This repository has been archived by the owner on Apr 21, 2020. It is now read-only.
OOP, extended API, example plugin #6
Merged
chrisguitarguy
merged 4 commits into
chrisguitarguy:master
from
franz-josef-kaiser:master
Jun 28, 2012
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
! defined( 'ABSPATH' ) AND exit(); | ||
/* | ||
Plugin Name: Additional Plugin Directories: Example Plugin | ||
Plugin URI: http://github.com/chrisguitarguy | ||
Description: Example Plugin to show how to register additional plugin directories | ||
Version: 0.1 | ||
Author: Franz Josef Kaiser | ||
Author URI: http://unserkaiser.com | ||
License: MIT | ||
*/ | ||
|
||
|
||
/** | ||
* Registers a new plugin directory | ||
* | ||
* @example | ||
* $args Array (Valid args for `root`) 'content', 'plugins', 'muplugins', 'root' | ||
* The new directories must be subdirectories of the following WP file system constants: | ||
* 'content': (default) WP_CONTENT_DIR | ||
* 'plugins': WP_PLUGIN_DIR | ||
* 'muplugins': WPMU_PLUGIN_DIR | ||
* 'root': one level below WP_CONTENT_DIR | ||
* | ||
* @return void | ||
*/ | ||
function cd_apd_register_additional_plugin_directories() | ||
{ | ||
// Better abort - if we don't do this, we'll create an error on deactivation of the main plugin. | ||
if ( ! function_exists( 'register_plugin_directory' ) ) | ||
return; | ||
|
||
// Call the public API function once for every directory you want to add. | ||
register_plugin_directory( array( | ||
'dir' => 'example_plugin_directory' | ||
,'label' => 'Example Label for the list table' | ||
,'root' => 'plugins' | ||
) ); | ||
} | ||
// Needs to be added on the `plugins_loaded` hook with a priority of `0`. | ||
add_action( 'plugins_loaded', 'cd_apd_register_additional_plugin_directories', 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooking the main class into
plugins_loaded
on priority 10. This will allow people better control via hooks. It also makes sure, the newstatic $instance
only runs once.