Нема описа

class-customize.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Singleton class for handling the theme's customizer integration.
  4. *
  5. * @since 1.0.0
  6. * @access public
  7. */
  8. final class xshop_pro_Customize {
  9. /**
  10. * Returns the instance.
  11. *
  12. * @since 1.0.0
  13. * @access public
  14. * @return object
  15. */
  16. public static function get_instance() {
  17. static $instance = null;
  18. if ( is_null( $instance ) ) {
  19. $instance = new self;
  20. $instance->setup_actions();
  21. }
  22. return $instance;
  23. }
  24. /**
  25. * Constructor method.
  26. *
  27. * @since 1.0.0
  28. * @access private
  29. * @return void
  30. */
  31. private function __construct() {}
  32. /**
  33. * Sets up initial actions.
  34. *
  35. * @since 1.0.0
  36. * @access private
  37. * @return void
  38. */
  39. private function setup_actions() {
  40. // Register panels, sections, settings, controls, and partials.
  41. add_action( 'customize_register', array( $this, 'sections' ) );
  42. // Register scripts and styles for the controls.
  43. add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
  44. }
  45. /**
  46. * Sets up the customizer sections.
  47. *
  48. * @since 1.0.0
  49. * @access public
  50. * @param object $manager
  51. * @return void
  52. */
  53. public function sections( $manager ) {
  54. // Load custom sections.
  55. require get_template_directory() . '/inc/info/section-pro.php';
  56. // Register custom section types.
  57. $manager->register_section_type( 'xshop_pro_Customize_Section_Pro' );
  58. // Register sections.
  59. $manager->add_section(
  60. new xshop_pro_Customize_Section_Pro(
  61. $manager,
  62. 'xshop_pro',
  63. array(
  64. 'title' => esc_html__( 'Now Available Xshop Pro', 'xshop' ),
  65. 'pro_text' => esc_html__( 'Go Pro','xshop' ),
  66. 'pro_url' => 'https://wpthemespace.com/product/xshop-pro/',
  67. 'priority' => 10,
  68. )
  69. )
  70. );
  71. }
  72. /**
  73. * Loads theme customizer CSS.
  74. *
  75. * @since 1.0.0
  76. * @access public
  77. * @return void
  78. */
  79. public function enqueue_control_scripts() {
  80. wp_enqueue_script( 'xshop-pro-customize-controls', trailingslashit( get_template_directory_uri() ) . 'inc/info/customize-controls.js', array( 'customize-controls' ) );
  81. wp_enqueue_style( 'xshop-pro-customize-controls', trailingslashit( get_template_directory_uri() ) . 'inc/info/customize-controls.css' );
  82. }
  83. }
  84. // Doing this customizer thang!
  85. xshop_pro_Customize::get_instance();