Shared.php
156 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 | new EmbedPress_Plugin_Usage_Tracker( |
| 21 | EMBEDPRESS_FILE, |
| 22 | 'http://app.wpdeveloper.net', |
| 23 | array(), |
| 24 | true, |
| 25 | true, |
| 26 | 1 |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | public function admin_notice() { |
| 31 | $notice = new EmbedPress_Notice( EMBEDPRESS_PLUGIN_BASENAME, EMBEDPRESS_VERSION ); |
| 32 | |
| 33 | /** |
| 34 | * Current Notice End Time. |
| 35 | * Notice will dismiss in 3 days if user does nothing. |
| 36 | */ |
| 37 | $notice->cne_time = '3 Day'; |
| 38 | |
| 39 | /** |
| 40 | * Current Notice Maybe Later Time. |
| 41 | * Notice will show again in 7 days |
| 42 | */ |
| 43 | $notice->maybe_later_time = '21 Day'; |
| 44 | |
| 45 | $notice->text_domain = 'embedpress'; |
| 46 | |
| 47 | $scheme = (parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY )) ? '&' : '?'; |
| 48 | $url = $_SERVER['REQUEST_URI'] . $scheme; |
| 49 | $notice->links = [ |
| 50 | 'review' => array( |
| 51 | 'later' => array( |
| 52 | 'link' => 'https://wordpress.org/support/plugin/embedpress/reviews/', |
| 53 | 'target' => '_blank', |
| 54 | 'label' => __( 'Ok, you deserve it!', 'embedpress' ), |
| 55 | 'icon_class' => 'dashicons dashicons-external', |
| 56 | ), |
| 57 | 'allready' => array( |
| 58 | 'link' => $url, |
| 59 | 'label' => __( 'I already did', 'embedpress' ), |
| 60 | 'icon_class' => 'dashicons dashicons-smiley', |
| 61 | 'data_args' => [ |
| 62 | 'dismiss' => true, |
| 63 | ], |
| 64 | ), |
| 65 | 'maybe_later' => array( |
| 66 | 'link' => $url, |
| 67 | 'label' => __( 'Maybe Later', 'embedpress' ), |
| 68 | 'icon_class' => 'dashicons dashicons-calendar-alt', |
| 69 | 'data_args' => [ |
| 70 | 'later' => true, |
| 71 | ], |
| 72 | ), |
| 73 | 'support' => array( |
| 74 | 'link' => 'https://wordpress.org/support/plugin/embedpress/', |
| 75 | 'label' => __( 'I need help', 'embedpress' ), |
| 76 | 'icon_class' => 'dashicons dashicons-sos', |
| 77 | ), |
| 78 | 'never_show_again' => array( |
| 79 | 'link' => $url, |
| 80 | 'label' => __( 'Never show again', 'embedpress' ), |
| 81 | 'icon_class' => 'dashicons dashicons-dismiss', |
| 82 | 'data_args' => [ |
| 83 | 'dismiss' => true, |
| 84 | ], |
| 85 | ), |
| 86 | ), |
| 87 | ]; |
| 88 | |
| 89 | /** |
| 90 | * This is review message and thumbnail. |
| 91 | */ |
| 92 | $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>' ); |
| 93 | $notice->thumbnail( 'review', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 94 | /** |
| 95 | * This is upsale notice settings |
| 96 | * classes for wrapper, |
| 97 | * Message message for showing. |
| 98 | */ |
| 99 | $notice->classes( 'upsale', 'notice is-dismissible ' ); |
| 100 | $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>' ); |
| 101 | $notice->thumbnail( 'upsale', plugins_url( 'assets/images/essential-blocks.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 102 | |
| 103 | // Update Notice For PRO Version |
| 104 | if ( $this->is_pro_active() && \version_compare( EMBEDPRESS_PRO_VERSION, '2.0.0', '<' ) ) { |
| 105 | $notice->classes( 'update', 'notice is-dismissible ' ); |
| 106 | $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>' ); |
| 107 | $notice->thumbnail( 'update', plugins_url( 'assets/images/icon-128x128.png', EMBEDPRESS_PLUGIN_BASENAME ) ); |
| 108 | } |
| 109 | |
| 110 | $notice->upsale_args = array( |
| 111 | 'slug' => 'essential-blocks', |
| 112 | 'page_slug' => 'essential-blocks', |
| 113 | 'file' => 'essential-blocks.php', |
| 114 | 'btn_text' => __( 'Install Free', 'embedpress' ), |
| 115 | 'condition' => [ |
| 116 | 'by' => 'class', |
| 117 | 'class' => 'EssentialAdmin' |
| 118 | ], |
| 119 | ); |
| 120 | |
| 121 | $notice->options_args = array( |
| 122 | 'notice_will_show' => [ |
| 123 | 'opt_in' => $notice->timestamp, |
| 124 | 'upsale' => $notice->makeTime( $notice->timestamp, '14 Day' ), |
| 125 | 'review' => $notice->makeTime( $notice->timestamp, '7 Day' ), // after 3 days |
| 126 | ], |
| 127 | ); |
| 128 | if ( $this->is_pro_active() && \version_compare( EMBEDPRESS_PRO_VERSION, '2.0.0', '<' ) ) { |
| 129 | $notice->options_args['notice_will_show']['update'] = $notice->timestamp; |
| 130 | } |
| 131 | |
| 132 | $notice->init(); |
| 133 | } |
| 134 | |
| 135 | public function is_pro_active() { |
| 136 | return is_plugin_active( 'embedpress-pro/embedpress-pro.php' ); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Show Admin notice when one of embedpress old plugin active |
| 141 | * |
| 142 | * @since 2.4.0 |
| 143 | */ |
| 144 | public function embedpress_admin_notice() { |
| 145 | |
| 146 | if ( get_option( 'embedpress_social_dismiss_notice' ) == true ) { |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | $msg = '<strong>Due to recent Facebook API changes, if you have embeded Facebook or Instagram link before, that won’t work. EmbedPress could help, configure <a href="'.admin_url( 'admin.php?page=embedpress' ).'">here</a>. [<a href="'.esc_url('https://embedpress.com/docs/how-to-connect-facebook-instagram-embedpress/').'">Read Details</a>] </strong>'; |
| 151 | echo '<div class="notice notice-info embedpress-plugin-notice-dismissible is-dismissible"> |
| 152 | <p>' . $msg . '</p> |
| 153 | </div>'; |
| 154 | } |
| 155 | |
| 156 | } |