Widgets on Pages - Version 1.3

Version Description

  1. Adding buttons to admin UI for copying/pasting the Shortcodes and Template Tags
  2. PRO - More Auto-Insert options. Can now auto-insert before/after header or footer, too.
  3. Updated main admin page to show video how to, following feedback from users.
  4. Fixed issue with < PHP5.5. Introduced with the conditional showing of shortcode/template-tag meta boxes as part of v1.2
Download this release

Release Info

Developer toddhalfpenny
Plugin Icon 128x128 Widgets on Pages
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.3 to 1.3

admin/class-widgets-on-pages-admin.php CHANGED
@@ -41,8 +41,8 @@ class Widgets_On_Pages_Admin
41
  * Initialize the class and set its properties.
42
  *
43
  * @since 1.0.0
44
- * @param string $plugin_name The name of this plugin.
45
- * @param string $version The version of this plugin.
46
  */
47
  public function __construct( $plugin_name, $version )
48
  {
@@ -66,17 +66,19 @@ class Widgets_On_Pages_Admin
66
  add_action( 'widgets_init', array( $this, 'wop_register_sidebar' ) );
67
  add_action( 'admin_menu', array( $this, 'wop_remove_hidden_meta' ) );
68
  // Shortcode/Template Tag Custom Meta on Turbo Sidebar CTP.
69
- add_action( 'load-post.php', function () {
70
- add_action( 'add_meta_boxes', array( $this, 'wop_add_edit_only_custom_meta' ) );
71
- } );
72
  add_filter(
73
  'contextual_help',
74
  array( $this, 'wop_plugin_help' ),
75
  10,
76
  3
77
  );
 
 
 
 
78
  }
79
-
80
  /**
81
  * Sets "Settings" link on listing in Plugins screen.
82
  *
@@ -89,7 +91,7 @@ class Widgets_On_Pages_Admin
89
  'settings' => '<a href="' . admin_url( '/options-general.php?page=widgets-on-pages' ) . '">' . __( 'Settings', 'widgets-on-pages' ) . '</a>',
90
  ), $links );
91
  }
92
-
93
  /**
94
  * Adds extra links under plugin description in listing on Plugins screen.
95
  *
@@ -99,7 +101,7 @@ class Widgets_On_Pages_Admin
99
  */
100
  public function wop_register_plugins_links( $links, $file )
101
  {
102
-
103
  if ( strpos( $file, $this->plugin_name ) !== false ) {
104
  $new_links = array(
105
  'donate' => '<a href="https://datamad.co.uk/donate.php" target="_blank">Donate</a>',
@@ -107,10 +109,10 @@ class Widgets_On_Pages_Admin
107
  );
108
  $links = array_merge( $links, $new_links );
109
  }
110
-
111
  return $links;
112
  }
113
-
114
  /**
115
  * Adds Admin Menu item.
116
  *
@@ -146,7 +148,7 @@ class Widgets_On_Pages_Admin
146
  'edit.php?post_type=turbo-sidebar-cpt'
147
  );
148
  }
149
-
150
  /**
151
  * Register our setting
152
  *
@@ -156,7 +158,7 @@ class Widgets_On_Pages_Admin
156
  {
157
  register_setting( 'wop_options', 'wop_options_field' );
158
  }
159
-
160
  /**
161
  * Render the options page for plugin
162
  *
@@ -166,27 +168,27 @@ class Widgets_On_Pages_Admin
166
  {
167
  include_once 'partials/widgets-on-pages-admin-display.php';
168
  }
169
-
170
  /**
171
  * Render the options page for plugin
172
  *
173
- * @param string $text The old help.
174
- * @param string $screen_id Unique string id of the screen.
175
  * @param WP_Screen $screen Current WP_Screen instance.
176
  * @since 1.0.0
177
  */
178
  public function wop_plugin_help( $text, $screen_id, $screen )
179
  {
180
-
181
  if ( $screen_id == $this->wop_option_screen_id ) {
182
  $text = '<h5>Need help with the Widgets on Pages plugin?</h5>';
183
  $text .= '<p>Check out the documentation and support forums for help with this plugin.</p>';
184
  $text .= '<a href="http://wordpress.org/extend/plugins/widgets-on-pages/">Documentation</a><br /><a href="https://wordpress.org/support/plugin/widgets-on-pages/">Support forums</a>';
185
  }
186
-
187
  return $text;
188
  }
189
-
190
  /**
191
  * Removes meta boxes from admin screen
192
  *
@@ -196,7 +198,19 @@ class Widgets_On_Pages_Admin
196
  {
197
  remove_meta_box( 'postexcerpt', 'turbo-sidebar-cpt', 'normal' );
198
  }
199
-
 
 
 
 
 
 
 
 
 
 
 
 
200
  /**
201
  * Adds meta boxes from admin screen (Shortcode and Template Tag)
202
  *
@@ -215,7 +229,7 @@ class Widgets_On_Pages_Admin
215
  null
216
  );
217
  }
218
-
219
  /**
220
  * Adds meta boxes from admin screen
221
  *
@@ -224,7 +238,26 @@ class Widgets_On_Pages_Admin
224
  public function wop_add_custom_meta()
225
  {
226
  }
227
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  /**
229
  * Shortcode metabox markup
230
  *
@@ -235,17 +268,141 @@ class Widgets_On_Pages_Admin
235
  {
236
  echo __( '<h4>Shortcode</h4><p>Use this shortcode in your post/page</h4>', 'widgets-on-pages' ) ;
237
  $shortcode_id = '[widgets_on_pages id="' . $post->post_title . '"]';
238
- echo '<p id="wop-shortcode">' . $shortcode_id . '</p>' ;
 
 
 
 
 
 
 
 
 
239
  echo __( '<h4>Template Tag</h4><p>Use this code to include the sidebar in your theme.</h4>', 'widgets-on-pages' ) ;
240
  $shortcode_id = esc_html( '<?php widgets_on_template("' . $post->post_title . '");?>' );
241
- echo '<p id="wop-template-tag">' . $shortcode_id . '</p>' ;
242
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  /**
245
  * Creates a new Turbo Sidebars custom post type
246
  *
247
- * @since 1.0.0
248
- * @uses register_post_type()
249
  */
250
  public static function wop_cpt_turbo_sidebars()
251
  {
@@ -269,7 +426,7 @@ class Widgets_On_Pages_Admin
269
  $opts['rewrite'] = false;
270
  $opts['show_in_admin_bar'] = false;
271
  $opts['show_in_menu'] = 'admin.php?page=widgets-on-pages';
272
- // $opts['show_in_menu'] = true;
273
  $opts['show_in_nav_menu'] = false;
274
  $opts['show_ui'] = true;
275
  $opts['supports'] = array( 'title', 'excerpt' );
@@ -309,7 +466,7 @@ class Widgets_On_Pages_Admin
309
  $opts = apply_filters( 'turbo-sidebars-cpt-options', $opts );
310
  register_post_type( strtolower( $cpt_name ), $opts );
311
  }
