refactor: remove plugin name constant
This commit is contained in:
parent
6fb2b20424
commit
51f3f92c26
7 changed files with 65 additions and 22 deletions
|
@ -86,7 +86,7 @@ class Footnotes_Admin {
|
||||||
*/
|
*/
|
||||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/layout/class-footnotes-layout-init.php';
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Footnotes_WYSIWYG {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function new_visual_editor_button( $p_arr_buttons ) {
|
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;
|
return $p_arr_buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class Footnotes_WYSIWYG {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function include_scripts( $p_arr_plugins ) {
|
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;
|
return $p_arr_plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,15 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-la
|
||||||
*/
|
*/
|
||||||
abstract class Footnotes_Layout_Engine {
|
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.
|
* Stores the Hook connection string for the child sub page.
|
||||||
*
|
*
|
||||||
|
@ -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 ) {
|
protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) {
|
||||||
return array(
|
return array(
|
||||||
'id' => Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_id,
|
'id' => $this->plugin_name . '-' . $p_str_id,
|
||||||
'title' => $p_str_title,
|
'title' => $p_str_title,
|
||||||
'submit' => $p_bool_has_submit_button,
|
'submit' => $p_bool_has_submit_button,
|
||||||
'container' => $p_int_settings_container_index,
|
'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 ) {
|
protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) {
|
||||||
return array(
|
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,
|
'id' => $p_str_id,
|
||||||
'title' => $p_str_title,
|
'title' => $p_str_title,
|
||||||
'callback' => $p_str_callback_function_name,
|
'callback' => $p_str_callback_function_name,
|
||||||
|
|
|
@ -15,6 +15,15 @@
|
||||||
*/
|
*/
|
||||||
class Footnotes_Layout_Init {
|
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.
|
* Slug for the Plugin main menu.
|
||||||
*
|
*
|
||||||
|
@ -35,11 +44,14 @@ class Footnotes_Layout_Init {
|
||||||
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
|
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @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->load_dependencies();
|
||||||
|
|
||||||
$this->settings_page = new Footnotes_Layout_Settings();
|
$this->settings_page = new Footnotes_Layout_Settings($this->plugin_name);
|
||||||
|
|
||||||
// Register hooks/actions.
|
// Register hooks/actions.
|
||||||
add_action( 'admin_menu', array( $this, 'register_options_submenu' ) );
|
add_action( 'admin_menu', array( $this, 'register_options_submenu' ) );
|
||||||
|
|
|
@ -50,6 +50,16 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'layout/class-footnotes-la
|
||||||
*/
|
*/
|
||||||
class Footnotes_Layout_Settings extends Footnotes_Layout_Engine {
|
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.
|
* Returns a Priority index. Lower numbers have a higher Priority.
|
||||||
*
|
*
|
||||||
|
@ -67,7 +77,7 @@ class Footnotes_Layout_Settings extends Footnotes_Layout_Engine {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_sub_page_slug() {
|
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.
|
// Localized notices are dropped to ease translators' task.
|
||||||
|
|
||||||
// "label-class-1" => ".footnote_plugin_tooltip_text",.
|
// "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",.
|
// "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",.
|
// "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",.
|
// "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
|
// phpcs:enable
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,14 +15,6 @@
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class Footnotes_Config {
|
class Footnotes_Config {
|
||||||
/**
|
|
||||||
* Internal Plugin name.
|
|
||||||
*
|
|
||||||
* @since 1.5.0
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
const C_STR_PLUGIN_NAME = 'footnotes';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Plugin name.
|
* Public Plugin name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,6 +17,26 @@ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'widget/class-footnotes-wi
|
||||||
*/
|
*/
|
||||||
class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base {
|
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.
|
* 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
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_name() {
|
protected function get_name() {
|
||||||
return Footnotes_Config::C_STR_PLUGIN_NAME;
|
return $this->plugin_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue