Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

final fixes + updates from GitHub repo directly #8

Merged
merged 4 commits into from

1 participant

@franz-josef-kaiser
Collaborator

If you're transferring the repo, I'll add another fix for the remote location.

Thanks for everything.

Btw: I sent you a bounty on WPSE.

@franz-josef-kaiser franz-josef-kaiser merged commit 88e0ec9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 60 additions and 81 deletions.
  1. +30 −0 changelog.html
  2. +0 −28 changelog.txt
  3. +9 −5 inc/admin.php
  4. +21 −48 plugin-dirs.php
View
30 changelog.html
@@ -0,0 +1,30 @@
+<h4>0.1</h4>
+Initial version.
+<h4>0.2</h4>
+Clean Up & code styling alignment.
+<h4>0.3</h4>
+Minor styling fixes.
+<h4>0.4</h4>
+Moved to OOP concept.
+<h4>0.5</h4>
+Improved API: now supports different plugin locations aside from the <code>WP_CONTENT_DIR</code>.
+<h4>0.5.1</h4>
+Minor fix for left over debug code.
+<h4>0.5.2</h4>
+JS styling for readability.
+<h4>0.6</h4>
+Removed <code>activate</code> link when plugin is already active, as suggested by <a href="https://github.com/chrisguitarguy/WP-Plugin-Directories/pull/3">Julien Chaumond in Issue #3</a>.
+<h4>0.7</h4>
+Added the <code>adp_root_{$root}</code> filter to allow completely custom locations. Moved changelog to separate file.
+<h4>0.7.1</h4>
+Fix script path for remote locations.
+<h4>0.7.2</h4>
+Renamed main plugin file to index.php to avoid accidental directory listing.
+<h4>0.7.3</h4>
+Reverted 0.7.2 to avoid plugin deactivation. Added <code>index.html</code> file instead.
+<h4>0.8</h4>
+Moved Bootstrap to OOP construct. Regular child plugins are now allowed to use the default priority.
+<h4>0.9</h4>
+Added better update message (as seen here).
+<h4>1.0</h4>
+Now updates from GitHub.
View
28 changelog.txt
@@ -1,28 +0,0 @@
-*0.1*
-Initial version.
-*0.2*
-Clean Up & code styling alignment.
-*0.3*
-Minor styling fixes.
-*0.4*
-Moved to OOP concept.
-*0.5*
-Improved API: now supports different plugin locations aside from the `WP_CONTENT_DIR`.
-*0.5.1*
-Minor fix for left over debug code.
-*0.5.2*
-JS styling for readability.
-*0.6*
-Removed "activate" link when plugin is already active, as suggested by Julien Chaumond in Issue #3.
-*0.7*
-Added the "adp_root_{$root}" filter to allow completely custom locations. Moved changelog to separate file.
-*0.7.1*
-Fix script path for remote locations.
-*0.7.2*
-Renamed main plugin file to index.php to avoid accidental directory listing.
-*0.7.3*
-Reverted 0.7.2 to avoid plugin deactivation. Added index.html file instead.
-*0.8*
-Moved Bootstrap to OOP construct. Regular child plugins are now allowed to use the default priority.
-*0.9*
-Added better update message (as seen here).
View
14 inc/admin.php
@@ -126,7 +126,11 @@ public function init()
// check to see if we're using one of our custom directories
if ( $this->get_plugin_status() )
{
- add_filter( "views_{$screen->id}", array( $this, 'views_again' ) );
+ // Disable default "advanced" plugins. Inside the callback,
+ // the 2nd arg is either for "Must Use" => 'mustuse' and for "DropIns" => 'dropins'.
+ add_filter( 'show_advanced_plugins', '__return_false', 10, 2 );
+
+ #add_filter( "views_{$screen->id}", array( $this, 'views_again' ) );
add_filter( 'all_plugins', array( $this, 'filter_plugins' ) );
// @TODO: support bulk actions
add_filter( "bulk_actions-{$screen->id}", '__return_empty_array' );
@@ -145,12 +149,12 @@ public function init()
*/
public function views( $views )
{
- global $wp_plugin_directories;
+ global $wp_plugin_directories, $totals;
// bail if we don't have any extra dirs
if ( empty( $wp_plugin_directories ) )
return $views;
-
+echo '<pre>'; print_r( $totals ); echo '</pre>';
// Add our directories to the action links
foreach ( $wp_plugin_directories as $key => $info )
{
@@ -183,7 +187,7 @@ public function views_again( $views )
{
if ( isset( $views['inactive'] ) )
unset( $views['inactive'] );
-
+echo '<pre> '.__LINE__.__FILE__.' '; print_r( $views ); echo '</pre>';
return $views;
}
@@ -405,7 +409,7 @@ public function handle_actions()
}
break;
- default:
+ default :
do_action( "custom_plugin_dir_{$action}" );
break;
}
View
69 plugin-dirs.php
@@ -1,7 +1,7 @@
<?php
! defined( 'ABSPATH' ) AND exit();
/*
-Plugin Name: Additional Plugin Directories 2
+Plugin Name: Additional Plugin Directories
Plugin URI: http://github.com/chrisguitarguy
Description: A framework to allow adding additional plugin directories to WordPress
Version: 1.0
@@ -112,13 +112,7 @@ class_exists( $class ) AND add_action( 'plugins_loaded', array( $class, 'instanc
// Updates from GitHub
// $ git submodule add git://github.com/franz-josef-kaiser/WordPress-GitHub-Plugin-Updater inc/updater
- add_action( 'admin_init', array( $this, 'update_from_github' ) );
-
- // Better update message
- $folder = basename( dirname( __FILE__ ) );
- $file = basename( __FILE__ );
- $hook = "in_plugin_update_message-{$folder}/{$file}";
- add_action( $hook, array( $this, 'update_message' ), 20, 2 );
+ add_action( 'init', array( $this, 'update_from_github' ), 0 );
}
@@ -130,9 +124,6 @@ class_exists( $class ) AND add_action( 'plugins_loaded', array( $class, 'instanc
*/
public function update_from_github()
{
- if ( 'plugins.php' !== $GLOBALS['pagenow'] )
- return;
-
global $wp_version;
// Load the updater
@@ -143,7 +134,7 @@ public function update_from_github()
$host = 'github.com';
$http = 'https://';
- $name = 'franz-josef-kaiser';
+ $name = 'chrisguitarguy';
$repo = 'WP-Plugin-Directories';
new wp_github_updater( array(
'slug' => plugin_basename( __FILE__ )
@@ -156,10 +147,21 @@ public function update_from_github()
,'requires' => $wp_version
,'tested' => $wp_version
,'readme_file' => 'readme.md'
+ ,'description' => array(
+ 'changelog' => $this->update_message()
+ )
) );
}
+ /**
+ * Callback to set the SSL verification for HTTP requests to GitHub to false
+ *
+ * @since 1.0
+ * @param array $args
+ * @param string $url
+ * @return array $args
+ */
public function update_request_args( $args, $url )
{
// Only needed once - this saves us checking the $url
@@ -176,51 +178,22 @@ public function update_request_args( $args, $url )
* Shows only the version updates from the current until the newest version
*
* @uses WordPress HTTP API
+ * @uses $allowed_html and $allowed_protocolls inside `install_plugin_information()`
*
* @since 0.9
- * @param array $plugin_data Data of the plugin itself
- * @param object $r Data of the remote request to the repo
* @return string The actual Output message
*/
- public function update_message( $plugin_data, $r )
+ public function update_message()
{
- if ( 'plugins.php' !== $GLOBALS['pagenow'] )
- return;
-
// Get `changelog.txt` from GitHub via WP HTTP API
- $changelog = wp_remote_get(
- $this->remote_changelog
- ,array(
- // We can't force anyone to alter the `~/.ssh/config` on the server
- 'sslverify' => false
- )
- );
-
+ $changelog = wp_remote_get( $this->remote_changelog );
// Die silently
if ( is_wp_error( $changelog ) )
- return;
-
- // Only retrieve what's new since the installed version
- $details = explode(
- '*'
- ,stristr(
- $changelog['body']
- ,"*{$plugin_data['Version']}*"
- )
- );
- // Build the update note
- $whats_new = '';
- for ( $i = 0; $i < count( $details ); $i++ )
- {
- $whats_new .= ( 0 != $i % 2 ) ? "<strong>{$details[ $i ]}" : "</strong><br />{$details[ $i ]}";
- }
+ return _e( 'No changelog could get fetched.', 'cd_apd_textdomain' );
- return printf(
- "%sThe Update from %s to %s brings you the following new features, bug fixes and additions.%s"
- ,'<hr />'
- ,"<code>{$plugin_data['Version']}</code>"
- ,"<code>{$r->new_version}</code>"
- ,"<p style='font-weight:normal;'>{$whats_new}</p>"
+ return sprintf(
+ "<p style='font-weight:normal;'>%s</p>"
+ ,wp_remote_retrieve_body( $changelog )
);
}
} // END Class CD_APD_Bootstrap
Something went wrong with that request. Please try again.