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