ber of modified posts. sprintf( esc_html__( 'SEO meta successfully updated in %d posts. The process was stopped as you have used all the credits on your site.', 'rank-math' ), $posts_processed ), [ 'type' => 'success', 'id' => 'rank_math_content_ai_posts', 'classes' => 'rank-math-notice', ] ); wp_clear_scheduled_hook( 'wp_bulk_edit_seo_meta_cron' ); } } return false; } catch ( \Exception $error ) { return true; } } /** * Get Posts to bulk update the data. * * @param array $data Data to process. * * @return array */ private function get_posts( $data ) { $connect_data = Admin_Helper::get_registration_data(); $posts = array_values( $data['posts'] ); $action = $data['action']; $language = $data['language']; $data = [ 'posts' => $posts, 'output' => $action, 'language' => $language, 'choices' => 1, 'username' => $connect_data['username'], 'api_key' => $connect_data['api_key'], 'site_url' => $connect_data['site_url'], 'is_taxonomy' => ! empty( $data['is_taxonomy'] ), 'plugin_version' => rank_math()->version, ]; return wp_remote_post( CONTENT_AI_URL . '/ai/bulk_seo_meta', [ 'headers' => [ 'content-type' => 'application/json', ], 'timeout' => 60, 'body' => wp_json_encode( $data ), ] ); } /** * Keep count of the Content AI posts that were processed. * * @param int $count Number of posts processed. * * @return void */ private function update_content_ai_posts_count( $count ) { $content_ai_posts_count = get_option( 'rank_math_content_ai_posts_processed', 0 ) + $count; update_option( 'rank_math_content_ai_posts_processed', $content_ai_posts_count, false ); } }