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


PHP Theme_Upgrader::install方法代码示例

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


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

示例1: install

 protected function install()
 {
     foreach ($this->themes as $theme) {
         $skin = new Jetpack_Automatic_Install_Skin();
         $upgrader = new Theme_Upgrader($skin);
         $link = $this->download_links[$theme];
         $result = $upgrader->install($link);
         if (file_exists($link)) {
             // Delete if link was tmp local file
             unlink($link);
         }
         if (!$this->bulk && is_wp_error($result)) {
             return $result;
         }
         if (!$result) {
             $error = $this->log[$theme]['error'] = __('An unknown error occurred during installation', 'jetpack');
         } elseif (!self::is_installed_theme($theme)) {
             $error = $this->log[$theme]['error'] = __('There was an error installing your theme', 'jetpack');
         } else {
             $this->log[$theme][] = $upgrader->skin->get_upgrade_messages();
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('install_error', $error, 400);
     }
     return true;
 }
开发者ID:netmagik,项目名称:netmagik,代码行数:27,代码来源:class.jetpack-json-api-themes-install-endpoint.php

示例2: install

 protected function install()
 {
     foreach ($this->themes as $theme) {
         /**
          * Filters whether to use an alternative process for installing a WordPress.com theme.
          * The alternative process can be executed during the filter.
          *
          * The filter can also return an instance of WP_Error; in which case the endpoint response will
          * contain this error.
          *
          * @module json-api
          *
          * @since 4.4.2
          *
          * @param bool   $use_alternative_install_method Whether to use the alternative method of installing
          *                                               a WPCom theme.
          * @param string $theme_slug                     Theme name (slug). If it is a WPCom theme,
          *                                               it should be suffixed with `-wpcom`.
          */
         $result = apply_filters('jetpack_wpcom_theme_install', false, $theme);
         $skin = null;
         $upgrader = null;
         $link = null;
         // If the alternative install method was not used, use the standard method.
         if (!$result) {
             $skin = new Jetpack_Automatic_Install_Skin();
             $upgrader = new Theme_Upgrader($skin);
             $link = $this->download_links[$theme];
             $result = $upgrader->install($link);
         }
         if (file_exists($link)) {
             // Delete if link was tmp local file
             unlink($link);
         }
         if (!$this->bulk && is_wp_error($result)) {
             return $result;
         }
         if (!$result) {
             $error = $this->log[$theme]['error'] = __('An unknown error occurred during installation', 'jetpack');
         } elseif (!self::is_installed_theme($theme)) {
             $error = $this->log[$theme]['error'] = __('There was an error installing your theme', 'jetpack');
         } elseif ($upgrader) {
             $this->log[$theme][] = $upgrader->skin->get_upgrade_messages();
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('install_error', $error, 400);
     }
     return true;
 }
开发者ID:automattic,项目名称:jetpack,代码行数:50,代码来源:class.jetpack-json-api-themes-install-endpoint.php

示例3: wp_ajax_install_theme

/**
 * AJAX handler for installing a theme.
 *
 * @since 4.X.0
 */
function wp_ajax_install_theme()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug'])) {
        wp_send_json_error(array('errorCode' => 'no_theme_specified'));
    }
    $status = array('install' => 'theme', 'slug' => sanitize_key($_POST['slug']));
    if (!current_user_can('install_themes')) {
        $status['error'] = __('You do not have sufficient permissions to install themes on this site.');
        wp_send_json_error($status);
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    include_once ABSPATH . 'wp-admin/includes/theme.php';
    $api = themes_api('theme_information', array('slug' => $status['slug'], 'fields' => array('sections' => false)));
    if (is_wp_error($api)) {
        $status['error'] = $api->get_error_message();
        wp_send_json_error($status);
    }
    $upgrader = new Theme_Upgrader(new Automatic_Upgrader_Skin());
    $result = $upgrader->install($api->download_link);
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $status['debug'] = $upgrader->skin->get_upgrade_messages();
    }
    if (is_wp_error($result)) {
        $status['error'] = $result->get_error_message();
        wp_send_json_error($status);
    } else {
        if (is_null($result)) {
            global $wp_filesystem;
            $status['errorCode'] = 'unable_to_connect_to_filesystem';
            $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
            // Pass through the error from WP_Filesystem if one was raised.
            if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
                $status['error'] = $wp_filesystem->errors->get_error_message();
            }
            wp_send_json_error($status);
        }
    }
    // Never switch to theme (unlike plugin activation).
    // See WP_Theme_Install_List_Table::_get_theme_status() if we wanted to check on post-install status.
    wp_send_json_success($status);
}
开发者ID:afragen,项目名称:shiny-updates,代码行数:47,代码来源:ajax-actions.php

