Skip to content

Commit

Permalink
Merge pull request #2 from afragen/develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
andriiryzhkov committed Jan 30, 2015
2 parents 978eca1 + d694f71 commit 5009eda
Show file tree
Hide file tree
Showing 19 changed files with 412 additions and 309 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#### 3.2.7
#### 3.3.0
* changed `is_a()` to `instanceof` per https://core.trac.wordpress.org/changeset/31188
* added [class Autoloader](https://github.com/afragen/autoloader), requires PHP 5.3 or greater as autoloader class requires namespacing

* renamed directory and class names to allow for PSR 0 style loading



#### 3.2.6
* added French translation by @daniel-menard
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Contributors: [Andy Fragen](https://github.com/afragen), [Gary Jones](https://github.com/GaryJones), [Seth Carstens](https://github.com/scarstens), [contributors](https://github.com/afragen/github-updater/graphs/contributors)
* Tags: plugin, theme, update, updater, github, bitbucket
* Requires at least: 3.8
* Requires PHP: 5.3
* Tested up to: 4.1
* Stable tag: master
* License: GPLv2 or later
Expand Down Expand Up @@ -179,7 +180,7 @@ Use `Requires WP:` to set the minimum required version of WordPress needed for y

Use `Requires PHP:` to set the minimum required version of PHP needed for your plugin or theme. eg. `Requires PHP: 5.3`

At the moment the default values are **WordPress 0.0.0** and **PHP 5.2.4**
At the moment the default values are **WordPress 0.0.0** and **PHP 5.3**

## Deleting Transients

Expand Down
13 changes: 7 additions & 6 deletions github-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Plugin Name: GitHub Updater
Plugin URI: https://github.com/afragen/github-updater
Description: A plugin to automatically update GitHub or Bitbucket hosted plugins and themes into WordPress. Plugin class based upon <a href="https://github.com/codepress/github-plugin-updater">codepress/github-plugin-updater</a>. Theme class based upon <a href="https://github.com/WordPress-Phoenix/whitelabel-framework">Whitelabel Framework</a> modifications.
Version: 3.2.6
Version: 3.2.6.1
Author: Andy Fragen
License: GNU General Public License v2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -21,18 +21,19 @@
GitHub Plugin URI: https://github.com/afragen/github-updater
GitHub Branch: develop
Requires WP: 3.8
Requires PHP: 5.3
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

// Load main class
if ( ! class_exists( 'GitHub_Updater' ) ) {
require 'includes/class-github-updater.php';
load_plugin_textdomain( 'github-updater', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
// Load Autoloader
require_once( 'includes/Autoloader.php' );

// Load textdomain
load_plugin_textdomain( 'github-updater', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

// Instantiate class GitHub_Updater
new GitHub_Updater;
Expand Down
62 changes: 62 additions & 0 deletions includes/Autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

// namespace must be unique to each plugin
namespace GitHub_Updater;

/**
* Class Autoloader - generic autoload class
*
* To use with different plugins be sure to create a new namespace.
*
* @package Autoloader
* @author Andy Fragen <[email protected]>
* @license GPL-2.0+
* @link http://github.com/afragen/autoloader
* @copyright 2015 Andy Fragen
* @version 1.1.0
*/

class Autoloader {

/**
* Constructor
*/
public function __construct() {
spl_autoload_register( array( $this, 'autoload' ) );
}

/**
* Autoloader
*
* @param $class
*/
protected function autoload( $class ) {
$classes = array();

// 4 directories deep, add more as needed
$directories = array( '', '*/', '*/*/', '*/*/*/', '*/*/*/*/' );

foreach ( $directories as $directory ) {
foreach ( glob( trailingslashit( __DIR__ ) . $directory . '*.php' ) as $file ) {
$base = __DIR__;
$class_dir = dirname( $file );
$class_dir = str_replace( $base, '', $class_dir );
$class_dir = ltrim( $class_dir, '/' );
$class_dir = str_replace( '/', '_', $class_dir );
$class_name = str_replace( '.php', '', basename( $file ) );
if ( ! empty( $class_dir ) ) {
$class_name = $class_dir . '_' . $class_name;
}
$classes[ strtolower( $class_name ) ] = $file;
}
}

$cn = strtolower( $class );

if ( isset( $classes[ $cn ] ) ) {
require_once( $classes[ $cn ] );
}
}
}

new Autoloader();
36 changes: 5 additions & 31 deletions includes/class-github-updater.php → includes/GitHub_Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,26 @@ class GitHub_Updater {
*/
protected static $options;

/**
* Autoloader
*
* @param $class
*/
protected function autoload( $class ) {
$classes = array(
'github_plugin_updater' => 'class-plugin-updater.php',
'github_theme_updater' => 'class-theme-updater.php',
'github_updater_github_api' => 'class-github-api.php',
'github_updater_bitbucket_api' => 'class-bitbucket-api.php',
'github_updater_settings' => 'class-github-updater-settings.php',
'parsedown' => 'Parsedown.php',
);

$cn = strtolower( $class );

if ( isset( $classes[ $cn ] ) ) {
require_once( $classes[ $cn ] );
}
}

/**
* Constructor
*
* Calls spl_autoload_register to set loading of classes.
* Loads options to private static variable.
*/
public function __construct() {
if ( function_exists( 'spl_autoload_register' ) ) {
spl_autoload_register( array( $this, 'autoload' ) );
}
self::$options = get_site_option( 'github_updater' );
$this->add_headers();
}

/**
* Instantiate GitHub_Plugin_Updater and GitHub_Theme_Updater
* Instantiate GitHub_Updater_Plugin and GitHub_Updater_Theme
* for proper user capabilities.
*/
public static function init() {
if ( current_user_can( 'update_plugins' ) ) {
new GitHub_Plugin_Updater;
new GitHub_Updater_Plugin;
}
if ( current_user_can( 'update_themes' ) ) {
new GitHub_Theme_Updater;
new GitHub_Updater_Theme;
}
if ( is_admin() && ( current_user_can( 'update_plugins' ) || current_user_can( 'update_themes' ) ) ) {
new GitHub_Updater_Settings;
Expand Down Expand Up @@ -400,7 +374,7 @@ protected function set_defaults( $type ) {
$this->$type->download_link = null;
$this->$type->tags = array();
$this->$type->rollback = array();
$this->$type->sections['changelog'] = 'No changelog is available via GitHub Updater. Create a file <code>CHANGES.md</code> or <code>CHANGELOG.md</code> in your repository.';
$this->$type->sections['changelog'] = __( 'No changelog is available via GitHub Updater. Create a file <code>CHANGES.md</code> or <code>CHANGELOG.md</code> in your repository.', 'github-updater' );
$this->$type->requires = null;
$this->$type->tested = null;
$this->$type->downloaded = 0;
Expand All @@ -415,7 +389,7 @@ protected function set_defaults( $type ) {
$this->$type->open_issues = 0;
$this->$type->score = 0;
$this->$type->requires_wp_version = '0.0.0';
$this->$type->requires_php_version = '5.2.4';
$this->$type->requires_php_version = '5.3';
}

/**
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
/**
* Update a WordPress plugin from a GitHub repo.
*
* @package GitHub_Plugin_Updater
* @package GitHub_Updater_Plugin
* @author Andy Fragen
* @author Codepress
* @link https://github.com/codepress/github-plugin-updater
*/
class GitHub_Plugin_Updater extends GitHub_Updater {
class GitHub_Updater_Plugin extends GitHub_Updater {

/**
* Constructor.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
/**
* Update a WordPress theme from a GitHub repo.
*
* @package GitHub_Theme_Updater
* @package GitHub_Updater_Theme
* @author Andy Fragen
* @author Seth Carstens
* @link https://github.com/WordPress-Phoenix/whitelabel-framework
* @author UCF Web Communications
* @link https://github.com/UCF/Theme-Updater
*/
class GitHub_Theme_Updater extends GitHub_Updater {
class GitHub_Updater_Theme extends GitHub_Updater {

/**
* Rollback variable
Expand Down
Binary file modified languages/github-updater-fr_FR.mo
Binary file not shown.
Loading

0 comments on commit 5009eda

Please sign in to comment.