everbox_customize_register

Add postMessage support for site title and description for the Theme Customizer.

Description

everbox_customize_register( (WP_Customize_Manager) $wp_customize ); 

Parameters (1)

0. $wp_customize (WP_Customize_Manager)
Theme Customizer object.

Usage

  1. if ( !function_exists( 'everbox_customize_register' ) ) { 
  2. require_once '/inc/customizer.php'; 
  3.  
  4. // Theme Customizer object. 
  5. $wp_customize = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = everbox_customize_register($wp_customize); 
  9.  

Defined (1)

The function is defined in the following location(s).

/inc/customizer.php  
  1. function everbox_customize_register( $wp_customize ) { 
  2. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
  3. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 
  4.  
  5. $wp_customize->add_section( 'everbox_general_section' , array( 
  6. 'title' => __( 'General', 'everbox' ) 
  7. ) ); 
  8.  
  9. // Primary Color 
  10. $wp_customize->add_setting( 'everbox_primary_color',  
  11. array( 
  12. 'default' => '', //Default setting/value to save 
  13. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  14. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  15. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  16. 'sanitize_callback' => 'everbox_sanitize_hex_color
  17. )  
  18. ); 
  19. $wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class 
  20. $wp_customize, //Pass the $wp_customize object (required) 
  21. 'everbox_primary_color', //Set a unique ID for the control 
  22. array( 
  23. 'label' => __( 'Primary Color', 'everbox' ), //Admin-visible name of the control 
  24. 'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  25. 'settings' => 'everbox_primary_color', //Which setting to load and manipulate (serialized is okay) 
  26. )  
  27. ) ); 
  28.  
  29. // Post excerpt length 
  30. $wp_customize->add_setting( 'everbox_excerpt_length',  
  31. array( 
  32. 'default' => 60, //Default setting/value to save 
  33. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  34. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  35. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  36. 'sanitize_callback' => 'everbox_sanitize_integer
  37. )  
  38. ); 
  39. $wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class 
  40. $wp_customize, //Pass the $wp_customize object (required) 
  41. 'everbox_excerpt_length', //Set a unique ID for the control 
  42. array( 
  43. 'label' => __( 'Post excerpt length', 'everbox' ), //Admin-visible name of the control 
  44. 'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  45. 'settings' => 'everbox_excerpt_length', //Which setting to load and manipulate (serialized is okay) 
  46. 'type' => 'number' 
  47. )  
  48. ) ); 
  49.  
  50. // Cagetory link 
  51. $wp_customize->add_setting( 'everbox_category_link',  
  52. array( 
  53. 'default' => 1, //Default setting/value to save 
  54. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  55. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  56. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  57. 'sanitize_callback' => 'everbox_sanitize_bool
  58. )  
  59. ); 
  60. $wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class 
  61. $wp_customize, //Pass the $wp_customize object (required) 
  62. 'everbox_category_link', //Set a unique ID for the control 
  63. array( 
  64. 'label' => __( 'Show cagetory link', 'everbox' ), //Admin-visible name of the control 
  65. 'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  66. 'settings' => 'everbox_category_link', //Which setting to load and manipulate (serialized is okay) 
  67. 'type' => 'checkbox' 
  68. )  
  69. ) ); 
  70.  
  71. // Infinite loading 
  72. $wp_customize->add_setting( 'everbox_infinite',  
  73. array( 
  74. 'default' => 0, //Default setting/value to save 
  75. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  76. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  77. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  78. 'sanitize_callback' => 'everbox_sanitize_bool
  79. )  
  80. ); 
  81. $wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class 
  82. $wp_customize, //Pass the $wp_customize object (required) 
  83. 'everbox_infinite', //Set a unique ID for the control 
  84. array( 
  85. 'label' => __( 'Infinite Pagination with jetpack', 'everbox' ), //Admin-visible name of the control 
  86. 'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  87. 'settings' => 'everbox_infinite', //Which setting to load and manipulate (serialized is okay) 
  88. 'type' => 'checkbox' 
  89. )  
  90. ) ); 
  91.  
  92. // Credit 
  93. $wp_customize->add_setting( 'everbox_credit',  
  94. array( 
  95. 'default' => 1, //Default setting/value to save 
  96. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  97. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  98. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  99. 'sanitize_callback' => 'everbox_sanitize_bool
  100. )  
  101. ); 
  102. $wp_customize->add_control( new WP_Customize_Control( //Instantiate the color control class 
  103. $wp_customize, //Pass the $wp_customize object (required) 
  104. 'everbox_credit', //Set a unique ID for the control 
  105. array( 
  106. 'label' => __( 'Footer Credit', 'everbox' ), //Admin-visible name of the control 
  107. 'section' => 'everbox_general_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  108. 'settings' => 'everbox_credit', //Which setting to load and manipulate (serialized is okay) 
  109. 'type' => 'checkbox' 
  110. )  
  111. ) ); 
  112.  
  113.  
  114. $wp_customize->add_section( 'everbox_icons_section' , array( 
  115. 'title' => __( 'ICONS', 'everbox' ) 
  116. ) ); 
  117.  
  118. // LOGO 
  119. $wp_customize->add_setting( 'everbox_logo',  
  120. array( 
  121. 'default' => '', //Default setting/value to save 
  122. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  123. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  124. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  125. 'sanitize_callback' => 'esc_url_raw' 
  126. )  
  127. ); 
  128. $wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class 
  129. $wp_customize, //Pass the $wp_customize object (required) 
  130. 'everbox_logo', //Set a unique ID for the control 
  131. array( 
  132. 'label' => __( 'LOGO', 'everbox' ), //Admin-visible name of the control 
  133. 'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  134. 'settings' => 'everbox_logo', //Which setting to load and manipulate (serialized is okay) 
  135. )  
  136. ) ); 
  137.  
  138. // favicon 
  139. $wp_customize->add_setting( 'everbox_favicon',  
  140. array( 
  141. 'default' => '', //Default setting/value to save 
  142. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  143. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  144. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  145. 'sanitize_callback' => 'esc_url_raw' 
  146. )  
  147. ); 
  148. $wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class 
  149. $wp_customize, //Pass the $wp_customize object (required) 
  150. 'everbox_favicon', //Set a unique ID for the control 
  151. array( 
  152. 'label' => __( 'Favicon', 'everbox' ), //Admin-visible name of the control 
  153. 'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  154. 'settings' => 'everbox_favicon', //Which setting to load and manipulate (serialized is okay) 
  155. )  
  156. ) ); 
  157.  
  158. // iPhone App icon 
  159. $wp_customize->add_setting( 'everbox_app',  
  160. array( 
  161. 'default' => '', //Default setting/value to save 
  162. 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 
  163. 'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. 
  164. 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 
  165. 'sanitize_callback' => 'esc_url_raw' 
  166. )  
  167. ); 
  168. $wp_customize->add_control( new WP_Customize_Image_Control( //Instantiate the color control class 
  169. $wp_customize, //Pass the $wp_customize object (required) 
  170. 'everbox_app', //Set a unique ID for the control 
  171. array( 
  172. 'label' => __( 'iPhone Retina icon (sizes:120x120)', 'everbox' ), //Admin-visible name of the control 
  173. 'section' => 'everbox_icons_section', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 
  174. 'settings' => 'everbox_app', //Which setting to load and manipulate (serialized is okay) 
  175. )  
  176. ) );