array( 'type' => 'integer', 'minimum' => 1 ), 'title' => array( 'type' => 'string', 'description' => __( 'SEO title. May contain Rank Math template variables. Empty string clears the override.', 'acrossai-abilities-manager' ) ), 'description' => array( 'type' => 'string', 'description' => __( 'Meta description. Empty string clears the override.', 'acrossai-abilities-manager' ) ), 'focus_keyword' => array( 'type' => 'string', 'description' => __( 'Comma-separated focus keywords; the first is the primary.', 'acrossai-abilities-manager' ) ), 'canonical_url' => array( 'type' => 'string', 'description' => __( 'Canonical URL override. Empty string clears it.', 'acrossai-abilities-manager' ) ), 'robots' => array( 'type' => 'array', 'items' => array( 'type' => 'string', 'enum' => array( 'index', 'noindex', 'nofollow', 'noarchive', 'noimageindex', 'nosnippet' ), ), 'description' => __( 'Robots directives as a list. Rank Math stores this as an array, so a string would be misread.', 'acrossai-abilities-manager' ), ), 'is_pillar' => array( 'type' => 'boolean', 'description' => __( 'Mark as pillar content.', 'acrossai-abilities-manager' ) ), 'is_cornerstone' => array( 'type' => 'boolean', 'description' => __( 'Mark as cornerstone content.', 'acrossai-abilities-manager' ) ), ); } protected function output_properties(): array { return array( 'post_id' => array( 'type' => 'integer' ), 'updated' => array( 'type' => 'object' ), ); } protected function required_input(): array { return array( 'post_id' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $post_id = isset( $input['post_id'] ) ? absint( $input['post_id'] ) : 0; $fields = $input; unset( $fields['post_id'] ); $result = Post_Meta_Repository::update_seo_meta( $post_id, $fields ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = sprintf( /* translators: 1: number of fields written, 2: post id */ _n( 'Wrote %1$d SEO field to post %2$d.', 'Wrote %1$d SEO fields to post %2$d.', count( $result['updated'] ), 'acrossai-abilities-manager' ), count( $result['updated'] ), $post_id ); return $result; } }