Passed
Push — master ( 5da25d...c9684a )
by Chris
02:40
created
classes/admin/class-settings.php 2 patches
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -9,276 +9,276 @@
 block discarded – undo
9 9
 class Settings {
10 10
 
11 11
 
12
-    /**
13
-     * Holds class instance
14
-     *
15
-     * @since 1.0.0
16
-     *
17
-     * @var object \lsx\sharing\classes\admin\Settings()
18
-     */
19
-    protected static $instance = null;
12
+     /**
13
+      * Holds class instance
14
+      *
15
+      * @since 1.0.0
16
+      *
17
+      * @var object \lsx\sharing\classes\admin\Settings()
18
+      */
19
+     protected static $instance = null;
20 20
 
21
-    /**
22
-     * Contructor
23
-     */
24
-    public function __construct() {
25
-         add_action('cmb2_admin_init', array( $this, 'register_settings_page' ));
26
-        add_action('lsx_sharing_settings_page', array( $this, 'configure_general_fields' ), 15, 1);
27
-        add_action('lsx_sharing_settings_page', array( $this, 'configure_archive_fields' ), 15, 1);
28
-        add_action('admin_enqueue_scripts', array( $this, 'assets' ));
29
-    }
21
+     /**
22
+      * Contructor
23
+      */
24
+     public function __construct() {
25
+          add_action('cmb2_admin_init', array( $this, 'register_settings_page' ));
26
+          add_action('lsx_sharing_settings_page', array( $this, 'configure_general_fields' ), 15, 1);
27
+          add_action('lsx_sharing_settings_page', array( $this, 'configure_archive_fields' ), 15, 1);
28
+          add_action('admin_enqueue_scripts', array( $this, 'assets' ));
29
+     }
30 30
 
31
-    /**
32
-     * Return an instance of this class.
33
-     *
34
-     * @since 1.0.0
35
-     *
36
-     * @return object \lsx\sharing\classes\admin\Settings()    A single instance of this class.
37
-     */
38
-    public static function get_instance() {
39
-         // If the single instance hasn't been set, set it now.
40
-        if ( null == self::$instance ) {
41
-            self::$instance = new self();
42
-        }
43
-        return self::$instance;
44
-    }
31
+     /**
32
+      * Return an instance of this class.
33
+      *
34
+      * @since 1.0.0
35
+      *
36
+      * @return object \lsx\sharing\classes\admin\Settings()    A single instance of this class.
37
+      */
38
+     public static function get_instance() {
39
+          // If the single instance hasn't been set, set it now.
40
+          if ( null == self::$instance ) {
41
+               self::$instance = new self();
42
+          }
43
+          return self::$instance;
44
+     }
45 45
 
46
-    /**
47
-     * Configure fields for the Settings page.
48
-     *
49
-     * @return void
50
-     */
51
-    public function register_settings_page() {
52
-         $args = array(
53
-			 'id'           => 'lsx_sharing_settings',
54
-			 'title'        => '<h1>' . esc_html__('LSX Sharing Settings', 'lsx-search') . ' <span class="version">' . LSX_SHARING_VER . '</span></h1>',
55
-			 'menu_title'   => esc_html__('LSX Sharing', 'search'), // Falls back to 'title' (above).
56
-			 'object_types' => array( 'options-page' ),
57
-			 'option_key'   => 'lsx-sharing-settings', // The option key and admin menu page slug.
58
-			 'parent_slug'  => 'options-general.php',
59
-			 'capability'   => 'manage_options', // Cap required to view options-page.
60
-		 );
61
-        $cmb  = new_cmb2_box($args);
62
-        do_action('lsx_sharing_settings_page', $cmb);
63
-    }
46
+     /**
47
+      * Configure fields for the Settings page.
48
+      *
49
+      * @return void
50
+      */
51
+     public function register_settings_page() {
52
+          $args = array(
53
+                    'id'           => 'lsx_sharing_settings',
54
+                    'title'        => '<h1>' . esc_html__('LSX Sharing Settings', 'lsx-search') . ' <span class="version">' . LSX_SHARING_VER . '</span></h1>',
55
+                    'menu_title'   => esc_html__('LSX Sharing', 'search'), // Falls back to 'title' (above).
56
+                    'object_types' => array( 'options-page' ),
57
+                    'option_key'   => 'lsx-sharing-settings', // The option key and admin menu page slug.
58
+                    'parent_slug'  => 'options-general.php',
59
+                    'capability'   => 'manage_options', // Cap required to view options-page.
60
+               );
61
+          $cmb  = new_cmb2_box($args);
62
+          do_action('lsx_sharing_settings_page', $cmb);
63
+     }
64 64
 
65
-    /**
66
-     * Enqueue JS and CSS.
67
-     */
68
-    public function assets( $hook ) {
69
-         wp_enqueue_style('lsx-sharing-admin', LSX_SHARING_URL . 'assets/css/lsx-sharing-admin.css', array(), LSX_SHARING_VER);
70
-    }
65
+     /**
66
+      * Enqueue JS and CSS.
67
+      */
68
+     public function assets( $hook ) {
69
+          wp_enqueue_style('lsx-sharing-admin', LSX_SHARING_URL . 'assets/css/lsx-sharing-admin.css', array(), LSX_SHARING_VER);
70
+     }
71 71
 
72
-    /**
73
-     * Enable Business Directory Search settings only if LSX Search plugin is enabled.
74
-     *
75
-     * @return void
76
-     */
77
-    public function configure_general_fields( $cmb ) {
78
-         $global_args = array(
79
-			 'title' => __('Global', 'lsx-search'),
80
-			 'desc'  => esc_html__('Control the sharing WordPress post types.', 'lsx-search'),
81
-		 );
82
-        $this->get_fields($cmb, 'global', $global_args);
83
-    }
72
+     /**
73
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
74
+      *
75
+      * @return void
76
+      */
77
+     public function configure_general_fields( $cmb ) {
78
+          $global_args = array(
79
+                    'title' => __('Global', 'lsx-search'),
80
+                    'desc'  => esc_html__('Control the sharing WordPress post types.', 'lsx-search'),
81
+               );
82
+          $this->get_fields($cmb, 'global', $global_args);
83
+     }
84 84
 
85
-    /**
86
-     * Enable Sharing settings only if LSX Search plugin is enabled.
87
-     *
88
-     * @param  object $cmb      The CMB2() class.
89
-     * @param  string $position either top of bottom.
90
-     * @return void
91
-     */
92
-    public function configure_archive_fields( $cmb ) {
93
-         $archives       = array();
94
-        $post_type_args = array(
95
-			'public' => true,
96
-        );
97
-        $post_types     = get_post_types($post_type_args);
98
-        if ( ! empty($post_types) ) {
99
-            foreach ( $post_types as $post_type_key => $post_type_value ) {
100
-                switch ( $post_type_key ) {
101
-					case 'post':
102
-						$page_url      = home_url();
103
-						$page_title    = __('Home', 'lsx-search');
104
-						$show_on_front = get_option('show_on_front');
105
-						if ( 'page' === $show_on_front ) {
106
-								$page_for_posts = get_option('page_for_posts');
107
-							if ( '' !== $page_for_posts ) {
108
-								$page_title   = get_the_title($page_for_posts);
109
-								$page_url     = get_permalink($page_for_posts);
110
-							}
111
-						}
112
-						$description = sprintf(
113
-						/* translators: %s: The subscription info */
114
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> posts.', 'lsx-search'),
115
-							$page_url,
116
-							$page_title
117
-						);
118
-						$archives[ $post_type_key ] = array(
119
-							'title' => __('Blog', 'lsx-search'),
120
-							'desc'  => $description,
121
-						);
122
-					break;
85
+     /**
86
+      * Enable Sharing settings only if LSX Search plugin is enabled.
87
+      *
88
+      * @param  object $cmb      The CMB2() class.
89
+      * @param  string $position either top of bottom.
90
+      * @return void
91
+      */
92
+     public function configure_archive_fields( $cmb ) {
93
+          $archives       = array();
94
+          $post_type_args = array(
95
+               'public' => true,
96
+          );
97
+          $post_types     = get_post_types($post_type_args);
98
+          if ( ! empty($post_types) ) {
99
+               foreach ( $post_types as $post_type_key => $post_type_value ) {
100
+                    switch ( $post_type_key ) {
101
+                         case 'post':
102
+                              $page_url      = home_url();
103
+                              $page_title    = __('Home', 'lsx-search');
104
+                              $show_on_front = get_option('show_on_front');
105
+                              if ( 'page' === $show_on_front ) {
106
+                                        $page_for_posts = get_option('page_for_posts');
107
+                                   if ( '' !== $page_for_posts ) {
108
+                                        $page_title   = get_the_title($page_for_posts);
109
+                                        $page_url     = get_permalink($page_for_posts);
110
+                                   }
111
+                              }
112
+                              $description = sprintf(
113
+                              /* translators: %s: The subscription info */
114
+                                   __('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> posts.', 'lsx-search'),
115
+                                   $page_url,
116
+                                   $page_title
117
+                              );
118
+                              $archives[ $post_type_key ] = array(
119
+                                   'title' => __('Blog', 'lsx-search'),
120
+                                   'desc'  => $description,
121
+                              );
122
+                         break;
123 123
 
124
-					case 'product':
125
-						$page_url = home_url();
126
-						$page_title    = __('Shop', 'lsx-search');
127
-						if ( function_exists('wc_get_page_id') ) {
128
-							$shop_page  = wc_get_page_id('shop');
129
-							$page_url   = get_permalink($shop_page);
130
-							$page_title = get_the_title($shop_page);
131
-						}
132
-						$description = sprintf(
133
-						/* translators: %s: The subscription info */
134
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
135
-							$page_url,
136
-							$page_title
137
-						);
138
-						$archives[ $post_type_key ] = array(
139
-							'title' => __('Shop', 'lsx-search'),
140
-							'desc'  => $description,
141
-						);
142
-					break;
124
+                         case 'product':
125
+                              $page_url = home_url();
126
+                              $page_title    = __('Shop', 'lsx-search');
127
+                              if ( function_exists('wc_get_page_id') ) {
128
+                                   $shop_page  = wc_get_page_id('shop');
129
+                                   $page_url   = get_permalink($shop_page);
130
+                                   $page_title = get_the_title($shop_page);
131
+                              }
132
+                              $description = sprintf(
133
+                              /* translators: %s: The subscription info */
134
+                                   __('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
135
+                                   $page_url,
136
+                                   $page_title
137
+                              );
138
+                              $archives[ $post_type_key ] = array(
139
+                                   'title' => __('Shop', 'lsx-search'),
140
+                                   'desc'  => $description,
141
+                              );
142
+                         break;
143 143
 
144
-					case 'custom_title':
145
-						$page_url = home_url();
146
-						$page_title    = __('Shop', 'lsx-search');
147
-						if ( function_exists('wc_get_page_id') ) {
148
-							$shop_page  = wc_get_page_id('shop');
149
-							$page_url   = get_permalink($shop_page);
150
-							$page_title = get_the_title($shop_page);
151
-						}
152
-						$description = sprintf(
153
-						/* translators: %s: The subscription info */
154
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
155
-							$page_url,
156
-							$page_title
157
-						);
158
-						$archives[ $post_type_key ] = array(
159
-							'title' => __('Custom Title', 'lsx-search'),
160
-							'desc'  => $description,
161
-						);
162
-					break;
144
+                         case 'custom_title':
145
+                              $page_url = home_url();
146
+                              $page_title    = __('Shop', 'lsx-search');
147
+                              if ( function_exists('wc_get_page_id') ) {
148
+                                   $shop_page  = wc_get_page_id('shop');
149
+                                   $page_url   = get_permalink($shop_page);
150
+                                   $page_title = get_the_title($shop_page);
151
+                              }
152
+                              $description = sprintf(
153
+                              /* translators: %s: The subscription info */
154
+                                   __('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
155
+                                   $page_url,
156
+                                   $page_title
157
+                              );
158
+                              $archives[ $post_type_key ] = array(
159
+                                   'title' => __('Custom Title', 'lsx-search'),
160
+                                   'desc'  => $description,
161
+                              );
162
+                         break;
163 163
 
164
-					default:
165
-						if ( in_array($post_type_key, \lsx\sharing\includes\functions\get_restricted_post_types()) ) {
166
-								break;
167
-						}
168
-						$temp_post_type = get_post_type_object($post_type_key);
169
-						if ( ! is_wp_error($temp_post_type) ) {
170
-							$page_url    = get_post_type_archive_link($temp_post_type->name);
171
-							$description = sprintf(
172
-							/* translators: %s: The subscription info */
173
-								__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> singles.', 'lsx-search'),
174
-								$page_url,
175
-								$temp_post_type->label
176
-							);
164
+                         default:
165
+                              if ( in_array($post_type_key, \lsx\sharing\includes\functions\get_restricted_post_types()) ) {
166
+                                        break;
167
+                              }
168
+                              $temp_post_type = get_post_type_object($post_type_key);
169
+                              if ( ! is_wp_error($temp_post_type) ) {
170
+                                   $page_url    = get_post_type_archive_link($temp_post_type->name);
171
+                                   $description = sprintf(
172
+                                   /* translators: %s: The subscription info */
173
+                                        __('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> singles.', 'lsx-search'),
174
+                                        $page_url,
175
+                                        $temp_post_type->label
176
+                                   );
177 177
 
178
-							$archives[ $post_type_key ] = array(
179
-								'title' => $temp_post_type->label,
180
-								'desc'  => $description,
181
-							);
182
-						}
178
+                                   $archives[ $post_type_key ] = array(
179
+                                        'title' => $temp_post_type->label,
180
+                                        'desc'  => $description,
181
+                                   );
182
+                              }
183 183
                     break;
184
-                }
185
-            }
186
-        }
187
-        if ( ! empty($archives) ) {
188
-            foreach ( $archives as $archive_key => $archive_args ) {
189
-                $this->get_fields($cmb, $archive_key, $archive_args);
190
-            }
191
-        }
192
-    }
193
-    /**
194
-     * Gets the sharing fields and loops through them.
195
-     *
196
-     * @param  object $cmb
197
-     * @param  string $section
198
-     * @param  array  $args
199
-     * @return void
200
-     */
201
-    public function get_fields( $cmb, $section, $args ) {
202
-         $cmb->add_field(
203
-            array(
204
-				'id'          => 'settings_' . $section . '_sharing',
205
-				'type'        => 'title',
206
-				'name'        => $args['title'],
207
-				'default'     => $args['title'],
208
-				'description' => $args['desc'],
209
-            )
210
-        );
211
-        if ( 'global' === $section ) {
212
-            $cmb->add_field(
213
-                array(
214
-					'name'        => esc_html__('Disable all', 'lsx-sharing'),
215
-					'id'          => $section . '_disable_all',
216
-					'description' => esc_html__('Disable all share buttons on the site', 'lsx-sharing'),
217
-					'type'        => 'checkbox',
218
-                )
219
-            );
220
-        } else {
221
-            $cmb->add_field(
222
-                array(
223
-					'name'        => esc_html__('Disable', 'lsx-sharing'),
224
-					'id'          => $section . '_disable_pt',
225
-					'description' => esc_html__('Disable the share buttons on this post type', 'lsx-sharing'),
226
-					'type'        => 'checkbox',
227
-                )
228
-            );
229
-        }
184
+                    }
185
+               }
186
+          }
187
+          if ( ! empty($archives) ) {
188
+               foreach ( $archives as $archive_key => $archive_args ) {
189
+                    $this->get_fields($cmb, $archive_key, $archive_args);
190
+               }
191
+          }
192
+     }
193
+     /**
194
+      * Gets the sharing fields and loops through them.
195
+      *
196
+      * @param  object $cmb
197
+      * @param  string $section
198
+      * @param  array  $args
199
+      * @return void
200
+      */
201
+     public function get_fields( $cmb, $section, $args ) {
202
+          $cmb->add_field(
203
+               array(
204
+                    'id'          => 'settings_' . $section . '_sharing',
205
+                    'type'        => 'title',
206
+                    'name'        => $args['title'],
207
+                    'default'     => $args['title'],
208
+                    'description' => $args['desc'],
209
+               )
210
+          );
211
+          if ( 'global' === $section ) {
212
+               $cmb->add_field(
213
+                    array(
214
+                         'name'        => esc_html__('Disable all', 'lsx-sharing'),
215
+                         'id'          => $section . '_disable_all',
216
+                         'description' => esc_html__('Disable all share buttons on the site', 'lsx-sharing'),
217
+                         'type'        => 'checkbox',
218
+                    )
219
+               );
220
+          } else {
221
+               $cmb->add_field(
222
+                    array(
223
+                         'name'        => esc_html__('Disable', 'lsx-sharing'),
224
+                         'id'          => $section . '_disable_pt',
225
+                         'description' => esc_html__('Disable the share buttons on this post type', 'lsx-sharing'),
226
+                         'type'        => 'checkbox',
227
+                    )
228
+               );
229
+          }
230 230
 
231
-		if ( 'global' === $section ) {
232
-			$label_text_description = esc_html__( 'If no text is specified per post type this text will display.' , 'lsx-sharing' );
233
-		} else {
234
-			$label_text_description = esc_html__( 'A default label for the sharing.', 'lsx-sharing' );
235
-		}
231
+          if ( 'global' === $section ) {
232
+               $label_text_description = esc_html__( 'If no text is specified per post type this text will display.' , 'lsx-sharing' );
233
+          } else {
234
+               $label_text_description = esc_html__( 'A default label for the sharing.', 'lsx-sharing' );
235
+          }
236 236
 		
237
-        $cmb->add_field(
238
-            array(
239
-				'name'        => esc_html__( 'Label text', 'lsx-sharing' ),
240
-				'id'          => $section . '_label_text',
241
-				'description' => $label_text_description,
242
-				'type'        => 'text',
243
-            )
244
-        );
245
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'facebook' ) ) ) {
246
-            $cmb->add_field(
247
-                array(
248
-					'name'        => esc_html__( 'Disable Facebook', 'lsx-sharing' ),
249
-					'id'          => $section . '_disable_facebook',
250
-					'description' => esc_html__( 'Disable Facebook share button.', 'lsx-sharing' ),
251
-					'type'        => 'checkbox',
252
-                )
253
-            );
254
-        }
255
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'twitter' ) ) ) {
256
-            $cmb->add_field(
257
-                array(
258
-					'name'        => esc_html__( 'Disable Twitter', 'lsx-sharing' ),
259
-					'id'          => $section . '_disable_twitter',
260
-					'description' => esc_html__( 'Disable Twitter share button.', 'lsx-sharing' ),
261
-					'type'        => 'checkbox',
262
-                )
263
-            );
264
-        }
265
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'pinterest' ) ) ) {
266
-            $cmb->add_field(
267
-                array(
268
-					'name'        => esc_html__( 'Disable Pinterest', 'lsx-sharing'),
269
-					'id'          => $section . '_disable_pinterest',
270
-					'description' => esc_html__( 'Disable Pinterest button.', 'lsx-sharing'),
271
-					'type'        => 'checkbox',
272
-                )
273
-            );
274
-        }
237
+          $cmb->add_field(
238
+               array(
239
+                    'name'        => esc_html__( 'Label text', 'lsx-sharing' ),
240
+                    'id'          => $section . '_label_text',
241
+                    'description' => $label_text_description,
242
+                    'type'        => 'text',
243
+               )
244
+          );
245
+          if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'facebook' ) ) ) {
246
+               $cmb->add_field(
247
+                    array(
248
+                         'name'        => esc_html__( 'Disable Facebook', 'lsx-sharing' ),
249
+                         'id'          => $section . '_disable_facebook',
250
+                         'description' => esc_html__( 'Disable Facebook share button.', 'lsx-sharing' ),
251
+                         'type'        => 'checkbox',
252
+                    )
253
+               );
254
+          }
255
+          if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'twitter' ) ) ) {
256
+               $cmb->add_field(
257
+                    array(
258
+                         'name'        => esc_html__( 'Disable Twitter', 'lsx-sharing' ),
259
+                         'id'          => $section . '_disable_twitter',
260
+                         'description' => esc_html__( 'Disable Twitter share button.', 'lsx-sharing' ),
261
+                         'type'        => 'checkbox',
262
+                    )
263
+               );
264
+          }
265
+          if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'pinterest' ) ) ) {
266
+               $cmb->add_field(
267
+                    array(
268
+                         'name'        => esc_html__( 'Disable Pinterest', 'lsx-sharing'),
269
+                         'id'          => $section . '_disable_pinterest',
270
+                         'description' => esc_html__( 'Disable Pinterest button.', 'lsx-sharing'),
271
+                         'type'        => 'checkbox',
272
+                    )
273
+               );
274
+          }
275 275
 
