Popups by OptinMonster – Best WordPress Lead Generation Plugin - Version 1.1.6.1

Version Description

  • General plugin enhancements and bug fixes.
Download this release

Release Info

Developer griffinjt
Plugin Icon 128x128 Popups by OptinMonster – Best WordPress Lead Generation Plugin
Version 1.1.6.1
Comparing to
See all releases

Code changes from version 1.1.6 to 1.1.6.1

Files changed (4) hide show
  1. OMAPI/Menu.php +3 -4
  2. OMAPI/Review.php +85 -270
  3. optin-monster-wp-api.php +2 -2
  4. readme.txt +3 -0
OMAPI/Menu.php CHANGED
@@ -337,10 +337,9 @@ class OMAPI_Menu {
337
  */
338
  public function footer( $text ) {
339
 
340
- $new_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">OptinMonster</a>!', 'optin-monster-api' ),
341
- 'http://optinmonster.com'
342
- );
343
- return str_replace( '</span>', '', $text ) . ' | ' . $new_text . '</span>';
344
 
345
  }
346
 
337
  */
338
  public function footer( $text ) {
339
 
340
+ $url = 'https://wordpress.org/support/plugin/optinmonster/reviews?filter=5#new-post';
341
+ $text = sprintf( __( 'Please rate <strong>OptinMonster</strong> <a href="%s" target="_blank" rel="noopener">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the OptinMonster team!', 'optin-monster-api' ), $url, $url );
342
+ return $text;
 
343
 
344
  }
345
 
OMAPI/Review.php CHANGED
@@ -85,17 +85,19 @@ class OMAPI_Review {
85
 
86
  // Set our object.
87
  $this->set();
88
- // Scripts
89
- add_action('admin_enqueue_scripts', array($this, 'maybe_enqueue_pointer') );
90
- add_action('admin_enqueue_scripts', array($this, 'maybe_enqueue_reminder_pointer') );
91
- // Options
92
- add_action('wp_ajax_set_omapi_review_reminder', array($this, 'set_user_review_reminder') );
93
  // Pages
94
- add_action('admin_menu', array($this, 'register_review_page') );
 
95
  // Action
96
- add_action( 'admin_post_omapi_send_review', array( $this, 'omapi_send_review') );
 
 
 
 
 
97
  // Admin Notices
98
- add_action('admin_notices', array($this, 'notices') );
99
 
100
  }
101
 
@@ -172,10 +174,9 @@ class OMAPI_Review {
172
  */
173
  public function footer( $text ) {
174
 
175
- $new_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">OptinMonster</a>!', 'optin-monster-api' ),
176
- 'http://optinmonster.com'
177
- );
178
- return str_replace( '</span>', '', $text ) . ' | ' . $new_text . '</span>';
179
 
180
  }
181
 
