function spa_toolbox_environment_form()
{
    #== ENVIRONMENT INFO Tab ==========================================================
    global $wp_version, $wpdb;
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    $theme = wp_get_theme();
    $wp_plugins = get_plugins();
    $sp_plugins = sp_get_plugins();
    spa_paint_open_tab(spa_text('Toolbox') . ' - ' . spa_text('Environment'), true);
    spa_paint_open_fieldset(spa_text('Environment'), false);
    echo '<div id="sp-environment-data">';
    echo '<table class=:widefat">';
    spa_env_open(spa_text('Simple:Press'));
    spa_env_info(spa_text('Version'), SPVERSION);
    spa_env_info(spa_text('Build'), SPBUILD);
    spa_env_info(spa_text('Release'), SPRELEASE);
    spa_env_close();
    spa_env_open(spa_text('WordPress'));
    spa_env_info(spa_text('Version'), $wp_version);
    spa_env_info(spa_text('Language'), get_bloginfo('language'));
    spa_env_info(spa_text('Character Set'), get_bloginfo('charset'));
    spa_env_info(spa_text('Theme'), $theme->get('Name'));
    spa_env_close();
    spa_env_open(spa_text('PHP'));
    spa_env_info(spa_text('Version'), phpversion());
    spa_env_info(spa_text('Memory'), ini_get('memory_limit'));
    spa_env_info(spa_text('Max Upload'), ini_get('upload_max_filesize'));
    spa_env_info(spa_text('Timeout'), ini_get('user_ini.cache_ttl'));
    spa_env_close();
    spa_env_open(spa_text('MySQL'));
    spa_env_info(spa_text('Version'), $wpdb->db_version());
    spa_env_info(spa_text('Prefix'), $wpdb->prefix);
    spa_env_close();
    spa_env_open(spa_text('Server'));
    spa_env_info(spa_text('Version'), $_SERVER['SERVER_SOFTWARE']);
    spa_env_close();
    spa_env_open(spa_text('WP Plugins'));
    foreach (array_keys($wp_plugins) as $key) {
        if (is_plugin_active($key)) {
            $plugin = $wp_plugins[$key];
            spa_env_list($plugin['Name'], $plugin['Version']);
        }
    }
    spa_env_close();
    spa_env_open(spa_text('SP Plugins'));
    foreach ((array) $sp_plugins as $plugin_file => $plugin_data) {
        if (sp_is_plugin_active($plugin_file)) {
            spa_env_list($plugin_data['Name'], $plugin_data['Version']);
        }
    }
    spa_env_close();
    echo '</table>';
    echo '</div>';
    spa_paint_close_fieldset();
    do_action('sph_toolbox_environment_panel');
    spa_paint_close_container();
    spa_paint_close_tab();
}
Ejemplo n.º 2
0
function sp_validate_plugin($plugin)
{
    if (validate_file($plugin)) {
        return new WP_Error('plugin_invalid', sp_text('Invalid plugin path'));
    }
    if (!file_exists(SFPLUGINDIR . $plugin)) {
        return new WP_Error('plugin_not_found', sp_text('Plugin file does not exist'));
    }
    $installed_plugins = sp_get_plugins();
    if (!isset($installed_plugins[$plugin])) {
        return new WP_Error('no_plugin_header', sp_text('The plugin does not have a valid header'));
    }
    return 0;
}
function spa_get_plugins_list_data()
{
    $plugins = sp_get_plugins();
    return $plugins;
}
function sp_check_for_updates()
{
    $xml = sp_load_version_xml();
    if ($xml) {
        $installed_version = sp_get_option('sfversion');
        $installed_build = sp_get_option('sfbuild');
        if (empty($installed_build)) {
            return;
        }
        if ($xml->core->build > $installed_build) {
            $up = get_site_transient('update_plugins');
            $data = new stdClass();
            $data->slug = 'simple-press';
            $data->new_version = (string) $xml->core->version . ' Build ' . (string) $xml->core->build;
            $data->new_build = (string) $xml->core->build;
            $data->upgrade_notice = (string) $xml->core->message;
            $data->url = 'http://simple-press.com';
            $data->package = (string) $xml->core->archive;
            $up->response['simple-press/sp-control.php'] = $data;
            set_site_transient('update_plugins', $up);
        }
        $update = false;
        $plugins = sp_get_plugins();
        if (!empty($plugins)) {
            $up = new stdClass();
            foreach ($plugins as $file => $installed) {
                foreach ($xml->plugins->plugin as $latest) {
                    if ($installed['Name'] == $latest->name) {
                        if (version_compare($latest->version, $installed['Version'], '>') == 1) {
                            $data->slug = $file;
                            $data->new_version = (string) $latest->version;
                            $data->url = 'http://simple-press.com';
                            $data->package = (string) $latest->archive . '&wpupdate=1';
                            $up->response[$file] = $data;
                            $update = true;
                        }
                    }
                }
            }
        }
        if ($update) {
            set_site_transient('sp_update_plugins', $up);
        } else {
            delete_site_transient('sp_update_plugins');
        }
        include_once SF_PLUGIN_DIR . '/admin/panel-themes/support/spa-themes-prepare.php';
        $update = false;
        $themes = sp_get_themes();
        if (!empty($themes)) {
            $up = new stdClass();
            foreach ($themes as $file => $installed) {
                foreach ($xml->themes->theme as $latest) {
                    if ($installed['Name'] == $latest->name) {
                        if (version_compare($latest->version, $installed['Version'], '>') == 1) {
                            $data = new stdClass();
                            $data->slug = $file;
                            $data->stylesheet = $installed['Stylesheet'];
                            $data->new_version = (string) $latest->version;
                            $data->url = 'http://simple-press.com';
                            $data->package = (string) $latest->archive . '&wpupdate=1';
                            $up->response[$file] = $data;
                            $update = true;
                        }
                    }
                }
            }
        }
        if ($update) {
            set_site_transient('sp_update_themes', $up);
        } else {
            delete_site_transient('sp_update_themes');
        }
    }
}
 function plugin_info()
 {
     if (!is_array($this->result)) {
         return false;
     }
     if (empty($this->result['destination_name'])) {
         return false;
     }
     $plugin = sp_get_plugins('/' . $this->result['destination_name']);
     # Ensure to pass with leading slash
     if (empty($plugin)) {
         return false;
     }
     $pluginfiles = array_keys($plugin);
     # Assume the requested plugin is the first in the list
     return $this->result['destination_name'] . '/' . $pluginfiles[0];
 }
