refactor: remove Hungarian notation and MCI prefixes

I had to use some RegEx-fu for this. Specifically:

```bash
find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/\(p\|l\|a\)_\(str\|bool\|int\|obj\|flo\|arr\)_//g' {} \;
find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/MCI_Footnotes/Footnotes/g' {} \;
find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/C_\(INT\|STR\|FLO\)_//g' {} \;
```

This should have covered all the bases.

In my testing I encountered one error caused by these changes.
In the `add_select_box` function in `/class/dashboard/layout.php`,
there was a function parameter called `$p_arr_options` and a variable
called `$l_str_options`. Removing the Hungarian notation caused an
error as these two variables were both now called `$options`.

This has been fixed, and I like to think that that will have been
the only naming conflict, but I think it is more likely that there
maybe others. Further testing is required before I am happy calling
this release-ready.

Close #34, progress #36
This commit is contained in:
Ben Goldsworthy 2021-04-16 23:55:05 +01:00
parent df7160fad8
commit 1284544556
15 changed files with 1710 additions and 1710 deletions

View file

@ -12,7 +12,7 @@
*
* @since 1.5.0
*/
class MCI_Footnotes_WYSIWYG {
class Footnotes_WYSIWYG {
/**
* Registers Button hooks.
@ -28,16 +28,16 @@ class MCI_Footnotes_WYSIWYG {
* @return void
*/
public static function register_hooks() {
add_filter( 'mce_buttons', array( 'MCI_Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
add_action( 'admin_print_footer_scripts', array( 'MCI_Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
add_filter( 'mce_buttons', array( 'Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
add_action( 'admin_print_footer_scripts', array( 'Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
add_filter( 'mce_external_plugins', array( 'MCI_Footnotes_WYSIWYG', 'include_scripts' ) );
add_filter( 'mce_external_plugins', array( 'Footnotes_WYSIWYG', 'include_scripts' ) );
// phpcs:disable
// 'footnotes_getTags' must match its instance in wysiwyg-editor.js.
// 'footnotes_getTags' must match its instance in editor-button.html.
add_action( 'wp_ajax_nopriv_footnotes_getTags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
add_action( 'wp_ajax_footnotes_getTags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
add_action( 'wp_ajax_nopriv_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
add_action( 'wp_ajax_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
// phpcs:enable
}
@ -46,12 +46,12 @@ class MCI_Footnotes_WYSIWYG {
* Append a new Button to the WYSIWYG editor of Posts and Pages.
*
* @since 1.5.0
* @param array $p_arr_buttons pre defined Buttons from WordPress.
* @param array $buttons pre defined Buttons from WordPress.
* @return array
*/
public static function new_visual_editor_button( $p_arr_buttons ) {
array_push( $p_arr_buttons, MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
return $p_arr_buttons;
public static function new_visual_editor_button( $buttons ) {
array_push( $buttons, Footnotes_Config::PLUGIN_NAME );
return $buttons;
}
/**
@ -60,9 +60,9 @@ class MCI_Footnotes_WYSIWYG {
* @since 1.5.0
*/
public static function new_plain_text_editor_button() {
$l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'editor-button' );
$template = new Footnotes_Template( Footnotes_Template::DASHBOARD, 'editor-button' );
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $l_obj_template->get_content();
echo $template->get_content();
// phpcs:enable
}
@ -70,12 +70,12 @@ class MCI_Footnotes_WYSIWYG {
* Includes the Plugins WYSIWYG editor script.
*
* @since 1.5.0
* @param array $p_arr_plugins Scripts to be included to the editor.
* @param array $plugins Scripts to be included to the editor.
* @return array
*/
public static function include_scripts( $p_arr_plugins ) {
$p_arr_plugins[ MCI_Footnotes_Config::C_STR_PLUGIN_NAME ] = plugins_url( '/../js/wysiwyg-editor.js', __FILE__ );
return $p_arr_plugins;
public static function include_scripts( $plugins ) {
$plugins[ Footnotes_Config::PLUGIN_NAME ] = plugins_url( '/../js/wysiwyg-editor.js', __FILE__ );
return $plugins;
}
/**
@ -86,16 +86,16 @@ class MCI_Footnotes_WYSIWYG {
*/
public static function ajax_callback() {
// Get start and end tag for the footnotes short code.
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END );
if ( 'userdefined' === $l_str_starting_tag || 'userdefined' === $l_str_ending_tag ) {
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
$starting_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_START );
$ending_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_END );
if ( 'userdefined' === $starting_tag || 'userdefined' === $ending_tag ) {
$starting_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
$ending_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
}
echo json_encode(
array(
'start' => htmlspecialchars( $l_str_starting_tag ),
'end' => htmlspecialchars( $l_str_ending_tag ),
'start' => htmlspecialchars( $starting_tag ),
'end' => htmlspecialchars( $ending_tag ),
)
);
exit;