312
-
313
  /**
314
  * Register the sidebars, based upon our Turbo Sidebars.
315
  *
@@ -327,7 +484,7 @@ class Widgets_On_Pages_Admin
327
  $myposts = get_posts( $args );
328
  foreach ( $myposts as $post ) {
329
  setup_postdata( $post );
330
-
331
  if ( is_numeric( $post->post_name ) ) {
332
  $name = 'Widgets on Pages ' . $post->post_name;
333
  $shortcode_id = $post->post_name;
@@ -337,7 +494,7 @@ class Widgets_On_Pages_Admin
337
  $id = 'wop-' . $post->post_name;
338
  $shortcode_id = $post->post_title;
339
  }
340
-
341
  if ( '' != $post->post_excerpt ) {
342
  $id = 'wop-' . $post->post_excerpt;
343
  }
@@ -354,7 +511,7 @@ class Widgets_On_Pages_Admin
354
  ) );
355
  }
356
  }
357
-
358
  /**
359
  * Register the stylesheets for the admin area.
360
  *
@@ -381,14 +538,50 @@ class Widgets_On_Pages_Admin
381
  'all'
382
  );
383
  }
384
-
385
  /**
386
  * Register the JavaScript for the admin area.
387
  *
 
388
  * @since 1.0.0
389
  */
390
- public function enqueue_scripts()
391
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  }
393
 
394
- }
41
  * Initialize the class and set its properties.
42
  *
43
  * @since 1.0.0
44
+ * @param string $plugin_name The name of this plugin.
45
+ * @param string $version The version of this plugin.
46
  */
47
  public function __construct( $plugin_name, $version )
48
  {
66
  add_action( 'widgets_init', array( $this, 'wop_register_sidebar' ) );
67
  add_action( 'admin_menu', array( $this, 'wop_remove_hidden_meta' ) );
68
  // Shortcode/Template Tag Custom Meta on Turbo Sidebar CTP.
69
+ add_action( 'load-post.php', array( $this, 'wop_load_post_hook' ) );
 
 
70
  add_filter(
71
  'contextual_help',
72
  array( $this, 'wop_plugin_help' ),
73
  10,
74
  3
75
  );
76
+ if ( wop_fs()->is_not_paying() ) {
77
+ // Auto Insert Turbo Sidebar PRO-feature Custom Meta.
78
+ add_action( 'add_meta_boxes', array( $this, 'wop_add_free_custom_meta' ) );
79
+ }
80
  }
81
+
82
  /**
83
  * Sets "Settings" link on listing in Plugins screen.
84
  *
91
  'settings' => '<a href="' . admin_url( '/options-general.php?page=widgets-on-pages' ) . '">' . __( 'Settings', 'widgets-on-pages' ) . '</a>',
92
  ), $links );
93
  }
94
+
95
  /**
96
  * Adds extra links under plugin description in listing on Plugins screen.
97
  *
101
  */
102
  public function wop_register_plugins_links( $links, $file )
103
  {
104
+
105
  if ( strpos( $file, $this->plugin_name ) !== false ) {
106
  $new_links = array(
107
  'donate' => '<a href="https://datamad.co.uk/donate.php" target="_blank">Donate</a>',
109
  );
110
  $links = array_merge( $links, $new_links );
111
  }
112
+
113
  return $links;
114
  }
115
+
116
  /**
117
  * Adds Admin Menu item.
118
  *
148
  'edit.php?post_type=turbo-sidebar-cpt'
149
  );
150
  }
151
+
152
  /**
153
  * Register our setting
154
  *
158
  {
159
  register_setting( 'wop_options', 'wop_options_field' );
160
  }
161
+
162
  /**
163
  * Render the options page for plugin
164
  *
168
  {
169
  include_once 'partials/widgets-on-pages-admin-display.php';
170
  }
171
+
172
  /**
173
  * Render the options page for plugin
174
  *
175
+ * @param string $text The old help.
176
+ * @param string $screen_id Unique string id of the screen.
177
  * @param WP_Screen $screen Current WP_Screen instance.
178
  * @since 1.0.0
179
  */
180
  public function wop_plugin_help( $text, $screen_id, $screen )
181
  {
182
+
183
  if ( $screen_id == $this->wop_option_screen_id ) {
184
  $text = '<h5>Need help with the Widgets on Pages plugin?</h5>';
185
  $text .= '<p>Check out the documentation and support forums for help with this plugin.</p>';
186
  $text .= '<a href="http://wordpress.org/extend/plugins/widgets-on-pages/">Documentation</a><br /><a href="https://wordpress.org/support/plugin/widgets-on-pages/">Support forums</a>';
187
  }
188
+
189
  return $text;
190
  }