@@ -359,9 +360,6 @@ class OMAPI_Review {
359
 
360
  $message = isset($action_query) ? $action_query : 'success';
361
 
362
- // Stop the review pointers from showing since they tried submitting a valid form
363
- $this->dismiss_all_the_pointers();
364
-
365
  // Update array
366
  $data_array['status'] = 'finished';
367
 
@@ -374,283 +372,118 @@ class OMAPI_Review {
374
  }
375
 
376
  /**
377
- * Maybe add in our pointer
378
  *
379
- * @since 1.1.4.5
380
- * @param $hook_suffix
381
  */
382
- public function maybe_enqueue_pointer( $hook_suffix ) {
383
-
384
- $enqueue_pointer_script_style = false;
385
-
386
- $current_screen = get_current_screen();
387
- $show_on = array('dashboard', 'plugins', 'toplevel_page_optin-monster-api-settings' );
388
-
389
- if( ! in_array( $current_screen->id, $show_on ) ) {
390
- return;
391
- }
392
-
393
- // If no API credentials have been entered, hide the notice.
394
  if ( ! $this->base->get_api_credentials() ) {
395
  return;
396
  }
397
 
398
- // Get array list of dismissed pointers for current user and convert it to array
399
- $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
400
-
401
- // Check if our pointer is not among dismissed ones and that the user should see this
402
- if( !in_array( 'omapi_review_pointer', $dismissed_pointers ) && current_user_can('activate_plugins') ) {
403
- $time = get_user_meta( get_current_user_id(), '_om_pointer_time', true );
404
- if ( ! $time ) {
405
- update_user_meta( get_current_user_id(), '_om_pointer_time', strtotime( '+1 week' ) );
406
- return;
407
- } else {
408
- // Don't enqueue if it hasn't been a week.
409
- if ( $time > time() ) {
410
- return;
411
- }
 
412
  }
413
-
414
- $enqueue_pointer_script_style = true;
415
-
416
- // Add footer scripts using callback function
417
- add_action( 'admin_print_footer_scripts', array( $this, 'pointer_review_content') );
418
  }
419
 
420
- // Enqueue pointer CSS and JS files, if needed
421
- if( $enqueue_pointer_script_style ) {
422
- wp_enqueue_style( 'wp-pointer' );
423
- wp_enqueue_script( 'wp-pointer' );
424
- }
425
-
426
- }
427
-
428
- /**
429
- * Maybe add in our reminder pointer
430
- *
431
- * @since 1.1.4.5
432
- * @param $hook_suffix
433
- */
434
- public function maybe_enqueue_reminder_pointer( $hook_suffix ) {
435
-
436
- $enqueue_pointer_script_style = false;
437
-
438
- $current_screen = get_current_screen();
439
- $show_on = array('dashboard', 'plugins', 'toplevel_page_optin-monster-api-settings' );
440
-
441
- if( ! in_array( $current_screen->id, $show_on ) ) {
442
  return;
443
  }
444
 
445
- $reminder_time = get_user_meta( get_current_user_id(), 'omapi_reminder', true );
446
- if ( $reminder_time === '') {
 
 
 
 
 
447
  return;
448
  }
449
 
450
- // Get array list of dismissed pointers for current user and convert it to array
451
- $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
452
-
453
- // Make sure the initial pointer has been viewed and user still has permissions
454
- if( in_array( 'omapi_review_pointer', $dismissed_pointers ) && !in_array( 'omapi_reminder_pointer', $dismissed_pointers) && current_user_can('activate_plugins') ) {
455
-
456
- if ( current_time('timestamp') > $reminder_time ) {
457
- $enqueue_pointer_script_style = true;
458
 
459
- // Add footer scripts using callback function
460
- add_action( 'admin_print_footer_scripts', array( $this, 'pointer_review_content_reminder') );
 
 
461
  }
462
 
 
 
 
 
463
  }
464
 
465
- // Enqueue pointer CSS and JS files, if needed
466
- if( $enqueue_pointer_script_style ) {
467
- wp_enqueue_style( 'wp-pointer' );
468
- wp_enqueue_script( 'wp-pointer' );
469
  }
470
 
471
- }
472
-
473
- /**
474
- * Ask for OptinMonster review
475
- *
476
- * @since 1.1.4.5
477
- */
478
- public function pointer_review_content() {
479
-
480
- $pointer_content = '<h3 class="omapi-pointer_review">' . __( 'Rate OptinMonster', 'optin-monster-api' ) . '</h3>';
481
- $pointer_content .= '<p><strong>' . __("Thank you for using OptinMonster.","optin-monster-api") . '</strong></p>';
482
- $pointer_content .= '<p>' . __("Would you mind taking a moment to rate it? It wont take more than two minutes.", "optin-monster-api") . '</p>';
483
- $pointer_content .= '<p><strong>' . __("Thanks for your support!", "optin-monster-api") . '</strong></p>';
484
- $pointer_content .= '<p><a class="button button-primary button-hero omapi-pointer_button" href="' . esc_url_raw( admin_url( 'admin.php?page=optin-monster-api-review' ) ) . '">' . __("Rate OptinMonster Now","optin-monster-api") . '</a></p>';
485
- $pointer_content .= '<p><a id="omapi-pointer_remind-me-later" class="button button-secondary button-hero omapi-pointer_button" href="#" >' . __("Remind me later","optin-monster-api") . '</a></p>';
486
- $nothanks = __( 'No, thanks', 'optin-monster-api' );
487
- ?>
488
-
489
- <script type="text/javascript">
490
- jQuery(document).ready( function($) {
491
- var nothanks = '<?php echo $nothanks; ?>';
492
- $('#toplevel_page_optin-monster-api-settings').pointer({
493
- content: '<?php echo $pointer_content; ?>',
494
- position: {
495
- edge: 'left',
496
- align: 'middle'
497
- },
498
- pointerWidth: 270,
499
- buttons: function( event, t ) {
500
- var button = $('<a class="close omapi-pointer_close-override" href="#">' + nothanks + '</a>');
501
-
502
- return button.bind( 'click.pointer', function(e) {
503
- e.preventDefault();
504
- t.element.pointer('close');
505
- });
506
- },
507
- close: function() {
508
- $.post( ajaxurl, {
509
- pointer: 'omapi_review_pointer',
510
- action: 'dismiss-wp-pointer'
511
- });
512
- }
513
- }).pointer('open');
514
-
515
- $('#omapi-pointer_remind-me-later').click(function( event ) {
516
- event.preventDefault();
517
- //Set the pointer to be closed for this user
518
- $.post( ajaxurl, {
519
- pointer: 'omapi_review_pointer',
520
- action: 'dismiss-wp-pointer'
521
- });
522
- $.post( ajaxurl, {
523
- omapi_reminder: 'omapi_review_pointer',
524
- action: 'set_omapi_review_reminder'
525
- });
526
- $('#omapi-pointer_remind-me-later').parents('.wp-pointer').remove();
527
- });
528
- });
529
- </script>
530
- <style type="text/css">
531
- .wp-pointer-content h3.omapi-pointer_review {
532
- background: #0085BA;
533
- }
534
- .wp-pointer-content h3.omapi-pointer_review::before {
535
- content: "\f529";
536
- color: #fff;
537
- background: transparent;
538
- }
539
- .wp-pointer-content .omapi-pointer_button {
540
- width: 100%;
541
- text-align: center;
542
- }
543
- .wp-pointer-buttons .close.omapi-pointer_close-override {
544
- float: left;
545
- margin-left: 15px;
546
- }
547
- </style>
548
- <?php
549
- }
550
-
551
- /**
552
- * Requested reminder to review OptinMonster
553
- *
554
- * @since 1.1.4.5
555
- */
556
- public function pointer_review_content_reminder(){
557
-
558
- $pointer_content = '<h3 class="omapi-pointer_review">' . __( 'Rate OptinMonster', 'optin-monster-api' ) . '</h3>';
559
- $pointer_content .= '<p><strong>' . __("Thank you for using OptinMonster.","optin-monster-api") . '</strong></p>';
560
- $pointer_content .= '<p>' . __("You asked to be reminded to review OptinMonster.","optin-monster-api") . '</p>';
561
- $pointer_content .= '<p><strong>' . __("Thanks for your support!","optin-monster-api") . '</strong></p>';
562
- $pointer_content .= '<p><a id="omapi-pointer_review-now" class="button button-primary button-hero omapi-pointer_button" href="' . esc_url_raw( admin_url( 'admin.php?page=optin-monster-api-review' ) ) . '">' . __("Rate OptinMonster Now","optin-monster-api") . '</a></p>';
563
- $pointer_content .= '<p><a id="omapi-pointer_remind-me-later" class="button button-secondary button-hero omapi-pointer_button" href="#" >' . __("Remind me later","optin-monster-api") . '</a></p>';
564
- $nothanks = __( 'No, thanks', 'optin-monster-api' );
565
  ?>
566
-
 
 
 
 
 
 
 
 
567
  <script type="text/javascript">
568
  jQuery(document).ready( function($) {
569
- var nothanks = '<?php echo $nothanks; ?>';
570
- $('#toplevel_page_optin-monster-api-settings').pointer({
571
- content: '<?php echo $pointer_content; ?>',
572
- position: {
573
- edge: 'left',
574
- align: 'middle'
575
- },
576
- pointerWidth: 270,
577
- buttons: function( event, t ) {
578
- var button = $('<a class="close omapi-pointer_close-override" href="#">' + nothanks + '</a>');
579
-
580
- return button.bind( 'click.pointer', function(e) {
581
- e.preventDefault();
582
- t.element.pointer('close');
583
- });
584
- },
585
- close: function() {
586
- $.post( ajaxurl, {
587
- pointer: 'omapi_reminder_pointer',
588
- action: 'dismiss-wp-pointer'
589
- });
590
  }
591
- }).pointer('open');
592
 
593
- $('#omapi-pointer_remind-me-later').click(function( event ) {
594
- event.preventDefault();
595
  $.post( ajaxurl, {
596
- omapi_reminder: 'omapi_review_pointer',
597
- action: 'set_omapi_review_reminder'
598
  });
599
- $('#omapi-pointer_remind-me-later').parents('.wp-pointer').remove();
600
- });
601
 
602
- $('#omapi-pointer_review-now').click(function( event ) {
603
- event.preventDefault();
604
- $.post( ajaxurl, {
605
- omapi_reminder: 'omapi_review_pointer',
606
- action: 'set_omapi_review_reminder'
607
- });
608
- //Set the pointer to be closed for this user
609
- $.post( ajaxurl, {
610
- pointer: 'omapi_review_pointer',
611
- action: 'dismiss-wp-pointer'
612
- });
613
- $('#omapi-pointer_remind-me-later').parents('.wp-pointer').remove();
614
  });
615
  });
616
  </script>
617
- <style type="text/css">
618
- .wp-pointer-content h3.omapi-pointer_review {
619
- background: #0085BA;
620
- }
621
- .wp-pointer-content h3.omapi-pointer_review::before {
622
- content: "\f529";
623
- color: #fff;
624
- background: transparent;
625
- }
626
- .wp-pointer-content .omapi-pointer_button {
627
- width: 100%;
628
- text-align: center;
629
- }
630
- .wp-pointer-buttons .close.omapi-pointer_close-override {
631
- float: left;
632
- margin-left: 15px;
633
- }
634
- </style>
635
- <?php
636
-
637
  }
638
 
639
  /**
640
- * Set the review reminder user_meta
641
  *
642
- * @since 1.1.4.5
643
  */
644
- public function set_user_review_reminder() {
645
-
646
- //set reminder time 1 week from now
647
- $reminder_time = (int) strtotime("+1 week");
648
-
649
- //update user_meta with request
650
- update_user_meta( get_current_user_id(), 'omapi_reminder', $reminder_time);
651
 
652
- wp_die();
 
653
 
 
 
654
  }
655
 
656
  /**
@@ -676,22 +509,4 @@ class OMAPI_Review {
676
 
677
  }
678
 
679
- /**
680
- * Add all review pointers as read for current user
681
- *
682
- * @since 1.1.4.5
683
- *
684
- */
685
- public function dismiss_all_the_pointers() {
686
-
687
- $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
688
- $review_pointers = array('omapi_review_pointer', 'omapi_reminder_pointer');
689
-
690
- $dismissed = array_merge( $dismissed, $review_pointers);
691
- $dismissed = implode( ',', $dismissed);
692
-
693
- update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
694
-
695
- }
696
-
697
  }
