Skip to content
This repository has been archived by the owner on Apr 21, 2020. It is now read-only.

final fixes + updates from GitHub repo directly #8

Merged
merged 4 commits into from
Jul 3, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions changelog.html
Original file line number Diff line number Diff line change
@@ -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.
28 changes: 0 additions & 28 deletions changelog.txt

This file was deleted.

14 changes: 9 additions & 5 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -405,7 +409,7 @@ public function handle_actions()
}
break;

default:
default :
do_action( "custom_plugin_dir_{$action}" );
break;
}
Expand Down
69 changes: 21 additions & 48 deletions plugin-dirs.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 );
}


Expand All @@ -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
Expand All @@ -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__ )
Expand All @@ -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
Expand All @@ -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
Expand Down