191
+
192
  /**
193
  * Removes meta boxes from admin screen
194
  *
198
  {
199
  remove_meta_box( 'postexcerpt', 'turbo-sidebar-cpt', 'normal' );
200
  }
201
+
202
+ /**
203
+ * Hook to add action for shortcode / template tag meta boxes
204
+ * Note: We have this seprate function for the action as we saw this error
205
+ * https://wordpress.org/support/topic/warning-call_user_func_array-expects-parameter-1-to-be-a-valid-callback-13/#post-9420083
206
+ *
207
+ * @since 1.3.0
208
+ */
209
+ public function wop_load_post_hook()
210
+ {
211
+ add_action( 'add_meta_boxes', array( $this, 'wop_add_edit_only_custom_meta' ) );
212
+ }
213
+
214
  /**
215
  * Adds meta boxes from admin screen (Shortcode and Template Tag)
216
  *
229
  null
230
  );
231
  }
232
+
233
  /**
234
  * Adds meta boxes from admin screen
235
  *
238
  public function wop_add_custom_meta()
239
  {
240
  }
241
+
242
+ /**
243
+ * Adds meta boxes from admin screen
244
+ *
245
+ * @since 1.3.0
246
+ */
247
+ public function wop_add_free_custom_meta()
248
+ {
249
+ // Auto Insert.
250
+ add_meta_box(
251
+ 'wop-cpt-autoinsert-free-meta-box',
252
+ __( 'Auto Insert', 'widgets-on-pages' ),
253
+ array( $this, 'cpt_autoinsert_free_meta_box_markup' ),
254
+ 'turbo-sidebar-cpt',
255
+ 'normal',
256
+ 'low',
257
+ null
258
+ );
259
+ }
260
+
261
  /**
262
  * Shortcode metabox markup
263
  *
268
  {
269
  echo __( '<h4>Shortcode</h4><p>Use this shortcode in your post/page</h4>', 'widgets-on-pages' ) ;
270
  $shortcode_id = '[widgets_on_pages id="' . $post->post_title . '"]';
271
+ ?>
272
+ <?php
273
+ echo '<p id="wop-shortcode">' . $shortcode_id . '</p><button type="button" id="bq_copy_sc" value="Copy Shortcode" class="button-secondary" />Copy Shortcode</button>' ;
274
+
275
+ if ( wop_fs()->is_not_paying() ) {
276
+ echo '<section><h3>' . esc_html__( 'Insert using the visual editor', 'widgets-on-pages' ) . '</h3>' ;
277
+ echo '<p><a href="' . wop_fs()->get_upgrade_url() . '">' . esc_html__( 'Upgrade Now', 'widgets-on-pages' ) . '</a>' . esc_html__( ' to use the visual editor and arrange widgets in columns, too!', 'widgets-on-pages' ) ;
278
+ echo '</section>' ;
279
+ }
280
+
281
  echo __( '<h4>Template Tag</h4><p>Use this code to include the sidebar in your theme.</h4>', 'widgets-on-pages' ) ;
282
  $shortcode_id = esc_html( '<?php widgets_on_template("' . $post->post_title . '");?>' );
283
+ echo '<p id="wop-template-tag">' . $shortcode_id . '</p><button type="button" id="bq_copy_tt" value="Copy Shortcode" class="button-secondary" />Copy PHP</button>' ;
284
  }
285
+
286
+ /**
287
+ * Auto Insert PRO INFO metabox markup
288
+ *
289
+ * @since 1.3.0
290
+ */
291
+ public function cpt_autoinsert_free_meta_box_markup()
292
+ {
293
+ ?>
294
+ <div class='inside'>
295
+ <?php
296
+ echo '<h4>' . esc_html__( 'Auto Insert options is a Widgets on Pages PRO feature', 'widgets-on-pages' ) . '</h4><p>' . esc_html__( 'To auto-insert widgets into your theme\'s header, before-or-after page content, or into your theme\'s footer you need ', 'widgets-on-pages' ) . '<a href="' . wop_fs()->get_upgrade_url() . '">Widgets on Pages PRO.</a></p><p><a href="' . wop_fs()->get_upgrade_url() . '">' . esc_html__( 'Upgrade now', 'widgets-on-pages' ) . '</a> ' . esc_html( 'to access these features (and more), updates and priority support', 'widgets-on-pages' ) . '</p>' ;
297
+ echo '<a class="button-primary" href="' . wop_fs()->get_upgrade_url() . '">' . esc_html__( 'Get PRO Features', 'widgets-on-pages' ) . '</a>' ;
298
+ ?>
299
+ </div>
300
+ <hr/>
301
+ <div class='inside'>
302
+ <h3><?php
303
+ _e( 'Auto Insert', 'widgets-on-pages' );
304
+ ?>
305
+ </h3>
306
+ <p>
307
+ <input type="radio" disabled /> Yes<br />
308
+ <input type="radio" disabled/> No
309
+ </p>
310
+ </div>
311
+
312
+ <div class='inside'>
313
+ <h3><?php
314
+ _e( 'Position', 'widgets-on-pages' );
315
+ ?>
316
+ </h3>
317
+ <p>
318
+ <input type="radio" disabled /> Before Header<br />
319
+ <input type="radio" disabled /> After Header
320
+ </p>
321
+ <p>
322
+ <input type="radio" disabled /> Before Content<br />
323
+ <input type="radio" disabled /> After Content
324
+ </p>
325
+ <p>
326
+ <input type="radio" disabled /> Before Footer<br />
327
+ <input type="radio" disabled /> After Footer
328
+ </p>
329
+ </p>
330
+ </div>
331
 
332
+ <div class='inside'>
333
+ <h3><?php
334
+ _e( 'Show on Posts / Pages', 'widgets-on-pages' );
335
+ ?>
336
+ </h3>
337
+ <p>
338
+ <input type="radio" disabled /> Posts<br />
339
+ <input type="radio" disabled /> Pages<br />
340
+ <input type="radio" disabled /> Posts &amp; Pages
341
+ </p>
342
+ </div>
343
+
344
+ <div class='inside'>
345
+ <h3><?php
346
+ _e( 'Layout Options', 'widgets-on-pages' );
347
+ ?>
348
+ </h3>
349
+ <p><?php
350
+ _e( 'Number of widget columms per screen size', 'widgets-on-pages' );
351
+ ?>
352
+ </p>
353
+ <p><label><?php
354
+ _e( 'Small Screen', 'widgets-on-pages' );
355
+ ?>
356
+ </label>
357
+ <select>
358
+ <option value="1" selected>1</option>
359
+ <option value="2">2</option>
360
+ <option value="3">3</option>
361
+ <option value="4">4</option>
362
+ </select>
363
+ </p>
364
+ <p><label><?php
365
+ _e( 'Medium Screen', 'widgets-on-pages' );
366
+ ?>
367
+ </label>
368
+ <select>
369
+ <option value="1">1</option>
370
+ <option value="2">2</option>
371
+ <option value="3">3</option>
372
+ <option value="4">4</option>
373
+ </select>
374
+ </p>
375
+ <p><label><?php
376
+ _e( 'Large Screen', 'widgets-on-pages' );
377
+ ?>
378
+ </label>
379
+ <select>
380
+ <option value="1">1</option>
381
+ <option value="2">2</option>
382
+ <option value="3">3</option>
383
+ <option value="4">4</option>
384
+ </select>
385
+ </p>
386
+ <p><label><?php
387
+ _e( 'Wide Screen', 'widgets-on-pages' );
388
+ ?>
389
+ </label>
390
+ <select>
391
+ <option value="1"></option>
392
+ <option value="2"></option>
393
+ <option value="3"></option>
394
+ <option value="4"></option>
395
+ </select>
396
+ </p>
397
+
398
+ <?php
399
+ }
400
+
401
  /**
402
  * Creates a new Turbo Sidebars custom post type
403
  *
404
+ * @since 1.0.0
405
+ * @uses register_post_type()
406
  */
407
  public static function wop_cpt_turbo_sidebars()
408
  {
426
  $opts['rewrite'] = false;
427
  $opts['show_in_admin_bar'] = false;
428
  $opts['show_in_menu'] = 'admin.php?page=widgets-on-pages';
429
+ // $opts['show_in_menu'] = true;
430
  $opts['show_in_nav_menu'] = false;
431
  $opts['show_ui'] = true;
432
  $opts['supports'] = array( 'title', 'excerpt' );
466
  $opts = apply_filters( 'turbo-sidebars-cpt-options', $opts );
467
  register_post_type( strtolower( $cpt_name ), $opts );
468
  }
469
+
470
  /**
471
  * Register the sidebars, based upon our Turbo Sidebars.
472
  *
484
  $myposts = get_posts( $args );
485
  foreach ( $myposts as $post ) {
486
  setup_postdata( $post );
487
+
488
  if ( is_numeric( $post->post_name ) ) {
489
  $name = 'Widgets on Pages ' . $post->post_name;
490
  $shortcode_id = $post->post_name;
494
  $id = 'wop-' . $post->post_name;
495
  $shortcode_id = $post->post_title;
496
  }
497
+
498
  if ( '' != $post->post_excerpt ) {
499
  $id = 'wop-' . $post->post_excerpt;
500
  }
511
  ) );
512
  }
513
  }
514
+
515
  /**
516
  * Register the stylesheets for the admin area.
517
  *
538
  'all'
539
  );
540
  }
541
+
542
  /**
543
  * Register the JavaScript for the admin area.
544
  *
545
+ * @param string $hook Name of our hook.
546
  * @since 1.0.0
547
  */
