/**
  * If a requested theme/plugin is from wordpress.org -OR- from us, let it through
  * @param array $options
  */
 public function run($options)
 {
     $_options = get_option('gd_quicksetup_options');
     if (preg_match('/(?:(\\.)?wordpress\\.org|' . preg_quote(parse_url($_options['api_url'], PHP_URL_HOST)) . ')$/', parse_url($options['package'], PHP_URL_HOST))) {
         // Some older servers don't have our SSL certs in their bundle
         add_filter('https_ssl_verify', '__return_false');
         parent::run($options);
         remove_filter('https_local_ssl_verify', '__return_false');
     }
 }
Пример #2
0
 public static function updateFromZip($fileRaw, $updateInfo)
 {
     N2Loader::import('libraries.zip.zip_read');
     $tmpHandle = tmpfile();
     fwrite($tmpHandle, $fileRaw);
     $metaData = stream_get_meta_data($tmpHandle);
     $tmpFilename = $metaData['uri'];
     $_GET['plugins'] = $updateInfo['plugin'];
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     $upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin')));
     $upgrader->init();
     $upgrader->upgrade_strings();
     add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
     add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4);
     $upgrader->run(array('package' => $tmpFilename, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $updateInfo['plugin'], 'type' => 'plugin', 'action' => 'update')));
     // Cleanup our hooks, in case something else does a upgrade on this connection.
     remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'));
     remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'));
     // Force refresh of plugin update information
     wp_clean_plugins_cache(true);
     fclose($tmpHandle);
     include ABSPATH . 'wp-admin/admin-footer.php';
     return true;
 }
 /**
  * Performs the actual installation of each plugin.
  *
  * @since 2.2.0
  *
  * @see WP_Upgrader::run()
  *
  * @param array $options The installation config options.
  * @return null|array Return early if error, array of installation data on success.
  */
 public function run($options)
 {
     $result = parent::run($options);
     // Reset the strings in case we changed one during automatic activation.
     if ($this->tgmpa->is_automatic) {
         if ('update' === $this->skin->options['install_type']) {
             $this->upgrade_strings();
         } else {
             $this->install_strings();
         }
     }
     return $result;
 }
 function upgrade_bsf_product($request_product_id, $bundled_id)
 {
     global $bsf_product_validate_url, $bsf_support_url;
     if (!current_user_can('update_plugins')) {
         wp_die(__('You do not have sufficient permissions to update plugins for this site.', 'bsf'));
     }
     $brainstrom_users = get_option('brainstrom_users') ? get_option('brainstrom_users') : array();
     $brainstrom_products = get_option('brainstrom_products') ? get_option('brainstrom_products') : array();
     $brainstrom_bundled_products = get_option('brainstrom_bundled_products') ? get_option('brainstrom_bundled_products') : array();
     $plugins = $themes = $mix = array();
     if (!empty($brainstrom_products)) {
         $plugins = isset($brainstrom_products['plugins']) ? $brainstrom_products['plugins'] : array();
         $themes = isset($brainstrom_products['themes']) ? $brainstrom_products['themes'] : array();
     }
     $mix = array_merge($plugins, $themes);
     $bsf_username = $purchase_key = $type = $template = $name = '';
     if (!empty($brainstrom_users)) {
         foreach ($brainstrom_users as $bsf_user) {
             $bsf_username = $bsf_user['email'];
         }
     }
     $found_in_bsf_products = false;
     if ($bundled_id !== false) {
         $product_details_id = $bundled_id;
     } else {
         $product_details_id = $request_product_id;
     }
     foreach ($mix as $key => $product) {
         $pid = $product['id'];
         if ($pid === $product_details_id) {
             $purchase_key = $product['purchase_key'];
             $type = $product['type'];
             $template = $product['template'];
             $name = $product['product_name'];
             $found_in_bsf_products = true;
             break;
         }
     }
     if ($bundled_id !== false) {
         if (!empty($brainstrom_bundled_products)) {
             foreach ($brainstrom_bundled_products as $bp) {
                 if ($bp->id === $request_product_id) {
                     $type = $bp->type;
                     $template = $bp->init;
                     $name = $bp->name;
                 }
             }
         }
     }
     if ($bsf_username === '' || $purchase_key === '' || $request_product_id === '') {
         wp_die('Not valid to update product');
     }
     $path = base64_decode($bsf_product_validate_url);
     $data = array('action' => 'bsf_product_update_request', 'id' => $request_product_id, 'username' => $bsf_username, 'purchase_key' => $purchase_key, 'site_url' => get_site_url(), 'bundled' => $bundled_id);
     $request = @wp_remote_post($path, array('body' => $data, 'timeout' => '60', 'sslverify' => false));
     if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
         $result = json_decode($request['body']);
         if (isset($result->error) && !$result->error) {
             $download_path = $result->update_data->download_url;
             $timezone = date_default_timezone_get();
             $call = 'file=' . $download_path . '&hashtime=' . strtotime(date('d-m-Y h:i:s a')) . '&timezone=' . $timezone;
             $hash = base64_encode($call);
             $parse = parse_url($path);
             $download = $parse['scheme'] . '://' . $parse['host'];
             $get_path = 'http://downloads.brainstormforce.com/';
             $download_path = rtrim($get_path, '/') . '/download.php?hash=' . $hash;
             //echo $download_path;
             //die();
             require_once ABSPATH . '/wp-admin/includes/file.php';
             WP_Filesystem();
             global $wp_filesystem;
             require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             $WP_Upgrader = new WP_Upgrader();
             $res = $WP_Upgrader->fs_connect(array(WP_CONTENT_DIR));
             if (!$res) {
                 wp_die(new WP_Error('Server error', __("Error! Can't connect to filesystem", 'bsf')));
             } else {
                 $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade_tmp/bsf_package';
                 $package_filename = basename($download_path);
                 $plugin_folder = dirname($template);
                 if ($type === 'theme' && $bundled_id === false) {
                     $defaults = array('clear_update_cache' => true);
                     $args = array();
                     $parsed_args = wp_parse_args($args, $defaults);
                     $Theme_Upgrader = new Theme_Upgrader();
                     $Theme_Upgrader->init();
                     $Theme_Upgrader->upgrade_strings();
                     $Theme_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
                     add_filter('upgrader_pre_install', array(&$Theme_Upgrader, 'current_before'), 10, 2);
                     add_filter('upgrader_post_install', array(&$Theme_Upgrader, 'current_after'), 10, 2);
                     add_filter('upgrader_clear_destination', array(&$Theme_Upgrader, 'delete_old_theme'), 10, 4);
                     $Theme_Upgrader->run(array('package' => $download_path, 'destination' => get_theme_root($template), 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'hook_extra' => array('theme' => $template, 'type' => 'theme', 'action' => 'update')));
                     remove_filter('upgrader_pre_install', array(&$Theme_Upgrader, 'current_before'));
                     remove_filter('upgrader_post_install', array(&$Theme_Upgrader, 'current_after'));
                     remove_filter('upgrader_clear_destination', array(&$Theme_Upgrader, 'delete_old_theme'));
                     if (!$Theme_Upgrader->result || is_wp_error($Theme_Upgrader->result)) {
                         return $Theme_Upgrader->result;
                     }
                     wp_clean_themes_cache($parsed_args['clear_update_cache']);
                     $response = array('status' => true, 'type' => 'theme', 'name' => $name);
                     return $response;
                 } elseif ($type === 'plugin') {
                     $Plugin_Upgrader = new Plugin_Upgrader();
                     $Plugin_Upgrader->init();
                     $Plugin_Upgrader->upgrade_strings();
                     $Plugin_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
                     add_filter('upgrader_pre_install', array(&$Plugin_Upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
                     add_filter('upgrader_clear_destination', array(&$Plugin_Upgrader, 'delete_old_plugin'), 10, 4);
                     $Plugin_Upgrader->run(array('package' => $download_path, 'destination' => WP_PLUGIN_DIR, 'abort_if_destination_exists' => false, 'clear_destination' => false, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin_folder)));
                     // Cleanup our hooks, in case something else does a upgrade on this connection.
                     remove_filter('upgrader_pre_install', array(&$Plugin_Upgrader, 'deactivate_plugin_before_upgrade'));
                     remove_filter('upgrader_clear_destination', array(&$Plugin_Upgrader, 'delete_old_plugin'));
                     if (!$Plugin_Upgrader->result || is_wp_error($Plugin_Upgrader->result)) {
                         return $Plugin_Upgrader->result;
                     }
                     if (is_dir($wp_filesystem->wp_content_dir() . 'upgrade_tmp/bsf_package')) {
                         $wp_filesystem->delete($wp_filesystem->wp_content_dir() . 'upgrade_tmp/bsf_package', true);
                     }
                     // Force refresh of plugin update information
                     delete_site_transient('update_plugins');
                     wp_cache_delete('plugins', 'plugins');
                     $response = array('status' => true, 'type' => 'plugin', 'name' => $name);
                     return $response;
                 }
             }
         } else {
             echo $result->message;
         }
     }
 }