276
-        do_action( 'lsx_sharing_settings_section', $cmb, $section );
277
-        $cmb->add_field(
278
-            array(
279
-				'id'   => $section . '_title_closing',
280
-				'type' => 'tab_closing',
281
-            )
282
-        );
283
-    }
276
+          do_action( 'lsx_sharing_settings_section', $cmb, $section );
277
+          $cmb->add_field(
278
+               array(
279
+                    'id'   => $section . '_title_closing',
280
+                    'type' => 'tab_closing',
281
+               )
282
+          );
283
+     }
284 284
 }
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  * @package lsx-sharing
8 8
  */
9
-class Settings {
9
+class Settings{
10 10
 
11 11
 
12 12
     /**
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @var object \lsx\sharing\classes\admin\Settings()
18 18
      */
19
-    protected static $instance = null;
19
+    protected static $instance=null;
20 20
 
21 21
     /**
22 22
      * Contructor
23 23
      */
24
-    public function __construct() {
25
-         add_action('cmb2_admin_init', array( $this, 'register_settings_page' ));
26
-        add_action('lsx_sharing_settings_page', array( $this, 'configure_general_fields' ), 15, 1);
27
-        add_action('lsx_sharing_settings_page', array( $this, 'configure_archive_fields' ), 15, 1);
28
-        add_action('admin_enqueue_scripts', array( $this, 'assets' ));
24
+    public function __construct(){
25
+         add_action('cmb2_admin_init',array($this,'register_settings_page'));
26
+        add_action('lsx_sharing_settings_page',array($this,'configure_general_fields'),15,1);
27
+        add_action('lsx_sharing_settings_page',array($this,'configure_archive_fields'),15,1);
28
+        add_action('admin_enqueue_scripts',array($this,'assets'));
29 29
     }
30 30
 
31 31
     /**
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @return object \lsx\sharing\classes\admin\Settings()    A single instance of this class.
37 37
      */
38
-    public static function get_instance() {
38
+    public static function get_instance(){
39 39
          // If the single instance hasn't been set, set it now.
40
-        if ( null == self::$instance ) {
41
-            self::$instance = new self();
40
+        if(null==self::$instance){
41
+            self::$instance=new self();
42 42
         }
43 43
         return self::$instance;
44 44
     }
@@ -48,25 +48,25 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return void
50 50
      */
51
-    public function register_settings_page() {
52
-         $args = array(
51
+    public function register_settings_page(){
52
+         $args=array(
53 53
 			 'id'           => 'lsx_sharing_settings',
54
-			 'title'        => '<h1>' . esc_html__('LSX Sharing Settings', 'lsx-search') . ' <span class="version">' . LSX_SHARING_VER . '</span></h1>',
55
-			 'menu_title'   => esc_html__('LSX Sharing', 'search'), // Falls back to 'title' (above).
56
-			 'object_types' => array( 'options-page' ),
57
-			 'option_key'   => 'lsx-sharing-settings', // The option key and admin menu page slug.
54
+			 'title'        => '<h1>'.esc_html__('LSX Sharing Settings','lsx-search').' <span class="version">'.LSX_SHARING_VER.'</span></h1>',
55
+			 'menu_title'   => esc_html__('LSX Sharing','search'),// Falls back to 'title' (above).
56
+			 'object_types' => array('options-page'),
57
+			 'option_key'   => 'lsx-sharing-settings',// The option key and admin menu page slug.
58 58
 			 'parent_slug'  => 'options-general.php',
59
-			 'capability'   => 'manage_options', // Cap required to view options-page.
59
+			 'capability'   => 'manage_options',// Cap required to view options-page.
60 60
 		 );
61
-        $cmb  = new_cmb2_box($args);
62
-        do_action('lsx_sharing_settings_page', $cmb);
61
+        $cmb=new_cmb2_box($args);
62
+        do_action('lsx_sharing_settings_page',$cmb);
63 63
     }
64 64
 
65 65
     /**
66 66
      * Enqueue JS and CSS.
67 67
      */
68
-    public function assets( $hook ) {
69
-         wp_enqueue_style('lsx-sharing-admin', LSX_SHARING_URL . 'assets/css/lsx-sharing-admin.css', array(), LSX_SHARING_VER);
68
+    public function assets($hook){
69
+         wp_enqueue_style('lsx-sharing-admin',LSX_SHARING_URL.'assets/css/lsx-sharing-admin.css',array(),LSX_SHARING_VER);
70 70
     }
71 71
 
72 72
     /**
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @return void
76 76
      */
77
-    public function configure_general_fields( $cmb ) {
78
-         $global_args = array(
79
-			 'title' => __('Global', 'lsx-search'),
80
-			 'desc'  => esc_html__('Control the sharing WordPress post types.', 'lsx-search'),
77
+    public function configure_general_fields($cmb){
78
+         $global_args=array(
79
+			 'title' => __('Global','lsx-search'),
80
+			 'desc'  => esc_html__('Control the sharing WordPress post types.','lsx-search'),
81 81
 		 );
82
-        $this->get_fields($cmb, 'global', $global_args);
82
+        $this->get_fields($cmb,'global',$global_args);
83 83
     }
84 84
 
85 85
     /**
@@ -89,93 +89,93 @@  discard block
 block discarded – undo
89 89
      * @param  string $position either top of bottom.
90 90
      * @return void
91 91
      */
92
-    public function configure_archive_fields( $cmb ) {
93
-         $archives       = array();
94
-        $post_type_args = array(
92
+    public function configure_archive_fields($cmb){
93
+         $archives=array();
94
+        $post_type_args=array(
95 95
 			'public' => true,
96 96
         );
97
-        $post_types     = get_post_types($post_type_args);
98
-        if ( ! empty($post_types) ) {
99
-            foreach ( $post_types as $post_type_key => $post_type_value ) {
100
-                switch ( $post_type_key ) {
97
+        $post_types=get_post_types($post_type_args);
98
+        if(!empty($post_types)){
99
+            foreach($post_types as $post_type_key => $post_type_value){
100
+                switch($post_type_key){
101 101
 					case 'post':
102
-						$page_url      = home_url();
103
-						$page_title    = __('Home', 'lsx-search');
104
-						$show_on_front = get_option('show_on_front');
105
-						if ( 'page' === $show_on_front ) {
106
-								$page_for_posts = get_option('page_for_posts');
107
-							if ( '' !== $page_for_posts ) {
108
-								$page_title   = get_the_title($page_for_posts);
109
-								$page_url     = get_permalink($page_for_posts);
102
+						$page_url=home_url();
103
+						$page_title=__('Home','lsx-search');
104
+						$show_on_front=get_option('show_on_front');
105
+						if('page'===$show_on_front){
106
+								$page_for_posts=get_option('page_for_posts');
107
+							if(''!==$page_for_posts){
108
+								$page_title=get_the_title($page_for_posts);
109
+								$page_url=get_permalink($page_for_posts);
110 110
 							}
111 111
 						}
112
-						$description = sprintf(
112
+						$description=sprintf(
113 113
 						/* translators: %s: The subscription info */
114
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> posts.', 'lsx-search'),
114
+							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> posts.','lsx-search'),
115 115
 							$page_url,
116 116
 							$page_title
117 117
 						);
118
-						$archives[ $post_type_key ] = array(
119
-							'title' => __('Blog', 'lsx-search'),
118
+						$archives[$post_type_key]=array(
119
+							'title' => __('Blog','lsx-search'),
120 120
 							'desc'  => $description,
121 121
 						);
122 122
 					break;
123 123
 
124 124
 					case 'product':
125
-						$page_url = home_url();
126
-						$page_title    = __('Shop', 'lsx-search');
127
-						if ( function_exists('wc_get_page_id') ) {
128
-							$shop_page  = wc_get_page_id('shop');
129
-							$page_url   = get_permalink($shop_page);
130
-							$page_title = get_the_title($shop_page);
125
+						$page_url=home_url();
126
+						$page_title=__('Shop','lsx-search');
127
+						if(function_exists('wc_get_page_id')){
128
+							$shop_page=wc_get_page_id('shop');
129
+							$page_url=get_permalink($shop_page);
130
+							$page_title=get_the_title($shop_page);
131 131
 						}
132
-						$description = sprintf(
132
+						$description=sprintf(
133 133
 						/* translators: %s: The subscription info */
134
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
134
+							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.','lsx-search'),
135 135
 							$page_url,
136 136
 							$page_title
137 137
 						);
138
-						$archives[ $post_type_key ] = array(
139
-							'title' => __('Shop', 'lsx-search'),
138
+						$archives[$post_type_key]=array(
139
+							'title' => __('Shop','lsx-search'),
140 140
 							'desc'  => $description,
141 141
 						);
142 142
 					break;
143 143
 
144 144
 					case 'custom_title':
145
-						$page_url = home_url();
146
-						$page_title    = __('Shop', 'lsx-search');
147
-						if ( function_exists('wc_get_page_id') ) {
148
-							$shop_page  = wc_get_page_id('shop');
149
-							$page_url   = get_permalink($shop_page);
150
-							$page_title = get_the_title($shop_page);
145
+						$page_url=home_url();
146
+						$page_title=__('Shop','lsx-search');
147
+						if(function_exists('wc_get_page_id')){
148
+							$shop_page=wc_get_page_id('shop');
149
+							$page_url=get_permalink($shop_page);
150
+							$page_title=get_the_title($shop_page);
151 151
 						}
152
-						$description = sprintf(
152
+						$description=sprintf(
153 153
 						/* translators: %s: The subscription info */
154
-							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search'),
154
+							__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.','lsx-search'),
155 155
 							$page_url,
156 156
 							$page_title
157 157
 						);
158
-						$archives[ $post_type_key ] = array(
159
-							'title' => __('Custom Title', 'lsx-search'),
158
+						$archives[$post_type_key]=array(
159
+							'title' => __('Custom Title','lsx-search'),
160 160
 							'desc'  => $description,
161 161
 						);
162 162
 					break;
163 163
 
164 164
 					default:
165
-						if ( in_array($post_type_key, \lsx\sharing\includes\functions\get_restricted_post_types()) ) {
165
+						if(in_array($post_type_key,\lsx\sharing\includes\functions\get_restricted_post_types())){
166 166
 								break;
167 167
 						}
168
-						$temp_post_type = get_post_type_object($post_type_key);
169
-						if ( ! is_wp_error($temp_post_type) ) {
170
-							$page_url    = get_post_type_archive_link($temp_post_type->name);
171
-							$description = sprintf(
168
+						$temp_post_type=get_post_type_object($post_type_key);
169
+						if(!is_wp_error($temp_post_type)){
170
+							$page_url=get_post_type_archive_link($temp_post_type->name);
171
+							$description=sprintf(
172 172
 							/* translators: %s: The subscription info */
173
-								__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> singles.', 'lsx-search'),
173
+								__('Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> singles.','lsx-search'),
174 174
 								$page_url,
175 175
 								$temp_post_type->label
176 176
 							);
177 177
 
178
-							$archives[ $post_type_key ] = array(
178
+							$archives[$post_type_key]=array(
179 179
 								'title' => $temp_post_type->label,
180 180
 								'desc'  => $description,
181 181
 							);
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
                 }
185 185
             }
186 186
         }
187
-        if ( ! empty($archives) ) {
188
-            foreach ( $archives as $archive_key => $archive_args ) {
189
-                $this->get_fields($cmb, $archive_key, $archive_args);
187
+        if(!empty($archives)){
188
+            foreach($archives as $archive_key => $archive_args){
189
+                $this->get_fields($cmb,$archive_key,$archive_args);
190 190
             }
191 191
         }
192 192
     }
@@ -198,85 +198,85 @@  discard block
 block discarded – undo
198 198
      * @param  array  $args
199 199
      * @return void
200 200
      */
201
-    public function get_fields( $cmb, $section, $args ) {
201
+    public function get_fields($cmb,$section,$args){
202 202
          $cmb->add_field(
203 203
             array(
204
-				'id'          => 'settings_' . $section . '_sharing',
204
+				'id'          => 'settings_'.$section.'_sharing',
205 205
 				'type'        => 'title',
206 206
 				'name'        => $args['title'],
207 207
 				'default'     => $args['title'],
208 208
 				'description' => $args['desc'],
209 209
             )
210 210
         );
211
-        if ( 'global' === $section ) {
211
+        if('global'===$section){
212 212
             $cmb->add_field(
213 213
                 array(
214
-					'name'        => esc_html__('Disable all', 'lsx-sharing'),
215
-					'id'          => $section . '_disable_all',
216
-					'description' => esc_html__('Disable all share buttons on the site', 'lsx-sharing'),
214
+					'name'        => esc_html__('Disable all','lsx-sharing'),
215
+					'id'          => $section.'_disable_all',
216
+					'description' => esc_html__('Disable all share buttons on the site','lsx-sharing'),
217 217
 					'type'        => 'checkbox',
218 218
                 )
219 219
             );
220
-        } else {
220
+        }else{
221 221
             $cmb->add_field(
222 222
                 array(
223
-					'name'        => esc_html__('Disable', 'lsx-sharing'),
224
-					'id'          => $section . '_disable_pt',
225
-					'description' => esc_html__('Disable the share buttons on this post type', 'lsx-sharing'),
223
+					'name'        => esc_html__('Disable','lsx-sharing'),
224
+					'id'          => $section.'_disable_pt',
225
+					'description' => esc_html__('Disable the share buttons on this post type','lsx-sharing'),
226 226
 					'type'        => 'checkbox',
227 227
                 )
228 228
             );
229 229
         }
230 230
 
231
-		if ( 'global' === $section ) {
232
-			$label_text_description = esc_html__( 'If no text is specified per post type this text will display.' , 'lsx-sharing' );
233
-		} else {
234
-			$label_text_description = esc_html__( 'A default label for the sharing.', 'lsx-sharing' );
231
+		if('global'===$section){
232
+			$label_text_description=esc_html__('If no text is specified per post type this text will display.','lsx-sharing');
233
+		}else{
234
+			$label_text_description=esc_html__('A default label for the sharing.','lsx-sharing');
235 235
 		}
236 236
 		
237 237
         $cmb->add_field(
238 238
             array(
239
-				'name'        => esc_html__( 'Label text', 'lsx-sharing' ),
240
-				'id'          => $section . '_label_text',
239
+				'name'        => esc_html__('Label text','lsx-sharing'),
240
+				'id'          => $section.'_label_text',
241 241
 				'description' => $label_text_description,
242 242
 				'type'        => 'text',
243 243
             )
244 244
         );
245
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'facebook' ) ) ) {
245
+        if('global'===$section||('global'!==$section&&!\lsx\sharing\includes\functions\is_button_disabled('global','facebook'))){
246 246
             $cmb->add_field(
247 247
                 array(
248
-					'name'        => esc_html__( 'Disable Facebook', 'lsx-sharing' ),
249
-					'id'          => $section . '_disable_facebook',
250
-					'description' => esc_html__( 'Disable Facebook share button.', 'lsx-sharing' ),
248
+					'name'        => esc_html__('Disable Facebook','lsx-sharing'),
249
+					'id'          => $section.'_disable_facebook',
250
+					'description' => esc_html__('Disable Facebook share button.','lsx-sharing'),
251 251
 					'type'        => 'checkbox',
252 252
                 )
253 253
             );
254 254
         }
255
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'twitter' ) ) ) {
255
+        if('global'===$section||('global'!==$section&&!\lsx\sharing\includes\functions\is_button_disabled('global','twitter'))){
256 256
             $cmb->add_field(
257 257
                 array(
258
-					'name'        => esc_html__( 'Disable Twitter', 'lsx-sharing' ),
259
-					'id'          => $section . '_disable_twitter',
260
-					'description' => esc_html__( 'Disable Twitter share button.', 'lsx-sharing' ),
258
+					'name'        => esc_html__('Disable Twitter','lsx-sharing'),
259
+					'id'          => $section.'_disable_twitter',
260
+					'description' => esc_html__('Disable Twitter share button.','lsx-sharing'),
261 261
 					'type'        => 'checkbox',
262 262
                 )
263 263
             );
264 264
         }
265
-        if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled( 'global', 'pinterest' ) ) ) {
265
+        if('global'===$section||('global'!==$section&&!\lsx\sharing\includes\functions\is_button_disabled('global','pinterest'))){
266 266
             $cmb->add_field(
267 267
                 array(
268
-					'name'        => esc_html__( 'Disable Pinterest', 'lsx-sharing'),
269
-					'id'          => $section . '_disable_pinterest',
270
-					'description' => esc_html__( 'Disable Pinterest button.', 'lsx-sharing'),
268
+					'name'        => esc_html__('Disable Pinterest','lsx-sharing'),
269
+					'id'          => $section.'_disable_pinterest',
270
+					'description' => esc_html__('Disable Pinterest button.','lsx-sharing'),
271 271
 					'type'        => 'checkbox',
272 272
                 )
273 273
             );
274 274
         }
275 275
 
276
-        do_action( 'lsx_sharing_settings_section', $cmb, $section );
276
+        do_action('lsx_sharing_settings_section',$cmb,$section);
277 277
         $cmb->add_field(
278 278
             array(
279
-				'id'   => $section . '_title_closing',
279
+				'id'   => $section.'_title_closing',
280 280
 				'type' => 'tab_closing',
281 281
             )
282 282
         );
Please login to merge, or discard this patch.