Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions inc/Modules/Core/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ public function register_assets(): void {

/**
* Add scripts and styles to the page.
*
* @param string $hook_suffix Admin page name.
*/
public function enqueue_scripts( $hook_suffix ): void {
public function enqueue_scripts(): void {
// @todo Only enqueue on OneSearch admin pages.
wp_enqueue_style( self::ADMIN_STYLES_HANDLE );
}
Expand Down
5 changes: 2 additions & 3 deletions inc/Modules/Rest/Governing_Data_Controller.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

declare(strict_types = 1);

/**
* Routes for Search-related operations.
*
* @package OneSearch
*/

declare(strict_types = 1);

namespace OneSearch\Modules\Rest;

use OneSearch\Modules\Search\Settings as Search_Settings;
Expand Down
5 changes: 2 additions & 3 deletions inc/Modules/Rest/Governing_Data_Handler.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php

declare(strict_types = 1);

/**
* Handles cross-site requests for governing brand data.
*
Expand All @@ -10,6 +7,8 @@
* @package OneSearch\Modules\Rest
*/

declare(strict_types = 1);

namespace OneSearch\Modules\Rest;

use OneSearch\Encryptor;
Expand Down
5 changes: 2 additions & 3 deletions inc/Modules/Rest/Search_Controller.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

declare(strict_types = 1);

/**
* Routes for Search-related operations.
*
* @package OneSearch
*/

declare(strict_types = 1);

namespace OneSearch\Modules\Rest;

use OneSearch\Modules\Search\Index;
Expand Down
2 changes: 1 addition & 1 deletion inc/Modules/Search/Post_Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function get_cleaned_post_content( \WP_Post $post ): string {
$removed_filter = remove_filter( 'the_content', 'wptexturize', 10 );

try {
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHookname -- intentionally using the_content.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- intentionally using the_content.
$content = (string) apply_filters( 'the_content', $post->post_content );
} catch ( \Throwable $e ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- @todo Surface this better with a Logger class.
Expand Down
13 changes: 5 additions & 8 deletions inc/Modules/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// Author data.
add_filter( 'get_the_author_display_name', [ $this, 'get_post_author' ], 10 );
add_filter( 'author_link', [ $this, 'get_post_author_link' ], 10, 3 );
add_filter( 'author_link', [ $this, 'get_post_author_link' ], 10 );
add_filter( 'get_avatar_url', [ $this, 'get_post_author_avatar' ], 10 );

// Term and taxonomy link handling for remote objects.
Expand All @@ -67,7 +67,7 @@
add_filter( 'wp_get_post_terms', [ $this, 'get_post_terms' ], 10, 3 );

// Block-theme compatibility: fix remote permalinks/excerpts in rendered blocks.
add_filter( 'render_block', [ $this, 'filter_render_block' ], 10, 3 );
add_filter( 'render_block', [ $this, 'filter_render_block' ], 10, 2 );
}

/**
Expand Down Expand Up @@ -99,7 +99,7 @@

$query->post_count = count( $posts_to_return );
$query->found_posts = isset( $results['nbHits'] ) ? (int) $results['nbHits'] : $query->post_count;
$query->is_algolia_search = true;

Check failure on line 102 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Query::$is_algolia_search.

return $posts_to_return;
}
Expand Down Expand Up @@ -166,13 +166,11 @@
/**
* Author link mapping for remote posts.
*
* @param string $author_link Default author link.
* @param int $author_id Author ID (negative for remote).
* @param string|null $author_nicename The author's nicename if provided by the filter.
* @param string $author_link Default author link.
*
* @return string
*/
public function get_post_author_link( $author_link, $author_id, $author_nicename = null ) {
public function get_post_author_link( $author_link ) {
global $wp_query, $post;

if ( ! $this->is_search_enabled() || ! $wp_query instanceof \WP_Query || ! $this->should_filter_query( $wp_query ) ) {
Expand Down Expand Up @@ -325,11 +323,10 @@
*
* @param string $block_content Rendered block HTML.
* @param array<string,mixed> $block Block data.
* @param \WP_Block $instance Block instance.
*
* @return string
*/
public function filter_render_block( $block_content, $block, $instance ) {
public function filter_render_block( $block_content, $block ) {
global $post;

if ( ! $this->is_search_enabled() || ! $post instanceof \WP_Post || (int) $post->ID >= 0 || empty( $post->guid ) ) {
Expand Down Expand Up @@ -580,7 +577,7 @@
continue;
}

$post->onesearch_algolia_highlights = $this->extract_algolia_highlights( $record );

Check failure on line 580 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_algolia_highlights.

$posts[] = $post;
}
Expand Down Expand Up @@ -711,8 +708,8 @@
return null;
}

$post->onesearch_site_url = $site_url;

Check failure on line 711 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_site_url.
$post->onesearch_site_name = $record['site_name'] ?? '';

Check failure on line 712 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_site_name.

return $post;
}
Expand All @@ -739,15 +736,15 @@
// Set negative author ID to avoid conflicts.
if ( isset( $record['post_author_data'] ) ) {
$post->post_author = (string) ( -1000 - absint( $record['post_author_data']['author_id'] ) );
$post->onesearch_remote_post_author_display_name = $record['post_author_data']['author_display_name'] ?? '';

Check failure on line 739 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_remote_post_author_display_name.
$post->onesearch_remote_post_author_link = $record['post_author_data']['author_posts_url'] ?? '';

Check failure on line 740 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_remote_post_author_link.
$post->onesearch_remote_post_author_gravatar = $record['post_author_data']['author_avatar'] ?? '';

Check failure on line 741 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_remote_post_author_gravatar.
}

// Set Custom OneSearch properties.
$post->onesearch_original_id = $record['post_id'];

Check failure on line 745 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_original_id.
$post->onesearch_remote_taxonomies = $record['taxonomies'] ?? [];

Check failure on line 746 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_remote_taxonomies.
$post->onesearch_site_url = $record['site_url'] ?? '';

Check failure on line 747 in inc/Modules/Search/Search.php

View workflow job for this annotation

GitHub Actions / PHPStan / PHPStan Static Analysis

Access to an undefined property WP_Post::$onesearch_site_url.
$post->onesearch_site_name = $record['site_name'] ?? '';

return $post;
Expand Down
8 changes: 6 additions & 2 deletions inc/Modules/Search/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ public function register_settings(): void {
/**
* Deletes Algolia index when site type is changed to consumer.
*
* @internal Hook callback
*
* @param mixed $old_value The old value.
* @param mixed $new_value The new value.
*/
public function on_site_type_change( $old_value, $new_value ): void {
public function on_site_type_change( $old_value, $new_value ): void { // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
if ( Admin_Settings::SITE_TYPE_CONSUMER !== $new_value ) {
return;
}
Expand Down Expand Up @@ -252,11 +254,13 @@ static function ( $site_url ) {
/**
* Purges the Governing_Data_Handler cache when a setting update triggers.
*
* @internal Hook callback
*
* @param mixed $old_value The old value.
* @param mixed $new_value The new value.
* @param string $option The option name.
*/
public function purge_cache_on_update( $old_value, $new_value, $option ): void {
public function purge_cache_on_update( $old_value, $new_value, $option ): void { // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
match ( $option ) {
self::OPTION_GOVERNING_ALGOLIA_CREDENTIALS,
self::OPTION_GOVERNING_SEARCH_SETTINGS,
Expand Down
4 changes: 3 additions & 1 deletion inc/Modules/Search/Watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ public function register_hooks(): void {
/**
* Triggered when a post's status changes (e.g., publish, update, trash, etc.)
*
* @internal Hook callback
*
* @param string $new_status The new post status.
* @param string $old_status The previous post status.
* @param \WP_Post $post The post object.
*/
public function on_post_transition( $new_status, $old_status, $post ): void {
public function on_post_transition( $new_status, $old_status, $post ): void { // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
if ( ! $post instanceof \WP_Post || ! $this->is_post_type_indexable( (string) $post->post_type ) ) {
return;
}
Expand Down
4 changes: 3 additions & 1 deletion inc/Modules/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ public function register_settings(): void {
/**
* Ensures the API key is generated when the site type changes to 'consumer'.
*
* @internal Hook callback
*
* @param mixed $old_value The old value.
* @param mixed $new_value The new value.
*/
public function on_site_type_change( $old_value, $new_value ): void {
public function on_site_type_change( $old_value, $new_value ): void { // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
if ( self::SITE_TYPE_CONSUMER !== $new_value ) {
return;
}
Expand Down
Loading