Shared.php
134 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress\Includes\Traits; |
| 4 | |
| 5 | if ( !defined( 'ABSPATH' ) ) { |
| 6 | exit; |
| 7 | } // Exit if accessed directly |
| 8 | use \EmbedPress\Includes\Classes\EmbedPress_Plugin_Usage_Tracker; |
| 9 | use \EmbedPress\Includes\Classes\EmbedPress_Notice; |
| 10 | |
| 11 | use PriyoMukul\WPNotice\Notices; |
| 12 | |
| 13 | trait Shared { |
| 14 | |
| 15 | private $insights = null; |
| 16 | |
| 17 | |
| 18 | /** |
| 19 | * Optional usage tracker |
| 20 | * |
| 21 | * @since v1.0.0 |
| 22 | */ |
| 23 | public function start_plugin_tracking() { |
| 24 | $this->insights = $tracker = EmbedPress_Plugin_Usage_Tracker::get_instance( EMBEDPRESS_FILE, [ |
| 25 | 'opt_in' => true, |
| 26 | 'goodbye_form' => true, |
| 27 | 'item_id' => '98ba0ac16a4f7b3b940d' |
| 28 | ] ); |
| 29 | $tracker->set_notice_options(array( |
| 30 | 'notice' => __( 'Want to help make <strong>EmbedPress</strong> even more awesome? You can get a <strong>10% discount coupon</strong> for Premium extensions if you allow us to track the usage.', 'embedpress' ), |
| 31 | 'extra_notice' => __( 'We collect non-sensitive diagnostic data and plugin usage information. |
| 32 | Your site URL, WordPress & PHP version, plugins & themes and email address to send you the |
| 33 | discount coupon. This data lets us make sure this plugin always stays compatible with the most |
| 34 | popular plugins and themes. No spam, I promise.', 'embedpress' ), |
| 35 | )); |
| 36 | $tracker->init(); |
| 37 | } |
| 38 | |
| 39 | public function admin_notice() { |
| 40 | $_assets_url = plugins_url( 'assets/', EMBEDPRESS_PLUGIN_BASENAME ); |
| 41 | |
| 42 | $notices = new Notices([ |
| 43 | 'id' => 'embedpress', |
| 44 | 'store' => 'options', |
| 45 | 'storage_key' => 'notices', |
| 46 | 'version' => '1.0.0', |
| 47 | 'lifetime' => 3, |
| 48 | 'styles' => $_assets_url . 'css/admin-notices.css', |
| 49 | ]); |
| 50 | |
| 51 | /** |
| 52 | * This is review message and thumbnail. |
| 53 | */ |
| 54 | $_review_notice = [ |
| 55 | 'thumbnail' => $_assets_url . 'images/icon-128x128.png', |
| 56 | 'html' => '<p>' . __( 'We hope you\'re enjoying EmbedPress! Could you please do us a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'embedpress' ) . '</p>', |
| 57 | 'links' => [ |
| 58 | 'later' => array( |
| 59 | 'link' => 'https://wordpress.org/support/plugin/embedpress/reviews/', |
| 60 | 'target' => '_blank', |
| 61 | 'label' => __('Ok, you deserve it!', 'wp-scheduled-posts'), |
| 62 | 'icon_class' => 'dashicons dashicons-external', |
| 63 | ), |
| 64 | 'allready' => array( |
| 65 | 'label' => __('I already did', 'wp-scheduled-posts'), |
| 66 | 'icon_class' => 'dashicons dashicons-smiley', |
| 67 | 'attributes' => [ |
| 68 | 'data-dismiss' => true |
| 69 | ], |
| 70 | ), |
| 71 | 'maybe_later' => array( |
| 72 | 'label' => __('Maybe Later', 'wp-scheduled-posts'), |
| 73 | 'icon_class' => 'dashicons dashicons-calendar-alt', |
| 74 | 'attributes' => [ |
| 75 | 'data-later' => true |
| 76 | ], |
| 77 | ), |
| 78 | 'support' => array( |
| 79 | 'link' => 'https://wpdeveloper.com/support', |
| 80 | 'label' => __('I need help', 'wp-scheduled-posts'), |
| 81 | 'icon_class' => 'dashicons dashicons-sos', |
| 82 | ), |
| 83 | 'never_show_again' => array( |
| 84 | 'label' => __('Never show again', 'wp-scheduled-posts'), |
| 85 | 'icon_class' => 'dashicons dashicons-dismiss', |
| 86 | 'attributes' => [ |
| 87 | 'data-dismiss' => true |
| 88 | ], |
| 89 | ), |
| 90 | ], |
| 91 | ]; |
| 92 | |
| 93 | $notices->add( |
| 94 | 'review', |
| 95 | $_review_notice, |
| 96 | [ |
| 97 | 'start' => $notices->strtotime( '+15 day' ), |
| 98 | 'recurrence' => 30, |
| 99 | 'dismissible' => true, |
| 100 | 'refresh' => EMBEDPRESS_VERSION, |
| 101 | ] |
| 102 | ); |
| 103 | |
| 104 | $notices->add( |
| 105 | 'optin', |
| 106 | [$this->insights, 'notice'], |
| 107 | [ |
| 108 | 'start' => $notices->time(), |
| 109 | 'recurrence' => 30, |
| 110 | 'dismissible' => true, |
| 111 | 'refresh' => EMBEDPRESS_VERSION, |
| 112 | 'do_action' => 'wpdeveloper_notice_clicked_for_embedpress', |
| 113 | 'display_if' => ! is_array( $notices->is_installed( 'embedpress-pro/embedpress-pro.php' ) ) |
| 114 | ] |
| 115 | ); |
| 116 | |
| 117 | $notices->init(); |
| 118 | } |
| 119 | |
| 120 | public function is_pro_active() { |
| 121 | return is_plugin_active( 'embedpress-pro/embedpress-pro.php' ); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Show Admin notice when one of embedpress old plugin active |
| 126 | * |
| 127 | * @since 2.4.0 |
| 128 | */ |
| 129 | public function embedpress_admin_notice() { |
| 130 | |
| 131 | } |
| 132 | |
| 133 | } |
| 134 |