548
+ public function enqueue_scripts( $hook )
549
  {
550
+ /**
551
+ * This function is provided for demonstration purposes only.
552
+ *
553
+ * An instance of this class should be passed to the run() function
554
+ * defined in Widgets_On_Pages_Loader as all of the hooks are defined
555
+ * in that particular class.
556
+ *
557
+ * The Widgets_On_Pages_Loader will then create the relationship
558
+ * between the defined hooks and the functions defined in this
559
+ * class.
560
+ */
561
+ // Load our JS for Turbo Sidebars admin screen.
562
+
563
+ if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
564
+ $screen = get_current_screen();
565
+
566
+ if ( is_object( $screen ) && 'turbo-sidebar-cpt' == $screen->post_type ) {
567
+ wp_enqueue_script(
568
+ $this->plugin_name,
569
+ plugin_dir_url( __FILE__ ) . 'js/wop-cpt-admin.js',
570
+ array( 'jquery' ),
571
+ $this->version,
572
+ true
573
+ );
574
+ wp_enqueue_script(
575
+ $this->plugin_name . '_prem',
576
+ plugin_dir_url( __FILE__ ) . 'js/wop-cpt-admin__premium_only.js',
577
+ array( 'jquery' ),
578
+ $this->version,
579
+ true
580
+ );
581
+ }
582
+
583
+ }
584
+
585
  }
586
 
587
+ }
admin/css/widgets-on-pages-admin.css CHANGED
@@ -8,7 +8,7 @@
8
  border-radius: 5px 5px 0 0;
9
  }
10
 
11
- p#wop-shortcode {
12
  font-family: courier, monospace, sans-serif;
13
  }
14
 
@@ -21,4 +21,16 @@ i.mce-i-icon {
21
  -moz-osx-font-smoothing: grayscale;
22
  margin-left: -2px;
23
  padding-right: 2px
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
8
  border-radius: 5px 5px 0 0;
9
  }
10
 
11
+ p#wop-shortcode, p#wop-template-tag {
12
  font-family: courier, monospace, sans-serif;
13
  }
14
 
21
  -moz-osx-font-smoothing: grayscale;
22
  margin-left: -2px;
23
  padding-right: 2px
24
+ }
25
+
26
+ div#wop-cpt-autoinsert-meta-box label {
27
+ width: 9em;
28
+ display: inline-block;
29
+ }
30
+
31
+ table.wop-form-table td {
32
+ vertical-align: top;
33
+ margin-bottom: 0;
34
+ padding-bottom: 0;
35
+ padding-top: 0;
36
  }
admin/js/wop-cpt-admin.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function( $ ) {
2
+
3
+ // Copy Shortcode / Template Tag
4
+ function copyToClipboard(element) { var $temp = $("<input>");
5
+ $("body").append($temp);
6
+ $temp.val($(element).text()).select();
7
+ document.execCommand("copy");
8
+ $temp.remove();
9
+ }
10
+
11
+ $('#bq_copy_sc').on('click', function() {
12
+ copyToClipboard("#wop-shortcode")
13
+ })
14
+
15
+ $('#bq_copy_tt').on('click', function() {
16
+ copyToClipboard("#wop-template-tag")
17
+ })
18
+
19
+ });
admin/partials/widgets-on-pages-admin-display.php CHANGED
@@ -28,29 +28,32 @@
28
  }
29
  ?>
30
 
31
- <table class="form-table">
32
 
33
  <tr valign="top">
34
- <th scope="row">Enable styling (remove bullets etc)</th>
35
  <td>
36
- <?php echo '<input name="wop_options_field[enable_css]" type="checkbox" value="1" class="code" ' . checked( 1, $enable_css, false ) . ' />';
37
- ?>
 
 
 
 
 
 
38
  </td>
39
  </tr>
40
-
41
- <tr><td></td><td>
42
- <p class="submit">
43
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'widgets-on-pages' ) ?>" />
44
  </p>
45
- </td></tr>
46
- <tr><td></td>
47
- <td><input type="hidden" name="action" value="update" /></td></tr>
48
- <tr><td colspan="2">
49
  <h3>Additional Sidebars</h3>
50
  <p><strong>Note:</strong> Additional sidebars are now managed under the <a href="<?php echo admin_url( 'edit.php?post_type=turbo-sidebar-cpt' ); ?>">Turbo Sidebars menu item</a>.</p>
 
 
51
  </td></tr>
52
- <tr><td colspan='2'><h3>Rate this plugin</h3><p><a href="http://wordpress.org/support/view/plugin-reviews/widgets-on-pages?rate=5#postform" title="Rate me">If you like me, please rate me</a>... or maybe even <a href="http://datamad.co.uk/donate/" title="Show you love">donate to the author</a>... <p><p>or perhaps just spread the good word <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/extend/plugins/widgets-on-pages/" data-text="Using the Widgets on Pages WordPress plugin and lovin' it" data-via="toddhalfpenny" data-count="none">Tweet</a>
53
- </p></p></p></td></tr></table>
54
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p></td></tr>
55
  </form>
56
  </div>
28
  }
29
  ?>
30
 
31
+ <table class="form-table wop-form-table">
32
 
33
  <tr valign="top">
 
34
  <td>
35
+ <h3>Enable styling (remove bullets etc)</h3>
36
+
37
+ <?php echo '<input name="wop_options_field[enable_css]" type="checkbox" value="1" class="code" ' . checked( 1, $enable_css, false ) . ' />';
38
+ ?>
39
+ <p class="submit">
40
+ <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'widgets-on-pages' ) ?>" />
41
+ <input type="hidden" name="action" value="update" />
42
+ </p>
43
  </td>
44
  </tr>
45
+ <tr>
46
+ <td><h3>Rate this plugin</h3><p><a href="http://wordpress.org/support/view/plugin-reviews/widgets-on-pages?rate=5#postform" title="Rate me">If you like me, please rate me</a>... or maybe even <a href="http://datamad.co.uk/donate/" title="Show you love">donate to the author</a>... </p><p>or perhaps just spread the good word <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/extend/plugins/widgets-on-pages/" data-text="Using the Widgets on Pages WordPress plugin and lovin' it" data-via="toddhalfpenny" data-count="none">Tweet</a>
 
 
47
  </p>
48
+ </td>
49
+ </tr>
50
+ <tr><td>
 
51
  <h3>Additional Sidebars</h3>
52
  <p><strong>Note:</strong> Additional sidebars are now managed under the <a href="<?php echo admin_url( 'edit.php?post_type=turbo-sidebar-cpt' ); ?>">Turbo Sidebars menu item</a>.</p>
53
+ <h3>Video How To</h3>
54
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/w2LfCihCqRI" frameborder="0" allowfullscreen></iframe>
55
  </td></tr>
56
+ </table>
 
57
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p></td></tr>
58
  </form>
59
  </div>
includes/class-functions.php CHANGED
@@ -21,4 +21,67 @@ if ( ! function_exists( 'widgets_on_template' ) ) {
21
  echo Widgets_On_Pages_Public::widgets_on_template( $id );
22
  }
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  ?>
21
  echo Widgets_On_Pages_Public::widgets_on_template( $id );
22
  }
