get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->add_section( 'everbox_general_section' , array(
'title' => __( 'General', 'everbox' )
) );
// Primary Color
$wp_customize->add_setting( 'everbox_primary_color',
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'everbox_sanitize_hex_color'
)
);
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_primary_color', //Set a unique ID for the control
array(
'label' => __( 'Primary Color', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_primary_color', //Which setting to load and manipulate (serialized is okay)
)
) );
// Post excerpt length
$wp_customize->add_setting( 'everbox_excerpt_length',
array(
'default' => 60, //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'everbox_sanitize_integer'
)
);
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_excerpt_length', //Set a unique ID for the control
array(
'label' => __( 'Post excerpt length', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_excerpt_length', //Which setting to load and manipulate (serialized is okay)
'type' => 'number'
)
) );
// Cagetory link
$wp_customize->add_setting( 'everbox_category_link',
array(
'default' => 1, //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'everbox_sanitize_bool'
)
);
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_category_link', //Set a unique ID for the control
array(
'label' => __( 'Show cagetory link', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_category_link', //Which setting to load and manipulate (serialized is okay)
'type' => 'checkbox'
)
) );
// Infinite loading
$wp_customize->add_setting( 'everbox_infinite',
array(
'default' => 0, //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'everbox_sanitize_bool'
)
);
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_infinite', //Set a unique ID for the control
array(
'label' => __( 'Infinite Pagination with jetpack', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_infinite', //Which setting to load and manipulate (serialized is okay)
'type' => 'checkbox'
)
) );
// Credit
$wp_customize->add_setting( 'everbox_credit',
array(
'default' => 1, //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'everbox_sanitize_bool'
)
);
$wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_credit', //Set a unique ID for the control
array(
'label' => __( 'Footer Credit', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_credit', //Which setting to load and manipulate (serialized is okay)
'type' => 'checkbox'
)
) );
$wp_customize->add_section( 'everbox_icons_section' , array(
'title' => __( 'ICONS', 'everbox' )
) );
// LOGO
$wp_customize->add_setting( 'everbox_logo',
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_logo', //Set a unique ID for the control
array(
'label' => __( 'LOGO', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_logo', //Which setting to load and manipulate (serialized is okay)
)
) );
// favicon
$wp_customize->add_setting( 'everbox_favicon',
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_favicon', //Set a unique ID for the control
array(
'label' => __( 'Favicon', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_favicon', //Which setting to load and manipulate (serialized is okay)
)
) );
// iPhone App icon
$wp_customize->add_setting( 'everbox_app',
array(
'default' => '', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'everbox_app', //Set a unique ID for the control
array(
'label' => __( 'iPhone Retina icon (sizes:120x120)', 'everbox' ), //Admin-visible name of the control
'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'everbox_app', //Which setting to load and manipulate (serialized is okay)
)
) );
}
add_action( 'customize_register', 'everbox_customize_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function everbox_customize_preview_js() {
wp_enqueue_script( 'everbox_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
}
add_action( 'customize_preview_init', 'everbox_customize_preview_js' );
/**
* Adjusting color
* @param [type] $hex color need to be adjusted
* @param [type] $steps adjust by step
* @return [type] hex color
*/
function everbox_adjustBrightness($hex, $steps) {
// Steps should be between -255 and 255. Negative = darker, positive = lighter
$steps = max(-255, min(255, $steps));
// Normalize into a six character long hex string
$hex = str_replace('#', '', $hex);
if (strlen($hex) == 3) {
$hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
}
// Split into three parts: R, G and B
$color_parts = str_split($hex, 2);
$return = '#';
foreach ($color_parts as $color) {
$color = hexdec($color); // Convert to decimal
$color = max(0,min(255,$color + $steps)); // Adjust color
$return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code
}
return $return;
}
function everbox_custom_head() {
$primary_color = get_theme_mod( 'everbox_primary_color', '' );
$favicon_url = get_theme_mod('everbox_favicon', '');
$iphone_icon = get_theme_mod('everbox_app', '');
?>