Moved admin files to their own directory, trying to get a comprehensive structure in place

This commit is contained in:
Brian 2021-10-06 09:50:36 -06:00
parent 753aafe24d
commit bd6e3f2d60
Signed by: brian
GPG Key ID: DE1A5390A3B84CD8
7 changed files with 63 additions and 9 deletions

View File

@ -6,7 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Settings {
class AdminSettings {
/**
* Class constructor.
@ -93,4 +93,4 @@ class Settings {
}
new Settings();
new AdminSettings();

17
admin/class-install.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace PluginNamespace;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Install {
private static $db_updates = array(
'1.1.0' => array(
'dh_update_110_options',
),
);
}

View File

@ -0,0 +1,18 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Update something in the database
*
* @since 1.1.0
*
* @return void
*/
function dh_update_110_options() {
global $wpdb;
// do the thing here to update the database
}

View File

@ -26,9 +26,11 @@
},
"autoload": {
"psr-4": {
"PluginNamespace\\Admin\\": "admin/",
"PluginNamespace\\": "includes/"
},
"classmap": [
"admin/",
"includes/"
]
},

View File

@ -11,6 +11,12 @@ if ( ! defined( 'ABSPATH' ) ) {
class App {
/** @var string */
public $version = '1.0.0';
/** @var string */
public $db_version = '1.0.0';
/** @var \PluginNamespace\App */
public static $instance;
@ -36,7 +42,7 @@ class App {
* @return void
*/
public static function plugin_deactivation(): void {
//
error_log( 'Deactivation hook invoked.' );
}
/**
@ -106,8 +112,10 @@ class App {
* @return void
*/
public function scaffold_plugin(): void {
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
}
}
/**
* Setting up the WordPress dashboard menu for this plugin.
@ -143,7 +151,7 @@ class App {
public function includes(): void {
// Files to include on the admin.
if ( is_admin() ) {
require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-settings.php';
require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-adminsettings.php';
}
//

View File

@ -20,7 +20,7 @@ use eftec\bladeone\BladeOne;
* Update URI: https://example.com/my-plugin/
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Requires PHP: 7.3.0
* Author: Plugin Author
* Author URI: https://plugin-author.com
* Text Domain: nmsp-plugin-name-text-domain
@ -37,9 +37,14 @@ if ( ! defined( 'ABSPATH' ) ) {
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
if ( ! defined( 'PLUGIN_NAME_VERSION' ) ) {
define( 'PLUGIN_NAME_VERSION', '1.0.0' );
}
if ( ! defined('NMSP_PLUGIN_BASE_DIR') ) {
define( 'NMSP_PLUGIN_BASE_DIR', __DIR__ );
}
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/bootstrap.php';
@ -54,5 +59,6 @@ $blade = new BladeOne( __DIR__ . '/templates', __DIR__ . '/cache/blade', $mode )
register_activation_hook( __FILE__, array( App::class, 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( App::class, 'plugin_deactivation' ) );
register_uninstall_hook( __DIR__ . '/uninstall.php', 'run_uninstaller' );
nmsp_plugin_app()->load_blade( $blade );

View File

@ -9,4 +9,7 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
function run_uninstaller() {
// Put logic here to undo things when this plugin is uninstalled.
error_log( 'Uninstall hook activated for plugin at ' . __DIR__ );
}