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


PHP Plugin_Upgrader::plugin_info方法代码示例

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


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

示例1: elseif

 function mpi_plugin_handle_download($plugin_name, $package, $mpi_action, $whform)
 {
     global $wp_version;
     if (version_compare($wp_version, '3.0', '<')) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $upgrader = new Plugin_Upgrader();
         $upgrader->install($package);
         if ($upgrader->plugin_info()) {
             echo '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $upgrader->plugin_info(), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
         }
     } else {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
         $res = $upgrader->install($package);
         //remove temp files
         if ($whform == "upload_locFiles") {
             @unlink($package);
         }
         if (!$upgrader->plugin_info()) {
             echo $res;
         } elseif ($mpi_action == "activate") {
             $mpiplugins = get_option('active_plugins');
             if ($mpiplugins) {
                 $puginsToActiv = array($upgrader->plugin_info());
                 foreach ($puginsToActiv as $mpiplugin) {
                     if (!in_array($mpiplugin, $mpiplugins)) {
                         array_push($mpiplugins, $mpiplugin);
                         update_option('active_plugins', $mpiplugins);
                     }
                 }
             }
             _e('<b class="mpi_act">Plugin activated successfully.</b><br/>', 'mpi');
         }
     }
 }
开发者ID:linniepinski,项目名称:perssistant,代码行数:35,代码来源:mpi-Class.php

示例2: hooks_plugin_install_or_update

 /**
  * @param Plugin_Upgrader $upgrader
  * @param array $extra
  */
 public function hooks_plugin_install_or_update($upgrader, $extra)
 {
     if (!isset($extra['type']) || 'plugin' !== $extra['type']) {
         return;
     }
     if ('install' === $extra['action']) {
         $path = $upgrader->plugin_info();
         if (!$path) {
             return;
         }
         $data = get_plugin_data($upgrader->skin->result['local_destination'] . '/' . $path, true, false);
         aal_insert_log(array('action' => 'installed', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
     }
     if ('update' === $extra['action']) {
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['plugins'];
         } else {
             if (!isset($upgrader->skin->plugin)) {
                 return;
             }
             $slugs = array($upgrader->skin->plugin);
         }
         foreach ($slugs as $slug) {
             $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $slug, true, false);
             aal_insert_log(array('action' => 'updated', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
         }
     }
 }
开发者ID:JDjimenezdelgado,项目名称:old-mmexperience,代码行数:32,代码来源:class-aal-hook-plugins.php

示例3: explode

 function pl_ui_build_body($obj)
 {
     if (isset($_GET['install_faves']) && 'true' == $_GET['install_faves'] || isset($_GET['install_multi']) && 'true' == $_GET['install_multi']) {
         if (isset($_GET['install_multi'])) {
             $mode = 'multi';
         } else {
             $mode = 'fav';
         }
         if ('multi' == $mode) {
             $banner = 'Installing Selected Products';
             $favs = explode(',', $_GET['slugs']);
             foreach ($favs as $k => $fav) {
                 $favs[$fav] = $fav;
                 unset($favs[$k]);
             }
         } else {
             $banner = 'Installing Favourite Products';
             $favs = (array) get_user_meta(wp_get_current_user()->ID, '_card_fav', true);
         }
         printf('<h2>%s</2>', $banner);
         // lets go!
         if (!empty($favs)) {
             include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
             $data = PL_Platform()->functions->cache_get('connect_updates');
             foreach ($data as $k => $prod) {
                 $data[$prod->slug] = $prod;
                 unset($data[$k]);
             }
             foreach ($favs as $slug => $k) {
                 $path = sprintf('%s/%s.php', $slug, $slug);
                 if (PL_Platform()->extend->is_plugin_installed($path)) {
                     printf('<p>%s is already installed, skipping.</p>', $data[$slug]->post_title);
                 } else {
                     printf('<p><i class="%s-spinner fa fa-cog fa-spin"></i><div style="display:none">', $slug);
                     $link = PL_Platform_Updater::get_download_link($data[$slug]->download_data);
                     $res = $upgrader->install($link);
                     printf('</div></p><script>jQuery(".%s-spinner").hide()</script>', $slug);
                     if ($upgrader->plugin_info()) {
                         $result = activate_plugin($path);
                         printf('<p><strong>%s</strong> has been installed successfully and is activated.</p>', $data[$slug]->post_title);
                     } else {
                         echo $res;
                         break;
                     }
                 }
             }
             echo '</p><h3>All Done!</h3></p><script>localStorage.clear();setTimeout(function(){window.location.href=window.PLAdmin.extendURL},3000)</script>';
         }
     } else {
         $obj->build_body();
     }
 }
开发者ID:voomco,项目名称:WordPress,代码行数:53,代码来源:extend.php

示例4:

 function handle_download($plugin_name, $package)
 {
     global $wp_version;
     if (version_compare($wp_version, '2.8', '<')) {
         $this->update_plugin_advanced($plugin_name, $package);
     } else {
         if (version_compare($wp_version, '3.0', '<')) {
             include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             $upgrader = new Plugin_Upgrader();
             $upgrader->install($package);
             if ($upgrader->plugin_info()) {
                 echo '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $upgrader->plugin_info(), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
             }
         } else {
             include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('type', 'title', 'nonce', 'url')));
             $res = $upgrader->install($package);
             if (!$upgrader->plugin_info()) {
                 echo $res;
             }
         }
     }
 }
