__( 'Sidebar', 'bpro' ), 'id' => 'sidebar', 'description' => __( 'Widgets in this area will be shown in the sidebar.', 'bpro' ), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' )); } // Add theme widgets require_once (get_template_directory() . "/widgets/flickr-widget.php"); require_once (get_template_directory() . "/widgets/recent-comments.php"); require_once (get_template_directory() . "/widgets/recent-posts.php"); // Delist the default WordPress widgets replaced by custom theme widgets add_action('widgets_init', 'bpro_unregister_default_widgets', 11); function bpro_unregister_default_widgets() { unregister_widget('WP_Widget_Recent_Comments'); unregister_widget('WP_Widget_Recent_Posts'); } // Check whether the browser supports JavaScript add_action( 'wp_head', 'bpro_html_js_class', 1 ); function bpro_html_js_class () { echo ''. "\n"; } // Archive navigation function function bpro_archive_navigation() { global $wp_query; if ( $wp_query->max_num_pages > 1 ) : ?>
' . get_previous_posts_link( '← ' . __('Previous', 'bpro')) . ''; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } /** Link to first page, plus ellipses if necessary */ if ( ! in_array( 1, $links ) ) { $class = 1 == $paged ? ' active' : ''; printf( '
  • %s
  • ' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) echo '
  • ...
  • '; } /** Link to current page, plus 2 pages in either direction if necessary */ sort( $links ); foreach ( (array) $links as $link ) { $class = $paged == $link ? ' active' : ''; printf( '
  • %s
  • ' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); } /** Link to last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) echo '
  • ...
  • ' . "\n"; $class = $paged == $max ? ' active' : ''; printf( '
  • %s
  • ' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); } if ( get_next_posts_link() ) echo '
  • ' . get_next_posts_link( __('Next', 'bpro') . ' →') . '
  • '; ?>
    ' . __('Read More','bpro') . '

    '; } // Add body class if is_single and has_featured_image add_filter('body_class','bpro_is_single_featured_image'); function bpro_is_single_featured_image( $classes ){ if ( is_single() && has_post_thumbnail() ){ $classes[] = 'has-featured-image'; } return $classes; } // Get comment excerpt length function bpro_get_comment_excerpt($comment_ID = 0, $num_words = 20) { $comment = get_comment( $comment_ID ); $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > $num_words) { $k = $num_words; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); } // Style the admin area add_action('admin_head', 'bpro_admin_area_style'); function bpro_admin_area_style() { echo ' '; } // Flexslider function for format-gallery function bpro_flexslider($size) { if ( is_page()) : $attachment_parent = $post->ID; else : $attachment_parent = get_the_ID(); endif; if($images = get_posts(array( 'post_parent' => $attachment_parent, 'post_type' => 'attachment', 'numberposts' => -1, // show all 'post_status' => null, 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', ))) { ?>
      ID,$size); ?>
    • post_excerpt) && is_single()) : ?>

      post_excerpt; ?>

    '; else echo '
    '; } } // BloggingPro comment function if ( ! function_exists( 'bpro_comment' ) ) : function bpro_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  • id="comment-"> ', '' ); ?>
  • id="li-comment-">
    user_id === $post->post_author ) : ?>

    ', '' ); ?>
    comment_approved ) : ?>
    __('Reply','bpro'), 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
    ', 'after' => '
    ' ) ); ?>
    add_section( 'bpro_options', array( 'title' => __( 'Options for BloggingPro', 'bpro' ), //Visible title of section 'priority' => 35, //Determines what order this appears in 'capability' => 'edit_theme_options', //Capability needed to tweak 'description' => __('Allows you to customize theme settings for BloggingPro.', 'bpro'), //Descriptive tooltip ) ); $wp_customize->add_section( 'bpro_logo_section' , array( 'title' => __( 'Logo', 'bpro' ), 'priority' => 40, 'description' => __('Upload a logo to replace the default site title in the header.', 'bpro'), ) ); //2. Register new settings to the WP database... $wp_customize->add_setting( 'accent_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record array( 'default' => '#0093C2', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 'sanitize_callback' => 'sanitize_hex_color' ) ); //2.1. Register new settings to the WP database... $wp_customize->add_setting( 'header_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record array( 'default' => '#33363b', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 'sanitize_callback' => 'sanitize_hex_color' ) ); //2.2. Register new settings to the WP database... $wp_customize->add_setting( 'read_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record array( 'default' => '#666', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 'sanitize_callback' => 'sanitize_hex_color' ) ); $wp_customize->add_setting( 'bpro_logo', array( 'sanitize_callback' => 'esc_url_raw' ) ); //3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)... $wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class $wp_customize, //Pass the $wp_customize object (required) 'bpro_accent_color', //Set a unique ID for the control array( 'label' => __( 'Accent Color', 'bpro' ), //Admin-visible name of the control 'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 'settings' => 'accent_color', //Which setting to load and manipulate (serialized is okay) 'priority' => 10, //Determines the order this control appears in for the specified section ) ) ); //3.1. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)... $wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class $wp_customize, //Pass the $wp_customize object (required) 'bpro_header_color', //Set a unique ID for the control array( 'label' => __( 'Header Color', 'bpro' ), //Admin-visible name of the control 'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 'settings' => 'header_color', //Which setting to load and manipulate (serialized is okay) 'priority' => 11, //Determines the order this control appears in for the specified section ) ) ); //3.2. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)... $wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class $wp_customize, //Pass the $wp_customize object (required) 'bpro_read_color', //Set a unique ID for the control array( 'label' => __( 'Read Color', 'bpro' ), //Admin-visible name of the control 'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 'settings' => 'read_color', //Which setting to load and manipulate (serialized is okay) 'priority' => 12, //Determines the order this control appears in for the specified section ) ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'bpro_logo', array( 'label' => __( 'Logo', 'bpro' ), 'section' => 'bpro_logo_section', 'settings' => 'bpro_logo', ) ) ); //4. We can also change built-in settings by modifying properties. For instance, let's make some stuff use live preview JS... $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } public static function bpro_header_output() { ?>