85
 
86
  // Set our object.
87
  $this->set();
88
+
 
 
 
 
89
  // Pages
90
+ add_action( 'admin_menu', array( $this, 'register_review_page' ) );
91
+
92
  // Action
93
+ add_action( 'admin_post_omapi_send_review', array( $this, 'omapi_send_review' ) );
94
+
95
+ // Review Notices
96
+ add_action( 'admin_notices', array( $this, 'review' ) );
97
+ add_action( 'wp_ajax_omapi_dismiss_review', array( $this, 'dismiss_review' ) );
98
+
99
  // Admin Notices
100
+ add_action( 'admin_notices', array( $this, 'notices' ) );
101
 
102
  }
103
 
174
  */
175
  public function footer( $text ) {
176
 
177
+ $url = 'https://wordpress.org/support/plugin/optinmonster/reviews?filter=5#new-post';
178
+ $text = sprintf( __( 'Please rate <strong>OptinMonster</strong> <a href="%s" target="_blank" rel="noopener">&#9733;&#9733;&#9733;&#9733;&#9733;</a> on <a href="%s" target="_blank">WordPress.org</a> to help us spread the word. Thank you from the OptinMonster team!', 'optin-monster-api' ), $url, $url );
179
+ return $text;
 
180
 
181
  }
182
 