开发者ID:87surendra,项目名称:mbr,代码行数:23,代码来源:plugin-central.class.php

示例5: do_plugin_install

 /**
  * Installs a plugin or activates a plugin depending on the hover
  * link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure
  */
 protected function do_plugin_install()
 {
     /** All plugin information will be stored in an array for processing */
     $plugin = array();
     /** Checks for actions from hover links to process the installation */
     if (isset($_GET[sanitize_key('plugin')]) && (isset($_GET[sanitize_key('tgmpa-install')]) && 'install-plugin' == $_GET[sanitize_key('tgmpa-install')] || isset($_GET[sanitize_key('tgmpa-update')]) && 'update-plugin' == $_GET[sanitize_key('tgmpa-update')])) {
         check_admin_referer('tgmpa-install');
         $plugin['name'] = $_GET[sanitize_key('plugin_name')];
         // Plugin name
         $plugin['slug'] = $_GET[sanitize_key('plugin')];
         // Plugin slug
         $plugin['source'] = $_GET[sanitize_key('plugin_source')];
         // Plugin source
         $plugin['version'] = isset($_GET[sanitize_key('version')]) ? $_GET[sanitize_key('version')] : '';
         // Plugin source
         $install_type = isset($_GET[sanitize_key('tgmpa-update')]) ? $_GET[sanitize_key('tgmpa-update')] : '';
         // Install type
         /** Pass all necessary information via URL if WP_Filesystem is needed */
         $url = wp_nonce_url(add_query_arg(array('page' => $this->menu, 'plugin' => $plugin['slug'], 'plugin_name' => $plugin['name'], 'plugin_source' => $plugin['source'], 'tgmpa-install' => 'install-plugin'), admin_url($this->parent_url_slug)), 'tgmpa-install');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary
         $fields = array(sanitize_key('tgmpa-install'));
         // Extra fields to pass to WP_Filesystem
         if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $fields))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials($url, $method, true, false, $fields);
             // Setup WP_Filesystem
             return true;
         }
         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         // Need for plugins_api
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         // Need for upgrade classes
         /** Set plugin source to WordPress API link if available */
         if (isset($plugin['source']) && 'repo' == $plugin['source']) {
             $api = plugins_api('plugin_information', array('slug' => $plugin['slug'], 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 wp_die($this->strings['oops'] . var_dump($api));
             }
             if (isset($api->download_link)) {
                 $plugin['source'] = $api->download_link;
             }
         }
         /** Set type, based on whether the source starts with http:// or https:// */
         $type = preg_match('|^http(s)?://|', $plugin['source']) ? 'web' : 'upload';
         /** Prep variables for Plugin_Installer_Skin class */
         $title = sprintf($this->strings['installing'], $plugin['name']);
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => $plugin['slug']), 'update.php');
         if (isset($_GET['from'])) {
             $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
         }
         $nonce = 'install-plugin_' . $plugin['slug'];
         /** Prefix a default path to pre-packaged plugins */
         $source = 'upload' == $type ? $this->default_path . $plugin['source'] : $plugin['source'];
         /** Create a new instance of Plugin_Upgrader */
         $upgrader = new Plugin_Upgrader($skin = new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
         /** Perform the action and install the plugin from the $source urldecode() */
         if ($install_type == 'update-plugin') {
             delete_site_transient('update_plugins');
             $data = get_site_transient('update_plugins');
             if (!is_object($data)) {
                 $data = new stdClass();
             }
             $data->response[$plugin['slug']]->package = $source;
             $data->response[$plugin['slug']]->version = $plugin['version'];
             set_site_transient('update_plugins', $data);
             $upgrader->upgrade($plugin['slug']);
         } else {
             $upgrader->install($source);
         }
         /** Flush plugins cache so we can make sure that the installed plugins list is always up to date */
         wp_cache_flush();
         /** Only activate plugins if the config option is set to true */
         if ($this->is_automatic) {
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method
             $activate = activate_plugin($plugin_activate);
             // Activate the plugin
//.........这里部分代码省略.........
开发者ID:newmight2015,项目名称:psmpsm,代码行数:101,代码来源:class-tgm-plugin-activation.php

示例6: do_plugin_install

 /**
  * Installs and activates the plugin.
  *
  * This method actually installs the plugins. It instantiates the
  * WP_Filesystem Abstraction class to do the heavy lifting.
  *
  * Any errors are displayed using the WP_Error class.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure
  */
 protected function do_plugin_install()
 {
     if (empty($_POST)) {
         // Bail out if the global $_POST is empty
         return false;
     }
     check_admin_referer('tgmpa');
     // Security check
     foreach ($this->plugins as $plugin) {
         // Iterate and perform the action for each plugin in the array
         $fields = array(sanitize_key($plugin['name']));
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary
         if (isset($_POST[sanitize_key($plugin['name'])])) {
             // Don't do anything if the form has not been submitted
             $url = wp_nonce_url('themes.php?page=' . $this->menu, 'tgmpa');
             // Make sure we are coming from the right page
             if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $fields))) {
                 return true;
             }
             if (!WP_Filesystem($creds)) {
                 request_filesystem_credentials($url, $method, true, false, $fields);
                 // Setup WP_Filesystem
                 return true;
             }
             require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
             // Need for plugins_api
             require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
             // Need for upgrade classes
             $api = plugins_api('plugin_information', array('slug' => $plugin['slug'], 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 wp_die($this->strings['oops'] . var_dump($api));
             }
             // Prep variables for Plugin_Installer_Skin class
             $title = sprintf($this->strings['installing'], $plugin['name']);
             $nonce = 'install-plugin_' . $plugin['slug'];
             $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => $plugin['slug']), 'update.php');
             if (isset($_GET['from'])) {
                 $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
             }
             if (!isset($plugin['source']) && isset($api->download_link)) {
                 $plugin['source'] = $api->download_link;
             }
             /** Set type, based on whether the source starts with http:// or https:// */
             $type = preg_match('|^http(s)?://|', $plugin['source']) ? 'web' : 'upload';
             /** Prefix a default path to pre-packaged plugins */
             $source = 'upload' == $type ? $this->default_path . $plugin['source'] : $plugin['source'];
             $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
             // Create a new instance of Plugin_Upgrader
             $upgrader->install($source);
             // Perform the action and install the plugin from the $source urldecode()
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method
             wp_cache_flush();
             // Flush the cache to remove plugin header errors
             $activate = activate_plugin($plugin_activate);
             // Activate the plugin
             $this->populate_file_path();
             // Re-populate the file path now that the plugin has been installed and activated
             if (is_wp_error($activate)) {
                 echo '<div id="message" class="error"><p>' . $activate->get_error_message() . '</p></div>';
                 echo '<p><a href="' . add_query_arg('page', $this->menu, admin_url('themes.php')) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . __('Return to Required Plugins Installer', $this->domain) . '</a></p>';
                 return true;
                 // End it here if there is an error with automatic activation
             } else {
                 echo '<p>' . $this->strings['plugin_activated'] . '</p>';
                 foreach ($this->plugins as $plugin) {
                     if (!is_plugin_active($plugin['file_path'])) {
                         echo '<p><a href="' . add_query_arg('page', $this->menu, admin_url('themes.php')) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . __('Return to Required Plugins Installer', $this->domain) . '</a></p>';
                         break;
                     }
                 }
             }
         }
     }
     return true;
 }
