当前位置: 首页>>代码示例>>PHP>>正文


PHP Plugin_Upgrader::init方法代码示例

本文整理汇总了PHP中Plugin_Upgrader::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin_Upgrader::init方法的具体用法?PHP Plugin_Upgrader::init怎么用?PHP Plugin_Upgrader::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin_Upgrader的用法示例。


在下文中一共展示了Plugin_Upgrader::init方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateFromZip

 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;
 }
开发者ID:MBerguer,项目名称:wp-demo,代码行数:24,代码来源:platform.php

示例2: array

 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);
//.........这里部分代码省略.........
开发者ID:jfitzsimmons,项目名称:soundtrackforspace,代码行数:101,代码来源:admin-functions.php

示例3: update

 protected function update()
 {
     wp_clean_plugins_cache();
     ob_start();
     wp_update_plugins();
     // Check for Plugin updates
     ob_end_clean();
     $update_plugins = get_site_transient('update_plugins');
     if (isset($update_plugins->response)) {
         $plugin_updates_needed = array_keys($update_plugins->response);
     } else {
         $plugin_updates_needed = array();
     }
     $update_attempted = false;
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     // unhook this functions that output things before we send our response header.
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     $result = false;
     foreach ($this->plugins as $plugin) {
         if (!in_array($plugin, $plugin_updates_needed)) {
             $this->log[$plugin][] = __('No update needed', 'jetpack');
             continue;
         }
         /**
          * Pre-upgrade action
          * 
          * @since 3.9.3
          * 
          * @param array $plugin Plugin data
          * @param array $plugin Array of plugin objects
          * @param bool $updated_attempted false for the first update, true subsequently
          */
         do_action('jetpack_pre_plugin_upgrade', $plugin, $this->plugins, $update_attempted);
         $update_attempted = true;
         // Object created inside the for loop to clean the messages for each plugin
         $skin = new Automatic_Upgrader_Skin();
         // The Automatic_Upgrader_Skin skin shouldn't output anything.
         $upgrader = new Plugin_Upgrader($skin);
         $upgrader->init();
         // This avoids the plugin to be deactivated.
         defined('DOING_CRON') or define('DOING_CRON', true);
         $result = $upgrader->upgrade($plugin);
         $this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
     }
     if (!$this->bulk && !$result && $update_attempted) {
         return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
     }
     return $this->default_action();
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:51,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php

示例4: array

$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();
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:31,代码来源:upgrade.php

示例5: basename

    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();
    }
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:32,代码来源:yop_poll.php

示例6: update

 protected function update()
 {
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     // unhook this functions that output things before we send our response header.
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     foreach ($this->plugins as $plugin) {
         wp_clean_plugins_cache();
         ob_start();
         wp_update_plugins();
         // Check for Plugin updates
         ob_end_clean();
         // Object created inside the for loop to clean the messages for each plugin
         $skin = new Automatic_Upgrader_Skin();
         // The Automatic_Upgrader_Skin skin shouldn't output anything.
         $upgrader = new Plugin_Upgrader($skin);
         $upgrader->init();
         $result = $upgrader->upgrade($plugin);
         $this->log[$plugin][] = $upgrader->skin->get_upgrade_messages();
     }
     if (!$this->bulk && !$result) {
         return new WP_Error('update_fail', __('There was an error updating your plugin', 'jetpack'), 400);
     }
     return $this->default_action();
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:26,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php

示例7: array

 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;
 }
开发者ID:ksan5835,项目名称:maadithottam,代码行数:95,代码来源:admin-functions.php

示例8: upgrade_plugin

 protected function upgrade_plugin()
 {
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     // clear cache
     wp_clean_plugins_cache();
     ob_start();
     wp_update_plugins();
     // Check for Plugin updates
     ob_end_clean();
     $skin = new Automatic_Upgrader_Skin();
     // The Automatic_Upgrader_Skin skin shouldn't output anything.
     $upgrader = new Plugin_Upgrader($skin);
     $upgrader->init();
     // unhook this functions that output things before we send our response header.
     remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
     remove_action('upgrader_process_complete', 'wp_version_check');
     remove_action('upgrader_process_complete', 'wp_update_themes');
     ob_start();
     $result = $upgrader->upgrade($this->plugin);
     $output = ob_get_contents();
     ob_end_clean();
     if (false === $result) {
         return new WP_Error('plugin_up_to_date', __('The Plugin is already up to date.', 'jetpack'), 400);
     }
     if (empty($result) && !empty($output)) {
         return new WP_Error('unknown_error', __('There was an error while trying to upgrade.', 'jetpack'), 500);
     }
     if (is_wp_error($result)) {
         return $result;
     }
     return true;
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:32,代码来源:class.json-api-jetpack-endpoints.php


注:本文中的Plugin_Upgrader::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。