Skip to content

Commit de928b7

Browse files
committed
Reprefix and rename pwcc variables and hook names.
1 parent 1de5289 commit de928b7

File tree

3 files changed

+35
-40
lines changed

3 files changed

+35
-40
lines changed

inc/namespace.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ function bootstrap() {
3636
* @param bool $notify_async Whether to notify IndexNow asynchronously.
3737
* Default is false, meaning synchronous pings.
3838
*/
39-
$notify_async = apply_filters( 'pwcc/index-now/notify-async', false );
39+
$notify_async = apply_filters( 'simple_search_submission_notify_async', false );
4040

4141
if ( $notify_async ) {
4242
// Use the async ping action.
43-
add_action( 'pwcc/index-now/ping', __NAMESPACE__ . '\\async_ping_indexnow', 10, 1 );
44-
add_action( 'pwcc/index-now/async_ping', __NAMESPACE__ . '\\ping_indexnow', 10, 1 );
43+
add_action( 'simple_search_submission_ping', __NAMESPACE__ . '\\async_ping_indexnow', 10, 1 );
44+
add_action( 'simple_search_submission_async_ping', __NAMESPACE__ . '\\ping_indexnow', 10, 1 );
4545
} else {
4646
// Use the synchronous ping action.
47-
add_action( 'pwcc/index-now/ping', __NAMESPACE__ . '\\ping_indexnow', 10, 1 );
47+
add_action( 'simple_search_submission_ping', __NAMESPACE__ . '\\ping_indexnow', 10, 1 );
4848
}
4949
}
5050

