From 667d8dada93cfb5ef72921b0c513049bc8739b7f Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Sun, 2 May 2021 21:04:31 +0100 Subject: [PATCH] refactor: run Rector `NAMING` setlist --- src/admin/layout/class-init.php | 10 +++++----- src/admin/layout/class-settings.php | 6 +++--- src/includes/class-core.php | 30 ++++++++++++++--------------- src/includes/class-loader.php | 8 ++++---- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/admin/layout/class-init.php b/src/admin/layout/class-init.php index ae41125..4649583 100644 --- a/src/admin/layout/class-init.php +++ b/src/admin/layout/class-init.php @@ -43,7 +43,7 @@ class Init { * * @since 1.5.0 */ - private Settings $settings_page; + private Settings $settings; /** * Initializes all WordPress hooks for the Plugin Settings. @@ -64,7 +64,7 @@ class Init { ) { $this->load_dependencies(); - $this->settings_page = new Settings( $this->plugin_name ); + $this->settings = new Settings( $this->plugin_name ); // Register hooks/actions. add_action( @@ -123,7 +123,7 @@ class Init { */ public function initialize_settings(): void { Includes\Settings::instance()->register_settings(); - $this->settings_page->register_sections(); + $this->settings->register_sections(); } /** @@ -139,9 +139,9 @@ class Init { \footnotes\includes\Config::PLUGIN_PUBLIC_NAME, 'manage_options', self::MAIN_MENU_SLUG, - fn() => $this->settings_page->display_content() + fn() => $this->settings->display_content() ); - $this->settings_page->register_sub_page(); + $this->settings->register_sub_page(); } // phpcs:disable WordPress.Security.NonceVerification.Missing diff --git a/src/admin/layout/class-settings.php b/src/admin/layout/class-settings.php index b5dc4ce..1db528b 100644 --- a/src/admin/layout/class-settings.php +++ b/src/admin/layout/class-settings.php @@ -1231,7 +1231,7 @@ class Settings extends Engine { * @todo Review in light of admin/public split. */ public function help(): void { - $footnotes = new General\General( $this->plugin_name, 'foo' ); + $general = new General\General( $this->plugin_name, 'foo' ); // Load footnotes starting and end tag. $footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START ); @@ -1268,7 +1268,7 @@ class Settings extends Engine { 'end' => $footnote_ending_tag['value'], 'example-code' => $example, 'example-string' => '
' . __( 'will be displayed as:', 'footnotes' ), - 'example' => $footnotes->task->exec( $example, true ), + 'example' => $general->task->exec( $example, true ), // Translators: %1$s, %2$s: anchor element with hyperlink to the Support Forum. 'information' => sprintf( __( 'For further information please check out our %1$sSupport Forum%2$s on WordPress.org.', 'footnotes' ), '', '' ), ) @@ -1282,7 +1282,7 @@ class Settings extends Engine { * the name of the filtered function. * When this callback function was renamed, this call went unnoticed. */ - $footnotes->task->footnotes_output_head(); + $general->task->footnotes_output_head(); // Display template with replaced placeholders. // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped diff --git a/src/includes/class-core.php b/src/includes/class-core.php index b9b230c..e5b0a2b 100644 --- a/src/includes/class-core.php +++ b/src/includes/class-core.php @@ -168,9 +168,9 @@ class Core { */ private function set_locale() { - $plugin_i18n = new i18n(); + $i18n = new i18n(); - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); + $this->loader->add_action( 'plugins_loaded', $i18n, 'load_plugin_textdomain' ); } @@ -186,23 +186,23 @@ class Core { */ private function define_admin_hooks() { - $plugin_admin = new Admin\Admin( $this->get_plugin_name(), $this->get_version() ); + $admin = new Admin\Admin( $this->get_plugin_name(), $this->get_version() ); - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); + $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_styles' ); + $this->loader->add_action( 'admin_enqueue_scripts', $admin, 'enqueue_scripts' ); - $this->loader->add_filter( 'plugin_action_links_footnotes/footnotes.php', $plugin_admin, 'action_links' ); + $this->loader->add_filter( 'plugin_action_links_footnotes/footnotes.php', $admin, 'action_links' ); - $this->loader->add_filter( 'mce_buttons', $plugin_admin->wysiwyg, 'new_visual_editor_button' ); - $this->loader->add_action( 'admin_print_footer_scripts', $plugin_admin->wysiwyg, 'new_plain_text_editor_button' ); + $this->loader->add_filter( 'mce_buttons', $admin->wysiwyg, 'new_visual_editor_button' ); + $this->loader->add_action( 'admin_print_footer_scripts', $admin->wysiwyg, 'new_plain_text_editor_button' ); - $this->loader->add_filter( 'mce_external_plugins', $plugin_admin->wysiwyg, 'include_scripts' ); + $this->loader->add_filter( 'mce_external_plugins', $admin->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. - $this->loader->add_action( 'wp_ajax_nopriv_footnotes_getTags', $plugin_admin->wysiwyg, 'ajax_callback' ); - $this->loader->add_action( 'wp_ajax_footnotes_getTags', $plugin_admin->wysiwyg, 'ajax_callback' ); + $this->loader->add_action( 'wp_ajax_nopriv_footnotes_getTags', $admin->wysiwyg, 'ajax_callback' ); + $this->loader->add_action( 'wp_ajax_footnotes_getTags', $admin->wysiwyg, 'ajax_callback' ); // phpcs:enable } @@ -217,12 +217,12 @@ class Core { */ private function define_public_hooks() { - $plugin_public = new General\General( $this->get_plugin_name(), $this->get_version() ); + $general = new General\General( $this->get_plugin_name(), $this->get_version() ); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); + $this->loader->add_action( 'wp_enqueue_scripts', $general, 'enqueue_styles' ); + $this->loader->add_action( 'wp_enqueue_scripts', $general, 'enqueue_scripts' ); - $this->loader->add_action( 'widgets_init', $plugin_public, 'register_widgets' ); + $this->loader->add_action( 'widgets_init', $general, 'register_widgets' ); } /** diff --git a/src/includes/class-loader.php b/src/includes/class-loader.php index a0d6bcf..5ca90a7 100644 --- a/src/includes/class-loader.php +++ b/src/includes/class-loader.php @@ -137,12 +137,12 @@ class Loader { */ public function run() { - foreach ( $this->filters as $hook ) { - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + foreach ( $this->filters as $filter ) { + add_filter( $filter['hook'], array( $filter['component'], $filter['callback'] ), $filter['priority'], $filter['accepted_args'] ); } - foreach ( $this->actions as $hook ) { - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + foreach ( $this->actions as $action ) { + add_action( $action['hook'], array( $action['component'], $action['callback'] ), $action['priority'], $action['accepted_args'] ); } }