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


PHP Plugin_Upgrader::install_strings方法代码示例

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


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

示例1: install_strings

 /**
  * Initialize the install strings.
  *
  * @since 1.0.0
  */
 public function install_strings()
 {
     parent::install_strings();
     $this->strings['downloading_package'] = __('Downloading the Envato Market install package…', 'envato-market');
 }
开发者ID:RinkuArnob,项目名称:wp-envato-market,代码行数:10,代码来源:upgrader.php

示例2: 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


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