示例4: install_theme

 private function install_theme($theme_slug)
 {
     include_once ABSPATH . 'wp-admin/includes/theme-install.php';
     //for themes_api..
     $api = themes_api('theme_information', array('slug' => $theme_slug, 'fields' => array('sections' => false, 'tags' => false)));
     if (is_wp_error($api)) {
         wp_die($api);
     }
     wp_enqueue_script('customize-loader');
     $title = sprintf(esc_html__('Installing theme: %s', '1and1-wordpress-wizard'), $api->name . ' ' . $api->version);
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     //for theme installer
     include_once 'theme-installer-skin.php';
     //for the 1&1 installer skin
     $installer = new Theme_Upgrader(new One_And_One_Theme_Installer_Skin(array('title' => $title, 'theme' => $theme_slug)));
     $installer->install($api->download_link);
 }
开发者ID:Ajoinsardegna,项目名称:wp,代码行数:17,代码来源:batch-installer.php

示例5: install

 function install()
 {
     $args = $this->input();
     if (isset($args['zip'][0]['id'])) {
         $attachment_id = $args['zip'][0]['id'];
         $local_file = get_attached_file($attachment_id);
         if (!$local_file) {
             return new WP_Error('local-file-does-not-exist');
         }
         $skin = new Jetpack_Automatic_Install_Skin();
         $upgrader = new Theme_Upgrader($skin);
         $pre_install_list = wp_get_themes();
         $result = $upgrader->install($local_file);
         // clean up.
         wp_delete_attachment($attachment_id, true);
         if (is_wp_error($result)) {
             return $result;
         }
         $after_install_list = wp_get_themes();
         $plugin = array_values(array_diff(array_keys($after_install_list), array_keys($pre_install_list)));
         if (!$result) {
             $error_code = $upgrader->skin->get_main_error_code();
             $message = $upgrader->skin->get_main_error_message();
             if (empty($message)) {
                 $message = __('An unknown error occurred during installation', 'jetpack');
             }
             if ('download_failed' === $error_code) {
                 $error_code = 'no_package';
             }
             return new WP_Error($error_code, $message, 400);
         }
         if (empty($plugin)) {
             return new WP_Error('theme_already_installed');
         }
         $this->themes = $plugin;
         $this->log[$plugin[0]] = $upgrader->skin->get_upgrade_messages();
         return true;
     }
     return new WP_Error('no_theme_installed');
 }
开发者ID:automattic,项目名称:jetpack,代码行数:40,代码来源:class.jetpack-json-api-themes-new-endpoint.php

示例6: wp_ajax_install_theme

/**
 * Ajax handler for installing a theme.
 *
 * @since 4.6.0
 *
 * @see Theme_Upgrader
 */
