get( 'Version' ); /** * Enqueue scripts and styles. */ function courtyard_scripts() { global $courtyard_version; // Add custom fonts, used in the main stylesheet. wp_enqueue_style( 'courtyard-fonts', courtyard_fonts_url(), array(), null ); // Load the Bootstrap library according to customizer control option. if ( get_theme_mod( 'courtyard_optimize_bootstrap_activate', '1' ) == 1 ) { // Enqueue Optimize Bootstrap Grid wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.optimized.min.css', array(), '3.3.7', '' ); } else { // Enqueue Bootstrap Grid wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.7', '' ); } // Enqueue animate css wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.min.css', array(), '3.5.1', '' ); // Enqueue FontAwesome wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.7.0', '' ); // Enqueue elegant_font wp_enqueue_style( 'elegant-font', get_template_directory_uri() . '/css/elegant-font.custom.css', array(), '', '' ); // Enqueue Swiper.css wp_enqueue_style( 'swiper', get_template_directory_uri() . '/css/swiper.min.css', array(), '3.4.0', '' ); wp_enqueue_style( 'courtyard-style', get_stylesheet_uri() ); // Enqueue Swiper wp_enqueue_script( 'swiper', get_template_directory_uri() . '/js/swiper.jquery.min.js', array( 'jquery' ), '3.4.0', true ); // Custom JS wp_enqueue_script( 'courtyard-custom', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), $courtyard_version, true ); wp_enqueue_script( 'courtyard-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true ); wp_enqueue_script( 'courtyard-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'courtyard_scripts' ); /*--------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'courtyard_fonts_url' ) ) : /** * Register Google fonts for Courtyard. * * Create your own courtyard_fonts_url() function to override in a child theme. * * @return string Google fonts URL for the theme. */ function courtyard_fonts_url() { $fonts_url = ''; /** * Translators: If there are characters in your language that are not * supported by Roboto, translate this to 'off'. Do not translate * into your own language. */ $roboto_font = _x( 'on', 'Courgette|Roboto font: on or off', 'courtyard' ); if ( 'off' !== $roboto_font ) { $font_families = array(); $font_families[] = 'Courgette|Roboto:300,400,500,700'; $query_args = array( 'family' => urlencode( implode( '|', $font_families ) ), 'subset' => urlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); } return esc_url_raw( $fonts_url ); } endif; /*--------------------------------------------------------------------------------------------------*/ /** * Added customizer scripts */ function courtyard_admin_scripts( ) { global $courtyard_version; $pt_cScreen = get_current_screen(); if( $pt_cScreen->id === "customize" || $pt_cScreen->id === "widgets" ) { // Run some code, only on the admin customize and wigets page wp_enqueue_style( 'courtyard-admin-style', get_template_directory_uri() .'/css/admin/admin-style.css', $courtyard_version, '' ); // Image Uploader wp_enqueue_media(); wp_enqueue_script( 'courtyard-image-uploader', get_template_directory_uri() . '/js/admin/image-uploader.js', false, $courtyard_version, true ); // Color Picker wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'courtyard-color-picker', get_template_directory_uri() . '/js/admin/color-picker.js', array( 'wp-color-picker' ), $courtyard_version, true ); wp_enqueue_script( 'courtyard-customizer-script', get_template_directory_uri() .'/js/admin/customizer-scripts.js', array( 'jquery' ), $courtyard_version, true ); } if( $pt_cScreen->id === "page" ) { // Enqueue Custom Admin Script, only on the admin Page page. wp_enqueue_script( 'courtyard-admin-script', get_template_directory_uri() .'/js/admin/admin-scripts.js', array( 'jquery' ), $courtyard_version, true ); } } add_action('admin_enqueue_scripts', 'courtyard_admin_scripts'); /*--------------------------------------------------------------------------------------------------*/ /** * Footer credits */ function courtyard_footer_credits() { printf( __( 'Copyright © %1$s %3$s. %2$s.', 'courtyard' ), date('Y'), esc_html__('All rights reserved','courtyard'), '' . esc_html( get_bloginfo( 'name', 'display' ) ) . '' ); echo ' | '; printf( __( 'Designed by %2$s', 'courtyard' ), '', 'Precise Themes' ); } add_action( 'courtyard_footer', 'courtyard_footer_credits' ); /*--------------------------------------------------------------------------------------------------*/ /** * Excerpt length */ function courtyard_excerpt_length( $length ) { $excerpt = get_theme_mod('courtyard_blog_post_excerpt_length', '40'); return absint($excerpt); } add_filter( 'excerpt_length', 'courtyard_excerpt_length', 99 ); /*--------------------------------------------------------------------------------------------------*/ /** * Excerpt String . */ function courtyard_excerpt_more( $more ) { return '...'; } add_filter( 'excerpt_more', 'courtyard_excerpt_more' ); /*--------------------------------------------------------------------------------------------------*/ add_filter( 'manage_edit-page_columns', 'courtyard_page_columns' ); add_filter( 'parse_query', 'courtyard_page_by_template' ); add_action( 'manage_page_posts_custom_column', 'courtyard_render_page_columns' ); add_action( 'restrict_manage_posts', 'courtyard_template_filter' ); /** * Define custom columns for page. * @param array $existing_columns * @return array */ function courtyard_page_columns( $existing_columns ) { $new_column_list = array(); foreach($existing_columns as $key => $title) { if ($key=='author') // Put the Page Template column before the Author column $new_column_list['template'] = esc_html__( 'Page Template', 'courtyard' ); $new_column_list[$key] = $title; } return $new_column_list; } /** * Listing the page by page templates */ function courtyard_page_by_template($query) { global $pagenow; if ( isset( $_GET['courtyard_template_filter'] ) ) { if(is_admin() && $pagenow=='edit.php' && isset($_GET['post_type']) && isset($_GET['post_type'])=='page'){ $query->query_vars['meta_key'] = '_wp_page_template'; $query->query_vars['meta_value'] = $_GET['courtyard_template_filter']; } } } /** * Ouput custom columns for pages. * @param string $column */ function courtyard_render_page_columns( $column ){ global $post; if ( 'template' == $column ) { $page_templates = get_page_templates(); foreach ( $page_templates as $template_name => $template_filename ) { if ( $template_filename == get_page_template_slug( $post->ID ) ) { $template = $template_name; } } echo isset( $template ) ? esc_html( $template ) : esc_html__( 'Default Template', 'courtyard' ); } } /** * Page Templates Dropdown filter list. */ function courtyard_template_filter() { global $typenow; if( $typenow == 'page' ){ $pt_templates = wp_get_theme()->get_page_templates(); echo ''; } } /*--------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'courtyard_sidebar_layout_class' ) ) : /** * Generate layout class for sidebar based on customizer and post meta settings. */ function courtyard_sidebar_layout_class() { global $post; $layout = get_theme_mod( 'courtyard_blog_global_sidebar', 'right_sidebar' ); // Front page displays in Reading Settings $page_for_posts = get_option('page_for_posts'); // Get Layout meta if($post) { $layout_meta = get_post_meta( $post->ID, 'page_specific_layout', true ); } // Home page if Posts page is assigned if( is_home() && !( is_front_page() ) ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'page_specific_layout', true ); if( $layout_meta != 'default_layout' && $layout_meta != '' ) { $layout = get_post_meta( $queried_id, 'page_specific_layout', true ); } } elseif( is_page() ) { $layout = get_theme_mod( 'courtyard_page_global_sidebar', 'right_sidebar' ); if( $layout_meta != 'default_layout' && $layout_meta != '' ) { $layout = get_post_meta( $post->ID, 'page_specific_layout', true ); } } elseif( is_single() ) { $layout = get_theme_mod( 'courtyard_post_global_sidebar', 'right_sidebar' ); if( $layout_meta != 'default_layout' && $layout_meta != '' ) { $layout = get_post_meta( $post->ID, 'page_specific_layout', true ); } } return esc_html( $layout ); } endif; /*--------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'courtyard_primary_sidebar' ) ) : /** * Select and show sidebar based on post meta and customizer default settings */ function courtyard_primary_sidebar() { $layout = courtyard_sidebar_layout_class(); if ( $layout == "right_sidebar" ) { $classes = 'col-md-8'; } elseif ( $layout == "left_sidebar" ) { $classes = 'col-md-8 pull-right'; } elseif ( $layout == "no_sidebar_full_width" ) { $classes = 'col-md-12'; } return esc_html( $classes ); } endif; /*--------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'courtyard_secondary_sidebar' ) ) : /** * Select and show sidebar based on post meta and customizer default settings */ function courtyard_secondary_sidebar() { $layout = courtyard_sidebar_layout_class(); if ( $layout == "right_sidebar" ) { $classes = 'col-md-4 '; } elseif ( $layout == "left_sidebar" ) { $classes = 'col-md-4 pull-left'; } elseif ( $layout == "no_sidebar_full_width" ) { $classes = 'col-md-12'; } return esc_html( $classes ); } endif; /*---------------------------------------------------------------------------------------------------------------*/ if ( ! function_exists( 'courtyard_sidebar_select' ) ) : /** * Select and show sidebar based on post meta and customizer default settings */ function courtyard_sidebar_select() { $layout = courtyard_sidebar_layout_class(); if( $layout != "no_sidebar_full_width" ) { if ( $layout == "right_sidebar" || $layout = "left_sidebar" || $layout = "default_layout" ) { echo '
'; } } } endif; /*--------------------------------------------------------------------------------------------------*/ if ( ! function_exists ( 'courtyard_listing_pagination' ) ) : function courtyard_listing_pagination( $total ) { /** * We construct the pagination arguments to enter into our paginate_links * function. */ $big = 999999999; // need an unlikely integer $pagination_args = array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $total ); if ( paginate_links($pagination_args) ) { echo '