diff --git a/src/admin/class-footnotes-admin.php b/src/admin/class-footnotes-admin.php index 174c1e3..b6a62a7 100644 --- a/src/admin/class-footnotes-admin.php +++ b/src/admin/class-footnotes-admin.php @@ -86,7 +86,7 @@ class Footnotes_Admin { */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/layout/class-footnotes-layout-init.php'; - new Footnotes_Layout_Init(); + new Footnotes_Layout_Init($this->plugin_name); } /** diff --git a/src/admin/class-footnotes-wysiwyg.php b/src/admin/class-footnotes-wysiwyg.php index 0907759..6c9d2a7 100644 --- a/src/admin/class-footnotes-wysiwyg.php +++ b/src/admin/class-footnotes-wysiwyg.php @@ -44,7 +44,7 @@ class Footnotes_WYSIWYG { * @return array */ public static function new_visual_editor_button( $p_arr_buttons ) { - array_push( $p_arr_buttons, Footnotes_Config::C_STR_PLUGIN_NAME ); + array_push( $p_arr_buttons, $this->plugin_name ); return $p_arr_buttons; } @@ -68,7 +68,7 @@ class Footnotes_WYSIWYG { * @return array */ public static function include_scripts( $p_arr_plugins ) { - $p_arr_plugins[ Footnotes_Config::C_STR_PLUGIN_NAME ] = plugins_url( '/../admin/js/wysiwyg-editor' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.js', __FILE__ ); + $p_arr_plugins[ $this->plugin_name ] = plugins_url( '/../admin/js/wysiwyg-editor' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.js', __FILE__ ); return $p_arr_plugins; } diff --git a/src/admin/layout/class-footnotes-layout-engine.php b/src/admin/layout/class-footnotes-layout-engine.php index 07a3c59..df09682 100644 --- a/src/admin/layout/class-footnotes-layout-engine.php +++ b/src/admin/layout/class-footnotes-layout-engine.php @@ -23,6 +23,15 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-la */ abstract class Footnotes_Layout_Engine { + /** + * The ID of this plugin. + * + * @since 2.8.0 + * @access private + * @var string $plugin_name The ID of this plugin. + */ + protected $plugin_name; + /** * Stores the Hook connection string for the child sub page. * @@ -78,7 +87,7 @@ abstract class Footnotes_Layout_Engine { * @return array */ abstract protected function get_meta_boxes(); - + /** * Returns an array describing a sub page section. * @@ -91,7 +100,7 @@ abstract class Footnotes_Layout_Engine { */ protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) { return array( - 'id' => Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_id, + 'id' => $this->plugin_name . '-' . $p_str_id, 'title' => $p_str_title, 'submit' => $p_bool_has_submit_button, 'container' => $p_int_settings_container_index, @@ -110,7 +119,7 @@ abstract class Footnotes_Layout_Engine { */ protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) { return array( - 'parent' => Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_section_id, + 'parent' => $this->plugin_name . '-' . $p_str_section_id, 'id' => $p_str_id, 'title' => $p_str_title, 'callback' => $p_str_callback_function_name, diff --git a/src/admin/layout/class-footnotes-layout-init.php b/src/admin/layout/class-footnotes-layout-init.php index 3dca904..760f5ad 100644 --- a/src/admin/layout/class-footnotes-layout-init.php +++ b/src/admin/layout/class-footnotes-layout-init.php @@ -15,6 +15,15 @@ */ class Footnotes_Layout_Init { + /** + * The ID of this plugin. + * + * @since 2.8.0 + * @access private + * @var string $plugin_name The ID of this plugin. + */ + private $plugin_name; + /** * Slug for the Plugin main menu. * @@ -35,11 +44,14 @@ class Footnotes_Layout_Init { * Class Constructor. Initializes all WordPress hooks for the Plugin Settings. * * @since 1.5.0 + * @since 2.8.0 Added `$plugin_name` parameter. */ - public function __construct() { + public function __construct( $plugin_name ) { + $this->plugin_name = $plugin_name; + $this->load_dependencies(); - $this->settings_page = new Footnotes_Layout_Settings(); + $this->settings_page = new Footnotes_Layout_Settings($this->plugin_name); // Register hooks/actions. add_action( 'admin_menu', array( $this, 'register_options_submenu' ) ); diff --git a/src/admin/layout/class-footnotes-layout-settings.php b/src/admin/layout/class-footnotes-layout-settings.php index 6cc4ce3..cc03c01 100644 --- a/src/admin/layout/class-footnotes-layout-settings.php +++ b/src/admin/layout/class-footnotes-layout-settings.php @@ -49,6 +49,16 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-la * @since 1.5.0 */ class Footnotes_Layout_Settings extends Footnotes_Layout_Engine { + + /** + * Initialize the class and set its properties. + * + * @since 2.8.0 + * @param string $plugin_name The name of this plugin. + */ + public function __construct( $plugin_name ) { + $this->plugin_name = $plugin_name; + } /** * Returns a Priority index. Lower numbers have a higher Priority. @@ -67,7 +77,7 @@ class Footnotes_Layout_Settings extends Footnotes_Layout_Engine { * @return string */ protected function get_sub_page_slug() { - return '-' . Footnotes_Config::C_STR_PLUGIN_NAME; + return '-' . $this->plugin_name; } /** @@ -1160,16 +1170,16 @@ class Footnotes_Layout_Settings extends Footnotes_Layout_Engine { // Localized notices are dropped to ease translators' task. // "label-class-1" => ".footnote_plugin_tooltip_text",. - // "class-1" => $this->add_text(__("superscript, Footnotes index", Footnotes_Config::C_STR_PLUGIN_NAME)),. + // "class-1" => $this->add_text(__("superscript, Footnotes index", $this->plugin_name)),. // "label-class-2" => ".footnote_tooltip",. - // "class-2" => $this->add_text(__("mouse-over box, tooltip for each superscript", Footnotes_Config::C_STR_PLUGIN_NAME)),. + // "class-2" => $this->add_text(__("mouse-over box, tooltip for each superscript", $this->plugin_name)),. // "label-class-3" => ".footnote_plugin_index",. - // "class-3" => $this->add_text(__("1st column of the Reference Container, Footnotes index", Footnotes_Config::C_STR_PLUGIN_NAME)),. + // "class-3" => $this->add_text(__("1st column of the Reference Container, Footnotes index", $this->plugin_name)),. // "label-class-4" => ".footnote_plugin_text",. - // "class-4" => $this->add_text(__("2nd column of the Reference Container, Footnote text", Footnotes_Config::C_STR_PLUGIN_NAME)). + // "class-4" => $this->add_text(__("2nd column of the Reference Container, Footnote text", $this->plugin_name)). // phpcs:enable ) ); diff --git a/src/includes/class-footnotes-config.php b/src/includes/class-footnotes-config.php index 2440fa8..c37a1dd 100644 --- a/src/includes/class-footnotes-config.php +++ b/src/includes/class-footnotes-config.php @@ -15,14 +15,6 @@ * @since 1.5.0 */ class Footnotes_Config { - /** - * Internal Plugin name. - * - * @since 1.5.0 - * @var string - */ - const C_STR_PLUGIN_NAME = 'footnotes'; - /** * Public Plugin name. * diff --git a/src/public/widget/class-footnotes-widget-reference-container.php b/src/public/widget/class-footnotes-widget-reference-container.php index f12a181..bb33473 100644 --- a/src/public/widget/class-footnotes-widget-reference-container.php +++ b/src/public/widget/class-footnotes-widget-reference-container.php @@ -17,6 +17,26 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'widget/class-footnotes-wi */ class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base { + /** + * The ID of this plugin. + * + * @since 2.8.0 + * @access private + * @var string $plugin_name The ID of this plugin. + */ + private $plugin_name; + + /** + * Initialize the class and set its properties. + * + * @since 2.8.0 + * @param string $plugin_name The name of this plugin. + */ + public function __construct( $plugin_name ) { + parent::__construct(); + $this->plugin_name = $plugin_name; + } + /** * Returns an unique ID as string used for the Widget Base ID. * @@ -34,7 +54,7 @@ class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base { * @return string */ protected function get_name() { - return Footnotes_Config::C_STR_PLUGIN_NAME; + return $this->plugin_name; } /**