芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/backup/gerard-philippe-peinture.fr/wp-content/themes/saral/functions.php
'; var_dump($data); echo ''; } function d($data = null){ p($data); die(); } } include( get_template_directory() . '/admin/theme-options.php'); get_template_part('framework/saral-config'); if ( ! isset( $content_width ) ) { $content_width = 600; } if ( ! function_exists( 'saral_setup' ) ) : function saral_setup() { load_theme_textdomain( 'saral' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'custom-header' ); add_theme_support( 'custom-background' ); add_theme_support( 'woocommerce' ); add_editor_style( array( 'css/editor-style.css') ); /*-------- register images sizes ---------*/ add_image_size( 'saral_standard', 940, 640, array( 'center', 'top')); add_image_size( 'saral_medium', 600, 322, array( 'center', 'top')); add_image_size( 'saral_100x100', 100, 100, array( 'center', 'top')); } endif; // saral_setup add_action( 'after_setup_theme', 'saral_setup' ); /*-------------- Function to register the theme menu --------------------*/ register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu','saral' ), )); /*----- saral custom Pagination function -----*/ if(!function_exists('saral_custom_pagination')){ function saral_custom_pagination($numpages = '', $pagerange = '', $paged='') { if (empty($pagerange)) { $pagerange = 2; } global $paged; if (empty($paged)) { $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; } if ($numpages == '') { global $wp_query; $numpages = $wp_query->max_num_pages; if(!$numpages) { $numpages = 1; } } $pagination_args = array( 'base' => add_query_arg('paged','%#%'), 'format' => '?paged=%#%', 'total' => $numpages, 'current' => $paged, 'show_all' => true, 'end_size' => 1, 'mid_size' => $pagerange, 'prev_next' => True, 'prev_text' => '
', 'next_text' => '
', 'type' => 'list', 'add_args' => false, 'add_fragment' => '' ); $paginate_links = paginate_links($pagination_args); if ($paginate_links) { echo "
".$paginate_links."
"; } } } /*------------ function to get the sidebar ----------*/ function saral_site_sidebar(){ global $saral_options; $pid = get_queried_object_id(); if($saral_options['enable_sidebar']): $global_enable_sidebar='show'; else: $global_enable_sidebar='hide'; endif; $sidebar['show'] = (get_post_meta($pid,'saral_enable_sidebar', true) != 'default' && get_post_meta($pid,'saral_enable_sidebar', true)) ? get_post_meta($pid,'saral_enable_sidebar', true) : $global_enable_sidebar; $sidebar['name'] = (get_post_meta($pid,'saral_sidebar_name', true) != 'default' && get_post_meta($pid,'saral_sidebar_name', true) ) ? get_post_meta($pid,'saral_sidebar_name', true) : $saral_options['sidebar_type']; $sidebar['posi'] = (get_post_meta($pid,'saral_sidebar_position', true) != 'default') && get_post_meta($pid,'saral_sidebar_position', true) ? get_post_meta($pid,'saral_sidebar_position', true) : $saral_options['sidebar_position']; if($sidebar['show'] == 'show' && is_active_sidebar($sidebar['name'])): $sidebar['show'] = 1; $sidebar['class'] = "col-xs-12 col-sm-12 col-md-8 col-lg-8 content-at-".$sidebar['posi']; else: $sidebar['class'] = 'col-xs-12 col-sm-12 col-md-12 col-lg-12'; endif; return $sidebar; } /*------- function for kses element array ------*/ function saral_kses_array(){ $ele = array( 'a' => array( 'href' => array(), 'title' => array(), 'target' => array(), 'class' => array(), ), 'code' =>array(), 'br' => array(), 'em' => array(), 'strong' => array(), 'span' => array('class' => array()) ); return $ele; } /*-------------- Function to return excerpt out of content --------------------*/ if(!function_exists('saral_content_excerpt')){ function saral_content_excerpt($post_id, $word_length = 140, $read_more_link = false, $strip_tags='yes') { global $saral_options; $post = get_post($post_id); $con = sanitize_post_field( 'post_content', $post->post_content, $post->ID, 'display' ); $content = strip_tags(apply_filters( 'the_content', $con )); $excerpt = ''; if( $post->post_excerpt ) { $excerpt .= esc_html(wp_trim_words(strip_tags($post->post_excerpt),$word_length,'')); }elseif (!empty($post->post_content)) { $excerpt .= esc_html(wp_trim_words($content, $word_length,'...')); } $p_excerpt = '
'.$excerpt.'
'; if($read_more_link){ $read_more = $saral_options['show_listing_link']; $read_more_text = $saral_options['read_more_text']; switch($read_more){ case 'link': $p_excerpt .= "
".esc_html($read_more_text)."
"; break; case 'icon': $p_excerpt .= "
"; break; } } return $p_excerpt; } } /*--------- Function to upload the admin scripts --------*/ if( !function_exists( 'saral_admin_scripts' ) ): function saral_admin_scripts(){ $url = get_template_directory_uri().'/framework/admin'; wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('upload_media_widget', $url.'/js/upload-script.js', array('jquery')); wp_enqueue_style('thickbox'); wp_enqueue_style( 'saral-admin-style', $url.'/css/saral-admin.css'); } add_action('admin_enqueue_scripts','saral_admin_scripts'); endif; /*-------------- Function to register scripts and styles used in theme --------------------*/ if( !function_exists( 'saral_reg_scripts' ) ): function saral_reg_scripts() { global $saral_options; $apikey = isset($saral_options['google_api_key']) ? $saral_options['google_api_key'] : 'AIzaSyDrd1DkT-tKFR0HHCSqS3GWaDgo911NAE0'; $url = get_template_directory_uri().'/js'; /*------ header scripts -------*/ $theme_info = wp_get_theme(); /*---------- footer scripts --------*/ if($apikey!=''): wp_register_script('google-map', 'https://maps.googleapis.com/maps/api/js?key='.$apikey.'&v=3.exp', array('jquery') , $theme_info->get('Version'), true ); wp_enqueue_script('google-map'); endif; wp_register_script('saral-js-libs', $url.'/js-libs.js', array('jquery'), $theme_info->get('Version'), true ); wp_enqueue_script('saral-js-libs'); wp_register_script('saral-main', $url.'/main.js', array('jquery'), $theme_info->get('Version'), true ); wp_enqueue_script('saral-main'); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } saral_reg_styles($theme_info); } add_action('wp_enqueue_scripts', 'saral_reg_scripts', 1000 ); endif; /*-------------- Function to register the css files --------------------*/ if(!function_exists('saral_reg_styles')){ function saral_reg_styles($theme_info){ $url = get_template_directory_uri(); wp_enqueue_style( 'slick', $url.'/css/slick.css'); wp_enqueue_style( 'slimmenu.min', $url.'/css/slimmenu.min.css'); wp_enqueue_style( 'magnific-popup', $url.'/css/magnific-popup.css'); wp_enqueue_style( 'font-awesome', $url.'/css/font-awesome.min.css'); wp_enqueue_style( 'saral-stylesheet', get_stylesheet_uri(), array(), $theme_info->get( 'Version' ) ); } } /*---------- Function to call on wp_head hook ---------*/ if(!function_exists('saral_header_code')): function saral_header_code() { global $saral_options; if(!empty($saral_options['code_before_head'])){ echo ($saral_options['code_before_head']); } $css_output = "\n\n"; if ( !empty( $css_output ) ){ echo ($css_output); } if ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ) { if($saral_options['favicon']['url']): echo '
'; endif; } } add_action( 'wp_head', 'saral_header_code' ); endif; /*----------- Function to call on wp_footer hook ------------*/ if(!function_exists('saral_footer_code')): function saral_footer_code(){ global $saral_options; if(!empty($saral_options['code_before_body'])){ echo ($saral_options['code_before_body']); } } add_action( 'wp_footer', 'saral_footer_code' ); endif; /*------- function to add body class --------*/ function saral_body_class($classes){ global $woocommerce, $saral_options, $post, $saral_site_width; $classes[] = 'saral-container-'.$saral_site_width; return $classes; } add_filter( 'body_class', 'saral_body_class' ); /*---------- Function to set global variables ---------*/ function saral_width_globals(){ global $woocommerce, $saral_options, $post, $saral_site_width; $object_id = get_queried_object_id(); $saral_site_width = $saral_options['site_layout']; if(is_singular()): if(get_post_meta($post->ID, 'saral_site_layout', true)!='default' && get_post_meta($post->ID, 'saral_site_layout', true) !='' && is_singular()): $saral_site_width = get_post_meta($post->ID, 'saral_site_layout', true); endif; endif; /*----- control title bar and side width on woocommerce pages ------*/ if(is_singular(array('saral_team_member')) ) { $saral_site_width = 'full'; } } add_action( 'wp', 'saral_width_globals' ); /*------- function to get the post meta -------*/ if ( ! function_exists( 'saral_post_meta' ) ) : function saral_post_meta( $date= 'yes', $author = 'yes', $category = 'no' ){ echo '
'; if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) && $date == 'yes' ) { echo '
'; saral_entry_date(); echo '
'; } if ( 'post' === get_post_type() && $author == 'yes' ) { $author_avatar_size = apply_filters( 'saral_author_avatar_size', 49 ); printf( '
'.esc_html__('By:', 'saral').'
%2$s
', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ); } echo '
'; if ( 'post' === get_post_type() && $category == 'yes') { saral_entry_taxonomies(); } } endif; /*------- function to get the entry date of the post ---------*/ if ( ! function_exists( 'saral_entry_date' ) ) : function saral_entry_date() { $time_string = '
%2$s
'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '
%2$s
'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), get_the_date() ); $url = ('post' === get_post_type() && get_the_title() !='' ? get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j')) : get_permalink() ); printf( '
%1$s
%3$s
', _x( 'Posted on', 'Used before publish date.', 'saral' ), esc_url( $url ), $time_string ); } endif; /*------- function to get the post category ---------*/ if ( ! function_exists( 'saral_entry_taxonomies' ) ) : function saral_entry_taxonomies() { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'saral' ) ); echo "
".esc_html__('Categories: ', 'saral').$categories_list."
"; } endif; /*------ function to check the categorised blog -------*/ function saral_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'saral_categories' ) ) ) { $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'number' => 2, ) ); $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'saral_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { return true; } else { return false; } } /*------ function to flushes out the transients used in saral_categorized_blog() ------*/ function saral_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } delete_transient( 'saral_categories' ); } add_action( 'edit_category', 'saral_category_transient_flusher' ); add_action( 'save_post', 'saral_category_transient_flusher' ); /*--------- Function to get the comment count and dte for the post ----------*/ if ( ! function_exists( 'saral_post_grid_info' ) ) : function saral_post_grid_info( $comment= true ,$show_date= true ) { if( $show_date || $comment){ echo '
'; if($show_date){ saral_entry_date(); } if($comment){ if ( comments_open() ) : echo '
'; comments_popup_link( 'No comments', '1 comment', '% comments', 'comments-link', 'Comments are off for this post'); endif; } echo '
'; } } endif; /*----- function to get the saral meta info----*/ if ( ! function_exists( 'saral_blog_meta_info' ) ) : function saral_blog_meta_info($author= true ,$category= true ){ if( $author || $category){ if($author){ $author_avatar_size = apply_filters( 'saral_author_avatar_size', 49 ); printf( '
'.esc_html__('By:', 'saral').'
%2$s
', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ); } if($category){ saral_entry_taxonomies(); } } } endif; /*-------- Remove redux notices -------*/ function saral_removeDemoModeLink() { if ( class_exists('ReduxFrameworkPlugin') ) { remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 ); } if ( class_exists('ReduxFrameworkPlugin') ) { remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) ); } } add_action('init', 'saral_removeDemoModeLink'); ob_start(); ?>