Ocean Custom Sidebar - Version 1.0.5

Version Description

  • Added: Codes for the Freemius switch.
Download this release

Release Info

Developer oceanwp
Plugin Icon 128x128 Ocean Custom Sidebar
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4 to 1.0.5

Files changed (2) hide show
  1. ocean-custom-sidebar.php +441 -394
  2. readme.txt +6 -3
ocean-custom-sidebar.php CHANGED
@@ -1,394 +1,441 @@
1
- <?php
2
- /**
3
- * Plugin Name: Ocean Custom Sidebar
4
- * Plugin URI: https://oceanwp.org/extension/ocean-custom-sidebar/
5
- * Description: Generates an unlimited number of sidebars and place them on any page you wish.
6
- * Version: 1.0.4
7
- * Author: OceanWP
8
- * Author URI: https://oceanwp.org/
9
- * Requires at least: 4.5.0
10
- * Tested up to: 5.0
11
- *
12
- * Text Domain: ocean-custom-sidebar
13
- * Domain Path: /languages/
14
- *
15
- * @package Ocean_Custom_Sidebar
16
- * @category Core
17
- * @author OceanWP
18
- * @see https://github.com/pojome/pojo-sidebars/
19
- */
20
-
21
- // Exit if accessed directly
22
- if ( ! defined( 'ABSPATH' ) ) {
23
- exit;
24
- }
25
-
26
- /**
27
- * Returns the main instance of Ocean_Custom_Sidebar to prevent the need to use globals.
28
- *
29
- * @since 1.0.0
30
- * @return object Ocean_Custom_Sidebar
31
- */
32
- function Ocean_Custom_Sidebar() {
33
- return Ocean_Custom_Sidebar::instance();
34
- } // End Ocean_Custom_Sidebar()
35
-
36
- Ocean_Custom_Sidebar();
37
-
38
- /**
39
- * Main Ocean_Custom_Sidebar Class
40
- *
41
- * @class Ocean_Custom_Sidebar
42
- * @version 1.0.0
43
- * @since 1.0.0
44
- * @package Ocean_Custom_Sidebar
45
- */
46
- final class Ocean_Custom_Sidebar {
47
- /**
48
- * Ocean_Custom_Sidebar The single instance of Ocean_Custom_Sidebar.
49
- * @var object
50
- * @access private
51
- * @since 1.0.0
52
- */
53
- private static $_instance = null;
54
-
55
- protected $_menu_parent = '';
56
- protected $_sidebars = null;
57
-
58
- /**
59
- * The token.
60
- * @var string
61
- * @access public
62
- * @since 1.0.0
63
- */
64
- public $token;
65
-
66
- /**
67
- * The version number.
68
- * @var string
69
- * @access public
70
- * @since 1.0.0
71
- */
72
- public $version;
73
-
74
- // Admin - Start
75
- /**
76
- * The admin object.
77
- * @var object
78
- * @access public
79
- * @since 1.0.0
80
- */
81
- public $admin;
82
-
83
- /**
84
- * Constructor function.
85
- * @access public
86
- * @since 1.0.0
87
- * @return void
88
- */
89
- public function __construct( $widget_areas = array() ) {
90
- $this->token = 'ocean-custom-sidebar';
91
- $this->plugin_url = plugin_dir_url( __FILE__ );
92
- $this->plugin_path = plugin_dir_path( __FILE__ );
93
- $this->version = '1.0.4';
94
-
95
- register_activation_hook( __FILE__, array( $this, 'install' ) );
96
-
97
- add_action( 'init', array( $this, 'ocs_load_plugin_textdomain' ) );
98
-
99
- add_action( 'init', array( $this, 'ocs_setup' ) );
100
- }
101
-
102
- /**
103
- * Main Ocean_Custom_Sidebar Instance
104
- *
105
- * Ensures only one instance of Ocean_Custom_Sidebar is loaded or can be loaded.
106
- *
107
- * @since 1.0.0
108
- * @static
109
- * @see Ocean_Custom_Sidebar()
110
- * @return Main Ocean_Custom_Sidebar instance
111
- */
112
- public static function instance() {
113
- if ( is_null( self::$_instance ) )
114
- self::$_instance = new self();
115
- return self::$_instance;
116
- } // End instance()
117
-
118
- /**
119
- * Load the localisation file.
120
- * @access public
121
- * @since 1.0.0
122
- * @return void
123
- */
124
- public function ocs_load_plugin_textdomain() {
125
- load_plugin_textdomain( 'ocean-custom-sidebar', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
126
- }
127
-
128
- /**
129
- * Cloning is forbidden.
130
- *
131
- * @since 1.0.0
132
- */
133
- public function __clone() {
134
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
135
- }
136
-
137
- /**
138
- * Unserializing instances of this class is forbidden.
139
- *
140
- * @since 1.0.0
141
- */
142
- public function __wakeup() {
143
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
144
- }
145
-
146
- /**
147
- * Installation.
148
- * Runs on activation. Logs the version number and assigns a notice message to a WordPress option.
149
- * @access public
150
- * @since 1.0.0
151
- * @return void
152
- */
153
- public function install() {
154
- $this->_log_version_number();
155
- }
156
-
157
- /**
158
- * Log the plugin version number.
159
- * @access private
160
- * @since 1.0.0
161
- * @return void
162
- */
163
- private function _log_version_number() {
164
- // Log the version number.
165
- update_option( $this->token . '-version', $this->version );
166
- }
167
-
168
- /**
169
- * Setup all the things.
170
- * Only executes if OceanWP or a child theme using OceanWP as a parent is active and the extension specific filter returns true.
171
- * @return void
172
- */
173
- public function ocs_setup() {
174
- $theme = wp_get_theme();
175
-
176
- if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
177
- if ( class_exists( 'Ocean_Extra' ) ) {
178
- $this->_menu_parent = 'oceanwp-panel';
179
- } else {
180
- $this->_menu_parent = 'themes.php';
181
- }
182
- $this->register_taxonomy();
183
- $this->register_sidebars();
184
- add_action( 'admin_menu', array( $this, 'register_menu' ), 11 );
185
- add_action( 'admin_head', array( $this, 'menu_highlight' ) );
186
- add_filter( 'manage_edit-ocean_sidebars_columns', array( $this, 'manage_columns' ) );
187
- add_filter( 'manage_ocean_sidebars_custom_column', array( $this, 'manage_custom_columns' ), 10, 3 );
188
- add_filter( 'manage_edit-ocean_sidebars_sortable_columns', array( $this, 'sortable_columns' ) );
189
- add_action( 'admin_head', array( $this, 'admin_head' ) );
190
- add_action( 'admin_footer', array( $this, 'admin_footer' ) );
191
- }
192
- }
193
-
194
- /**
195
- * Register Sidebars taxonomy.
196
- */
197
- protected function register_taxonomy() {
198
-
199
- $labels = array(
200
- 'name' => esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
201
- 'singular_name' => esc_html__( 'Sidebar', 'ocean-custom-sidebar' ),
202
- 'menu_name' => esc_html_x( 'Sidebars', 'Admin menu name', 'ocean-custom-sidebar' ),
203
- 'search_items' => esc_html__( 'Search Sidebars', 'ocean-custom-sidebar' ),
204
- 'all_items' => esc_html__( 'All Sidebars', 'ocean-custom-sidebar' ),
205
- 'parent_item' => esc_html__( 'Parent Sidebar', 'ocean-custom-sidebar' ),
206
- 'parent_item_colon' => esc_html__( 'Parent Sidebar:', 'ocean-custom-sidebar' ),
207
- 'edit_item' => esc_html__( 'Edit Sidebar', 'ocean-custom-sidebar' ),
208
- 'update_item' => esc_html__( 'Update Sidebar', 'ocean-custom-sidebar' ),
209
- 'add_new_item' => esc_html__( 'Add New Sidebar', 'ocean-custom-sidebar' ),
210
- 'new_item_name' => esc_html__( 'New Sidebar Name', 'ocean-custom-sidebar' ),
211
- );
212
-
213
- $args = array(
214
- 'hierarchical' => false,
215
- 'labels' => $labels,
216
- 'public' => false,
217
- 'show_in_nav_menus' => false,
218
- 'show_ui' => true,
219
- 'capabilities' => array( 'manage_options' ),
220
- 'query_var' => false,
221
- 'rewrite' => false,
222
- );
223
-
224
- register_taxonomy(
225
- 'ocean_sidebars',
226
- apply_filters( 'ocean_taxonomy_objects_sidebars', array() ),
227
- apply_filters( 'ocean_taxonomy_args_sidebars', $args )
228
- );
229
-
230
- }
231
-
232
- /**
233
- * Return the sidebar.
234
- */
235
- public function get_sidebars() {
236
-
237
- if ( is_null( $this->_sidebars ) ) {
238
- $this->_sidebars = get_terms(
239
- 'ocean_sidebars',
240
- array(
241
- 'hide_empty' => false,
242
- )
243
- );
244
- }
245
-
246
- return $this->_sidebars;
247
-
248
- }
249
-
250
- /**
251
- * If has sidebar.
252
- */
253
- public function has_sidebars() {
254
-
255
- $sidebars = $this->get_sidebars();
256
- return ! empty( $sidebars );
257
-
258
- }
259
-
260
- /**
261
- * Register the sidebar.
262
- */
263
- public function register_sidebars() {
264
-
265
- if ( ! self::has_sidebars() ) {
266
- return;
267
- }
268
-
269
- $sidebars = self::get_sidebars();
270
-
271
- foreach ( $sidebars as $sidebar ) {
272
- $sidebar_classes = array( 'ocean-sidebar' );
273
-
274
- register_sidebar(
275
- array(
276
- 'id' => 'ocs-' . sanitize_title( $sidebar->name ),
277
- 'name' => $sidebar->name,
278
- 'description' => $sidebar->description,
279
- 'before_widget' => '<div class="sidebar-box %2$s clr">',
280
- 'after_widget' => '</div>',
281
- 'before_title' => '<h4 class="widget-title">',
282
- 'after_title' => '</h4>',
283
- )
284
- );
285
-
286
- }
287
-
288
- }
289
-
290
- /**
291
- * Register the Sidebars menu.
292
- */
293
- public function register_menu() {
294
-
295
- add_submenu_page(
296
- $this->_menu_parent,
297
- esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
298
- esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
299
- 'manage_options',
300
- 'edit-tags.php?taxonomy=ocean_sidebars'
301
- );
302
-
303
- }
304
-
305
- /**
306
- * If has sidebar.
307
- */
308
- public function menu_highlight() {
309
-
310
- global $parent_file, $submenu_file;
311
-
312
- if ( 'edit-tags.php?taxonomy=ocean_sidebars' === $submenu_file ) {
313
- $parent_file = $this->_menu_parent;
314
- }
315
-
316
- }
317
-
318
- /**
319
- * Columns name.
320
- */
321
- public function manage_columns( $columns ) {
322
-
323
- $col = $columns;
324
- $columns = array(
325
- 'cb' => $col['cb'],
326
- 'name' => $col['name'],
327
- 'ID' => esc_html__( 'ID', 'ocean-custom-sidebar' ),
328
- 'description' => $col['description'],
329
- );
330
-
331
- return $columns;
332
-
333
- }
334
-
335
- /**
336
- * Sortable columns.
337
- */
338
- public function sortable_columns( $sortable_columns ) {
339
-
340
- $sortable_columns['ID'] = 'ID';
341
- return $sortable_columns;
342
-
343
- }
344
-
345
- /**
346
- * Add prefix to the ID column.
347
- */
348
- public function manage_custom_columns( $value, $column_name, $term_id ) {
349
-
350
- $term = get_term( $term_id, 'ocean_sidebars' );
351
-
352
- switch ( $column_name ) {
353
- case 'ID' :
354
- $value = 'ocs-' . sanitize_title( $term->name );
355
- break;
356
- }
357
-
358
- return $value;
359
-
360
- }
361
-
362
- /**
363
- * Hide the slug input.
364
- */
365
- public function admin_head() {
366
-
367
- if ( 'edit-ocean_sidebars' !== get_current_screen()->id ) {
368
- return;
369
- } ?>
370
-
371
- <style>#addtag div.form-field.term-name-wrap > p, #edittag tr.form-field.term-name-wrap p, #addtag div.form-field.term-description-wrap > p, #edittag tr.form-field.term-description-wrap p { opacity: 0; }#the-list tr.inline-editor .inline-edit-col label:last-child, #addtag div.form-field.term-slug-wrap, #edittag tr.form-field.term-slug-wrap { display: none; }</style>
372
-
373
- <?php
374
- }
375
-
376
- /**
377
- * Change the description of the inputs.
378
- */
379
- public function admin_footer() {
380
-
381
- if ( 'edit-ocean_sidebars' !== get_current_screen()->id ) {
382
- return;
383
- } ?>
384
-
385
- <script>jQuery( document ).ready( function( $ ) {
386
- var $wrapper = $( '#addtag, #edittag' );
387
- $wrapper.find( 'tr.form-field.term-name-wrap p, div.form-field.term-name-wrap > p' ).text( '<?php _e( 'The name of the widgets area', 'ocean-custom-sidebar' ); ?>' ).css( 'opacity', '1' );
388
- $wrapper.find( 'tr.form-field.term-description-wrap p, div.form-field.term-description-wrap > p' ).text( '<?php _e( 'The description of the widgets area (optional)', 'ocean-custom-sidebar' ); ?>' ).css( 'opacity', '1' );
389
- } );</script>
390
-
391
- <?php
392
- }
393
-
394
- } // End Class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Ocean Custom Sidebar
4
+ * Plugin URI: https://oceanwp.org/extension/ocean-custom-sidebar/
5
+ * Description: Generates an unlimited number of sidebars and place them on any page you wish.
6
+ * Version: 1.0.5
7
+ * Author: OceanWP
8
+ * Author URI: https://oceanwp.org/
9
+ * Requires at least: 4.5.0
10
+ * Tested up to: 5.2
11
+ *
12
+ * Text Domain: ocean-custom-sidebar
13
+ * Domain Path: /languages/
14
+ *
15
+ * @package Ocean_Custom_Sidebar
16
+ * @category Core
17
+ * @author OceanWP
18
+ * @see https://github.com/pojome/pojo-sidebars/
19
+ */
20
+
21
+ // Exit if accessed directly
22
+ if ( ! defined( 'ABSPATH' ) ) {
23
+ exit;
24
+ }
25
+
26
+ /**
27
+ * Returns the main instance of Ocean_Custom_Sidebar to prevent the need to use globals.
28
+ *
29
+ * @since 1.0.0
30
+ * @return object Ocean_Custom_Sidebar
31
+ */
32
+ function Ocean_Custom_Sidebar() {
33
+ return Ocean_Custom_Sidebar::instance();
34
+ } // End Ocean_Custom_Sidebar()
35
+
36
+ Ocean_Custom_Sidebar();
37
+
38
+ /**
39
+ * Main Ocean_Custom_Sidebar Class
40
+ *
41
+ * @class Ocean_Custom_Sidebar
42
+ * @version 1.0.0
43
+ * @since 1.0.0
44
+ * @package Ocean_Custom_Sidebar
45
+ */
46
+ final class Ocean_Custom_Sidebar {
47
+ /**
48
+ * Ocean_Custom_Sidebar The single instance of Ocean_Custom_Sidebar.
49
+ * @var object
50
+ * @access private
51
+ * @since 1.0.0
52
+ */
53
+ private static $_instance = null;
54
+
55
+ protected $_menu_parent = '';
56
+ protected $_sidebars = null;
57
+
58
+ /**
59
+ * The token.
60
+ * @var string
61
+ * @access public
62
+ * @since 1.0.0
63
+ */
64
+ public $token;
65
+
66
+ /**
67
+ * The version number.
68
+ * @var string
69
+ * @access public
70
+ * @since 1.0.0
71
+ */
72
+ public $version;
73
+
74
+ // Admin - Start
75
+ /**
76
+ * The admin object.
77
+ * @var object
78
+ * @access public
79
+ * @since 1.0.0
80
+ */
81
+ public $admin;
82
+
83
+ /**
84
+ * Constructor function.
85
+ * @access public
86
+ * @since 1.0.0
87
+ * @return void
88
+ */
89
+ public function __construct( $widget_areas = array() ) {
90
+ $this->token = 'ocean-custom-sidebar';
91
+ $this->plugin_url = plugin_dir_url( __FILE__ );
92
+ $this->plugin_path = plugin_dir_path( __FILE__ );
93
+ $this->version = '1.0.5';
94
+
95
+ register_activation_hook( __FILE__, array( $this, 'install' ) );
96
+
97
+ add_action( 'init', array( $this, 'ocs_load_plugin_textdomain' ) );
98
+
99
+ add_action( 'init', array( $this, 'ocs_setup' ) );
100
+ }
101
+
102
+ /**
103
+ * Main Ocean_Custom_Sidebar Instance
104
+ *
105
+ * Ensures only one instance of Ocean_Custom_Sidebar is loaded or can be loaded.
106
+ *
107
+ * @since 1.0.0
108
+ * @static
109
+ * @see Ocean_Custom_Sidebar()
110
+ * @return Main Ocean_Custom_Sidebar instance
111
+ */
112
+ public static function instance() {
113
+ if ( is_null( self::$_instance ) )
114
+ self::$_instance = new self();
115
+ return self::$_instance;
116
+ } // End instance()
117
+
118
+ /**
119
+ * Load the localisation file.
120
+ * @access public
121
+ * @since 1.0.0
122
+ * @return void
123
+ */
124
+ public function ocs_load_plugin_textdomain() {
125
+ load_plugin_textdomain( 'ocean-custom-sidebar', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
126
+ }
127
+
128
+ /**
129
+ * Cloning is forbidden.
130
+ *
131
+ * @since 1.0.0
132
+ */
133
+ public function __clone() {
134
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
135
+ }
136
+
137
+ /**
138
+ * Unserializing instances of this class is forbidden.
139
+ *
140
+ * @since 1.0.0
141
+ */
142
+ public function __wakeup() {
143
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), '1.0.0' );
144
+ }
145
+
146
+ /**
147
+ * Installation.
148
+ * Runs on activation. Logs the version number and assigns a notice message to a WordPress option.
149
+ * @access public
150
+ * @since 1.0.0
151
+ * @return void
152
+ */
153
+ public function install() {
154
+ $this->_log_version_number();
155
+ }
156
+
157
+ /**
158
+ * Log the plugin version number.
159
+ * @access private
160
+ * @since 1.0.0
161
+ * @return void
162
+ */
163
+ private function _log_version_number() {
164
+ // Log the version number.
165
+ update_option( $this->token . '-version', $this->version );
166
+ }
167
+
168
+ /**
169
+ * Setup all the things.
170
+ * Only executes if OceanWP or a child theme using OceanWP as a parent is active and the extension specific filter returns true.
171
+ * @return void
172
+ */
173
+ public function ocs_setup() {
174
+ $theme = wp_get_theme();
175
+
176
+ if ( 'OceanWP' == $theme->name || 'oceanwp' == $theme->template ) {
177
+ if ( class_exists( 'Ocean_Extra' ) ) {
178
+ $this->_menu_parent = 'oceanwp-panel';
179
+ } else {
180
+ $this->_menu_parent = 'themes.php';
181
+ }
182
+ $this->register_taxonomy();
183
+ $this->register_sidebars();
184
+ add_action( 'admin_menu', array( $this, 'register_menu' ), 11 );
185
+ add_action( 'admin_head', array( $this, 'menu_highlight' ) );
186
+ add_filter( 'manage_edit-ocean_sidebars_columns', array( $this, 'manage_columns' ) );
187
+ add_filter( 'manage_ocean_sidebars_custom_column', array( $this, 'manage_custom_columns' ), 10, 3 );
188
+ add_filter( 'manage_edit-ocean_sidebars_sortable_columns', array( $this, 'sortable_columns' ) );
189
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
190
+ add_action( 'admin_footer', array( $this, 'admin_footer' ) );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Register Sidebars taxonomy.
196
+ */
197
+ protected function register_taxonomy() {
198
+
199
+ $labels = array(
200
+ 'name' => esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
201
+ 'singular_name' => esc_html__( 'Sidebar', 'ocean-custom-sidebar' ),
202
+ 'menu_name' => esc_html_x( 'Sidebars', 'Admin menu name', 'ocean-custom-sidebar' ),
203
+ 'search_items' => esc_html__( 'Search Sidebars', 'ocean-custom-sidebar' ),
204
+ 'all_items' => esc_html__( 'All Sidebars', 'ocean-custom-sidebar' ),
205
+ 'parent_item' => esc_html__( 'Parent Sidebar', 'ocean-custom-sidebar' ),
206
+ 'parent_item_colon' => esc_html__( 'Parent Sidebar:', 'ocean-custom-sidebar' ),
207
+ 'edit_item' => esc_html__( 'Edit Sidebar', 'ocean-custom-sidebar' ),
208
+ 'update_item' => esc_html__( 'Update Sidebar', 'ocean-custom-sidebar' ),
209
+ 'add_new_item' => esc_html__( 'Add New Sidebar', 'ocean-custom-sidebar' ),
210
+ 'new_item_name' => esc_html__( 'New Sidebar Name', 'ocean-custom-sidebar' ),
211
+ );
212
+
213
+ $args = array(
214
+ 'hierarchical' => false,
215
+ 'labels' => $labels,
216
+ 'public' => false,
217
+ 'show_in_nav_menus' => false,
218
+ 'show_ui' => true,
219
+ 'capabilities' => array( 'manage_options' ),
220
+ 'query_var' => false,
221
+ 'rewrite' => false,
222
+ );
223
+
224
+ register_taxonomy(
225
+ 'ocean_sidebars',
226
+ apply_filters( 'ocean_taxonomy_objects_sidebars', array() ),
227
+ apply_filters( 'ocean_taxonomy_args_sidebars', $args )
228
+ );
229
+
230
+ }
231
+
232
+ /**
233
+ * Return the sidebar.
234
+ */
235
+ public function get_sidebars() {
236
+
237
+ if ( is_null( $this->_sidebars ) ) {
238
+ $this->_sidebars = get_terms(
239
+ 'ocean_sidebars',
240
+ array(
241
+ 'hide_empty' => false,
242
+ )
243
+ );
244
+ }
245
+
246
+ return $this->_sidebars;
247
+
248
+ }
249
+
250
+ /**
251
+ * If has sidebar.
252
+ */
253
+ public function has_sidebars() {
254
+
255
+ $sidebars = $this->get_sidebars();
256
+ return ! empty( $sidebars );
257
+
258
+ }
259
+
260
+ /**
261
+ * Register the sidebar.
262
+ */
263
+ public function register_sidebars() {
264
+
265
+ if ( ! self::has_sidebars() ) {
266
+ return;
267
+ }
268
+
269
+ $sidebars = self::get_sidebars();
270
+
271
+ foreach ( $sidebars as $sidebar ) {
272
+ $sidebar_classes = array( 'ocean-sidebar' );
273
+
274
+ register_sidebar(
275
+ array(
276
+ 'id' => 'ocs-' . sanitize_title( $sidebar->name ),
277
+ 'name' => $sidebar->name,
278
+ 'description' => $sidebar->description,
279
+ 'before_widget' => '<div class="sidebar-box %2$s clr">',
280
+ 'after_widget' => '</div>',
281
+ 'before_title' => '<h4 class="widget-title">',
282
+ 'after_title' => '</h4>',
283
+ )
284
+ );
285
+
286
+ }
287
+
288
+ }
289
+
290
+ /**
291
+ * Register the Sidebars menu.
292
+ */
293
+ public function register_menu() {
294
+
295
+ add_submenu_page(
296
+ $this->_menu_parent,
297
+ esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
298
+ esc_html__( 'Sidebars', 'ocean-custom-sidebar' ),
299
+ 'manage_options',
300
+ 'edit-tags.php?taxonomy=ocean_sidebars'
301
+ );
302
+
303
+ }
304
+
305
+ /**
306
+ * If has sidebar.
307
+ */
308
+ public function menu_highlight() {
309
+
310
+ global $parent_file, $submenu_file;
311
+
312
+ if ( 'edit-tags.php?taxonomy=ocean_sidebars' === $submenu_file ) {
313
+ $parent_file = $this->_menu_parent;
314
+ }
315
+
316
+ }
317
+
318
+ /**
319
+ * Columns name.
320
+ */
321
+ public function manage_columns( $columns ) {
322
+
323
+ $col = $columns;
324
+ $columns = array(
325
+ 'cb' => $col['cb'],
326
+ 'name' => $col['name'],
327
+ 'ID' => esc_html__( 'ID', 'ocean-custom-sidebar' ),
328
+ 'description' => $col['description'],
329
+ );
330
+
331
+ return $columns;
332
+
333
+ }
334
+
335
+ /**
336
+ * Sortable columns.
337
+ */
338
+ public function sortable_columns( $sortable_columns ) {
339
+
340
+ $sortable_columns['ID'] = 'ID';
341
+ return $sortable_columns;
342
+
343
+ }
344
+
345
+ /**
346
+ * Add prefix to the ID column.
347
+ */
348
+ public function manage_custom_columns( $value, $column_name, $term_id ) {
349
+
350
+ $term = get_term( $term_id, 'ocean_sidebars' );
351
+
352
+ switch ( $column_name ) {
353
+ case 'ID' :
354
+ $value = 'ocs-' . sanitize_title( $term->name );
355
+ break;
356
+ }
357
+
358
+ return $value;
359
+
360
+ }
361
+
362
+ /**
363
+ * Hide the slug input.
364
+ */
365
+ public function admin_head() {
366
+
367
+ if ( 'edit-ocean_sidebars' !== get_current_screen()->id ) {
368
+ return;
369
+ } ?>
370
+
371
+ <style>#addtag div.form-field.term-name-wrap > p, #edittag tr.form-field.term-name-wrap p, #addtag div.form-field.term-description-wrap > p, #edittag tr.form-field.term-description-wrap p { opacity: 0; }#the-list tr.inline-editor .inline-edit-col label:last-child, #addtag div.form-field.term-slug-wrap, #edittag tr.form-field.term-slug-wrap { display: none; }</style>
372
+
373
+ <?php
374
+ }
375
+
376
+ /**
377
+ * Change the description of the inputs.
378
+ */
379
+ public function admin_footer() {
380
+
381
+ if ( 'edit-ocean_sidebars' !== get_current_screen()->id ) {
382
+ return;
383
+ } ?>
384
+
385
+ <script>jQuery( document ).ready( function( $ ) {
386
+ var $wrapper = $( '#addtag, #edittag' );
387
+ $wrapper.find( 'tr.form-field.term-name-wrap p, div.form-field.term-name-wrap > p' ).text( '<?php _e( 'The name of the widgets area', 'ocean-custom-sidebar' ); ?>' ).css( 'opacity', '1' );
388
+ $wrapper.find( 'tr.form-field.term-description-wrap p, div.form-field.term-description-wrap > p' ).text( '<?php _e( 'The description of the widgets area (optional)', 'ocean-custom-sidebar' ); ?>' ).css( 'opacity', '1' );
389
+ } );</script>
390
+
391
+ <?php
392
+ }
393
+
394
+ } // End Class
395
+
396
+ #--------------------------------------------------------------------------------
397
+ #region Freemius
398
+ #--------------------------------------------------------------------------------
399
+
400
+ if ( ! function_exists( 'ocean_custom_sidebar_fs' ) ) {
401
+ // Create a helper function for easy SDK access.
402
+ function ocean_custom_sidebar_fs() {
403
+ global $ocean_custom_sidebar_fs;
404
+
405
+ if ( ! isset( $ocean_custom_sidebar_fs ) ) {
406
+ $ocean_custom_sidebar_fs = OceanWP_EDD_Addon_Migration::instance( 'ocean_custom_sidebar_fs' )->init_sdk( array(
407
+ 'id' => '3810',
408
+ 'slug' => 'ocean-custom-sidebar',
409
+ 'public_key' => 'pk_e1fc615375e847fd4d955c62b2a34',
410
+ 'is_premium' => false,
411
+ 'is_premium_only' => false,
412
+ 'has_paid_plans' => false,
413
+ ) );
414
+ }
415
+
416
+ return $ocean_custom_sidebar_fs;
417
+ }
418
+
419
+ function ocean_custom_sidebar_fs_addon_init() {
420
+ if ( class_exists( 'Ocean_Extra' ) ) {
421
+ OceanWP_EDD_Addon_Migration::instance( 'ocean_custom_sidebar_fs' )->init();
422
+ }
423
+ }
424
+
425
+ if ( 0 == did_action( 'owp_fs_loaded' ) ) {
426
+ // Init add-on only after parent theme was loaded.
427
+ add_action( 'owp_fs_loaded', 'ocean_custom_sidebar_fs_addon_init', 15 );
428
+ } else {
429
+ if ( class_exists( 'Ocean_Extra' ) ) {
430
+ /**
431
+ * This makes sure that if the theme was already loaded
432
+ * before the plugin, it will run Freemius right away.
433
+ *
434
+ * This is crucial for the plugin's activation hook.
435
+ */
436
+ ocean_custom_sidebar_fs_addon_init();
437
+ }
438
+ }
439
+ }
440
+
441
+ #endregion
readme.txt CHANGED
@@ -2,14 +2,14 @@
2
  Contributors: oceanwp
3
  Tags: custom, custom sidebars, personalize, sidebar, sidebars, widget, widgets, oceanwp
4
  Requires at least: 4.5
5
- Tested up to: 5.0
6
- Stable tag: 1.0.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  == Description ==
11
 
12
- Generates an unlimited number of sidebars and place them anywhere you wish. Go to Theme Panel > Sidebars to create your custom sidebars.
13
  This plugin requires the [OceanWP](https://oceanwp.org/) theme to be installed.
14
 
15
  == Installation ==
@@ -31,6 +31,9 @@ This plugin will only work with the [OceanWP](https://oceanwp.org/) theme.
31
 
32
  == Changelog ==
33
 
 
 
 
34
  = 1.0.4 =
35
  - Added: Polish translation, thanks to Fin Fafarafiel.
36
 
2
  Contributors: oceanwp
3
  Tags: custom, custom sidebars, personalize, sidebar, sidebars, widget, widgets, oceanwp
4
  Requires at least: 4.5
5
+ Tested up to: 5.2
6
+ Stable tag: 1.0.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  == Description ==
11
 
12
+ Generates an unlimited number of sidebars and place them on any page you wish. Go to Theme Panel > Sidebars to create your custom sidebars.
13
  This plugin requires the [OceanWP](https://oceanwp.org/) theme to be installed.
14
 
15
  == Installation ==
31
 
32
  == Changelog ==
33
 
34
+ = 1.0.5 =
35
+ - Added: Codes for the Freemius switch.
36
+
37
  = 1.0.4 =
38
  - Added: Polish translation, thanks to Fin Fafarafiel.
39