360
 
361
  $message = isset($action_query) ? $action_query : 'success';
362
 
 
 
 
363
  // Update array
364
  $data_array['status'] = 'finished';
365
 
372
  }
373
 
374
  /**
375
+ * Add admin notices as needed for reviews.
376
  *
377
+ * @since 1.1.6.1
 
378
  */
379
+ public function review() {
380
+ // Verify API credentials have been set.
 
 
 
 
 
 
 
 
 
 
381
  if ( ! $this->base->get_api_credentials() ) {
382
  return;
383
  }
384
 
385
+ // Verify that we can do a check for reviews.
386
+ $review = get_option( 'omapi_review' );
387
+ $time = time();
388
+ $load = false;
389
+
390
+ if ( ! $review ) {
391
+ $review = array(
392
+ 'time' => $time,
393
+ 'dismissed' => false
394
+ );
395
+ $load = true;
396
+ } else {
397
+ // Check if it has been dismissed or not.
398
+ if ( (isset( $review['dismissed'] ) && ! $review['dismissed']) && (isset( $review['time'] ) && (($review['time'] + DAY_IN_SECONDS) <= $time)) ) {
399
+ $load = true;
400
  }
 
 
 
 
 
401
  }
402
 
403
+ // If we cannot load, return early.
404
+ if ( ! $load ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  return;
406
  }
407
 
408
+ // Update the review option now.
409
+ update_option( 'omapi_review', $review );
410
+
411
+ // Run through optins on the site to see if any have been loaded for more than a week.
412
+ $valid = false;
413
+ $optins = $this->base->get_optins();
414
+ if ( ! $optins ) {
415
  return;
416
  }
417
 
418
+ foreach ( $optins as $optin ) {
419
+ // Verify the optin has been enabled.
420
+ $enabled = get_post_meta( $optin->ID, '_omapi_enabled', true );
421
+ if ( ! $enabled ) {
422
+ continue;
423
+ }
 
 
424
 
425
+ // Check the creation date of the local optin. It must be at least one week after.
426
+ $created = isset( $optin->post_date ) ? strtotime( $optin->post_date ) + (7 * DAY_IN_SECONDS) : false;
427
+ if ( ! $created ) {
428
+ continue;
429
  }
430
 
431
+ if ( $created <= $time ) {
432
+ $valid = true;
433
+ break;
434
+ }
435
  }
436
 
437
+ // If we don't have a valid optin yet, return.
438
+ if ( ! $valid ) {
439
+ return;
 
440
  }
441
 
442
+ // We have a candidate! Output a review message.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  ?>
444
+ <div class="notice notice-info is-dismissible om-review-notice">
445
+ <p><?php _e( 'Hey, I noticed you have been using OptinMonster for 7 days now - that\'s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress? This will help us spread the word and boost our motivation - thanks!', 'optin-monster-api' ); ?></p>
446
+ <p><strong><?php _e( '~ Syed Balkhi<br>Co-Founder of OptinMonster', 'optin-monster-api' ); ?></strong></p>
447
+ <p>
448
+ <a href="https://wordpress.org/support/plugin/optinmonster/reviews?filter=5#new-post" class="om-dismiss-review-notice om-review-out" target="_blank" rel="noopener"><?php _e( 'Ok, you deserve it', 'optin-monster-api' ); ?></a><br>
449
+ <a href="#" class="om-dismiss-review-notice" target="_blank" rel="noopener"><?php _e( 'Nope, maybe later', 'optin-monster-api' ); ?></a><br>
450
+ <a href="#" class="om-dismiss-review-notice" target="_blank" rel="noopener"><?php _e( 'I already did', 'optin-monster-api' ); ?></a><br>
451
+ </p>
452
+ </div>
453
  <script type="text/javascript">
454
  jQuery(document).ready( function($) {
455
+ $(document).on('click', '.om-dismiss-review-notice, .om-review-notice button', function( event ) {
456
+ if ( ! $(this).hasClass('om-review-out') ) {
457
+ event.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  }
 
459
 
 
 
460
  $.post( ajaxurl, {
461
+ action: 'omapi_dismiss_review'
 
462
  });
 
 
463
 
464
+ $('.om-review-notice').remove();
 
 
 
 
 
 
 
 
 
 
 
465
  });
466
  });
467
  </script>
468
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
 
471
  /**
472
+ * Dismiss the review nag
473
  *
474
+ * @since 1.1.6.1
475
  */
476
+ public function dismiss_review() {
477
+ $review = get_option( 'omapi_review' );
478
+ if ( ! $review ) {
479
+ $review = array();
480
+ }
 
 
481
 
482
+ $review['time'] = time();
483
+ $review['dismissed'] = true;
484
 
485
+ update_option( 'omapi_review', $review );
486
+ die;
487
  }
488
 
489
  /**
509
 
510
  }
511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  }
optin-monster-wp-api.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster forms.
6
  * Author: Thomas Griffin
7
  * Author URI: https://thomasgriffin.io
8
- * Version: 1.1.6
9
  * Text Domain: optin-monster-api
10
  * Domain Path: languages
11
  *
@@ -60,7 +60,7 @@ class OMAPI {
60
  *
61
  * @var string
62
  */
63
- public $version = '1.1.6';
64
 
65
  /**
66
  * The name of the plugin.
5
  * Description: OptinMonster API plugin to connect your WordPress site to your OptinMonster forms.
6
  * Author: Thomas Griffin
7
  * Author URI: https://thomasgriffin.io
8
+ * Version: 1.1.6.1
9
  * Text Domain: optin-monster-api
10
  * Domain Path: languages
11
  *
60
  *
61
  * @var string
62
  */
63
+ public $version = '1.1.6.1';
64
 
65
  /**
66
  * The name of the plugin.
readme.txt CHANGED
@@ -160,6 +160,9 @@ OptinMonster is the <a href="http://optinmonster.com" rel="friend" title="OptinM
160
 
161
  == Changelog ==
162
 
 
 
 
163
  = 1.1.6 =
164
  * Compatibility updates for WordPress 4.7.
165
 
160
 
161
  == Changelog ==
162
 
163
+ = 1.1.6.1 =
164
+ * General plugin enhancements and bug fixes.
165
+
166
  = 1.1.6 =
167
  * Compatibility updates for WordPress 4.7.
168