开发者ID:phanhoanglong2610,项目名称:flowershop,代码行数:95,代码来源:plugin-activation.php

示例7: do_plugin_install

 /**
  * Installs a plugin or activates a plugin depending on the hover
  * link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure.
  */
 protected function do_plugin_install()
 {
     if (!isset($_GET['plugin'])) {
         return false;
     }
     // All plugin information will be stored in an array for processing.
     $plugin = array();
     $slug = sanitize_key($_GET['plugin']);
     // Checks for actions from hover links to process the installation.
     if (isset($this->plugins[$slug], $_GET['tgmpa-install']) && 'install-plugin' === $_GET['tgmpa-install']) {
         check_admin_referer('tgmpa-install');
         // Pass necessary information via URL if WP_Filesystem is needed.
         $url = wp_nonce_url(add_query_arg(array('plugin' => urlencode($slug), 'tgmpa-install' => 'install-plugin'), $this->get_tgmpa_url()), 'tgmpa-install');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, array()))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials(esc_url_raw($url), $method, true, false, array());
             // Setup WP_Filesystem.
             return true;
         }
         // If we arrive here, we have the filesystem
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         // Need for upgrade classes.
         $plugin['slug'] = $slug;
         // Needed for potentially renaming of directory name
         $plugin['name'] = $this->plugins[$slug]['name'];
         $source = $this->get_download_url($slug);
         // Prep variables for Plugin_Installer_Skin class.
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => urlencode($slug)), 'update.php');
         // Create a new instance of Plugin_Upgrader.
         $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(array('type' => preg_match(self::IS_URL_REGEX, $source) ? 'web' : 'upload', 'title' => sprintf($this->strings['installing'], $plugin['name']), 'url' => esc_url_raw($url), 'nonce' => 'install-plugin_' . $slug, 'plugin' => $plugin)));
         // Perform the action and install the plugin from the $source urldecode().
         add_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3);
         $upgrader->install($source);
         remove_filter('upgrader_source_selection', array($this, 'maybe_adjust_source_dir'), 1, 3);
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         $this->flush_plugins_cache();
         // Only activate plugins if the config option is set to true.
         if ($this->is_automatic) {
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method.
             if (false === $this->activate_single_plugin($plugin_activate, $slug, true)) {
                 return true;
                 // Finish execution of the function early as we encountered an error
             }
             // Re-populate the file path now that the plugin has been installed and activated.
             $this->populate_file_path($slug);
         }
         // Display message based on if all plugins are now active or not.
         $complete = true;
         foreach ($this->plugins as $plugin) {
             if (!is_plugin_active($plugin['file_path'])) {
                 echo '<p><a href="', esc_url($this->get_tgmpa_url()), '" target="_parent">', esc_html($this->strings['return']), '</a></p>';
                 $complete = false;
                 break;
             }
         }
         // All plugins are active, so we display the complete string and hide the plugin menu.
         if (true === $complete) {
             echo '<p>', sprintf(esc_html($this->strings['complete']), '<a href="' . esc_url(self_admin_url()) . '">' . esc_html__('Return to the Dashboard', 'tgmpa') . '</a>'), '</p>';
             echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
         }
         return true;
     } elseif (isset($this->plugins[$slug]['file_path'], $_GET['tgmpa-activate']) && 'activate-plugin' === $_GET['tgmpa-activate']) {
         check_admin_referer('tgmpa-activate', 'tgmpa-activate-nonce');
         if (false === $this->activate_single_plugin($this->plugins[$slug]['file_path'], $slug)) {
             return true;
             // Finish execution of the function early as we encountered an error
         }
     }
     return false;
 }
