catchresponsive_customize_register

Implements Catchresponsive theme options into Theme Customizer.

Description

catchresponsive_customize_register( $wp_customize ); 

Parameters (1)

0. $wp_customize
Theme Customizer object

Usage

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

Defined (1)

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

/inc/customizer-includes/catchresponsive-customizer.php  
  1. function catchresponsive_customize_register( $wp_customize ) { 
  2. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
  3.  
  4. /** 
  5. * Set priority of blogname (Site Title) to 1. 
  6. * Strangly, if more than two options is added, Site title is moved below Tagline. This rectifies this issue. 
  7. */ 
  8. $wp_customize->get_control( 'blogname' )->priority = 1; 
  9.  
  10. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 
  11.  
  12.  
  13.  
  14. //Custom Controls 
  15. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-custom-controls.php'; 
  16.  
  17. //@remove Remove this block when WordPress 4.8 is released 
  18. if ( ! function_exists( 'has_custom_logo' ) ) { 
  19. // Custom Logo (added to Site Title and Tagline section in Theme Customizer) 
  20. $wp_customize->add_setting( 'catchresponsive_theme_options[logo]', array( 
  21. 'capability' => 'edit_theme_options',  
  22. 'default' => $defaults['logo'],  
  23. 'sanitize_callback' => 'catchresponsive_sanitize_image
  24. ) ); 
  25.  
  26. $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'logo', array( 
  27. 'label' => __( 'Logo', 'catch-responsive' ),  
  28. 'priority' => 100,  
  29. 'section' => 'title_tagline',  
  30. 'settings' => 'catchresponsive_theme_options[logo]',  
  31. ) ) ); 
  32.  
  33. $wp_customize->add_setting( 'catchresponsive_theme_options[logo_disable]', array( 
  34. 'capability' => 'edit_theme_options',  
  35. 'default' => $defaults['logo_disable'],  
  36. 'sanitize_callback' => 'catchresponsive_sanitize_checkbox',  
  37. ) ); 
  38.  
  39. $wp_customize->add_control( 'catchresponsive_theme_options[logo_disable]', array( 
  40. 'label' => __( 'Check to disable logo', 'catch-responsive' ),  
  41. 'priority' => 101,  
  42. 'section' => 'title_tagline',  
  43. 'settings' => 'catchresponsive_theme_options[logo_disable]',  
  44. 'type' => 'checkbox',  
  45. ) ); 
  46.  
  47. $wp_customize->add_setting( 'catchresponsive_theme_options[logo_alt_text]', array( 
  48. 'capability' => 'edit_theme_options',  
  49. 'default' => $defaults['logo_alt_text'],  
  50. 'sanitize_callback' => 'sanitize_text_field',  
  51. ) ); 
  52.  
  53. $wp_customize->add_control( 'catchresponsive_logo_alt_text', array( 
  54. 'label' => __( 'Logo Alt Text', 'catch-responsive' ),  
  55. 'priority' => 102,  
  56. 'section' => 'title_tagline',  
  57. 'settings' => 'catchresponsive_theme_options[logo_alt_text]',  
  58. 'type' => 'text',  
  59. ) ); 
  60.  
  61. $wp_customize->add_setting( 'catchresponsive_theme_options[move_title_tagline]', array( 
  62. 'capability' => 'edit_theme_options',  
  63. 'default' => $defaults['move_title_tagline'],  
  64. 'sanitize_callback' => 'catchresponsive_sanitize_checkbox',  
  65. ) ); 
  66.  
  67. $wp_customize->add_control( 'catchresponsive_theme_options[move_title_tagline]', array( 
  68. 'label' => __( 'Check to move Site Title and Tagline before logo', 'catch-responsive' ),  
  69. 'priority' => function_exists( 'has_custom_logo' ) ? 10 : 103,  
  70. 'section' => 'title_tagline',  
  71. 'settings' => 'catchresponsive_theme_options[move_title_tagline]',  
  72. 'type' => 'checkbox',  
  73. ) ); 
  74. // Custom Logo End 
  75.  
  76. // Color Scheme 
  77. $wp_customize->add_setting( 'catchresponsive_theme_options[color_scheme]', array( 
  78. 'capability' => 'edit_theme_options',  
  79. 'default' => $defaults['color_scheme'],  
  80. 'sanitize_callback' => 'catchresponsive_sanitize_select',  
  81. 'transport' => 'postMessage',  
  82. ) ); 
  83.  
  84.  
  85. $choices = array(); 
  86.  
  87. foreach ( $schemes as $scheme ) { 
  88. $choices[ $scheme['value'] ] = $scheme['label']; 
  89.  
  90. $wp_customize->add_control( 'catchresponsive_theme_options[color_scheme]', array( 
  91. 'choices' => $choices,  
  92. 'label' => __( 'Color Scheme', 'catch-responsive' ),  
  93. 'priority' => 5,  
  94. 'section' => 'colors',  
  95. 'settings' => 'catchresponsive_theme_options[color_scheme]',  
  96. 'type' => 'radio',  
  97. ) ); 
  98.  
  99. $wp_customize->add_setting( 'catchresponsive_theme_options[mobile_menu_color_scheme]', array( 
  100. 'capability' => 'edit_theme_options',  
  101. 'default' => $defaults['mobile_menu_color_scheme'],  
  102. 'sanitize_callback' => 'catchresponsive_sanitize_select
  103. ) ); 
  104.  
  105. $wp_customize->add_control( 'catchresponsive_theme_options[mobile_menu_color_scheme]', array( 
  106. 'choices' => $choices,  
  107. 'label' => __( 'Mobile Menu Color Scheme', 'catch-responsive' ),  
  108. 'section' => 'colors',  
  109. 'settings' => 'catchresponsive_theme_options[mobile_menu_color_scheme]',  
  110. 'type' => 'radio',  
  111. ) ); 
  112. //End Color Scheme 
  113.  
  114. // Header Options (added to Header section in Theme Customizer) 
  115. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-header-options.php'; 
  116.  
  117. //Theme Options 
  118. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-theme-options.php'; 
  119.  
  120. //Featured Content Setting 
  121. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-featured-content-setting.php'; 
  122.  
  123. //Featured Slider 
  124. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-featured-slider.php'; 
  125.  
  126. //Social Links 
  127. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer-social-icons.php'; 
  128.  
  129. // Reset all settings to default 
  130. $wp_customize->add_section( 'catchresponsive_reset_all_settings', array( 
  131. 'description' => __( 'Caution: Reset all settings to default. Refresh the page after save to view full effects.', 'catch-responsive' ),  
  132. 'priority' => 700,  
  133. 'title' => __( 'Reset all settings', 'catch-responsive' ),  
  134. ) ); 
  135.  
  136. $wp_customize->add_setting( 'catchresponsive_theme_options[reset_all_settings]', array( 
  137. 'capability' => 'edit_theme_options',  
  138. 'default' => $defaults['reset_all_settings'],  
  139. 'sanitize_callback' => 'catchresponsive_sanitize_checkbox',  
  140. 'transport' => 'postMessage',  
  141. ) ); 
  142.  
  143. $wp_customize->add_control( 'catchresponsive_theme_options[reset_all_settings]', array( 
  144. 'label' => __( 'Check to reset all settings to default', 'catch-responsive' ),  
  145. 'section' => 'catchresponsive_reset_all_settings',  
  146. 'settings' => 'catchresponsive_theme_options[reset_all_settings]',  
  147. 'type' => 'checkbox',  
  148. ) ); 
  149. // Reset all settings to default end 
  150.  
  151. //Important Links 
  152. $wp_customize->add_section( 'important_links', array( 
  153. 'priority' => 999,  
  154. 'title' => __( 'Important Links', 'catch-responsive' ),  
  155. ) ); 
  156.  
  157. /** 
  158. * Has dummy Sanitizaition function as it contains no value to be sanitized 
  159. */ 
  160. $wp_customize->add_setting( 'important_links', array( 
  161. 'sanitize_callback' => 'sanitize_text_field',  
  162. ) ); 
  163.  
  164. $wp_customize->add_control( new Catchresponsive_Important_Links( $wp_customize, 'important_links', array( 
  165. 'label' => __( 'Important Links', 'catch-responsive' ),  
  166. 'section' => 'important_links',  
  167. 'settings' => 'important_links',  
  168. 'type' => 'important_links',  
  169. ) ) ); 
  170. //Important Links End