Skip to content

Commit

Permalink
Remove namespacing and tenup prefixes from helper function names
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiebordone committed Jan 10, 2024
1 parent 59cf21b commit df602d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions inc/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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' );
2 changes: 1 addition & 1 deletion tests/unit/test-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit df602d2

Please sign in to comment.