Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New ep_post_test_meta_value filter #3850

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
23 changes: 22 additions & 1 deletion includes/classes/Indexable/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2825,7 +2825,10 @@ public function get_predicted_indexable_meta_keys( bool $force_refresh = false )
$empty_post = new \WP_Post( (object) [] );
$meta_keys = $this->get_distinct_meta_field_keys_db( $force_refresh );

$fake_meta_values = array_combine( $meta_keys, array_fill( 0, count( $meta_keys ), 'test-value' ) );
$fake_meta_values = array_combine(
$meta_keys,
array_fill( 0, count( $meta_keys ), $this->get_test_meta_value() )
);
$filtered_meta = apply_filters( 'ep_prepare_meta_data', $fake_meta_values, $empty_post );

$all_keys = array_filter(
Expand All @@ -2840,6 +2843,24 @@ function( $meta_key ) use ( $empty_post ) {
return $all_keys;
}

/**
* Return the value used to fill meta fields while predicting indexable content.
*
* @since 5.1.0
* @return string
*/
public function get_test_meta_value() : string {
/**
* Filter the value used to fill meta fields while predicting indexable content.
*
* @hook ep_post_test_meta_value
* @since 5.1.0
* @param {string} $test_meta_value The test meta value. Default: test-value
* @return {string} New test meta value
*/
return (string) apply_filters( 'ep_post_test_meta_value', 'test-value' );
}

/**
* Given a post type, *yields* their Post IDs.
*
Expand Down
Loading