/** * Is the current process an install or upgrade of plugin(s) * * @return bool */ public static function is_installing_or_updating_plugins() { if (!is_null(self::$is_installing_or_updating_plugins)) { return self::$is_installing_or_updating_plugins; } self::$is_installing_or_updating_plugins = false; global $pagenow; if ('update.php' === $pagenow && isset($_GET['action']) && 'install-plugin' === $_GET['action']) { // We are installing a plugin self::$is_installing_or_updating_plugins = true; } if ('plugins.php' === $pagenow && isset($_POST['action'])) { $action = $_POST['action']; if (isset($_POST['action2']) && '-1' !== $_POST['action2']) { $action = $_POST['action2']; } if ('update-selected' === $action) { // We are updating plugins from the plugin page self::$is_installing_or_updating_plugins = true; } } if ('update-core.php' === $pagenow && isset($_GET['action']) && 'do-plugin-upgrade' === $_GET['action']) { // We are updating plugins from the updates page self::$is_installing_or_updating_plugins = true; } return self::$is_installing_or_updating_plugins; }
/** * Display a custom install notice if the plugin is not setup */ function get_admin_notice() { $plugins_not_installed = $this->required_plugins_not_installed(); if (empty($plugins_not_installed)) { parent::get_admin_notice(); return; } $this->plugin_installer->load_installer_assets(); if ($notices = get_site_transient('as3cfpro_installer_notices')) { if (isset($notices['filesystem_error'])) { // Don't show the installer notice if we have filesystem credential issues return; } } $install_notice = untrailingslashit(plugin_dir_path($this->plugin_file_path)) . '/view/install-notice.php'; include $install_notice; }
function __construct($plugin_file_path) { parent::__construct('Amazon Web Services', 'amazon-web-services', $plugin_file_path, null, null, null, null, true); }
/** * Display our license issue notice which covers - * - No license * - Expired licenses * - Media library larger than license limit * * @param bool $dashboard Are we displaying across the dashboard? * @param bool $skip_transient */ function licence_issue_notice($dashboard = false, $skip_transient = false) { global $amazon_web_services, $current_user; if (!$amazon_web_services->are_access_keys_set()) { // Don't show the notice if we haven't set up AWS keys return; } if ($dashboard && method_exists('WP_AWS_Compatibility_Check', 'is_installing_or_updating_plugins') && WP_AWS_Compatibility_Check::is_installing_or_updating_plugins()) { // Don't show the notice for plugin installs & updates, just too much noise return; } $upgrade_url = 'https://deliciousbrains.com/my-account/'; $license_check = $this->is_licence_expired(); $message = false; $type = false; $title = ''; $existing_type = get_site_option($this->plugin->prefix . '_licence_issue_type', false); if (isset($license_check['errors']['no_licence'])) { $type = 'no_licence'; $message = $license_check['errors']['no_licence']; $title = __('Activate Your License', 'as3cf-pro'); if ($dashboard) { // Don't show the activate license notice dashboard wide return; } } else { if (isset($license_check['errors']['subscription_expired'])) { $type = 'subscription_expired'; $message = $license_check['errors']['subscription_expired']; $title = __('Renew Your License', 'as3cf-pro'); } else { if (!isset($license_check['errors'])) { $media_limit_check = $this->check_licence_media_limit($skip_transient); if (!isset($media_limit_check['status']) || self::MEDIA_USAGE_UNDER === $media_limit_check['status']['code']) { return; } $limit = absint($media_limit_check['limit']); $total = absint($media_limit_check['total']); if ($media_limit_check['status']['code'] >= self::MEDIA_USAGE_REACHED) { $type = 'over_limit'; $message = sprintf(__('The total number of attachments across the media libraries for your installs (%s) has %s the limit for your license (%s).', 'as3cf-pro'), number_format($total), $media_limit_check['status']['text'], number_format($limit), $upgrade_url); $title = __('Upgrade Your License', 'as3cf-pro'); } else { if (self::MEDIA_USAGE_APPROACHING === $media_limit_check['status']['code']) { $type = 'near_limit'; $message = sprintf(__('The total number of attachments across the media libraries for your installs (%s) is %s the limit for your license (%s).', 'as3cf-pro'), number_format($total), $media_limit_check['status']['text'], number_format($limit), $upgrade_url); $title = __('Approaching License Limit', 'as3cf-pro'); } } } } } // Has the license issue type changed since the last check? if ($type !== $existing_type) { // Delete the dismissed flag for the user delete_user_meta($current_user->ID, $this->plugin->prefix . '-dismiss-licence-notice'); // Store the type of issue for comparison later update_site_option($this->plugin->prefix . '_licence_issue_type', $type); } if (!$message) { // No license issue delete_site_option($this->plugin->prefix . '_licence_issue_type'); return; } // Don't show if current user has dismissed notice if ($dashboard && get_user_meta($current_user->ID, $this->plugin->prefix . '-dismiss-licence-notice')) { return; } $features_url = 'https://deliciousbrains.com/wp-offload-s3/doc/non-essential-features/'; $free_limit_url = 'https://deliciousbrains.com/wp-offload-s3/pricing/#free-up-limit'; $extra = sprintf(__('All essential features will continue to work, but a few <a href="%s">non-essential features</a> will be disabled', 'as3cf-pro'), $features_url, strtolower($title)); if (!isset($license_check['errors'])) { if ('near_limit' === $type) { $extra = sprintf(__('When you exceed the limit, all essential features will continue to work, but a few <a href="%s">non-essential features</a> will be disabled', 'as3cf-pro'), $features_url); } $extra .= ' ' . sprintf(__('until you <a href="%s">upgrade your license</a> or <a href="%s">free-up some of your current limit</a>'), $upgrade_url, $free_limit_url); } else { $extra .= ' ' . sprintf(__('until you %s', 'as3cf-pro'), strtolower($title)); } $extra .= '.'; $check_url = $this->get_licence_notice_url('check-licence', true, $dashboard); $dismiss_url = false; if ($dashboard) { $dismiss_url = $this->get_licence_notice_url('dismiss-licence-notice', false, $dashboard); } $args = array('dashboard' => $dashboard, 'check_url' => $check_url, 'dismiss_url' => $dismiss_url, 'title' => $title, 'type' => $type, 'message' => $message, 'extra' => $extra); $this->as3cf->render_view('licence-notice', $args); }