function wp_ajax_install_theme()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug'])) {
        wp_send_json_error(array('slug' => '', 'errorCode' => 'no_theme_specified', 'errorMessage' => __('No theme specified.')));
    }
    $slug = sanitize_key(wp_unslash($_POST['slug']));
    $status = array('install' => 'theme', 'slug' => $slug);
    if (!current_user_can('install_themes')) {
        $status['errorMessage'] = __('Sorry, you are not allowed to install themes on this site.');
        wp_send_json_error($status);
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    include_once ABSPATH . 'wp-admin/includes/theme.php';
    $api = themes_api('theme_information', array('slug' => $slug, 'fields' => array('sections' => false)));
    if (is_wp_error($api)) {
        $status['errorMessage'] = $api->get_error_message();
        wp_send_json_error($status);
    }
    $skin = new WP_Ajax_Upgrader_Skin();
    $upgrader = new Theme_Upgrader($skin);
    $result = $upgrader->install($api->download_link);
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $status['debug'] = $skin->get_upgrade_messages();
    }
    if (is_wp_error($result)) {
        $status['errorCode'] = $result->get_error_code();
        $status['errorMessage'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (is_wp_error($skin->result)) {
        $status['errorCode'] = $skin->result->get_error_code();
        $status['errorMessage'] = $skin->result->get_error_message();
        wp_send_json_error($status);
    } elseif ($skin->get_errors()->get_error_code()) {
        $status['errorMessage'] = $skin->get_error_messages();
        wp_send_json_error($status);
    } elseif (is_null($result)) {
        global $wp_filesystem;
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
        }
        wp_send_json_error($status);
    }
    $status['themeName'] = wp_get_theme($slug)->get('Name');
    if (current_user_can('switch_themes')) {
        if (is_multisite()) {
            $status['activateUrl'] = add_query_arg(array('action' => 'enable', '_wpnonce' => wp_create_nonce('enable-theme_' . $slug), 'theme' => $slug), network_admin_url('themes.php'));
        } else {
            $status['activateUrl'] = add_query_arg(array('action' => 'activate', '_wpnonce' => wp_create_nonce('switch-theme_' . $slug), 'stylesheet' => $slug), admin_url('themes.php'));
        }
    }
    if (!is_multisite() && current_user_can('edit_theme_options') && current_user_can('customize')) {
        $status['customizeUrl'] = add_query_arg(array('return' => urlencode(network_admin_url('theme-install.php', 'relative'))), wp_customize_url($slug));
    }
    /*
     * See WP_Theme_Install_List_Table::_get_theme_status() if we wanted to check
     * on post-install status.
     */
    wp_send_json_success($status);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:70,代码来源:ajax-actions.php

示例7: array

 static function install_theme()
 {
     check_ajax_referer(self::AJAX_NONCE, 'nonce');
     $theme_id = $_REQUEST['themeId'];
     $theme = wp_get_theme($theme_id);
     if (!$theme->exists()) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         include_once ABSPATH . 'wp-admin/includes/theme-install.php';
         $theme_info = themes_api('theme_information', array('slug' => $theme_id, 'fields' => array('sections' => false, 'tags' => false)));
         error_log(print_r($theme_info, true));
         if (is_wp_error($theme_info)) {
             wp_send_json_error('Could not look up theme ' . $theme_id . ': ' . $theme_info->get_error_message());
             die;
         } else {
             $upgrader = new Theme_Upgrader(new Automatic_Upgrader_Skin());
             $install_response = $upgrader->install($theme_info->download_link);
             if (is_wp_error($install_response)) {
                 wp_send_json_error('Could not install theme: ' . $install_response->get_error_message());
                 die;
             } elseif (!$install_response) {
                 wp_send_json_error('Could not install theme (unspecified server error)');
                 die;
             }
         }
     }
     wp_send_json_success($theme_id);
 }
开发者ID:hyperhy,项目名称:hyperhy,代码行数:27,代码来源:class.jetpack-start-end-points.php

