array( 'color' => $color_value ),
* $value => array( 'color' => $color_value ),
* )`
*
*/
/**
* Radio color customize control.
*
* @since 3.0.0
* @access public
*/
class Blog_Rider_Customize_Control_Radio_Color extends WP_Customize_Control {
/**
* The type of customize control being rendered.
*
* @since 3.0.0
* @access public
* @var string
*/
public $type = 'radio-color';
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 3.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
// We need to make sure we have the correct color URL.
foreach ( $this->choices as $value => $args )
$this->choices[ $value ]['color'] = esc_attr( $args['color'] );
$this->json['choices'] = $this->choices;
$this->json['link'] = $this->get_link();
$this->json['value'] = $this->value();
$this->json['id'] = $this->id;
}
/**
* Don't render the content via PHP. This control is handled with a JS template.
*
* @since 4.0.0
* @access public
* @return bool
*/
protected function render_content() {}
/**
* Underscore JS template to handle the control's output.
*
* @since 3.0.0
* @access public
* @return void
*/
public function content_template() { ?>
<# if ( ! data.choices ) {
return;
} #>
<# if ( data.label ) { #>
{{ data.label }}
<# } #>
<# if ( data.description ) { #>
{{{ data.description }}}
<# } #>
<# _.each( data.choices, function( args, choice ) { #>
<# } ) #>
register_control_type( 'Blog_Rider_Customize_Control_Radio_Color' );
$default = blog_rider_get_default_mods();
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->remove_control( 'header_textcolor' );
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'blog_rider_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'blog_rider_customize_partial_blogdescription',
) );
}
/**
*
*
* Header panel
*
*
*/
// Header panel
$wp_customize->add_panel(
'blog_rider_header_panel',
array(
'title' => esc_html__( 'Header', 'blog-rider' ),
'priority' => 100
)
);
$wp_customize->get_section( 'header_image' )->panel = 'blog_rider_header_panel';
// Header text display setting
$wp_customize->add_setting(
'blog_rider_header_text_display',
array(
'sanitize_callback' => 'blog_rider_sanitize_checkbox',
'default' => true,
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'blog_rider_header_text_display',
array(
'section' => 'title_tagline',
'type' => 'checkbox',
'label' => esc_html__( 'Display Site Title and Tagline', 'blog-rider' ),
)
);
/**
*
*
* Color panel
*
*
*/
// Header panel
$wp_customize->add_panel(
'blog_rider_color_panel',
array(
'title' => esc_html__( 'Color Options', 'blog-rider' ),
'priority' => 100,
)
);
//$wp_customize->get_section( 'colors' )->panel = 'blog_rider_color_panel';
// Header title color setting
$wp_customize->add_setting(
'blog_rider_header_title_color',
array(
'sanitize_callback' => 'blog_rider_sanitize_hex_color',
'default' => '#cf3140',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'blog_rider_header_title_color',
array(
'section' => 'colors',
'label' => esc_html__( 'Site title Color:', 'blog-rider' ),
)
)
);
// Header tagline color setting
$wp_customize->add_setting(
'blog_rider_header_tagline',
array(
'sanitize_callback' => 'blog_rider_sanitize_hex_color',
'default' => '#929292',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'blog_rider_header_tagline',
array(
'section' => 'colors',
'label' => esc_html__( 'Site tagline Color:', 'blog-rider' ),
)
)
);
/**
*
*
* Home sections panel
*
*
*/
// Home sections panel
$wp_customize->add_panel(
'blog_rider_home_panel',
array(
'title' => esc_html__( 'Homepage Sections', 'blog-rider' ),
'priority' => 105
)
);
//$wp_customize->get_section( 'static_front_page' )->panel = 'blog_rider_home_panel';
// Homepage sort section
$wp_customize->add_section(
'blog_rider_homepage_section_sort',
array(
'title' => esc_html__( 'Sort sections', 'blog-rider' ),
'panel' => 'blog_rider_home_panel',
)
);
// Your latest posts title setting
$wp_customize->add_setting(
'blog_rider_your_latest_posts_title',
array(
'sanitize_callback' => 'sanitize_text_field',
'default' => esc_html__( 'Blogs', 'blog-rider' ),
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'blog_rider_your_latest_posts_title',
array(
'section' => 'static_front_page',
'label' => esc_html__( 'Title:', 'blog-rider' ),
'active_callback' => 'blog_rider_is_latest_posts'
)
);
$wp_customize->selective_refresh->add_partial(
'blog_rider_your_latest_posts_title',
array(
'selector' => '.home.blog #shadow-page-header .shadow-page-title',
'render_callback' => 'blog_rider_your_latest_posts_partial_title',
)
);
require get_parent_theme_file_path('/inc/customizer/frontpage/slider.php');
require get_parent_theme_file_path('/inc/customizer/frontpage/featured-post.php');
require get_parent_theme_file_path('/inc/customizer/frontpage/list-post.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/general.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/layout.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/blog.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/single-post.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/single-page.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/pagination.php');
require get_parent_theme_file_path('/inc/customizer/theme-options/reset.php');
/**
*
* General settings panel
*
*/
// General settings panel
$wp_customize->add_panel(
'blog_rider_general_panel',
array(
'title' => esc_html__( 'Theme Option Settings', 'blog-rider' ),
'priority' => 107
)
);
$wp_customize->get_section( 'custom_css' )->panel = 'blog_rider_home_panel';
$wp_customize->add_panel(
'blog_rider_background_image_panel',
array(
'title' => esc_html__( 'Background Image', 'blog-rider' ),
'priority' => 101
)
);
}
add_action( 'customize_register', 'blog_rider_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function blog_rider_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function blog_rider_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function blog_rider_customize_preview_js() {
wp_enqueue_script( 'blog-rider-customizer', get_theme_file_uri( '/assets/js/customizer.js' ), array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'blog_rider_customize_preview_js' );
/**
* Binds JS handlers for Customizer controls.
*/
function blog_rider_customize_control_js() {
wp_enqueue_style( 'blog-rider-customize-style', get_theme_file_uri( '/assets/css/customize-controls.css' ), array(), '20151215' );
wp_enqueue_script( 'blog-rider-customize-control', get_theme_file_uri( '/assets/js/customize-control.js' ), array( 'jquery', 'customize-controls' ), '20151215', true );
$localized_data = array(
'refresh_msg' => esc_html__( 'Refresh the page after Save and Publish.', 'blog-rider' ),
'reset_msg' => esc_html__( 'Warning!!! This will reset all the settings. Refresh the page after Save and Publish to reset all.', 'blog-rider' ),
);
wp_localize_script( 'blog-rider-customize-control', 'localized_data', $localized_data );
}
add_action( 'customize_controls_enqueue_scripts', 'blog_rider_customize_control_js' );
/**
* Selective refresh.
*/
/**
* Selective refresh for footer copyright.
*/
function blog_rider_copyright_partial() {
return wp_kses_post( get_theme_mod( 'blog_rider_copyright_txt' ) );
}
/**
* Selective refresh for your latest posts title.
*/
function blog_rider_your_latest_posts_partial_title() {
return esc_html( get_theme_mod( 'blog_rider_your_latest_posts_title' ) );
}
if ( ! function_exists( 'blog_rider_validate_excerpt_length' ) ) :
function blog_rider_validate_excerpt_length( $validity, $value ){
$value = intval( $value );
if ( empty( $value ) || ! is_numeric( $value ) ) {
$validity->add( 'required', esc_html__( 'You must supply a valid number.', 'blog-rider' ) );
} elseif ( $value < 5 ) {
$validity->add( 'min_no_of_words', esc_html__( 'Minimum no of words is 5', 'blog-rider' ) );
} elseif ( $value > 100 ) {
$validity->add( 'max_no_of_words', esc_html__( 'Maximum no of words is 100', 'blog-rider' ) );
}
return $validity;
}
endif;
if ( ! function_exists( 'blog_rider_validate_list_article_count' ) ) :
function blog_rider_validate_list_article_count( $validity, $value ){
$value = intval( $value );
if ( empty( $value ) || ! is_numeric( $value ) ) {
$validity->add( 'required', esc_html__( 'You must supply a valid number.', 'blog-rider' ) );
} elseif ( $value < 1 ) {
$validity->add( 'min_no_of_words', esc_html__( 'Minimum no of words is 1', 'blog-rider' ) );
} elseif ( $value > 4 ) {
$validity->add( 'max_no_of_words', esc_html__( 'Maximum no of words is 4', 'blog-rider' ) );
}
return $validity;
}
endif;