PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/pilot/includes/customizer.php

https://bitbucket.org/GraphicFusion/crafti-landing
PHP | 153 lines | 122 code | 23 blank | 8 comment | 0 complexity | 695247df3c1d6891787ac290ffb9b216 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, Apache-2.0, GPL-3.0
  1. <?php
  2. /**
  3. * Add postMessage support for site title and description for the Theme Customizer.
  4. *
  5. * @param WP_Customize_Manager $wp_customize Theme Customizer object.
  6. */
  7. function _s_customize_register($wp_customize)
  8. {
  9. $wp_customize->get_setting('blogname')->transport = 'postMessage';
  10. $wp_customize->get_setting('blogdescription')->transport = 'postMessage';
  11. $wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
  12. }
  13. add_action('customize_register', '_s_customize_register');
  14. /**
  15. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  16. */
  17. function _s_customize_preview_js()
  18. {
  19. wp_enqueue_script('_s_customizer', get_template_directory_uri() . '/js/customizer.js', array('customize-preview'), '20130508', true);
  20. }
  21. add_action('customize_preview_init', '_s_customize_preview_js');
  22. function sanitize_text( $input ) {
  23. return wp_kses_post( force_balance_tags( $input ) );
  24. }
  25. function add_header_footer_logo($wp_customize) {
  26. $wp_customize->add_setting(
  27. 'header_logo'
  28. );
  29. $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'header_logo',
  30. array(
  31. 'label' => 'Header Logo',
  32. 'section' => 'title_tagline',
  33. 'settings' => 'header_logo',
  34. )));
  35. $wp_customize->add_setting(
  36. 'footer_logo'
  37. );
  38. $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'footer_logo',
  39. array(
  40. 'label' => 'Footer Logo',
  41. 'section' => 'title_tagline',
  42. 'settings' => 'footer_logo',
  43. )));
  44. }
  45. function add_footer_content($wp_customize){
  46. $wp_customize->add_section(
  47. 'footer',
  48. array(
  49. 'title' => 'Footer Settings',
  50. 'description' => 'Change the content of the footer. e.g. Address, Phone Number, copyright',
  51. 'priority' => 35,
  52. )
  53. );
  54. $wp_customize->add_setting(
  55. 'copyright_textbox',
  56. array(
  57. 'sanitize_callback' => 'sanitize_text',
  58. )
  59. );
  60. $wp_customize->add_control(
  61. 'copyright_textbox',
  62. array(
  63. 'label' => 'Copyright text',
  64. 'section' => 'footer',
  65. 'type' => 'text',
  66. )
  67. );
  68. $wp_customize->add_setting(
  69. 'address_1_textbox',
  70. array(
  71. 'sanitize_callback' => 'sanitize_text',
  72. )
  73. );
  74. $wp_customize->add_control(
  75. 'address_1_textbox',
  76. array(
  77. 'label' => 'Street Address',
  78. 'section' => 'footer',
  79. 'type' => 'text',
  80. )
  81. );
  82. $wp_customize->add_setting(
  83. 'address_2_textbox',
  84. array(
  85. 'sanitize_callback' => 'sanitize_text',
  86. )
  87. );
  88. $wp_customize->add_control(
  89. 'address_2_textbox',
  90. array(
  91. 'label' => 'City, State and Zip',
  92. 'section' => 'footer',
  93. 'type' => 'text',
  94. )
  95. );
  96. $wp_customize->add_setting(
  97. 'phone_textbox',
  98. array(
  99. 'sanitize_callback' => 'sanitize_text',
  100. )
  101. );
  102. $wp_customize->add_control(
  103. 'phone_textbox',
  104. array(
  105. 'label' => 'Phone Number',
  106. 'section' => 'footer',
  107. 'type' => 'text',
  108. )
  109. );
  110. $wp_customize->add_setting(
  111. 'fax_textbox',
  112. array(
  113. 'sanitize_callback' => 'sanitize_text',
  114. )
  115. );
  116. $wp_customize->add_control(
  117. 'fax_textbox',
  118. array(
  119. 'label' => 'Fax Number',
  120. 'section' => 'footer',
  121. 'type' => 'text',
  122. )
  123. );
  124. }
  125. function add_pilot_theme_menus($wp_customize)
  126. {
  127. add_header_footer_logo($wp_customize);
  128. add_footer_content($wp_customize);
  129. }
  130. add_action('customize_register', 'add_pilot_theme_menus');