示例8: install_project

 /**
  * Install a new plugin.
  *
  * @since  4.0.0
  * @param  int    $pid The project ID.
  * @param  string $error Output parameter. Holds error message.
  * @param  bool   $die_on_error If set to false the function will return
  *                false instead of die().
  * @return bool True on success.
  */
 public function install_project($pid, &$error = false, $die_on_error = true)
 {
     if ($this->is_project_installed($pid)) {
         if ($die_on_error) {
             wp_send_json_error(array('message' => __('Already installed', 'wdpmudev')));
         } else {
             return false;
         }
     }
     $project = WPMUDEV_Dashboard::$site->get_project_infos($pid);
     // Make sure Upfront is available before an upfront theme is installed.
     if ($project->need_upfront && !$this->is_upfront_installed()) {
         $this->install_project($this->id_upfront, $error, false);
     }
     // For plugins_api..
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     ob_start();
     // Save on a bit of bandwidth.
     $api = plugins_api('plugin_information', array('slug' => 'wpmudev_install-' . $pid, 'fields' => array('sections' => false)));
     if (is_wp_error($api)) {
         if ($die_on_error) {
             wp_send_json_error(array('message' => __('No data found', 'wpmudev')));
         } else {
             return false;
         }
     }
     $skin = new Automatic_Upgrader_Skin();
     /*
      * Set before the update:
      * WP will refresh local cache via action-hook before the install()
      * method is finished. That refresh call must scan the FS again.
      */
     $this->flush_fs_cache = true;
     $this->flush_info_cache = true;
     switch ($project->type) {
         case 'plugin':
             $upgrader = new Plugin_Upgrader($skin);
             $upgrader->install($api->download_link);
             break;
         case 'theme':
             $upgrader = new Theme_Upgrader($skin);
             $upgrader->install($api->download_link);
             break;
     }
     $details = ob_get_clean();
     if (is_wp_error($skin->result)) {
         $error = $skin->result->get_error_message();
         $this->refresh_local_projects('remote');
         return false;
     }
     // API call to inform wpmudev site about the change.
     $this->refresh_local_projects('remote');
     // Fetch latest project details.
     $project = WPMUDEV_Dashboard::$site->get_project_infos($pid);
     if (!$project->is_installed && !$error) {
         $error = __('Installation failed. Maybe wrong folder permissions.', 'wpmudev');
     }
     return $project->is_installed;
 }
开发者ID:TakenCdosG,项目名称:admissionsrevolution_new,代码行数:70,代码来源:class-wpmudev-dashboard-site.php

示例9: foreach

 function wp_install_themes($array)
 {
     require_once $this->data['dir'] . '/wp-admin/includes/class-wp-upgrader.php';
     global $WPQI_Installer_Skin;
     $WPQI_Installer_Skin();
     $first = true;
     foreach ($array as $name) {
         if (!$name) {
             continue;
         }
         $is_url = preg_match("/^(http|https):\\/\\//i", $name);
         $url = $is_url ? $name : "https://downloads.wordpress.org/theme/{$name}.zip";
         $upgrader = new Theme_Upgrader(new WPQI_Installer_Skin());
         $upgrader->install($url);
         if ($first) {
             switch_theme($name);
             $first = false;
         }
     }
     wp_clean_themes_cache();
 }
开发者ID:pravdomil,项目名称:WP-Quick-Install,代码行数:21,代码来源:wp-quick-install.php

示例10: array

 function install_theme($name, $values)
 {
     include_once ABSPATH . 'wp-admin/includes/theme-install.php';
     //for themes_api..
     if ($values['url']) {
         $download_link = $values['url'];
     } else {
         $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false)));
         //Save on a bit of bandwidth.
         if (is_wp_error($api)) {
             return WP_Error(__('Failed to contact theme API', 'ls-installer'), $api);
         }
         $download_link = $api->download_link;
     }
     $title = sprintf(__('Installing Theme: %s', 'ls-installer'), $values['label']);
     $theme = $name;
     $type = 'web';
     //Install theme type, From Web or an Upload.
     $upgrader = new Theme_Upgrader(new LSInstaller_Theme_Installer_Skin(compact('title', 'theme', 'api')));
     $upgrader->install($download_link);
     return $upgrader->result;
 }