Пример #5
0
$plugin = $plugin_slug . "/" . 'yop_poll' . ".php";
$upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(array('title' => 'Yop Poll 2.0 Plugin', 'plugin' => $plugin_slug . '/yop_poll.php')));
$options = get_option('yop_poll_options');
$options['vote_permisions_facebook'] = "no";
$options['vote_permisions_google'] = "no";
$options['vote_permisions_facebook_label'] = __yop_poll('Vote as Facebook User');
$options['vote_permisions_google_label'] = __yop_poll('Vote as G+ User');
$options['facebook_share_description'] = __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name');
$options['show_google_share_button'] = "no";
$options['facebook_share_after_vote'] = "no";
$options['google_integration'] = "no";
$options['facebook_integration'] = "no";
$options['user_interface_type'] = "beginner";
$options['is_default_other_answer'] = "no";
$options['facebook_show_comments_widget'] = "no";
update_option('yop_poll_options', $options);
$upgrader->init();
if (is_plugin_active($plugin)) {
    deactivate_plugins($plugin);
}
$result = @$upgrader->run(array('package' => $download_link, 'destination' => WP_PLUGIN_DIR . "/" . $plugin_slug . "/", 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array()));
if (!is_wp_error($result)) {
    if (!is_plugin_active($plugin)) {
        $pro_options = get_option("yop_poll_pro");
        unset($pro_options['rand_number']);
        update_option("yop_poll_pro", $pro_options);
        activate_plugins($plugin);
    }
}
Yop_Poll_DbSchema::add_defaults_to_database();
wp_die();
Пример #6
0
 /**
  * Worker update
  * 
  */
 function update_worker_plugin($params)
 {
     extract($params);
     if ($download_url) {
         @(include_once ABSPATH . 'wp-admin/includes/file.php');
         @(include_once ABSPATH . 'wp-admin/includes/misc.php');
         @(include_once ABSPATH . 'wp-admin/includes/template.php');
         @(include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
         @(include_once ABSPATH . 'wp-admin/includes/screen.php');
         if (!$this->is_server_writable()) {
             return array('error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide/faq/my-pluginsthemes-fail-to-update-or-i-receive-a-yellow-ftp-warning">add FTP details for automatic upgrades.</a>');
         }
         ob_start();
         @unlink(dirname(__FILE__));
         $upgrader = new Plugin_Upgrader();
         $result = $upgrader->run(array('package' => $download_url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => 'worker/init.php')));
         ob_end_clean();
         if (is_wp_error($result) || !$result) {
             return array('error' => 'ManageWP Worker plugin could not be updated.');
         } else {
             return array('success' => 'ManageWP Worker plugin successfully updated.');
         }
     }
     return array('error' => 'Bad download path for worker installation file.');
 }
