Actualizacion 7.1.2
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+72
-5
@@ -12,6 +12,7 @@ namespace RankMath\Abilities\AI_Visibility;
|
||||
|
||||
use WP_REST_Request;
|
||||
use RankMath\Abilities\Ability_Interface;
|
||||
use RankMath\AI_Visibility\Platforms;
|
||||
use RankMath\AI_Visibility\Api\Brands_Controller;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
@@ -66,14 +67,18 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
[
|
||||
'category' => $this->category,
|
||||
'label' => esc_html__( 'Create AI Visibility brand', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__(
|
||||
'Creates a new brand for AI Visibility monitoring, triggering an initial analysis automatically.',
|
||||
'seo-by-rank-math'
|
||||
'description' => sprintf(
|
||||
/* translators: %s: supported platform IDs. */
|
||||
esc_html__(
|
||||
'Creates a new brand for AI Visibility monitoring, triggering an initial analysis automatically. Ask which AI platforms to track. Supported platforms: %s. Selecting more than one requires the Expert plan; other plans may choose only one.',
|
||||
'seo-by-rank-math'
|
||||
),
|
||||
Platforms::supported_as_string()
|
||||
),
|
||||
'input_schema' => [
|
||||
'type' => 'object',
|
||||
'default' => [],
|
||||
'required' => [ 'name', 'url' ],
|
||||
'required' => [ 'name', 'url', 'language', 'platforms' ],
|
||||
'properties' => [
|
||||
'name' => [
|
||||
'type' => 'string',
|
||||
@@ -94,6 +99,30 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
'description' => esc_html__( 'ISO 3166-1 alpha-2 country code (e.g. "US", "HU"). Defaults to no country filter.', 'seo-by-rank-math' ),
|
||||
'default' => '',
|
||||
],
|
||||
'language' => [
|
||||
'type' => 'string',
|
||||
'description' => esc_html__( 'Language the brand should be analyzed in (e.g. "US English", "French"). Required; immutable after creation — ask the user which language to use.', 'seo-by-rank-math' ),
|
||||
'enum' => Brands_Controller::get_language_choices( false ),
|
||||
],
|
||||
'interval' => [
|
||||
'type' => 'string',
|
||||
'description' => esc_html__( 'Analysis refresh cadence. Defaults to the account plan\'s default when omitted.', 'seo-by-rank-math' ),
|
||||
'enum' => array_merge( [ '' ], Brands_Controller::get_interval_choices() ),
|
||||
'default' => '',
|
||||
],
|
||||
'platforms' => [
|
||||
'type' => 'array',
|
||||
'minItems' => 1,
|
||||
'description' => sprintf(
|
||||
/* translators: %s: supported platform IDs. */
|
||||
esc_html__( 'AI platforms to track. Supported: %s. Selecting more than one requires the Expert plan; otherwise choose exactly one. Do not assume a default — ask the user which platform(s) to use.', 'seo-by-rank-math' ),
|
||||
Platforms::supported_as_string()
|
||||
),
|
||||
'items' => [
|
||||
'type' => 'string',
|
||||
'enum' => Platforms::supported(),
|
||||
],
|
||||
],
|
||||
],
|
||||
'additionalProperties' => false,
|
||||
],
|
||||
@@ -130,11 +159,19 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
* @return array
|
||||
*/
|
||||
public function execute( array $input = [] ): array {
|
||||
$platforms = $this->validate_platforms( $input['platforms'] ?? null );
|
||||
if ( isset( $platforms['error'] ) ) {
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
$request = new WP_REST_Request( 'POST' );
|
||||
$request->set_param( 'name', sanitize_text_field( (string) ( $input['name'] ?? '' ) ) );
|
||||
$request->set_param( 'url', esc_url_raw( (string) ( $input['url'] ?? '' ) ) );
|
||||
$request->set_param( 'description', sanitize_textarea_field( (string) ( $input['description'] ?? '' ) ) );
|
||||
$request->set_param( 'locale', sanitize_text_field( (string) ( $input['locale'] ?? '' ) ) );
|
||||
$request->set_param( 'language', sanitize_text_field( (string) ( $input['language'] ?? '' ) ) );
|
||||
$request->set_param( 'interval', sanitize_text_field( (string) ( $input['interval'] ?? '' ) ) );
|
||||
$request->set_param( 'platforms', $platforms );
|
||||
|
||||
$response = $this->controller->create_brand( $request );
|
||||
|
||||
@@ -149,11 +186,28 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
'id' => $brand['id'] ?? '',
|
||||
'name' => $brand['name'] ?? '',
|
||||
'url' => $brand['url'] ?? '',
|
||||
'interval' => $brand['interval'] ?? null,
|
||||
'platforms' => $brand['platforms'] ?? [],
|
||||
'analysis_status' => 'pending',
|
||||
'created_at' => $brand['created_at'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize and validate platforms. No silent defaults.
|
||||
*
|
||||
* @param mixed $platforms Raw platforms value.
|
||||
* @return string[]|array{error: string}
|
||||
*/
|
||||
private function validate_platforms( $platforms ) {
|
||||
$valid = Platforms::validate( $platforms );
|
||||
if ( is_wp_error( $valid ) ) {
|
||||
return [ 'error' => $valid->get_error_message() ];
|
||||
}
|
||||
|
||||
return Platforms::sanitize( $platforms );
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON schema for the ability output.
|
||||
*
|
||||
@@ -176,6 +230,19 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
'format' => 'uri',
|
||||
'description' => 'Brand website URL.',
|
||||
],
|
||||
'interval' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'enum' => array_merge( [ null ], Brands_Controller::get_interval_choices() ),
|
||||
'description' => 'Resolved analysis cadence for this brand.',
|
||||
],
|
||||
'platforms' => [
|
||||
'type' => 'array',
|
||||
'description' => 'AI platforms selected for this brand.',
|
||||
'items' => [
|
||||
'type' => 'string',
|
||||
'enum' => Platforms::supported(),
|
||||
],
|
||||
],
|
||||
'analysis_status' => [
|
||||
'type' => 'string',
|
||||
'enum' => [ 'pending' ],
|
||||
@@ -188,7 +255,7 @@ class Create_AI_Visibility_Brand implements Ability_Interface {
|
||||
],
|
||||
'error' => [
|
||||
'type' => 'string',
|
||||
'description' => 'Present only on failure — human-readable error from the upstream API.',
|
||||
'description' => 'Present only on failure — human-readable error from validation or the upstream API.',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
+36
-26
@@ -109,7 +109,6 @@ class Get_AI_Visibility_Brand_Insights implements Ability_Interface {
|
||||
|
||||
$cached = Cache::get_analysis( $brand_id );
|
||||
|
||||
// Cache miss or stale — signal the caller to trigger a fetch via the REST endpoint.
|
||||
if ( false === $cached || Cache::is_brand_stale( $brand_id ) ) {
|
||||
rank_math()->tracking->track_ability_executed(
|
||||
'AI Visibility Brand Insights Fetched',
|
||||
@@ -175,31 +174,38 @@ class Get_AI_Visibility_Brand_Insights implements Ability_Interface {
|
||||
'type' => [ 'number', 'null' ],
|
||||
'description' => 'Total number of AI citations.',
|
||||
],
|
||||
'analysis' => [
|
||||
'type' => [ 'object', 'null' ],
|
||||
'description' => 'Metadata about the latest analysis run.',
|
||||
'properties' => [
|
||||
'id' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'Analysis UUID.',
|
||||
],
|
||||
'status' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'Analysis status (e.g. done, processing, error).',
|
||||
],
|
||||
'started_at' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'format' => 'date-time',
|
||||
'description' => 'ISO 8601 datetime when the analysis started.',
|
||||
],
|
||||
'finished_at' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'format' => 'date-time',
|
||||
'description' => 'ISO 8601 datetime when the analysis completed.',
|
||||
],
|
||||
'duration_seconds' => [
|
||||
'type' => [ 'number', 'null' ],
|
||||
'description' => 'How long the analysis took in seconds.',
|
||||
'analyses' => [
|
||||
'type' => 'array',
|
||||
'description' => 'The latest completed analysis for each tracked AI platform (one entry per platform).',
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'id' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'Analysis UUID.',
|
||||
],
|
||||
'platform' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'AI platform this analysis ran on (e.g. chatgpt, gemini).',
|
||||
],
|
||||
'status' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'Analysis status (e.g. done, processing, error).',
|
||||
],
|
||||
'started_at' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'format' => 'date-time',
|
||||
'description' => 'ISO 8601 datetime when the analysis started.',
|
||||
],
|
||||
'finished_at' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'format' => 'date-time',
|
||||
'description' => 'ISO 8601 datetime when the analysis completed.',
|
||||
],
|
||||
'duration_seconds' => [
|
||||
'type' => [ 'number', 'null' ],
|
||||
'description' => 'How long the analysis took in seconds.',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -243,6 +249,10 @@ class Get_AI_Visibility_Brand_Insights implements Ability_Interface {
|
||||
'type' => 'string',
|
||||
'description' => 'The query that was submitted to the AI model.',
|
||||
],
|
||||
'platform' => [
|
||||
'type' => [ 'string', 'null' ],
|
||||
'description' => 'AI platform that produced this result (e.g. chatgpt, gemini).',
|
||||
],
|
||||
'found' => [
|
||||
'type' => 'boolean',
|
||||
'description' => 'Whether the brand was mentioned in the AI response.',
|
||||
|
||||
@@ -18,6 +18,8 @@ use RankMath\Abilities\Analytics\Subscriber as Analytics_Subscriber;
|
||||
use RankMath\Abilities\AI_Visibility\Subscriber as AI_Visibility_Subscriber;
|
||||
use RankMath\Abilities\Settings\Subscriber as Settings_Subscriber;
|
||||
use RankMath\Abilities\Content_Analysis\Subscriber as Content_Analysis_Subscriber;
|
||||
use RankMath\Abilities\Sitemap\Subscriber as Sitemap_Subscriber;
|
||||
use RankMath\Abilities\Monitor_404\Subscriber as Monitor_404_Subscriber;
|
||||
use RankMath\Abilities\Redirections\Subscriber as Redirections_Subscriber;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
@@ -74,6 +76,8 @@ class Abilities {
|
||||
new AI_Visibility_Subscriber( $shared_meta ),
|
||||
new Settings_Subscriber( $shared_meta ),
|
||||
new Content_Analysis_Subscriber( $shared_meta ),
|
||||
new Sitemap_Subscriber( $shared_meta ),
|
||||
new Monitor_404_Subscriber( $shared_meta ),
|
||||
new Redirections_Subscriber( $shared_meta ),
|
||||
];
|
||||
|
||||
|
||||
+13
@@ -11,6 +11,7 @@
|
||||
namespace RankMath\Abilities\Link_Genius;
|
||||
|
||||
use RankMath\Abilities\Ability_Interface;
|
||||
use RankMath\Rest\Rest_Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
@@ -117,6 +118,15 @@ class Get_Post_Links implements Ability_Interface {
|
||||
*/
|
||||
public function execute( array $input = [] ): array {
|
||||
$post_id = absint( $input['post_id'] ?? 0 );
|
||||
$post = $post_id ? get_post( $post_id ) : null;
|
||||
|
||||
if ( ! $post ) {
|
||||
return [ 'error' => esc_html__( 'Invalid post ID.', 'seo-by-rank-math' ) ];
|
||||
}
|
||||
|
||||
if ( ! Rest_Helper::can_edit_post( $post ) ) {
|
||||
return [ 'error' => esc_html__( 'Sorry, you are not allowed to edit this post.', 'seo-by-rank-math' ) ];
|
||||
}
|
||||
|
||||
$result = $this->runner->run(
|
||||
[
|
||||
@@ -226,6 +236,9 @@ class Get_Post_Links implements Ability_Interface {
|
||||
],
|
||||
],
|
||||
],
|
||||
'error' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* Ability: rank-math/get-404-logs
|
||||
*
|
||||
* @since 1.0.279
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Abilities\Monitor_404
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Abilities\Monitor_404;
|
||||
|
||||
use RankMath\Abilities\Ability_Interface;
|
||||
use RankMath\Monitor\DB;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Registers and executes the rank-math/get-404-logs ability.
|
||||
*/
|
||||
class Get_404_Logs implements Ability_Interface {
|
||||
|
||||
/**
|
||||
* Ability category slug.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Shared meta args.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $shared_meta;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $category Ability category slug.
|
||||
* @param array $shared_meta Shared meta args.
|
||||
*/
|
||||
public function __construct( string $category, array $shared_meta ) {
|
||||
$this->category = $category;
|
||||
$this->shared_meta = $shared_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the ability with the WordPress Abilities API.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void {
|
||||
\wp_register_ability(
|
||||
'rank-math/get-404-logs',
|
||||
[
|
||||
'category' => $this->category,
|
||||
'label' => esc_html__( 'Get 404 logs', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__(
|
||||
'Returns the 404 error monitor log entries, with hit counts and referer/user-agent data.',
|
||||
'seo-by-rank-math'
|
||||
),
|
||||
'input_schema' => [
|
||||
'type' => 'object',
|
||||
'default' => [],
|
||||
'properties' => [
|
||||
'per_page' => [
|
||||
'type' => 'integer',
|
||||
'description' => esc_html__( 'The number of log entries to return per page.', 'seo-by-rank-math' ),
|
||||
'default' => 100,
|
||||
'minimum' => 1,
|
||||
'maximum' => 1000,
|
||||
],
|
||||
'page' => [
|
||||
'type' => 'integer',
|
||||
'description' => esc_html__( 'The page number to return.', 'seo-by-rank-math' ),
|
||||
'default' => 1,
|
||||
],
|
||||
'orderby' => [
|
||||
'type' => 'string',
|
||||
'enum' => [ 'hits', 'accessed' ],
|
||||
'default' => 'hits',
|
||||
'description' => esc_html__( 'Field to order results by.', 'seo-by-rank-math' ),
|
||||
],
|
||||
'order' => [
|
||||
'type' => 'string',
|
||||
'enum' => [ 'asc', 'desc' ],
|
||||
'default' => 'desc',
|
||||
'description' => esc_html__( 'Sort direction.', 'seo-by-rank-math' ),
|
||||
],
|
||||
],
|
||||
'additionalProperties' => false,
|
||||
],
|
||||
'output_schema' => $this->output_schema(),
|
||||
'permission_callback' => [ $this, 'check_permissions' ],
|
||||
'execute_callback' => [ $this, 'execute' ],
|
||||
'meta' => array_merge(
|
||||
$this->shared_meta,
|
||||
[
|
||||
'annotations' => [
|
||||
'readonly' => true,
|
||||
'destructive' => false,
|
||||
'idempotent' => true,
|
||||
],
|
||||
]
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user has permission to execute this ability.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check_permissions(): bool {
|
||||
return current_user_can( 'rank_math_404_monitor' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the ability.
|
||||
*
|
||||
* @param array $input Ability input arguments.
|
||||
* @return array
|
||||
*/
|
||||
public function execute( array $input = [] ): array {
|
||||
$per_page = isset( $input['per_page'] ) ? absint( $input['per_page'] ) : 100;
|
||||
$page = max( 1, isset( $input['page'] ) ? (int) $input['page'] : 1 );
|
||||
$orderby = isset( $input['orderby'] ) ? sanitize_text_field( $input['orderby'] ) : 'hits';
|
||||
$order = isset( $input['order'] ) && in_array( $input['order'], [ 'asc', 'desc' ], true ) ? $input['order'] : 'desc';
|
||||
|
||||
$order_map = [
|
||||
'hits' => 'times_accessed',
|
||||
'accessed' => 'accessed',
|
||||
];
|
||||
|
||||
$logs = DB::get_logs(
|
||||
[
|
||||
'orderby' => $order_map[ $orderby ] ?? 'times_accessed',
|
||||
'order' => strtoupper( $order ),
|
||||
'limit' => $per_page,
|
||||
'paged' => $page,
|
||||
]
|
||||
);
|
||||
|
||||
$items = array_map(
|
||||
function ( $log ) {
|
||||
return [
|
||||
'id' => (int) $log['id'],
|
||||
'uri' => $log['uri'],
|
||||
'hits' => (int) $log['times_accessed'],
|
||||
'referer' => $log['referer'],
|
||||
'user_agent' => $log['user_agent'],
|
||||
'accessed' => $log['accessed'],
|
||||
];
|
||||
},
|
||||
$logs['logs']
|
||||
);
|
||||
|
||||
$stats = DB::get_stats();
|
||||
|
||||
$result = [
|
||||
'stats' => [
|
||||
'total_urls' => (int) ( $stats->total ?? 0 ),
|
||||
'total_hits' => (int) ( $stats->hits ?? 0 ),
|
||||
],
|
||||
'total' => (int) $logs['count'],
|
||||
'items' => $items,
|
||||
];
|
||||
|
||||
rank_math()->tracking->track_ability_executed(
|
||||
'404 Logs Fetched',
|
||||
[ 'count' => (int) $logs['count'] ],
|
||||
'rank_math_404_monitor'
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON schema for the ability output.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function output_schema(): array {
|
||||
return [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'stats' => [
|
||||
'type' => 'object',
|
||||
'description' => esc_html__( 'Log counts across the entire table, independent of pagination.', 'seo-by-rank-math' ),
|
||||
'properties' => [
|
||||
'total_urls' => [ 'type' => 'integer' ],
|
||||
'total_hits' => [ 'type' => 'integer' ],
|
||||
],
|
||||
],
|
||||
'total' => [
|
||||
'type' => 'integer',
|
||||
'description' => esc_html__( 'Number of log entries included in this response (the size of items).', 'seo-by-rank-math' ),
|
||||
],
|
||||
'items' => [
|
||||
'type' => 'array',
|
||||
'description' => esc_html__( 'The 404 log entries for the requested page.', 'seo-by-rank-math' ),
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'id' => [ 'type' => 'integer' ],
|
||||
'uri' => [ 'type' => 'string' ],
|
||||
'hits' => [ 'type' => 'integer' ],
|
||||
'referer' => [ 'type' => 'string' ],
|
||||
'user_agent' => [ 'type' => 'string' ],
|
||||
'accessed' => [ 'type' => 'string' ],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Subscriber for 404 Monitor abilities.
|
||||
*
|
||||
* @since 1.0.279
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Abilities\Monitor_404
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Abilities\Monitor_404;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Abilities\Subscriber_Interface;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Registers the 404 Monitor ability category and its abilities.
|
||||
*/
|
||||
class Subscriber implements Subscriber_Interface {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Ability category slug for 404 Monitor abilities.
|
||||
*/
|
||||
const CATEGORY_SLUG = 'rank-math-404-monitor';
|
||||
|
||||
/**
|
||||
* Shared meta args.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $shared_meta;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $shared_meta Shared meta args from the top-level Abilities class.
|
||||
*/
|
||||
public function __construct( array $shared_meta ) {
|
||||
$this->shared_meta = $shared_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire hooks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void {
|
||||
$this->action( 'wp_abilities_api_categories_init', 'register_category' );
|
||||
$this->action( 'wp_abilities_api_init', 'register_get_404_logs' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the 404 Monitor ability category.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_category(): void {
|
||||
\wp_register_ability_category(
|
||||
self::CATEGORY_SLUG,
|
||||
[
|
||||
'label' => esc_html__( '404 Monitor', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__( 'Abilities to inspect the 404 error monitor log.', 'seo-by-rank-math' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the rank-math/get-404-logs ability.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_get_404_logs(): void {
|
||||
( new Get_404_Logs( self::CATEGORY_SLUG, $this->shared_meta ) )->register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
/**
|
||||
* Ability: rank-math/get-sitemap-status
|
||||
*
|
||||
* @since 1.0.277
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Abilities\Sitemap
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Abilities\Sitemap;
|
||||
|
||||
use RankMath\Abilities\Ability_Interface;
|
||||
use RankMath\Helper;
|
||||
use RankMath\Sitemap\Generator;
|
||||
use RankMath\Sitemap\Router;
|
||||
use RankMath\Sitemap\Sitemap;
|
||||
use RankMath\Sitemap\Providers\Post_Type as Post_Type_Provider;
|
||||
use RankMath\Sitemap\Providers\Taxonomy as Taxonomy_Provider;
|
||||
use RankMath\Sitemap\Providers\Author as Author_Provider;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Registers and executes the rank-math/get-sitemap-status ability.
|
||||
*/
|
||||
class Get_Sitemap_Status implements Ability_Interface {
|
||||
|
||||
/**
|
||||
* Ability category slug.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Shared meta args.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $shared_meta;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $category Ability category slug.
|
||||
* @param array $shared_meta Shared meta args.
|
||||
*/
|
||||
public function __construct( string $category, array $shared_meta ) {
|
||||
$this->category = $category;
|
||||
$this->shared_meta = $shared_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the ability with the WordPress Abilities API.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void {
|
||||
\wp_register_ability(
|
||||
'rank-math/get-sitemap-status',
|
||||
[
|
||||
'category' => $this->category,
|
||||
'label' => esc_html__( 'Get sitemap status', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__(
|
||||
'Returns whether the XML sitemap is enabled, the sitemap index URL, and the active sitemap types (post types, taxonomies, and the Local SEO sitemap, when active) with their URLs and estimated entry counts.',
|
||||
'seo-by-rank-math'
|
||||
),
|
||||
'input_schema' => [
|
||||
'type' => 'object',
|
||||
'default' => [],
|
||||
'properties' => [],
|
||||
'additionalProperties' => false,
|
||||
],
|
||||
'output_schema' => $this->output_schema(),
|
||||
'permission_callback' => [ $this, 'check_permissions' ],
|
||||
'execute_callback' => [ $this, 'execute' ],
|
||||
'meta' => array_merge(
|
||||
$this->shared_meta,
|
||||
[
|
||||
'annotations' => [
|
||||
'readonly' => true,
|
||||
'destructive' => false,
|
||||
'idempotent' => true,
|
||||
],
|
||||
]
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user has permission to execute this ability.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check_permissions(): bool {
|
||||
return current_user_can( 'rank_math_sitemap' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the ability.
|
||||
*
|
||||
* @param array $input Ability input arguments.
|
||||
* @return array
|
||||
*/
|
||||
public function execute( array $input = [] ): array {
|
||||
$enabled = Helper::is_module_active( 'sitemap' );
|
||||
|
||||
$result = [
|
||||
'enabled' => $enabled,
|
||||
'index_url' => Router::get_base_url( Sitemap::get_sitemap_index_slug() . '.xml' ),
|
||||
'sitemaps' => $this->get_sitemaps(),
|
||||
];
|
||||
|
||||
rank_math()->tracking->track_ability_executed(
|
||||
'Sitemap Status Fetched',
|
||||
[
|
||||
'enabled' => $enabled,
|
||||
'sitemaps_count' => count( $result['sitemaps'] ),
|
||||
],
|
||||
'rank_math_sitemap'
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the list of active sitemap types with their URL and estimated entry count.
|
||||
*
|
||||
* Reuses the real Generator's provider list, so PRO types (e.g. news/video)
|
||||
* show up automatically. Local SEO's `local-sitemap.xml` isn't a Provider
|
||||
* though, so it's captured separately via get_non_provider_entries().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_sitemaps(): array {
|
||||
$max_entries = absint( Helper::get_settings( 'sitemap.items_per_page', 100 ) );
|
||||
$providers = ( new Generator() )->providers;
|
||||
|
||||
$sitemaps = [];
|
||||
foreach ( $providers as $provider ) {
|
||||
$sitemaps = array_merge( $sitemaps, $this->build_sitemap_entries( $provider, $max_entries ) );
|
||||
}
|
||||
|
||||
$local_sitemap = $this->get_local_sitemap();
|
||||
if ( null !== $local_sitemap ) {
|
||||
$sitemaps[] = $local_sitemap;
|
||||
}
|
||||
|
||||
return array_merge( $sitemaps, $this->get_non_provider_entries() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture sitemap entries added outside the Provider system, via the
|
||||
* `rank_math/sitemap/index` filter (currently only Local SEO's KML_File).
|
||||
*
|
||||
* The 'local' type is excluded here because get_local_sitemap() already
|
||||
* builds that entry with an accurate location count; KML_File::add_local_sitemap()
|
||||
* fires this same filter internally, so without the exclusion the local
|
||||
* sitemap would be added twice.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_non_provider_entries(): array {
|
||||
$entries = [];
|
||||
$capture = function ( $item, $label, $type_slug = null ) use ( &$entries ) {
|
||||
$type = ( is_string( $type_slug ) && '' !== $type_slug ) ? $type_slug : $label;
|
||||
if ( ! empty( $item['loc'] ) && 'local' !== $type ) {
|
||||
$entries[] = [
|
||||
'type' => $type,
|
||||
'url' => $item['loc'],
|
||||
'estimated_count' => 1,
|
||||
];
|
||||
}
|
||||
return $item;
|
||||
};
|
||||
|
||||
add_filter( 'rank_math/sitemap/index/entry', $capture, 10, 3 );
|
||||
apply_filters( 'rank_math/sitemap/index', '' );
|
||||
remove_filter( 'rank_math/sitemap/index/entry', $capture, 10 );
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build sitemap entries for a single provider.
|
||||
*
|
||||
* Get_index_links() only returns {loc, lastmod}, so type and page number
|
||||
* are captured via the `sitemap/index/entry` filter it fires internally.
|
||||
* Per-page counts use each provider's own safe public method instead of
|
||||
* get_sitemap_links(), which can die() via Sitemap::maybe_redirect() when
|
||||
* called outside an actual sitemap page request.
|
||||
*
|
||||
* @param object $provider Sitemap provider instance.
|
||||
* @param int $max_entries Entries per sitemap page.
|
||||
* @return array
|
||||
*/
|
||||
private function build_sitemap_entries( $provider, int $max_entries ): array {
|
||||
$entries = [];
|
||||
$capture = function ( $item, $label, $type_slug = null ) use ( &$entries ) {
|
||||
if ( ! empty( $item['loc'] ) ) {
|
||||
$entries[] = [
|
||||
'type' => ( is_string( $type_slug ) && '' !== $type_slug ) ? $type_slug : $label,
|
||||
'url' => $item['loc'],
|
||||
];
|
||||
}
|
||||
return $item;
|
||||
};
|
||||
|
||||
add_filter( 'rank_math/sitemap/index/entry', $capture, 10, 3 );
|
||||
$provider->get_index_links( $max_entries );
|
||||
remove_filter( 'rank_math/sitemap/index/entry', $capture, 10 );
|
||||
|
||||
$post_type_totals = [];
|
||||
$page_numbers = [];
|
||||
$sitemaps = [];
|
||||
foreach ( $entries as $entry ) {
|
||||
$type = $entry['type'];
|
||||
$page_numbers[ $type ] = ( $page_numbers[ $type ] ?? 0 ) + 1;
|
||||
$page = $page_numbers[ $type ];
|
||||
|
||||
if ( $provider instanceof Post_Type_Provider ) {
|
||||
if ( ! isset( $post_type_totals[ $type ] ) ) {
|
||||
$post_type_totals[ $type ] = (int) $provider->get_post_type_count( $type );
|
||||
}
|
||||
|
||||
$offset = ( $page - 1 ) * $max_entries;
|
||||
$estimated_count = max( 0, min( $max_entries, $post_type_totals[ $type ] - $offset ) );
|
||||
} elseif ( $provider instanceof Taxonomy_Provider ) {
|
||||
$estimated_count = $this->count_taxonomy_page( $provider, $type, $max_entries, $page );
|
||||
} elseif ( $provider instanceof Author_Provider ) {
|
||||
$estimated_count = count(
|
||||
(array) $provider->get_users(
|
||||
[
|
||||
'offset' => ( $page - 1 ) * $max_entries,
|
||||
'number' => $max_entries,
|
||||
]
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$estimated_count = $max_entries;
|
||||
}
|
||||
|
||||
$sitemaps[] = [
|
||||
'type' => $type,
|
||||
'url' => $entry['url'],
|
||||
'estimated_count' => $estimated_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $sitemaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Local SEO sitemap entry, if the Local Sitemap is active.
|
||||
*
|
||||
* Mirrors the conditions in RankMath\Local_Seo\Local_Seo::location_sitemap(),
|
||||
* which is what actually decides whether local-sitemap.xml gets served.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function get_local_sitemap(): ?array {
|
||||
if (
|
||||
! Helper::is_module_active( 'sitemap' ) ||
|
||||
! Helper::is_module_active( 'local-seo' ) ||
|
||||
'company' !== Helper::get_settings( 'titles.knowledgegraph_type' ) ||
|
||||
! apply_filters( 'rank_math/sitemap/locations', false ) // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$locations = apply_filters( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
|
||||
'rank_math/sitemap/locations/data',
|
||||
[ [ 'name' => Helper::get_settings( 'titles.knowledgegraph_name' ) ] ]
|
||||
);
|
||||
|
||||
return [
|
||||
'type' => 'local',
|
||||
'url' => Router::get_base_url( 'local-sitemap.xml' ),
|
||||
'estimated_count' => is_array( $locations ) ? count( $locations ) : 0,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Real per-page term count for a taxonomy, via Taxonomy_Provider::get_terms().
|
||||
*
|
||||
* @param Taxonomy_Provider $provider Taxonomy provider instance.
|
||||
* @param string $taxonomy Taxonomy slug.
|
||||
* @param int $max_entries Entries per sitemap page.
|
||||
* @param int $current_page Page number (1-indexed).
|
||||
* @return int
|
||||
*/
|
||||
private function count_taxonomy_page( Taxonomy_Provider $provider, string $taxonomy, int $max_entries, int $current_page ): int {
|
||||
$taxonomy_object = get_taxonomy( $taxonomy );
|
||||
if ( ! $taxonomy_object ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return count( (array) $provider->get_terms( $taxonomy_object, $max_entries, $current_page ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON schema for the ability output.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function output_schema(): array {
|
||||
return [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'enabled' => [
|
||||
'type' => 'boolean',
|
||||
'description' => esc_html__( 'Whether the XML sitemap module is active.', 'seo-by-rank-math' ),
|
||||
],
|
||||
'index_url' => [
|
||||
'type' => 'string',
|
||||
'description' => esc_html__( 'The URL of the sitemap index file.', 'seo-by-rank-math' ),
|
||||
],
|
||||
'sitemaps' => [
|
||||
'type' => 'array',
|
||||
'description' => esc_html__( 'The active sitemap types, e.g. post types, taxonomies, and the Local SEO sitemap (PRO adds news/video when active).', 'seo-by-rank-math' ),
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'type' => [ 'type' => 'string' ],
|
||||
'url' => [ 'type' => 'string' ],
|
||||
'estimated_count' => [ 'type' => 'integer' ],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Subscriber for Sitemap abilities.
|
||||
*
|
||||
* @since 1.0.277
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Abilities\Sitemap
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Abilities\Sitemap;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Abilities\Subscriber_Interface;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Registers the Sitemap ability category and its abilities.
|
||||
*/
|
||||
class Subscriber implements Subscriber_Interface {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Ability category slug for Sitemap abilities.
|
||||
*/
|
||||
const CATEGORY_SLUG = 'rank-math-sitemap';
|
||||
|
||||
/**
|
||||
* Shared meta args.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $shared_meta;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $shared_meta Shared meta args from the top-level Abilities class.
|
||||
*/
|
||||
public function __construct( array $shared_meta ) {
|
||||
$this->shared_meta = $shared_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire hooks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void {
|
||||
$this->action( 'wp_abilities_api_categories_init', 'register_category' );
|
||||
$this->action( 'wp_abilities_api_init', 'register_get_sitemap_status' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Sitemap ability category.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_category(): void {
|
||||
\wp_register_ability_category(
|
||||
self::CATEGORY_SLUG,
|
||||
[
|
||||
'label' => esc_html__( 'Sitemap', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__( 'Abilities to inspect the XML sitemap status.', 'seo-by-rank-math' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the rank-math/get-sitemap-status ability.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_get_sitemap_status(): void {
|
||||
( new Get_Sitemap_Status( self::CATEGORY_SLUG, $this->shared_meta ) )->register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
||||
@@ -31,13 +31,14 @@ class KB {
|
||||
'free-account' => 'https://rankmath.com/my-account/',
|
||||
'support' => 'https://rankmath.com/support/',
|
||||
'pro' => 'https://rankmath.com/pricing/',
|
||||
'ai-pricing' => 'https://rankmath.com/ai/pricing/',
|
||||
'site-checkout' => 'https://rankmath.com/site-checkout/',
|
||||
'changelog' => 'https://rankmath.com/changelog/',
|
||||
'changelog-free' => 'https://rankmath.com/changelog/free/',
|
||||
'help-affiliate' => 'https://rankmath.com/affiliates/',
|
||||
'seo-care' => 'https://rankmath.com/services/',
|
||||
'content-ai' => 'https://rankmath.com/content-ai/',
|
||||
'content-ai-pricing-tables' => 'https://rankmath.com/content-ai/?#pricing-tables',
|
||||
'content-ai-pricing-tables' => 'https://rankmath.com/ai/pricing/',
|
||||
'content-ai-restore-credits' => 'https://rankmath.com/kb/how-to-restore-missing-content-ai-credits/',
|
||||
'free-vs-pro' => 'https://rankmath.com/free-vs-pro/',
|
||||
'google-updates' => 'https://rankmath.com/google-updates/',
|
||||
@@ -148,6 +149,7 @@ class KB {
|
||||
'analysis-search-console' => 'https://rankmath.com/kb/seo-analysis/?#search-console-test',
|
||||
'analysis-sitemaps' => 'https://rankmath.com/kb/seo-analysis/?#sitemaps-test',
|
||||
'analysis-auto-update' => 'https://rankmath.com/kb/seo-analysis/?#priority',
|
||||
'llms' => 'https://rankmath.com/kb/llms-txt/',
|
||||
|
||||
// Link Genius.
|
||||
'link-genius' => 'https://rankmath.com/kb/wordpress/ai-link-genius/',
|
||||
|
||||
@@ -140,9 +140,9 @@ trait Content_AI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get Content AI Plan.
|
||||
* Function to get Rank Math AI Plan.
|
||||
*
|
||||
* @return string Content AI Plan.
|
||||
* @return string Rank Math AI Plan.
|
||||
*/
|
||||
public static function get_content_ai_plan() {
|
||||
$credits_data = get_option( self::$credits_key, [] );
|
||||
@@ -487,6 +487,140 @@ trait Content_AI {
|
||||
return ! empty( $languages ) ? current( array_keys( $languages ) ) : 'US English';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the list of supported languages.
|
||||
*
|
||||
* @return array Supported languages.
|
||||
*/
|
||||
public static function get_content_ai_languages() {
|
||||
return [
|
||||
[
|
||||
'name' => 'US English',
|
||||
'icon' => '🇺🇸',
|
||||
],
|
||||
[
|
||||
'name' => 'UK English',
|
||||
'icon' => '🇬🇧',
|
||||
],
|
||||
[
|
||||
'name' => 'Arabic',
|
||||
'icon' => '🇦🇪',
|
||||
],
|
||||
[
|
||||
'name' => 'Bulgarian',
|
||||
'icon' => '🇧🇬',
|
||||
],
|
||||
[
|
||||
'name' => 'Chinese',
|
||||
'icon' => '🇨🇳',
|
||||
],
|
||||
[
|
||||
'name' => 'Czech',
|
||||
'icon' => '🇨🇿',
|
||||
],
|
||||
[
|
||||
'name' => 'Danish',
|
||||
'icon' => '🇩🇰',
|
||||
],
|
||||
[
|
||||
'name' => 'Dutch',
|
||||
'icon' => '🇳🇱',
|
||||
],
|
||||
[
|
||||
'name' => 'Estonian',
|
||||
'icon' => '🇪🇪',
|
||||
],
|
||||
[
|
||||
'name' => 'Finnish',
|
||||
'icon' => '🇫🇮',
|
||||
],
|
||||
[
|
||||
'name' => 'French',
|
||||
'icon' => '🇫🇷',
|
||||
],
|
||||
[
|
||||
'name' => 'German',
|
||||
'icon' => '🇩🇪',
|
||||
],
|
||||
[
|
||||
'name' => 'Greek',
|
||||
'icon' => '🇬🇷',
|
||||
],
|
||||
[
|
||||
'name' => 'Hebrew',
|
||||
'icon' => '🇮🇱',
|
||||
],
|
||||
[
|
||||
'name' => 'Hungarian',
|
||||
'icon' => '🇭🇺',
|
||||
],
|
||||
[
|
||||
'name' => 'Indonesian',
|
||||
'icon' => '🇮🇩',
|
||||
],
|
||||
[
|
||||
'name' => 'Italian',
|
||||
'icon' => '🇮🇹',
|
||||
],
|
||||
[
|
||||
'name' => 'Japanese',
|
||||
'icon' => '🇯🇵',
|
||||
],
|
||||
[
|
||||
'name' => 'Korean',
|
||||
'icon' => '🇰🇷',
|
||||
],
|
||||
[
|
||||
'name' => 'Latvian',
|
||||
'icon' => '🇱🇻',
|
||||
],
|
||||
[
|
||||
'name' => 'Lithuanian',
|
||||
'icon' => '🇱🇹',
|
||||
],
|
||||
[
|
||||
'name' => 'Norwegian',
|
||||
'icon' => '🇳🇴',
|
||||
],
|
||||
[
|
||||
'name' => 'Polish',
|
||||
'icon' => '🇵🇱',
|
||||
],
|
||||
[
|
||||
'name' => 'Portuguese',
|
||||
'icon' => '🇵🇹',
|
||||
],
|
||||
[
|
||||
'name' => 'Romanian',
|
||||
'icon' => '🇷🇴',
|
||||
],
|
||||
[
|
||||
'name' => 'Russian',
|
||||
'icon' => '🇷🇺',
|
||||
],
|
||||
[
|
||||
'name' => 'Slovak',
|
||||
'icon' => '🇸🇰',
|
||||
],
|
||||
[
|
||||
'name' => 'Slovenian',
|
||||
'icon' => '🇸🇮',
|
||||
],
|
||||
[
|
||||
'name' => 'Spanish',
|
||||
'icon' => '🇪🇸',
|
||||
],
|
||||
[
|
||||
'name' => 'Swedish',
|
||||
'icon' => '🇸🇪',
|
||||
],
|
||||
[
|
||||
'name' => 'Turkish',
|
||||
'icon' => '🇹🇷',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get different error codes we get from the API
|
||||
*
|
||||
@@ -496,7 +630,7 @@ trait Content_AI {
|
||||
return [
|
||||
'not_connected' => esc_html__( 'Please connect your account to use the Content AI.', 'seo-by-rank-math' ),
|
||||
'plugin_update_required' => esc_html__( 'Please update the Rank Math SEO plugin to the latest version to use this feature.', 'seo-by-rank-math' ),
|
||||
'upgrade_required' => esc_html__( 'This feature is only available for Content AI subscribers.', 'seo-by-rank-math' ),
|
||||
'upgrade_required' => esc_html__( 'This feature is only available for Rank Math AI subscribers.', 'seo-by-rank-math' ),
|
||||
'rate_limit_exceeded' => esc_html__( 'Oops! Too many requests in a short time. Please try again after some time.', 'seo-by-rank-math' ),
|
||||
'domain_limit_reached' => esc_html__( 'You\'ve reached the monthly usage limit for this feature on your domain.', 'seo-by-rank-math' ),
|
||||
'account_limit_reached' => esc_html__( 'You\'ve reached the monthly usage limit for this feature.', 'seo-by-rank-math' ),
|
||||
|
||||
@@ -179,6 +179,55 @@ class Sitepress {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permalink for a post, resolved in the post's own language.
|
||||
*
|
||||
* Temporarily switches WPML's active language to the post's language before
|
||||
* calling get_permalink(), then restores it. This avoids returning the wrong
|
||||
* language's URL when the active request language differs from the post's
|
||||
* language, e.g. in background/async jobs or REST/MCP requests. For
|
||||
* separate-domain installs, the scheme+host is also stripped so the caller
|
||||
* can rebuild the URL against the correct language domain.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_permalink( $post_id ) {
|
||||
if ( ! $this->is_active() ) {
|
||||
return get_permalink( $post_id );
|
||||
}
|
||||
|
||||
$sitepress = $this->get_var();
|
||||
|
||||
$details = apply_filters( 'wpml_post_language_details', null, $post_id );
|
||||
$code = $details['language_code'] ?? '';
|
||||
$current = $sitepress->get_current_language();
|
||||
$switched = $code && $code !== $current;
|
||||
|
||||
if ( $switched ) {
|
||||
$sitepress->switch_lang( $code, true );
|
||||
}
|
||||
|
||||
try {
|
||||
$permalink = get_permalink( $post_id );
|
||||
} finally {
|
||||
if ( $switched ) {
|
||||
$sitepress->switch_lang( $current, true );
|
||||
}
|
||||
}
|
||||
|
||||
$language_domains = $sitepress->get_setting( 'language_domains', [] );
|
||||
if ( $language_domains ) {
|
||||
$permalink = apply_filters( 'wpml_permalink', $permalink, $code );
|
||||
foreach ( $language_domains as $domain ) {
|
||||
$permalink = preg_replace( "#https?://{$domain}#i", '', $permalink );
|
||||
}
|
||||
}
|
||||
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is per domain negotiation type.
|
||||
*
|
||||
|
||||
@@ -233,12 +233,13 @@ class Manager {
|
||||
];
|
||||
|
||||
$modules['ai-visibility'] = [
|
||||
'title' => esc_html__( 'AI Visibility', 'seo-by-rank-math' ),
|
||||
'desc' => esc_html__( 'Track your brand\'s AI search visibility. Monitor brand mentions, citations, & sentiment, and discover opportunities to grow your AI visibility.', 'seo-by-rank-math' ),
|
||||
'icon' => 'ai-visibility',
|
||||
'class' => 'RankMath\AI_Visibility\AI_Visibility',
|
||||
'settings' => Helper::get_admin_url( 'ai-visibility' ),
|
||||
'betabadge' => true,
|
||||
'title' => esc_html__( 'AI Visibility', 'seo-by-rank-math' ),
|
||||
'desc' => esc_html__( 'Track your brand\'s AI search visibility. Monitor brand mentions, citations, & sentiment, and discover opportunities to grow your AI visibility.', 'seo-by-rank-math' ),
|
||||
'icon' => 'ai-visibility',
|
||||
'class' => 'RankMath\AI_Visibility\AI_Visibility',
|
||||
'settings' => Helper::get_admin_url( 'ai-visibility' ),
|
||||
'betabadge' => true,
|
||||
'upgradeable' => true,
|
||||
];
|
||||
|
||||
return $modules;
|
||||
@@ -453,7 +454,7 @@ class Manager {
|
||||
<?php } ?>
|
||||
<?php if ( $is_upgradeable && ! $is_pro_active ) { ?>
|
||||
<span class="is-upgradeable rank-math-tooltip">
|
||||
<a href="<?php KB::the( 'pro', esc_html( $module->get( 'title' ) ) . ' Module Upgradable Icon' ); ?>">
|
||||
<a href="<?php KB::the( in_array( $key, [ 'content-ai', 'ai-visibility' ], true ) ? 'ai-pricing' : 'pro', esc_html( $module->get( 'title' ) ) . ' Module Upgradable Icon' ); ?>">
|
||||
<div>«</div>
|
||||
</a>
|
||||
<span><?php echo esc_html__( 'More powerful options are available in the PRO version.', 'seo-by-rank-math' ); ?></span>
|
||||
@@ -562,7 +563,7 @@ class Manager {
|
||||
<h3><?php esc_html_e( 'Take SEO to the Next Level!', 'seo-by-rank-math' ); ?></h3>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Unlimited personal websites', 'seo-by-rank-math' ); ?></li>
|
||||
<li><?php esc_html_e( 'Free 15-Day Content AI Trial', 'seo-by-rank-math' ); ?></li>
|
||||
<li><?php esc_html_e( 'Free 15-day Rank Math AI Trial', 'seo-by-rank-math' ); ?></li>
|
||||
<li><?php esc_html_e( 'Track 500 Keywords', 'seo-by-rank-math' ); ?></li>
|
||||
<li><?php esc_html_e( 'Powerful Schema Generator', 'seo-by-rank-math' ); ?></li>
|
||||
<li><?php esc_html_e( '24/7 Support', 'seo-by-rank-math' ); ?></li>
|
||||
|
||||
+37
@@ -15,6 +15,7 @@ use RankMath\Traits\Hooker;
|
||||
use RankMath\Admin\Page;
|
||||
use RankMath\Admin\Admin_Helper;
|
||||
use RankMath\Helpers\Param;
|
||||
use RankMath\AI_Visibility\Api\Brands_Controller;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
@@ -90,6 +91,10 @@ class Admin {
|
||||
'isSiteUrlValid' => Admin_Helper::is_site_url_valid(),
|
||||
'isPro' => defined( 'RANK_MATH_PRO_FILE' ),
|
||||
'plan' => Helper::get_content_ai_plan(),
|
||||
'languages' => Helper::get_content_ai_languages(),
|
||||
'defaultLanguage' => Helper::content_ai_default_language(),
|
||||
'platforms' => Platforms::all(),
|
||||
'maxPlatforms' => Platforms::max_selectable(),
|
||||
'locales' => array_values(
|
||||
array_filter(
|
||||
array_map(
|
||||
@@ -111,6 +116,7 @@ class Admin {
|
||||
)
|
||||
)
|
||||
),
|
||||
'intervals' => $this->get_intervals(),
|
||||
],
|
||||
],
|
||||
],
|
||||
@@ -118,6 +124,37 @@ class Admin {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available intervals for AI Visibility.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_intervals() {
|
||||
$allowed = Brands_Controller::get_allowed_intervals();
|
||||
|
||||
$intervals = [
|
||||
[
|
||||
'label' => esc_html__( 'Daily', 'seo-by-rank-math' ),
|
||||
'value' => 'daily',
|
||||
],
|
||||
[
|
||||
'label' => esc_html__( 'Weekly', 'seo-by-rank-math' ),
|
||||
'value' => 'weekly',
|
||||
],
|
||||
[
|
||||
'label' => esc_html__( 'Monthly', 'seo-by-rank-math' ),
|
||||
'value' => 'monthly',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ( $intervals as &$interval ) {
|
||||
$interval['disabled'] = ! in_array( $interval['value'], $allowed, true );
|
||||
}
|
||||
unset( $interval );
|
||||
|
||||
return $intervals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue Mixpanel script and inject tracking data for JS events on this page.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ abstract class Base_Controller extends WP_REST_Controller {
|
||||
$args['body'] = wp_json_encode( $body );
|
||||
}
|
||||
|
||||
$url = 'https://ai-visibility.rankmath.com/' . ltrim( $path, '/' );
|
||||
$url = RANK_MATH_AIV_URL . '/' . ltrim( $path, '/' );
|
||||
$response = wp_remote_request( $url, $args );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
|
||||
+207
-46
@@ -14,7 +14,9 @@ namespace RankMath\AI_Visibility\Api;
|
||||
|
||||
use WP_REST_Server;
|
||||
use WP_REST_Request;
|
||||
use RankMath\Helper;
|
||||
use RankMath\AI_Visibility\Cache;
|
||||
use RankMath\AI_Visibility\Platforms;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
@@ -28,6 +30,66 @@ class Brands_Controller extends Base_Controller {
|
||||
*/
|
||||
const BRAND_ID_PATTERN = '(?P<id>[a-zA-Z0-9\-]+)';
|
||||
|
||||
/**
|
||||
* Allowed values for the `language` request param.
|
||||
*
|
||||
* @param bool $allow_empty Whether '' (no value) is a valid choice.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_language_choices( bool $allow_empty = true ): array {
|
||||
$names = wp_list_pluck( Helper::get_content_ai_languages(), 'name' );
|
||||
return $allow_empty ? array_merge( [ '' ], $names ) : $names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed values for the `interval` request param.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_interval_choices(): array {
|
||||
return [ 'daily', 'weekly', 'monthly' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cadences allowed for a given AI Visibility plan.
|
||||
*
|
||||
* @param string|null $plan Plan slug. Defaults to the current account's plan.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_allowed_intervals( ?string $plan = null ): array {
|
||||
$plan = $plan ?? Helper::get_content_ai_plan();
|
||||
|
||||
return 'expert' === $plan
|
||||
? [ 'daily', 'weekly', 'monthly' ]
|
||||
: [ 'weekly', 'monthly' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject an `interval` value the caller's plan does not allow.
|
||||
*
|
||||
* @param string $interval Requested cadence value.
|
||||
*
|
||||
* @return \WP_Error|true
|
||||
*/
|
||||
private function check_interval_allowed( string $interval ) {
|
||||
$allowed = self::get_allowed_intervals();
|
||||
if ( in_array( $interval, $allowed, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->error(
|
||||
'aiv_frequency_not_allowed',
|
||||
sprintf(
|
||||
/* translators: %s: comma-separated list of allowed cadences. */
|
||||
__( 'The selected analysis frequency is not available on your plan. Allowed frequencies: %s. Upgrade your plan to unlock more frequency options.', 'seo-by-rank-math' ),
|
||||
implode( ', ', $allowed )
|
||||
),
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register routes.
|
||||
*/
|
||||
@@ -114,6 +176,23 @@ class Brands_Controller extends Base_Controller {
|
||||
'required' => false,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
],
|
||||
'language' => [
|
||||
'description' => esc_html__( 'Output language to use when analyzing/generating content for this brand. Independent of `locale` (target country). Required; immutable after creation.', 'seo-by-rank-math' ),
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'enum' => self::get_language_choices( false ),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
],
|
||||
'interval' => [
|
||||
'description' => esc_html__( 'Analysis refresh cadence. Omitted → backend applies the account plan\'s default.', 'seo-by-rank-math' ),
|
||||
'type' => 'string',
|
||||
'required' => false,
|
||||
'enum' => self::get_interval_choices(),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
],
|
||||
'platforms' => Platforms::rest_arg( true ),
|
||||
],
|
||||
]
|
||||
);
|
||||
@@ -149,20 +228,33 @@ class Brands_Controller extends Base_Controller {
|
||||
'required' => false,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
],
|
||||
'language' => [
|
||||
'type' => 'string',
|
||||
'required' => false,
|
||||
'enum' => self::get_language_choices(),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
],
|
||||
'status' => [
|
||||
'type' => 'string',
|
||||
'required' => false,
|
||||
'enum' => [ 'active', 'inactive' ],
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
],
|
||||
'interval' => [
|
||||
'type' => 'string',
|
||||
'required' => false,
|
||||
'enum' => self::get_interval_choices(),
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
],
|
||||
'platforms' => Platforms::rest_arg( false ),
|
||||
]
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
// GET /brands/{id}/insights — full latest-analysis payload
|
||||
// (competitors + transcripts). Cache-first; the only proxy route that
|
||||
// may call the upstream analyses/results endpoint.
|
||||
// GET /brands/{id}/insights — full latest-analysis payload (competitors + transcripts).
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
'/brands/' . self::BRAND_ID_PATTERN . '/insights',
|
||||
@@ -244,15 +336,12 @@ class Brands_Controller extends Base_Controller {
|
||||
return $this->overview_response( $cached, false, $search );
|
||||
}
|
||||
|
||||
// Stale-while-revalidate: serve stale immediately; the client
|
||||
// fires a background `refresh=1` request on seeing `is_stale`.
|
||||
return $this->overview_response( $cached, true, $search );
|
||||
}
|
||||
|
||||
$result = $this->remote_request( 'GET', '/api/v1/overview' );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
// Serve stale cache on upstream failure rather than erroring out.
|
||||
if ( null !== $cached ) {
|
||||
return $this->overview_response( $cached, true, $search );
|
||||
}
|
||||
@@ -276,9 +365,6 @@ class Brands_Controller extends Base_Controller {
|
||||
/**
|
||||
* Map an /overview brand item (API shape) to the UI row shape.
|
||||
*
|
||||
* Note: `description` is not returned by /overview — it is fetched
|
||||
* lazily and cached per brand via `get_brand()`.
|
||||
*
|
||||
* @param array $brand Raw brand item.
|
||||
*
|
||||
* @return array
|
||||
@@ -289,7 +375,10 @@ class Brands_Controller extends Base_Controller {
|
||||
'name' => $brand['name'] ?? '',
|
||||
'url' => $brand['url'] ?? '',
|
||||
'locale' => $brand['country_code'] ?? null,
|
||||
'language' => $brand['language'] ?? null,
|
||||
'status' => ! empty( $brand['active'] ) ? 'active' : 'inactive',
|
||||
'interval' => $brand['analysis_frequency'] ?? null,
|
||||
'platforms' => Platforms::sanitize( $brand['platforms'] ?? [] ),
|
||||
'score' => $brand['ai_visibility_score'] ?? null,
|
||||
'rank' => $brand['rank'] ?? null,
|
||||
'avg_sentiment' => $brand['avg_sentiment'] ?? null,
|
||||
@@ -303,9 +392,7 @@ class Brands_Controller extends Base_Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the dashboard response envelope, applying the optional search
|
||||
* filter (name/URL) against the stored rows. The filter never affects
|
||||
* what is cached — only what is returned.
|
||||
* Build the dashboard response envelope, applying the optional search filter.
|
||||
*
|
||||
* @param array $data Cached dashboard payload.
|
||||
* @param bool $is_stale Whether the payload is past its TTL.
|
||||
@@ -352,8 +439,7 @@ class Brands_Controller extends Base_Controller {
|
||||
return $this->success( [ 'brand' => $cached ] );
|
||||
}
|
||||
|
||||
// /overview omits `description`, so the single-brand endpoint is the
|
||||
// canonical source for full identity. Fetched once, then cached.
|
||||
// /overview omits `description`; fetch full identity once and cache it.
|
||||
$result = $this->remote_request( 'GET', '/api/v1/brands/' . $uuid );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
@@ -375,17 +461,48 @@ class Brands_Controller extends Base_Controller {
|
||||
* @return \WP_REST_Response|\WP_Error
|
||||
*/
|
||||
public function create_brand( $request ) {
|
||||
$locale = $request->get_param( 'locale' );
|
||||
$result = $this->remote_request(
|
||||
'POST',
|
||||
'/api/v1/brands',
|
||||
[
|
||||
'name' => sanitize_text_field( (string) $request->get_param( 'name' ) ),
|
||||
'url' => esc_url_raw( (string) $request->get_param( 'url' ) ),
|
||||
'description' => sanitize_textarea_field( (string) $request->get_param( 'description' ) ),
|
||||
'country_code' => $locale ? strtoupper( (string) $locale ) : '',
|
||||
]
|
||||
);
|
||||
$locale = $request->get_param( 'locale' );
|
||||
$language = $request->get_param( 'language' );
|
||||
$interval = $request->get_param( 'interval' );
|
||||
$platforms = $request->get_param( 'platforms' );
|
||||
|
||||
// Re-validate: the create-brand ability bypasses the REST arg constraints.
|
||||
$valid = Platforms::validate( $platforms );
|
||||
if ( is_wp_error( $valid ) ) {
|
||||
return $valid;
|
||||
}
|
||||
|
||||
$platforms = Platforms::sanitize( $platforms );
|
||||
|
||||
if ( ! $language ) {
|
||||
return $this->error(
|
||||
'aiv_bad_request',
|
||||
__( 'Please select a language for this brand.', 'seo-by-rank-math' ),
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
$body = [
|
||||
'name' => sanitize_text_field( (string) $request->get_param( 'name' ) ),
|
||||
'url' => esc_url_raw( (string) $request->get_param( 'url' ) ),
|
||||
'description' => sanitize_textarea_field( (string) $request->get_param( 'description' ) ),
|
||||
'language' => (string) $language,
|
||||
'platforms' => $platforms,
|
||||
];
|
||||
|
||||
// Omit rather than send '' — the backend rejects an explicit empty string.
|
||||
if ( $locale ) {
|
||||
$body['country_code'] = strtoupper( (string) $locale );
|
||||
}
|
||||
if ( $interval ) {
|
||||
$allowed = $this->check_interval_allowed( $interval );
|
||||
if ( is_wp_error( $allowed ) ) {
|
||||
return $allowed;
|
||||
}
|
||||
$body['analysis_frequency'] = (string) $interval;
|
||||
}
|
||||
|
||||
$result = $this->remote_request( 'POST', '/api/v1/brands', $body );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
@@ -394,9 +511,7 @@ class Brands_Controller extends Base_Controller {
|
||||
$brand = $this->map_brand( $result );
|
||||
$uuid = $brand['id'];
|
||||
|
||||
// Prime caches from the create response. Creation atomically seeds a
|
||||
// pending analysis, so the row starts as `pending` (no last_analyzed) —
|
||||
// this is what makes it eligible for the first-analysis poller.
|
||||
// Row starts as `pending` — creation atomically seeds the first analysis.
|
||||
Cache::append_brand_row(
|
||||
array_merge(
|
||||
$brand,
|
||||
@@ -421,8 +536,9 @@ class Brands_Controller extends Base_Controller {
|
||||
'AI Visibility Brand Created',
|
||||
[
|
||||
'locale' => $brand['locale'] ?? null,
|
||||
'interval' => 'weekly',
|
||||
'platforms' => [ 'chatgpt' ],
|
||||
'language' => $brand['language'] ?? null,
|
||||
'interval' => $brand['interval'] ?? null,
|
||||
'platforms' => $platforms,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -460,6 +576,31 @@ class Brands_Controller extends Base_Controller {
|
||||
$body['country_code'] = strtoupper( sanitize_text_field( $locale ) );
|
||||
}
|
||||
|
||||
// Omit blank values — the backend rejects an explicit empty string.
|
||||
$language = $request->get_param( 'language' );
|
||||
if ( $language ) {
|
||||
$body['language'] = sanitize_text_field( $language );
|
||||
}
|
||||
|
||||
$interval = $request->get_param( 'interval' );
|
||||
if ( null !== $interval ) {
|
||||
$allowed = $this->check_interval_allowed( $interval );
|
||||
if ( is_wp_error( $allowed ) ) {
|
||||
return $allowed;
|
||||
}
|
||||
$body['analysis_frequency'] = sanitize_text_field( $interval );
|
||||
}
|
||||
|
||||
$platforms = $request->get_param( 'platforms' );
|
||||
if ( null !== $platforms ) {
|
||||
$valid = Platforms::validate( $platforms );
|
||||
if ( is_wp_error( $valid ) ) {
|
||||
return $valid;
|
||||
}
|
||||
|
||||
$body['platforms'] = Platforms::sanitize( $platforms );
|
||||
}
|
||||
|
||||
if ( empty( $body ) ) {
|
||||
return $this->error( 'aiv_bad_request', __( 'No fields to update.', 'seo-by-rank-math' ), 400 );
|
||||
}
|
||||
@@ -472,7 +613,6 @@ class Brands_Controller extends Base_Controller {
|
||||
|
||||
$brand = $this->map_brand( isset( $result['data'] ) ? $result['data'] : $result );
|
||||
|
||||
// Write-through: patch the dashboard row, replace the identity transient.
|
||||
Cache::patch_brand_row(
|
||||
$uuid,
|
||||
[
|
||||
@@ -480,7 +620,10 @@ class Brands_Controller extends Base_Controller {
|
||||
'url' => $brand['url'],
|
||||
'description' => $brand['description'],
|
||||
'locale' => $brand['locale'],
|
||||
'language' => $brand['language'],
|
||||
'status' => $brand['status'],
|
||||
'interval' => $brand['interval'],
|
||||
'platforms' => $brand['platforms'],
|
||||
]
|
||||
);
|
||||
Cache::set_brand( $uuid, $brand );
|
||||
@@ -492,6 +635,8 @@ class Brands_Controller extends Base_Controller {
|
||||
'fields_changed' => array_keys( $body ),
|
||||
'status_changed' => $status_changed,
|
||||
'new_status' => $status_changed ? $brand['status'] : null,
|
||||
'platforms' => $brand['platforms'],
|
||||
'language' => $brand['language'] ?? null,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -512,9 +657,12 @@ class Brands_Controller extends Base_Controller {
|
||||
'url' => $brand['url'] ?? '',
|
||||
'description' => $brand['description'] ?? '',
|
||||
'locale' => $brand['country_code'] ?? null,
|
||||
'language' => $brand['language'] ?? null,
|
||||
'status' => $brand['status'] ?? 'active',
|
||||
'interval' => $brand['analysis_frequency'] ?? null,
|
||||
'last_analyzed' => $brand['last_analyzed_at'] ?? null,
|
||||
'created_at' => $brand['created_at'] ?? null,
|
||||
'platforms' => Platforms::sanitize( $brand['platforms'] ?? [] ),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -568,15 +716,22 @@ class Brands_Controller extends Base_Controller {
|
||||
);
|
||||
|
||||
// Keep the dashboard row's summary in sync (poller success path).
|
||||
$finished_ats = array_filter( array_column( $insights['analyses'], 'finished_at' ) );
|
||||
|
||||
// Resolve status here rather than relying on /overview, which can lag.
|
||||
$analysis_statuses = array_column( $insights['analyses'], 'status' );
|
||||
$analysis_status = in_array( 'error', $analysis_statuses, true ) ? 'error' : 'success';
|
||||
|
||||
Cache::patch_brand_row(
|
||||
$uuid,
|
||||
[
|
||||
'score' => $insights['score'],
|
||||
'rank' => $insights['rank'],
|
||||
'avg_sentiment' => $insights['avg_sentiment'],
|
||||
'mentions' => $insights['mentions'],
|
||||
'citations' => $insights['citations'],
|
||||
'last_analyzed' => $insights['analysis']['finished_at'],
|
||||
'score' => $insights['score'],
|
||||
'rank' => $insights['rank'],
|
||||
'avg_sentiment' => $insights['avg_sentiment'],
|
||||
'mentions' => $insights['mentions'],
|
||||
'citations' => $insights['citations'],
|
||||
'last_analyzed' => $finished_ats ? max( $finished_ats ) : null,
|
||||
'analysis_status' => $analysis_status,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -591,7 +746,7 @@ class Brands_Controller extends Base_Controller {
|
||||
* @return array
|
||||
*/
|
||||
private function map_insights( $result ) {
|
||||
$analysis = isset( $result['analysis'] ) ? (array) $result['analysis'] : [];
|
||||
$analyses = isset( $result['analyses'] ) ? (array) $result['analyses'] : [];
|
||||
|
||||
return [
|
||||
'score' => $result['ai_visibility_score'] ?? null,
|
||||
@@ -599,14 +754,19 @@ class Brands_Controller extends Base_Controller {
|
||||
'avg_sentiment' => $result['avg_sentiment'] ?? null,
|
||||
'mentions' => $result['mentions'] ?? null,
|
||||
'citations' => $result['citations'] ?? null,
|
||||
'analysis' => [
|
||||
'id' => $analysis['uuid'] ?? null,
|
||||
// Map the API status vocabulary to the UI one (`success` → `done`).
|
||||
'status' => isset( $analysis['status'] ) && 'success' === $analysis['status'] ? 'done' : ( $analysis['status'] ?? null ),
|
||||
'started_at' => $analysis['started_at'] ?? null,
|
||||
'finished_at' => $analysis['finished_at'] ?? null,
|
||||
'duration_seconds' => $analysis['duration_seconds'] ?? null,
|
||||
],
|
||||
'analyses' => array_map(
|
||||
function ( $analysis ) {
|
||||
return [
|
||||
'id' => $analysis['uuid'] ?? null,
|
||||
'platform' => $analysis['platform'] ?? null,
|
||||
'status' => isset( $analysis['status'] ) && 'success' === $analysis['status'] ? 'done' : ( $analysis['status'] ?? null ),
|
||||
'started_at' => $analysis['started_at'] ?? null,
|
||||
'finished_at' => $analysis['finished_at'] ?? null,
|
||||
'duration_seconds' => $analysis['duration_seconds'] ?? null,
|
||||
];
|
||||
},
|
||||
$analyses
|
||||
),
|
||||
'competitors' => array_map(
|
||||
function ( $competitor ) {
|
||||
return [
|
||||
@@ -623,6 +783,7 @@ class Brands_Controller extends Base_Controller {
|
||||
return [
|
||||
'query_id' => $query_result['query_uuid'] ?? null,
|
||||
'query_text' => $query_result['query_text'] ?? '',
|
||||
'platform' => $query_result['platform'] ?? null,
|
||||
'found' => ! empty( $query_result['found'] ),
|
||||
'rank' => $query_result['rank_among_competitors'] ?? null,
|
||||
'sentiment' => $query_result['sentiment_score'] ?? null,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+10
-10
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { useMemo, useState, useEffect } from '@wordpress/element'
|
||||
import { useMemo, useState, useEffect, useRef } from '@wordpress/element'
|
||||
import { __ } from '@wordpress/i18n'
|
||||
import { SelectControl, SearchControl, Button } from '@wordpress/components'
|
||||
|
||||
@@ -43,28 +43,31 @@ const AnalysesFilterBar = ( {
|
||||
} ) => {
|
||||
const ns = 'rank-math-ai-visibility-analyses-filter-bar'
|
||||
|
||||
// Prepend "All Brands" option to the brand list.
|
||||
const brandSelectOptions = useMemo( () => [
|
||||
{ label: __( 'All Brands', 'seo-by-rank-math' ), value: '' },
|
||||
...brandOptions,
|
||||
], [ brandOptions ] )
|
||||
|
||||
// The hook stores brandIds as an array. For the single-select UI we store
|
||||
// the first item (or '') and convert back on change.
|
||||
// brandIds is an array; the single-select UI only needs the first item.
|
||||
const activeBrandId = ( filters.brandIds && filters.brandIds[ 0 ] )
|
||||
? String( filters.brandIds[ 0 ] )
|
||||
: ''
|
||||
|
||||
// Local search state — debounced 300 ms before propagating to the hook.
|
||||
// This prevents a new API request on every keystroke.
|
||||
const [ localSearch, setLocalSearch ] = useState( filters.search || '' )
|
||||
const isFirstSearchRender = useRef( true )
|
||||
|
||||
// Sync local state if the parent resets filters externally (e.g. "clear all").
|
||||
// Sync when the parent resets filters externally (e.g. "clear all").
|
||||
useEffect( () => {
|
||||
setLocalSearch( filters.search || '' )
|
||||
}, [ filters.search ] )
|
||||
|
||||
// Skip on mount — avoids a no-op filter change resetting pagination.
|
||||
useEffect( () => {
|
||||
if ( isFirstSearchRender.current ) {
|
||||
isFirstSearchRender.current = false
|
||||
return
|
||||
}
|
||||
|
||||
const timer = setTimeout( () => {
|
||||
onFilterChange( { search: localSearch } )
|
||||
}, 300 )
|
||||
@@ -82,7 +85,6 @@ const AnalysesFilterBar = ( {
|
||||
return (
|
||||
<div className={ ns }>
|
||||
|
||||
{ /* Brand — standard SelectControl, matches Status style */ }
|
||||
<SelectControl
|
||||
className={ `${ ns }__brand` }
|
||||
value={ activeBrandId }
|
||||
@@ -102,7 +104,6 @@ const AnalysesFilterBar = ( {
|
||||
__nextHasNoMarginBottom={ true }
|
||||
/>
|
||||
|
||||
{ /* Search — value bound to local state; propagation is debounced 300 ms */ }
|
||||
<SearchControl
|
||||
className={ `${ ns }__search` }
|
||||
placeholder={ __( 'Search', 'seo-by-rank-math' ) }
|
||||
@@ -123,7 +124,6 @@ const AnalysesFilterBar = ( {
|
||||
</Button>
|
||||
) }
|
||||
|
||||
{ /* Date range: [📅 From] - [📅 To] */ }
|
||||
<div className={ `${ ns }__dates` }>
|
||||
<div className={ `${ ns }__date-wrap` }>
|
||||
<DateInput
|
||||
|
||||
+27
-15
@@ -26,20 +26,28 @@ import './AnalysisRunDetail.scss'
|
||||
/**
|
||||
* Map an insights query result to the shape TranscriptModal expects.
|
||||
*
|
||||
* The id is qualified by platform — the backend reuses the same query_id
|
||||
* across platforms, so an unqualified id would collide.
|
||||
*
|
||||
* @param {Object} result Query result from the insights payload.
|
||||
* @param {number} index Fallback index.
|
||||
* @param {Object} analysis Parent analysis meta.
|
||||
* @param {Object} analysis Analysis run (matched by platform) this result belongs to.
|
||||
* @return {Object} Normalised entry.
|
||||
*/
|
||||
const normalise = ( result, index, analysis ) => ( {
|
||||
...result,
|
||||
id: result.query_id ?? index,
|
||||
query: result.query_text ?? '',
|
||||
response: result.response ?? '',
|
||||
created_at: analysis?.finished_at ?? null,
|
||||
duration_seconds: analysis?.duration_seconds ?? null,
|
||||
model: null,
|
||||
} )
|
||||
const normalise = ( result, index, analysis ) => {
|
||||
const baseId = result.query_id ?? index
|
||||
const platform = result.platform ?? 'default'
|
||||
|
||||
return {
|
||||
...result,
|
||||
id: `${ baseId }-${ platform }`,
|
||||
query: result.query_text ?? '',
|
||||
response: result.response ?? '',
|
||||
created_at: analysis?.finished_at ?? null,
|
||||
duration_seconds: analysis?.duration_seconds ?? null,
|
||||
model: null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AnalysisRunDetail component.
|
||||
@@ -60,10 +68,14 @@ const AnalysisRunDetail = ( { row, onBack } ) => {
|
||||
const insights = insightsData?.insights ?? null
|
||||
const [ modalEntry, setModalEntry ] = useState( null )
|
||||
|
||||
const transcripts = ( insights?.query_results ?? [] ).map( ( result, i ) => normalise( result, i, insights?.analysis ) )
|
||||
const totalDuration = insights?.analysis?.duration_seconds ?? 0
|
||||
const analyses = insights?.analyses ?? []
|
||||
const findAnalysis = ( platform ) => analyses.find( ( analysis ) => analysis.platform === platform ) ?? analyses[ 0 ] ?? null
|
||||
|
||||
const transcripts = ( insights?.query_results ?? [] ).map( ( result, i ) => normalise( result, i, findAnalysis( result.platform ) ) )
|
||||
const totalDuration = analyses.reduce( ( sum, analysis ) => sum + ( analysis.duration_seconds ?? 0 ), 0 )
|
||||
const durationLabel = totalDuration ? `${ totalDuration }s` : '—'
|
||||
const startedAt = row?.started_at ?? insights?.analysis?.started_at
|
||||
const startedAts = analyses.map( ( analysis ) => analysis.started_at ).filter( Boolean ).sort()
|
||||
const startedAt = row?.started_at ?? startedAts[ 0 ]
|
||||
|
||||
const handleExportReport = () => navigateToReportsTab( row.id )
|
||||
|
||||
@@ -94,7 +106,7 @@ const AnalysisRunDetail = ( { row, onBack } ) => {
|
||||
value={ row?.brand_name || '—' }
|
||||
className="rank-math-ai-visibility-stat-card--target-brand"
|
||||
tooltip={ __( 'The brand this analysis run is for.', 'seo-by-rank-math' ) }
|
||||
analysis={ insights?.analysis }
|
||||
analysis={ analyses[ 0 ] ?? null }
|
||||
/>
|
||||
|
||||
<StatCard
|
||||
@@ -105,7 +117,7 @@ const AnalysisRunDetail = ( { row, onBack } ) => {
|
||||
sub={ formatShortDate( startedAt ) }
|
||||
className="rank-math-ai-visibility-stat-card--duration-timing"
|
||||
tooltip={ __( 'Total duration of all queries in this run, and the date it was started.', 'seo-by-rank-math' ) }
|
||||
analysis={ insights?.analysis }
|
||||
analysis={ analyses[ 0 ] ?? null }
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
+14
-25
@@ -20,6 +20,7 @@ import { addQueryArgs } from '@wordpress/url'
|
||||
* Internal dependencies
|
||||
*/
|
||||
import useDashboard from '../shared/hooks/useDashboard'
|
||||
import usePagination from '../shared/hooks/usePagination'
|
||||
import { getAnalysisState } from '../utils/analysisState'
|
||||
import { SectionHeader } from '../shared/components'
|
||||
import AnalysesFilterBar from './AnalysesFilterBar'
|
||||
@@ -36,20 +37,15 @@ const DEFAULT_FILTERS = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync filters + pagination into the URL without reloading.
|
||||
*
|
||||
* @param {Object} filters Active filter bag.
|
||||
* @param {Object} pagination Active pagination.
|
||||
* @param {Object} filters Active filter bag.
|
||||
*/
|
||||
const writeToUrl = ( filters, pagination ) => {
|
||||
const writeFiltersToUrl = ( filters ) => {
|
||||
const params = {
|
||||
aiv_brands: filters.brandIds.length ? filters.brandIds.join( ',' ) : undefined,
|
||||
aiv_status: filters.status || undefined,
|
||||
aiv_search: filters.search || undefined,
|
||||
aiv_from: filters.dateFrom || undefined,
|
||||
aiv_to: filters.dateTo || undefined,
|
||||
aiv_page: pagination.page > 1 ? pagination.page : undefined,
|
||||
aiv_per: pagination.perPage !== 10 ? pagination.perPage : undefined,
|
||||
}
|
||||
|
||||
const url = addQueryArgs( window.location.href, params )
|
||||
@@ -70,8 +66,7 @@ const toRunRow = ( brand ) => {
|
||||
brand_id: brand.id,
|
||||
brand_name: brand.name,
|
||||
started_at: brand.last_analyzed,
|
||||
// Display/filter bucket: running | error | done | none. Same icon
|
||||
// derivation as the Dashboard column, so the two tabs never disagree.
|
||||
// Matches the Dashboard column's derivation, so both tabs agree.
|
||||
status: state ?? ( brand.last_analyzed ? 'done' : 'none' ),
|
||||
}
|
||||
}
|
||||
@@ -85,7 +80,6 @@ const Analyses = () => {
|
||||
const { brands, loading, error } = useDashboard()
|
||||
|
||||
const [ filters, setFilters ] = useState( DEFAULT_FILTERS )
|
||||
const [ pagination, setPagination ] = useState( { page: 1, perPage: 10 } )
|
||||
const [ selectedRow, setSelectedRow ] = useState( null )
|
||||
|
||||
const brandOptions = useMemo(
|
||||
@@ -93,7 +87,6 @@ const Analyses = () => {
|
||||
[ brands ]
|
||||
)
|
||||
|
||||
// Derive + filter rows client-side.
|
||||
const filteredItems = useMemo( () => {
|
||||
return brands.map( toRunRow ).filter( ( item ) => {
|
||||
if ( filters.search && ! item.brand_name.toLowerCase().includes( filters.search.toLowerCase() ) ) {
|
||||
@@ -118,26 +111,22 @@ const Analyses = () => {
|
||||
} )
|
||||
}, [ brands, filters ] )
|
||||
|
||||
const total = filteredItems.length
|
||||
const pages = Math.max( 1, Math.ceil( total / pagination.perPage ) )
|
||||
const pageItems = useMemo( () => {
|
||||
const offset = ( pagination.page - 1 ) * pagination.perPage
|
||||
return filteredItems.slice( offset, offset + pagination.perPage )
|
||||
}, [ filteredItems, pagination ] )
|
||||
const { pagination, pageItems, total, pages, onPageChange, onPerPageChange, resetPage } =
|
||||
usePagination( filteredItems, { perPage: 10, syncUrl: true } )
|
||||
|
||||
const handleFilterChange = useCallback( ( patch ) => {
|
||||
setFilters( ( prev ) => ( { ...prev, ...patch } ) )
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) )
|
||||
}, [] )
|
||||
resetPage()
|
||||
}, [ resetPage ] )
|
||||
|
||||
const handleClearFilters = useCallback( () => {
|
||||
setFilters( DEFAULT_FILTERS )
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) )
|
||||
}, [] )
|
||||
resetPage()
|
||||
}, [ resetPage ] )
|
||||
|
||||
useEffect( () => {
|
||||
writeToUrl( filters, pagination )
|
||||
}, [ filters, pagination ] )
|
||||
writeFiltersToUrl( filters )
|
||||
}, [ filters ] )
|
||||
|
||||
if ( selectedRow ) {
|
||||
return (
|
||||
@@ -177,8 +166,8 @@ const Analyses = () => {
|
||||
loading={ loading }
|
||||
pagination={ { ...pagination, total, pages } }
|
||||
onViewDetail={ ( row ) => setSelectedRow( row ) }
|
||||
onPageChange={ ( page ) => setPagination( ( prev ) => ( { ...prev, page: Math.max( 1, page ) } ) ) }
|
||||
onPerPageChange={ ( perPage ) => setPagination( { page: 1, perPage: Math.max( 1, perPage ) } ) }
|
||||
onPageChange={ onPageChange }
|
||||
onPerPageChange={ onPerPageChange }
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ const App = ( { config = {} } ) => {
|
||||
setActiveTab( tabName )
|
||||
}
|
||||
|
||||
const { isSiteConnected, isPro, plan, locales = [] } = rankMath.aiVisibility
|
||||
const { isSiteConnected, isPro, plan, locales = [], languages = [], defaultLanguage = '', intervals = [], platforms = {}, maxPlatforms = 1 } = rankMath.aiVisibility
|
||||
|
||||
// Access gate — Free Content AI plan: PRO users get the trial flow,
|
||||
// free plugin users get the upgrade modal.
|
||||
@@ -100,7 +100,7 @@ const App = ( { config = {} } ) => {
|
||||
<div className={ 'rank-math-ai-visibility__tab rank-math-ai-visibility__tab--' + tab.name }>
|
||||
{ ! isSiteConnected && <Connect config={ config } /> }
|
||||
{ isSiteConnected && (
|
||||
isPlanGated ? <GatedPreview /> : createElement( tab.view, { locales, onBrandCreated: showSnackbar } )
|
||||
isPlanGated ? <GatedPreview /> : createElement( tab.view, { locales, languages, defaultLanguage, intervals, platforms, maxPlatforms, onBrandCreated: showSnackbar } )
|
||||
) }
|
||||
</div>
|
||||
) }
|
||||
|
||||
+5
@@ -72,6 +72,11 @@ const BrandHeader = ( {
|
||||
{ brand.url }
|
||||
</a>
|
||||
{ brand.locale && <CountryFlag locale={ brand.locale } /> }
|
||||
{ brand.language && (
|
||||
<span className={ `${ ns }__language` }>
|
||||
{ brand.language }
|
||||
</span>
|
||||
) }
|
||||
<a
|
||||
className={ `${ ns }__external` }
|
||||
href={ getBrandUrl( brand.url ) }
|
||||
|
||||
+10
@@ -81,6 +81,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
&__language {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border-radius: 20px;
|
||||
font-size: 11px;
|
||||
color: $color-text-muted;
|
||||
border: 1px solid $color-border;
|
||||
}
|
||||
|
||||
&__external {
|
||||
color: #757575;
|
||||
display: inline-flex;
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ const BrandOverview = ( { brand, insights = null, loading = false } ) => {
|
||||
: placeholder
|
||||
}
|
||||
tooltip={ __( 'AI Visibility Score for this brand across AI platforms.', 'seo-by-rank-math' ) }
|
||||
analysis={ insights?.analysis }
|
||||
analysis={ insights?.analyses?.[ 0 ] }
|
||||
/>
|
||||
|
||||
<StatCard
|
||||
@@ -71,7 +71,7 @@ const BrandOverview = ( { brand, insights = null, loading = false } ) => {
|
||||
: placeholder
|
||||
}
|
||||
tooltip={ __( 'Average sentiment score across all AI mentions of this brand.', 'seo-by-rank-math' ) }
|
||||
analysis={ insights?.analysis }
|
||||
analysis={ insights?.analyses?.[ 0 ] }
|
||||
/>
|
||||
|
||||
<StatCard
|
||||
@@ -98,7 +98,7 @@ const BrandOverview = ( { brand, insights = null, loading = false } ) => {
|
||||
label={ __( 'Top Competitor', 'seo-by-rank-math' ) }
|
||||
value={ topCompetitor || placeholder }
|
||||
tooltip={ __( 'The competitor brand with the highest share of voice in AI mentions.', 'seo-by-rank-math' ) }
|
||||
analysis={ insights?.analysis }
|
||||
analysis={ insights?.analyses?.[ 0 ] }
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
+25
-12
@@ -20,21 +20,29 @@ import './RunDetail.scss'
|
||||
/**
|
||||
* Map an insights query result to the shape TranscriptViewer expects.
|
||||
*
|
||||
* The id is qualified by platform — the backend reuses the same query_id
|
||||
* across platforms, so an unqualified id would collide.
|
||||
*
|
||||
* @param {Object} result Query result from the insights payload.
|
||||
* @param {number} index Fallback index.
|
||||
* @param {Object} analysis Parent analysis meta.
|
||||
* @param {Object} analysis Analysis run (matched by platform) this result belongs to.
|
||||
* @return {Object} Normalised entry.
|
||||
*/
|
||||
const toEntry = ( result, index, analysis ) => ( {
|
||||
...result,
|
||||
id: result.query_id ?? index,
|
||||
query: result.query_text ?? '',
|
||||
response: result.response ?? '',
|
||||
created_at: analysis?.finished_at ?? null,
|
||||
duration_seconds: analysis?.duration_seconds ?? null,
|
||||
status: result.found ? 'success' : 'partial',
|
||||
model: null,
|
||||
} )
|
||||
const toEntry = ( result, index, analysis ) => {
|
||||
const baseId = result.query_id ?? index
|
||||
const platform = result.platform ?? 'default'
|
||||
|
||||
return {
|
||||
...result,
|
||||
id: `${ baseId }-${ platform }`,
|
||||
query: result.query_text ?? '',
|
||||
response: result.response ?? '',
|
||||
created_at: analysis?.finished_at ?? null,
|
||||
duration_seconds: analysis?.duration_seconds ?? null,
|
||||
status: result.found ? 'success' : 'partial',
|
||||
model: null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} props
|
||||
@@ -44,7 +52,12 @@ const toEntry = ( result, index, analysis ) => ( {
|
||||
*/
|
||||
const RunDetail = ( { insights = null, loading = false } ) => {
|
||||
const entries = useMemo(
|
||||
() => ( insights?.query_results ?? [] ).map( ( result, i ) => toEntry( result, i, insights?.analysis ) ),
|
||||
() => {
|
||||
const analyses = insights?.analyses ?? []
|
||||
const findAnalysis = ( platform ) => analyses.find( ( analysis ) => analysis.platform === platform ) ?? analyses[ 0 ] ?? null
|
||||
|
||||
return ( insights?.query_results ?? [] ).map( ( result, i ) => toEntry( result, i, findAnalysis( result.platform ) ) )
|
||||
},
|
||||
[ insights ]
|
||||
)
|
||||
|
||||
|
||||
+11
-1
@@ -55,9 +55,14 @@ const SUB_TABS = [
|
||||
* @param {number} props.brandId
|
||||
* @param {Function} [props.onBack]
|
||||
* @param {Array} [props.locales]
|
||||
* @param {Array} [props.languages]
|
||||
* @param {string} [props.defaultLanguage] Default language for new brands (site language).
|
||||
* @param {Array} [props.intervals]
|
||||
* @param {Object} [props.platforms] AI platform registry from PHP.
|
||||
* @param {number} [props.maxPlatforms] Platforms selectable on the current plan.
|
||||
* @return {JSX.Element} Rendered component.
|
||||
*/
|
||||
const BrandDetail = ( { brandId, onBack, locales = [] } ) => {
|
||||
const BrandDetail = ( { brandId, onBack, locales = [], languages = [], defaultLanguage = '', intervals = [], platforms = {}, maxPlatforms = 1 } ) => {
|
||||
const handleBack = onBack || navigateBackToDashboard
|
||||
const { data: brandData, loading, error, setData: setBrandData } = useFetch(
|
||||
() => getBrand( brandId ),
|
||||
@@ -165,6 +170,11 @@ const BrandDetail = ( { brandId, onBack, locales = [] } ) => {
|
||||
isSaving={ isSaving }
|
||||
apiError={ saveError }
|
||||
locales={ locales }
|
||||
languages={ languages }
|
||||
defaultLanguage={ defaultLanguage }
|
||||
intervals={ intervals }
|
||||
platforms={ platforms }
|
||||
maxPlatforms={ maxPlatforms }
|
||||
/>
|
||||
) }
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ const GatedPreview = () => {
|
||||
<StatCard
|
||||
className="rank-math-ai-visibility-stat-card--analyses"
|
||||
icon={ trendingUp }
|
||||
label={ __( 'Analyses in last 24h', 'seo-by-rank-math' ) }
|
||||
label={ __( 'Analyses in the last 7 days', 'seo-by-rank-math' ) }
|
||||
value={ 0 }
|
||||
/>
|
||||
<StatCard
|
||||
|
||||
+36
-15
@@ -21,6 +21,7 @@ import { trendingUp, store } from '@wordpress/icons'
|
||||
* Internal dependencies
|
||||
*/
|
||||
import useDashboard from '../shared/hooks/useDashboard'
|
||||
import usePagination from '../shared/hooks/usePagination'
|
||||
import { getBrand } from '../shared/services/api/aiVisibilityApi'
|
||||
import { StatCard, EmptyState } from '../shared/components'
|
||||
import { ConfirmModal, AddBrandModal, UpgradePlanModal } from '../shared/Modals'
|
||||
@@ -67,11 +68,11 @@ const getConfirmMessage = ( confirmBrand, confirmAction ) => {
|
||||
/**
|
||||
* Resolve the display value for a summary StatCard.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {boolean} options.loading Whether the dashboard is still loading.
|
||||
* @param {boolean} options.hasBrands Whether any brands are tracked.
|
||||
* @param {*} options.raw Raw summary value (may be null/undefined).
|
||||
* @param {Function} [options.format] Optional formatter for a present value.
|
||||
* @param {Object} options
|
||||
* @param {boolean} options.loading Whether the dashboard is still loading.
|
||||
* @param {boolean} options.hasBrands Whether any brands are tracked.
|
||||
* @param {*} options.raw Raw summary value (may be null/undefined).
|
||||
* @param {Function} [options.format] Optional formatter for a present value.
|
||||
* @return {string|number|null} Placeholder, null (empty), 0 (missing) or formatted value.
|
||||
*/
|
||||
const getStatValue = ( { loading, hasBrands, raw, format } ) => {
|
||||
@@ -89,11 +90,16 @@ const getStatValue = ( { loading, hasBrands, raw, format } ) => {
|
||||
|
||||
/**
|
||||
* @param {Object} props
|
||||
* @param {Array} [props.locales] Locale options for the brand modals.
|
||||
* @param {Function} [props.onBrandCreated] Callback when a new brand is successfully created.
|
||||
* @param {Array} [props.locales] Locale options for the brand modals.
|
||||
* @param {Array} [props.languages] Output language options for the brand modals.
|
||||
* @param {string} [props.defaultLanguage] Default language for new brands (site language).
|
||||
* @param {Object} [props.platforms] AI platform registry from PHP.
|
||||
* @param {number} [props.maxPlatforms] Platforms selectable on the current plan.
|
||||
* @param {Function} [props.onBrandCreated] Callback when a new brand is successfully created.
|
||||
* @param {Array} [props.intervals] Interval options for the brand modals.
|
||||
* @return {JSX.Element} Rendered component.
|
||||
*/
|
||||
const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
const Dashboard = ( { locales = [], languages = [], defaultLanguage = '', platforms = {}, maxPlatforms = 1, onBrandCreated = () => {}, intervals = [] } ) => {
|
||||
const [ activeBrandId, setActiveBrandId ] = useState( getActiveBrandId )
|
||||
|
||||
useEffect( () => {
|
||||
@@ -114,13 +120,11 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
handleEnableBrand,
|
||||
} = useDashboard()
|
||||
|
||||
// Modal state
|
||||
const [ isAddModalOpen, setAddModalOpen ] = useState( false )
|
||||
const [ editBrand, setEditBrand ] = useState( null )
|
||||
const [ isSaving, setIsSaving ] = useState( false )
|
||||
const [ saveError, setSaveError ] = useState( null )
|
||||
|
||||
// ConfirmModal state
|
||||
const [ confirmBrand, setConfirmBrand ] = useState( null )
|
||||
const [ confirmAction, setConfirmAction ] = useState( 'delete' )
|
||||
const [ isProcessing, setIsProcessing ] = useState( false )
|
||||
@@ -128,10 +132,13 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
|
||||
const [ isUpgradeModalOpen, setUpgradeModalOpen ] = useState( false )
|
||||
|
||||
// Search: debounced 300 ms, proxy filters cached rows server-side.
|
||||
// Search is debounced 300ms.
|
||||
const [ searchQuery, setSearchQuery ] = useState( '' )
|
||||
const isFirstSearchRender = useRef( true )
|
||||
|
||||
const { pagination, pageItems, total, pages, onPageChange, onPerPageChange, resetPage } =
|
||||
usePagination( brands, { perPage: 10, syncUrl: true } )
|
||||
|
||||
useEffect( () => {
|
||||
if ( isFirstSearchRender.current ) {
|
||||
isFirstSearchRender.current = false
|
||||
@@ -140,9 +147,10 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
|
||||
const timer = setTimeout( () => {
|
||||
handleSearch( searchQuery.trim() )
|
||||
resetPage()
|
||||
}, 300 )
|
||||
return () => clearTimeout( timer )
|
||||
}, [ searchQuery, handleSearch ] )
|
||||
}, [ searchQuery, handleSearch, resetPage ] )
|
||||
|
||||
const hasActiveSearch = !! searchQuery.trim()
|
||||
const isEmpty = ! loading && brands.length === 0 && ! hasActiveSearch
|
||||
@@ -234,6 +242,11 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
brandId={ activeBrandId }
|
||||
onBack={ handleBackToDashboard }
|
||||
locales={ locales }
|
||||
languages={ languages }
|
||||
defaultLanguage={ defaultLanguage }
|
||||
intervals={ intervals }
|
||||
platforms={ platforms }
|
||||
maxPlatforms={ maxPlatforms }
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -260,8 +273,8 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
<StatCard
|
||||
className="rank-math-ai-visibility-stat-card--analyses"
|
||||
icon={ trendingUp }
|
||||
label={ __( 'Analyses in last 24h', 'seo-by-rank-math' ) }
|
||||
value={ getStatValue( { loading, hasBrands: brands.length > 0, raw: summary?.analyses_last_24h } ) }
|
||||
label={ __( 'Analyses in the last 7 days', 'seo-by-rank-math' ) }
|
||||
value={ getStatValue( { loading, hasBrands: brands.length > 0, raw: summary?.analyses_last_7d } ) }
|
||||
tooltip={ __( 'Total analysis runs completed in the past 24 hours.', 'seo-by-rank-math' ) }
|
||||
/>
|
||||
<StatCard
|
||||
@@ -297,8 +310,9 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
/>
|
||||
|
||||
<BrandsTable
|
||||
brands={ brands }
|
||||
brands={ pageItems }
|
||||
loading={ loading }
|
||||
pagination={ { ...pagination, total, pages } }
|
||||
onView={ handleViewBrand }
|
||||
onEdit={ async ( brand ) => {
|
||||
setEditBrand( brand )
|
||||
@@ -313,6 +327,8 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
}
|
||||
} }
|
||||
onDisable={ ( brand ) => openDisableConfirm( brand ) }
|
||||
onPageChange={ onPageChange }
|
||||
onPerPageChange={ onPerPageChange }
|
||||
/>
|
||||
</div>
|
||||
) }
|
||||
@@ -325,6 +341,11 @@ const Dashboard = ( { locales = [], onBrandCreated = () => {} } ) => {
|
||||
isSaving={ isSaving }
|
||||
apiError={ saveError }
|
||||
locales={ locales }
|
||||
languages={ languages }
|
||||
defaultLanguage={ defaultLanguage }
|
||||
intervals={ intervals }
|
||||
platforms={ platforms }
|
||||
maxPlatforms={ maxPlatforms }
|
||||
/>
|
||||
) }
|
||||
|
||||
|
||||
+4
@@ -136,7 +136,11 @@ const Reports = () => {
|
||||
rows[ 0 ].competitors = ( data?.insights?.competitors ?? [] ).map( ( c ) => c.name )
|
||||
rows[ 0 ].queries = ( data?.insights?.query_results ?? [] ).map( ( q ) => ( {
|
||||
query: q.query_text ?? '',
|
||||
platform: q.platform ?? null,
|
||||
response: q.response ?? '',
|
||||
found: q.found ?? null,
|
||||
sentiment_score: q.sentiment ?? null,
|
||||
citations_count: q.citations ?? null,
|
||||
} ) )
|
||||
} catch {
|
||||
// Competitors and queries are nice-to-have in the report — ignore.
|
||||
|
||||
+120
-77
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n'
|
||||
import { __, _n, sprintf } from '@wordpress/i18n'
|
||||
import { useState, useEffect, useMemo, useRef } from '@wordpress/element'
|
||||
import { Modal, TextControl, TextareaControl, SelectControl, CheckboxControl, Icon } from '@wordpress/components'
|
||||
import { close } from '@wordpress/icons'
|
||||
@@ -19,54 +19,31 @@ import { SelectWithSearch } from '@rank-math/components'
|
||||
import Button from '../components/Button'
|
||||
import LoadingButton from '../components/LoadingButton'
|
||||
import getLink from '@helpers/getLink'
|
||||
import { toPlatformList, getDefaultPlatforms, getEnabledPlatformIds } from '../services/platforms'
|
||||
import './AddBrandModal.scss'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Constants
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const EMPTY_FORM = {
|
||||
/**
|
||||
* Blank form state.
|
||||
*
|
||||
* @param {Array} platformList Available platforms.
|
||||
* @param {string} [defaultLanguage=''] Default language for a new brand (site language).
|
||||
* @return {Object} Empty form values.
|
||||
*/
|
||||
const emptyForm = ( platformList, defaultLanguage = '' ) => ( {
|
||||
name: '',
|
||||
url: '',
|
||||
description: '',
|
||||
locale: '',
|
||||
interval: 'weekly',
|
||||
platforms: [ 'chatgpt' ],
|
||||
}
|
||||
language: defaultLanguage,
|
||||
interval: 'monthly',
|
||||
platforms: getDefaultPlatforms( platformList ),
|
||||
} )
|
||||
|
||||
/**
|
||||
* Order in which fields are validated / scrolled to.
|
||||
* Used to focus the first errored field on a failed save.
|
||||
*/
|
||||
const FIELD_ORDER = [ 'name', 'url', 'description' ]
|
||||
|
||||
/**
|
||||
* Analysis interval options.
|
||||
*/
|
||||
const INTERVAL_OPTIONS = [
|
||||
{ label: __( 'Weekly', 'seo-by-rank-math' ), value: 'weekly', disabled: false },
|
||||
{ label: __( 'Monthly (Coming Soon)', 'seo-by-rank-math' ), value: 'monthly', disabled: true },
|
||||
{ label: __( 'Daily (Coming Soon)', 'seo-by-rank-math' ), value: 'daily', disabled: true },
|
||||
]
|
||||
|
||||
/**
|
||||
* AI Platform definitions.
|
||||
*
|
||||
* `enabled` — whether the platform is available for selection.
|
||||
* Disabled platforms show a "Coming Soon" badge.
|
||||
*
|
||||
* Layout: left column = index 0–2, right column = index 3–4.
|
||||
*/
|
||||
const AI_PLATFORMS = [
|
||||
{ id: 'chatgpt', label: 'ChatGPT', enabled: true },
|
||||
{ id: 'perplexity', label: 'Perplexity', enabled: false },
|
||||
{ id: 'google_ai_overview', label: 'Google AI Overview', enabled: false },
|
||||
{ id: 'gemini', label: 'Gemini', enabled: false },
|
||||
{ id: 'claude', label: 'Claude', enabled: false },
|
||||
]
|
||||
|
||||
const LEFT_PLATFORMS = AI_PLATFORMS.slice( 0, 3 )
|
||||
const RIGHT_PLATFORMS = AI_PLATFORMS.slice( 3 )
|
||||
const FIELD_ORDER = [ 'name', 'url', 'description', 'language' ]
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sub-components
|
||||
@@ -114,12 +91,17 @@ const PlatformRow = ( { platform, checked, onChange, disabled } ) => {
|
||||
* AddBrandModal component.
|
||||
*
|
||||
* @param {Object} props
|
||||
* @param {Object|null} [props.brand=null] null = add mode, object = edit (pre-fills form).
|
||||
* @param {Function} props.onSave Called with the validated form payload.
|
||||
* @param {Function} props.onClose Called when the modal should close.
|
||||
* @param {boolean} [props.isSaving=false] Shows spinner + disables all fields.
|
||||
* @param {string | null} props.apiError API error message to display.
|
||||
* @param {Array} [props.locales=[]] Locale options injected from PHP via wp_localize_script.
|
||||
* @param {Object|null} [props.brand=null] null = add mode, object = edit (pre-fills form).
|
||||
* @param {Function} props.onSave Called with the validated form payload.
|
||||
* @param {Function} props.onClose Called when the modal should close.
|
||||
* @param {boolean} [props.isSaving=false] Shows spinner + disables all fields.
|
||||
* @param {string | null} props.apiError API error message to display.
|
||||
* @param {Array} [props.locales=[]] Locale options injected from PHP via wp_localize_script.
|
||||
* @param {Array} [props.languages=[]] Output language options injected from PHP via wp_localize_script.
|
||||
* @param {string} [props.defaultLanguage=''] Default language for a new brand (site language), injected from PHP.
|
||||
* @param {Array} [props.intervals=[]] { label, value, disabled } options injected from PHP via wp_localize_script.
|
||||
* @param {Object} [props.platforms={}] AI platform registry injected from PHP.
|
||||
* @param {number} [props.maxPlatforms=1] Platforms selectable on the current plan.
|
||||
* @return {JSX.Element} Brand add/edit dialog.
|
||||
*/
|
||||
const AddBrandModal = ( {
|
||||
@@ -129,8 +111,16 @@ const AddBrandModal = ( {
|
||||
isSaving = false,
|
||||
apiError = null,
|
||||
locales = [],
|
||||
languages = [],
|
||||
defaultLanguage = '',
|
||||
intervals = [],
|
||||
platforms = {},
|
||||
maxPlatforms = 1,
|
||||
} ) => {
|
||||
const [ form, setForm ] = useState( EMPTY_FORM )
|
||||
const platformList = useMemo( () => toPlatformList( platforms ), [ platforms ] )
|
||||
const enabledPlatformCount = useMemo( () => getEnabledPlatformIds( platformList ).length, [ platformList ] )
|
||||
|
||||
const [ form, setForm ] = useState( () => emptyForm( platformList, defaultLanguage ) )
|
||||
const [ errors, setErrors ] = useState( {} )
|
||||
|
||||
const ns = 'rank-math-ai-visibility-add-brand-modal'
|
||||
@@ -140,6 +130,7 @@ const AddBrandModal = ( {
|
||||
name: useRef( null ),
|
||||
url: useRef( null ),
|
||||
description: useRef( null ),
|
||||
language: useRef( null ),
|
||||
}
|
||||
|
||||
// Locale options — object map expected by SelectWithSearch: { value: label, … }
|
||||
@@ -152,6 +143,14 @@ const AddBrandModal = ( {
|
||||
[ locales ]
|
||||
)
|
||||
|
||||
const languageOptions = useMemo(
|
||||
() => languages.reduce( ( acc, { name, icon } ) => {
|
||||
acc[ name ] = icon ? `${ icon } ${ name }` : name
|
||||
return acc
|
||||
}, {} ),
|
||||
[ languages ]
|
||||
)
|
||||
|
||||
// Pre-fill when editing.
|
||||
useEffect( () => {
|
||||
if ( brand ) {
|
||||
@@ -161,12 +160,17 @@ const AddBrandModal = ( {
|
||||
url: brand.url ?? '',
|
||||
description: brand.description ?? '',
|
||||
locale: brand.locale ?? '',
|
||||
interval: brand.interval ?? 'weekly',
|
||||
platforms: brand.platforms ?? [ 'chatgpt' ],
|
||||
// Legacy brands predate the language field.
|
||||
language: brand.language ?? 'US English',
|
||||
interval: brand.interval ?? 'monthly',
|
||||
platforms: brand.platforms?.length
|
||||
? brand.platforms.slice( 0, maxPlatforms )
|
||||
: getDefaultPlatforms( platformList ),
|
||||
} )
|
||||
} else {
|
||||
setForm( EMPTY_FORM )
|
||||
setForm( emptyForm( platformList, defaultLanguage ) )
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [ brand ] )
|
||||
|
||||
// ── Field helpers ────────────────────────────────────────────────────────
|
||||
@@ -184,18 +188,24 @@ const AddBrandModal = ( {
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a platform ID in the platforms array.
|
||||
* Toggle a platform. Selecting past the plan cap evicts the oldest pick.
|
||||
*
|
||||
* @param {string} id Platform id to toggle.
|
||||
*/
|
||||
const togglePlatform = ( id ) => {
|
||||
setForm( ( prev ) => {
|
||||
const exists = prev.platforms.includes( id )
|
||||
if ( prev.platforms.includes( id ) ) {
|
||||
return {
|
||||
...prev,
|
||||
platforms: prev.platforms.filter( ( p ) => p !== id ),
|
||||
}
|
||||
}
|
||||
|
||||
const next = [ ...prev.platforms, id ]
|
||||
|
||||
return {
|
||||
...prev,
|
||||
platforms: exists
|
||||
? prev.platforms.filter( ( p ) => p !== id )
|
||||
: [ ...prev.platforms, id ],
|
||||
platforms: next.slice( Math.max( 0, next.length - maxPlatforms ) ),
|
||||
}
|
||||
} )
|
||||
}
|
||||
@@ -229,6 +239,9 @@ const AddBrandModal = ( {
|
||||
if ( ! form.description.trim() ) {
|
||||
newErrors.description = __( 'Description is required.', 'seo-by-rank-math' )
|
||||
}
|
||||
if ( ! form.language ) {
|
||||
newErrors.language = __( 'Language is required.', 'seo-by-rank-math' )
|
||||
}
|
||||
|
||||
setErrors( newErrors )
|
||||
return newErrors
|
||||
@@ -266,13 +279,14 @@ const AddBrandModal = ( {
|
||||
url: form.url.trim(),
|
||||
description: form.description.trim(),
|
||||
locale: form.locale,
|
||||
language: form.language,
|
||||
interval: form.interval,
|
||||
platforms: form.platforms,
|
||||
} )
|
||||
}
|
||||
|
||||
const isEditMode = Boolean( brand )
|
||||
const isActionDisabled = isSaving || form?.platforms?.length === 0 || Object.keys( errors ).length > 0
|
||||
const isActionDisabled = isSaving || form?.platforms?.length === 0 || ! form?.language || Object.keys( errors ).length > 0
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@@ -370,12 +384,35 @@ const AddBrandModal = ( {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={ `${ ns }__field` } ref={ fieldRefs.language }>
|
||||
<span className={ `${ ns }__label` }>
|
||||
{ __( 'Output Language', 'seo-by-rank-math' ) }
|
||||
</span>
|
||||
<SelectWithSearch
|
||||
value={ form.language }
|
||||
options={ languageOptions }
|
||||
onChange={ set( 'language' ) }
|
||||
disabled={ isSaving || isEditMode }
|
||||
className={ errors.language ? `${ ns }__field--error` : '' }
|
||||
/>
|
||||
{ errors.language && (
|
||||
<p className={ `${ ns }__field-note ${ ns }__field-note--error` }>
|
||||
{ errors.language }
|
||||
</p>
|
||||
) }
|
||||
{ isEditMode && (
|
||||
<p className={ `${ ns }__field-note` }>
|
||||
{ __( 'Language can\'t be changed after a brand is created.', 'seo-by-rank-math' ) }
|
||||
</p>
|
||||
) }
|
||||
</div>
|
||||
|
||||
{ /* Interval */ }
|
||||
<div className={ `${ ns }__field` }>
|
||||
<SelectControl
|
||||
label={ __( 'Frequency of analyses', 'seo-by-rank-math' ) }
|
||||
value={ form.interval }
|
||||
options={ INTERVAL_OPTIONS }
|
||||
options={ intervals }
|
||||
onChange={ set( 'interval' ) }
|
||||
disabled={ isSaving }
|
||||
__next40pxDefaultSize={ true }
|
||||
@@ -388,29 +425,35 @@ const AddBrandModal = ( {
|
||||
<span className={ `${ ns }__label` }>
|
||||
{ __( 'AI Platforms', 'seo-by-rank-math' ) }
|
||||
</span>
|
||||
{ maxPlatforms < enabledPlatformCount && (
|
||||
<p className={ `${ ns }__field-note` }>
|
||||
{ sprintf(
|
||||
/* translators: %d: number of AI platforms selectable on the current plan. */
|
||||
_n(
|
||||
'Your plan lets you track %d platform per brand. Upgrade to Expert to track them all at once.',
|
||||
'Your plan lets you track %d platforms per brand. Upgrade to Expert to track them all at once.',
|
||||
maxPlatforms,
|
||||
'seo-by-rank-math'
|
||||
),
|
||||
maxPlatforms
|
||||
) }
|
||||
</p>
|
||||
) }
|
||||
{ form.platforms.length === 0 && (
|
||||
<p className={ `${ ns }__field-note ${ ns }__field-note--error` }>
|
||||
{ __( 'Select at least one AI platform.', 'seo-by-rank-math' ) }
|
||||
</p>
|
||||
) }
|
||||
<div className={ `${ ns }__platforms` }>
|
||||
<div className={ `${ ns }__platforms-col` }>
|
||||
{ LEFT_PLATFORMS.map( ( platform ) => (
|
||||
<PlatformRow
|
||||
key={ platform.id }
|
||||
platform={ platform }
|
||||
checked={ form.platforms.includes( platform.id ) }
|
||||
onChange={ () => togglePlatform( platform.id ) }
|
||||
disabled={ isSaving }
|
||||
/>
|
||||
) ) }
|
||||
</div>
|
||||
<div className={ `${ ns }__platforms-col` }>
|
||||
{ RIGHT_PLATFORMS.map( ( platform ) => (
|
||||
<PlatformRow
|
||||
key={ platform.id }
|
||||
platform={ platform }
|
||||
checked={ form.platforms.includes( platform.id ) }
|
||||
onChange={ () => togglePlatform( platform.id ) }
|
||||
disabled={ isSaving }
|
||||
/>
|
||||
) ) }
|
||||
</div>
|
||||
{ platformList.map( ( platform ) => (
|
||||
<PlatformRow
|
||||
key={ platform.id }
|
||||
platform={ platform }
|
||||
checked={ form.platforms.includes( platform.id ) }
|
||||
onChange={ () => togglePlatform( platform.id ) }
|
||||
disabled={ isSaving }
|
||||
/>
|
||||
) ) }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+11
-6
@@ -132,6 +132,16 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__field-note {
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
color: $color-text-muted;
|
||||
|
||||
&--error {
|
||||
color: $color-trend-down;
|
||||
}
|
||||
}
|
||||
|
||||
.components-base-control__label,
|
||||
.components-input-control__label {
|
||||
font-size: 11px;
|
||||
@@ -186,16 +196,11 @@
|
||||
&__platforms {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-auto-flow: row;
|
||||
gap: 10px 16px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
&__platforms-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
&__platform-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import './StatCard.scss'
|
||||
* @return {JSX.Element} Stat card with icon, label, value, and optional trend.
|
||||
*/
|
||||
const StatCard = ( { icon, label, value, tooltip, sub, compact = false, className = '', analysis = null } ) => {
|
||||
const hasData = ( analysis?.status && analysis?.status === 'done' ) ?? ( value !== null && value !== undefined && value !== '' && value !== '—' )
|
||||
const hasData = ( analysis?.status && ( analysis?.status === 'done' || analysis?.status === 'partial' ) ) ?? ( value !== null && value !== undefined && value !== '' && value !== '—' )
|
||||
|
||||
const ns = 'rank-math-ai-visibility-stat-card'
|
||||
|
||||
|
||||
+4
@@ -173,6 +173,10 @@ const TranscriptViewer = ( {
|
||||
if ( e.query ) {
|
||||
label = e.query.length > 60 ? e.query.slice( 0, 60 ) + '…' : e.query
|
||||
}
|
||||
// Append platform — multiple platforms can share the same query text.
|
||||
if ( e.platform ) {
|
||||
label += ` — ${ e.platform }`
|
||||
}
|
||||
return { label, value: String( e.id ) }
|
||||
} ),
|
||||
], [ entries ] )
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* usePagination — client-side pagination over an in-memory array.
|
||||
*
|
||||
* @since 1.0.274
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from '@wordpress/element'
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { getPageFromUrl, getPerPageFromUrl, writePaginationToUrl } from '../../utils/urlState'
|
||||
|
||||
const DEFAULT_PER_PAGE = 10
|
||||
|
||||
/**
|
||||
* @param {Array} items Full, already-filtered item list to paginate.
|
||||
* @param {Object} [options]
|
||||
* @param {number} [options.perPage=10] Default/initial page size.
|
||||
* @param {boolean} [options.syncUrl=false] Read the initial page from the URL and keep it updated.
|
||||
* @return {Object} `{ pagination, pageItems, total, pages, onPageChange, onPerPageChange, resetPage }`
|
||||
*/
|
||||
const usePagination = ( items = [], { perPage = DEFAULT_PER_PAGE, syncUrl = false } = {} ) => {
|
||||
const [ pagination, setPagination ] = useState( () => ( {
|
||||
page: syncUrl ? getPageFromUrl( 1 ) : 1,
|
||||
perPage: syncUrl ? getPerPageFromUrl( perPage ) : perPage,
|
||||
} ) )
|
||||
|
||||
const total = items.length
|
||||
const pages = Math.max( 1, Math.ceil( total / pagination.perPage ) )
|
||||
|
||||
const pageItems = useMemo( () => {
|
||||
const offset = ( pagination.page - 1 ) * pagination.perPage
|
||||
return items.slice( offset, offset + pagination.perPage )
|
||||
}, [ items, pagination ] )
|
||||
|
||||
// Clamp out-of-range pages, but not on mount (would clobber a URL-provided page).
|
||||
const isFirstRun = useRef( true )
|
||||
useEffect( () => {
|
||||
if ( isFirstRun.current ) {
|
||||
isFirstRun.current = false
|
||||
return
|
||||
}
|
||||
setPagination( ( prev ) => ( prev.page > pages ? { ...prev, page: pages } : prev ) )
|
||||
}, [ pages ] )
|
||||
|
||||
useEffect( () => {
|
||||
if ( syncUrl ) {
|
||||
writePaginationToUrl( pagination, perPage )
|
||||
}
|
||||
}, [ pagination, syncUrl, perPage ] )
|
||||
|
||||
const onPageChange = useCallback(
|
||||
( page ) => setPagination( ( prev ) => ( { ...prev, page: Math.max( 1, page ) } ) ),
|
||||
[]
|
||||
)
|
||||
|
||||
const onPerPageChange = useCallback(
|
||||
( newPerPage ) => setPagination( { page: 1, perPage: Math.max( 1, newPerPage ) } ),
|
||||
[]
|
||||
)
|
||||
|
||||
const resetPage = useCallback(
|
||||
() => setPagination( ( prev ) => ( prev.page === 1 ? prev : { ...prev, page: 1 } ) ),
|
||||
[]
|
||||
)
|
||||
|
||||
return { pagination, pageItems, total, pages, onPageChange, onPerPageChange, resetPage }
|
||||
}
|
||||
|
||||
export default usePagination
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* AI platform registry helpers — mirrors `Platforms` in PHP.
|
||||
*
|
||||
* @since 1.0.275
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { map, filter } from 'lodash'
|
||||
|
||||
/**
|
||||
* Convert the localized registry map into a list, preserving key order.
|
||||
*
|
||||
* @param {Object} platforms Registry keyed by platform ID.
|
||||
* @return {Array<{id: string, label: string, enabled: boolean}>} Platform list.
|
||||
*/
|
||||
export const toPlatformList = ( platforms = {} ) =>
|
||||
map( platforms, ( platform, id ) => ( {
|
||||
id,
|
||||
label: platform?.label ?? id,
|
||||
enabled: Boolean( platform?.enabled ),
|
||||
} ) )
|
||||
|
||||
/**
|
||||
* Platform IDs available for selection.
|
||||
*
|
||||
* @param {Array} platformList Output of toPlatformList().
|
||||
* @return {string[]} Enabled platform IDs.
|
||||
*/
|
||||
export const getEnabledPlatformIds = ( platformList = [] ) =>
|
||||
map( filter( platformList, 'enabled' ), 'id' )
|
||||
|
||||
/**
|
||||
* Default selection for a new brand — the first enabled platform.
|
||||
*
|
||||
* @param {Array} platformList Output of toPlatformList().
|
||||
* @return {string[]} Default platform IDs.
|
||||
*/
|
||||
export const getDefaultPlatforms = ( platformList = [] ) =>
|
||||
getEnabledPlatformIds( platformList ).slice( 0, 1 )
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Derive a brand's display analysis state from its `analysis_status`.
|
||||
*
|
||||
* API status semantics:
|
||||
* success → ran successfully (a future weekly run is masked as success)
|
||||
* success → ran successfully (a future monthly run is masked as success)
|
||||
* partial → last run completed partially
|
||||
* pending → awaiting first run, or an overdue run is due
|
||||
* running → a run is currently in progress
|
||||
|
||||
+30
@@ -110,3 +110,33 @@ export const navigateToReportsTab = ( brandId ) => {
|
||||
window.history.pushState( {}, '', url )
|
||||
window.dispatchEvent( new window.PopStateEvent( 'popstate' ) )
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} [fallback=1] Fallback when `aiv_page` is absent/invalid.
|
||||
* @return {number} Page number from the URL.
|
||||
*/
|
||||
export const getPageFromUrl = ( fallback = 1 ) => {
|
||||
const raw = parseInt( getQueryArg( window.location.href, 'aiv_page' ), 10 )
|
||||
return raw > 0 ? raw : fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} [fallback=10] Fallback when `aiv_per` is absent/invalid.
|
||||
* @return {number} Page size from the URL.
|
||||
*/
|
||||
export const getPerPageFromUrl = ( fallback = 10 ) => {
|
||||
const raw = parseInt( getQueryArg( window.location.href, 'aiv_per' ), 10 )
|
||||
return raw > 0 ? raw : fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} pagination `{ page, perPage }`.
|
||||
* @param {number} [defaultPerPage=10] Omitted from the URL when matched.
|
||||
*/
|
||||
export const writePaginationToUrl = ( pagination, defaultPerPage = 10 ) => {
|
||||
const url = addQueryArgs( window.location.href, {
|
||||
aiv_page: pagination.page > 1 ? pagination.page : undefined,
|
||||
aiv_per: pagination.perPage !== defaultPerPage ? pagination.perPage : undefined,
|
||||
} )
|
||||
window.history.replaceState( {}, '', url )
|
||||
}
|
||||
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* AI platform registry.
|
||||
*
|
||||
* @since 1.0.275
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\AI_Visibility
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\AI_Visibility;
|
||||
|
||||
use WP_Error;
|
||||
use RankMath\Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Platforms class.
|
||||
*/
|
||||
final class Platforms {
|
||||
|
||||
/**
|
||||
* Plan that unlocks every supported platform.
|
||||
*/
|
||||
const UNLIMITED_PLAN = 'expert';
|
||||
|
||||
/**
|
||||
* Platform definitions. Key order drives the UI column split.
|
||||
*
|
||||
* @var array<string, array{label: string, enabled: bool}>
|
||||
*/
|
||||
private const PLATFORMS = [
|
||||
'chatgpt' => [
|
||||
'label' => 'ChatGPT',
|
||||
'enabled' => true,
|
||||
],
|
||||
'gemini' => [
|
||||
'label' => 'Google Gemini',
|
||||
'enabled' => true,
|
||||
],
|
||||
'perplexity' => [
|
||||
'label' => 'Perplexity',
|
||||
'enabled' => false,
|
||||
],
|
||||
'claude' => [
|
||||
'label' => 'Claude',
|
||||
'enabled' => false,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Every known platform, keyed by ID.
|
||||
*
|
||||
* @return array<string, array{label: string, enabled: bool}>
|
||||
*/
|
||||
public static function all() {
|
||||
return self::PLATFORMS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform IDs available for selection.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function supported() {
|
||||
return array_keys(
|
||||
array_filter(
|
||||
self::PLATFORMS,
|
||||
function ( $platform ) {
|
||||
return ! empty( $platform['enabled'] );
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Platforms the current plan may track per brand.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function max_selectable() {
|
||||
return self::UNLIMITED_PLAN === Helper::get_content_ai_plan()
|
||||
? count( self::supported() )
|
||||
: 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported IDs as a quoted list, e.g. `"chatgpt", "gemini"`.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function supported_as_string() {
|
||||
return implode(
|
||||
', ',
|
||||
array_map(
|
||||
function ( $id ) {
|
||||
return '"' . $id . '"';
|
||||
},
|
||||
self::supported()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* REST route arg definition for a `platforms` param.
|
||||
*
|
||||
* @param bool $required Whether the param is mandatory.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function rest_arg( $required ) {
|
||||
return [
|
||||
'description' => sprintf(
|
||||
/* translators: %s: supported platform IDs. */
|
||||
esc_html__( 'AI platforms to track for this brand. Supported values: %s. Tracking more than one platform per brand requires the Expert plan.', 'seo-by-rank-math' ),
|
||||
self::supported_as_string()
|
||||
),
|
||||
'type' => 'array',
|
||||
'minItems' => 1,
|
||||
'items' => [
|
||||
'type' => 'string',
|
||||
'enum' => self::supported(),
|
||||
],
|
||||
'required' => $required,
|
||||
'validate_callback' => [ self::class, 'validate' ],
|
||||
'sanitize_callback' => [ self::class, 'sanitize' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize, dedupe and drop unsupported IDs.
|
||||
*
|
||||
* @param mixed $value Raw platforms value.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function sanitize( $value ) {
|
||||
return array_values(
|
||||
array_unique(
|
||||
array_intersect(
|
||||
array_map( 'sanitize_text_field', (array) $value ),
|
||||
self::supported()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate against the registry and the plan limit.
|
||||
*
|
||||
* @param mixed $value Raw platforms value.
|
||||
*
|
||||
* @return true|WP_Error
|
||||
*/
|
||||
public static function validate( $value ) {
|
||||
if ( null === $value || '' === $value || [] === $value ) {
|
||||
return new WP_Error(
|
||||
'aiv_bad_request',
|
||||
sprintf(
|
||||
/* translators: %s: supported platform IDs. */
|
||||
esc_html__( 'Please specify which AI platforms to track. Supported values: %s.', 'seo-by-rank-math' ),
|
||||
self::supported_as_string()
|
||||
),
|
||||
[ 'status' => 400 ]
|
||||
);
|
||||
}
|
||||
|
||||
$platforms = self::sanitize( $value );
|
||||
|
||||
if ( empty( $platforms ) ) {
|
||||
return new WP_Error(
|
||||
'aiv_bad_request',
|
||||
sprintf(
|
||||
/* translators: %s: supported platform IDs. */
|
||||
esc_html__( 'No valid AI platforms were provided. Supported values: %s.', 'seo-by-rank-math' ),
|
||||
self::supported_as_string()
|
||||
),
|
||||
[ 'status' => 400 ]
|
||||
);
|
||||
}
|
||||
|
||||
$max = self::max_selectable();
|
||||
if ( count( $platforms ) > $max ) {
|
||||
return new WP_Error(
|
||||
'aiv_plan_limit',
|
||||
sprintf(
|
||||
/* translators: 1: platforms allowed on the current plan, 2: supported platform IDs. */
|
||||
esc_html__( 'Your plan allows tracking %1$d AI platform(s) per brand — upgrade to the Expert plan to track more. Supported values: %2$s.', 'seo-by-rank-math' ),
|
||||
$max,
|
||||
self::supported_as_string()
|
||||
),
|
||||
[ 'status' => 403 ]
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -133,26 +133,6 @@ class Watcher {
|
||||
* @return string
|
||||
*/
|
||||
public function get_permalink( $post_id ) {
|
||||
$permalink = get_permalink( $post_id );
|
||||
|
||||
if ( ! Sitepress::get()->is_active() ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
$sitepress = Sitepress::get()->get_var();
|
||||
|
||||
$language_domains = $sitepress->get_setting( 'language_domains', [] );
|
||||
if ( ! $language_domains ) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
$details = apply_filters( 'wpml_post_language_details', null, $post_id );
|
||||
$code = $details['language_code'] ?? '';
|
||||
$permalink = apply_filters( 'wpml_permalink', get_the_permalink( $post_id ), $code );
|
||||
foreach ( $language_domains as $key => $domain ) {
|
||||
$permalink = preg_replace( "#https?://{$domain}#i", '', $permalink );
|
||||
}
|
||||
|
||||
return $permalink;
|
||||
return Sitepress::get()->get_permalink( $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+4
-4
@@ -35,8 +35,8 @@ const getErrorMessage = () => {
|
||||
if ( ! rankMath.contentAI.plan ) {
|
||||
return (
|
||||
<>
|
||||
{ __( 'You do not have a Content AI plan.', 'seo-by-rank-math' ) }
|
||||
<a href="https://rankmath.com/kb/how-to-use-content-ai/?play-video=ioPeVIntJWw&utm_source=Plugin&utm_medium=Buy+Plan+Button&utm_campaign=WP">
|
||||
{ __( 'You do not have a Rank Math AI plan.', 'seo-by-rank-math' ) }
|
||||
<a href="https://rankmath.com/ai/pricing/?utm_source=Plugin&utm_medium=Buy+Plan+Button&utm_campaign=WP">
|
||||
{ __( 'Choose your plan', 'seo-by-rank-math' ) }
|
||||
</a>
|
||||
</>
|
||||
@@ -45,8 +45,8 @@ const getErrorMessage = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{ __( 'You have exhausted your Content AI Credits.', 'seo-by-rank-math' ) }
|
||||
<a href="https://rankmath.com/kb/how-to-use-content-ai/?play-video=ioPeVIntJWw&utm_source=Plugin&utm_medium=Buy+Credits+Button&utm_campaign=WP" target="_blank" rel="noreferrer">
|
||||
{ __( 'You have exhausted your Rank Math AI Usage.', 'seo-by-rank-math' ) }
|
||||
<a href="https://rankmath.com/ai/pricing/?utm_source=Plugin&utm_medium=Buy+Credits+Button&utm_campaign=WP" target="_blank" rel="noreferrer">
|
||||
{ __( 'Get more', 'seo-by-rank-math' ) }
|
||||
</a>
|
||||
</>
|
||||
|
||||
@@ -142,7 +142,7 @@ class Admin {
|
||||
$refresh_date = Helper::get_content_ai_refresh_date();
|
||||
$content_ai = [
|
||||
'ca_plan' => [
|
||||
'label' => esc_html__( 'Content AI Plan', 'seo-by-rank-math' ),
|
||||
'label' => esc_html__( 'Rank Math AI Plan', 'seo-by-rank-math' ),
|
||||
'value' => \ucwords( Helper::get_content_ai_plan() ),
|
||||
],
|
||||
'ca_credits' => [
|
||||
|
||||
@@ -69,6 +69,7 @@ class Content_AI {
|
||||
'audience' => (array) Helper::get_settings( 'general.content_ai_audience', 'General Audience' ),
|
||||
'tone' => (array) Helper::get_settings( 'general.content_ai_tone', 'Formal' ),
|
||||
'language' => Helper::get_settings( 'general.content_ai_language', Helper::content_ai_default_language() ),
|
||||
'languages' => Helper::get_content_ai_languages(),
|
||||
'history' => Helper::get_outputs(),
|
||||
'chats' => Helper::get_chats(),
|
||||
'recentPrompts' => Helper::get_recent_prompts(),
|
||||
|
||||
@@ -212,7 +212,7 @@ class Rest extends WP_REST_Controller {
|
||||
'permission_callback' => [ $this, 'has_ping_permission' ],
|
||||
'args' => [
|
||||
'plan' => [
|
||||
'description' => esc_html__( 'Content AI plan to update in the Database.', 'seo-by-rank-math' ),
|
||||
'description' => esc_html__( 'Rank Math AI plan to update in the Database.', 'seo-by-rank-math' ),
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
],
|
||||
@@ -675,7 +675,7 @@ class Rest extends WP_REST_Controller {
|
||||
return wp_kses_post(
|
||||
sprintf(
|
||||
// Translators: link to the update page.
|
||||
__( 'There is a new version of Content AI available! %s the Rank Math SEO plugin to use this feature.', 'seo-by-rank-math' ),
|
||||
__( 'There is a new version of Rank Math AI available! %s the Rank Math SEO plugin to use this feature.', 'seo-by-rank-math' ),
|
||||
'<a href="' . esc_url( self_admin_url( 'update-core.php' ) ) . '">' . __( 'Please update', 'seo-by-rank-math' ) . '</a>'
|
||||
)
|
||||
);
|
||||
|
||||
+3
-4
@@ -326,14 +326,13 @@ class Instant_Indexing extends Base {
|
||||
}
|
||||
|
||||
if ( Sitepress::get()->is_active() ) {
|
||||
$details = apply_filters( 'wpml_post_language_details', null, $post_id );
|
||||
$code = $details['language_code'] ?? '';
|
||||
$url = apply_filters( 'wpml_permalink', get_the_permalink( $post_id ), $code );
|
||||
$url = Sitepress::get()->get_permalink( $post_id );
|
||||
|
||||
$sitepress = Sitepress::get()->get_var();
|
||||
$urls = $sitepress->get_setting( 'urls' );
|
||||
if ( isset( $urls['directory_for_default_language'] ) && $urls['directory_for_default_language'] ) {
|
||||
$lang = $sitepress->get_current_language();
|
||||
$details = apply_filters( 'wpml_post_language_details', null, $post_id );
|
||||
$lang = $details['language_code'] ?? $sitepress->get_current_language();
|
||||
if ( 0 !== strpos( $url, '/' . $lang ) ) {
|
||||
$url = get_home_url() . $post->post_name;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -152,26 +152,29 @@ class LLMS_Txt {
|
||||
* @return void
|
||||
*/
|
||||
private function add_header_content() {
|
||||
$site_title = Helper::get_settings( 'titles.knowledgegraph_name', get_bloginfo( 'name' ) );
|
||||
$site_desc = Helper::get_settings( 'titles.organization_description', get_bloginfo( 'description' ) );
|
||||
$site_title .= $site_desc ? ': ' . $site_desc : '';
|
||||
|
||||
if ( ! $this->do_filter( 'llms_txt/remove_credit', false ) ) {
|
||||
$this->output_line( 'Generated by Rank Math SEO, this is an llms.txt file designed to help LLMs better understand and index this website.' );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
$this->output_line( '# ' . esc_html( $site_title ) );
|
||||
$site_title = $this->format_text( Helper::get_settings( 'titles.knowledgegraph_name', get_bloginfo( 'name' ) ) );
|
||||
$summary = $this->format_text( Helper::replace_vars( Helper::get_settings( 'general.llms_summary', '' ) ) );
|
||||
|
||||
$this->output_line( '# ' . $site_title );
|
||||
$this->output_line( '' );
|
||||
|
||||
if ( $summary ) {
|
||||
$this->output_line( '> ' . $summary );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
if ( ! Helper::is_module_active( 'sitemap' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->output_line( '' );
|
||||
$sitemap_url = Router::get_base_url( Sitemap::get_sitemap_index_slug() . '.xml' );
|
||||
$this->output_line( '## Sitemaps' );
|
||||
$this->output_line( '[XML Sitemap](' . esc_url( $sitemap_url ) . '): Includes all crawlable and indexable pages.' );
|
||||
// Add an extra blank line after the header content.
|
||||
$this->output_line( '- [XML Sitemap](' . esc_url_raw( $sitemap_url ) . '): Includes all crawlable and indexable pages.' );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
@@ -219,16 +222,16 @@ class LLMS_Txt {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = get_post_type_object( $post_type )->labels->name;
|
||||
$this->output_line( '## ' . esc_html( $label ) );
|
||||
$label = $this->format_text( get_post_type_object( $post_type )->labels->name );
|
||||
$this->output_line( '## ' . $label );
|
||||
|
||||
foreach ( $posts as $object ) {
|
||||
if ( ! Helper::is_post_indexable( $object ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = get_the_title( $object );
|
||||
$link = get_permalink( $object );
|
||||
$title = $this->format_text( get_the_title( $object ) );
|
||||
$link = esc_url_raw( get_permalink( $object ) );
|
||||
$object->post_content = do_shortcode( $object->post_content );
|
||||
$desc = Helper::replace_vars( '%excerpt%', $object );
|
||||
|
||||
@@ -240,12 +243,12 @@ class LLMS_Txt {
|
||||
* @param \WP_Post $object The post object.
|
||||
* @return string Modified description.
|
||||
*/
|
||||
$desc = wp_strip_all_tags( $this->do_filter( 'llms_txt/post_description', $desc, $object ) );
|
||||
$desc = $this->format_text( $this->do_filter( 'llms_txt/post_description', $desc, $object ) );
|
||||
|
||||
$this->output_line(
|
||||
$desc
|
||||
? '- [' . esc_html( $title ) . '](' . esc_url( $link ) . '): ' . esc_html( $desc )
|
||||
: '- [' . esc_html( $title ) . '](' . esc_url( $link ) . ')'
|
||||
? '- [' . $title . '](' . $link . '): ' . $desc
|
||||
: '- [' . $title . '](' . $link . ')'
|
||||
);
|
||||
}
|
||||
$this->output_line( '' );
|
||||
@@ -291,13 +294,19 @@ class LLMS_Txt {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = $tax_obj->labels->name;
|
||||
$this->output_line( '## ' . esc_html( $label ) );
|
||||
$label = $this->format_text( $tax_obj->labels->name );
|
||||
$this->output_line( '## ' . $label );
|
||||
foreach ( $terms as $term ) {
|
||||
if ( $term && Helper::is_term_indexable( $term ) ) {
|
||||
$name = $term->name;
|
||||
$link = get_term_link( $term );
|
||||
$this->output_line( '- [' . esc_html( $name ) . '](' . esc_url( $link ) . ')' );
|
||||
$name = $this->format_text( $term->name );
|
||||
$link = esc_url_raw( get_term_link( $term ) );
|
||||
$desc = $this->format_text( $term->description );
|
||||
|
||||
$this->output_line(
|
||||
$desc
|
||||
? '- [' . $name . '](' . $link . '): ' . $desc
|
||||
: '- [' . $name . '](' . $link . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->output_line( '' );
|
||||
@@ -319,17 +328,28 @@ class LLMS_Txt {
|
||||
*/
|
||||
$extra = $this->do_filter( 'llms_txt/extra_content', Helper::get_settings( 'general.llms_extra_content', '' ) );
|
||||
if ( ! empty( $extra ) ) {
|
||||
$this->output_line( esc_html( str_replace( "\n", "\n", $extra ) ) );
|
||||
$this->output_line( $this->format_text( $extra ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a line with a newline character (\n).
|
||||
* Normalizes text for plain-text output: strips tags, decodes entities.
|
||||
* Decode first, so an entity-encoded tag (e.g. <script>) can't survive stripping.
|
||||
*
|
||||
* @param string $content The content to output.
|
||||
* @param string $text The text to normalize.
|
||||
* @return string Normalized plain text.
|
||||
*/
|
||||
private function format_text( $text ) {
|
||||
return trim( wp_strip_all_tags( html_entity_decode( (string) $text, ENT_QUOTES, 'UTF-8' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a line with a trailing newline.
|
||||
*
|
||||
* @param string $content Plain text content; must already be sanitized (see format_text()).
|
||||
* @return void
|
||||
*/
|
||||
private function output_line( $content ) {
|
||||
echo esc_html( $content ) . "\n";
|
||||
echo $content . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Plain text, not HTML; see format_text().
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -271,7 +271,7 @@ class Post_Type implements Provider {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_post_type_count( $post_types ) {
|
||||
public function get_post_type_count( $post_types ) {
|
||||
global $wpdb;
|
||||
|
||||
$posts_to_exclude = 'page' === $post_types ? $this->get_blog_page_id() : '';
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ class Taxonomy implements Provider {
|
||||
* @param int $current_page Current page of the sitemap.
|
||||
* @return false|array
|
||||
*/
|
||||
private function get_terms( $taxonomy, $max_entries, $current_page ) {
|
||||
public function get_terms( $taxonomy, $max_entries, $current_page ) {
|
||||
$offset = $current_page > 1 ? ( ( $current_page - 1 ) * $max_entries ) : 0;
|
||||
$hide_empty = ! Helper::get_settings( 'sitemap.tax_' . $taxonomy->name . '_include_empty' );
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
# This file is distributed under the GPL-3.0+.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Rank Math SEO 1.0.278\n"
|
||||
"Project-Id-Version: Rank Math SEO 1.0.279\n"
|
||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/seo-by-rank-math\n"
|
||||
"Last-Translator: Rank Math <support@rankmath.com>\n"
|
||||
"Language-Team: Rank Math <support@rankmath.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2026-09-08T05:37:53+00:00\n"
|
||||
"POT-Creation-Date: 2026-09-22T04:13:08+00:00\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"X-Generator: WP-CLI 2.12.0\n"
|
||||
"X-Domain: seo-by-rank-math\n"
|
||||
@@ -46,7 +46,8 @@ msgstr ""
|
||||
msgid "Create AI Visibility brand"
|
||||
msgstr ""
|
||||
|
||||
msgid "Creates a new brand for AI Visibility monitoring, triggering an initial analysis automatically."
|
||||
#. translators: %s: supported platform IDs.
|
||||
msgid "Creates a new brand for AI Visibility monitoring, triggering an initial analysis automatically. Ask which AI platforms to track. Supported platforms: %s. Selecting more than one requires the Expert plan; other plans may choose only one."
|
||||
msgstr ""
|
||||
|
||||
msgid "Brand name."
|
||||
@@ -61,6 +62,16 @@ msgstr ""
|
||||
msgid "ISO 3166-1 alpha-2 country code (e.g. \"US\", \"HU\"). Defaults to no country filter."
|
||||
msgstr ""
|
||||
|
||||
msgid "Language the brand should be analyzed in (e.g. \"US English\", \"French\"). Required; immutable after creation — ask the user which language to use."
|
||||
msgstr ""
|
||||
|
||||
msgid "Analysis refresh cadence. Defaults to the account plan's default when omitted."
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: supported platform IDs.
|
||||
msgid "AI platforms to track. Supported: %s. Selecting more than one requires the Expert plan; otherwise choose exactly one. Do not assume a default — ask the user which platform(s) to use."
|
||||
msgstr ""
|
||||
|
||||
msgid "Get AI Visibility brand insights"
|
||||
msgstr ""
|
||||
|
||||
@@ -223,6 +234,9 @@ msgstr ""
|
||||
msgid "ID of the post whose links to retrieve."
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid post ID."
|
||||
msgstr ""
|
||||
|
||||
msgid "Upgrade to Rank Math PRO to unlock broken link detection, redirect chain analysis, and HTTP status distribution from the AI Link Genius audit."
|
||||
msgstr ""
|
||||
|
||||
@@ -232,6 +246,39 @@ msgstr ""
|
||||
msgid "Abilities to retrieve and analyse internal and external link data for posts."
|
||||
msgstr ""
|
||||
|
||||
msgid "Get 404 logs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Returns the 404 error monitor log entries, with hit counts and referer/user-agent data."
|
||||
msgstr ""
|
||||
|
||||
msgid "The number of log entries to return per page."
|
||||
msgstr ""
|
||||
|
||||
msgid "The page number to return."
|
||||
msgstr ""
|
||||
|
||||
msgid "Field to order results by."
|
||||
msgstr ""
|
||||
|
||||
msgid "Sort direction."
|
||||
msgstr ""
|
||||
|
||||
msgid "Log counts across the entire table, independent of pagination."
|
||||
msgstr ""
|
||||
|
||||
msgid "Number of log entries included in this response (the size of items)."
|
||||
msgstr ""
|
||||
|
||||
msgid "The 404 log entries for the requested page."
|
||||
msgstr ""
|
||||
|
||||
msgid "404 Monitor"
|
||||
msgstr ""
|
||||
|
||||
msgid "Abilities to inspect the 404 error monitor log."
|
||||
msgstr ""
|
||||
|
||||
msgid "Get post SEO metadata"
|
||||
msgstr ""
|
||||
|
||||
@@ -259,9 +306,6 @@ msgstr ""
|
||||
msgid "The number of redirections to return per page."
|
||||
msgstr ""
|
||||
|
||||
msgid "The page number to return."
|
||||
msgstr ""
|
||||
|
||||
msgid "Search redirections by source or target URL."
|
||||
msgstr ""
|
||||
|
||||
@@ -295,9 +339,6 @@ msgstr ""
|
||||
msgid "When true (default), includes the schema types available on this install. Always pass true when evaluating which schema to add."
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid post ID."
|
||||
msgstr ""
|
||||
|
||||
msgid "This schema type requires Rank Math PRO. Upgrade at rankmath.com/pro to unlock Movie, Dataset, Fact Check, and custom schema types."
|
||||
msgstr ""
|
||||
|
||||
@@ -843,6 +884,27 @@ msgstr ""
|
||||
msgid "Abilities to read and configure Rank Math plugin settings."
|
||||
msgstr ""
|
||||
|
||||
msgid "Get sitemap status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Returns whether the XML sitemap is enabled, the sitemap index URL, and the active sitemap types (post types, taxonomies, and the Local SEO sitemap, when active) with their URLs and estimated entry counts."
|
||||
msgstr ""
|
||||
|
||||
msgid "Whether the XML sitemap module is active."
|
||||
msgstr ""
|
||||
|
||||
msgid "The URL of the sitemap index file."
|
||||
msgstr ""
|
||||
|
||||
msgid "The active sitemap types, e.g. post types, taxonomies, and the Local SEO sitemap (PRO adds news/video when active)."
|
||||
msgstr ""
|
||||
|
||||
msgid "Sitemap"
|
||||
msgstr ""
|
||||
|
||||
msgid "Abilities to inspect the XML sitemap status."
|
||||
msgstr ""
|
||||
|
||||
msgid "Rank Math Dashboard"
|
||||
msgstr ""
|
||||
|
||||
@@ -2370,7 +2432,7 @@ msgstr ""
|
||||
msgid "Please update the Rank Math SEO plugin to the latest version to use this feature."
|
||||
msgstr ""
|
||||
|
||||
msgid "This feature is only available for Content AI subscribers."
|
||||
msgid "This feature is only available for Rank Math AI subscribers."
|
||||
msgstr ""
|
||||
|
||||
msgid "Oops! Too many requests in a short time. Please try again after some time."
|
||||
@@ -2437,9 +2499,6 @@ msgstr ""
|
||||
msgid "Items per page"
|
||||
msgstr ""
|
||||
|
||||
msgid "404 Monitor"
|
||||
msgstr ""
|
||||
|
||||
msgid "Records the URLs on which visitors & search engines run into 404 Errors. You can also turn on Redirections to redirect the error causing URLs to other URLs."
|
||||
msgstr ""
|
||||
|
||||
@@ -2455,9 +2514,6 @@ msgstr ""
|
||||
msgid "Enable support for the structured data, which adds Schema code in your website, resulting in rich search results, better CTR and more traffic."
|
||||
msgstr ""
|
||||
|
||||
msgid "Sitemap"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enable Rank Math's sitemap feature, which helps search engines intelligently crawl your website's content. It also supports hreflang tag."
|
||||
msgstr ""
|
||||
|
||||
@@ -2627,7 +2683,7 @@ msgstr ""
|
||||
msgid "Unlimited personal websites"
|
||||
msgstr ""
|
||||
|
||||
msgid "Free 15-Day Content AI Trial"
|
||||
msgid "Free 15-day Rank Math AI Trial"
|
||||
msgstr ""
|
||||
|
||||
msgid "Track 500 Keywords"
|
||||
@@ -2811,6 +2867,15 @@ msgstr ""
|
||||
msgid "AI Visibility %s"
|
||||
msgstr ""
|
||||
|
||||
msgid "Daily"
|
||||
msgstr ""
|
||||
|
||||
msgid "Weekly"
|
||||
msgstr ""
|
||||
|
||||
msgid "Monthly"
|
||||
msgstr ""
|
||||
|
||||
msgid "Rank Math account not connected. Please connect your account and try again."
|
||||
msgstr ""
|
||||
|
||||
@@ -2821,6 +2886,10 @@ msgstr ""
|
||||
msgid "AI Visibility API returned an invalid response."
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: comma-separated list of allowed cadences.
|
||||
msgid "The selected analysis frequency is not available on your plan. Allowed frequencies: %s. Upgrade your plan to unlock more frequency options."
|
||||
msgstr ""
|
||||
|
||||
msgid "Brand UUID."
|
||||
msgstr ""
|
||||
|
||||
@@ -2836,12 +2905,21 @@ msgstr ""
|
||||
msgid "ISO 3166-1 alpha-2 country code (e.g. \"US\", \"HU\")."
|
||||
msgstr ""
|
||||
|
||||
msgid "Output language to use when analyzing/generating content for this brand. Independent of `locale` (target country). Required; immutable after creation."
|
||||
msgstr ""
|
||||
|
||||
msgid "Analysis refresh cadence. Omitted → backend applies the account plan's default."
|
||||
msgstr ""
|
||||
|
||||
msgid "Query UUID."
|
||||
msgstr ""
|
||||
|
||||
msgid "Whether the query is enabled for analysis."
|
||||
msgstr ""
|
||||
|
||||
msgid "Please select a language for this brand."
|
||||
msgstr ""
|
||||
|
||||
msgid "No fields to update."
|
||||
msgstr ""
|
||||
|
||||
@@ -2854,6 +2932,22 @@ msgstr ""
|
||||
msgid "We could not activate your trial. Please try again."
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: supported platform IDs.
|
||||
msgid "AI platforms to track for this brand. Supported values: %s. Tracking more than one platform per brand requires the Expert plan."
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: supported platform IDs.
|
||||
msgid "Please specify which AI platforms to track. Supported values: %s."
|
||||
msgstr ""
|
||||
|
||||
#. translators: %s: supported platform IDs.
|
||||
msgid "No valid AI platforms were provided. Supported values: %s."
|
||||
msgstr ""
|
||||
|
||||
#. translators: 1: platforms allowed on the current plan, 2: supported platform IDs.
|
||||
msgid "Your plan allows tracking %1$d AI platform(s) per brand — upgrade to the Expert plan to track more. Supported values: %2$s."
|
||||
msgstr ""
|
||||
|
||||
msgid "Data fetching cancelled."
|
||||
msgstr ""
|
||||
|
||||
@@ -3245,7 +3339,7 @@ msgstr ""
|
||||
msgid "Get sophisticated AI suggestions for related Keywords, Questions & Links to include in the SEO meta & Content Area. %s."
|
||||
msgstr ""
|
||||
|
||||
msgid "Content AI Plan"
|
||||
msgid "Rank Math AI Plan"
|
||||
msgstr ""
|
||||
|
||||
msgid "Content AI Credits"
|
||||
@@ -3377,7 +3471,7 @@ msgstr ""
|
||||
msgid "A list of prompts received from the API to be saved in the database."
|
||||
msgstr ""
|
||||
|
||||
msgid "Content AI plan to update in the Database."
|
||||
msgid "Rank Math AI plan to update in the Database."
|
||||
msgstr ""
|
||||
|
||||
msgid "Content AI reset date to update in the Database"
|
||||
@@ -3408,7 +3502,7 @@ msgid "No data found for the researched keyword."
|
||||
msgstr ""
|
||||
|
||||
#. Translators: link to the update page.
|
||||
msgid "There is a new version of Content AI available! %s the Rank Math SEO plugin to use this feature."
|
||||
msgid "There is a new version of Rank Math AI available! %s the Rank Math SEO plugin to use this feature."
|
||||
msgstr ""
|
||||
|
||||
msgid "Please update"
|
||||
@@ -7491,10 +7585,10 @@ msgstr ""
|
||||
msgid "Start using Content AI by connecting your RankMath.com Account"
|
||||
msgstr ""
|
||||
|
||||
msgid "To access this Content AI feature, you need to have an active subscription plan."
|
||||
msgid "To access this Content AI feature, you need to have an active Rank Math AI subscription."
|
||||
msgstr ""
|
||||
|
||||
msgid "To access this Content AI feature, you have to purchase a Content AI Subscription."
|
||||
msgid "To access this Content AI feature, you have to purchase a Rank Math AI subscription."
|
||||
msgstr ""
|
||||
|
||||
msgid "You are one step away from unlocking this premium feature along with many more."
|
||||
@@ -7563,13 +7657,13 @@ msgstr ""
|
||||
msgid " We are sorry for the inconvenience."
|
||||
msgstr ""
|
||||
|
||||
msgid "⛔️ Content AI Credit Alert!"
|
||||
msgid "⛔️ Rank Math AI Usage Alert!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Your monthly Content AI credits have been fully utilized. You can wait till %s for your credits to refresh or upgrade to continue enjoying seamless content creation"
|
||||
msgid "Your monthly Rank Math AI usage has been exhausted. You can wait till %s for your limit to refresh or upgrade to continue enjoying seamless content creation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Your monthly Content AI credits have been fully utilized. To continue enjoying seamless content creation, simply click the button below to upgrade your plan and access more credits."
|
||||
msgid "Your monthly Rank Math AI usage limit has been exhausted. To continue enjoying seamless content creation, simply click the button below to upgrade your plan for higher limits."
|
||||
msgstr ""
|
||||
|
||||
msgid "Missing Credits?"
|
||||
@@ -7731,6 +7825,12 @@ msgstr ""
|
||||
msgid "Your llms.txt file is available at: "
|
||||
msgstr ""
|
||||
|
||||
msgid "Summary"
|
||||
msgstr ""
|
||||
|
||||
msgid "A short summary of your site, shown as a quote block right below the title in your llms.txt file."
|
||||
msgstr ""
|
||||
|
||||
msgid "%s (opens in a new tab)"
|
||||
msgstr ""
|
||||
|
||||
@@ -8805,15 +8905,6 @@ msgstr ""
|
||||
msgid "Pending"
|
||||
msgstr ""
|
||||
|
||||
msgid "Weekly"
|
||||
msgstr ""
|
||||
|
||||
msgid "Monthly (Coming Soon)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Daily (Coming Soon)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Coming Soon"
|
||||
msgstr ""
|
||||
|
||||
@@ -8847,12 +8938,26 @@ msgstr ""
|
||||
msgid "Target Country (Optional)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Output Language"
|
||||
msgstr ""
|
||||
|
||||
msgid "Language can't be changed after a brand is created."
|
||||
msgstr ""
|
||||
|
||||
msgid "Frequency of analyses"
|
||||
msgstr ""
|
||||
|
||||
msgid "AI Platforms"
|
||||
msgstr ""
|
||||
|
||||
msgid "Your plan lets you track %d platform per brand. Upgrade to Expert to track them all at once."
|
||||
msgid_plural "Your plan lets you track %d platforms per brand. Upgrade to Expert to track them all at once."
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
msgid "Select at least one AI platform."
|
||||
msgstr ""
|
||||
|
||||
msgid "Brand name is required."
|
||||
msgstr ""
|
||||
|
||||
@@ -8865,6 +8970,9 @@ msgstr ""
|
||||
msgid "Description is required."
|
||||
msgstr ""
|
||||
|
||||
msgid "Language is required."
|
||||
msgstr ""
|
||||
|
||||
msgid "Adding…"
|
||||
msgstr ""
|
||||
|
||||
@@ -9129,7 +9237,7 @@ msgstr ""
|
||||
msgid "Average rank score across all tracked brands."
|
||||
msgstr ""
|
||||
|
||||
msgid "Analyses in last 24h"
|
||||
msgid "Analyses in the last 7 days"
|
||||
msgstr ""
|
||||
|
||||
msgid "Total analysis runs completed in the past 24 hours."
|
||||
@@ -9648,7 +9756,7 @@ msgstr ""
|
||||
msgid "Upgrade to buy more credits from "
|
||||
msgstr ""
|
||||
|
||||
msgid "Content AI Pricing."
|
||||
msgid "Rank Math AI Pricing."
|
||||
msgstr ""
|
||||
|
||||
msgid "here."
|
||||
@@ -9801,9 +9909,6 @@ msgstr ""
|
||||
msgid "The style of the content."
|
||||
msgstr ""
|
||||
|
||||
msgid "Output Language"
|
||||
msgstr ""
|
||||
|
||||
msgid "Topic"
|
||||
msgstr ""
|
||||
|
||||
@@ -10635,9 +10740,6 @@ msgstr ""
|
||||
msgid "Image URL is missing."
|
||||
msgstr ""
|
||||
|
||||
msgid "50 Content AI credits will be used to generate the Alt"
|
||||
msgstr ""
|
||||
|
||||
msgid "Generate With AI"
|
||||
msgstr ""
|
||||
|
||||
@@ -10653,13 +10755,13 @@ msgstr ""
|
||||
msgid "Improve Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "You have exhausted your Content AI Credits."
|
||||
msgid "You have exhausted your Rank Math AI Usage."
|
||||
msgstr ""
|
||||
|
||||
msgid "Get more"
|
||||
msgstr ""
|
||||
|
||||
msgid "You do not have a Content AI plan."
|
||||
msgid "You do not have a Rank Math AI plan."
|
||||
msgstr ""
|
||||
|
||||
msgid "Choose your plan"
|
||||
@@ -10788,12 +10890,6 @@ msgstr ""
|
||||
msgid "Select Repeat Frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Daily"
|
||||
msgstr ""
|
||||
|
||||
msgid "Monthly"
|
||||
msgstr ""
|
||||
|
||||
msgid "Yearly"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: Rank Math SEO
|
||||
* Version: 1.0.278
|
||||
* Version: 1.0.279
|
||||
* Plugin URI: https://rankmath.com/
|
||||
* Description: Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.
|
||||
* Author: Rank Math SEO
|
||||
@@ -34,7 +34,7 @@ final class RankMath {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '1.0.278';
|
||||
public $version = '1.0.279';
|
||||
|
||||
/**
|
||||
* Rank Math database version.
|
||||
@@ -253,6 +253,9 @@ final class RankMath {
|
||||
if ( ! defined( 'CONTENT_AI_URL' ) ) {
|
||||
define( 'CONTENT_AI_URL', 'https://cai.rankmath.com' );
|
||||
}
|
||||
if ( ! defined( 'RANK_MATH_AIV_URL' ) ) {
|
||||
define( 'RANK_MATH_AIV_URL', 'https://ai-visibility.rankmath.com' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ Tags: seo, google search console, schema, redirection, xml sitemap
|
||||
Tested up to: 7.1
|
||||
Requires at least: 6.7
|
||||
Requires PHP: 7.4
|
||||
Stable tag: 1.0.278
|
||||
Stable tag: 1.0.279
|
||||
License: GPLv3 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
@@ -16,7 +16,7 @@ Grow your organic traffic and AI visibility with powerful SEO tools, XML sitemap
|
||||
### Rank Math SEO – WordPress AI SEO Plugin to Rank Higher 📈 ###
|
||||
★★★★★<br>
|
||||
|
||||
**Rank Math SEO** helps you stay ahead of competitors with **AI-powered SEO tools** built for modern search engines, AI assistants, and evolving search experiences.
|
||||
**Rank Math SEO** helps you stay ahead of competitors with **AI-powered SEO tools** built for today's search engines and AI assistants.
|
||||
|
||||
The plugin brings **powerful AI SEO tools right into WordPress**. It helps you optimize content, include Schema Markup, add smart internal links, target the right keywords, run SEO checks, and more.
|
||||
|
||||
@@ -37,7 +37,7 @@ Over 4 million WordPress websites trust Rank Math to grow their organic traffic
|
||||
|
||||
|
||||
➜ AI Visibility score to monitor your brand’s visibility
|
||||
➜ Track how ChatGPT and other AI platforms mention your brand
|
||||
➜ Track how ChatGPT and Gemini mention your brand
|
||||
➜ Monitor your brand’s sentiment across AI responses
|
||||
➜ See how you compare against your competitors in AI Search
|
||||
➜ Access complete transcripts of AI responses
|
||||
@@ -53,7 +53,7 @@ Over 4 million WordPress websites trust Rank Math to grow their organic traffic
|
||||
➜ View every internal and external link on your site from one dashboard
|
||||
➜ Update hundreds of links at once instead of editing pages one by one
|
||||
➜ Get smart link suggestions as you write, right inside the editor
|
||||
➜ Monitor broken links, redirects and overall link health
|
||||
➜ Monitor broken links, redirects, and overall link health
|
||||
➜ Automatically link keyword variations to the right pages
|
||||
➜ Get related post suggestions that keep readers on your site longer
|
||||
➜ Find pages nobody links to and reconnect them to the rest of your site
|
||||
@@ -81,7 +81,7 @@ Get Started with Content AI for FREE and enjoy:
|
||||
See the features only Rank Math offers, and find out why it's the **right SEO plugin for you**.
|
||||
|
||||
✔ Intuitive [Setup Wizard](https://rankmath.com/kb/how-to-setup/?utm_source=LP&utm_campaign=WP) that configures Rank Math automatically for your site
|
||||
✔ [16+ Schema types](https://rankmath.com/kb/rich-snippets/?utm_source=LP&utm_campaign=WP#schema-types-offers-by-rank-math) to add rich results in few clicks
|
||||
✔ [16+ Schema types](https://rankmath.com/kb/rich-snippets/?utm_source=LP&utm_campaign=WP#schema-types-offers-by-rank-math) to add rich results in a few clicks
|
||||
✔ Optimize post for unlimited focus keywords (5 by default, unlimited [with this filter](https://rankmath.com/kb/filters-hooks-api-developer/?utm_source=LP&utm_campaign=WP#unlimited-keywords))
|
||||
✔ [Content AI](https://rankmath.com/kb/how-to-use-content-ai/?utm_source=LP&utm_campaign=WP) to help you write SEO-friendly content
|
||||
✔ Google Search Console integration
|
||||
@@ -117,7 +117,7 @@ See the features only Rank Math offers, and find out why it's the **right SEO pl
|
||||
✔ 1-Click Import from Redirection plugin
|
||||
✔ Translation plugins support including WPML, Weglot, TranslatePress and Polylang
|
||||
✔ Theme support including Astra, Kadence, Flothemes, OceanWP, Themify, Schema Theme and more
|
||||
✔ Page builder support including Oxygen, WPBakery, Avada, Beaver Builder, and Page Builder Framework and more
|
||||
✔ Page builder support including Oxygen, WPBakery, Avada, Beaver Builder, Page Builder Framework and more
|
||||
|
||||
### Who Can Benefit From Rank Math? ###
|
||||
|
||||
@@ -136,6 +136,27 @@ See the features only Rank Math offers, and find out why it's the **right SEO pl
|
||||
✔ Vloggers (Video Bloggers)
|
||||
✔ Or any WordPress Website
|
||||
|
||||
### Which Schema Types Does Rank Math Support? ###
|
||||
✔ Article Schema
|
||||
✔ Book Schema
|
||||
✔ Course Schema
|
||||
✔ Event Schema
|
||||
✔ FAQ Schema
|
||||
✔ How To Schema
|
||||
✔ Job Posting Schema
|
||||
✔ Music Schema
|
||||
✔ Person Schema
|
||||
✔ Organization Schema
|
||||
✔ Local Business Schema
|
||||
✔ Product Schema
|
||||
✔ Profile Page Schema
|
||||
✔ Recipe Schema
|
||||
✔ Restaurant Schema
|
||||
✔ Service Schema
|
||||
✔ Video Schema
|
||||
✔ Breadcrumb Schema
|
||||
✔ And much more...
|
||||
|
||||
### Take a sneak peek into Rank Math’s features ###
|
||||
|
||||
#### Detailed Setup Tutorial ####
|
||||
@@ -250,7 +271,7 @@ Rank Math® SEO is a registered trademark. Please use the following format when
|
||||
3. You’re done!
|
||||
|
||||
= Getting Started: =
|
||||
**<a href="https://rankmath.com/kb/how-to-setup/?utm_source=LP&utm_campaign=WP" target="_blank">1. How to Setup Rank Math:</a>** Once you install Rank Math for the first time, you will be greeted with the Setup Wizard, which is discussed in detail here.
|
||||
**<a href="https://rankmath.com/kb/how-to-setup/?utm_source=LP&utm_campaign=WP" target="_blank">1. How to Set up Rank Math:</a>** Once you install Rank Math for the first time, you will be greeted with the Setup Wizard, which is discussed in detail here.
|
||||
|
||||
**<a href="https://rankmath.com/kb/wordpress/seo-suite/?utm_source=LP&utm_campaign=WP" target="_blank">2. User Documentation:</a>** Although Rank Math is already easy to set up, we've put together tutorials, guides, and some knowledge bases to help you set up and get started with Rank Math.
|
||||
|
||||
@@ -266,7 +287,7 @@ Rank Math® SEO is a registered trademark. Please use the following format when
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Can I transfer my SEO & Redirection settings from another plugin to Rank Math? =
|
||||
Absolutely. Rank Math has a built-in feature to import SEO settings from popular SEO plugins like Yoast SEO, Yoast SEO Premium, AIO SEO Pack, All In One Schema Rich Snippets, and Redirection. Once you install Rank Math and run the setup wizard, you'll see a dedicated step where you'll get to import all your SEO settings to Rank Math.
|
||||
Yes. Rank Math has a built-in feature to import SEO settings from popular SEO plugins like Yoast SEO, Yoast SEO Premium, AIO SEO Pack, SEOPress, All In One Schema Rich Snippets, and Redirection. Once you install Rank Math and run the setup wizard, you'll see a dedicated step where you'll get to import all your SEO settings to Rank Math.
|
||||
|
||||
= What themes does Rank Math support? =
|
||||
Rank Math has been tested with many WordPress themes and supports all major WordPress themes. Rank Math follows WordPress plugin guidelines, so it works perfectly with any theme. If you've installed Rank Math and are facing issues, it might not be because of theme incompatibility. Please contact the support team by opening a support ticket in our support forum, and we will fix it for you.
|
||||
@@ -274,11 +295,11 @@ Rank Math has been tested with many WordPress themes and supports all major Word
|
||||
= What plugins is Rank Math compatible with? =
|
||||
Rank Math has been designed using WordPress' strict plugin development guidelines and is compatible with most plugins. Using another SEO plugin alongside Rank Math can cause conflicts if they perform similar functions. For best results, disable or delete any other SEO plugins.
|
||||
|
||||
= Will my website slow down if I Install Rank Math? =
|
||||
No. Rank Math's code has been created and optimized for maximum performance. That is why using Rank Math on your website will not slow down your website. On the contrary, your website will perform better than ever , as Rank Math does the job of multiple plugins in one. For best results, disable or delete any other SEO plugins.
|
||||
= Will my website slow down if I install Rank Math? =
|
||||
No. Rank Math's code has been created and optimized for maximum performance. That is why using Rank Math on your website will not slow down your website. On the contrary, your website will perform better than ever, as Rank Math does the job of multiple plugins in one. For best results, disable or delete any other SEO plugins.
|
||||
|
||||
= Is creating a Rank Math account needed to use the plugin? =
|
||||
Not at all. Creating a FREE Rank Math account is needed only to utilize our API, which allows you get automatic keyword suggestions from Google and run SEO Site Analysis inside WordPress. <a href="https://rankmath.com/kb/free-account-benefits/?utm_source=LP&utm_campaign=WP" target="_blank">You can read more about that here.</a>
|
||||
Not at all. Creating a FREE Rank Math account is needed only to utilize our API, which allows you to get automatic keyword suggestions from Google and run SEO Site Analysis inside WordPress. <a href="https://rankmath.com/kb/free-account-benefits/?utm_source=LP&utm_campaign=WP" target="_blank">You can read more about that here.</a>
|
||||
|
||||
= Will you set up Rank Math on my website? =
|
||||
Rank Math is pretty easy to set up on your website. Apart from detailed instructions on installing Rank Math on our website, we've built a user-friendly setup wizard that will help you set up and configure Rank Math ideally for your website. If you face any issues even after using the setup wizard, please get in touch with the support team by sending an email to support@rankmath.com
|
||||
@@ -287,7 +308,7 @@ Rank Math is pretty easy to set up on your website. Apart from detailed instruct
|
||||
It is recommended to remove other SEO plugins. Rank Math is designed to be an all-rounder SEO plugin that handles everything SEO-related. Using other SEO plugins alongside Rank Math can hurt your website's performance and cause conflicting SEO results.
|
||||
|
||||
= I already use an SEO plugin. Can I use Rank Math on top of that plugin? =
|
||||
We do not recommend it. Rank Math has all the functionalities you need in an SEO plugin. You can do that if you still prefer using another plugin for a specific feature. However, we recommend that you turn off that functionality of Rank Math to avoid potential conflicts or issues.
|
||||
We do not recommend it. Rank Math has all the functionalities you need in an SEO plugin. You can do that if you still prefer using another plugin for a specific feature. However, we recommend that you turn off that functionality in Rank Math to avoid potential conflicts or issues.
|
||||
|
||||
= Will I lose my rankings if I switch to Rank Math? =
|
||||
No, you won't. When you install Rank Math, it will seamlessly import your settings from your current SEO plugin. Once the process is complete, the search engines won't notice a change on your website.
|
||||
@@ -299,7 +320,7 @@ If you set up Rank Math from scratch, your search engine rankings will depend on
|
||||
Please report security bugs found in the source code of the Rank Math SEO plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/9e5fb4c0-23d7-4a55-9a5c-256a4c6daf1e). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
|
||||
|
||||
= Can I use Rank Math on a WordPress.com website? =
|
||||
Yes, as the plugin is provided through WordPress.org, it is available on WordPress.com as well. However, you might be required to opt for the business plan on WordPress.com.
|
||||
Yes, as the plugin is provided through WordPress.org, it is available on WordPress.com. However, you might be required to opt for the business plan on WordPress.com.
|
||||
|
||||
= I have further questions; how do I contact you? =
|
||||
Please drop us an email at support@rankmath.com, and we will be more than happy to assist you.
|
||||
@@ -407,14 +428,14 @@ Terms of service: https://developers.facebook.com/terms/
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.278 [Sep 08, 2026] =
|
||||
- Added [HUGE!] MCP Tools now allow users to [connect with AI assistants through OAuth](https://rankmath.com/kb/connect-rank-math-mcp-with-claude-desktop/).
|
||||
- Added new [MCP Tools](https://rankmath.com/kb/mcp-tools/) to fetch Redirections, Robots.txt, and LLMs.txt data.
|
||||
- Added Content AI support to pre-fill the Focus Keyword field using the keywords already added to the post.
|
||||
- Fixed the Post/Page editor incorrectly showing "Review 1 change" with a save prompt on every load when using block themes.
|
||||
- Fixed the [Recalculate SEO Score option](https://rankmath.com/kb/seo-score-not-available/#import-data) showing in Redirections & Schema plugin importers, where it does not apply.
|
||||
- Fixed [404 Monitor](https://rankmath.com/kb/monitor-404-errors/) exclude paths losing their comparison key when multiple paths were saved at once.
|
||||
- Fixed a compatibility issue with WPML where the Local SEO Contact page was missing the `ContactPage` Schema type for non-default languages.
|
||||
= 1.0.279 [Sep 22, 2026] =
|
||||
- [HUGE!] Added Gemini Tracking, Multi-Language Support, and Daily/Weekly/Monthly refresh options to [AI Visibility] (https://rankmath.com/ai-visibility/?play-video=gS5-DFQrSxs).
|
||||
- Added `rank-math/get-404-logs` and `rank-math/get-sitemap-status` MCP tools to expose [404 Monitor](https://rankmath.com/kb/monitor-404-errors/) log data and sitemap status/sub-type data to AI assistants.
|
||||
- Improved [llms.txt](https://rankmath.com/kb/llms-txt/) output to conform to the latest llms.txt specification.
|
||||
- Fixed AI Visibility Brand detail page was missing data shown on the dashboard, and the "Analyses in last 24h" label was misleading.
|
||||
- Fixed `rank-math/get-post-links` MCP tool to correctly enforce per-post capability checks.
|
||||
- Fixed Link Suggestions was building link HTML by unescaped string concatenation, allowing unsafe URL and link text values into block content.
|
||||
- Fixed Analytics Objects table `page` column was not showing accurate values for WPML translated pages.
|
||||
|
||||
|
||||
Full changelog can be found here - **[Rank Math changelog](https://rankmath.com/changelog/?utm_source=Plugin&utm_medium=Changelog&utm_campaign=WP)**
|
||||
+1
-1
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInita50e6b304efbc99120a5f1c6ce16f39b::getLoader();
|
||||
return ComposerAutoloaderInitda5118e07739bcc2a9ee8b03eeea8972::getLoader();
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
---
|
||||
name: beads
|
||||
description: Use when working in a repository that uses bd or Beads for durable project task tracking, issue dependencies, blocker management, multi-session handoff, or shared work memory. Trigger when the user asks to find ready work, claim or close tasks, create follow-up work, inspect blockers, recover project context, or choose between local planning and persistent project tracking.
|
||||
---
|
||||
|
||||
# Beads
|
||||
|
||||
Use Beads as the shared project task system. Local plans, scratch files, and personal memories are useful, but they are not the durable source of truth for project work.
|
||||
|
||||
## First Step
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
bd prime
|
||||
```
|
||||
|
||||
If that prints nothing, check whether the repository has an active Beads workspace:
|
||||
|
||||
```bash
|
||||
bd where
|
||||
```
|
||||
|
||||
## Preferred Route
|
||||
|
||||
Use the `bd` CLI when shell access is available. It is the most compact and direct Beads interface.
|
||||
|
||||
## Core CLI Workflow
|
||||
|
||||
1. Find work:
|
||||
|
||||
```bash
|
||||
bd ready
|
||||
bd list --status=open
|
||||
bd list --status=in_progress
|
||||
```
|
||||
|
||||
2. Inspect before editing:
|
||||
|
||||
```bash
|
||||
bd show <id>
|
||||
```
|
||||
|
||||
3. Claim work atomically:
|
||||
|
||||
```bash
|
||||
bd update <id> --claim
|
||||
```
|
||||
|
||||
4. Create durable follow-up work when implementation reveals new tasks:
|
||||
|
||||
```bash
|
||||
bd create "Short title" --description="Why this exists and what needs to be done" --type=task --priority=2
|
||||
```
|
||||
|
||||
5. Close completed work:
|
||||
|
||||
```bash
|
||||
bd close <id> --reason="Completed"
|
||||
```
|
||||
|
||||
## What Belongs In Beads
|
||||
|
||||
Use Beads for:
|
||||
|
||||
- shared project tasks
|
||||
- blockers and dependencies
|
||||
- discovered follow-up work
|
||||
- work that must survive thread reset, compaction, or handoff
|
||||
- status that another person or agent should be able to resume
|
||||
|
||||
Use agent-local planning tools only for the current turn's execution checklist. Do not treat them as shared project state.
|
||||
|
||||
## Rules
|
||||
|
||||
- Do not create markdown TODO files as the source of truth when Beads is available.
|
||||
- Do not use `bd edit`; it opens an interactive editor. Use `bd update` flags instead.
|
||||
- Prefer `--json` when parsing `bd` output programmatically.
|
||||
- If hooks are installed, `bd prime` may already be injected. Run it manually when context is missing.
|
||||
- Do not auto-close or mutate tasks unless the work is actually complete.
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
interface:
|
||||
display_name: "Beads"
|
||||
short_description: "Project task tracking with bd"
|
||||
default_prompt: "Use $beads to inspect ready work and manage durable project tasks."
|
||||
@@ -1,68 +0,0 @@
|
||||
# Beads Configuration File
|
||||
# This file configures default behavior for all bd commands in this repository
|
||||
# All settings can also be set via environment variables (BD_* prefix)
|
||||
# or overridden with command-line flags
|
||||
|
||||
# Issue prefix for this repository (used by bd init)
|
||||
# If not set, bd init will auto-detect from directory name
|
||||
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
|
||||
# issue-prefix: ""
|
||||
|
||||
# Use no-db mode: JSONL-only, no Dolt database
|
||||
# When true, .beads/issues.jsonl is the only local store
|
||||
# no-db: false
|
||||
|
||||
# Enable JSON output by default
|
||||
# json: false
|
||||
|
||||
# Feedback title formatting for mutating commands (create/update/close/dep/edit)
|
||||
# 0 = hide titles, N > 0 = truncate to N characters
|
||||
# output:
|
||||
# title-length: 255
|
||||
|
||||
# Default actor for audit trails (overridden by BEADS_ACTOR or --actor)
|
||||
# actor: ""
|
||||
|
||||
# Export events (audit trail) to .beads/events.jsonl on each flush/sync
|
||||
# When enabled, new events are appended incrementally using a high-water mark.
|
||||
# Use 'bd export --events' to trigger manually regardless of this setting.
|
||||
# events-export: false
|
||||
|
||||
# Multi-repo configuration (experimental - bd-307)
|
||||
# Allows hydrating from multiple repositories and routing writes to the correct database
|
||||
# repos:
|
||||
# primary: "." # Primary repo (where this database lives)
|
||||
# additional: # Additional repos to hydrate from (read-only)
|
||||
# - ~/beads-planning # Personal planning repo
|
||||
# - ~/work-planning # Work planning repo
|
||||
|
||||
# Dolt-native backup (periodic backup for off-machine recovery)
|
||||
# This is full database backup only. Cross-machine sync uses Dolt remotes.
|
||||
# backup:
|
||||
# enabled: false # Disable auto-backup entirely
|
||||
# interval: 15m # Minimum time between auto-backups
|
||||
# git-push: false # Disable git push (backup locally only)
|
||||
# git-repo: "" # Separate git repo for backups (default: project repo)
|
||||
|
||||
# Optional JSONL auto-export for viewers, interchange, and issue-level migration.
|
||||
# Disabled by default; enable only when an integration needs fresh .beads/issues.jsonl.
|
||||
# Use relative paths under .beads/ for JSONL import/export filenames.
|
||||
# export:
|
||||
# auto: false
|
||||
# path: issues.jsonl
|
||||
# interval: 60s
|
||||
# git-add: false
|
||||
# import:
|
||||
# path: issues.jsonl
|
||||
|
||||
# Integration settings (access with 'bd config get/set')
|
||||
# Non-secret keys (stored in the database):
|
||||
# - jira.url, jira.project
|
||||
# - linear.team_id
|
||||
# - github.org, github.repo
|
||||
#
|
||||
# Secret keys (stored in this file but prefer env vars to avoid git exposure):
|
||||
# - linear.api_key → use LINEAR_API_KEY env var instead
|
||||
# - github.token → use GITHUB_TOKEN env var instead
|
||||
|
||||
sync.remote: "git+ssh://git@github.com/CMB2/CMB2.git"
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# --- BEGIN BEADS INTEGRATION v1.0.5 ---
|
||||
# This section is managed by beads. Do not remove these markers.
|
||||
if command -v bd >/dev/null 2>&1; then
|
||||
export BD_GIT_HOOK=1
|
||||
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||
_bd_used_perl=0
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$_bd_timeout" bd hooks run post-checkout "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
gtimeout "$_bd_timeout" bd hooks run post-checkout "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v perl >/dev/null 2>&1; then
|
||||
_bd_used_perl=1
|
||||
perl -e 'alarm shift; exec @ARGV' "$_bd_timeout" bd hooks run post-checkout "$@"
|
||||
_bd_exit=$?
|
||||
else
|
||||
echo >&2 "beads: hook 'post-checkout' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT"
|
||||
bd hooks run post-checkout "$@"
|
||||
_bd_exit=$?
|
||||
fi
|
||||
if [ $_bd_exit -eq 124 ] || { [ $_bd_used_perl -eq 1 ] && [ $_bd_exit -eq 142 ]; }; then
|
||||
echo >&2 "beads: hook 'post-checkout' timed out after ${_bd_timeout}s — continuing without beads"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -eq 3 ]; then
|
||||
echo >&2 "beads: database not initialized — skipping hook 'post-checkout'"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||
fi
|
||||
# --- END BEADS INTEGRATION v1.0.5 ---
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# --- BEGIN BEADS INTEGRATION v1.0.5 ---
|
||||
# This section is managed by beads. Do not remove these markers.
|
||||
if command -v bd >/dev/null 2>&1; then
|
||||
export BD_GIT_HOOK=1
|
||||
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||
_bd_used_perl=0
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$_bd_timeout" bd hooks run post-merge "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
gtimeout "$_bd_timeout" bd hooks run post-merge "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v perl >/dev/null 2>&1; then
|
||||
_bd_used_perl=1
|
||||
perl -e 'alarm shift; exec @ARGV' "$_bd_timeout" bd hooks run post-merge "$@"
|
||||
_bd_exit=$?
|
||||
else
|
||||
echo >&2 "beads: hook 'post-merge' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT"
|
||||
bd hooks run post-merge "$@"
|
||||
_bd_exit=$?
|
||||
fi
|
||||
if [ $_bd_exit -eq 124 ] || { [ $_bd_used_perl -eq 1 ] && [ $_bd_exit -eq 142 ]; }; then
|
||||
echo >&2 "beads: hook 'post-merge' timed out after ${_bd_timeout}s — continuing without beads"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -eq 3 ]; then
|
||||
echo >&2 "beads: database not initialized — skipping hook 'post-merge'"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||
fi
|
||||
# --- END BEADS INTEGRATION v1.0.5 ---
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# --- BEGIN BEADS INTEGRATION v1.0.5 ---
|
||||
# This section is managed by beads. Do not remove these markers.
|
||||
if command -v bd >/dev/null 2>&1; then
|
||||
export BD_GIT_HOOK=1
|
||||
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||
_bd_used_perl=0
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$_bd_timeout" bd hooks run pre-commit "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
gtimeout "$_bd_timeout" bd hooks run pre-commit "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v perl >/dev/null 2>&1; then
|
||||
_bd_used_perl=1
|
||||
perl -e 'alarm shift; exec @ARGV' "$_bd_timeout" bd hooks run pre-commit "$@"
|
||||
_bd_exit=$?
|
||||
else
|
||||
echo >&2 "beads: hook 'pre-commit' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT"
|
||||
bd hooks run pre-commit "$@"
|
||||
_bd_exit=$?
|
||||
fi
|
||||
if [ $_bd_exit -eq 124 ] || { [ $_bd_used_perl -eq 1 ] && [ $_bd_exit -eq 142 ]; }; then
|
||||
echo >&2 "beads: hook 'pre-commit' timed out after ${_bd_timeout}s — continuing without beads"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -eq 3 ]; then
|
||||
echo >&2 "beads: database not initialized — skipping hook 'pre-commit'"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||
fi
|
||||
# --- END BEADS INTEGRATION v1.0.5 ---
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# --- BEGIN BEADS INTEGRATION v1.0.5 ---
|
||||
# This section is managed by beads. Do not remove these markers.
|
||||
if command -v bd >/dev/null 2>&1; then
|
||||
export BD_GIT_HOOK=1
|
||||
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||
_bd_used_perl=0
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$_bd_timeout" bd hooks run pre-push "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
gtimeout "$_bd_timeout" bd hooks run pre-push "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v perl >/dev/null 2>&1; then
|
||||
_bd_used_perl=1
|
||||
perl -e 'alarm shift; exec @ARGV' "$_bd_timeout" bd hooks run pre-push "$@"
|
||||
_bd_exit=$?
|
||||
else
|
||||
echo >&2 "beads: hook 'pre-push' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT"
|
||||
bd hooks run pre-push "$@"
|
||||
_bd_exit=$?
|
||||
fi
|
||||
if [ $_bd_exit -eq 124 ] || { [ $_bd_used_perl -eq 1 ] && [ $_bd_exit -eq 142 ]; }; then
|
||||
echo >&2 "beads: hook 'pre-push' timed out after ${_bd_timeout}s — continuing without beads"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -eq 3 ]; then
|
||||
echo >&2 "beads: database not initialized — skipping hook 'pre-push'"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||
fi
|
||||
# --- END BEADS INTEGRATION v1.0.5 ---
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# --- BEGIN BEADS INTEGRATION v1.0.5 ---
|
||||
# This section is managed by beads. Do not remove these markers.
|
||||
if command -v bd >/dev/null 2>&1; then
|
||||
export BD_GIT_HOOK=1
|
||||
_bd_timeout=${BEADS_HOOK_TIMEOUT:-300}
|
||||
_bd_used_perl=0
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$_bd_timeout" bd hooks run prepare-commit-msg "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v gtimeout >/dev/null 2>&1; then
|
||||
gtimeout "$_bd_timeout" bd hooks run prepare-commit-msg "$@"
|
||||
_bd_exit=$?
|
||||
elif command -v perl >/dev/null 2>&1; then
|
||||
_bd_used_perl=1
|
||||
perl -e 'alarm shift; exec @ARGV' "$_bd_timeout" bd hooks run prepare-commit-msg "$@"
|
||||
_bd_exit=$?
|
||||
else
|
||||
echo >&2 "beads: hook 'prepare-commit-msg' running without timeout; install coreutils or perl to enable BEADS_HOOK_TIMEOUT"
|
||||
bd hooks run prepare-commit-msg "$@"
|
||||
_bd_exit=$?
|
||||
fi
|
||||
if [ $_bd_exit -eq 124 ] || { [ $_bd_used_perl -eq 1 ] && [ $_bd_exit -eq 142 ]; }; then
|
||||
echo >&2 "beads: hook 'prepare-commit-msg' timed out after ${_bd_timeout}s — continuing without beads"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -eq 3 ]; then
|
||||
echo >&2 "beads: database not initialized — skipping hook 'prepare-commit-msg'"
|
||||
_bd_exit=0
|
||||
fi
|
||||
if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
|
||||
fi
|
||||
# --- END BEADS INTEGRATION v1.0.5 ---
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
{"id":"int-f6186c1fddd8774503e521dfa8b8670e","kind":"field_change","created_at":"2026-05-31T00:00:12.920701Z","actor":"Justin Sternberg","issue_id":"cmb2-g75","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Pinned wp-env to 2622/2623, updated all 8889 refs, self-starting phptests; verified cold start + 214 tests pass"}}
|
||||
{"id":"int-f05369fcf819c002c87a25c82ac472de","kind":"field_change","created_at":"2026-05-31T00:14:44.983827Z","actor":"Justin Sternberg","issue_id":"cmb2-kr3","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Baseline screenshots/observations captured on WP 6.3.1 + develop; bug confirmed absent on pre-7.0."}}
|
||||
{"id":"int-afd5b3d83029cda4cf16d048e98c36b2","kind":"field_change","created_at":"2026-05-31T00:31:09.412889Z","actor":"Justin Sternberg","issue_id":"cmb2-oyp","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Bug reproduced on WP 7.0 + develop on both settings and post-edit surfaces; confirmed visually + via computed background-color."}}
|
||||
{"id":"int-9549a1593d112d2b39bba593ea15d1bd","kind":"field_change","created_at":"2026-05-31T00:34:04.776317Z","actor":"Justin Sternberg","issue_id":"cmb2-tl6","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"qa-1557 branch = develop + PR fix, ready to build."}}
|
||||
{"id":"int-7f549a6dc21af415f57991c1d16ff278","kind":"field_change","created_at":"2026-05-31T00:34:30.301373Z","actor":"Justin Sternberg","issue_id":"cmb2-8ww","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"npm run build:css clean; compiled CSS across all variants carries the :not(checkbox/radio):focus rule + fresh banner."}}
|
||||
{"id":"int-821e7108d8898d670ccfefa51b97fce6","kind":"field_change","created_at":"2026-05-31T00:37:37.67524Z","actor":"Justin Sternberg","issue_id":"cmb2-6j0","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"PR :not() fix verified on WP 7.0, both surfaces, via focus-independent CSSOM matches() check + computed style."}}
|
||||
{"id":"int-9a1a03859bd9b3d391abfef7cbad5ecc","kind":"field_change","created_at":"2026-05-31T00:39:28.329499Z","actor":"Justin Sternberg","issue_id":"cmb2-7ku","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"No back-compat regression on 6.3.1 with the :not() fix; checkbox/radio indicators (::before) unaffected, text tint preserved."}}
|
||||
{"id":"int-0399e8dc4cc2eabb55268aadbe84dd8d","kind":"field_change","created_at":"2026-05-31T00:40:54.575881Z","actor":"Justin Sternberg","issue_id":"cmb2-ec8","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Option B (full removal of focus-background rule) implemented and built; #fffff8 gone from all compiled CSS."}}
|
||||
{"id":"int-acef19ce9398e511d870cd408bb4608a","kind":"field_change","created_at":"2026-05-31T00:43:35.529154Z","actor":"Justin Sternberg","issue_id":"cmb2-8at","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Option B verified across 6.3.1 + 7.0 (both surfaces): fixes bug on 7.0, no regression on 6.3.1, intended text-tint removal only."}}
|
||||
{"id":"int-e2ce899d2f9c0628d914c2dc721064bf","kind":"field_change","created_at":"2026-05-31T00:56:22.447965Z","actor":"Justin Sternberg","issue_id":"cmb2-vr3","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"PR #1557 force-updated to clean Option B commit; title/description/QA-comment posted; awaiting merge."}}
|
||||
{"id":"int-b0d259257f751a7cc46d807c8171e59f","kind":"field_change","created_at":"2026-05-31T00:56:22.609131Z","actor":"Justin Sternberg","issue_id":"cmb2-14j","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"QA epic complete: bug reproduced + Option B fix verified on WP 7.0 and 6.3.1 (both surfaces); PR #1557 finalized with Option B."}}
|
||||
{"id":"int-609ac7c3963b63f52c482951e37a77cf","kind":"field_change","created_at":"2026-05-31T01:13:10.673448Z","actor":"Justin Sternberg","issue_id":"cmb2-do9","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Migrated wp-env off deprecated env/testsPort/testsEnvironment: dev env in .wp-env.json (2622, testsEnvironment:false) + isolated tests env in new .wp-env-tests.json (2623) via --config. Updated phptests (runs in cli container now, no tests-cli), env:tests:* scripts, Playwright webServer, CI test.yml, CLAUDE.md, playwright README. Verified: no deprecation warning, phpunit 214 pass, Playwright plugin+metabox specs pass."}}
|
||||
{"id":"int-fa30a19689a3cc8554fe4ffdb54845b6","kind":"field_change","created_at":"2026-05-31T01:28:09.672662Z","actor":"Justin Sternberg","issue_id":"cmb2-0sq","extra":{"field":"status","new_value":"in_progress","old_value":"open"}}
|
||||
{"id":"int-a18293201847231d3c19f8ee5825a9be","kind":"field_change","created_at":"2026-05-31T01:34:39.67677Z","actor":"Justin Sternberg","issue_id":"cmb2-cfj","extra":{"field":"status","new_value":"in_progress","old_value":"open"}}
|
||||
{"id":"int-bbff1f9ac7c003e0a91ee801fe7f5330","kind":"field_change","created_at":"2026-05-31T01:37:06.473028Z","actor":"Justin Sternberg","issue_id":"cmb2-0sq","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Set WP_DEBUG=true + WP_DEBUG_DISPLAY=false in .wp-env-tests.json: logs PHP deprecations without rendering into pages (verified visual suite stable). aec1d71"}}
|
||||
{"id":"int-6539bee7eabbcfa7c726d8833ca65a10","kind":"field_change","created_at":"2026-05-31T01:37:06.622781Z","actor":"Justin Sternberg","issue_id":"cmb2-cfj","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Simplified Playwright webServer command to 'npm run env:tests:start'; removed dead CI echo branch. aec1d71"}}
|
||||
{"id":"int-34391301c83184ac337692c0e67e01a9","kind":"field_change","created_at":"2026-05-31T02:04:33.067846Z","actor":"Justin Sternberg","issue_id":"cmb2-cz6","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Re-scoped Mobile/Tablet visual tests from fullPage post-new.php screenshots to the opened #cmb2_integration_tests_default_closed metabox element at 375px/768px viewports. Local baselines regenerated (mobile 353x230, tablet 746x193 — fields reflow captured); full visual suite passes deterministically across 2 consecutive runs. Committed to develop 74551bc (no PR). No CI impact (suite is CI-skipped)."}}
|
||||
@@ -1 +0,0 @@
|
||||
{"_type":"issue","id":"cmb2-u2a","title":"Harden #[AllowDynamicProperties] coverage across CMB2 class roots","description":"The PHP 8.2+ dynamic-property deprecation fix shipped only on the CMB2 class (a leaf), leaving CMB2_Field, all CMB2_Type_* field types, and all CMB2_Display_* classes still emitting deprecations when user code/extensions assign undeclared properties (CMB2's most common customization idiom). None of these classes define __set, so the deprecation fires. Not a regression (2.11.0 had zero coverage) but incomplete. Fix: place #[AllowDynamicProperties] on the extension-surface roots (CMB2_Base covers CMB2 + CMB2_Field via inheritance; CMB2_Type_Base; CMB2_Field_Display) and remove the now-redundant leaf attribute on CMB2. Parsed as a harmless # comment on PHP 7.4-7.x.","status":"closed","priority":1,"issue_type":"task","owner":"justin@dsgnwrks.pro","created_at":"2026-05-30T18:02:19Z","created_by":"Justin Sternberg","updated_at":"2026-05-30T18:13:36Z","started_at":"2026-05-30T18:02:24Z","closed_at":"2026-05-30T18:13:36Z","close_reason":"Widened #[AllowDynamicProperties] to CMB2_Base, CMB2_Type_Base, CMB2_Field_Display; pushed in f372385","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"database": "dolt",
|
||||
"backend": "dolt",
|
||||
"dolt_mode": "server",
|
||||
"dolt_server_port": 3308,
|
||||
"dolt_database": "beads_cmb2",
|
||||
"project_id": "0ab5e157-ff0a-4c5d-8948-2d6166a6d85b"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
[features]
|
||||
hooks = true
|
||||
@@ -0,0 +1,8 @@
|
||||
# Shell and CI environment variables override these local development values.
|
||||
WP_BASE_URL=http://localhost:2623
|
||||
WP_USERNAME=admin
|
||||
WP_PASSWORD=replace-with-local-password
|
||||
|
||||
# Use 1 only when WordPress is already running or its availability is known.
|
||||
SKIP_WP_SERVER=0
|
||||
SKIP_WP_CHECK=0
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"sub": true,
|
||||
"unused": true,
|
||||
"undef": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"globals": {
|
||||
"exports": true,
|
||||
"module": false
|
||||
},
|
||||
"predef": [
|
||||
"document",
|
||||
"window",
|
||||
"jQuery",
|
||||
"cmb2_l10",
|
||||
"wp",
|
||||
"tinyMCEPreInit",
|
||||
"tinyMCE",
|
||||
"console",
|
||||
"postboxes",
|
||||
"pagenow",
|
||||
"QTags",
|
||||
"quicktags",
|
||||
"_"
|
||||
]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"port": 2623,
|
||||
"plugins": ["."],
|
||||
"testsEnvironment": false,
|
||||
"config": {
|
||||
"WP_DEBUG": true,
|
||||
"WP_DEBUG_DISPLAY": false,
|
||||
"SCRIPT_DEBUG": false
|
||||
},
|
||||
"mappings": {
|
||||
"wp-content/mu-plugins/cmb2-test-fields.php": "./tests/playwright/fixtures/test-fields.php"
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
# Agent Instructions
|
||||
|
||||
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
```bash
|
||||
bd ready # Find available work
|
||||
bd show <id> # View issue details
|
||||
bd update <id> --claim # Claim work atomically
|
||||
bd close <id> # Complete work
|
||||
bd sync # Sync with git
|
||||
```
|
||||
|
||||
## Non-Interactive Shell Commands
|
||||
|
||||
**ALWAYS use non-interactive flags** with file operations to avoid hanging on confirmation prompts.
|
||||
|
||||
Shell commands like `cp`, `mv`, and `rm` may be aliased to include `-i` (interactive) mode on some systems, causing the agent to hang indefinitely waiting for y/n input.
|
||||
|
||||
**Use these forms instead:**
|
||||
```bash
|
||||
# Force overwrite without prompting
|
||||
cp -f source dest # NOT: cp source dest
|
||||
mv -f source dest # NOT: mv source dest
|
||||
rm -f file # NOT: rm file
|
||||
|
||||
# For recursive operations
|
||||
rm -rf directory # NOT: rm -r directory
|
||||
cp -rf source dest # NOT: cp -r source dest
|
||||
```
|
||||
|
||||
**Other commands that may prompt:**
|
||||
- `scp` - use `-o BatchMode=yes` for non-interactive
|
||||
- `ssh` - use `-o BatchMode=yes` to fail instead of prompting
|
||||
- `apt-get` - use `-y` flag
|
||||
- `brew` - use `HOMEBREW_NO_AUTO_UPDATE=1` env var
|
||||
|
||||
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:970c3bf2 -->
|
||||
## Beads Issue Tracker
|
||||
|
||||
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
|
||||
|
||||
### Quick Reference
|
||||
|
||||
```bash
|
||||
bd ready # Find available work
|
||||
bd show <id> # View issue details
|
||||
bd update <id> --claim # Claim work
|
||||
bd close <id> # Complete work
|
||||
```
|
||||
|
||||
### Rules
|
||||
|
||||
- Use `bd` for ALL task tracking — do NOT use TodoWrite, TaskCreate, or markdown TODO lists
|
||||
- Run `bd prime` for detailed command reference and session close protocol
|
||||
- Use `bd remember` for persistent knowledge — do NOT use MEMORY.md files
|
||||
|
||||
**Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md for details and anti-patterns.
|
||||
|
||||
## Agent Context Profiles
|
||||
|
||||
The managed Beads block is task-tracking guidance, not permission to override repository, user, or orchestrator instructions.
|
||||
|
||||
- **Conservative (default)**: Use `bd` for task tracking. Do not run git commits, git pushes, or Dolt remote sync unless explicitly asked. At handoff, report changed files, validation, and suggested next commands.
|
||||
- **Minimal**: Keep tool instruction files as pointers to `bd prime`; use the same conservative git policy unless active instructions say otherwise.
|
||||
- **Team-maintainer**: Only when the repository explicitly opts in, agents may close beads, run quality gates, commit, and push as part of session close. A current "do not commit" or "do not push" instruction still wins.
|
||||
|
||||
## Session Completion
|
||||
|
||||
This protocol applies when ending a Beads implementation workflow. It is subordinate to explicit user, repository, and orchestrator instructions.
|
||||
|
||||
1. **File issues for remaining work** - Create beads for anything that needs follow-up
|
||||
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
||||
3. **Update issue status** - Close finished work, update in-progress items
|
||||
4. **Handle git/sync by active profile**:
|
||||
```bash
|
||||
# Conservative/minimal/default: report status and proposed commands; wait for approval.
|
||||
git status
|
||||
|
||||
# Team-maintainer opt-in only, unless current instructions forbid it:
|
||||
git pull --rebase
|
||||
bd dolt push
|
||||
git push
|
||||
git status
|
||||
```
|
||||
5. **Hand off** - Summarize changes, validation, issue status, and any blocked sync/commit/push step
|
||||
|
||||
**Critical rules:**
|
||||
- Explicit user or orchestrator instructions override this Beads block.
|
||||
- Do not commit or push without clear authority from the active profile or the current user request.
|
||||
- If a required sync or push is blocked, stop and report the exact command and error.
|
||||
<!-- END BEADS INTEGRATION -->
|
||||
|
||||
<!-- BEGIN BEADS CODEX SETUP: generated by bd setup codex -->
|
||||
## Beads Issue Tracker
|
||||
|
||||
Use Beads (`bd`) for durable task tracking in repositories that include it. Use the `beads` skill at `.agents/skills/beads/SKILL.md` (project install) or `~/.agents/skills/beads/SKILL.md` (global install) for Beads workflow guidance, then use the `bd` CLI for issue operations.
|
||||
|
||||
### Quick Reference
|
||||
|
||||
```bash
|
||||
bd ready # Find available work
|
||||
bd show <id> # View issue details
|
||||
bd update <id> --claim # Claim work
|
||||
bd close <id> # Complete work
|
||||
bd prime # Refresh Beads context
|
||||
```
|
||||
|
||||
### Rules
|
||||
|
||||
- Use `bd` for all task tracking; do not create markdown TODO lists.
|
||||
- Run `bd prime` when Beads context is missing or stale. Codex 0.129.0+ can load Beads context automatically through native hooks; use `/hooks` to inspect or toggle them.
|
||||
- Keep persistent project memory in Beads via `bd remember`; do not create ad hoc memory files.
|
||||
|
||||
**Architecture in one line:** issues live in a local Dolt DB; sync uses `refs/dolt/data` on your git remote; `.beads/issues.jsonl` is a passive export. See https://github.com/gastownhall/beads/blob/main/docs/SYNC_CONCEPTS.md for details and anti-patterns.
|
||||
<!-- END BEADS CODEX SETUP -->
|
||||
@@ -0,0 +1,167 @@
|
||||
# CMB2 Conventions & Blast-Radius Notes
|
||||
|
||||
CMB2 is an opinionated, 10+-year-old library bundled inside hundreds of themes
|
||||
and plugins. This file is the compounding knowledge base of its conventions,
|
||||
architectural seams, and back-compat blast radii — written for both human
|
||||
contributors and AI agents.
|
||||
|
||||
**Reading rule:** consult this file before changing anything under `includes/`,
|
||||
`bootstrap.php`, or `init.php`.
|
||||
|
||||
**Capture rule:** when a code review catches a convention violation or a
|
||||
back-compat near-miss, the fix must land alongside a new or updated entry here,
|
||||
on the same branch. Each entry cites the canonical in-code example — the code
|
||||
is the spec; this file is the index to it.
|
||||
|
||||
**Delegation rule (AI agents):** subagents don't inherit this context. Work
|
||||
orders delegating changes must quote the relevant entries verbatim.
|
||||
|
||||
---
|
||||
|
||||
## C1 — Per-box features hook up via `cmb2_init_hookup_{$cmb_id}`
|
||||
|
||||
**Rule:** A feature that attaches to boxes (hookup, REST, notices, anything
|
||||
box-aware) registers a `maybe_init_and_hookup( CMB2 $cmb )` static on the
|
||||
box-specific `cmb2_init_hookup_{$cmb_id}` action, added in the `CMB2`
|
||||
constructor. The feature class *self-guards*: it receives every box and decides
|
||||
for itself whether it applies (e.g. `CMB2_REST` checks `show_in_rest`).
|
||||
|
||||
**Canonical example:** `includes/CMB2.php` constructor (the
|
||||
`CMB2_Hookup`/`CMB2_REST` `add_action` pair); fired from `bootstrap.php`'s
|
||||
`cmb2_init_hookup_{$cmb->cmb_id}` loop; contract in
|
||||
`CMB2_Hookup_Base::maybe_init_and_hookup()`.
|
||||
|
||||
**Anti-pattern:** registering a global hook elsewhere and scanning
|
||||
`CMB2_Boxes::get_all()` to find relevant boxes. Two sources of truth for
|
||||
"which boxes does this apply to", misses late-registered boxes, and bypasses
|
||||
the per-box action seam developers use to unhook features from a single box.
|
||||
|
||||
**Blast radius:** extenders unhook/re-order `cmb2_init_hookup_*` callbacks per
|
||||
box; a feature wired outside that seam won't respect their customizations.
|
||||
|
||||
## C2 — `bootstrap.php` is generic lifecycle only
|
||||
|
||||
**Rule:** `bootstrap.php` contains only the init ceremony: `do_action` /
|
||||
`apply_filters` lifecycle events and the box-instantiation loops. No
|
||||
feature-specific class references, ever. Feature wiring belongs in the `CMB2`
|
||||
constructor (per-box features, see C1) or in the feature's own file.
|
||||
|
||||
**Canonical example:** `bootstrap.php` — note it ends "End. That's it, folks!"
|
||||
and has barely changed since 2.2.0.
|
||||
|
||||
## C3 — The self-electing loader makes every behavior change site-wide
|
||||
|
||||
**Rule:** `init.php` version-elects: when multiple copies of CMB2 are bundled
|
||||
(themes + plugins commonly each ship one), the *newest* copy wins and serves
|
||||
ALL registered boxes on the site. Any default-behavior change therefore
|
||||
propagates to every bundling product the moment one of them updates.
|
||||
|
||||
**Consequence:** behavior flips ship staged — opt-in first (default-off filter
|
||||
+ notice + docs), default-on only in a later release. Never flip a default in
|
||||
the same release that introduces the switch.
|
||||
|
||||
**Canonical example:** `init.php` (the `CMB2_Bootstrap_*` priority dance);
|
||||
staged-rollout example: the `cmb2_rest_enforce_options_page_read_permissions`
|
||||
filter (default false).
|
||||
|
||||
## C4 — REST reads are public by design; permission filters are the escape hatch
|
||||
|
||||
**Rule:** Boxes with `show_in_rest` readable expose reads publicly — this
|
||||
mirrors WP core's `show_in_rest` semantics for object meta and is intentional,
|
||||
not an oversight. Per-request overrides go through the existing
|
||||
`cmb2_api_get_box_permissions_check` / `cmb2_api_get_field_permissions_check`
|
||||
filters, which always run last and have final say. New permission logic must
|
||||
run *before* them and must not remove them.
|
||||
|
||||
**Canonical example:** `CMB2_REST_Controller_Boxes::get_item_permissions_check_filter()`;
|
||||
pinned by tests in `tests/test-cmb-rest-controllers.php`.
|
||||
|
||||
**Blast radius:** headless/decoupled front-ends read box data anonymously for
|
||||
public display. Tightening reads by default breaks them — hence the staged
|
||||
approach in C3, scoped only to options-page boxes (matching core's
|
||||
settings-vs-meta distinction).
|
||||
|
||||
## C5 — The `capability` box prop means "who sees the admin screen"
|
||||
|
||||
**Rule:** `capability` (default `manage_options` for options pages) governs the
|
||||
admin page. Reusing it for other gates (REST, front-end) conflates concerns —
|
||||
acceptable only where the semantic genuinely matches (e.g. options-page REST
|
||||
reads mirror the settings screen), and even then behind its own switch.
|
||||
|
||||
**Canonical example:** `includes/CMB2.php` `$mb_defaults['capability']` usage in
|
||||
`CMB2_Options_Hookup`.
|
||||
|
||||
**Where the semantic does match:** an options-page target's *object id is the
|
||||
option name* the data lands in, so "may write this option" and "may use this
|
||||
settings screen" are the same question — see
|
||||
`CMB2_Ajax::can_cache_for_options_page()`. Note the shape: the box that
|
||||
declared the option key is also the only place a capability for it exists, so
|
||||
looking the box up both supplies the check and bounds the accepted option keys
|
||||
to ones a box declared. An id no box claims has no capability to consult, and
|
||||
is therefore not a target.
|
||||
|
||||
## C6 — Autoloader paths are case-sensitive by prefix
|
||||
|
||||
**Rule:** `cmb2_autoload_classes()` maps `CMB2_REST`/`CMB2_REST_*` (exact case)
|
||||
to `includes/rest-api/`, `CMB2_Type*` to `includes/types/`, everything else to
|
||||
`includes/`. A class named `CMB2_Rest_Foo` (lowercase "est") deliberately lands
|
||||
in `includes/` — name classes with full awareness of which directory the prefix
|
||||
routes to, and match filename to class name exactly.
|
||||
|
||||
**Canonical example:** `includes/helper-functions.php` `cmb2_autoload_classes()`.
|
||||
|
||||
## C7 — PHP floor is 7.4; local tests don't prove it
|
||||
|
||||
**Rule:** All code must run on PHP 7.4. Local `npm run phptests` runs PHP 8.3
|
||||
only; the 7.4 floor is guarded exclusively by the CI matrix (`phpunit.yml`).
|
||||
"Passes locally" is necessary, never sufficient. (Tooling details: CLAUDE.md
|
||||
"Testing Strategy".)
|
||||
|
||||
## C8 — Configuration over code: box props are the primary interface
|
||||
|
||||
**Rule:** A new per-box behavior must be reachable as a **box registration
|
||||
property**. The registration array is the interface CMB2 developers actually
|
||||
use — and the one a bundling theme/plugin can ship per box — so it is the
|
||||
primary layer; filters are the secondary, site-wide layer for cross-cutting
|
||||
policy. When a behavior has both, the box prop wins outright and the filter
|
||||
governs only the boxes that left the prop unset. That way a box declares its
|
||||
intent once, in the array where it was registered, and keeps it across a later
|
||||
default flip (C3).
|
||||
|
||||
**Canonical examples:** `includes/CMB2.php` `$mb_defaults` — `show_in_rest`,
|
||||
`capability`, and `rest_read_capability`. The last one is the shape to copy,
|
||||
reading exactly as plain English: `false` = "no" (REST reads disabled for
|
||||
everyone, via core's `do_not_allow`); `true` = "yes, everyone" (alias of
|
||||
`'exist'`, the capability WP grants every visitor); `'box-capability'` = the
|
||||
box's own `capability` prop (the only non-duplicating spelling — naming the cap
|
||||
copies a value that lives elsewhere and can drift); any other capability string
|
||||
= only its holders; unset = the default policy (and the staged flip, C3). It
|
||||
cascades field → box → default like `show_in_rest`. Precedence is resolved in one
|
||||
place, `CMB2_REST::get_rest_read_capability()`, and consumed by
|
||||
`CMB2_REST_Controller::maybe_gate_read_by_capability()`.
|
||||
|
||||
**Value semantics — a prop value must read correctly in plain English.** A
|
||||
config value is documentation; if its plain-English reading is ambiguous or
|
||||
contradicts its behavior, it's the wrong value. `rest_read_capability` went
|
||||
through this exact wringer: `false` originally meant "reads are public (no
|
||||
capability required)" — but it *reads* as "REST read capability? no", i.e.
|
||||
reads disabled. The fix wasn't banning the boolean; it was making the meaning
|
||||
match the reading (`false` now disables reads; `true` now means everyone).
|
||||
Corollaries: booleans are fine only when yes/no is the honest answer to the
|
||||
prop's name read as a question; when the answer is a *which* (which
|
||||
capability?), every value is a real answer; and prefer WP-canonical vocabulary
|
||||
over invented sentinels — `'exist'` (granted to everyone) and `do_not_allow`
|
||||
(denied to everyone) bound the range, so neither "public" nor "disabled" needs
|
||||
special-casing.
|
||||
|
||||
**Anti-pattern:** shipping a filter-only interface for per-box behavior. It
|
||||
forces every developer to write a callback that re-derives "which box is this?"
|
||||
from the filter args, cannot be expressed in the registration array a theme or
|
||||
plugin already ships, and leaves no way to declare per-box intent — the filter
|
||||
answers site-wide, so a site with a single box needing the old behavior has to
|
||||
special-case every box by hand.
|
||||
|
||||
**Blast radius:** props are public API forever — name them for the behavior,
|
||||
not the implementation. Adding one to `$mb_defaults` also changes the array
|
||||
pinned by `Test_CMB2_Core::test_defaults_set()`; update that fixture in the same
|
||||
commit.
|
||||
@@ -0,0 +1,26 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
**Please report security issues privately — not in a public issue.**
|
||||
|
||||
Use GitHub's [private vulnerability reporting](https://github.com/CMB2/CMB2/security/advisories/new). It goes directly to the maintainers, and nothing is public until an advisory is published.
|
||||
|
||||
Please include:
|
||||
|
||||
1. The CMB2 and WordPress versions you tested.
|
||||
2. Steps to reproduce, plus the metabox/field registration code needed to trigger it (a [gist](https://gist.github.com/) is fine).
|
||||
3. The impact: what an attacker can do, and what role or capability they need to do it.
|
||||
4. Whether the issue still reproduces on the [`develop`](https://github.com/CMB2/CMB2/tree/develop) branch.
|
||||
|
||||
## Supported versions
|
||||
|
||||
CMB2 maintains a single line — the latest release. Security fixes land in the next patch release; there are no backports to older versions. Note that CMB2 is often bundled inside a theme or plugin rather than installed from wordpress.org, so "upgrade" may mean updating that bundled copy.
|
||||
|
||||
## What to expect
|
||||
|
||||
* Acknowledgement within 7 days.
|
||||
* An assessment — accepted, needs more information, or not a vulnerability — within 14 days.
|
||||
* A fix in the next patch release, with a GitHub Security Advisory crediting you unless you ask otherwise.
|
||||
|
||||
Please give us a reasonable window to ship a fix before disclosing publicly. If you have had no response after 14 days, open a public issue to nudge the thread — without any vulnerability details.
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "cmb2/cmb2",
|
||||
"description": "CMB2 is a metabox, custom fields, and forms library for WordPress that will blow your mind.",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Justin Sternberg",
|
||||
"email": "justin@dsgnwrks.pro",
|
||||
"homepage": "https://dsgnwrks.pro",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "WebDevStudios",
|
||||
"email": "contact@webdevstudios.com",
|
||||
"homepage": "https://github.com/WebDevStudios",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"keywords": ["wordpress", "plugin", "metabox"],
|
||||
"homepage": "https://github.com/CMB2/CMB2",
|
||||
"type": "wordpress-plugin",
|
||||
"support": {
|
||||
"issues": "https://github.com/CMB2/CMB2/issues",
|
||||
"source": "http://wordpress.org/support/plugin/cmb2"
|
||||
},
|
||||
"require": {
|
||||
"php": ">7.4"
|
||||
},
|
||||
"suggest": {
|
||||
"composer/installers": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"yoast/phpunit-polyfills": "^1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"vendor/bin/phpunit"
|
||||
],
|
||||
"phpcs:install": "@composer install --working-dir=tools/phpcs --no-interaction",
|
||||
"phpcs": "@php tools/phpcs/run.php phpcs",
|
||||
"phpcbf": "@php tools/phpcs/run.php phpcbf",
|
||||
"post-install-cmd": [
|
||||
"@php tools/phpcs/maybe-install.php"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php tools/phpcs/maybe-install.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* CMB2 - v2.12.0 - 2026-05-31
|
||||
* CMB2 - v2.13.0 - 2026-09-20
|
||||
* https://cmb2.io
|
||||
* Copyright (c) 2026
|
||||
* Licensed GPLv2+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*! CMB2 - v2.12.0 - 2026-05-31 | https://cmb2.io | Copyright (c) 2026 CMB2 team | Licensed GPLv2 */
|
||||
/*! CMB2 - v2.13.0 - 2026-09-20 | https://cmb2.io | Copyright (c) 2026 CMB2 team | Licensed GPLv2 */
|
||||
/*!
|
||||
* CMB2 - v2.12.0 - 2026-05-31
|
||||
* CMB2 - v2.13.0 - 2026-09-20
|
||||
* https://cmb2.io
|
||||
* Copyright (c) 2026
|
||||
* Licensed GPLv2+
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* CMB2 - v2.12.0 - 2026-05-31
|
||||
* CMB2 - v2.13.0 - 2026-09-20
|
||||
* https://cmb2.io
|
||||
* Copyright (c) 2026
|
||||
* Licensed GPLv2+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*! CMB2 - v2.12.0 - 2026-05-31 | https://cmb2.io | Copyright (c) 2026 CMB2 team | Licensed GPLv2 */
|
||||
/*! CMB2 - v2.13.0 - 2026-09-20 | https://cmb2.io | Copyright (c) 2026 CMB2 team | Licensed GPLv2 */
|
||||
/*!
|
||||
* CMB2 - v2.12.0 - 2026-05-31
|
||||
* CMB2 - v2.13.0 - 2026-09-20
|
||||
* https://cmb2.io
|
||||
* Copyright (c) 2026
|
||||
* Licensed GPLv2+
|
||||
|
||||
@@ -101,6 +101,29 @@ class CMB2 extends CMB2_Base {
|
||||
'new_user_section' => 'add-new-user', // or 'add-existing-user'.
|
||||
'new_term_section' => true,
|
||||
'show_in_rest' => false,
|
||||
|
||||
/*
|
||||
* Declares who may read this box via the REST API (only applicable when
|
||||
* 'show_in_rest' is readable). Accepts:
|
||||
*
|
||||
* - false No one may read it, administrators included.
|
||||
* - true Everyone may read it, logged-out visitors included.
|
||||
* - 'box-capability' Only holders of this box's 'capability' may read it
|
||||
* (falling back to 'manage_options').
|
||||
* - 'a_capability' Only holders of the named capability may read it,
|
||||
* e.g. 'edit_posts'.
|
||||
* - null (default) CMB2's current behavior: reads are public, unless
|
||||
* the box is an options page and the site-wide
|
||||
* `cmb2_rest_enforce_options_page_read_permissions` filter is
|
||||
* enabled.
|
||||
*
|
||||
* The same property may be set on an individual field, where it takes precedence
|
||||
* over the box's for reads of that field.
|
||||
*
|
||||
* The `cmb2_api_get_box_permissions_check`/`cmb2_api_get_field_permissions_check`
|
||||
* filters still run afterward and have the final say.
|
||||
*/
|
||||
'rest_read_capability' => null,
|
||||
'classes' => null, // Optionally add classes to the CMB2 wrapper.
|
||||
'classes_cb' => '', // Optionally add classes to the CMB2 wrapper (via a callback).
|
||||
|
||||
@@ -250,6 +273,9 @@ class CMB2 extends CMB2_Base {
|
||||
|
||||
// Hook in the rest api functionality.
|
||||
add_action( "cmb2_init_hookup_{$this->cmb_id}", array( 'CMB2_REST', 'maybe_init_and_hookup' ) );
|
||||
|
||||
// Hook in the notice about the upcoming REST read-permissions alignment.
|
||||
add_action( "cmb2_init_hookup_{$this->cmb_id}", array( 'CMB2_Rest_Read_Permissions_Notice', 'maybe_init_and_hookup' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+103
-5
@@ -68,7 +68,7 @@ class CMB2_Ajax {
|
||||
}
|
||||
|
||||
// Sanitize our search string.
|
||||
$oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] );
|
||||
$oembed_string = sanitize_text_field( wp_unslash( $_REQUEST['oembed_url'] ) );
|
||||
|
||||
// Send back error if empty.
|
||||
if ( empty( $oembed_string ) ) {
|
||||
@@ -86,20 +86,118 @@ class CMB2_Ajax {
|
||||
'width' => $embed_width,
|
||||
);
|
||||
|
||||
$object_id = isset( $_REQUEST['object_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['object_id'] ) ) : '';
|
||||
$object_type = isset( $_REQUEST['object_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['object_type'] ) ) : 'post';
|
||||
|
||||
/*
|
||||
* The lookup result gets cached against the requested object, so only accept a
|
||||
* target the caller already has rights over -- matching what CMB2's other write
|
||||
* paths require (see CMB2_Hookup::save_post()/save_term()/taxonomy_can_save()).
|
||||
* An empty object_id caches nothing against an object, so it needs no rights.
|
||||
*/
|
||||
if ( '' !== $object_id && ! $this->can_cache_for_object( $object_type, $object_id ) ) {
|
||||
wp_send_json_error( '<p class="ui-state-error-text">' . esc_html__( 'Please Try Again', 'cmb2' ) . '</p>' );
|
||||
}
|
||||
|
||||
$this->ajax_update = true;
|
||||
|
||||
// Get embed code (or fallback link).
|
||||
$html = $this->get_oembed( array(
|
||||
'url' => $oembed_url,
|
||||
'object_id' => $_REQUEST['object_id'],
|
||||
'object_type' => isset( $_REQUEST['object_type'] ) ? $_REQUEST['object_type'] : 'post',
|
||||
'object_id' => $object_id,
|
||||
'object_type' => $object_type,
|
||||
'oembed_args' => $embed_args,
|
||||
'field_id' => $_REQUEST['field_id'],
|
||||
'field_id' => isset( $_REQUEST['field_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['field_id'] ) ) : '',
|
||||
) );
|
||||
|
||||
wp_send_json_success( $html );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current user may have an oEmbed result cached against the requested object.
|
||||
*
|
||||
* Both the object type and the object id arrive in the request, and together they
|
||||
* decide where the result is written -- the object's metadata, or, for an
|
||||
* options-page target, the option whose name IS the object id. An object type
|
||||
* outside CMB2's core set names no store to check rights against.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param string $object_type Object type the result would be cached against.
|
||||
* @param string|int $object_id Object id (an option key for an options-page target).
|
||||
* @return bool Whether the caller may write to that target.
|
||||
*/
|
||||
protected function can_cache_for_object( $object_type, $object_id ) {
|
||||
switch ( $object_type ) {
|
||||
case 'post':
|
||||
return current_user_can( 'edit_post', $object_id );
|
||||
|
||||
case 'user':
|
||||
return current_user_can( 'edit_user', $object_id );
|
||||
|
||||
case 'comment':
|
||||
return current_user_can( 'edit_comment', $object_id );
|
||||
|
||||
case 'term':
|
||||
return $this->can_cache_for_term( $object_id );
|
||||
|
||||
case 'options-page':
|
||||
return $this->can_cache_for_options_page( $object_id );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current user may have a result cached against a term.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param string|int $term_id Term id.
|
||||
* @return bool Whether the caller may write to the term's meta.
|
||||
*/
|
||||
protected function can_cache_for_term( $term_id ) {
|
||||
$term = get_term( absint( $term_id ) );
|
||||
|
||||
if ( ! $term || is_wp_error( $term ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$taxonomy = get_taxonomy( $term->taxonomy );
|
||||
|
||||
// The same check CMB2_Hookup::taxonomy_can_save() makes before writing term meta.
|
||||
return isset( $taxonomy->cap->edit_terms ) && current_user_can( $taxonomy->cap->edit_terms );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current user may have a result cached into an options-page option.
|
||||
*
|
||||
* The result is stored in the option value itself, so the gate is the registered
|
||||
* box's 'capability' prop -- the value that already governs that options page.
|
||||
* An option key no registered box declared has no such value to consult, and so
|
||||
* is not an accepted target.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param string $option_key Option key the result would be cached into.
|
||||
* @return bool Whether the caller may write to that option.
|
||||
*/
|
||||
protected function can_cache_for_options_page( $option_key ) {
|
||||
foreach ( CMB2_Boxes::get_all() as $cmb ) {
|
||||
$keys = (array) $cmb->options_page_keys();
|
||||
|
||||
if ( ! in_array( $option_key, $keys, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( current_user_can( $cmb->prop( 'capability' ) ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves oEmbed from url/object ID
|
||||
*
|
||||
@@ -178,7 +276,7 @@ class CMB2_Ajax {
|
||||
|
||||
// Send back our embed.
|
||||
if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) {
|
||||
return '<div class="cmb2-oembed embed-status">' . $oembed['embed'] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $oembed['args']['field_id'] . '">' . esc_html__( 'Remove Embed', 'cmb2' ) . '</a></p></div>';
|
||||
return '<div class="cmb2-oembed embed-status">' . $oembed['embed'] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . esc_attr( $oembed['args']['field_id'] ) . '">' . esc_html__( 'Remove Embed', 'cmb2' ) . '</a></p></div>';
|
||||
}
|
||||
|
||||
// Otherwise, send back error info that no oEmbeds were found.
|
||||
|
||||
+15
-7
@@ -347,16 +347,22 @@ abstract class CMB2_Base {
|
||||
/**
|
||||
* Checks if this object has parameter corresponding to the given filter
|
||||
* which is callable. If so, it registers the callback, and if not,
|
||||
* converts the maybe-modified $val to a boolean for return.
|
||||
* converts the declared parameter to a boolean for return.
|
||||
*
|
||||
* The registered handlers will have a parameter name which matches the filter, except:
|
||||
* - The 'cmb2_api' prefix will be removed
|
||||
* - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters).
|
||||
*
|
||||
* Only a declared parameter is consulted. The caller's default is deliberately not
|
||||
* passed to prop() as a fallback: prop() stores a truthy fallback on the object, so
|
||||
* doing that would turn one request's default into a declared parameter for every
|
||||
* later call — see the `$val` note below.
|
||||
*
|
||||
* @since 2.2.3
|
||||
*
|
||||
* @param string $hook_name The hook name.
|
||||
* @param bool $val The default value.
|
||||
* @param bool $val The default value, returned as-is when the parameter
|
||||
* is not declared on this object.
|
||||
* @param string $hook_function The hook function. Default: 'add_filter'.
|
||||
*
|
||||
* @return null|bool Null if hook is registered, or bool for value.
|
||||
@@ -366,11 +372,13 @@ abstract class CMB2_Base {
|
||||
// Remove filter prefix, add param suffix.
|
||||
$parameter = substr( $hook_name, strlen( 'cmb2_api_' ) ) . '_cb';
|
||||
|
||||
return self::maybe_hook(
|
||||
$this->prop( $parameter, $val ),
|
||||
$hook_name,
|
||||
$hook_function
|
||||
);
|
||||
$declared = $this->prop( $parameter );
|
||||
|
||||
if ( null === $declared ) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return self::maybe_hook( $declared, $hook_name, $hook_function );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -200,7 +200,7 @@ class CMB2_Options_Hookup extends CMB2_Hookup {
|
||||
<h2><?php echo wp_kses_post( $this->cmb->prop( 'title' ) ); ?></h2>
|
||||
<?php endif; ?>
|
||||
<?php $this->options_page_tab_nav_output(); ?>
|
||||
<form class="cmb-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="POST" id="<?php echo $this->cmb->cmb_id; ?>" enctype="multipart/form-data" encoding="multipart/form-data">
|
||||
<form class="cmb-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="POST" id="<?php echo esc_attr( $this->cmb->cmb_id ); ?>" enctype="multipart/form-data" encoding="multipart/form-data">
|
||||
<input type="hidden" name="action" value="<?php echo esc_attr( $this->option_key ); ?>">
|
||||
<?php $this->options_page_metabox(); ?>
|
||||
<?php submit_button( esc_attr( $this->cmb->prop( 'save_button' ) ), 'primary', 'submit-cmb' ); ?>
|
||||
|
||||
Vendored
+235
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin notice announcing the upcoming alignment of CMB2's REST API read
|
||||
* permissions for settings data with WordPress core conventions.
|
||||
*
|
||||
* Shown only when the site actually registers a REST-readable options/settings
|
||||
* box and the alignment has not already been enabled, so sites that need no
|
||||
* action (or that already opted in) are not nagged.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @category WordPress_Plugin
|
||||
* @package CMB2
|
||||
* @author CMB2 team
|
||||
* @license GPL-2.0+
|
||||
* @link https://cmb2.io
|
||||
*/
|
||||
class CMB2_Rest_Read_Permissions_Notice {
|
||||
|
||||
/**
|
||||
* Default URL for the explainer guide.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.13.0
|
||||
*/
|
||||
const GUIDE_URL = 'https://cmb2.io/docs/REST-API-Read-Permissions';
|
||||
|
||||
/**
|
||||
* Option key used to persist notice dismissal.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.13.0
|
||||
*/
|
||||
const DISMISSED_OPTION = 'cmb2_rest_read_permissions_notice_dismissed';
|
||||
|
||||
/**
|
||||
* Nonce/action name used for the dismissal AJAX request.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.13.0
|
||||
*/
|
||||
const AJAX_ACTION = 'cmb2_dismiss_rest_read_permissions_notice';
|
||||
|
||||
/**
|
||||
* Affected (REST-readable options-page) boxes fed in via the per-box hookup,
|
||||
* keyed by cmb_id.
|
||||
*
|
||||
* @var CMB2[]
|
||||
* @since 2.13.0
|
||||
*/
|
||||
protected static $tracked_boxes = array();
|
||||
|
||||
/**
|
||||
* Per-box hookup, matching CMB2's `cmb2_init_hookup_{$cmb_id}` convention
|
||||
* (see CMB2_Hookup::maybe_init_and_hookup / CMB2_REST::maybe_init_and_hookup).
|
||||
*
|
||||
* Tracks each affected box so the notice can consult only the boxes actually
|
||||
* registered on this request, and registers the admin render + dismissal
|
||||
* handlers once, when the first affected box is seen.
|
||||
*
|
||||
* A box which declares a `rest_read_capability` has stated its intent and will
|
||||
* not be affected by a future default change, so it is not an affected box at
|
||||
* all — filtering it out here (rather than in should_show()) keeps "affected"
|
||||
* defined in one place and leaves should_show() to the single remaining
|
||||
* question: are any affected boxes still ungated?
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param CMB2 $cmb The CMB2 object being hooked up.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function maybe_init_and_hookup( CMB2 $cmb ) {
|
||||
if ( ! is_admin() || ! CMB2_REST::is_options_page_box( $cmb ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( CMB2_REST::has_explicit_rest_read_capability( $cmb ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$first_box = empty( self::$tracked_boxes );
|
||||
|
||||
self::$tracked_boxes[ $cmb->cmb_id ] = $cmb;
|
||||
|
||||
if ( $first_box ) {
|
||||
add_action( 'admin_notices', array( __CLASS__, 'render' ) );
|
||||
add_action( 'wp_ajax_' . self::AJAX_ACTION, array( __CLASS__, 'ajax_dismiss' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets tracked-box state.
|
||||
*
|
||||
* @internal Intended for test isolation.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function reset() {
|
||||
self::$tracked_boxes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the notice has been dismissed.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_dismissed() {
|
||||
return (bool) get_option( self::DISMISSED_OPTION, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists dismissal of the notice.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function dismiss() {
|
||||
update_option( self::DISMISSED_OPTION, 1, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the notice is eligible to be shown.
|
||||
*
|
||||
* Eligible only when at least one tracked affected box (fed in via
|
||||
* maybe_init_and_hookup) still has ungated reads (the alignment filter is
|
||||
* returning its default false), and the notice has not already been dismissed.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function should_show() {
|
||||
if ( self::is_dismissed() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( self::$tracked_boxes as $cmb ) {
|
||||
// If any affected box is still ungated, the owner should be informed.
|
||||
if ( ! apply_filters( 'cmb2_rest_enforce_options_page_read_permissions', false, $cmb ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the admin notice, when eligible and the user can manage options.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function render() {
|
||||
if ( ! current_user_can( 'manage_options' ) || ! self::should_show() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$guide_url = self::GUIDE_URL;
|
||||
$nonce = wp_create_nonce( self::AJAX_ACTION );
|
||||
?>
|
||||
<div class="notice notice-info is-dismissible cmb2-rest-read-permissions-notice" data-cmb2-notice-nonce="<?php echo esc_attr( $nonce ); ?>">
|
||||
<p>
|
||||
<strong><?php esc_html_e( 'CMB2: Upcoming change to REST API read permissions for settings data', 'cmb2' ); ?></strong>
|
||||
</p>
|
||||
<p>
|
||||
<?php esc_html_e( 'This site uses CMB2 (a custom-fields library that is usually bundled inside a theme or plugin) to register one or more settings pages that are readable through the WordPress REST API. To align with WordPress core conventions, a future CMB2 release will limit REST API reads of settings-page data to users who can manage those settings (administrators, typically). Most sites need no action, and nothing changes yet. If your site has a custom integration that reads these settings through the REST API, please share the guide below with your developer.', 'cmb2' ); ?>
|
||||
</p>
|
||||
<p>
|
||||
<a class="button button-secondary" href="<?php echo esc_url( $guide_url ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Read the guide', 'cmb2' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
( function () {
|
||||
var notice = document.querySelector( '.cmb2-rest-read-permissions-notice' );
|
||||
if ( ! notice ) {
|
||||
return;
|
||||
}
|
||||
notice.addEventListener( 'click', function ( event ) {
|
||||
if ( ! event.target.classList.contains( 'notice-dismiss' ) ) {
|
||||
return;
|
||||
}
|
||||
var body = new URLSearchParams();
|
||||
body.append( 'action', '<?php echo esc_js( self::AJAX_ACTION ); ?>' );
|
||||
body.append( 'nonce', notice.getAttribute( 'data-cmb2-notice-nonce' ) );
|
||||
// keepalive lets the request finish if the user navigates right away;
|
||||
// a dismissal that fails to persist would otherwise be silent.
|
||||
window.fetch( window.ajaxurl, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
keepalive: true,
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
||||
body: body.toString()
|
||||
} ).then( function ( response ) {
|
||||
if ( ! response.ok ) {
|
||||
throw new Error( response.status );
|
||||
}
|
||||
return response.text();
|
||||
} ).catch( function ( err ) {
|
||||
if ( window.console ) {
|
||||
console.warn( 'CMB2: notice dismissal may not have persisted.', err );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} )();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler that persists dismissal of the notice.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function ajax_dismiss() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( '', 403 );
|
||||
}
|
||||
|
||||
check_ajax_referer( self::AJAX_ACTION, 'nonce' );
|
||||
|
||||
self::dismiss();
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -335,13 +335,13 @@ class CMB2_Types {
|
||||
$this->_desc( true, true, true );
|
||||
?>
|
||||
|
||||
<div id="<?php echo $table_id; ?>" class="cmb-repeat-table cmb-nested">
|
||||
<div id="<?php echo esc_attr( $table_id ); ?>" class="cmb-repeat-table cmb-nested">
|
||||
<div class="cmb-tbody cmb-field-list">
|
||||
<?php $this->repeatable_rows(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cmb-add-row">
|
||||
<button type="button" data-selector="<?php echo $table_id; ?>" class="cmb-add-row-button button-secondary"><?php echo esc_html( $this->_text( 'add_row_text', esc_html__( 'Add Row', 'cmb2' ) ) ); ?></button>
|
||||
<button type="button" data-selector="<?php echo esc_attr( $table_id ); ?>" class="cmb-add-row-button button-secondary"><?php echo esc_html( $this->_text( 'add_row_text', esc_html__( 'Add Row', 'cmb2' ) ) ); ?></button>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
|
||||
+165
@@ -807,6 +807,171 @@ class CMB2_REST extends CMB2_Hookup_Base {
|
||||
return self::$boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a box is a REST-readable options-page box.
|
||||
*
|
||||
* WordPress core exposes object meta reads publicly, but gates settings/options
|
||||
* reads behind a capability (see WP_REST_Settings_Controller). This helper
|
||||
* identifies the CMB2 boxes that map to that options/settings category so their
|
||||
* REST reads can be aligned with the same core convention.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param CMB2 $cmb The CMB2 box object to check.
|
||||
*
|
||||
* @return bool Whether the box is an options-page box exposed for REST reads.
|
||||
*/
|
||||
public static function is_options_page_box( CMB2 $cmb ) {
|
||||
return $cmb->is_options_page_mb() && self::is_readable( $cmb->prop( 'show_in_rest' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a box explicitly declares how its REST reads are permissioned.
|
||||
*
|
||||
* A box which sets the `rest_read_capability` property to a recognized value
|
||||
* (`false`, `true`, or a capability string) has declared its intent, so CMB2 should
|
||||
* neither second-guess it via the site-wide alignment filter nor nag about it.
|
||||
*
|
||||
* Only the box property is consulted: a field-level declaration speaks for that
|
||||
* field, not for the box.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param CMB2 $cmb The CMB2 box object to check.
|
||||
*
|
||||
* @return bool Whether the box declares an explicit read permission.
|
||||
*/
|
||||
public static function has_explicit_rest_read_capability( CMB2 $cmb ) {
|
||||
return null !== self::declared_read_capability( $cmb->prop( 'rest_read_capability' ), $cmb );
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a `rest_read_capability` declaration into the capability it requires.
|
||||
*
|
||||
* Recognized values, all of which resolve to a capability string so the caller has
|
||||
* a single kind of answer to act on:
|
||||
*
|
||||
* - false Reads are not permitted, for anyone. Maps to WordPress's
|
||||
* `do_not_allow` pseudo-capability, which WP_User::has_cap()
|
||||
* denies unconditionally — administrators included.
|
||||
* - true Reads are permitted for everyone. Maps to WordPress's `exist`
|
||||
* pseudo-capability, which WP_User::has_cap() grants
|
||||
* unconditionally to every visitor, logged out included
|
||||
* ("Everyone is allowed to exist").
|
||||
* - 'box-capability' Reads require the box's own `capability` property (falling
|
||||
* back to `manage_options`). This is a reserved value, not a
|
||||
* real WordPress capability: it is the only spelling of "gate by
|
||||
* this box's capability" which does not duplicate a value that
|
||||
* lives elsewhere and can drift out of sync. On a field, it
|
||||
* means "gate this field by whatever the box's capability is".
|
||||
* - string Reads require the named capability, e.g. `edit_posts`. Since
|
||||
* the two booleans are spelled as capabilities, `'exist'` and
|
||||
* `'do_not_allow'` work as literal strings too, with the same
|
||||
* meanings.
|
||||
*
|
||||
* Anything else (null, an empty string, other types) is not a declaration.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param mixed $declared The declared value.
|
||||
* @param CMB2 $cmb The CMB2 box object the declaration was made on or within.
|
||||
*
|
||||
* @return string|null The capability to require, or null if the value is not a
|
||||
* declaration.
|
||||
*/
|
||||
protected static function declared_read_capability( $declared, CMB2 $cmb ) {
|
||||
if ( is_bool( $declared ) ) {
|
||||
return $declared ? 'exist' : 'do_not_allow';
|
||||
}
|
||||
|
||||
if ( 'box-capability' === $declared ) {
|
||||
return self::get_box_capability( $cmb );
|
||||
}
|
||||
|
||||
if ( is_string( $declared ) && '' !== trim( $declared ) ) {
|
||||
return $declared;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the capability which gates REST reads of the given box or field, if any.
|
||||
*
|
||||
* The `rest_read_capability` property is the primary interface, and takes
|
||||
* precedence over the site-wide filter entirely. It is resolved in the same
|
||||
* cascading order as `show_in_rest` (see declare_read_edit_fields()): the field's
|
||||
* own declaration wins, else the box's, else the default policy.
|
||||
*
|
||||
* See declared_read_capability() for the recognized values. With no declaration at
|
||||
* either level, CMB2's historical behavior applies: reads are public, except that
|
||||
* options-page box reads are gated by the box `capability` when the
|
||||
* `cmb2_rest_enforce_options_page_read_permissions` filter is enabled.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param CMB2 $cmb The CMB2 box object being read.
|
||||
* @param CMB2_Field|array|null $field The field being read, when the read is of a
|
||||
* single field rather than the box itself.
|
||||
*
|
||||
* @return string|null The capability to require, or null when reads are not gated.
|
||||
*/
|
||||
public static function get_rest_read_capability( CMB2 $cmb, $field = null ) {
|
||||
$field_args = $field instanceof CMB2_Field ? $field->args() : $field;
|
||||
|
||||
if ( is_array( $field_args ) && isset( $field_args['rest_read_capability'] ) ) {
|
||||
$capability = self::declared_read_capability( $field_args['rest_read_capability'], $cmb );
|
||||
|
||||
if ( null !== $capability ) {
|
||||
return $capability;
|
||||
}
|
||||
}
|
||||
|
||||
$capability = self::declared_read_capability( $cmb->prop( 'rest_read_capability' ), $cmb );
|
||||
|
||||
if ( null !== $capability ) {
|
||||
return $capability;
|
||||
}
|
||||
|
||||
// Declared at neither level: only options-page boxes, and only when opted in site-wide.
|
||||
if ( ! self::is_options_page_box( $cmb ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to align options-page box REST reads with WordPress core's
|
||||
* settings/options convention (reads gated behind a capability).
|
||||
*
|
||||
* Defaults to false, preserving CMB2's historical public-read behavior. Only
|
||||
* consulted for boxes which have not declared a `rest_read_capability`.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param bool $enforce Whether to gate options-page reads behind a capability.
|
||||
* @param CMB2 $cmb The CMB2 box object being read.
|
||||
*/
|
||||
if ( ! apply_filters( 'cmb2_rest_enforce_options_page_read_permissions', false, $cmb ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::get_box_capability( $cmb );
|
||||
}
|
||||
|
||||
/**
|
||||
* The box's `capability` property, falling back to `manage_options`.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param CMB2 $cmb The CMB2 box object.
|
||||
*
|
||||
* @return string The capability.
|
||||
*/
|
||||
protected static function get_box_capability( CMB2 $cmb ) {
|
||||
$capability = $cmb->prop( 'capability' );
|
||||
|
||||
return empty( $capability ) ? 'manage_options' : $capability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if given value is readable.
|
||||
*
|
||||
|
||||
Vendored
+37
@@ -141,6 +141,43 @@ abstract class CMB2_REST_Controller extends WP_REST_Controller {
|
||||
return $default_access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionally gates a read behind a capability, aligning with WordPress core.
|
||||
*
|
||||
* WordPress core exposes object meta reads publicly, but gates settings/options
|
||||
* reads behind a capability (WP_REST_Settings_Controller). CMB2's
|
||||
* `rest_read_capability` property is how a box (or a single field on it) declares
|
||||
* which side of that line it sits on; see CMB2_REST::get_rest_read_capability() for
|
||||
* the full precedence. With the property left unset, CMB2 keeps its historical
|
||||
* public-read behavior unless the box is an options page and the site-wide
|
||||
* `cmb2_rest_enforce_options_page_read_permissions` filter is enabled.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*
|
||||
* @param bool $can_access The default access for this read request.
|
||||
* @param CMB2_Field|array|null $field The field being read, when the read is of
|
||||
* a single field rather than the box.
|
||||
*
|
||||
* @return bool The possibly-adjusted access value.
|
||||
*/
|
||||
protected function maybe_gate_read_by_capability( $can_access, $field = null ) {
|
||||
if ( ! $this->rest_box && $this->request->get_param( 'cmb_id' ) ) {
|
||||
$this->rest_box = CMB2_REST::get_rest_box( $this->request->get_param( 'cmb_id' ) );
|
||||
}
|
||||
|
||||
if ( ! $this->rest_box || is_wp_error( $this->rest_box ) ) {
|
||||
return $can_access;
|
||||
}
|
||||
|
||||
$capability = CMB2_REST::get_rest_read_capability( $this->rest_box->cmb, $field );
|
||||
|
||||
if ( null === $capability ) {
|
||||
return $can_access;
|
||||
}
|
||||
|
||||
return current_user_can( $capability );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the CMB2 box has any registered callback parameters for the given filter.
|
||||
*
|
||||
|
||||
+3
@@ -169,6 +169,9 @@ class CMB2_REST_Controller_Boxes extends CMB2_REST_Controller {
|
||||
* @return WP_Error|boolean
|
||||
*/
|
||||
public function get_item_permissions_check_filter( $can_access = true ) {
|
||||
// Optionally gate the read behind a capability, per the box's declaration.
|
||||
$can_access = $this->maybe_gate_read_by_capability( $can_access );
|
||||
|
||||
/**
|
||||
* By default, no special permissions needed.
|
||||
*
|
||||
|
||||
+11
@@ -164,6 +164,17 @@ class CMB2_REST_Controller_Fields extends CMB2_REST_Controller_Boxes {
|
||||
* @return WP_Error|boolean
|
||||
*/
|
||||
public function get_item_permissions_check_filter( $can_access = true ) {
|
||||
/*
|
||||
* Optionally gate the read behind a capability, per the field's declaration,
|
||||
* falling back to the box's. Passing the field is what makes this per-field:
|
||||
* the fields collection sets $this->field before each call, so a field the
|
||||
* current user cannot read is left out of the collection.
|
||||
*/
|
||||
$can_access = $this->maybe_gate_read_by_capability(
|
||||
$can_access,
|
||||
$this->field instanceof CMB2_Field ? $this->field : null
|
||||
);
|
||||
|
||||
/**
|
||||
* By default, no special permissions needed.
|
||||
*
|
||||
|
||||
+10
-10
@@ -20,7 +20,7 @@
|
||||
* Bill Erickson (@billerickson / billerickson.net)
|
||||
* Andrew Norcross (@norcross / andrewnorcross.com)
|
||||
*
|
||||
* Version: 2.12.0
|
||||
* Version: 2.13.0
|
||||
*
|
||||
* Text Domain: cmb2
|
||||
* Domain Path: languages
|
||||
@@ -53,7 +53,7 @@
|
||||
* ***********************************************************************
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'CMB2_Bootstrap_2120', false ) ) {
|
||||
if ( ! class_exists( 'CMB2_Bootstrap_2130', false ) ) {
|
||||
|
||||
/**
|
||||
* Handles checking for and loading the newest version of CMB2
|
||||
@@ -66,7 +66,7 @@ if ( ! class_exists( 'CMB2_Bootstrap_2120', false ) ) {
|
||||
* @license GPL-2.0+
|
||||
* @link https://cmb2.io
|
||||
*/
|
||||
class CMB2_Bootstrap_2120 {
|
||||
class CMB2_Bootstrap_2130 {
|
||||
|
||||
/**
|
||||
* Current version number
|
||||
@@ -74,7 +74,7 @@ if ( ! class_exists( 'CMB2_Bootstrap_2120', false ) ) {
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
const VERSION = '2.12.0';
|
||||
const VERSION = '2.13.0';
|
||||
|
||||
/**
|
||||
* Current version hook priority.
|
||||
@@ -83,20 +83,20 @@ if ( ! class_exists( 'CMB2_Bootstrap_2120', false ) ) {
|
||||
* @var int
|
||||
* @since 2.0.0
|
||||
*/
|
||||
const PRIORITY = 9956;
|
||||
const PRIORITY = 9955;
|
||||
|
||||
/**
|
||||
* Single instance of the CMB2_Bootstrap_2120 object
|
||||
* Single instance of the CMB2_Bootstrap_2130 object
|
||||
*
|
||||
* @var CMB2_Bootstrap_2120
|
||||
* @var CMB2_Bootstrap_2130
|
||||
*/
|
||||
public static $single_instance = null;
|
||||
|
||||
/**
|
||||
* Creates/returns the single instance CMB2_Bootstrap_2120 object
|
||||
* Creates/returns the single instance CMB2_Bootstrap_2130 object
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return CMB2_Bootstrap_2120 Single instance object
|
||||
* @return CMB2_Bootstrap_2130 Single instance object
|
||||
*/
|
||||
public static function initiate() {
|
||||
if ( null === self::$single_instance ) {
|
||||
@@ -192,6 +192,6 @@ if ( ! class_exists( 'CMB2_Bootstrap_2120', false ) ) {
|
||||
}
|
||||
|
||||
// Make it so...
|
||||
CMB2_Bootstrap_2120::initiate();
|
||||
CMB2_Bootstrap_2130::initiate();
|
||||
|
||||
}// End if().
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
const { defineConfig, devices } = require('@playwright/test');
|
||||
|
||||
/**
|
||||
* @see https://playwright.dev/docs/test-configuration
|
||||
*/
|
||||
module.exports = defineConfig({
|
||||
testDir: './tests/playwright',
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Single worker on CI — tests share one WordPress instance so parallel
|
||||
execution causes session/state interference (e.g., logout kills other sessions). */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: process.env.CI ? 'github' : 'list',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: process.env.WP_BASE_URL || 'http://localhost:2623',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
|
||||
/* Screenshot on failure */
|
||||
screenshot: 'only-on-failure',
|
||||
|
||||
/* Video on retry */
|
||||
video: 'retain-on-failure',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
/* Auth setup — runs first, saves login state for other projects */
|
||||
{
|
||||
name: 'setup',
|
||||
testMatch: /auth\.setup\.js/,
|
||||
},
|
||||
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
storageState: 'tests/playwright/.auth/user.json',
|
||||
},
|
||||
dependencies: ['setup'],
|
||||
testIgnore: /auth\.setup\.js/,
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
storageState: 'tests/playwright/.auth/user.json',
|
||||
},
|
||||
dependencies: ['setup'],
|
||||
testIgnore: /auth\.setup\.js/,
|
||||
},
|
||||
|
||||
{
|
||||
name: 'webkit',
|
||||
use: {
|
||||
...devices['Desktop Safari'],
|
||||
storageState: 'tests/playwright/.auth/user.json',
|
||||
},
|
||||
dependencies: ['setup'],
|
||||
testIgnore: /auth\.setup\.js/,
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: process.env.SKIP_WP_SERVER ? undefined : {
|
||||
command: 'npm run env:tests:start',
|
||||
url: process.env.WP_BASE_URL || 'http://localhost:2623',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 180 * 1000,
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
},
|
||||
|
||||
/* Global setup and teardown */
|
||||
globalSetup: './tests/playwright/global-setup.js',
|
||||
globalTeardown: './tests/playwright/global-teardown.js',
|
||||
});
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* CSS banner injection and minification script.
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/build-banner.js # Add expanded banners to CSS files
|
||||
* node scripts/build-banner.js --minify # Create .min.css files with one-line banner
|
||||
*/
|
||||
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
const pkg = require( path.join( __dirname, '..', 'package.json' ) );
|
||||
const date = new Date().toISOString().slice( 0, 10 );
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
const cssFiles = [
|
||||
'css/cmb2.css',
|
||||
'css/cmb2-front.css',
|
||||
'css/cmb2-display.css',
|
||||
'css/cmb2-rtl.css',
|
||||
'css/cmb2-front-rtl.css',
|
||||
'css/cmb2-display-rtl.css',
|
||||
];
|
||||
|
||||
const expandedBanner =
|
||||
'/*!\n' +
|
||||
' * ' + pkg.title + ' - v' + pkg.version + ' - ' + date + '\n' +
|
||||
' * ' + pkg.homepage + '\n' +
|
||||
' * Copyright (c) ' + year + '\n' +
|
||||
' * Licensed GPLv2+\n' +
|
||||
' */\n';
|
||||
|
||||
const minBanner =
|
||||
'/*! ' + pkg.title + ' - v' + pkg.version + ' - ' + date +
|
||||
' | ' + pkg.homepage +
|
||||
' | Copyright (c) ' + year + ' ' + pkg.author.name +
|
||||
' | Licensed ' + pkg.license +
|
||||
' */';
|
||||
|
||||
const isMinify = process.argv.includes( '--minify' );
|
||||
|
||||
if ( isMinify ) {
|
||||
// Minify mode: create .min.css files with one-line banner.
|
||||
let CleanCSS;
|
||||
try {
|
||||
CleanCSS = require( 'clean-css' );
|
||||
} catch ( e1 ) {
|
||||
try {
|
||||
// clean-css may be nested inside clean-css-cli
|
||||
CleanCSS = require( 'clean-css-cli/node_modules/clean-css' );
|
||||
} catch ( e2 ) {
|
||||
console.error( 'clean-css not found. Install clean-css-cli: npm install clean-css-cli' );
|
||||
process.exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
const cleancss = new CleanCSS( { level: 1 } );
|
||||
|
||||
cssFiles.forEach( function( file ) {
|
||||
const content = fs.readFileSync( file, 'utf8' );
|
||||
const result = cleancss.minify( content );
|
||||
|
||||
if ( result.errors.length ) {
|
||||
console.error( 'Error minifying ' + file + ':', result.errors );
|
||||
process.exit( 1 );
|
||||
}
|
||||
|
||||
const outFile = file.replace( '.css', '.min.css' );
|
||||
fs.writeFileSync( outFile, minBanner + '\n' + result.styles );
|
||||
console.log( 'Minified: ' + outFile );
|
||||
} );
|
||||
} else {
|
||||
// Banner mode: prepend expanded banner to CSS files.
|
||||
cssFiles.forEach( function( file ) {
|
||||
if ( ! fs.existsSync( file ) ) {
|
||||
console.warn( 'Skipping (not found): ' + file );
|
||||
return;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync( file, 'utf8' );
|
||||
|
||||
// Strip any existing banner before adding new one.
|
||||
const stripped = content.replace( /^\/\*![\s\S]*?\*\/\s*/, '' );
|
||||
fs.writeFileSync( file, expandedBanner + '\n' + stripped );
|
||||
console.log( 'Banner added: ' + file );
|
||||
} );
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user