Shared.php
166 lines
| 1 | <?php |
| 2 | namespace EmbedPress\Includes\Traits; |
| 3 | |
| 4 | if (!defined('ABSPATH')) { |
| 5 | exit; |
| 6 | } // Exit if accessed directly |
| 7 | use \EmbedPress\Includes\Classes\EmbedPress_Plugin_Usage_Tracker; |
| 8 | use \EmbedPress\Includes\Classes\EmbedPress_Notice; |
| 9 | |
| 10 | trait Shared { |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * Optional usage tracker |
| 15 | * |
| 16 | * @since v1.0.0 |
| 17 | */ |
| 18 | public function start_plugin_tracking() { |
| 19 | new EmbedPress_Plugin_Usage_Tracker( |
| 20 | EMBEDPRESS_FILE, |
| 21 | 'http://app.wpdeveloper.net', |
| 22 | array(), |
| 23 | true, |
| 24 | true, |
| 25 | 1 |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | public function admin_notice() { |
| 30 | $notice = new EmbedPress_Notice(EMBEDPRESS_PLUGIN_BASENAME, EMBEDPRESS_VERSION); |
| 31 | |
| 32 | /** |
| 33 | * Current Notice End Time. |
| 34 | * Notice will dismiss in 3 days if user does nothing. |
| 35 | */ |
| 36 | $notice->cne_time = '3 Day'; |
| 37 | |
| 38 | /** |
| 39 | * Current Notice Maybe Later Time. |
| 40 | * Notice will show again in 7 days |
| 41 | */ |
| 42 | $notice->maybe_later_time = '21 Day'; |
| 43 | |
| 44 | $notice->text_domain = 'embedpress'; |
| 45 | |
| 46 | $scheme = (parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY)) ? '&' : '?'; |
| 47 | $url = $_SERVER['REQUEST_URI'] . $scheme; |
| 48 | $notice->links = [ |
| 49 | 'review' => array( |
| 50 | 'later' => array( |
| 51 | 'link' => 'https://wordpress.org/support/plugin/embedpress/reviews/', |
| 52 | 'target' => '_blank', |
| 53 | 'label' => __('Ok, you deserve it!', 'embedpress'), |
| 54 | 'icon_class' => 'dashicons dashicons-external', |
| 55 | ), |
| 56 | 'allready' => array( |
| 57 | 'link' => $url, |
| 58 | 'label' => __('I already did', 'embedpress'), |
| 59 | 'icon_class' => 'dashicons dashicons-smiley', |
| 60 | 'data_args' => [ |
| 61 | 'dismiss' => true, |
| 62 | ], |
| 63 | ), |
| 64 | 'maybe_later' => array( |
| 65 | 'link' => $url, |
| 66 | 'label' => __('Maybe Later', 'embedpress'), |
| 67 | 'icon_class' => 'dashicons dashicons-calendar-alt', |
| 68 | 'data_args' => [ |
| 69 | 'later' => true, |
| 70 | ], |
| 71 | ), |
| 72 | 'support' => array( |
| 73 | 'link' => 'https://wordpress.org/support/plugin/embedpress/', |
| 74 | 'label' => __('I need help', 'embedpress'), |
| 75 | 'icon_class' => 'dashicons dashicons-sos', |
| 76 | ), |
| 77 | 'never_show_again' => array( |
| 78 | 'link' => $url, |
| 79 | 'label' => __('Never show again', 'embedpress'), |
| 80 | 'icon_class' => 'dashicons dashicons-dismiss', |
| 81 | 'data_args' => [ |
| 82 | 'dismiss' => true, |
| 83 | ], |
| 84 | ), |
| 85 | ), |
| 86 | ]; |
| 87 | |
| 88 | /** |
| 89 | * This is review message and thumbnail. |
| 90 | */ |
| 91 | $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>'); |
| 92 | $notice->thumbnail('review', plugins_url('assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME)); |
| 93 | /** |
| 94 | * This is upsale notice settings |
| 95 | * classes for wrapper, |
| 96 | * Message message for showing. |
| 97 | */ |
| 98 | $notice->classes( 'upsale', 'notice is-dismissible ' ); |
| 99 | $notice->message( 'upsale', '<p>'. __( 'If you are using Gutenberg, you must install <a href="https://essential-blocks.com/" target="_blank">Essential Blocks</a>, it extends your capacity, with 22 Free Blocks!', $notice->text_domain ) .'</p>' ); |
| 100 | $notice->thumbnail( 'upsale', plugins_url( 'assets/images/essential-blocks.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 101 | |
| 102 | // Update Notice For PRO Version |
| 103 | if( $this->is_pro_active() && \version_compare( EMBEDPRESS_PRO_VERSION, '2.0.0', '<' ) ) { |
| 104 | $notice->classes( 'update', 'notice is-dismissible ' ); |
| 105 | $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>', $notice->text_domain ) .'</p>' ); |
| 106 | $notice->thumbnail( 'update', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 107 | } |
| 108 | |
| 109 | $notice->upsale_args = array( |
| 110 | 'slug' => 'essential-blocks', |
| 111 | 'page_slug' => 'essential-blocks', |
| 112 | 'file' => 'essential-blocks.php', |
| 113 | 'btn_text' => __( 'Install Free', 'embedpress'), |
| 114 | 'condition' => [ |
| 115 | 'by' => 'class', |
| 116 | 'class' => 'EssentialAdmin' |
| 117 | ], |
| 118 | ); |
| 119 | |
| 120 | $notice->options_args = array( |
| 121 | 'notice_will_show' => [ |
| 122 | 'opt_in' => $notice->timestamp, |
| 123 | 'upsale' => $notice->makeTime($notice->timestamp, '14 Day'), |
| 124 | 'review' => $notice->makeTime($notice->timestamp, '7 Day'), // after 3 days |
| 125 | ], |
| 126 | ); |
| 127 | if( $this->is_pro_active() && \version_compare( EMBEDPRESS_PRO_VERSION, '2.0.0', '<' ) ) { |
| 128 | $notice->options_args['notice_will_show']['update'] = $notice->timestamp; |
| 129 | } |
| 130 | |
| 131 | $notice->init(); |
| 132 | } |
| 133 | |
| 134 | public function is_pro_active(){ |
| 135 | return is_plugin_active('embedpress-pro/embedpress-pro.php'); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Show Admin notice when one of embedpress old plugin active |
| 140 | * |
| 141 | * @since 2.4.0 |
| 142 | */ |
| 143 | public function embedpress_admin_notice(){ |
| 144 | |
| 145 | if (get_option( 'embedpress_dismiss_notice' ) == true || $this->is_pro_active() ) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | $plugin_list = [ |
| 150 | 'embedpress-vimeo/embedpress-vimeo.php', |
| 151 | 'embedpress-wistia/embedpress-wistia.php', |
| 152 | 'embedpress-youtube/embedpress-youtube.php', |
| 153 | ]; |
| 154 | $active_plugins = get_option('active_plugins'); |
| 155 | foreach($active_plugins as $plugin){ |
| 156 | if(in_array($plugin,$plugin_list)){ |
| 157 | $msg = '<strong>[Good News]</strong> Introducing <strong>EmbedPress Pro</strong>! And as existing Loyal User you get Unlimited Sites access to EmbedPress Pro for free. Please update and claim your free license to continue. <br/><strong>[<a href="https://embedpress.com/ep-loyal-users" target="_blank" rel="noopener">Details</a>] - [<a href="https://embedpress.com/new-pro-2020-free" target="_blank" rel="noopener">Get EmbedPress Pro for Free</a>]</strong>'; |
| 158 | echo '<div class="notice notice-info embedpress-plugin-notice-dismissible is-dismissible"> |
| 159 | <p>'.$msg.'</p> |
| 160 | </div>'; |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | } |