OSDN Git Service

WordPressテンプレート使用ショップデモデータ追加。
[magic3/magic3.git] / templates / shop-isle / inc / customizer / customize-pro / class-shopisle-customizer-upsell.php
1 <?php
2 /**
3  * Singleton class for handling the theme's customizer integration.
4  *
5  * @package WordPress
6  * @subpackage Shop Isle
7  */
8
9 /**
10  * Class Shopisle_Customizer_Upsell
11  *
12  * @since  1.0.0
13  * @access public
14  */
15 final class Shopisle_Customizer_Upsell {
16
17         /**
18          * Constructor method.
19          *
20          * @since  1.0.0
21          * @access private
22          * @return void
23          */
24         private function __construct() {
25         }
26
27         /**
28          * Returns the instance.
29          *
30          * @since  1.0.0
31          * @access public
32          * @return object
33          */
34         public static function get_instance() {
35
36                 static $instance = null;
37
38                 if ( is_null( $instance ) ) {
39                         $instance = new self;
40                         $instance->setup_actions();
41                 }
42
43                 return $instance;
44         }
45
46         /**
47          * Sets up initial actions.
48          *
49          * @since  1.0.0
50          * @access private
51          * @return void
52          */
53         private function setup_actions() {
54
55                 // Register panels, sections, settings, controls, and partials.
56                 add_action( 'customize_register', array( $this, 'sections' ) );
57
58                 // Register scripts and styles for the controls.
59                 add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
60         }
61
62         /**
63          * Sets up the customizer sections.
64          *
65          * @since  1.0.0
66          * @access public
67          *
68          * @param  object $manager - the wp_customizer object.
69          *
70          * @return void
71          */
72         public function sections( $manager ) {
73
74                 // Load custom sections.
75                 require_once( trailingslashit( get_template_directory() ) . 'inc/customizer/customize-pro/class-shopisle-customizer-upsell-main.php' );
76                 require_once( trailingslashit( get_template_directory() ) . 'inc/customizer/customize-pro/class-shopisle-customizer-upsell-text.php' );
77                 require_once( trailingslashit( get_template_directory() ) . 'inc/customizer/customize-pro/class-shopisle-customizer-upsell-section.php' );
78
79                 // Register custom section types.
80                 $manager->register_section_type( 'Shopisle_Customizer_Upsell_Main' );
81                 $manager->register_section_type( 'Shopisle_Customizer_Upsell_Text' );
82
83                 // Register sections.
84                 // Main Upsell In Customizer Root.
85                 $manager->add_section(
86                         new Shopisle_Customizer_Upsell_Main(
87                                 $manager, 'shopisle-upsell', array(
88                                         'upsell_title' => __( 'Shop Isle', 'shop-isle' ),
89                                         'label_url'    => 'http://docs.themeisle.com/article/421-shop-isle-documentation-wordpress-org',
90                                         'label_text'   => __( 'Documentation', 'shop-isle' ),
91                                 )
92                         )
93                 );
94
95                 // Frontpage Sections Upsell.
96                 $manager->add_section(
97                         new Shopisle_Customizer_Upsell_Section(
98                                 $manager, 'shopisle-upsell-section', array(
99                                         'panel'       => 'shop_isle_front_page_sections',
100                                         'priority'    => 500,
101                                         'options'     => array(
102                                                 esc_html__( 'Categories Section', 'shop-isle' ),
103                                                 esc_html__( 'Map Section', 'shop-isle' ),
104                                                 esc_html__( 'Ribbon Section', 'shop-isle' ),
105                                                 esc_html__( 'Services Section', 'shop-isle' ),
106                                                 esc_html__( 'Shortcodes Section', 'shop-isle' ),
107                                         ),
108                                         'button_url'  => esc_url( 'https://www.themeisle.com/themes/shop-isle-pro/' ),
109                                         'button_text' => esc_html__( 'View PRO version', 'shop-isle' ),
110                                 )
111                         )
112                 );
113
114                 // Frontpage Instructions.
115                 $shop_isle_wporg_flag = get_option( 'shop_isle_wporg_flag' );
116                 if ( ( ( ! empty( $shop_isle_wporg_flag ) && ( 'true' === $shop_isle_wporg_flag ) ) ) && ( 'posts' === get_option( 'show_on_front' ) ) ) {
117
118                         $manager->add_section(
119                                 new Shopisle_Customizer_Upsell_Text(
120                                         $manager, 'shopisle-upsell-frontpage-instructions', array(
121                                                 'upsell_text' =>
122                                                 sprintf(
123                                                         /* translators: 1: Link to static front page customizer control */
124                                                         __( 'To customize the Frontpage sections please create a page. After that, go to %1$s and select "A static page". Finally, for "Front page" choose the page you previously created.', 'shop-isle' ),
125                                                         sprintf(
126                                                                 /* translators: 1: Link to static front page customizer control 2: 'Static Front Page' */
127                                                                 '<a class="shop_isle_go_to_section" href="%1$s">%2$s</a>',
128                                                                 admin_url( 'customize.php?autofocus[control]=show_on_front' ),
129                                                                 esc_html__( 'Static Front Page', 'shop-isle' )
130                                                         )
131                                                 ) . '<br><br>' . sprintf(
132                                                         /* translators: 1: Link to documentation page. 2: 'doc' */
133                                                         __( 'Need further informations? Check this %1$s', 'shop-isle' ),
134                                                         sprintf(
135                                                                 '<a href="http://docs.themeisle.com/article/236-how-to-set-up-the-home-page-for-llorix-one" target="_blank">%s</a>',
136                                                                 esc_html__( 'doc', 'shop-isle' )
137                                                         )
138                                                 ),
139                                                 'panel'    => 'shop_isle_front_page_sections',
140                                                 'priority' => 1,
141                                         )
142                                 )
143                         );
144
145                 }
146         }
147
148         /**
149          * Loads theme customizer CSS.
150          *
151          * @since  1.0.0
152          * @access public
153          * @return void
154          */
155         public function enqueue_control_scripts() {
156
157                 wp_enqueue_script( 'shopisle-upsell-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/customize-pro/shopisle-upsell-customize-controls.js', array( 'customize-controls' ) );
158
159                 wp_enqueue_style( 'shopisle-upsell-style', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/customize-pro/shopisle-upsell-customize-controls.css' );
160         }
161 }
162
163 Shopisle_Customizer_Upsell::get_instance();