23
  }
24
+
25
+ /**
26
+ * Ajax handler to maybe return TurboSidebat content for inclusion in header/footer
27
+ *
28
+ * @since 1.3.0
29
+ */
30
+ function wop_maybe_insert_with_header() {
31
+ $pst_id = intval( $_POST['post_id'] );
32
+
33
+ $args = array(
34
+ 'post_type' => 'turbo-sidebar-cpt',
35
+ 'posts_per_page' => 50,
36
+ 'meta_query' => array(
37
+ 'relation' => 'AND',
38
+ array(
39
+ 'key' => '_wop_auto_insert',
40
+ 'value' => 0,
41
+ ),
42
+ array(
43
+ 'key' => '_wop_before_after',
44
+ 'value' => array( '2', '3', '4', '5' ), // Before header, afetr header, before footer.
45
+ 'compare' => 'IN',
46
+ ),
47
+ ),
48
+ );
49
+ $potential_turbo_sidebars = get_posts( $args );
50
+
51
+ // Check if we should exclude for this post_id.
52
+ $pst_exclude = get_post_meta( $pst_id, '_wop_exclude', true );
53
+ if ( $pst_exclude ) {
54
+ wp_die();
55
+ }
56
+
57
+ // Check if we should show for this post type.
58
+ $valid_post_types = $potential_turbo_sidebars[0]->_wop_valid_post_types;
59
+ if ( 'all' == $valid_post_types ) {
60
+ $valid_post_type = true;
61
+ } else {
62
+ $pst_type = get_post_type( $pst_id );
63
+ if ( $pst_type == $valid_post_types ) {
64
+ $valid_post_type = true;
65
+ } else {
66
+ $valid_post_type = false;
67
+ }
68
+ }
69
+
70
+ if ( $valid_post_type ) {
71
+ $arr = array(
72
+ 'id' => $potential_turbo_sidebars[0]->post_title,
73
+ 'small' => $potential_turbo_sidebars[0]->_wop_cols_small,
74
+ 'medium' => $potential_turbo_sidebars[0]->_wop_cols_medium,
75
+ 'large' => $potential_turbo_sidebars[0]->_wop_cols_large,
76
+ 'wide' => $potential_turbo_sidebars[0]->_wop_cols_wide,
77
+ );
78
+ echo $potential_turbo_sidebars[0]->_wop_before_after . 'wop--part' . Widgets_On_Pages_Public::widgets_on_page( $arr );
79
+ } else {
80
+ wp_die();
81
+ }
82
+ wp_die();
83
+ }
84
+
85
+ add_action( 'wp_ajax_wop_maybe_insert_with_header', 'wop_maybe_insert_with_header' );
86
+
87
  ?>
public/class-widgets-on-pages-public.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * The public-facing functionality of the plugin.
4
  *
@@ -8,7 +9,6 @@
8
  * @package Widgets_On_Pages
9
  * @subpackage Widgets_On_Pages/public
10
  */
11
-
12
  /**
13
  * The public-facing functionality of the plugin.
14
  *
@@ -19,143 +19,136 @@
19
  * @subpackage Widgets_On_Pages/public
20
  * @author Todd Halfpenny <todd@toddhalfpenny.com>
21
  */
22
- class Widgets_On_Pages_Public {
23
-
24
- /**
25
- * The ID of this plugin.
26
- *
27
- * @since 1.0.0
28
- * @access private
29
- * @var string $plugin_name The ID of this plugin.
30
- */
31
- private $plugin_name;
32
-
33
- /**
34
- * The version of this plugin.
35
- *
36
- * @since 1.0.0
37
- * @access private
38
- * @var string $version The current version of this plugin.
39
- */
40
- private $version;
41
-
42
- /**
43
- * Initialize the class and set its properties.
44
- *
45
- * @since 1.0.0
46
- * @param string $plugin_name The name of the plugin.
47
- * @param string $version The version of this plugin.
48
- */
49
- public function __construct( $plugin_name, $version ) {
50
-
51
- $this->plugin_name = $plugin_name;
52
- $this->version = $version;
53
-
54
- $this->widgets_on_template();
55
-
56
- add_shortcode( 'widgets_on_pages', array( $this, 'widgets_on_page' ) );
57
- }
58
-
59
-
60
- /**
61
- * Our lovely shortcode.
62
- *
63
- * @param array $atts Should contain '$id' that should match to Turbo Sidebar.
64
- * @since 1.0.0
65
- */
66
- public static function widgets_on_page( $atts ) {
67
- extract( shortcode_atts( array( 'id' => '1', 'tiny' => '1', 'small' => '1', 'medium' => '1', 'large' => '1', 'wide' => '1' ), $atts ) );
68
- $str = "<div id='" . str_replace( ' ', '_', $id ) . "' class='widgets_on_page wop_tiny" . $tiny . ' wop_small' . $small . ' wop_medium' . $medium . ' wop_large' . $large . ' wop_wide' . $wide ."'>
69
- <ul>";
70
-
71
- // Legacy bullshit.
72
- if ( is_numeric( $id ) ) {
73
- $id = 'wop-' . $id;
74
- }
75
-
76
- ob_start();
77
- if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( $id ) ) {
78
- $my_str = ob_get_contents();
79
- } else {
80
- // Ouput somethign nice to the source.
81
- $my_str = '<!-- ERROR NO TURBO SIDEBAR FOUND WITH ID ' . $id . '-->';
82
- }
83
- ob_end_clean();
84
- $str .= $my_str;
85
- $str .= '</ul></div><!-- widgets_on_page -->';
86
- return $str;
87
- }
88
-
89
-
90
- /**
91
- * Our lovely template tage handler.
92
- *
93
- * @param string $id Id that should match the ID of our Turbo Sidebar.
94
- * @since 1.0.0
95
- */
96
- public static function widgets_on_template( $id = '1' ) {
97
- $arr = array( 'id' => $id );
98
- return Widgets_On_Pages_Public::widgets_on_page( $arr );
99
- }
100
-
101
-
102
- /**
103
- * Register the stylesheets for the public-facing side of the site.
104
- *
105
- * @since 1.0.0
106
- */
107
- public function enqueue_styles() {
108
-
109
- /**
110
- * This function is provided for demonstration purposes only.
111
- *
112
- * An instance of this class should be passed to the run() function
113
- * defined in Widgets_On_Pages_Loader as all of the hooks are defined
114
- * in that particular class.
115
- *
116
- * The Widgets_On_Pages_Loader will then create the relationship
117
- * between the defined hooks and the functions defined in this
118
- * class.
119
- */
120
-
121
- $options = get_option( 'wop_options_field' );
122
- if ( ! is_array( $options ) ) {
123
- $options = array();
124
- }
125
- if ( array_key_exists( 'enable_css', $options ) ) {
126
- $tmp = get_option( 'wop_options_field' );
127
- $enable_css = $tmp['enable_css'];
128
- // $enable_css = $options["enable_css"];
129
- if ( $enable_css ) {
130
- wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public.css', array(), $this->version, 'all' );
131
- }
132
- }
133
-
134
- }
135
-
136
- /**
137
- * Register the JavaScript for the public-facing side of the site.
138
- *
139
- * @since 1.0.0
140
- */
141
- public function enqueue_scripts() {
142
-
143
- /**
144
- * This function is provided for demonstration purposes only.
145
- *
146
- * An instance of this class should be passed to the run() function
147
- * defined in Widgets_On_Pages_Loader as all of the hooks are defined
148
- * in that particular class.
149
- *
150
- * The Widgets_On_Pages_Loader will then create the relationship
151
- * between the defined hooks and the functions defined in this
152
- * class.
153
- */
154
-
155
- /*
156
- We'd put our JS here
157
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/plugin-name-public.js', array( 'jquery' ), $this->version, false );
158
- */
159
-
160
- }
161
- }
1
  <?php
