__( 'Sidebar', 'branches' ),
'id' => 'sidebar',
'description' => __( 'Widgets in this area will be shown in the sidebar.', 'branches' ),
'before_title' => '
',
'before_widget' => ''
));
}
function branches_sanitize_int($yourVar){
//return true;
$sanitizedNum = filter_var($yourVar, FILTER_SANITIZE_NUMBER_INT);
return $sanitizedNum;
}
// Branches theme options
class branches_Customize {
public static function branches_register ( $wp_customize ) {
// Add Section for Logo
$wp_customize->add_section( 'branches_logo_section' , array(
'title' => __( 'Logo', 'branches' ),
'priority' => 40,
'description' => __('Upload a logo to replace the default site title in the header', 'branches'),
) );
// Add Setting for Logo
$wp_customize->add_setting( 'branches_logo',
array(
'sanitize_callback' => 'esc_url_raw'
)
);
// Add Control for Logo
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'branches_logo', array(
'label' => __( 'Logo', 'branches' ),
'section' => 'branches_logo_section',
'settings' => 'branches_logo',
) ) );
// Add Setting for Accent Color
$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' => '#000000', //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'
)
);
// Add Control for Accent Color
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'branches_accent_color', //Set a unique ID for the control
array(
'label' => __( 'Accent Color', 'branches' ), //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
)
) );
$wp_customize->add_section('branches_sidebar',
array(
'title' => 'Sidebar',
'description' => __( 'Define where to show the Sidebar.', 'branches' ),
'priority' => 65,
)
);
$wp_customize->add_setting(
'branches_sidebar_frontpage',
array(
'default' => true,
'sanitize_callback' => 'branches_sanitize_int'
)
);
$wp_customize->add_setting(
'branches_sidebar_singlepage',
array(
'default' => true,
'sanitize_callback' => 'branches_sanitize_int'
)
);
$wp_customize->add_control(
'branches_sidebar_frontpage',
array(
'label' => __( 'Show Sidebar on front page and on archive/category pages', 'branches' ),
'section' => 'branches_sidebar',
'type' => 'checkbox',
)
);
$wp_customize->add_control(
'branches_sidebar_singlepage',
array(
'label' => __( 'Show Sidebar on single post and page template', 'branches' ),
'section' => 'branches_sidebar',
'type' => 'checkbox',
)
);
$wp_customize->add_section('branches_posts_pages',
array(
'title' => 'Posts/Pages',
'description' => __( 'Some options for the single post and the page template.', 'branches' ),
'priority' => 75,
)
);
$wp_customize->add_setting(
'branches_show_header_singlepost',
array(
'default' => false,
'sanitize_callback' => 'branches_sanitize_int'
)
);
$wp_customize->add_control(
'branches_show_header_singlepost',
array(
'label' => __( 'Show Featured Image on single post template', 'branches' ),
'section' => 'branches_posts_pages',
'type' => 'checkbox',
)
);
$wp_customize->add_section('branches_social_media_links',
array(
'title' => 'Social Media Links',
'description' => __( 'Link to your Social Media Profiles. Just paste the URL to your Profile in the text fields.', 'branches' ),
'priority' => 85,
)
);
$wp_customize->add_setting(
'branches_social_media_links_position_header',
array(
'default' => true,
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_position_header',
array(
'label' => __( 'Show Social Media Links in Header', 'branches' ),
'section' => 'branches_social_media_links',
'type' => 'checkbox',
)
);
$wp_customize->add_setting(
'branches_social_media_links_position_footer',
array(
'default' => false,
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_position_footer',
array(
'label' => __( 'Show Social Media Links in Footer', 'branches' ),
'section' => 'branches_social_media_links',
'type' => 'checkbox',
)
);
$wp_customize->add_setting(
'branches_social_media_links_facebook',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_facebook',
array(
'label' => 'Facebook',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_twitter',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_twitter',
array(
'label' => 'Twitter',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_instagram',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_instagram',
array(
'label' => 'Instagram',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_youtube',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_youtube',
array(
'label' => 'YouTube',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_linkedin',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_linkedin',
array(
'label' => 'LinkedIn',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_googleplus',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_googleplus',
array(
'label' => 'Google+',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
$wp_customize->add_setting(
'branches_social_media_links_pinterest',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control(
'branches_social_media_links_pinterest',
array(
'label' => 'Pinterest',
'section' => 'branches_social_media_links',
'type' => 'text',
)
);
}
public static function branches_header_output() {
?>
' . get_the_author() . '';
} elseif ( is_year() ) {
$title = get_the_date( _x( 'Y', 'yearly archives date format', 'branches' ) );
} elseif ( is_month() ) {
$title = get_the_date( _x( 'F Y', 'monthly archives date format', 'branches' ) );
} elseif ( is_day() ) {
$title = get_the_date( _x( 'F j, Y', 'daily archives date format', 'branches' ) );
} elseif ( is_tax( 'post_format' ) ) {
if ( is_tax( 'post_format', 'post-format-aside' ) ) {
$title = _x( 'Asides', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
$title = _x( 'Galleries', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
$title = _x( 'Images', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
$title = _x( 'Videos', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
$title = _x( 'Quotes', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
$title = _x( 'Links', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
$title = _x( 'Statuses', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
$title = _x( 'Audio', 'post format archive title', 'branches' );
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
$title = _x( 'Chats', 'post format archive title', 'branches' );
}
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
} else {
$title = __( 'Archives', 'branches' );
}
return $title;
});
function wpb_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' );
if ( is_singular() ) wp_enqueue_script( "comment-reply" );
add_theme_support( 'title-tag' );
add_filter( 'wp_title', 'wpdocs_hack_wp_title_for_home' );
/**
* Customize the title for the home page, if one is not set.
*
* @param string $title The original title.
* @return string The title to use.
*/
function wpdocs_hack_wp_title_for_home( $title )
{
if ( empty( $title ) && ( is_home() || is_front_page() ) ) {
$title = get_bloginfo( 'name', 'display' ) . ' | ' . get_bloginfo( 'description' );
}
return $title;
}
// branches comment function
if ( ! function_exists( 'branches_comment' ) ) :
function branches_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
id="comment-">
', '' ); ?>
id="li-comment-">