function sp_update_check_sp_plugins()
{
    $xml = sp_load_version_xml();
    if ($xml) {
        $plugins = sp_get_plugins();
        if (empty($plugins)) {
            return;
        }
        $up = new stdClass();
        $update = false;
        $header = true;
        foreach ($plugins as $file => $installed) {
            foreach ($xml->plugins->plugin as $latest) {
                if ($installed['Name'] == $latest->name) {
                    if (version_compare($latest->version, $installed['Version'], '>') == 1) {
                        if ($header) {
                            $form_action = 'update-core.php?action=do-sp-plugin-upgrade';
                            ?>
							<h3><?php 
                            spa_etext('Simple:Press Plugins');
                            ?>
</h3>
							<p><?php 
                            spa_etext('The following plugins have new versions available. Check the ones you want to update and then click Update SP Plugin');
                            ?>
</p>
							<p><?php 
                            spa_etext('Please Note: Any customizations you have made to plugin files will be lost');
                            ?>
</p>
							<form method="post" action="<?php 
                            echo $form_action;
                            ?>
" name="upgrade-sp-plugins" class="upgrade">
							<?php 
                            wp_nonce_field('upgrade-core');
                            ?>
							<p><input id="upgrade-themes" class="button" type="submit" value="<?php 
                            spa_etext('Update SP Plugins');
                            ?>
" 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 
                            spa_etext('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 
                            spa_etext('Select All');
                            ?>
</label></th>
								</tr>
								</tfoot>
								<tbody class="plugins">
<?php 
                            $header = false;
                        }
                        echo "\n\t\t\t\t\t\t\t<tr class='active'>\n\t\t\t\t\t\t\t<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($file) . "' /></th>\n\t\t\t\t\t\t\t<td><strong>{$installed['Name']}</strong><br />" . sprintf(spa_text('You have version %1$s installed. Update to %2$s. Requires SP Version %3$s.'), $installed['Version'], $latest->version, $latest->requires) . '</td>
							</tr>';
                        $data = new stdClass();
                        $data->slug = $file;
                        $data->new_version = (string) $latest->version;
                        $data->url = 'http://simple-press.com';
                        $data->package = (string) $latest->archive . '&wpupdate=1';
                        $up->response[$file] = $data;
                        $update = true;
                    }
                }
            }
        }
        # any plugins to update?
        if ($update) {
            set_site_transient('sp_update_plugins', $up);
        } else {
            delete_site_transient('sp_update_plugins');
        }
        if (!$header) {
            ?>
				</tbody>
			</table>
			<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php 
            spa_etext('Update SP Plugins');
            ?>
" name="upgrade" /></p>
			</form>
<?php 
        } else {
            echo '<h3>' . spa_text('Simple:Press Plugins') . '</h3>';
            echo '<p>' . spa_text('Your SP plugins are all up to date') . '</p>';
        }
    }
}