From df602d222f5edebe331b12b69e52f0354fb35126 Mon Sep 17 00:00:00 2001 From: Frankie Bordone Date: Wed, 10 Jan 2024 15:41:58 -0500 Subject: [PATCH] Remove namespacing and tenup prefixes from helper function names --- inc/helpers.php | 18 +++++++++--------- tests/unit/test-admin.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/helpers.php b/inc/helpers.php index f7b0869..29a134a 100644 --- a/inc/helpers.php +++ b/inc/helpers.php @@ -12,7 +12,7 @@ * * @return void */ -function tenup_display_ads_txt() { +function display_ads_txt() { $request = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : false; if ( '/ads.txt' === $request || '/ads.txt?' === substr( $request, 0, 9 ) ) { $post_id = get_option( ADS_TXT_MANAGER_POST_OPTION ); @@ -70,14 +70,14 @@ function tenup_display_ads_txt() { } } } -add_action( 'init', __NAMESPACE__ . '\tenup_display_ads_txt' ); +add_action( 'init', __NAMESPACE__ . '\display_ads_txt' ); /** * Add custom capabilities. * * @return void */ -function add_adstxt_capabilities() { +function add_capabilities() { $role = get_role( 'administrator' ); // Bail early if the administrator role doesn't exist. @@ -89,15 +89,15 @@ function add_adstxt_capabilities() { $role->add_cap( ADS_TXT_MANAGE_CAPABILITY ); } } -add_action( 'admin_init', __NAMESPACE__ . '\add_adstxt_capabilities' ); -register_activation_hook( __FILE__, __NAMESPACE__ . '\add_adstxt_capabilities' ); +add_action( 'admin_init', __NAMESPACE__ . '\add_capabilities' ); +register_activation_hook( __FILE__, __NAMESPACE__ . '\add_capabilities' ); /** * Remove custom capabilities when deactivating the plugin. * * @return void */ -function remove_adstxt_capabilities() { +function remove_capabilities() { $role = get_role( 'administrator' ); // Bail early if the administrator role doesn't exist. @@ -107,7 +107,7 @@ function remove_adstxt_capabilities() { $role->remove_cap( ADS_TXT_MANAGE_CAPABILITY ); } -register_deactivation_hook( __FILE__, __NAMESPACE__ . '\remove_adstxt_capabilities' ); +register_deactivation_hook( __FILE__, __NAMESPACE__ . '\remove_capabilities' ); /** * Add a query var to detect when ads.txt has been saved. @@ -116,8 +116,8 @@ function remove_adstxt_capabilities() { * * @return array Array of query vars. */ -function tenup_ads_txt_add_query_vars( $qvars ) { +function add_query_vars( $qvars ) { $qvars[] = 'ads_txt_saved'; return $qvars; } -add_filter( 'query_vars', __NAMESPACE__ . '\tenup_ads_txt_add_query_vars' ); +add_filter( 'query_vars', __NAMESPACE__ . '\add_query_vars' ); diff --git a/tests/unit/test-admin.php b/tests/unit/test-admin.php index 2bd3f7d..79af56e 100644 --- a/tests/unit/test-admin.php +++ b/tests/unit/test-admin.php @@ -25,7 +25,7 @@ public function tearDown() : void { /** @test Query var is set */ public function test_query_vars() { - $vars = AdsTxt\tenup_ads_txt_add_query_vars( array( 'existing', 'vars' ) ); + $vars = AdsTxt\add_query_vars( array( 'existing', 'vars' ) ); $this->assertContains( 'ads_txt_saved', $vars ); }