Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first attempt to update from github repo

  • Loading branch information...
commit a96936fe2728537fc6fe13b402ce1dbd273f60f5 1 parent d593621
Kaiser authored June 29, 2012
4  .gitmodules
... ...
@@ -0,0 +1,4 @@
  1
+
  2
+[submodule "inc/updater"]
  3
+	path = inc/updater
  4
+	url = git://github.com/franz-josef-kaiser/WordPress-GitHub-Plugin-Updater.git
1  inc/updater
... ...
@@ -0,0 +1 @@
  1
+Subproject commit e18b83d4d2817bc8f8ba4df5e3c8142b8f4d4f2e
60  plugin-dirs.php
... ...
@@ -1,10 +1,10 @@
1 1
 <?php
2 2
 ! defined( 'ABSPATH' ) AND exit();
3 3
 /*
4  
-Plugin Name:  Additional Plugin Directories
  4
+Plugin Name:  Additional Plugin Directories 2
5 5
 Plugin URI:   http://github.com/chrisguitarguy
6 6
 Description:  A framework to allow adding additional plugin directories to WordPress
7  
-Version:      0.9
  7
+Version:      1.0
8 8
 Author:       Christopher Davis
9 9
 Contributors: Franz Josef Kaiser, Julien Chaumond
10 10
 Author URI:   http://christopherdavis.me
@@ -107,6 +107,13 @@ public function __construct()
107 107
 			class_exists( $class ) AND add_action( 'plugins_loaded', array( $class, 'instance' ) );
108 108
 		}
109 109
 
  110
+		if ( ! is_admin() )
  111
+			return;
  112
+
  113
+		// Updates from GitHub
  114
+		// $ git submodule add git://github.com/franz-josef-kaiser/WordPress-GitHub-Plugin-Updater inc/updater
  115
+		add_action( 'admin_init', array( $this, 'update_from_github' ) );
  116
+
110 117
 		// Better update message
111 118
 		$folder	= basename( dirname( __FILE__ ) );
112 119
 		$file	= basename( __FILE__ );
@@ -116,6 +123,55 @@ class_exists( $class ) AND add_action( 'plugins_loaded', array( $class, 'instanc
116 123
 
117 124
 
118 125
 	/**
  126
+	 * 
  127
+	 * @since 1.0
  128
+	 * 
  129
+	 * @return void
  130
+	 */
  131
+	public function update_from_github()
  132
+	{
  133
+		if ( 'plugins.php' !== $GLOBALS['pagenow'] )
  134
+			return;
  135
+
  136
+		global $wp_version;
  137
+
  138
+		// Load the updater
  139
+		include_once plugin_dir_path( __FILE__ ).'inc/updater/updater.php';
  140
+
  141
+		// Fix this strange WP bug(?)
  142
+		add_action( 'http_request_args', array( $this, 'update_request_args' ), 0, 2 );
  143
+
  144
+		$host	= 'github.com';
  145
+		$http	= 'https://';
  146
+		$name	= 'franz-josef-kaiser';
  147
+		$repo	= 'WP-Plugin-Directories';
  148
+		new wp_github_updater( array(
  149
+			 'slug'               => plugin_basename( __FILE__ )
  150
+			,'proper_folder_name' => dirname( plugin_basename(__FILE__) ) #plugin_basename( __FILE__ )
  151
+			,'api_url'            => "{$http}api.{$host}/repos/{$name}/{$repo}"
  152
+			,'raw_url'            => "{$http}raw.{$host}/{$name}/{$repo}/master"
  153
+			,'github_url'         => "{$http}{$host}/{$name}/{$repo}"
  154
+			,'zip_url'            => "{$http}{$host}/{$name}/{$repo}/zipball/master"
  155
+			,'sslverify'          => true
  156
+			,'requires'           => $wp_version
  157
+			,'tested'             => $wp_version
  158
+			,'readme_file'        => 'readme.md'
  159
+		) );
  160
+	}
  161
+
  162
+
  163
+	public function update_request_args( $args, $url )
  164
+	{
  165
+		// Only needed once - this saves us checking the $url
  166
+		remove_filter( current_filter(), __FUNCTION__ );
  167
+
  168
+		return array_merge( $args, array(
  169
+			'sslverify' => false
  170
+		) );
  171
+	}
  172
+
  173
+
  174
+	/**
119 175
 	 * Displays an update message for plugin list screens.
120 176
 	 * Shows only the version updates from the current until the newest version
121 177
 	 * 

0 notes on commit a96936f

Please sign in to comment.
Something went wrong with that request. Please try again.