开发者ID:azeemgolive,项目名称:thefunkidsgame,代码行数:95,代码来源:class-tgm-plugin-activation.php

示例8: fv_wp_flowplayer_install_extension

function fv_wp_flowplayer_install_extension($plugin_package = 'fv_player_pro')
{
    global $hook_suffix;
    $aInstalled = get_option('fv_flowplayer_extension_install') ? get_option('fv_flowplayer_extension_install') : array();
    $aInstalled = array_merge($aInstalled, array($plugin_package => false));
    update_option('fv_flowplayer_extension_install', $aInstalled);
    $aPluginInfo = get_transient('fv_flowplayer_license');
    $plugin_basename = $aPluginInfo->{$plugin_package}->slug;
    $download_url = $aPluginInfo->{$plugin_package}->url;
    $sPluginBasenameReal = fv_flowplayer_get_extension_path(str_replace('_', '-', $plugin_package));
    $plugin_basename = $sPluginBasenameReal ? $sPluginBasenameReal : $plugin_basename;
    $url = wp_nonce_url(site_url() . '/wp-admin/options-general.php?page=fvplayer', 'fv_player_pro_install', 'nonce_fv_player_pro_install');
    set_current_screen();
    ob_start();
    if (false === ($creds = request_filesystem_credentials($url, '', false, false, false))) {
        $form = ob_get_clean();
        include ABSPATH . 'wp-admin/admin-header.php';
        echo fv_wp_flowplayer_install_extension_talk($form);
        include ABSPATH . 'wp-admin/admin-footer.php';
        die;
    }
    if (!WP_Filesystem($creds)) {
        ob_start();
        request_filesystem_credentials($url, $method, true, false, false);
        $form = ob_get_clean();
        include ABSPATH . 'wp-admin/admin-header.php';
        echo fv_wp_flowplayer_install_extension_talk($form);
        include ABSPATH . 'wp-admin/admin-footer.php';
        die;
    }
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $sTaskDone = 'FV Flowplayer Pro extension installed - check the new <a href="' . site_url() . '/wp-admin/options-general.php?page=fvplayer#fv_player_pro">Pro features!</a>!';
    if (!$sPluginBasenameReal || is_wp_error(validate_plugin($plugin_basename))) {
        echo '<div style="display: none;">';
        $objInstaller = new Plugin_Upgrader();
        $objInstaller->install($download_url);
        echo '</div>';
        wp_cache_flush();
        if (is_wp_error($objInstaller->skin->result)) {
            update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension install failed - ' . $objInstaller->skin->result->get_error_message());
            $bResult = false;
        } else {
            if ($objInstaller->plugin_info()) {
                $plugin_basename = $objInstaller->plugin_info();
            }
            $activate = activate_plugin($plugin_basename);
            if (is_wp_error($activate)) {
                update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension install failed - ' . $activate->get_error_message());
                $bResult = false;
            }
        }
    } else {
        if ($sPluginBasenameReal) {
            $sTaskDone = 'FV Flowplayer Pro extension upgraded succesfully!';
            echo '<div style="display: none;">';
            $objInstaller = new Plugin_Upgrader();
            $objInstaller->upgrade($sPluginBasenameReal);
            echo '</div></div>';
            //  explanation: extra closing tag just to be safe (in case of "The plugin is at the latest version.")
            wp_cache_flush();
            if (is_wp_error($objInstaller->skin->result)) {
                update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension upgrade failed - ' . $objInstaller->skin->result->get_error_message());
                $bResult = false;
            } else {
                if ($objInstaller->plugin_info()) {
                    $plugin_basename = $objInstaller->plugin_info();
                }
                $activate = activate_plugin($plugin_basename);
                if (is_wp_error($activate)) {
                    update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension upgrade failed - ' . $activate->get_error_message());
                    $bResult = false;
                }
            }
        }
    }
    if (!isset($bResult)) {
        if (!isset($_GET['page']) || strcmp($_GET['page'], 'fvplayer') != 0) {
            update_option('fv_wordpress_flowplayer_deferred_notices', $sTaskDone);
        }
        $bResult = true;
    }
    $aInstalled = get_option('fv_flowplayer_extension_install') ? get_option('fv_flowplayer_extension_install') : array();
    $aInstalled = array_merge($aInstalled, array($plugin_package => $bResult));
    update_option('fv_flowplayer_extension_install', $aInstalled);
    return $bResult;
}
开发者ID:ryan2407,项目名称:Vision,代码行数:86,代码来源:backend.php