Пример #7
0
    function my_admin_notice()
    {
        ?>
        <div class="error">
            <p><?php 
        _e('YOP POLL!', 'my-text-domain');
        ?>
</p>
       	<p> 
       		<?php 
        _e("Your server is running php lower than 5.3. Please update your Php version and try again!");
        ?>
       	</p>
        </div>
        <?php 
        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        include_once ABSPATH . 'wp-admin/includes/plugin.php';
        $plugin_slug = basename(dirname(__FILE__));
        $plugin = $plugin_slug . "/" . 'yop_poll' . ".php";
        $upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(array('title' => 'Yop Poll Downgrade', 'plugin' => $plugin_slug . '/yop_poll.php')));
        $upgrader->init();
        if (is_plugin_active($plugin)) {
            deactivate_plugins($plugin);
        }
        $result = @$upgrader->run(array('package' => "https://downloads.wordpress.org/plugin/yop-poll.4.9.3.zip", 'destination' => WP_PLUGIN_DIR . "/" . $plugin_slug . "/", 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array()));
        if (!is_wp_error($result)) {
            if (!is_plugin_active($plugin)) {
                activate_plugins($plugin);
            }
        }
        wp_die();
    }
Пример #8
0
 /**
  * Manipulate addon.
  *
  * @param   string  $addon   Addon to manipulate.
  * @param   string  $action  Action to execute.
  *
  * @return  array
  */
 protected static function execute($addon, $action)
 {
     // Check capabilities
     foreach (self::$actions as $do => $capability) {
         if ($action == $do && !empty($capability) && !current_user_can($capability)) {
             throw new Exception(__('You do not have sufficient permissions to either add or delete plugins for this site.'));
         }
     }
     // Check if addon should be updated or removed
     if ('update' == $action || 'uninstall' == $action) {
         // Get plugin slug
         $plugin = self::check($addon, false);
         if (empty($plugin)) {
             throw new Exception(__('update' == $action ? 'Cannot detect plugin to be updated.' : 'Cannot detect plugin to be removed.', IG_LIBRARY_TEXTDOMAIN));
         }
     }
     // Check if addon should be removed
     if ('uninstall' == $action) {
         $result = delete_plugins(array($plugin));
         // Verify uninstallation result
         if (is_wp_error($result)) {
             throw new Exception($result->get_error_message());
         }
     } else {
         // Verify authentication data
         $authentication = (bool) $_GET['authentication'];
         $username = isset($_POST['username']) ? $_POST['username'] : '';
         $password = isset($_POST['password']) ? $_POST['password'] : '';
         if ($authentication && (empty($username) || empty($password))) {
             // Check if user has customer account saved
             $customer_account = get_option('ig_customer_account', null);
             if (is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password'])) {
                 $username = $customer_account['username'];
                 $password = $customer_account['password'];
             } else {
                 throw new Exception(null);
             }
         }
         // Try to authenticate or download addon installation package
         try {
             $package = self::download($addon, $authentication, $username, $password, 'authenticate' == $action);
         } catch (Exception $e) {
             throw $e;
         }
         // Get WordPress's WordPress Filesystem Abstraction object
         $wp_filesystem = IG_Init_File_System::get_instance();
         // Check if addon should be installed or updated
         if ('authenticate' != $action) {
             // Verify core and add-on compatibility
             if (isset($_GET['core']) && ($core = self::get($_GET['core']))) {
                 // Extract downloaded add-on package
                 $tmp_dir = substr($package, 0, -4);
                 $result = unzip_file($package, $tmp_dir);
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
                 // Find constant definition file
                 if (@is_file("{$tmp_dir}/defines.php")) {
                     include "{$tmp_dir}/defines.php";
                 } elseif (count($defines = glob("{$tmp_dir}/*/defines.php"))) {
                     include current($defines);
                 }
                 // Get minimum core version required for this add-on
                 if (defined($core_version = strtoupper($addon) . '_CORE_VERSION')) {
                     eval('$core_version = ' . $core_version . ';');
                 }
                 if ($core_version && version_compare($core_version, $core['Version'], '>')) {
                     // Delete downloaded add-on package and clean-up temporary directory
                     $wp_filesystem->delete($package);
                     $wp_filesystem->delete($tmp_dir, true);
                     // Skip add-on installation
                     throw new Exception(sprintf(__("Cannot install %1\$s v%2\$s.\nThis version requires %3\$s v%4\$s while you are using %5\$s v%6\$s.", IG_LIBRARY_TEXTDOMAIN), $core['Addons'][$addon]->name, $core['Addons'][$addon]->version, $core['Name'], $core_version, $core['Name'], $core['Version']));
                 }
                 // Verification done, clean-up temporary directory
                 $wp_filesystem->delete($tmp_dir, true);
             }
             // Init WordPress Plugin Upgrader
             class_exists('Plugin_Upgrader') || (include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
             function_exists('screen_icon') || (include_once ABSPATH . 'wp-admin/includes/screen.php');
             function_exists('show_message') || (include_once ABSPATH . 'wp-admin/includes/misc.php');
             function_exists('get_plugin_data') || (include_once ABSPATH . 'wp-admin/includes/plugin.php');
             // Either install or update add-on
             $upgrader = new Plugin_Upgrader();
             if ('install' == $action) {
                 // Install plugin
                 $result = $upgrader->install($package);
                 // Verify installation result
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
             } else {
                 // Update plugin
                 add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
                 add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4);
                 $upgrader->run(array('package' => $package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
                 remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'));
                 remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'));
                 if (is_wp_error($upgrader->result)) {
                     throw new Exception($upgrader->result->get_error_message());
                 }
                 // Force refresh of plugin update information
                 if (function_exists('wp_clean_plugins_cache')) {
                     wp_clean_plugins_cache(true);
                 }
             }
             // Try to activate plugin
             try {
                 $result = self::activate($addon, $action);
             } catch (Exception $e) {
                 throw $e;
             }
             // Remove downloaded add-on installation package
             $wp_filesystem->delete($package);
         } else {
             // Check if user want to save customer account
             if (isset($_POST['remember']) && (bool) $_POST['remember']) {
                 update_option('ig_customer_account', array('username' => $username, 'password' => $password));
             }
         }
     }
     // Return data
     return is_array($result) ? $result : array('success' => true, 'addon' => $addon, 'action' => $action, 'message' => 'authenticate' == $action ? json_decode($wp_filesystem->get_contents($package)) : null);
 }
 /**
  * Install plugin action.
  *
  * @return  void
  */
 protected function install_plugin_action()
 {
     try {
         // Get plugin being installed
         $plugin = isset($_GET['plugin']) ? $_GET['plugin'] : null;
         if (empty($plugin)) {
             throw new Exception(__('Missing parameter.', 'ferado'));
         }
         // Get sample data XML declaration
         $xml = $this->_parse_sample_data();
         // Get plugin details
         $plugin = $xml->xpath('//product/extension[@name="' . $plugin . '"]');
         $plugin = current($plugin);
         $state = $this->_get_plugin_state((string) $plugin['name'], (string) $plugin['version']);
         if ('installed' != $state) {
             // Generate path to store downloaded plugin package
             $path = wp_upload_dir();
             $path = $path['basedir'] . '/' . $this->id . '-sample-data/' . str_replace(' ', '-', (string) $plugin['name']) . '.zip';
             // Download requested plugin package
             $valid_headers = array('content-type' => array('application/zip', 'application/x-zip', 'application/x-zip-compressed', 'application/octet-stream', 'application/x-compress', 'application/x-compressed', 'multipart/x-zip'));
             $this->_download((string) $plugin['downloadurl'], $path, $valid_headers);
             // Init WordPress Plugin Upgrader
             $upgrader = new Plugin_Upgrader();
             if ('update' == $state) {
                 // Get relative path to plugin's main file
                 $plugin = $this->_get_plugin_path((string) $plugin['name']);
                 // Let WordPress upgrade requested plugin
                 add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
                 add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4);
                 $upgrader->run(array('package' => $path, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
                 // Cleanup our hooks, in case something else does a upgrade on this connection.
                 remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'));
                 remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'));
                 if (!$upgrader->result || is_wp_error($upgrader->result)) {
                     throw new Exception(sprintf(__('Upgrade plugin failed: %s', 'ferado'), $upgrader->result ? $upgrader->result->get_error_message() : __('Unknown reason', 'ferado')));
                 }
                 // Force refresh of plugin update information
                 if (function_exists('wp_clean_plugins_cache')) {
                     wp_clean_plugins_cache(true);
                 }
             } else {
                 // Let WordPress install requested plugin
                 $result = $upgrader->install($path);
                 if (!$result || is_wp_error($result)) {
                     throw new Exception(sprintf(__('Plugin installation failed: %s', 'ferado'), $result ? $result->get_error_message() : __('Unknown reason', 'ferado')));
                 }
                 // Get relative path to plugin's main file
                 $plugin = $this->_get_plugin_path((string) $plugin['name']);
                 // Let WordPress activate the newly installed plugin
                 $result = activate_plugin($plugin, '', is_network_admin(), true);
                 if (is_wp_error($result) && 'unexpected_output' != $result->get_error_code()) {
                     throw new Exception(sprintf(__('Plugin activation failed: %s', 'ferado'), $result->get_error_message()));
                 }
             }
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Пример #10
0
 /**
  * Client update
  * 
  */
 function update_client_plugin($params)
 {
     extract($params);
     if ($download_url) {
         @(include_once ABSPATH . 'wp-admin/includes/file.php');
         @(include_once ABSPATH . 'wp-admin/includes/misc.php');
         @(include_once ABSPATH . 'wp-admin/includes/template.php');
         @(include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
         @(include_once ABSPATH . 'wp-admin/includes/screen.php');
         if (!$this->is_server_writable()) {
             return array('error' => 'Failed. please add FTP details for automatic upgrades.');
         }
         ob_start();
         @unlink(dirname(__FILE__));
         $upgrader = new Plugin_Upgrader();
         $result = $upgrader->run(array('package' => $download_url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => 'iwp-client/init.php')));
         ob_end_clean();
         @wp_update_plugins();
         if (is_wp_error($result) || !$result) {
             return array('error' => 'InfiniteWP Client plugin could not be updated.');
         } else {
             return array('success' => 'InfiniteWP Client plugin successfully updated.');
         }
     }
     return array('error' => 'Bad download path for client installation file.');
 }
Пример #11
0
 /**
  * Client update
  * 
  */
 function update_client_plugin($params)
 {
     extract($params);
     if ($download_url) {
         @(include_once ABSPATH . 'wp-admin/includes/file.php');
         @(include_once ABSPATH . 'wp-admin/includes/plugin.php');
         @(include_once ABSPATH . 'wp-admin/includes/misc.php');
         @(include_once ABSPATH . 'wp-admin/includes/template.php');
         @(include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
         @(include_once ABSPATH . 'wp-admin/includes/screen.php');
         if (!$this->is_server_writable()) {
             return array('error' => 'Failed, please add FTP details', 'error_code' => 'automatic_upgrade_failed_add_ftp_details');
         }
         ob_start();
         @unlink(dirname(__FILE__));
         $upgrader = new Plugin_Upgrader();
         $result = $upgrader->run(array('package' => $download_url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => 'iwp-client/init.php')));
         ob_end_clean();
         @wp_update_plugins();
         //iwp_mmb_create_backup_table();
         //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
         /*global $wpdb;
         		
         			
         		$IWP_MMB_BACKUP_TABLE_VERSION = '1.0';
         		if (get_site_option( 'iwp_backup_table_version' ) != $IWP_MMB_BACKUP_TABLE_VERSION) {
         			
         			$table_name = $wpdb->base_prefix . "iwp_backup_status"; 
         							
         			$sql = "
         					CREATE TABLE IF NOT EXISTS $table_name (
         					  `ID` int(11) NOT NULL AUTO_INCREMENT,
         					  `historyID` int(11) NOT NULL,
         					  `taskName` varchar(255) NOT NULL,
         					  `action` varchar(50) NOT NULL,
         					  `type` varchar(50) NOT NULL,
         					  `category` varchar(50) NOT NULL,
         					  `stage` varchar(255) NOT NULL,
         					  `status` varchar(255) NOT NULL,
         					  `finalStatus` varchar(50) DEFAULT NULL,
         					  `statusMsg` varchar(255) NOT NULL,
         					  `requestParams` text NOT NULL,
         					  `responseParams` longtext,
         					  `taskResults` text,
         					  `startTime` int(11) DEFAULT NULL,
         					  `endTime` int(11) NOT NULL,
         					  PRIMARY KEY (`ID`)
         					) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
         					";
         				
         			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
         			dbDelta( $sql );
         			
         			add_option( "iwp_backup_table_version", $IWP_MMB_BACKUP_TABLE_VERSION);
         		}*/
         // import iwp_client_backup_tasks option table array to row data.
         if (is_wp_error($result) || !$result) {
             return array('error' => 'InfiniteWP Client plugin could not be updated.', 'error_code' => 'client_plugin_could_not_be_updated');
         } else {
             return array('success' => 'InfiniteWP Client plugin successfully updated.');
         }
     }
     return array('error' => 'Bad download path for client installation file.', 'error_code' => 'client_plugin_bad_download_path');
 }
Пример #12
0
 /**
  * Perform an automatic update
  *
  * @access private
  * @return
  **/
 public function perform_update()
 {
     //	We need to create a download session.
     $create_url = wp_remote_get($this->remote_check . 'create_download.php?' . $this->remote_params());
     $response_code = $create_url['response']['code'];
     //	An invalid license, maybe?
     if ($response_code !== 200) {
         return FALSE;
     }
     //	Now that we have a session, let's get the download.
     $create_url_array = json_decode($create_url['body']);
     $download_url = $create_url_array->download_url;
     $filename = $create_url_array->filename;
     //	Load the WordPress Plugin Updater
     include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     //	Setup the strings
     $skin = new Artsy_Skin();
     $skin->strings['up_to_date'] = __('The plugin is at the latest version.');
     $skin->strings['no_package'] = __('Update package not available.');
     $skin->strings['downloading_package'] = __('Downloading update&#8230;');
     $skin->strings['unpack_package'] = __('Unpacking the update&#8230;');
     $skin->strings['installing_package'] = __('Installing the plugin.');
     $skin->strings['deactivate_plugin'] = __('Deactivating the plugin&#8230;');
     $skin->strings['remove_old'] = __('Removing the old version of the plugin&#8230;');
     $skin->strings['remove_old_failed'] = __('Could not remove the old plugin.');
     $skin->strings['process_failed'] = __('Plugin update failed.');
     $skin->strings['process_success'] = __('Plugin updated successfully.');
     //	Setting up the update class
     $upgrader = new Plugin_Upgrader($skin);
     $run = array('package' => $download_url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array());
     return $upgrader->run($run);
 }
Пример #13
0
 function install_bsf_product($install_id)
 {
     global $bsf_product_validate_url, $bsf_support_url;
     if (!current_user_can('install_plugins')) {
         wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'bsf'));
     }
     $brainstrom_bundled_products = get_option('brainstrom_bundled_products') ? get_option('brainstrom_bundled_products') : array();
     $install_product_data = array();
     if (!empty($brainstrom_bundled_products)) {
         foreach ($brainstrom_bundled_products as $keys => $products) {
             if (strlen($keys) > 1) {
                 foreach ($products as $key => $product) {
                     if ($product->id === $install_id) {
                         $install_product_data = $product;
                         break;
                     }
                 }
             } else {
                 if ($products->id === $install_id) {
                     $install_product_data = $products;
                     break;
                 }
             }
         }
     }
     if (empty($install_product_data)) {
         return false;
     }
     if ($install_product_data->type !== 'plugin') {
         return false;
     }
     /* temp */
     /*$install_product_data->in_house = 'wp';
     		$install_product_data->download_url = 'https://downloads.wordpress.org/plugin/redux-framework.3.5.9.zip';*/
     $is_wp = isset($install_product_data->in_house) && $install_product_data->in_house === 'wp' ? true : false;
     if ($is_wp) {
         $download_path = $install_product_data->download_url;
     } else {
         $path = $bsf_product_validate_url;
         $timezone = date_default_timezone_get();
         $call = 'file=' . $install_product_data->download_url . '&hashtime=' . strtotime(date('d-m-Y h:i:s a')) . '&timezone=' . $timezone;
         $hash = $call;
         //$parse = parse_url($path);
         //$download = $parse['scheme'].'://'.$parse['host'];
         $get_path = 'http://downloads.brainstormforce.com/';
         $download_path = rtrim($get_path, '/') . '/download.php?' . $hash . '&base=ignore';
     }
     require_once ABSPATH . '/wp-admin/includes/file.php';
     WP_Filesystem();
     global $wp_filesystem;
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     $WP_Upgrader = new WP_Upgrader();
     $res = $WP_Upgrader->fs_connect(array(WP_CONTENT_DIR));
     if (!$res) {
         wp_die(new WP_Error('Server error', __("Error! Can't connect to filesystem", 'bsf')));
     }
     $Plugin_Upgrader = new Plugin_Upgrader();
     $defaults = array('clear_update_cache' => true);
     $args = array();
     $parsed_args = wp_parse_args($args, $defaults);
     $Plugin_Upgrader->init();
     $Plugin_Upgrader->install_strings();
     $Plugin_Upgrader->strings['downloading_package'] = __('Downloading package from Server', 'bsf');
     $Plugin_Upgrader->strings['remove_old'] = __('Removing old plugin, if exists', 'bsf');
     add_filter('upgrader_source_selection', array($Plugin_Upgrader, 'check_package'));
     $Plugin_Upgrader->run(array('package' => $download_path, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('type' => 'plugin', 'action' => 'install')));
     remove_filter('upgrader_source_selection', array($Plugin_Upgrader, 'check_package'));
     if (!$Plugin_Upgrader->result || is_wp_error($Plugin_Upgrader->result)) {
         return $Plugin_Upgrader->result;
     }
     // Force refresh of plugin update information
     wp_clean_plugins_cache($parsed_args['clear_update_cache']);
     //return true;
     $response = array('status' => true, 'type' => 'plugin', 'name' => $install_product_data->name, 'init' => $install_product_data->init);
     $plugin_abs_path = WP_PLUGIN_DIR . '/' . $install_product_data->init;
     if (is_file($plugin_abs_path)) {
         if (!isset($_GET['action']) && !isset($_GET['id'])) {
             echo '|bsf-plugin-installed|';
         }
         $is_plugin_installed = true;
         if (!is_plugin_active($install_product_data->init)) {
             activate_plugin($install_product_data->init);
             if (is_plugin_active($install_product_data->init)) {
                 if (!isset($_GET['action']) && !isset($_GET['id'])) {
                     echo '|bsf-plugin-activated|';
                 }
             }
         } else {
             if (!isset($_GET['action']) && !isset($_GET['id'])) {
                 echo '|bsf-plugin-activated|';
             }
         }
     }
     return $response;
 }