refactor: clean up internal dependency management

This commit is contained in:
Ben Goldsworthy 2021-04-27 08:33:28 +01:00
parent af14415067
commit 5de6719b9a
7 changed files with 38 additions and 11 deletions

View file

@ -8,10 +8,6 @@
* @subpackage footnotes/admin
*/
require_once dirname( __FILE__, 2 ) . '/includes/class-footnotes-config.php';
require_once dirname( __FILE__, 2 ) . '/includes/class-footnotes-settings.php';
require_once dirname( __FILE__, 2 ) . '/includes/class-footnotes-template.php';
/**
* Handles the WSYIWYG-Buttons.
*

View file

@ -14,7 +14,7 @@
* @since 2.5.5 Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report.
*/
require_once dirname( __FILE__ ) . '/class-footnotes-layout-init.php';
require_once plugin_dir_path( dirname( __FILE__ ) ). 'layout/class-footnotes-layout-init.php';
/**
* Layout Engine for the administration dashboard.

View file

@ -8,9 +8,6 @@
* @subpackage footnotes/admin
*/
require_once dirname( __FILE__, 3 ) . '/includes/class-footnotes-settings.php';
require_once dirname( __FILE__ ) . '/class-footnotes-layout-settings.php';
/**
* Handles the Settings interface of the Plugin.
*
@ -40,6 +37,8 @@ class Footnotes_Layout_Init {
* @since 1.5.0
*/
public function __construct() {
$this->load_dependencies();
$this->settings_page = new Footnotes_Layout_Settings();
// Register hooks/actions.
@ -49,6 +48,37 @@ class Footnotes_Layout_Init {
add_action( 'wp_ajax_nopriv_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) );
add_action( 'wp_ajax_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) );
}
/**
* Load the required dependencies for this plugin.
*
* Include the following files that make up the plugin:
*
* - `Footnotes_Config`. Defines constant plugin values.
* - `Footnotes_Settings`. Defines configurable plugin settings.
* - `Footnotes_Layout_Settings`. Defines the plugin settings page.
*
* Create an instance of the loader which will be used to register the hooks
* with WordPress.
*
* @since 2.8.0
* @access private
*/
private function load_dependencies() {
/**
* The class responsible for defining plugin constants.
*/
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-footnotes-config.php';
/**
* The class responsible for tracking configurable plugin settings.
*/
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-footnotes-settings.php';
/**
* The class responsible for defining the plugin settings page.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-layout-settings.php';
}
/**
* Registers the settings and initialises the settings page.

View file

@ -41,7 +41,7 @@
* @subpackage footnotes/admin/layout
*/
require_once dirname( __FILE__ ) . '/class-footnotes-layout-engine.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-layout-engine.php';
/**
* Displays and handles all Settings of the Plugin.

View file

@ -12,7 +12,7 @@
* @subpackage footnotes/includes
*/
require_once dirname( __FILE__ ) . '/class-footnotes-config.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-config.php';
/**
* Define the internationalization functionality.

View file

@ -14,7 +14,7 @@
* @subpackage footnotes/includes
*/
require_once dirname( __FILE__ ) . '/class-footnotes-convert.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-convert.php';
/**
* Loads the settings values, sets to default values if undefined.

View file

@ -117,6 +117,7 @@ class Footnotes {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-config.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-convert.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-settings.php';
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-template.php';
/**
* The class responsible for defining all actions that occur in the admin area.