Skip to content

Commit

Permalink
fix: fixing phpcs and rector
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Feb 29, 2024
1 parent 228dbb1 commit f24d8c9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions wp/headless-wp/includes/classes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function register_post_type_taxonomy_params(): void {
);

foreach ( $post_types as $post_type ) {
add_filter( sprintf('rest_%s_query', $post_type), [ $this, 'modify_rest_params' ], 10, 1 );
add_filter( sprintf('rest_%s_collection_params', $post_type), [ $this, 'modify_rest_params_schema' ], 10, 2 );
add_filter( sprintf( 'rest_%s_query', $post_type ), [ $this, 'modify_rest_params' ], 10, 1 );
add_filter( sprintf( 'rest_%s_collection_params', $post_type ), [ $this, 'modify_rest_params_schema' ], 10, 2 );
}
}

Expand Down
10 changes: 5 additions & 5 deletions wp/headless-wp/includes/classes/CacheFlush/CacheFlush.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public function register(): void {
}

/**
* Run the cron job
*
* @param int $post_id The post id
*/
public function run_job( int $post_id ): void {
* Run the cron job
*
* @param int $post_id The post id
*/
public function run_job( int $post_id ): void {
$this->revalidate( $post_id );
}

Expand Down
26 changes: 13 additions & 13 deletions wp/headless-wp/includes/classes/Links.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public function register(): void {
}

/**
* Create Taxonomy Rewrites
*
* /posts/category/category-slug
* /events/category/category-slug
*
* This is to allow taxonomy archive pages to exist that aren't specific to the 'post' post type by default and make more usable across other post types by
* creating default rewrite rules for taxonomy endpoints for post types for the front-end site to resolve to in the format /<CPT>/<taxonomy>/<slug>.
*
* @param array $rules Rewrite rules.
*/
public function create_taxonomy_rewrites( array $rules ): array {
* Create Taxonomy Rewrites
*
* /posts/category/category-slug
* /events/category/category-slug
*
* This is to allow taxonomy archive pages to exist that aren't specific to the 'post' post type by default and make more usable across other post types by
* creating default rewrite rules for taxonomy endpoints for post types for the front-end site to resolve to in the format /<CPT>/<taxonomy>/<slug>.
*
* @param array $rules Rewrite rules.
*/
public function create_taxonomy_rewrites( array $rules ): array {

// When set_taxonomy_rewrites_disabled true, bypasses these custom endpoint rewrite rules
if ( true === apply_filters( __FUNCTION__ . '_disabled', false ) ) {
Expand Down Expand Up @@ -72,8 +72,8 @@ public function create_taxonomy_rewrites( array $rules ): array {
continue;
}

$rules[ sprintf('%s/%s/(.+?)/?$', $post_slug, $rewrite_slug) ] = sprintf('index.php?%s=$1&post_type=%s', $rewrite_query_var, $post_type);
$rules[ sprintf('%s/%s/(.+?)/page/?([0-9]{1,})/?$', $post_slug, $rewrite_slug) ] = sprintf('index.php?%s=$1&paged=$2&post_type=%s', $rewrite_query_var, $post_type);
$rules[ sprintf( '%s/%s/(.+?)/?$', $post_slug, $rewrite_slug ) ] = sprintf( 'index.php?%s=$1&post_type=%s', $rewrite_query_var, $post_type );
$rules[ sprintf( '%s/%s/(.+?)/page/?([0-9]{1,})/?$', $post_slug, $rewrite_slug ) ] = sprintf( 'index.php?%s=$1&paged=$2&post_type=%s', $rewrite_query_var, $post_type );

}
}
Expand Down
4 changes: 2 additions & 2 deletions wp/headless-wp/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ function ( $the_class ): void {
$base_dir = __DIR__ . '/includes/classes/';
// Does the class use the namespace prefix?
$len = strlen( $prefix );
if ( strncmp( $prefix, (string) $the_class, $len ) !== 0 ) {
if ( strncmp( $prefix, $the_class, $len ) !== 0 ) {
return;
}
$relative_class = substr( (string) $the_class, $len );
$relative_class = substr( $the_class, $len );
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
// If the file exists, require it.
if ( file_exists( $file ) ) {
Expand Down
18 changes: 9 additions & 9 deletions wp/headless-wp/tests/php/includes/TestPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function test_handle_review(): void {


/**
* Tests the preview token generation
*/
public function test_preview_token_generation(): void {
* Tests the preview token generation
*/
public function test_preview_token_generation(): void {
$token = PreviewToken::generate( [ 'type' => 'test_token' ] );

$payload = (array) PreviewToken::get_payload_from_token( $token );
Expand All @@ -70,9 +70,9 @@ public function test_preview_token_generation(): void {
}

/**
* Tests getting the token payload
*/
public function test_get_payload_from_token(): void {
* Tests getting the token payload
*/
public function test_get_payload_from_token(): void {
$token = PreviewToken::generate( [ 'type' => 'test_token' ] );

$_SERVER['HTTP_AUTHORIZATION'] = 'Bearer ' . $token;
Expand All @@ -93,9 +93,9 @@ public function test_get_payload_from_token(): void {
}

/**
* Tests getting the token payload from alternative header
*/
public function test_get_payload_from_token_alternative_header(): void {
* Tests getting the token payload from alternative header
*/
public function test_get_payload_from_token_alternative_header(): void {
$token = PreviewToken::generate( [ 'type' => 'test_token' ] );

$_SERVER['HTTP_X_HEADSTARTWP_AUTHORIZATION'] = 'Bearer ' . $token;
Expand Down

0 comments on commit f24d8c9

Please sign in to comment.