Last active
October 7, 2020 17:24
-
-
Save corypina/b9e04efc5166ffafe67f6650fda3deb2 to your computer and use it in GitHub Desktop.
A jumpstart for new WordPress plugins
This file contains hidden or 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
<?php | |
/* | |
Plugin Name: [Your Great Plugin Name Goes Here] | |
Description: [Along with a Great Description] | |
Version: 0.1 | |
Author: Cory Piña | |
Author URI: http://thisiscory.com | |
*/ | |
// HOW TO USE THIS | |
// Any file in a folder will automatically be included in the plugin code. | |
// Folders and files can be excluded by add an underscore ('_') before | |
// the file or folder's name. | |
// EXAMPLES | |
// The directory 'library' will be included. | |
// The directory '_library' will NOT be included. | |
// The file 'library/template.php' will be included. | |
// The file 'library/_template.php' will NOT be included. | |
// The file '_library/template.php' will NOT be included. | |
if (!defined('ABSPATH')) { exit; } | |
// Global Config | |
// Call config properites with $config->key | |
$config = (object) array( | |
'key' => 'value', | |
); | |
// Get the directory of this plugin | |
$dir = plugin_dir_path(__FILE__); | |
// Get the list of folders | |
// and include all PHP files | |
$folders = array_filter(glob("{$dir}[!_]*"), 'is_dir'); | |
if ( !empty( $folders ) ) : | |
foreach ( $folders as $f ) : | |
foreach ( glob( "{$f}/[!_]*.php" ) as $file ) : | |
include $file; | |
endforeach; | |
endforeach; | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment