Permalink
Browse files

Removing the updater until I get it sorted out.

  • Loading branch information...
1 parent a2619f5 commit bd492150204bd9187b1c71861e806be0076552a0 Jeff Behnke committed Mar 26, 2012
Showing with 11 additions and 367 deletions.
  1. +0 −331 updater.php
  2. +11 −36 vw_benchmark.php → wp_benchmark.php
View
331 updater.php
@@ -1,331 +0,0 @@
-<?php
-
-// Prevent loading this file directly - Busted!
-if ( !defined('ABSPATH') )
- die('-1');
-
-if ( ! class_exists( 'WPGitHubUpdater' ) ) :
-
-/**
- * @version 1.3
- * @author Joachim Kudish <info@jkudish.com>
- * @link http://jkudish.com
- * @package GithubUpdater
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @copyright Copyright (c) 2011, Joachim Kudish
- *
- * GNU General Public License, Free Software Foundation
- * <http://creativecommons.org/licenses/GPL/2.0/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-class WPGitHubUpdater {
-
- /**
- * Class Constructor
- *
- * @since 1.0
- * @param array $config configuration
- * @return void
- */
- public function __construct( $config = array() ) {
-
- global $wp_version;
-
- $defaults = array(
- 'slug' => plugin_basename(__FILE__),
- 'proper_folder_name' => plugin_basename(__FILE__),
- 'api_url' => 'https://api.github.com/repos/jkudish/WordPress-GitHub-Plugin-Updater',
- 'raw_url' => 'https://raw.github.com/jkudish/WordPress-GitHub-Plugin-Updater/master',
- 'github_url' => 'https://github.com/jkudish/WordPress-GitHub-Plugin-Updater',
- 'zip_url' => 'https://github.com/jkudish/WordPress-GitHub-Plugin-Updater/zipball/master',
- 'sslverify' => true,
- 'requires' => $wp_version,
- 'tested' => $wp_version,
- );
-
- $this->config = wp_parse_args( $config, $defaults );
-
- $this->set_defaults();
-
- if ( ( defined('WP_DEBUG') && WP_DEBUG ) || ( defined('WP_GITHUB_FORCE_UPDATE') || WP_GITHUB_FORCE_UPDATE ) )
- add_action( 'init', array( $this, 'delete_transients' ) );
-
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
-
- // Hook into the plugin details screen
- add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 10, 3 );
- add_filter( 'upgrader_post_install', array( $this, 'upgrader_post_install' ), 10, 3 );
-
- // set timeout
- add_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );
- }
-
-
- /**
- * Set defaults
- *
- * @since 1.2
- * @return void
- */
- public function set_defaults() {
-
- if ( ! isset( $this->config['new_version'] ) )
- $this->config['new_version'] = $this->get_new_version();
-
- if ( ! isset( $this->config['last_updated'] ) )
- $this->config['last_updated'] = $this->get_date();
-
- if ( ! isset( $this->config['description'] ) )
- $this->config['description'] = $this->get_description();
-
- $plugin_data = $this->get_plugin_data();
- if ( ! isset( $this->config['plugin_name'] ) )
- $this->config['plugin_name'] = $plugin_data['Name'];
-
- if ( ! isset( $this->config['version'] ) )
- $this->config['version'] = $plugin_data['Version'];
-
- if ( ! isset( $this->config['author'] ) )
- $this->config['author'] = $plugin_data['Author'];
-
- if ( ! isset( $this->config['homepage'] ) )
- $this->config['homepage'] = $plugin_data['PluginURI'];
- }
-
-
- /**
- * Callback fn for the http_request_timeout filter
- *
- * @since 1.0
- * @return int timeout value
- */
- public function http_request_timeout() {
- return 2;
- }
-
-
- /**
- * Delete transients (runs when WP_DEBUG is on)
- * For testing purposes the site transient will be reset on each page load
- *
- * @since 1.0
- * @return void
- */
- public function delete_transients() {
- delete_site_transient( 'update_plugins' );
- delete_site_transient( $this->config['slug'].'_new_version' );
- delete_site_transient( $this->config['slug'].'_github_data' );
- delete_site_transient( $this->config['slug'].'_changelog' );
- }
-
-
- /**
- * Get New Version from github
- *
- * @since 1.0
- * @return int $version the version number
- */
- public function get_new_version() {
- $version = get_site_transient( $this->config['slug'].'_new_version' );
-
- if ( !isset( $version ) || !$version || '' == $version ) {
-
- $raw_response = wp_remote_get(
- trailingslashit($this->config['raw_url']).'README.md',
- array(
- 'sslverify' => $this->config['sslverify'],
- )
- );
-
- if ( is_wp_error( $raw_response ) )
- return false;
-
- $__version = explode( '~Current Version:', $raw_response['body'] );
-
- if ( !isset($__version['1']) )
- return false;
-
- $_version = explode( '~', $__version['1'] );
- $version = $_version[0];
-
- // refresh every 6 hours
- set_site_transient( $this->config['slug'].'_new_version', $version, 60*60*6 );
- }
-
- return $version;
- }
-
-
- /**
- * Get GitHub Data from the specified repository
- *
- * @since 1.0
- * @return array $github_data the data
- */
- public function get_github_data() {
- $github_data = get_site_transient( $this->config['slug'].'_github_data' );
-
- if ( ! isset( $github_data ) || ! $github_data || '' == $github_data ) {
- $github_data = wp_remote_get(
- $this->config['api_url']
- ,$this->config['sslverify']
- );
-
- if ( is_wp_error( $github_data ) )
- return false;
-
- $github_data = json_decode( $github_data['body'] );
-
- // refresh every 6 hours
- set_site_transient( $this->config['slug'].'_github_data', $github_data, 60*60*6);
- }
-
- return $github_data;
- }
-
-
- /**
- * Get update date
- *
- * @since 1.0
- * @return string $date the date
- */
- public function get_date() {
- $_date = $this->get_github_data();
- return ( !empty($_date->updated_at) ) ? date( 'Y-m-d', strtotime( $_date->updated_at ) ) : false;
- }
-
-
- /**
- * Get plugin description
- *
- * @since 1.0
- * @return string $description the description
- */
- public function get_description() {
- $_description = $this->get_github_data();
- return ( !empty($_description->description) ) ? $_description->description : false;
- }
-
-
- /**
- * Get Plugin data
- *
- * @since 1.0
- * @return object $data the data
- */
- public function get_plugin_data() {
- include_once( ABSPATH.'/wp-admin/includes/plugin.php' );
- $data = get_plugin_data( WP_PLUGIN_DIR.'/'.$this->config['slug'] );
- return $data;
- }
-
-
- /**
- * Hook into the plugin update check and connect to github
- *
- * @since 1.0
- * @param object $transient the plugin data transient
- * @return object $transient updated plugin data transient
- */
- public function api_check( $transient ) {
-
- // Check if the transient contains the 'checked' information
- // If not, just return its value without hacking it
- if ( empty( $transient->checked ) )
- return $transient;
-
- // check the version and decide if it's new
- $update = version_compare( $this->config['new_version'], $this->config['version'] );
-
- if ( 1 === $update ) {
- $response = new stdClass;
- $response->new_version = $this->config['new_version'];
- $response->slug = $this->config['slug'];
- $response->url = $this->config['github_url'];
- $response->package = $this->config['zip_url'];
-
- // If response is false, don't alter the transient
- if ( false !== $response )
- $transient->response[ $this->config['slug'] ] = $response;
- }
-
- return $transient;
- }
-
-
- /**
- * Get Plugin info
- *
- * @since 1.0
- * @param bool $false always false
- * @param string $action the API function being performed
- * @param object $args plugin arguments
- * @return object $response the plugin info
- */
- public function get_plugin_info( $false, $action, $args ) {
-
- // Check if this call API is for the right plugin
- if ( $args->slug != $this->config['slug'] )
- return false;
-
- $response->slug = $this->config['slug'];
- $response->plugin_name = $this->config['plugin_name'];
- $response->version = $this->config['new_version'];
- $response->author = $this->config['author'];
- $response->homepage = $this->config['homepage'];
- $response->requires = $this->config['requires'];
- $response->tested = $this->config['tested'];
- $response->downloaded = 0;
- $response->last_updated = $this->config['last_updated'];
- $response->sections = array( 'description' => $this->config['description'] );
- $response->download_link = $this->config['zip_url'];
-
- return $response;
- }
-
-
- /**
- * Upgrader/Updater
- * Move & activate the plugin, echo the update message
- *
- * @since 1.0
- * @param boolean $true always true
- * @param mixed $hook_extra not used
- * @param array $result the result of the move
- * @return array $result the result of the move
- */
- public function upgrader_post_install( $true, $hook_extra, $result ) {
-
- global $wp_filesystem;
-
- // Move & Activate
- $proper_destination = WP_PLUGIN_DIR.'/'.$this->config['proper_folder_name'];
- $wp_filesystem->move( $result['destination'], $proper_destination );
- $result['destination'] = $proper_destination;
- $activate = activate_plugin( WP_PLUGIN_DIR.'/'.$this->config['slug'] );
-
- // Output the update message
- $fail = __('The plugin has been updated, but could not be reactivated. Please reactivate it manually.', 'github_plugin_updater');
- $success = __('Plugin reactivated successfully.', 'github_plugin_updater');
- echo is_wp_error( $activate ) ? $fail : $success;
- return $result;
-
- }
-
-}
-
-endif; // endif class exists
View
47 vw_benchmark.php → wp_benchmark.php
@@ -1,7 +1,7 @@
<?php
/*
-Plugin Name: VW Benchmark
+Plugin Name: WP Benchmark
Plugin URI: https://github.com/topdown/WP-Benchmark
Description: <strong>(PHP 5+ is required)</strong> A quick benchmark utility for WordPress It will currently output Run Time, Query Count, Memory Usage, Included File count. It can also output all queries being run, query errors, constants, and included files. <strong>You shouldn't leave this active, there is no reason to, its purpose is for debugging.</strong> But if you do at least shut off all of the settings in the settings page for the plugin. <strong>Only admins can see the data from this plugin unless checked for everyone (Don't leave it checked).</strong>
Version: 1.0.0
@@ -34,12 +34,12 @@
* Created 3/26/12, 2:14 AM
*
* @category WordPress Plugin
- * @package VW Benchmark - vw_benchmark.php
+ * @package VW Benchmark - wp_benchmark.php
* @author Jeff Behnke <code@validwebs.com>
* @copyright 2009-12 ValidWebs.com
* @license GPL MIT
*/
-class vw_benchmark
+class wp_benchmark
{
/**
@@ -69,7 +69,7 @@ class vw_benchmark
*
* @var string
*/
- public $plugin_slug = 'vw_bench';
+ public $plugin_slug = 'wp_bench';
/**
* Initiate the plugin
@@ -93,10 +93,6 @@ public function __construct()
$this->plugin_slug . '_plugin_action_links'
), 10, 2);
- add_action('init', array(
- $this,
- 'github_updater_init'
- ));
}
else
{
@@ -127,9 +123,9 @@ public function __construct()
*
* @return array
*/
- public function vw_bench_plugin_action_links($links, $file)
+ public function wp_bench_plugin_action_links($links, $file)
{
- if ($file == 'WP-Benchmark/vw_benchmark.php')
+ if ($file == 'WP-Benchmark/wp_benchmark.php')
{
$settings_link = '<a href="options-general.php?page=' . $this->plugin_slug . '">' . __('Settings', $this->plugin_slug) . '</a>';
array_unshift($links, $settings_link);
@@ -138,7 +134,7 @@ public function vw_bench_plugin_action_links($links, $file)
}
// Insert the menu link
- public function vw_bench_menu()
+ public function wp_bench_menu()
{
//create new menu
//( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL )
@@ -157,7 +153,7 @@ public function vw_bench_menu()
/**
* The code for the options page / settings
*/
- public function vw_bench_settings()
+ public function wp_bench_settings()
{
global $current_user;
@@ -417,7 +413,7 @@ public function bench_css()
*
* @return mixed
*/
- public function vw_benchmark_init()
+ public function wp_benchmark_init()
{
global $current_user;
@@ -597,28 +593,7 @@ private function list_hooked_functions($tag = false)
}
- public function github_updater_init()
- {
- include_once('updater.php');
-
- define('WP_GITHUB_FORCE_UPDATE', true);
-
- $config = array(
- 'slug' => plugin_basename(__FILE__),
- 'proper_folder_name' => 'WP-Benchmark',
- 'api_url' => 'https://api.github.com/repos/topdown/WP-Benchmark',
- 'raw_url' => 'https://raw.github.com/topdown/WP-Benchmark/master',
- 'github_url' => 'https://github.com/topdown/WP-Benchmark',
- 'zip_url' => 'https://github.com/topdown/WP-Benchmark/zipball/master',
- 'sslverify' => true,
- 'requires' => '3.0',
- 'tested' => '3.3',
- );
-
- new WPGitHubUpdater($config);
-
- }
}
-$vw_benchmark = new vw_benchmark();
-// End vw_benchmark.php
+$wp_benchmark = new wp_benchmark();
+// End wp_benchmark.php

0 comments on commit bd49215

Please sign in to comment.