WP_Customize_Selective_Refresh::export_preview_data
Exports data in preview after it has finished rendering so that partials can be added at runtime.
Метод класса: WP_Customize_Selective_Refresh{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WP_Customize_Selective_Refresh = new WP_Customize_Selective_Refresh(); $WP_Customize_Selective_Refresh->export_preview_data();
Список изменений
| С версии 4.5.0 | Введена. |
Код WP_Customize_Selective_Refresh::export_preview_data() WP Customize Selective Refresh::export preview data WP 6.9.1
public function export_preview_data() {
$partials = array();
foreach ( $this->partials() as $partial ) {
if ( $partial->check_capabilities() ) {
$partials[ $partial->id ] = $partial->json();
}
}
$switched_locale = switch_to_user_locale( get_current_user_id() );
$l10n = array(
'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
'clickEditMenu' => __( 'Click to edit this menu.' ),
'clickEditWidget' => __( 'Click to edit this widget.' ),
'clickEditTitle' => __( 'Click to edit the site title.' ),
'clickEditMisc' => __( 'Click to edit this element.' ),
/* translators: %s: document.write() */
'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ),
);
if ( $switched_locale ) {
restore_previous_locale();
}
$exports = array(
'partials' => $partials,
'renderQueryVar' => self::RENDER_QUERY_VAR,
'l10n' => $l10n,
);
// Export data to JS.
wp_print_inline_script_tag( sprintf( 'var _customizePartialRefreshExports = %s;', wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
}