/** * Try to create backup archive * * @since 1.0.0 * @return bool */ public function make_backup() { global $wp_filesystem; if (!current_user_can('manage_options')) { return false; } include_once ABSPATH . '/wp-admin/includes/class-pclzip.php'; if (!$this->check_path()) { return false; } $this->protect_path(); ini_set('max_execution_time', -1); set_time_limit(0); $zip_name = $this->path . '/monstroid-' . monstroid_dashboard_updater()->get_current_version() . '.zip'; $files = $this->get_files(); $files = implode(',', $files); $remove_path = $wp_filesystem->wp_themes_dir(); $zip = new PclZip($zip_name); $result = $zip->create($files, PCLZIP_OPT_REMOVE_PATH, $remove_path); if (!$result) { return false; } return str_replace(ABSPATH, home_url('/'), $zip_name); }
/** * Get menu badge when update avaliable * * @since 1.0.0 * @return string */ public function get_menu_badge() { return monstroid_dashboard_updater()->force_has_update() ? '<span class="update-plugins count-1 md-badge" ><span class="update-count">1</span></span>' : ''; }
<div class="md-content"> <div class="md-description"> <h2 class="md-description_title"><?php _e('Welcome to Monstroid Dashboard', 'monstroid-dashboard'); ?> </h2> <div class="md-description_content"> <img class="md-description_image" src="<?php echo monstroid_dashboard()->plugin_url('assets/images/main-screen.png'); ?> " alt=""> <div class="md-description_text"> <div class="md-description_ver"> <?php $update_page = menu_page_url('monstroid-updater', false); printf(__('Monstroid Version: %1$s %2$s', 'monstroid-dashboard'), monstroid_dashboard_updater()->get_current_version(), monstroid_dashboard_updater()->check_update_messages('(<b></b>', ')', $update_page)); ?> </div> <div class="md-description_author"> <?php printf(__('By %s', 'monstroid-dashboard'), '<a href="http://www.templatemonster.com/" target="_blank">TemplateMonster</a>'); ?> </div> <div class="md-description_about"> <?php $options_url = menu_page_url('cherry', false); printf(__('Monstroid is powered by the latest %s that ensures easy and worry-free installation and customization. With over 30 inbuilt premium extensions, you can get any kind of functionality required for a specific project. Thanks to the brand new backup options, you can restore the theme any time you need.', 'monstroid-dashboard'), '<a href="' . $options_url . '">Cherry Framework 4</a>'); ?> </div> </div> </div>
/** * Save monstroid license key * * @since 1.0.0 */ public function save_key() { if (!isset($_REQUEST['nonce'])) { die; } if (!wp_verify_nonce(esc_attr($_REQUEST['nonce']), 'monstroid-dashboard')) { die; } if (!current_user_can('manage_options')) { die; } $key = isset($_REQUEST['key']) ? esc_attr($_REQUEST['key']) : ''; if (!$key) { wp_send_json_error(array('message' => __('Please, enter valid key', 'monstroid-dashboard'))); } $request_uri = add_query_arg(array('edd_action' => 'activate_license', 'item_name' => urlencode(monstroid_dashboard_updater()->monstroid_id), 'license' => $key), monstroid_dashboard_updater()->api); global $wp_version; $key_request = wp_remote_get($request_uri, array('user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'))); // Can't send request if (is_wp_error($key_request) || !isset($key_request['response'])) { wp_send_json_error(array('message' => __('Can`t send activation request. ' . $key_request->get_error_message(), 'monstroid-dashboard'))); } if (200 != $key_request['response']['code']) { wp_send_json_error(array('message' => __('Activation request error. ' . $key_request['response']['code'] . ' - ' . $key_request['response']['message'] . '. Please, try again later', 'monstroid-dashboard'))); } $response = json_decode($key_request['body']); // Request generate unexpected result if (!is_object($response) || !isset($response->success)) { wp_send_json_error(array('message' => __('Bad request.', 'monstroid-dashboard'))); } // Requested license key is missing if (!$response->success && 'missing' == $response->error) { wp_send_json_error(array('message' => __('Wrong license key. Make sure activation key is correct.', 'monstroid-dashboard'))); } // Hosts limit reached if (!$response->success && 'limit_reached' == $response->error) { wp_send_json_error(array('message' => __('Sorry, the license key you are trying to use exceeded the maximum amount of activations was applied for 3 domains', 'monstroid-dashboard'))); } if (!$response->success && 'no_activations_left' == $response->error) { wp_send_json_error(array('message' => __('Sorry, the license key you are trying to use exceeded the maximum amount of activations was applied for 3 domains', 'monstroid-dashboard'))); } // Unknown error if (!$response->success && $response->error) { wp_send_json_error(array('message' => $response->error)); } // Can not get the,e information from TM if (empty($response->tm_data->status) || 'request failed' == $response->tm_data->status) { wp_send_json_error(array('message' => __('License key is invalid or evaluation expired. Please, contact Support Live Chat: <a href="http://chat.template-help.com/">http://chat.template-help.com/</a>', 'monstroid-dashboard'))); } // Theme currently in queue if ('queue' == $response->tm_data->status) { wp_send_json_error(array('message' => __('Theme is not available yet. Please try again in 10 minutes.', 'monstroid-dashboard'))); } // Theme currently removed from cloud if ('failed' == $response->tm_data->status) { wp_send_json_error(array('message' => __('Theme is not available. Please contact support team for help.', 'monstroid-dashboard'))); } update_option('monstroid_key', $key); set_transient('cherry_theme_name', monstroid_dashboard_updater()->monstroid_id, WEEK_IN_SECONDS); set_transient('cherry_key', $key, WEEK_IN_SECONDS); $_SESSION['cherry_data'] = array('theme' => $response->tm_data->theme, 'sample' => $response->tm_data->sample_data); wp_send_json_success(array('message' => __('Key successfully activated and saved', 'monstroid-dashboard'))); }
/** * Get partial sample data download link by part name * * @since 1.1.0 * @param string $part part name. * @return string */ public function get_sample_data_part_link($part) { $key = get_option('monstroid_key'); $request_arg = array('action' => 'get-montroid-package-content', 'key' => $key, 'package' => $part); $request_url = add_query_arg($request_arg, monstroid_dashboard_updater()->api); $request = wp_remote_get($request_url); $data = wp_remote_retrieve_body($request); if (empty($data)) { return false; } $data = json_decode($data, true); if (empty($data['links']['sample_data'])) { return false; } return $data['links']['sample_data']; }
/** * Do actions on plugin activation * * @since 1.0.0 * @return void */ public static function activation() { monstroid_dashboard_updater()->shedule_updates(); }
* * @package monstroid_dashboard * @author Cherry Team * @license GPL-2.0+ * @version 1.0.0 */ // If this file is called directly, abort. if (!defined('WPINC')) { die; } ?> <div class="md-content"> <div class="md-updater-service-actions"> <?php // Show enable/disable update buttons $updater_options = monstroid_dashboard_updater()->get_options(); if ($updater_options['disable_auto_check']) { echo Monstroid_Dashboard_UI::enable_update_button(); } else { echo Monstroid_Dashboard_UI::disable_update_button(); } ?> </div> <h2><?php _e('Monstroid Updater', 'monstroid-dashboard'); ?> </h2> <?php echo Monstroid_Dashboard_UI::check_license_key(); ?> <div class="md-updater-items">
/** * Check update notice visibility and add it into shown notices array * * @since 1.0.0 * @param array $notice_data notice data. * @return void|bool false */ public function check_update_notice($notice_data) { if (!current_user_can('update_themes')) { return false; } if (isset($_GET['md_hide_notice']) && 'need_update' == $_GET['md_hide_notice']) { return false; } if (!monstroid_dashboard_updater()->has_update()) { return false; } $this->show_notices['need_update'] = $notice_data; }
if (true !== $filesystem_method) { printf('<div class="md-message md-warning">%s</div>', __('Please, set up filesystem credentials to allow automatic update', 'monstroid-dashboard')); } ?> <div class="md-misc-messages"> <?php _e('We will perform full backup prior updating your data', 'monstroid-dashboard'); ?> </div> <?php } ?> <div class="md-update-messages"></div> <div class="md-update-log md-hidden"></div> <?php if (!monstroid_dashboard_updater()->force_has_update()) { ?> <?php echo Monstroid_Dashboard_UI::check_update_button(); ?> <?php if (isset($_REQUEST['md_force_check_update'])) { echo monstroid_dashboard_updater()->check_update_messages(); } ?> <?php } ?> </div> </div>