2
+
3
  /**
4
  * The public-facing functionality of the plugin.
5
  *
9
  * @package Widgets_On_Pages
10
  * @subpackage Widgets_On_Pages/public
11
  */
 
12
  /**
13
  * The public-facing functionality of the plugin.
14
  *
19
  * @subpackage Widgets_On_Pages/public
20
  * @author Todd Halfpenny <todd@toddhalfpenny.com>
21
  */
22
+ class Widgets_On_Pages_Public
23
+ {
24
+ /**
25
+ * The ID of this plugin.
26
+ *
27
+ * @since 1.0.0
28
+ * @access private
29
+ * @var string $plugin_name The ID of this plugin.
30
+ */
31
+ private $plugin_name ;
32
+ /**
33
+ * The version of this plugin.
34
+ *
35
+ * @since 1.0.0
36
+ * @access private
37
+ * @var string $version The current version of this plugin.
38
+ */
39
+ private $version ;
40
+ /**
41
+ * Initialize the class and set its properties.
42
+ *
43
+ * @since 1.0.0
44
+ * @param string $plugin_name The name of the plugin.
45
+ * @param string $version The version of this plugin.
46
+ */
47
+ public function __construct( $plugin_name, $version )
48
+ {
49
+ $this->plugin_name = $plugin_name;
50
+ $this->version = $version;
51
+ $this->widgets_on_template();
52
+ add_shortcode( 'widgets_on_pages', array( $this, 'widgets_on_page' ) );
53
+ }
54
+
55
+ /**
56
+ * Our lovely shortcode.
57
+ *
58
+ * @param array $atts Should contain '$id' that should match to Turbo Sidebar.
59
+ * @since 1.0.0
60
+ */
61
+ public static function widgets_on_page( $atts )
62
+ {
63
+ extract( shortcode_atts( array(
64
+ 'id' => '1',
65
+ 'tiny' => '1',
66
+ 'small' => '1',
67
+ 'medium' => '1',
68
+ 'large' => '1',
69
+ 'wide' => '1',
70
+ ), $atts ) );
71
+ $str = '<div id=\'' . str_replace( ' ', '_', $id ) . '\' class=\'widgets_on_page wop_tiny' . $tiny . ' wop_small' . $small . ' wop_medium' . $medium . ' wop_large' . $large . ' wop_wide' . $wide . '\'>
72
+ <ul>';
73
+ // Legacy bullshit.
74
+ if ( is_numeric( $id ) ) {
75
+ $id = 'wop-' . $id;
76
+ }
77
+ ob_start();
78
+
79
+ if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( $id ) ) {
80
+ $my_str = ob_get_contents();
81
+ } else {
82
+ // Ouput somethign nice to the source.
83
+ $my_str = '<!-- ERROR NO TURBO SIDEBAR FOUND WITH ID ' . $id . '-->';
84
+ }
85
+
86
+ ob_end_clean();
87
+ $str .= $my_str;
88
+ $str .= '</ul></div><!-- widgets_on_page -->';
89
+ return $str;
90
+ }
91
+
92
+ /**
93
+ * Our lovely template tage handler.
94
+ *
95
+ * @param string $id Id that should match the ID of our Turbo Sidebar.
96
+ * @since 1.0.0
97
+ */
98
+ public static function widgets_on_template( $id = '1' )
99
+ {
100
+ $arr = array(
101
+ 'id' => $id,
102
+ );
103
+ return Widgets_On_Pages_Public::widgets_on_page( $arr );
104
+ }
105
+
106
+ /**
107
+ * Register the stylesheets for the public-facing side of the site.
108
+ *
109
+ * @since 1.0.0
110
+ */
111
+ public function enqueue_styles()
112
+ {
113
+ /**
114
+ * This function is provided for demonstration purposes only.
115
+ *
116
+ * An instance of this class should be passed to the run() function
117
+ * defined in Widgets_On_Pages_Loader as all of the hooks are defined
118
+ * in that particular class.
119
+ *
120
+ * The Widgets_On_Pages_Loader will then create the relationship
121
+ * between the defined hooks and the functions defined in this
122
+ * class.
123
+ */
124
+ $options = get_option( 'wop_options_field' );
125
+ if ( !is_array( $options ) ) {
126
+ $options = array();
127
+ }
128
+
129
+ if ( array_key_exists( 'enable_css', $options ) ) {
130
+ $tmp = get_option( 'wop_options_field' );
131
+ $enable_css = $tmp['enable_css'];
132
+ if ( $enable_css ) {
133
+ wp_enqueue_style(
134
+ $this->plugin_name,
135
+ plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public.css',
136
+ array(),
137
+ $this->version,
138
+ 'all'
139
+ );
140
+ }
141
+ }
142
+
143
+ }
144
+
145
+ /**
146
+ * Register the JavaScript for the public-facing side of the site.
147
+ *
148
+ * @since 1.0.0
149
+ */
150
+ public function enqueue_scripts()
151
+ {
152
+ }
153
+
154
+ }
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: toddhalfpenny
3
  Donate link: https://datamad.co.uk/donate/
4
  Tags: widgets, widgets in page, widgets in post, sidebar, pages, post, shortcode, inline, widgetise, widgetize, theme
5
  Requires at least: 2.8
6
- Tested up to: 4.8.1
7
- Stable tag: 1.2.3
8
 
9
  The easiest and highest rated way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
10
 
@@ -20,9 +20,21 @@ Sidebars can be included in the post/page by using a shortcode like the followin
20
 
21
  `[widgets_on_pages id=x]`
22
 
23
- > With the [PRO](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/) version the widgets can be inserted simply with clicks-not-code using a wizard in the visual editor. This version also includes layout options to easily set the widgets in columns/grid presentation.
24
  >
25
- > Pro version also supports the configurable option to automatically add widgets to all your posts and/or pages. Choose the layout options and whether to add the sidebar and widgets before or after the content. Ideal for adding lists of related posts to the end of every post. Each post and page can also be individually excluded from the auto-inclsion of the widgets.
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  The sidebars can also be added to any theme, using template tags. This is an ace way to add widgets/sidebars to a theme's header and footer (or any other part of a theme).
28
 
@@ -76,7 +88,9 @@ Yes... you can have an unlimited number of sidebars defined. The number availabl
76
 
77
  All of them. Yup, We've not come across a single non-working one yet.
78
 