开发者ID:blackparallax,项目名称:living-stories.wordpress,代码行数:22,代码来源:living-story-installer.php

示例11: doInstallUpdate

 /**
  * [doInstallUpdate description]
  * @param  [type] $update_id   [description]
  * @param  [type] $build_url   [description]
  * @param  [type] $package_url [description]
  * @return [type]              [description]
  */
 public function doInstallUpdate($update_row)
 {
     global $wp_filesystem;
     /*
     // Parse Update ID
       $update_keys = array('type', 'element', 'version', 'locale');
       $update_vals = explode( ':', $update_row->update_id );
       $update_rule = new wbSiteManager_Params( array_combine(array_intersect_key($update_keys, $update_vals), array_intersect_key($update_vals, $update_keys)) );
       if( empty($update_rule->type) ){
         $this->out('Invalid Update ID: ' . $update_id);
         return false;
       }
       $this->out('Processing Update ID: '. $update_id);
     */
     // Switch Type
     $this->out('Processing Update ID: ' . $update_row->update_id);
     switch ($update_row->type) {
         case 'core':
             // Load Update Record
             $remoteUrl = 'update-core.php?action=do-core-upgrade';
             $reinstall = false;
             if ($update_row->version == $update_row->installed_version) {
                 $reinstall = true;
                 $remoteUrl = 'update-core.php?action=do-core-reinstall';
             }
             $update = find_core_update($update_row->version, $update_row->get('locale', 'en_US'));
             if (!$update) {
                 $this->out(' - Failed to Load Update');
                 return false;
             }
             if ($reinstall) {
                 $update->response = 'reinstall';
             }
             // Confirm Write Access
             $allow_relaxed_file_ownership = isset($update->new_files) && !$update->new_files;
             if (false === ($credentials = request_filesystem_credentials($remoteUrl, '', false, ABSPATH, array('version', 'locale'), $allow_relaxed_file_ownership))) {
                 $this->out(' - Invalid File Permission');
                 return false;
             }
             if (!WP_Filesystem($credentials, ABSPATH, $allow_relaxed_file_ownership)) {
                 $this->out(' - Failed to load File Permissions');
                 return false;
             }
             if ($wp_filesystem->errors->get_error_code()) {
                 foreach ($wp_filesystem->errors->get_error_messages() as $message) {
                     $this->out(' - File Error: ' . $message);
                 }
                 return false;
             }
             // Run Update
             $upgrader_skin = new wbSiteManager_WP_Upgrader_Skin(array(), $this);
             $upgrader = new Core_Upgrader($upgrader_skin);
             $result = $upgrader->upgrade($update, array('allow_relaxed_file_ownership' => $allow_relaxed_file_ownership));
             $response_html = explode("\n", strip_tags(ob_get_clean()));
             ob_end_clean();
             if (is_wp_error($result)) {
                 if ($result->get_error_data() && is_string($result->get_error_data())) {
                     $message = $result->get_error_message() . ': ' . $result->get_error_data();
                 } else {
                     $message = $result->get_error_message();
                 }
                 $this->out(' - Update Error: ' . $message);
                 if ('up_to_date' != $result->get_error_code()) {
                     $this->out(' - Insallation Failed');
                 }
                 return false;
             }
             // Clear Cache
             set_site_transient('update_core', null);
             break;
         case 'plugin':
             // Install vs Upgrade
             if ($install) {
                 // Get Plugins API
                 $plugin_api = plugins_api('plugin_information', array('slug' => $update_row->extension_id, 'fields' => array('short_description' => false, 'sections' => false, 'requires' => false, 'rating' => false, 'ratings' => false, 'downloaded' => false, 'last_updated' => false, 'added' => false, 'tags' => false, 'compatibility' => false, 'homepage' => false, 'donate_link' => false)));
                 // Load Plugin Updater
                 $upgrader = new Plugin_Upgrader(new wbSiteManager_Plugin_Upgrader_Skin(array('title' => 'Install Plugin: ' . $update_row->extension_id . ' v' . $update_row->version, 'nonce' => 'install-plugin_' . $update_row->extension_id, 'url' => 'update.php?action=install-plugin&plugin=' . urlencode($update_row->extension_id), 'plugin' => $update_row->extension_id, 'api' => $api), $this));
                 $upgrader->install($plugin_api->download_link);
             } else {
                 // Load Plugin Updater
                 $upgrader = new Plugin_Upgrader(new wbSiteManager_Plugin_Upgrader_Skin(array('title' => 'Upgrade Plugin: ' . $update_row->extension_id . ' v' . $update_row->version, 'nonce' => 'upgrade-plugin_' . $update_row->extension_id, 'url' => 'update.php?action=upgrade-plugin&plugin=' . urlencode($update_row->extension_id), 'plugin' => $update_row->extension_id), $this));
                 $upgrader->upgrade($update_row->extension_id);
             }
             // Process Result
             if (empty($upgrader->result)) {
                 $this->out(' - Installation Failed');
                 return false;
             }
             // Clear Cache
             // set_site_transient( 'update_core', null );
             break;
         case 'theme':
             // Install vs Upgrade
//.........这里部分代码省略.........
开发者ID:WebuddhaInc,项目名称:wordpress-plg_wbsitemanager,代码行数:101,代码来源:autoupdate.php

示例12: install_themes

 private function install_themes($themes)
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     require_once ABSPATH . 'wp-admin/includes/theme.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/upgrader-skin.php';
     $upgrader = new Theme_Upgrader(new Ithemes_Sync_Upgrader_Skin());
     $results = array();
     foreach ((array) $themes as $theme) {
         Ithemes_Sync_Functions::set_time_limit(300);
         if (preg_match('{^(http|https|ftp)://}i', $theme)) {
             $result = $upgrader->install($theme);
         } else {
             $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false)));
             if (is_wp_error($api)) {
                 $result = $api;
             } else {
                 $result = $upgrader->install($api->download_link);
             }
         }
         if (is_wp_error($result)) {
             $results[$theme]['error'] = array('error_code' => $result->get_error_code(), 'error_details' => $result->get_error_message());
         } else {
             $results[$theme]['result'] = $result;
             $theme_info = $upgrader->theme_info();
             $results[$theme]['name'] = $theme_info->get('Name');
             $results[$theme]['version'] = $theme_info->get('Version');
             if (is_object($theme_info) && is_callable(array($theme_info, 'get_stylesheet'))) {
                 $results[$theme]['slug'] = basename($theme_info->get_stylesheet());
             } else {
                 if (isset($upgrader->result) && !empty($upgrader->result['destination_name'])) {
                     $results[$theme]['slug'] = $upgrader->result['destination_name'];
                 }
             }
             if (true === $result) {
                 $results[$theme]['success'] = true;
             }
         }
     }
     Ithemes_Sync_Functions::refresh_theme_updates();
     return $results;
 }
