/**
     * Perform automatic updates for the core plugin and addons
     *
     * @author Jonathan Davis
     * @author Kevin Behrens
     *
     * @return void
     **/
    public static function update($plugin = '')
    {
        global $parent_file, $submenu_file;
        pp_get_version_info(true);
        if (!current_user_can('update_plugins')) {
            wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
        }
        if (!$plugin) {
            $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
        }
        $plugin = urldecode($plugin);
        $title = '';
        global $pp_extensions;
        if (isset($pp_extensions[$_REQUEST['action']])) {
            $slug = $_REQUEST['action'];
            $title = sprintf(__('Upgrade %s', 'pp'), $pp_extensions[$slug]->label);
        }
        if ($slug) {
            // temp workaround
            global $pp_update_done;
            if (!empty($pp_update_done)) {
                $return;
            }
            $pp_update_done = true;
            // check_admin_referer('upgrade-plugin_' . $plugin);
            $parent_file = 'plugins.php';
            $submenu_file = 'plugins.php';
            ?>
<style>
.press-permit .updating { background-image:url('<?php 
            echo admin_url('');
            ?>
/images/wspin_light.gif');background-repeat:no-repeat; }
.press-permit button.updating { background-position:5px 1px;padding-left:25px; }
.press-permit .icon32 { background:url('<?php 
            echo PP_URLPATH;
            ?>
/admin/images/pp-logo-32.png') no-repeat; width:18px;height:32px;float:left;margin-right:15px }
.press-permit p { font-family: sans-serif;font-size: 12px;line-height: 1.4em; }
</style>
			<?php 
            $nonce = 'upgrade-plugin_' . $plugin;
            $url = "update.php?action={$slug}&plugin=" . $plugin;
            $upgrader = new PP_Core_Upgrader(new PP_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin')));
            $upgrader->upgrade_pp_package($plugin);
            define('UPDATED_PP_PLUGIN', true);
            $plugin_updates = get_site_transient('update_plugins');
            if (is_object($plugin_updates) && isset($plugin_updates->response)) {
                unset($plugin_updates->response[$plugin]);
                set_site_transient('update_plugins', $plugin_updates);
            }
        }
    }
Пример #2
0
 function flt_insert_pp_update_info($plugin_updates)
 {
     global $pp_extensions;
     static $busy;
     if (defined('UPDATED_PP_PLUGIN') || !empty($busy)) {
         return $plugin_updates;
     }
     $busy = true;
     $pp_updates = pp_get_version_info();
     $busy = false;
     foreach ($pp_extensions as $ext) {
         if (!empty($pp_updates->response[$ext->basename]->package)) {
             $plugin_updates->response[$ext->basename] = (object) array('slug' => $ext->slug);
             // Add this PP extension to the WP plugin update notification count
         }
     }
     return $plugin_updates;
 }
Пример #3
0
 function update_page_options($args)
 {
     global $pp_default_options;
     do_action('pp_update_options', $args);
     $default_prefix = apply_filters('pp_options_apply_default_prefix', '', $args);
     foreach (explode(',', $_POST['all_options']) as $option_basename) {
         $value = isset($_POST[$option_basename]) ? $_POST[$option_basename] : '';
         if (!is_array($value)) {
             $value = trim($value);
         }
         if ('beta_updates' == $option_basename) {
             if (stripslashes_deep($value) != pp_get_option('beta_updates')) {
                 // force regeneration and buffering of file update urls
                 delete_site_transient('update_plugins');
                 pp_get_version_info(true, false, true);
                 wp_update_plugins();
             }
         }
         pp_update_option($default_prefix . $option_basename, stripslashes_deep($value), $args);
     }
     foreach (explode(',', $_POST['all_otype_options']) as $option_basename) {
         // support stored default values (to apply to any post type which does not have an explicit setting)
         if (isset($_POST[$option_basename][0])) {
             $_POST[$option_basename][''] = $_POST[$option_basename][0];
             unset($_POST[$option_basename][0]);
         }
         $value = isset($pp_default_options[$option_basename]) ? $pp_default_options[$option_basename] : array();
         if ($current = pp_get_option($option_basename)) {
             // retain setting for any types which were previously enabled for filtering but are currently not registered
             $value = array_merge($value, $current);
         }
         if (isset($_POST[$option_basename])) {
             $value = array_merge($value, $_POST[$option_basename]);
         }
         foreach (array_keys($value) as $key) {
             $value[$key] = stripslashes_deep($value[$key]);
         }
         pp_update_option($default_prefix . $option_basename, $value, $args);
     }
     if (!empty($_POST['post_blockage_priority'])) {
         // once this is switched on manually, don't ever default-disable it again
         if (get_option('ppperm_legacy_exception_handling')) {
             delete_option('ppperm_legacy_exception_handling');
             require_once dirname(__FILE__) . '/admin/admin-load_pp.php';
             _pp_dashboard_dismiss_msg();
         }
     }
     if (!empty($_POST['do_group_index_drop'])) {
         if (get_option('pp_need_group_index_drop')) {
             require_once dirname(__FILE__) . '/admin/update_pp.php';
             PP_Updated::do_index_drop(PP_Updated::drop_group_indexes_sql(), 'pp_did_group_index_drop');
             delete_option('pp_need_group_index_drop');
         }
     }
 }
Пример #4
0
 function upgrade_pp_package($plugin)
 {
     $is_active = is_plugin_active($plugin);
     $this->init();
     $this->upgrade_strings();
     $current = get_site_transient('ppc_update_info');
     if (!isset($current->response[$plugin])) {
         $this->skin->set_result(false);
         $this->skin->error('up_to_date');
         $this->skin->after();
         return false;
     }
     // Get the URL to the zip file
     $r = $current->response[$plugin];
     add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
     add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
     $this->run(array('package' => $r->package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
     // Cleanup our hooks, incase something else does a upgrade on this connection.
     remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
     remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
     if (!$this->result || is_wp_error($this->result)) {
         delete_site_transient('update_plugins');
         // force reload of plugin status in case this is due to a key expiration
         pp_get_version_info(true, false, true);
         return $this->result;
     }
     if (!is_multisite() && $is_active) {
         activate_plugins($plugin);
     }
     // Force refresh of plugin update information
     set_site_transient('ppc_update_info', false);
     // Force refresh of plugin update information
     delete_site_transient('update_plugins');
     wp_cache_delete('plugins', 'plugins');
 }
Пример #5
0
function pp_get_all_updates_info($force_refresh = false)
{
    $update_info = (array) get_site_transient('ppc_all_updates');
    if (empty($update_info) || $force_refresh) {
        $update_info = (array) pp_get_version_info(true, true);
        // force refresh
    }
    return $update_info;
}