示例9: foreach

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

示例10: install_plugins

 private function install_plugins($plugins)
 {
     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/plugin-install.php';
     require_once dirname(dirname(__FILE__)) . '/upgrader-skin.php';
     $upgrader = new Plugin_Upgrader(new Ithemes_Sync_Upgrader_Skin());
     $results = array();
     foreach ((array) $plugins as $plugin) {
         Ithemes_Sync_Functions::set_time_limit(300);
         if (preg_match('{^(http|https|ftp)://}i', $plugin)) {
             $result = $upgrader->install($plugin);
         } else {
             $api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 $result = $api;
             } else {
                 $result = $upgrader->install($api->download_link);
             }
         }
         if (is_wp_error($result)) {
             $results[$plugin]['error'] = array('error_code' => $result->get_error_code(), 'error_details' => $result->get_error_message());
         } else {
             $results[$plugin] = array('result' => $result, 'slug' => $upgrader->plugin_info());
             if (true === $result) {
                 $results[$plugin]['success'] = true;
             }
         }
     }
     Ithemes_Sync_Functions::refresh_plugin_updates();
     return $results;
 }
开发者ID:jimlongo56,项目名称:rdiv,代码行数:33,代码来源:manage-plugins.php

示例11: do_plugin_install

 protected function do_plugin_install()
 {
     $plugin = array();
     if (isset($_GET['plugin']) && (isset($_GET['tgmpa-install']) && 'install-plugin' == $_GET['tgmpa-install'])) {
         check_admin_referer('tgmpa-install');
         $plugin['name'] = $_GET['plugin_name'];
         $plugin['slug'] = $_GET['plugin'];
         $plugin['source'] = $_GET['plugin_source'];
         $url = wp_nonce_url(add_query_arg(array('page' => urlencode($this->menu), 'plugin' => urlencode($plugin['slug']), 'plugin_name' => urlencode($plugin['name']), 'plugin_source' => urlencode($plugin['source']), 'tgmpa-install' => 'install-plugin'), network_admin_url('themes.php')), 'tgmpa-install');
         $method = '';
         $fields = array('tgmpa-install');
         if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, $fields))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials(esc_url_raw($url), $method, true, false, $fields);
             // Setup WP_Filesystem.
             return true;
         }
         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         if (isset($plugin['source']) && 'repo' == $plugin['source']) {
             $api = plugins_api('plugin_information', array('slug' => $plugin['slug'], 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 wp_die($this->strings['oops'] . var_dump($api));
             }
             if (isset($api->download_link)) {
                 $plugin['source'] = $api->download_link;
             }
         }
         $type = preg_match('|^http(s)?://|', $plugin['source']) ? 'web' : 'upload';
         $title = sprintf($this->strings['installing'], $plugin['name']);
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => urlencode($plugin['slug'])), 'update.php');
         if (isset($_GET['from'])) {
             $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
         }
         $url = esc_url_raw($url);
         $nonce = 'install-plugin_' . $plugin['slug'];
         $source = 'upload' == $type ? $this->default_path . $plugin['source'] : $plugin['source'];
         $upgrader = new Plugin_Upgrader($skin = new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
         $upgrader->install($source);
         wp_cache_flush();
         if ($this->is_automatic) {
             $plugin_activate = $upgrader->plugin_info();
             $activate = activate_plugin($plugin_activate);
             $this->populate_file_path();
             if (is_wp_error($activate)) {
                 echo '<div id="message" class="error"><p>' . $activate->get_error_message() . '</p></div>';
                 echo '<p><a href="' . esc_url(add_query_arg('page', urlencode($this->menu), network_admin_url('themes.php'))) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . $this->strings['return'] . '</a></p>';
                 return true;
             } else {
                 echo '<p>' . $this->strings['plugin_activated'] . '</p>';
             }
         }
         $complete = array();
         foreach ($this->plugins as $plugin) {
             if (!is_plugin_active($plugin['file_path'])) {
                 echo '<p><a href="' . esc_url(add_query_arg('page', urlencode($this->menu), network_admin_url('themes.php'))) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . $this->strings['return'] . '</a></p>';
                 $complete[] = $plugin;
                 break;
             } else {
                 $complete[] = '';
             }
         }
         $complete = array_filter($complete);
         if (empty($complete)) {
             echo '<p>' . sprintf($this->strings['complete'], '<a href="' . esc_url(network_admin_url()) . '" title="' . esc_attr__('Return to the Dashboard', 'tgmpa') . '">' . __('Return to the Dashboard', 'tgmpa') . '</a>') . '</p>';
             echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
         }
         return true;
     } elseif (isset($_GET['plugin']) && (isset($_GET['tgmpa-activate']) && 'activate-plugin' == $_GET['tgmpa-activate'])) {
         check_admin_referer('tgmpa-activate', 'tgmpa-activate-nonce');
         $plugin['name'] = $_GET['plugin_name'];
         $plugin['slug'] = $_GET['plugin'];
         $plugin['source'] = $_GET['plugin_source'];
         $plugin_data = get_plugins('/' . $plugin['slug']);
         $plugin_file = array_keys($plugin_data);
         $plugin_to_activate = $plugin['slug'] . '/' . $plugin_file[0];
         $activate = activate_plugin($plugin_to_activate);
         if (is_wp_error($activate)) {
             echo '<div id="message" class="error"><p>' . $activate->get_error_message() . '</p></div>';
             echo '<p><a href="' . esc_url(add_query_arg('page', urlencode($this->menu), network_admin_url('themes.php'))) . '" title="' . esc_attr($this->strings['return']) . '" target="_parent">' . $this->strings['return'] . '</a></p>';
             return true;
         } else {
             if (!isset($_POST['action'])) {
                 $msg = $this->strings['activated_successfully'] . ' <strong>' . $plugin['name'] . '.</strong>';
                 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
             }
         }
     }
     return false;
 }
