This repository has been archived by the owner on Apr 21, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from franz-josef-kaiser/master
OOP, extended API, example plugin
- Loading branch information
Showing
7 changed files
with
568 additions
and
241 deletions.
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.