__( 'Header Menu', 'yydevelopment-basic' ), ) ); // ---------------------------------------------------------------------------- // This feature adds RSS feed links to HTML // ---------------------------------------------------------------------------- add_theme_support( 'automatic-feed-links' ); // ---------------------------------------------------------------------------- // This function addes to the site header // ---------------------------------------------------------------------------- add_theme_support( "title-tag" ); // ---------------------------------------------------------------------------- // Adding the option to add custom background and css to the theme // ---------------------------------------------------------------------------- $args = array( 'default-color' => '', 'default-image' => '', ); add_theme_support( 'custom-background', $args ); // ---------------------------------------------------------------------------- // adding the option to add header background image // ---------------------------------------------------------------------------- if( !is_active_sidebar('yydev-header') ) { $args = array( 'width' => 1200, 'height' => 150, 'default-image' => '', ); add_theme_support( 'custom-header', $args ); } // if( !is_active_sidebar('yydev-header') ) { // ---------------------------------------------------------------------------- // This feature adds the option to set excerpt in pages and blog posts // ---------------------------------------------------------------------------- add_post_type_support( 'page', 'excerpt' ); // ---------------------------------------------------------------------------- // Adding the option to add featured images on posts and pages // ---------------------------------------------------------------------------- add_theme_support( 'post-thumbnails' ); // ---------------------------------------------------------------------------- // enabling shortcode in widgets // ---------------------------------------------------------------------------- add_filter( 'widget_text', 'do_shortcode' ); // ---------------------------------------------------------------------------- // This function allow us to control the resize of images on the theme // should be set as the max width of the images on page // ---------------------------------------------------------------------------- if ( ! isset( $content_width ) ) { $content_width = 1200; } // if ( ! isset( $content_width ) ) { // ---------------------------------------------------------------------------- // Allow to add formats to the pages // ---------------------------------------------------------------------------- add_theme_support( 'post-formats', array('video') ); // add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat' ) ); // ---------------------------------------------------------------------------- // Checking if sidebar registered and set class // $sidebar = the sidebar we want to load 'sidebar' is the default value // ---------------------------------------------------------------------------- function yydev_theme_check_active_sidebar($sidebar = 'sidebar') { $right_side_class = ''; if( is_active_sidebar( $sidebar ) ) { $right_side_class = "main-content-warp"; } // if( is_active_sidebar( $sidebar ) ) { return $right_side_class; } // function yydev_theme_check_active_sidebar($yydev_theme_data['yy_pages_sidebar']) { // ---------------------------------------------------------------------------- // This code will allow us to make changes to the blog excerpt // ---------------------------------------------------------------------------- // ----------------------------------------- // Changing the text for the read more button // ----------------------------------------- function yydev_theme_new_excerpt_more($more) { global $post; global $excerpt_read_text; return ' <a href="'. get_permalink($post->ID) . '">' . __('Read More...', 'yydevelopment-basic') . '</a>'; } // function yydev_theme_new_excerpt_more($more) { add_filter('excerpt_more', 'yydev_theme_new_excerpt_more'); // ----------------------------------------- // Changing the amount of word that will display in the excerpt // ----------------------------------------- $yy_excerpt_words_count = $yydev_theme_data['yy_excerpt_words_count']; // set the amount of words to display function yydev_theme_custom_excerpt_length( $length ) { global $yy_excerpt_words_count; return $yy_excerpt_words_count; } // function yydev_theme_custom_excerpt_length( $length ) { add_filter( 'excerpt_length', 'yydev_theme_custom_excerpt_length', 999 ); // ---------------------------------------------------------------------------- // Remove unnecessary code from the <head> in the pages // ---------------------------------------------------------------------------- remove_action('wp_head', 'rsd_link'); // ---------------------------------------------------------------------------- // Remove wordpress version from the page // ---------------------------------------------------------------------------- function yydev_theme_remove_wordpress_version() { return ''; } add_filter('the_generator', 'yydev_theme_remove_wordpress_version'); // ---------------------------------------------------------------------------- // Remove Wordpress emoji code // ---------------------------------------------------------------------------- remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); // ---------------------------------------------------------------------------- // Adding the page number in header <title> to categories and tags // ---------------------------------------------------------------------------- function yydev_theme_name_wp_title( $title, $sep ) { if ( is_feed() ) { return $title; } global $page, $paged; // Add the blog name $title .= get_bloginfo( 'name', 'display' ); // Add a page number if necessary: if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { $title .= " $sep " . sprintf( __( 'Page %s', 'yydevelopment-basic' ), max( $paged, $page ) ); } // if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { return $title; } // function yydev_theme_name_wp_title( $title, $sep ) { add_filter( 'wp_title', 'yydev_theme_name_wp_title', 10, 2 ); // ---------------------------------------------------------------------------- // This function allow us to have pages navigation on the blog page. // The amount of post on each page is set from the admin panel // ---------------------------------------------------------------------------- function yydev_theme_show_pages($output = true) { global $wp_query; $big = 999999999; // need an unlikely integer $pages_output = ""; $pages_output .= "<div class='theme-pagination blog-posts-pages no-smooth-scroll'>"; $pages_output .= paginate_links( array( // 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => 'page/%#%/', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages, 'prev_text' => "«", 'next_text' => "»", 'show_all' => true, ) ); $pages_output .= "</div><!--blog-posts-pages-->"; if( $output ) { echo $pages_output; } else { // if( $output ) { return $pages_output; } // } else { // if( $output ) { } // function yydev_theme_show_pages($output = true) { // ---------------------------------------------------------------------------- // This function will alow to create pages within pages and posts // ---------------------------------------------------------------------------- function yydev_theme_link_pages($output = true) { $pages_output = wp_link_pages( array( 'before' => '<div class="theme-pagination inner-posts-pages no-smooth-scroll">' . __( 'Pages:', 'yydevelopment-basic' ), 'after' => '</div><!--blog-posts-pages-->', 'echo' => false, 'previouspagelink' => "«", 'nextpagelink' => "»", ) ); if( $output ) { echo $pages_output; } else { // if( $output ) { return $pages_output; } // } else { // if( $output ) { } // function yydev_theme_link_pages($output = true) { // ---------------------------------------------------------------------------- // prevet wordpress from creating images in diffferent sizes when uploading images into the media library // ---------------------------------------------------------------------------- if( $yydev_theme_data['yy_stop_wp_images_resize'] == 1 ) { add_filter( 'intermediate_image_sizes', '__return_empty_array', 999 ); } // if( $yydev_theme_data['yy_stop_wp_images_resize'] == 1 ) { // ======================================================================================================================================================== // Include comments related functions // ======================================================================================================================================================== // ---------------------------------------------------------------------------- // Force opened comments on regular pages with // ---------------------------------------------------------------------------- function open_comments_on_static_blog_page( $open, $post_id ) { // getting the custom template path $custom_template_name = get_page_template_slug($post_id); global $yydev_theme_data; $page_layout = ''; if( isset($yydev_theme_data['yy_pages_display_output']) ) { if( $yydev_theme_data['yy_comments_on_custom_blog_page'] == 1 ) { $page_layout = $yydev_theme_data['yy_pages_display_output']; } // if( $yydev_theme_data['yy_comments_on_custom_blog_page'] == 1 ) { } // if( isset($yydev_theme_data['yy_pages_display_output']) ) { // checking if it's a custom blog page if( $page_layout === "blog_page" ) { $open = true; } // if( $page_layout === "blog_page" ) { return $open; } // function open_comments_on_static_blog_page( $open, $post_id ) { add_filter( 'comments_open', 'open_comments_on_static_blog_page', 10, 2 ); // ---------------------------------------------------------------------------- // This function will make comments links // open in new window. adding target="_blank" // ---------------------------------------------------------------------------- function yydev_theme_comment_links_in_new_tab($text) { $return = str_replace('<a', '<a target="_blank"', $text); return $return; } // function yydev_theme_comment_links_in_new_tab($text) { add_filter( 'get_comment_author_link', 'yydev_theme_comment_links_in_new_tab' ); add_filter( 'comment_text', 'yydev_theme_comment_links_in_new_tab' ); // ---------------------------------------------------------------------------- // Move the comment textarea field to the // bottom after name and email // ---------------------------------------------------------------------------- function yydev_theme_move_comment_to_bottom($fields) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } // function yydev_theme_move_comment_to_bottom($fields) { add_filter( 'comment_form_fields', 'yydev_theme_move_comment_to_bottom' ); // ---------------------------------------------------------------------------- // reCreate new comments structure and display it on the page // ---------------------------------------------------------------------------- function mytheme_comment($comment, $args, $depth) { // define the html type of comment if ( 'div' === $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { // if ( 'div' === $args['style'] ) { $tag = 'li'; $add_below = 'div-comment'; } // } else { // if ( 'div' === $args['style'] ) { $comments_output = ''; // -------------------------------------- // starting to create the comments code // -------------------------------------- // getting the comments output class we are checking // it to see if it's child comment or the main div wrap $comment_class = ""; if( !empty( $args['has_children']) ) { $comment_class = get_comment_class('parent'); $comment_class = implode(" ", $comment_class); $comment_class = " class='" . $comment_class . "' "; } // if( !empty( $args['has_children']) ) { $comment_id = " id='comment-" . get_comment_ID() . "'"; // starying to create the open <div> or <li> tag $comments_output .= "<" . $tag . $comment_class . $comment_id . ">"; if( $args['style'] != 'div' ) { $comments_output .= "<div id='div-comment-" . get_comment_ID() . "' class='comment-body'>"; } // if( $args['style'] != 'div' ) { // -------------------------------------- // creating the comments head part // -------------------------------------- $comments_output .= "<div class='comment-top-header'>"; // getting the author image avatar $comments_output .= "<div class='comment-main-content-warp'>"; $comments_output .= "<div class='comment-author vcard'>"; if( $args['avatar_size'] != 0 ) { $comments_output .= get_avatar( $comment, $args['avatar_size'] ); } // if( $args['avatar_size'] != 0 ) { $comments_output .= "</div><!--comment-author vcard-->"; $comments_output .= "</div><!--comment-main-content-warp-->"; // getting the author name and date $comments_output .= "<div class='comment-left-side'>"; // author name and link $comments_output .= "<cite class='comment-writer-name fn author'>"; $comments_output .= get_comment_author_link(); $comments_output .= "</cite>"; // date and comment link $comments_output .= "<div class='comment-meta commentmetadata'>"; $comments_output .= "<a href='" . htmlspecialchars( get_comment_link( $comment->comment_ID ) ) . "'>"; $comments_output .= get_comment_date() . " " . __('at', 'yydevelopment-basic') . " " . get_comment_time(); $comments_output .= "</a>"; // creating editing button $comments_output .= " <a class='comment-edit-link' href='" . get_edit_comment_link() . "'>" . __('(Edit)', 'yydevelopment-basic') . "</a>"; $comments_output .= "</div><!--comment-meta-->"; $comments_output .= "</div><!--comment-left-side-->"; $comments_output .= "<div class='clear'></div>"; $comments_output .= "</div><!--comment-top-header-->"; // if the comments wasn't approve automatically we will // show message saying the comment will be approve by admin if( $comment->comment_approved == '0' ) { $comments_output .= "<em class='comment-awaiting-moderation'>" . __('Your comment is pending admin approval before it will appears on the site', 'yydevelopment-basic') . "</em>"; $comments_output .= "<br />"; } // if( $comment->comment_approved == '0' ) { // creating the comment text body $comments_output .= "<div class='comment-text'>"; $comments_output .= "<p>" . get_comment_text() . "<br />"; // comments reply link $comments_output .= "<div class='reply'>"; $comments_output .= get_comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); $comments_output .= "</div><!--reply-->"; $comments_output .= "</div><!--comment-text-->"; if( $args['style'] != 'div' ) { $comments_output .= "</div>"; } // if( $args['style'] != 'div' ) { // -------------------------------------- // echoing the comments output to the page // -------------------------------------- echo $comments_output; } // function mytheme_comment($comment, $args, $depth) { // ======================================================================================================================================================== // Include theme widgets file // ======================================================================================================================================================== // ---------------------------------------------------------------------------- // Adding Header Widget // ---------------------------------------------------------------------------- function yydev_theme_register_header_widget() { register_sidebar( array( 'name' => __( 'Top Header', 'yydevelopment-basic' ), 'id' => 'yydev-header', 'description' => __( 'Insert the code you want to show up on the site header. Adding code here will replace the default header.', 'yydevelopment-basic' ), 'before_widget' => '<div class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widgettitle">', 'after_title' => '</h5>', )); } // function theme_slug_widgets_init() { add_action( 'widgets_init', 'yydev_theme_register_header_widget' ); // ---------------------------------------------------------------------------- // Adding Footer Widget // ---------------------------------------------------------------------------- function yydev_theme_register_footer_widget() { register_sidebar( array( 'name' => __( 'Website Footer', 'yydevelopment-basic' ), 'id' => 'yydev-footer', 'description' => __( 'Insert the code you want to show up on the site footer. Adding code here will replace the default footer.', 'yydevelopment-basic' ), 'before_widget' => '<div class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widgettitle">', 'after_title' => '</h5>', )); } // function theme_slug_widgets_init() { add_action( 'widgets_init', 'yydev_theme_register_footer_widget' ); // ---------------------------------------------------------------------------- // Adding Sidebar1 Widget // ---------------------------------------------------------------------------- function yydev_theme_register_sidbar_widget() { register_sidebar( array( 'name' => __( 'Website Sidebar1', 'yydevelopment-basic' ), 'id' => 'sidebar', 'description' => __( 'Insert the content you want to show up on the site sidebar.', 'yydevelopment-basic' ), 'before_widget' => '<section class="%2$s sidebar-widget">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', )); } // function theme_slug_widgets_init() { add_action( 'widgets_init', 'yydev_theme_register_sidbar_widget' ); // ---------------------------------------------------------------------------- // Adding Sidebar2 Widget // ---------------------------------------------------------------------------- function yydev_theme_register_sidbar2_widget() { register_sidebar( array( 'name' => __( 'Website Sidebar 2', 'yydevelopment-basic' ), 'id' => 'sidebar2', 'description' => __( 'Insert the content you want to show up on the site sidebar.', 'yydevelopment-basic' ), 'before_widget' => '<section class="%2$s sidebar-widget">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', )); } // function theme_slug_widgets_init() { add_action( 'widgets_init', 'yydev_theme_register_sidbar2_widget' ); // ---------------------------------------------------------------------------- // Adding Sidebar3 Widget // ---------------------------------------------------------------------------- function yydev_theme_register_sidbar1_widget() { register_sidebar( array( 'name' => __( 'Website Sidebar 3', 'yydevelopment-basic' ), 'id' => 'sidebar3', 'description' => __( 'Insert the content you want to show up on the site sidebar.', 'yydevelopment-basic' ), 'before_widget' => '<section class="%2$s sidebar-widget">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>', )); } // function theme_slug_widgets_init() { add_action( 'widgets_init', 'yydev_theme_register_sidbar1_widget' ); // ======================================================================================================================================================== // Loading functuions that effect wordpress plugins // ======================================================================================================================================================== // ---------------------------------------------------------------------------------- // Yoast SEO Functions // ---------------------------------------------------------------------------------- if ( function_exists('yoast_breadcrumb') ) { // ----------------------------------------- // remove the date from on yoast from blog posts // ----------------------------------------- function yydev_theme_modify_schema_graph_pieces( $data ) { unset($data['datePublished']); unset($data['dateModified']); return $data; } // function yoast_modify_schema_graph_pieces( $data ) { add_filter( 'wpseo_schema_article', 'yydev_theme_modify_schema_graph_pieces' ); add_filter( 'wpseo_schema_webpage', 'yydev_theme_modify_schema_graph_pieces' ); add_filter( 'wpseo_og_article_published_time', '__return_false' ); add_filter( 'wpseo_og_article_modified_time', '__return_false' ); add_filter( 'wpseo_og_og_updated_time', '__return_false' ); // ----------------------------------------- // change the output that yoast seo send when // we add %%page%% to the title on categories and tags // ----------------------------------------- function yydev_theme_filter_yoast_seo_pages_replacements( $replacements ) { if( isset( $replacements['%%page%%'] ) ){ $current_page_number = get_query_var('paged'); $replacements['%%page%%'] = '- ' . __( 'Page', 'yydevelopment-basic' ) . ' ' . $current_page_number; } return $replacements; }; // function yydev_theme_filter_yoast_seo_pages_replacements( $replacements ) { add_filter( 'wpseo_replacements', 'yydev_theme_filter_yoast_seo_pages_replacements', 10, 1 ); } // if ( function_exists('yoast_breadcrumb') ) { // ---------------------------------------------------------------------------------- // Advanced Custom Fields // ---------------------------------------------------------------------------------- // ----------------------------------------- // Getting back the wordpress custom field // after advance custom field plugin remove it // ----------------------------------------- add_filter('acf/settings/remove_wp_meta_box', '__return_false'); // ---------------------------------------------------------------------------------- // Visual Composer // ---------------------------------------------------------------------------------- // ----------------------------------------- // Remove visual_composer Powered by meta code generator // ----------------------------------------- function yydev_theme_myoverride() { if(function_exists('visual_composer')){ remove_action('wp_head', array(visual_composer(), 'addMetaData')); } // if(function_exists(visual_composer)){ } // function myoverride() { add_action('init', 'yydev_theme_myoverride', 100); // ============================================================================ // Dealing with wordpress theme, plugins, css and javascript files // ============================================================================ // ---------------------------------------------------------------------------- // Add style editor that will allow us to make change to TinyMCE in the backend // ---------------------------------------------------------------------------- add_editor_style( 'back-end/assets/css/style-editor.css' ); // ---------------------------------------------------------------------------- // Loading the theme main css file to the theme front-end // ---------------------------------------------------------------------------- function yydev_theme_register_theme_style_css( $content ) { // ---------------------------------------------- // getting all the theme settings data // ---------------------------------------------- global $yydev_theme_data; // ============================================================================ // Loading all the theme css files // ============================================================================ wp_register_style( 'yydev_theme_reset', esc_url(get_theme_file_uri('assets/css/wordpress-reset.css')) ); wp_enqueue_style( 'yydev_theme_reset' ); // -------------------------------------------- // choosing the correct blog type css file // ------------------------------------------- if( $yydev_theme_data['yy_blog_display_type'] === 'blog_line_posts' ) { // if the blog display type is line posts wp_register_style( 'yydev_theme_blog-posts', esc_url(get_theme_file_uri('assets/css/line-blog-posts.css')) ); wp_enqueue_style( 'yydev_theme_blog-posts' ); } else { // if( $yydev_theme_data['yy_blog_display_type'] === 'blog_line_posts' ) { // if the blog display type is column, and this is also the default option wp_register_style( 'yydev_theme_blog-posts', esc_url(get_theme_file_uri('assets/css/column-blog-posts.css')) ); wp_enqueue_style( 'yydev_theme_blog-posts' ); } // } else { // if( $yydev_theme_data['yy_blog_display_type'] === 'blog_line_posts' ) { // -------------------------------------------- // don't load unsessery code in blank page // ------------------------------------------- if( $yydev_theme_data['yy_pages_no_header_footer'] != 1 ) { wp_register_style( 'yydev_theme_header', esc_url(get_theme_file_uri('assets/css/header.css')) ); wp_enqueue_style( 'yydev_theme_header' ); wp_register_style( 'yydev_theme_footer', esc_url(get_theme_file_uri('assets/css/footer.css')) ); wp_enqueue_style( 'yydev_theme_footer' ); } // if( $yydev_theme_data['yy_pages_no_header_footer'] != 1 ) { // -------------------------------------------- // main style files // ------------------------------------------- wp_register_style( 'yydev_theme_style', esc_url(get_theme_file_uri('assets/css/style.css')) ); wp_enqueue_style( 'yydev_theme_style' ); // load LTR file incase it's english site if( !is_rtl() ) { wp_register_style( 'yydev_theme_ltr', esc_url(get_theme_file_uri('assets/css/ltr.css')) ); wp_enqueue_style( 'yydev_theme_ltr' ); } // if( !is_rtl() ) { } // function yydev_theme_register_theme_style_css( $content ) { add_action('wp_enqueue_scripts', 'yydev_theme_register_theme_style_css', 9999999); // ---------------------------------------------------------------------------- // Loading the theme main javascript file to the theme front-end // ---------------------------------------------------------------------------- function yydev_theme_register_theme_js( $content ) { wp_enqueue_script( 'yydev_theme_jquery', esc_url(get_theme_file_uri('assets/js/jquery-1.8.2.min.js')) ); wp_enqueue_script( 'yydev_theme_script', esc_url(get_theme_file_uri('assets/js/functions.js')) ); } // function yydev_theme_register_theme_js( $content ) { add_action('wp_enqueue_scripts', 'yydev_theme_register_theme_js', 9999999); // ---------------------------------------------------------------------------- // Loading the theme main css file to the theme back-end // ---------------------------------------------------------------------------- function yydev_theme_register_back_end_css() { wp_register_style('yydev_theme_backend_css', esc_url(get_theme_file_uri('back-end/assets/css/back-end-css.css')) ); wp_enqueue_style('yydev_theme_backend_css'); } //function yydev_theme_register_back_end_css() { add_action('admin_enqueue_scripts', 'yydev_theme_register_back_end_css'); // ---------------------------------------------------------------------------- // Remove type=text/javascript and type=text/css of some of the loading // elements to avoid W3C warnings // ---------------------------------------------------------------------------- function yydev_theme_remove_type_attr($tag, $handle) { return preg_replace( "%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $tag ); } // function yydev_theme_remove_type_attr($tag, $handle) { add_filter('style_loader_tag', 'yydev_theme_remove_type_attr', 10, 2); add_filter('script_loader_tag', 'yydev_theme_remove_type_attr', 10, 2); // ============================================================================ // Loading backend theme functions // ============================================================================ if( is_admin() ) { include( get_theme_file_path( 'back-end/theme-settings.php' ) ); } // if( is_admin() ) { ?>