开发者ID:morovan,项目名称:granitpiestany.sk,代码行数:92,代码来源:class-tgm-plugin-activation.php

示例12: feedback

 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
 class Plugin_Installer_Skin_B extends Plugin_Installer_Skin
 {
     public $done_header = true;
     public $done_footer = true;
     public function feedback($string)
     {
         if (strpos($string, 'Destination folder already exists.') !== false) {
             echo json_encode(array('failed' => __('Plugin already installed. Maybe not activated?', 'formcraft')));
             die;
         }
     }
 }
 $plugin_obj = new Plugin_Upgrader($skin = new Plugin_Installer_Skin_B(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
 $installed = $plugin_obj->install($plugin_file);
 $info = $plugin_obj->plugin_info();
 $old_location = rtrim(plugin_dir_path($info), '/');
 rename(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $old_location, WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $result['github-repo']);
 $info = str_replace($old_location, $result['github-repo'], $info);
 if ($installed == true) {
     $activated = activate_plugin($info);
     if ($activated == NULL) {
         echo json_encode(array('success' => 'true', 'plugin' => $plugin));
         die;
     } else {
         echo json_encode(array('failed' => __('Could not activate plugin', 'formcraft')));
         die;
     }
 } else {
     echo json_encode(array('failed' => __('Could not install plugin', 'formcraft')));
     die;
开发者ID:ceebee100,项目名称:AAGT2015,代码行数:31,代码来源:formcraft-main.php

示例13: soliloquy_ajax_install_addon

/**
 * Installs an Soliloquy addon.
 *
 * @since 1.0.0
 */
function soliloquy_ajax_install_addon()
{
    // Run a security check first.
    check_ajax_referer('soliloquy-install', 'nonce');
    // Install the addon.
    if (isset($_POST['plugin'])) {
        $download_url = $_POST['plugin'];
        global $hook_suffix;
        // Set the current screen to avoid undefined notices.
        set_current_screen();
        // Prepare variables.
        $method = '';
        $url = add_query_arg(array('page' => 'soliloquy-settings'), admin_url('admin.php'));
        // Start output bufferring to catch the filesystem form if credentials are needed.
        ob_start();
        if (false === ($creds = request_filesystem_credentials($url, $method, false, false, null))) {
            $form = ob_get_clean();
            echo json_encode(array('form' => $form));
            die;
        }
        // If we are not authenticated, make it happen now.
        if (!WP_Filesystem($creds)) {
            ob_start();
            request_filesystem_credentials($url, $method, true, false, null);
            $form = ob_get_clean();
            echo json_encode(array('form' => $form));
            die;
        }
        // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        require_once plugin_dir_path(Soliloquy::get_instance()->file) . 'includes/admin/skin.php';
        // Create the plugin upgrader with our custom skin.
        $installer = new Plugin_Upgrader($skin = new Soliloquy_Skin());
        $installer->install($download_url);
        // Flush the cache and return the newly installed plugin basename.
        wp_cache_flush();
        if ($installer->plugin_info()) {
            $plugin_basename = $installer->plugin_info();
            echo json_encode(array('plugin' => $plugin_basename));
            die;
        }
    }
    // Send back a response.
    echo json_encode(true);
    die;
}
开发者ID:jkhedani,项目名称:ccsa,代码行数:51,代码来源:ajax.php

示例14: install_plugin

function install_plugin($url)
{
    if (strstr($url, '.zip') != FALSE) {
        $download_link = $url;
    } else {
        $slug = explode('/', $url);
        $slug = $slug[count($slug) - 2];
        $api = plugins_api('plugin_information', array('slug' => $slug, 'fields' => array('sections' => 'false')));
        $download_link = $api->download_link;
    }
    $upgrader = new Plugin_Upgrader();
    if (!$upgrader->install($download_link)) {
        return 0;
    }
    //This will also activate the plugin after installation
    $plugin_to_activate = $upgrader->plugin_info();
    $activate = activate_plugin($plugin_to_activate);
    wp_cache_flush();
    return 1;
}
开发者ID:rolexmessi,项目名称:101,代码行数:20,代码来源:index.php

示例15: do_plugin_install

 /**
  * Installs a plugin or activates a plugin depending on the hover
  * link clicked by the user.
  *
  * Checks the $_GET variable to see which actions have been
  * passed and responds with the appropriate method.
  *
  * Uses WP_Filesystem to process and handle the plugin installation
  * method.
  *
  * @since 1.0.0
  *
  * @uses WP_Filesystem
  * @uses WP_Error
  * @uses WP_Upgrader
  * @uses Plugin_Upgrader
  * @uses Plugin_Installer_Skin
  *
  * @return boolean True on success, false on failure
  */
 protected function do_plugin_install()
 {
     // All plugin information will be stored in an array for processing.
     $plugin = array();
     // Checks for actions from hover links to process the installation.
     if (isset($_GET['plugin']) && (isset($_GET['tgmpa-install']) && 'install-plugin' === $_GET['tgmpa-install'])) {
         check_admin_referer('tgmpa-install');
         $plugin['name'] = $_GET['plugin_name'];
         // Plugin name. // @todo needs sanitizing, figure out how
         $plugin['slug'] = sanitize_title($_GET['plugin']);
         // Plugin slug.
         $plugin['source'] = $_GET['plugin_source'];
         // Plugin source. // @todo needs sanitizing, figure out how
         // Pass all necessary information via URL if WP_Filesystem is needed.
         $url = wp_nonce_url(add_query_arg(array('page' => urlencode($this->menu), 'plugin' => urlencode($plugin['slug']), 'plugin_name' => urlencode($plugin['name']), 'plugin_source' => urlencode($plugin['source']), 'tgmpa-install' => 'install-plugin'), self_admin_url($this->parent_slug)), 'tgmpa-install');
         $method = '';
         // Leave blank so WP_Filesystem can populate it as necessary.
         $fields = array('tgmpa-install');
         // Extra fields to pass to WP_Filesystem.
         if (false === ($creds = request_filesystem_credentials(esc_url_raw($url), $method, false, false, $fields))) {
             return true;
         }
         if (!WP_Filesystem($creds)) {
             request_filesystem_credentials(esc_url_raw($url), $method, true, false, $fields);
             // Setup WP_Filesystem.
             return true;
         }
         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         // Need for plugins_api.
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         // Need for upgrade classes.
         // Set plugin source to WordPress API link if available.
         if (isset($plugin['source']) && 'repo' === $plugin['source']) {
             $api = plugins_api('plugin_information', array('slug' => $plugin['slug'], 'fields' => array('sections' => false)));
             if (is_wp_error($api)) {
                 if (WP_DEBUG === true) {
                     wp_die(esc_html($this->strings['oops']) . var_dump($api));
                     // wpcs: xss ok
                 } else {
                     wp_die(esc_html($this->strings['oops']));
                 }
             }
             if (isset($api->download_link)) {
                 $plugin['source'] = $api->download_link;
             }
         }
         // Set type, based on whether the source starts with http:// or https://.
         $type = preg_match('|^http(s)?://|', $plugin['source']) ? 'web' : 'upload';
         // Prep variables for Plugin_Installer_Skin class.
         $title = sprintf($this->strings['installing'], $plugin['name']);
         $url = add_query_arg(array('action' => 'install-plugin', 'plugin' => urlencode($plugin['slug'])), 'update.php');
         if (isset($_GET['from'])) {
             $url .= add_query_arg('from', urlencode(stripslashes($_GET['from'])), $url);
         }
         $url = esc_url_raw($url);
         $nonce = 'install-plugin_' . $plugin['slug'];
         // Prefix a default path to pre-packaged plugins.
         $source = 'upload' === $type ? $this->default_path . $plugin['source'] : $plugin['source'];
         // Create a new instance of Plugin_Upgrader.
         $upgrader = new Plugin_Upgrader($skin = new Plugin_Installer_Skin(compact('type', 'title', 'url', 'nonce', 'plugin', 'api')));
         // Perform the action and install the plugin from the $source urldecode().
         $upgrader->install($source);
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
         // Only activate plugins if the config option is set to true.
         if ($this->is_automatic) {
             $plugin_activate = $upgrader->plugin_info();
             // Grab the plugin info from the Plugin_Upgrader method.
             $activate = activate_plugin($plugin_activate);
             // Activate the plugin.
             $this->populate_file_path();
             // Re-populate the file path now that the plugin has been installed and activated.
             if (is_wp_error($activate)) {
                 echo '<div id="message" class="error"><p>', wp_kses_post($activate->get_error_message()), '</p></div>', '<p><a href="', esc_url(add_query_arg('page', urlencode($this->menu), self_admin_url('themes.php'))), '" target="_parent">', esc_html($this->strings['return']), '</a></p>';
                 return true;
                 // End it here if there is an error with automatic activation
             } else {
                 echo '<p>', esc_html($this->strings['plugin_activated']), '</p>';
             }
         }
//.........这里部分代码省略.........
开发者ID:luxifel,项目名称:Bionerd,代码行数:101,代码来源:td-old-class-tgm-plugin-activation.php


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