开发者ID:AndyA,项目名称:River,代码行数:43,代码来源:manage-themes.php

示例13: install

 /**
  * Install remote plugin or theme.
  * @param $type
  *
  * @return bool
  */
 public function install($type)
 {
     if (isset($_POST['option_page']) && 'github_updater_install' == $_POST['option_page']) {
         if (empty($_POST['github_updater_branch'])) {
             $_POST['github_updater_branch'] = 'master';
         }
         /*
          * Exit early if no repo entered.
          */
         if (empty($_POST['github_updater_repo'])) {
             echo '<h3>';
             _e('A repository URI is required.', 'github-updater');
             echo '</h3>';
             return false;
         }
         /*
          * Transform URI to owner/repo
          */
         $headers = Base::parse_header_uri($_POST['github_updater_repo']);
         $_POST['github_updater_repo'] = $headers['owner_repo'];
         self::$install = Settings::sanitize($_POST);
         self::$install['repo'] = $headers['repo'];
         /*
          * Create GitHub endpoint.
          * Save Access Token if present.
          * Check for GitHub Self-Hosted.
          */
         if ('github' === self::$install['github_updater_api']) {
             if ('github.com' === $headers['host'] || empty($headers['host'])) {
                 $github_base = 'https://api.github.com';
                 $headers['host'] = 'github.com';
             } else {
                 $github_base = $headers['base_uri'] . '/api/v3';
             }
             self::$install['download_link'] = $github_base . '/repos/' . self::$install['github_updater_repo'] . '/zipball/' . self::$install['github_updater_branch'];
             /*
              * If asset is entered install it.
              */
             if (false !== stristr($headers['path'], 'releases/download')) {
                 self::$install['download_link'] = $headers['uri'];
             }
             if (!empty(self::$install['github_access_token'])) {
                 self::$install['download_link'] = add_query_arg('access_token', self::$install['github_access_token'], self::$install['download_link']);
                 parent::$options[self::$install['repo']] = self::$install['github_access_token'];
             } elseif (!empty(parent::$options['github_access_token']) && ('github.com' === $headers['host'] || empty($headers['host']))) {
                 self::$install['download_link'] = add_query_arg('access_token', parent::$options['github_access_token'], self::$install['download_link']);
             }
         }
         /*
          * Create Bitbucket endpoint and instantiate class Bitbucket_API.
          * Save private setting if present.
          * Ensures `maybe_authenticate_http()` is available.
          */
         if ('bitbucket' === self::$install['github_updater_api']) {
             self::$install['download_link'] = 'https://bitbucket.org/' . self::$install['github_updater_repo'] . '/get/' . self::$install['github_updater_branch'] . '.zip';
             if (isset(self::$install['is_private'])) {
                 parent::$options[self::$install['repo']] = 1;
             }
             new Bitbucket_API((object) $type);
         }
         /*
          * Create GitLab endpoint.
          * Check for GitLab Self-Hosted.
          */
         if ('gitlab' === self::$install['github_updater_api']) {
             if ('gitlab.com' === $headers['host'] || empty($headers['host'])) {
                 $gitlab_base = 'https://gitlab.com';
                 $headers['host'] = 'gitlab.com';
             } else {
                 $gitlab_base = $headers['base_uri'];
             }
             self::$install['download_link'] = implode('/', array($gitlab_base, self::$install['github_updater_repo'], 'repository/archive.zip'));
             self::$install['download_link'] = add_query_arg('ref', self::$install['github_updater_branch'], self::$install['download_link']);
             if (!empty(self::$install['gitlab_private_token'])) {
                 self::$install['download_link'] = add_query_arg('private_token', self::$install['gitlab_private_token'], self::$install['download_link']);
                 if ('gitlab.com' === $headers['host']) {
                     parent::$options['gitlab_private_token'] = self::$install['gitlab_private_token'];
                 } else {
                     parent::$options['gitlab_enterprise_token'] = self::$install['gitlab_private_token'];
                 }
             } elseif (!empty(parent::$options['gitlab_private_token'])) {
                 self::$install['download_link'] = add_query_arg('private_token', parent::$options['gitlab_private_token'], self::$install['download_link']);
             }
         }
         parent::$options['github_updater_install_repo'] = self::$install['repo'];
         if (defined('GITHUB_UPDATER_EXTENDED_NAMING') && GITHUB_UPDATER_EXTENDED_NAMING && 'plugin' === $type) {
             parent::$options['github_updater_install_repo'] = implode('-', array(self::$install['github_updater_api'], $headers['owner'], self::$install['repo']));
         }
         update_site_option('github_updater', parent::$options);
         $url = self::$install['download_link'];
         $nonce = wp_nonce_url($url);
         if ('plugin' === $type) {
             $plugin = self::$install['repo'];
             /*
//.........这里部分代码省略.........
开发者ID:adenix,项目名称:Alpha,代码行数:101,代码来源:Install.php

示例14: install

 /**
  * Install a new WPMU DEV plugin.
  *
  * @since  4.0.0
  * @param  int $pid The project ID.
  * @return bool True on success.
  */
 public function install($pid)
 {
     $this->clear_error();
     if ($this->is_project_installed($pid)) {
         $this->set_error($pid, 'INS.01', __('Already installed', 'wpmudev'));
         return false;
     }
     $project = WPMUDEV_Dashboard::$site->get_project_infos($pid);
     // Make sure Upfront is available before an upfront theme or plugin is installed.
     if ($project->need_upfront && !WPMUDEV_Dashboard::$site->is_upfront_installed()) {
         $this->install(WPMUDEV_Dashboard::$site->id_upfront);
     }
     // For plugins_api..
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     ob_start();
     // Save on a bit of bandwidth.
     $api = plugins_api('plugin_information', array('slug' => 'wpmudev_install-' . $pid, 'fields' => array('sections' => false)));
     if (is_wp_error($api)) {
         $this->set_error($pid, 'INS.02', __('No data found', 'wpmudev'));
         return false;
     }
     $skin = new Automatic_Upgrader_Skin();
     /*
      * Set before the update:
      * WP will refresh local cache via action-hook before the install()
      * method is finished. That refresh call must scan the FS again.
      */
     WPMUDEV_Dashboard::$site->clear_local_file_cache();
     switch ($project->type) {
         case 'plugin':
             $upgrader = new Plugin_Upgrader($skin);
             $upgrader->install($api->download_link);
             break;
         case 'theme':
             $upgrader = new Theme_Upgrader($skin);
             $upgrader->install($api->download_link);
             break;
     }
     $details = ob_get_clean();
     if (is_wp_error($skin->result)) {
         WPMUDEV_Dashboard::$site->schedule_shutdown_refresh();
         $this->set_error($pid, 'INS.03', $skin->result->get_error_message());
         return false;
     }
     // API call to inform wpmudev site about the change, as it's a single we can let it do that at the end to avoid multiple pings
     WPMUDEV_Dashboard::$site->schedule_shutdown_refresh();
     // Fetch latest project details.
     $project = WPMUDEV_Dashboard::$site->get_project_infos($pid);
     if (!$project->is_installed) {
         $this->set_error($pid, 'INS.04', __('Maybe wrong folder permissions', 'wpmudev'));
     }
     return $project->is_installed;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:61,代码来源:class-wpmudev-dashboard-upgrader.php

示例15: basename

 /**
  *
  * @TODO document
  *
  */
 function theme_upgrade($type, $file, $path, $uploader, $checked, $dash)
 {
     $this->wp_libs();
     if (!$checked) {
         $this->check_creds('extend', PL_EXTEND_THEMES_DIR);
     }
     global $wp_filesystem;
     $active = basename(get_stylesheet_directory()) === $file ? true : false;
     if ($active) {
         switch_theme(basename(get_template_directory()), basename(get_template_directory()));
     }
     $skin = new PageLines_Upgrader_Skin();
     $upgrader = new Theme_Upgrader($skin);
     $wp_filesystem->delete(trailingslashit(PL_EXTEND_THEMES_DIR) . $file, true, false);
     @$upgrader->install($this->make_url($type, $file));
     if ($active) {
         switch_theme(basename(get_template_directory()), $file);
     }
     // Output
     $text = '&extend_text=theme_upgrade#your_themes';
     $message = __('Theme Upgraded.', 'pagelines');
     $url = PL_ADMIN_STORE_SLUG;
     if ($dash) {
         $url = PL_MAIN_DASH;
         $this->remove_update($path);
     }
     $this->page_reload($url, null, $message);
 }
开发者ID:climo,项目名称:PageLines-Framework,代码行数:33,代码来源:class.extend.actions.php


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