@@ -55,7 +55,7 @@ function bootstrap() {
5555
* @return array Modified array of query vars.
5656
*/
5757
function register_query_vars( $vars ) {
58-
$vars[] = 'pwcc_indexnow_key';
58+
$vars[] = 'simple_search_submission_key';
5959
return $vars;
6060
}
6161

@@ -67,7 +67,7 @@ function add_key_rewrite_rule() {
6767

6868
add_rewrite_rule(
6969
'pwcc-indexnow-' . $key . '$',
70-
'index.php?pwcc_indexnow_key=' . $key,
70+
'index.php?simple_search_submission_key=' . $key,
7171
'top'
7272
);
7373
}
@@ -78,13 +78,13 @@ function add_key_rewrite_rule() {
7878
* @param \WP $wp WordPress instance.
7979
*/
8080
function handle_key_file_request( $wp ) {
81-
if ( empty( $wp->query_vars['pwcc_indexnow_key'] ) ) {
81+
if ( empty( $wp->query_vars['simple_search_submission_key'] ) ) {
8282
return;
8383
}
8484

8585
$key = get_indexnow_key();
86-
if ( ! $key || $wp->query_vars['pwcc_indexnow_key'] !== $key ) {
87-
$error = 'Invalid key: ' . get_query_var( 'pwcc_indexnow_key' );
86+
if ( ! $key || $wp->query_vars['simple_search_submission_key'] !== $key ) {
87+
$error = 'Invalid key: ' . get_query_var( 'simple_search_submission_key' );
8888
wp_die( esc_html( $error ), 'IndexNow Key Error', array( 'response' => 403 ) );
8989
return;
9090
}
@@ -106,14 +106,14 @@ function handle_key_file_request( $wp ) {
106106
* @return string Unique site key.
107107
*/
108108
function get_indexnow_key(): string {
109-
$key = get_option( 'pwcc_indexnow_key' );
109+
$key = get_option( 'simple_search_submission_key' );
110110

111111
if ( ! $key ) {
112112
// Generate a random key that meets IndexNow requirements.
113113
// Must be 8-128 hexadecimal characters (a-f, 0-9).
114114
$key = strtolower( wp_generate_password( 32, false, false ) );
115115

116-
update_option( 'pwcc_indexnow_key', $key );
116+
update_option( 'simple_search_submission_key', $key );
117117

118118
// Flush the rewrite rules.
119119
flush_rewrite_rules();
@@ -145,7 +145,7 @@ function maybe_ping_indexnow( $new_status, $old_status, $post ): void {
145145
* @param string $old_status The old post status.
146146
* @param \WP_Post $post The post object.
147147
*/
148-
$preflight_ping = apply_filters( 'pwcc/index-now/pre-maybe-ping-indexnow', null, $new_status, $old_status, $post );
148+
$preflight_ping = apply_filters( 'simple_search_submission_pre_maybe_ping_indexnow', null, $new_status, $old_status, $post );
149149

150150
if ( is_bool( $preflight_ping ) ) {
151151
if ( true === $preflight_ping ) {
@@ -154,7 +154,7 @@ function maybe_ping_indexnow( $new_status, $old_status, $post ): void {
154154
*
155155
* @param \WP_Post $post The post object.
156156
*/
157-
do_action( 'pwcc/index-now/ping', $post );
157+
do_action( 'simple_search_submission_ping', $post );
158158
}
159159
return;
160160
}
@@ -203,7 +203,7 @@ function maybe_ping_indexnow( $new_status, $old_status, $post ): void {
203203
}
204204

205205
/** This action is documented in inc/namespace.php */
206-
do_action( 'pwcc/index-now/ping', $post );
206+
do_action( 'simple_search_submission_ping', $post );
207207
}
208208

209209
/**
@@ -223,7 +223,7 @@ function get_post_ping_urls( $post ) {
223223
}
224224

225225
// Get previous pings from the post meta.
226-
$ping_urls = get_post_meta( $post->ID, '_pwcc_indexnow_urls', true );
226+
$ping_urls = get_post_meta( $post->ID, '_simple_search_submission_urls', true );
227227
if ( empty( $ping_urls ) || ! is_array( $ping_urls ) ) {
228228
// Initialize an empty array if no URLs are found.
229229
$ping_urls = array();
@@ -260,7 +260,7 @@ function add_post_ping_urls( $post, $urls ) {
260260
return;
261261
}
262262

263-
update_post_meta( $post->ID, '_pwcc_indexnow_urls', $ping_urls );
263+
update_post_meta( $post->ID, '_simple_search_submission_urls', $ping_urls );
264264
}
265265

266266
/**
@@ -298,15 +298,15 @@ function ping_indexnow( $post ) {
298298
* Default is an array with the single URL of the post.
299299
* @param \WP_Post $post The post object.
300300
*/
301-
$url_list = apply_filters( 'pwcc/index-now/url-list', $url_list, $post );
301+
$url_list = apply_filters( 'simple_search_submission_url_list', $url_list, $post );
302302

303303
if ( empty( $url_list ) ) {
304304
// If no URLs to ping, do nothing.
305305
return;
306306
}
307307

308308
if ( empty( get_option( 'permalink_structure' ) ) ) {
309-
$key_location = home_url( '?pwcc_indexnow_key=' . $key );
309+
$key_location = home_url( '?simple_search_submission_key=' . $key );
310310
} else {
311311
$key_location = trailingslashit( home_url( 'pwcc-indexnow-' . $key ) );
312312
}
@@ -318,7 +318,7 @@ function ping_indexnow( $post ) {
318318
* @param array $url_list The list if URLs to be submitted.
319319
* @param WP_Post $post The post object.
320320
*/
321-
$key_location = apply_filters( 'pwcc/index-now/key-location', $key_location, $url_list, $post );
321+
$key_location = apply_filters( 'simple_search_submission_key_location', $key_location, $url_list, $post );
322322

323323
$data = array(
324324
'host' => wp_parse_url( $key_location, PHP_URL_HOST ),
@@ -350,7 +350,7 @@ function ping_indexnow( $post ) {
350350
* @param \WP_Post $post The post object
351351
* @param string[] $url_list The list of URLs to be pinged
352352
*/
353-
&& apply_filters( 'pwcc/index-now/bypass-non-production-environment', true, $post, $url_list )
353+
&& apply_filters( 'simple_search_submission_bypass_non_production_environment', true, $post, $url_list )
354354
) {
355355
// In development, log the request for debugging.
356356
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
@@ -396,7 +396,7 @@ function async_ping_indexnow( $post ) {
396396

397397
$post_id = $post->ID;
398398

399-
if ( ! wp_next_scheduled( 'pwcc/index-now/async_ping', array( $post_id ) ) ) {
400-
wp_schedule_single_event( time() + 5, 'pwcc/index-now/async_ping', array( $post_id ) );
399+
if ( ! wp_next_scheduled( 'simple_search_submission_async_ping', array( $post_id ) ) ) {
400+
wp_schedule_single_event( time() + 5, 'simple_search_submission_async_ping', array( $post_id ) );
401401
}
402402
}

phpcs.xml.dist

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
2929
<properties>
3030
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
31-
<property name="prefixes" type="array" value="pwcc,_pwcc"/>
32-
</properties>
33-
</rule>
34-
<rule ref="WordPress.NamingConventions.ValidHookName">
35-
<properties>
36-
<property name="additionalWordDelimiters" value="/-"/>
31+
<property name="prefixes" type="array" value="simple_search_submission,_simple_search_submission"/>
3732
</properties>
3833
</rule>
3934
<rule ref="WordPress.WP.I18n">

tests/bootstrap.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
* @package SimpleSearchSubmission
66
*/
77

8-
$_pwcc_tests_directory = getenv( 'WP_TESTS_DIR' );
8+
$_simple_search_submission_tests_directory = getenv( 'WP_TESTS_DIR' );
99

10-
if ( ! $_pwcc_tests_directory ) {
11-
$_pwcc_tests_directory = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
10+
if ( ! $_simple_search_submission_tests_directory ) {
11+
$_simple_search_submission_tests_directory = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
1212
}
1313

1414
// Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.
15-
$_pwcc_tests_phpunit_polyfills_directory = __DIR__ . '/../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
16-
if ( false !== $_pwcc_tests_phpunit_polyfills_directory ) {
15+
$_simple_search_submission_tests_phpunit_polyfills_directory = __DIR__ . '/../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
16+
if ( false !== $_simple_search_submission_tests_phpunit_polyfills_directory ) {
1717
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- test suite constant.
18-
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_pwcc_tests_phpunit_polyfills_directory );
18+
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_simple_search_submission_tests_phpunit_polyfills_directory );
1919
}
2020

21-
if ( ! file_exists( "{$_pwcc_tests_directory}/includes/functions.php" ) ) {
22-
echo "Could not find {$_pwcc_tests_directory}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
21+
if ( ! file_exists( "{$_simple_search_submission_tests_directory}/includes/functions.php" ) ) {
22+
echo "Could not find {$_simple_search_submission_tests_directory}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2323
exit( 1 );
2424
}
2525

2626
// Give access to tests_add_filter() function.
27-
require_once "{$_pwcc_tests_directory}/includes/functions.php";
27+
require_once "{$_simple_search_submission_tests_directory}/includes/functions.php";
2828

2929
/**
3030
* Manually load the plugin being tested.
3131
*/
32-
function _pwcc_tests_manually_load_plugin() {
32+
function _simple_search_submission_tests_manually_load_plugin() {
3333
require dirname( __DIR__ ) . '/simple-search-submission.php';
3434
}
3535

36-
tests_add_filter( 'muplugins_loaded', '_pwcc_tests_manually_load_plugin' );
36+
tests_add_filter( 'muplugins_loaded', '_simple_search_submission_tests_manually_load_plugin' );
3737

3838
// Start up the WP testing environment.
39-
require "{$_pwcc_tests_directory}/includes/bootstrap.php";
39+
require "{$_simple_search_submission_tests_directory}/includes/bootstrap.php";

0 commit comments

Comments
 (0)