__( 'Main Menu', 'blogmaster' ), ) ); // Add support for a featured image and the size add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 300, 300, true ); add_image_size( 'blogmaster-home', 731, 441, true ); add_image_size( 'blogmaster-single', 1170, 450, true ); add_image_size( 'blogmaster-slider-nav', 234, 131, true ); // Adds RSS feed links to for posts and comments. add_theme_support( 'automatic-feed-links' ); } endif; // Display a admin notices add_action( 'admin_notices', 'blogmaster_admin_notice' ); function blogmaster_admin_notice() { global $current_user; $user_id = $current_user->ID; /* Check that the user hasn't already clicked to ignore the message */ if ( !get_user_meta( $user_id, 'blogmaster_ignore_notice' ) ) { echo '

'; printf( __( 'Like Blogmaster theme? You will LOVE Blogmaster PRO! ', 'blogmaster' ) . '' . __( 'Click here for all the exciting features.', 'blogmaster' ) . '', '?blogmaster_notice_ignore=0' ); echo "

"; } } add_action( 'admin_init', 'blogmaster_notice_ignore' ); function blogmaster_notice_ignore() { global $current_user; $user_id = $current_user->ID; /* If user clicks to ignore the notice, add that to their user meta */ if ( isset( $_GET[ 'blogmaster_notice_ignore' ] ) && '0' == $_GET[ 'blogmaster_notice_ignore' ] ) { add_user_meta( $user_id, 'blogmaster_ignore_notice', 'true', true ); } } //////////////////////////////////////////////////////////////////// // Set Content Width //////////////////////////////////////////////////////////////////// function blogmaster_content_width() { $GLOBALS['content_width'] = apply_filters( 'blogmaster_content_width', 800 ); } add_action( 'after_setup_theme', 'blogmaster_content_width', 0 ); //////////////////////////////////////////////////////////////////// // Enqueue Styles (normal style.css and bootstrap.css) //////////////////////////////////////////////////////////////////// function blogmaster_theme_stylesheets() { wp_enqueue_style( 'blogmaster-bootstra-css', get_template_directory_uri() . '/css/bootstrap.css', array(), '1', 'all' ); wp_enqueue_style( 'blogmaster-stylesheet', get_stylesheet_uri(), array(), '1', 'all' ); // load Font Awesome css wp_enqueue_style( 'blogmaster-font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css' ); // load Flexslider css wp_enqueue_style( 'blogmaster-flexslider-css', get_template_directory_uri() . '/css/flexslider.css', 'style' ); } add_action( 'wp_enqueue_scripts', 'blogmaster_theme_stylesheets' ); //////////////////////////////////////////////////////////////////// // Register Bootstrap JS with jquery //////////////////////////////////////////////////////////////////// function blogmaster_theme_js() { wp_enqueue_script( 'blogmaster-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ) ); wp_enqueue_script( 'blogmaster-theme-js', get_template_directory_uri() . '/js/customscript.js', array( 'jquery' ) ); wp_enqueue_script( 'blogmaster-flexslider-js', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'blogmaster_theme_js' ); //////////////////////////////////////////////////////////////////// // Register Custom Navigation Walker include custom menu widget to use walkerclass //////////////////////////////////////////////////////////////////// require_once('lib/wp_bootstrap_navwalker.php'); //////////////////////////////////////////////////////////////////// // Theme Info page //////////////////////////////////////////////////////////////////// if ( is_admin() ) { require_once(trailingslashit( get_template_directory() ) . '/lib/theme-info.php'); } //////////////////////////////////////////////////////////////////// // Register the Sidebar(s) //////////////////////////////////////////////////////////////////// add_action( 'widgets_init', 'blogmaster_widgets_init' ); function blogmaster_widgets_init() { register_sidebar( array( 'name' => __( 'Right Sidebar', 'blogmaster' ), 'id' => 'blogmaster-right-sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Left Sidebar', 'blogmaster' ), 'id' => 'blogmaster-left-sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Front Page: Content Top Section', 'blogmaster' ), 'id' => 'blogmaster-front-page-content-section', 'description' => __( 'Content Top Section', 'blogmaster' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Area After First Post', 'blogmaster' ), 'id' => 'blogmaster-post-area', 'description' => __( 'Suitable for text widget.', 'blogmaster' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } //////////////////////////////////////////////////////////////////// // Register hook and action to set Main content area col-md- width based on sidebar declarations //////////////////////////////////////////////////////////////////// add_action( 'blogmaster_main_content_width_hook', 'blogmaster_main_content_width_columns' ); function blogmaster_main_content_width_columns() { $columns = '12'; if ( get_theme_mod( 'rigth-sidebar-check', 1 ) != 0 ) { $columns = $columns - absint( get_theme_mod( 'right-sidebar-size', 3 ) ); } if ( get_theme_mod( 'left-sidebar-check', 0 ) != 0 ) { $columns = $columns - absint( get_theme_mod( 'left-sidebar-size', 3 ) ); } echo $columns; } function blogmaster_main_content_width() { do_action( 'blogmaster_main_content_width_hook' ); } if ( !function_exists( 'blogmaster_breadcrumb' ) ) : //////////////////////////////////////////////////////////////////// // Breadcrumbs //////////////////////////////////////////////////////////////////// function blogmaster_breadcrumb() { global $post, $wp_query; $home = esc_html__( 'Home', 'blogmaster' ); $delimiter = ' » '; $homeLink = home_url(); if ( is_home() || is_front_page() ) { // no need for breadcrumbs in homepage } else { echo ''; } } endif; //////////////////////////////////////////////////////////////////// // Meta functions //////////////////////////////////////////////////////////////////// function blogmaster_comments() { global $post; $args = array( 'number' => '1', 'post_id' => $post->ID, ); $comments = get_comments( $args ); $commentslink = get_comments_link( $post->ID ); if ( !empty( $comments ) ) { foreach ( $comments as $comment ) : $length = 80; // adjust to needed length $thiscomment = $comment->comment_content; if ( strlen( $thiscomment ) > $length ) { $thiscomment = substr( $thiscomment, 0, $length ); $thiscomment = $thiscomment . '...'; } echo '' . esc_html__( 'By: ', 'blogmaster' ) . '', ( esc_attr( $comment->comment_author ) . '

' . esc_attr( $thiscomment ) . '

' ); endforeach; } else { echo '

' . esc_html__( 'No comments', 'blogmaster' ) . '

'; } echo '

' . esc_html__( 'Add your comment', 'blogmaster' ) . '

'; } function blogmaster_comments_count() { global $post; $args = array( 'post_id' => $post->ID, 'count' => true ); $comments = get_comments( $args ); echo absint( $comments ); }