Shared.php
154 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 | trait Shared { |
| 12 | |
| 13 | |
| 14 | /** |
| 15 | * Optional usage tracker |
| 16 | * |
| 17 | * @since v1.0.0 |
| 18 | */ |
| 19 | public function start_plugin_tracking() { |
| 20 | $tracker = EmbedPress_Plugin_Usage_Tracker::get_instance( EMBEDPRESS_FILE, [ |
| 21 | 'opt_in' => true, |
| 22 | 'goodbye_form' => true, |
| 23 | 'item_id' => '98ba0ac16a4f7b3b940d' |
| 24 | ] ); |
| 25 | $tracker->set_notice_options(array( |
| 26 | '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' ), |
| 27 | 'extra_notice' => __( 'We collect non-sensitive diagnostic data and plugin usage information. |
| 28 | Your site URL, WordPress & PHP version, plugins & themes and email address to send you the |
| 29 | discount coupon. This data lets us make sure this plugin always stays compatible with the most |
| 30 | popular plugins and themes. No spam, I promise.', 'embedpress' ), |
| 31 | )); |
| 32 | $tracker->init(); |
| 33 | } |
| 34 | |
| 35 | public function admin_notice() { |
| 36 | $notice = new EmbedPress_Notice( EMBEDPRESS_PLUGIN_BASENAME, EMBEDPRESS_VERSION ); |
| 37 | |
| 38 | /** |
| 39 | * Current Notice End Time. |
| 40 | * Notice will dismiss in 3 days if user does nothing. |
| 41 | */ |
| 42 | $notice->cne_time = '3 Day'; |
| 43 | |
| 44 | /** |
| 45 | * Current Notice Maybe Later Time. |
| 46 | * Notice will show again in 7 days |
| 47 | */ |
| 48 | $notice->maybe_later_time = '21 Day'; |
| 49 | |
| 50 | $notice->text_domain = 'embedpress'; |
| 51 | |
| 52 | $scheme = (parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY )) ? '&' : '?'; |
| 53 | $url = $_SERVER['REQUEST_URI'] . $scheme; |
| 54 | $notice->links = [ |
| 55 | 'review' => array( |
| 56 | 'later' => array( |
| 57 | 'link' => 'https://wordpress.org/support/plugin/embedpress/reviews/', |
| 58 | 'target' => '_blank', |
| 59 | 'label' => __( 'Ok, you deserve it!', 'embedpress' ), |
| 60 | 'icon_class' => 'dashicons dashicons-external', |
| 61 | ), |
| 62 | 'allready' => array( |
| 63 | 'link' => $url, |
| 64 | 'label' => __( 'I already did', 'embedpress' ), |
| 65 | 'icon_class' => 'dashicons dashicons-smiley', |
| 66 | 'data_args' => [ |
| 67 | 'dismiss' => true, |
| 68 | ], |
| 69 | ), |
| 70 | 'maybe_later' => array( |
| 71 | 'link' => $url, |
| 72 | 'label' => __( 'Maybe Later', 'embedpress' ), |
| 73 | 'icon_class' => 'dashicons dashicons-calendar-alt', |
| 74 | 'data_args' => [ |
| 75 | 'later' => true, |
| 76 | ], |
| 77 | ), |
| 78 | 'support' => array( |
| 79 | 'link' => 'https://wordpress.org/support/plugin/embedpress/', |
| 80 | 'label' => __( 'I need help', 'embedpress' ), |
| 81 | 'icon_class' => 'dashicons dashicons-sos', |
| 82 | ), |
| 83 | 'never_show_again' => array( |
| 84 | 'link' => $url, |
| 85 | 'label' => __( 'Never show again', 'embedpress' ), |
| 86 | 'icon_class' => 'dashicons dashicons-dismiss', |
| 87 | 'data_args' => [ |
| 88 | 'dismiss' => true, |
| 89 | ], |
| 90 | ), |
| 91 | ), |
| 92 | ]; |
| 93 | |
| 94 | /** |
| 95 | * This is review message and thumbnail. |
| 96 | */ |
| 97 | $notice->message( 'review', '<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>' ); |
| 98 | $notice->thumbnail( 'review', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 99 | /** |
| 100 | * This is upsale notice settings |
| 101 | * classes for wrapper, |
| 102 | * Message message for showing. |
| 103 | */ |
| 104 | $notice->classes( 'upsale', 'notice is-dismissible ' ); |
| 105 | $notice->message( 'upsale', '<p>' . __( 'Thank you for relying on EmbedPress with 30,000 other websites. Checkout our Pro features.', $notice->text_domain ) . '</p>' ); |
| 106 | |
| 107 | // Update Notice For PRO Version |
| 108 | if ( $this->is_pro_active() && \version_compare( get_embedpress_pro_version(), '2.0.0', '<' ) ) { |
| 109 | $notice->classes( 'update', 'notice is-dismissible ' ); |
| 110 | $notice->message( 'update', '<p>' . __( 'You are using an incompatible version of EmbedPress PRO. Please update to v3.4.0+. <a href="https://essential-addons.com/elementor/docs/manually-update-essential-addons-pro/" target="_blank">Follow manual update guide.</a>', 'embedpress' ) . '</p>' ); |
| 111 | $notice->thumbnail( 'update', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 112 | } |
| 113 | |
| 114 | if ( \version_compare( EMBEDPRESS_VERSION, '3.0.0', '=' ) ) { |
| 115 | $notice->classes( 'update', 'notice is-dismissible ' ); |
| 116 | $notice->message( 'update', '<p>' . __( 'EmbedPress 3.0 is here with new features and options, read the details <a href="https://wpdeveloper.com/introducing-embedpress-3.0" target="_blank">here</a>, and check the new setting page. <a href="'. admin_url('admin.php?page=embedpress') .'">Click Here.</a>', 'embedpress' ) . '</p>' ); |
| 117 | $notice->thumbnail( 'update', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 118 | } |
| 119 | |
| 120 | $notice->upsale_args = array( |
| 121 | 'href' => 'https://embedpress.com/?utm_source=plugin&utm_medium=free&utm_campaign=pro_upgrade#pricing', |
| 122 | 'btn_text' => __( 'Learn More', 'embedpress' ), |
| 123 | ); |
| 124 | |
| 125 | $notice->options_args = array( |
| 126 | 'notice_will_show' => [ |
| 127 | 'update' => $notice->timestamp, |
| 128 | 'opt_in' => $notice->makeTime( $notice->timestamp, '3 Day' ), |
| 129 | 'upsale' => $notice->makeTime( $notice->timestamp, '14 Day' ), |
| 130 | 'review' => $notice->makeTime( $notice->timestamp, '7 Day' ), // after 3 days |
| 131 | ], |
| 132 | ); |
| 133 | if ( $this->is_pro_active() && \version_compare( get_embedpress_pro_version(), '2.0.0', '<' ) ) { |
| 134 | $notice->options_args['notice_will_show']['update'] = $notice->timestamp; |
| 135 | } |
| 136 | |
| 137 | $notice->init(); |
| 138 | } |
| 139 | |
| 140 | public function is_pro_active() { |
| 141 | return is_plugin_active( 'embedpress-pro/embedpress-pro.php' ); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Show Admin notice when one of embedpress old plugin active |
| 146 | * |
| 147 | * @since 2.4.0 |
| 148 | */ |
| 149 | public function embedpress_admin_notice() { |
| 150 | |
| 151 | } |
| 152 | |
| 153 | } |
| 154 |