Automattic\WooCommerce\Internal\EmailEditor
PageRenderer::preload_rest_api_data()
Preload REST API data for the email editor.
Метод класса: PageRenderer{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->preload_rest_api_data( $post ): void;
- $post(\WP_Post) (обязательный)
- Current post being edited.
Код PageRenderer::preload_rest_api_data() PageRenderer::preload rest api data WC 9.8.2
private function preload_rest_api_data( \WP_Post $post ): void { $email_post_type = $post->post_type; $user_theme_post_id = $this->user_theme->get_user_theme_post()->ID; $template_slug = get_post_meta( $post->ID, '_wp_page_template', true ); $routes = array( "/wp/v2/{$email_post_type}/" . intval( $post->ID ) . '?context=edit', "/wp/v2/types/{$email_post_type}?context=edit", '/wp/v2/global-styles/' . intval( $user_theme_post_id ) . '?context=edit', // Global email styles. '/wp/v2/block-patterns/patterns', '/wp/v2/templates?context=edit', '/wp/v2/block-patterns/categories', '/wp/v2/settings', '/wp/v2/types?context=view', '/wp/v2/taxonomies?context=view', ); if ( $template_slug ) { $routes[] = '/wp/v2/templates/lookup?slug=' . $template_slug; } else { $routes[] = "/wp/v2/{$email_post_type}?context=edit&per_page=30&status=publish,sent"; } // Preload the data for the specified routes. $preload_data = array_reduce( $routes, 'rest_preload_api_request', array() ); // Add inline script to set up preloading middleware. wp_add_inline_script( 'wp-blocks', sprintf( 'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );', wp_json_encode( $preload_data ) ) ); }