79
- Yes... you can have an unlimited number of sidebars defined. The number available can be administered via the settings menu.
 
 
80
 
81
  == Screenshots ==
82
 
@@ -87,6 +101,14 @@ Yes... you can have an unlimited number of sidebars defined. The number availabl
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
 
 
 
90
  = 1.2.3 =
91
 
92
  1. Fixed [issue](https://wordpress.org/support/topic/widgets-on-pages-partially-breaks-subscribe-to-comments-reloaded/#post-9389051) - Conflict with some admin pages - Seen with Subscribe to Comments Reloaded
3
  Donate link: https://datamad.co.uk/donate/
4
  Tags: widgets, widgets in page, widgets in post, sidebar, pages, post, shortcode, inline, widgetise, widgetize, theme
5
  Requires at least: 2.8
6
+ Tested up to: 4.9
7
+ Stable tag: 1.3
8
 
9
  The easiest and highest rated way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
10
 
20
 
21
  `[widgets_on_pages id=x]`
22
 
23
+ > With the PRO version the [widgets can be inserted](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/) simply with clicks-not-code using a wizard in the visual editor. This version also includes layout options to easily set the widgets in columns/grid presentation.
24
  >
25
+ > Pro version also supports the configurable option to [automatically add widgets to all your posts and/or pages](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/). Choose the layout options and whether to add the sidebar and widgets before or after the content. Ideal for adding lists of related posts to the end of every post. Each post and page can also be individually excluded from the auto-inclsion of the widgets.
26
+ >
27
+ > [Pro version](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/) key features
28
+ > * Visual editor widget inserts
29
+ > * Responsive Horizontal/Column/Grid layout
30
+ > * Auto insert in Header, Content, or Footer
31
+ > * Priority Support
32
+
33
+ **Basic In-Content Instructions**
34
+
35
+ * Create a Turbo Sidebar, these are your special widget containers
36
+ * Add widgets to the Turbo Sidebar in the same way as you do for normal sidebars
37
+ * Add the Shortcode into your post or page where you'd like it to appear.
38
 
39
  The sidebars can also be added to any theme, using template tags. This is an ace way to add widgets/sidebars to a theme's header and footer (or any other part of a theme).
40
 
88
 
89
  All of them. Yup, We've not come across a single non-working one yet.
90
 
91
+ = Auto Import for Headers/Footers isn't working - What now? =
92
+
93
+ This is a new feature, and is handled differently for various themes. Although tested with a variety of different ones I'm aware that this might not work straight out the box for all users. Please [post a support ticket](https://wordpress.org/support/plugin/widgets-on-pages) and I'll look into it.
94
 
95
  == Screenshots ==
96
 
101
 
102
  == Changelog ==
103
 
104
+ = 1.3 =
105
+
106
+ 1. Adding buttons to admin UI for copying/pasting the Shortcodes and Template Tags
107
+ 1. PRO - More Auto-Insert options. Can now auto-insert before/after header or footer, too.
108
+ 1. Updated main admin page to show video how to, following feedback from users.
109
+ 1. Fixed [issue](https://wordpress.org/support/topic/warning-call_user_func_array-expects-parameter-1-to-be-a-valid-callback-13/#post-9420083) with < PHP5.5. Introduced with the conditional showing of shortcode/template-tag meta boxes as part of v1.2
110
+
111
+
112
  = 1.2.3 =
113
 
114
  1. Fixed [issue](https://wordpress.org/support/topic/widgets-on-pages-partially-breaks-subscribe-to-comments-reloaded/#post-9389051) - Conflict with some admin pages - Seen with Subscribe to Comments Reloaded
widgets_on_pages.php CHANGED
@@ -9,9 +9,9 @@
9
  *
10
  * @wordpress-plugin
11
  * Plugin Name: Widgets On Pages
12
- * Plugin URI: https://datamad.co.uk/widgets-on-pages
13
  * Description: The easiest way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
14
- * Version: 1.2.3
15
  * Author: Todd Halfpenny
16
  * Author URI: http://toddhalfpenny.com/
17
  * License: GPL-2.0+
@@ -19,125 +19,133 @@
19
  * Text Domain: widgets-on-pages
20
  * Domain Path: /languages
21
  */
22
- /**
23
- * Freemius Stuff.
24
- * Create a helper function for easy SDK access.
25
- */
26
- function wop_fs()
27
- {
28
- global $wop_fs ;
29
 
30
- if ( !isset( $wop_fs ) ) {
31
- // Include Freemius SDK.
32
- require_once dirname( __FILE__ ) . '/freemius/start.php';
33
- $wop_fs = fs_dynamic_init( array(
34
- 'id' => '1049',
35
- 'slug' => 'widgets-on-pages',
36
- 'type' => 'plugin',
37
- 'public_key' => 'pk_cc686be98cc9dc884d69bfce70cfc',
38
- 'is_premium' => false,
39
- 'has_addons' => false,
40
- 'has_paid_plans' => true,
41
- 'menu' => array(
42
- 'slug' => 'widgets-on-pages',
43
- 'contact' => false,
44
- ),
45
- 'is_live' => true,
46
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
47
  }
48
-
49
- return $wop_fs;
50
- }
51
-
52
- // Init Freemius.
53
- wop_fs();
54
- // Signal that SDK was initiated.
55
- do_action( 'wop_fs_loaded' );
56
- function wop_fs_custom_connect_message_on_update(
57
- $message,
58
- $user_first_name,
59
- $plugin_title,
60
- $user_login,
61
- $site_link,
62
- $freemius_link
63
- )
64
- {
65
- return sprintf(
66
- __fs( 'hey-x' ) . '<br>' . __( 'Thanks for your continuing use of %2$s. Please help us improve it even further by opting-in below.</br>By doing so, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'widgets-on-pages' ),
67
  $user_first_name,
68
- '<b>' . $plugin_title . '</b>',
69
- '<b>' . $user_login . '</b>',
70
  $site_link,
71
  $freemius_link
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  );
73
- }
74
-
75
- wop_fs()->add_filter(
76
- 'connect_message_on_update',
77
- 'wop_fs_custom_connect_message_on_update',
78
- 10,
79
- 6
80
- );
81
- // If this file is called directly, abort.
82
- if ( !defined( 'WPINC' ) ) {
83
- die;
84
- }
85
- if ( !defined( 'WOP_PLUGIN_VERSION' ) ) {
86
- define( 'WOP_PLUGIN_VERSION', '1.2.3' );
87
- }
88
- /**
89
- * The code that runs during plugin activation.
90
- * This action is documented in includes/class-widgets-on-pages-activator.php
91
- *
92
- * @param strgin $wop_plugin_version Version of our plugin.
93
- */
94
- function activate_widgets_on_pages( $wop_plugin_version )
95
- {
96
- require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-activator.php';
97
- Widgets_On_Pages_Activator::activate( $wop_plugin_version );
98
- }
99
-
100
- /**
101
- * The code that runs during plugin deactivation.
102
- * This action is documented in includes/class-widgets-on-pages-deactivator.php
103
- */
104
- function deactivate_widgets_on_pages()
105
- {
106
- require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-deactivator.php';
107
- Widgets_On_Pages_Deactivator::deactivate();
108
- }
109
-
110
- register_activation_hook( __FILE__, 'activate_widgets_on_pages' );
111
- register_deactivation_hook( __FILE__, 'deactivate_widgets_on_pages' );
112
- /**
113
- * Also check if we have updated - note activation hook not fired upon updates
114
- */
115
- function wop_plugin_check_version()
116
- {
117
- if ( WOP_PLUGIN_VERSION !== get_option( 'wop_plugin_version' ) ) {
118
- activate_widgets_on_pages( WOP_PLUGIN_VERSION );
119
  }
120
- }
121
-
122
- add_action( 'plugins_loaded', 'wop_plugin_check_version' );
123
- /**
124
- * The core plugin class that is used to define internationalization,
125
- * admin-specific hooks, and public-facing site hooks.
126
- */
127
- require plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages.php';
128
- /**
129
- * Begins execution of the plugin.
130
- *
131
- * Since everything within the plugin is registered via hooks,
132
- * then kicking off the plugin from this point in the file does
133
- * not affect the page life cycle.
134
- *
135
- * @since 1.0.0
136
- */
137
- function run_widgets_on_pages()
138
- {
139
- $plugin = new Widgets_On_Pages( WOP_PLUGIN_VERSION );
140
- $plugin->run();
141
- }
142
-
143
- run_widgets_on_pages();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  *
10
  * @wordpress-plugin
11
  * Plugin Name: Widgets On Pages
12
+ * Plugin URI: https://datamad.co.uk/wordpress-plugins/widgets-on-pages/
13
  * Description: The easiest way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
14
+ * Version: 1.3.0
15
  * Author: Todd Halfpenny
16
  * Author URI: http://toddhalfpenny.com/
17
  * License: GPL-2.0+
19
  * Text Domain: widgets-on-pages
20
  * Domain Path: /languages
21
  */
 
 
 
 
 
 
 
22
 
23
+ if ( !function_exists( 'wop_fs' ) ) {
24
+ /**
25
+ * Freemius Stuff.
26
+ * Create a helper function for easy SDK access.
27
+ */
28
+ function wop_fs()
29
+ {
30
+ global $wop_fs ;
31
+
32
+ if ( !isset( $wop_fs ) ) {
33
+ // Include Freemius SDK.
34
+ require_once dirname( __FILE__ ) . '/freemius/start.php';
35
+ $wop_fs = fs_dynamic_init( array(
36
+ 'id' => '1049',
37
+ 'slug' => 'widgets-on-pages',
38
+ 'type' => 'plugin',
39
+ 'public_key' => 'pk_cc686be98cc9dc884d69bfce70cfc',
40
+ 'is_premium' => false,
41
+ 'has_addons' => false,
42
+ 'has_paid_plans' => true,
43
+ 'menu' => array(
44
+ 'slug' => 'widgets-on-pages',
45
+ 'contact' => false,
46
+ ),
47
+ 'is_live' => true,
48
+ ) );
49
+ }
50
+
51
+ return $wop_fs;
52
  }
53
+
54
+ // Init Freemius.
55
+ wop_fs();
56
+ // Signal that SDK was initiated.
57
+ do_action( 'wop_fs_loaded' );
58
+ function wop_fs_custom_connect_message_on_update(
59
+ $message,
 
 
 
 
 
 
 
 
 
 
 
 
60
  $user_first_name,
61
+ $plugin_title,
62
+ $user_login,
63
  $site_link,
64
  $freemius_link
65
+ )
66
+ {
67
+ return sprintf(
68
+ __fs( 'hey-x' ) . '<br>' . __( 'Thanks for your continuing use of %2$s. Please help us improve it even further by opting-in below.</br>By doing so, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'widgets-on-pages' ),
69
+ $user_first_name,
70
+ '<b>' . $plugin_title . '</b>',
71
+ '<b>' . $user_login . '</b>',
72
+ $site_link,
73
+ $freemius_link
74
+ );
75
+ }
76
+
77
+ wop_fs()->add_filter(
78
+ 'connect_message_on_update',
79
+ 'wop_fs_custom_connect_message_on_update',
80
+ 10,
81
+ 6
82
  );
83
+ // If this file is called directly, abort.
84
+ if ( !defined( 'WPINC' ) ) {
85
+ die;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+ if ( !defined( 'WOP_PLUGIN_VERSION' ) ) {
88
+ define( 'WOP_PLUGIN_VERSION', '1.3.0' );
89
+ }
90
+ /**
91
+ * The code that runs during plugin activation.
92
+ * This action is documented in includes/class-widgets-on-pages-activator.php
93
+ *
94
+ * @param strgin $wop_plugin_version Version of our plugin.
95
+ */
96
+ function activate_widgets_on_pages( $wop_plugin_version )
97
+ {
98
+ require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-activator.php';
99
+ Widgets_On_Pages_Activator::activate( $wop_plugin_version );
100
+ }
101
+
102
+ /**
103
+ * The code that runs during plugin deactivation.
104
+ * This action is documented in includes/class-widgets-on-pages-deactivator.php
105
+ */
106
+ function deactivate_widgets_on_pages()
107
+ {
108
+ require_once plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages-deactivator.php';
109
+ Widgets_On_Pages_Deactivator::deactivate();
110
+ }
111
+
112
+ register_activation_hook( __FILE__, 'activate_widgets_on_pages' );
113
+ register_deactivation_hook( __FILE__, 'deactivate_widgets_on_pages' );
114
+ /**
115
+ * Also check if we have updated - note activation hook not fired upon updates
116
+ */
117
+ function wop_plugin_check_version()
118
+ {
119
+ if ( WOP_PLUGIN_VERSION !== get_option( 'wop_plugin_version' ) ) {
120
+ activate_widgets_on_pages( WOP_PLUGIN_VERSION );
121
+ }
122
+ }
123
+
124
+ add_action( 'plugins_loaded', 'wop_plugin_check_version' );
125
+ /**
126
+ * The core plugin class that is used to define internationalization,
127
+ * admin-specific hooks, and public-facing site hooks.
128
+ */
129
+ require plugin_dir_path( __FILE__ ) . 'includes/class-widgets-on-pages.php';
130
+ /**
131
+ * Begins execution of the plugin.
132
+ *
133
+ * Since everything within the plugin is registered via hooks,
134
+ * then kicking off the plugin from this point in the file does
135
+ * not affect the page life cycle.
136
+ *
137
+ * @since 1.0.0
138
+ */
139
+ function run_widgets_on_pages()
140
+ {
141
+ $plugin = new Widgets_On_Pages( WOP_PLUGIN_VERSION );
142
+ $plugin->run();
143
+ }
144
+
145
+ run_widgets_on_pages();
146
+ } else {
147
+ $args = array(
148
+ 'back_link' => true,
149
+ );
150
+ wp_die( '<h1>Activation Failed</h1><p>Sorry, looks like you already have another version of Widgets on Pages already activated.</p><p>Please deactivate any other versions before re-attempting to activate</p>', 'Plugin activation failed', $args );
151
+ }