GC_Customize_Widgets::export_preview_data()
最后更新于:2021-11-27 10:13:20
GC_Customize_Widgets::export_preview_data()Communicates the sidebars that appeared on the page at the very end of the page, and at the very end of the gc_footer,
源文件
文件: gc-includes/class-gc-customize-widgets.php
public function export_preview_data() {
global $gc_registered_sidebars, $gc_registered_widgets;
$switched_locale = switch_to_locale( get_user_locale() );
$l10n = array(
'widgetTooltip' => __( 'Shift-click to edit this widget.' ),
);
if ( $switched_locale ) {
restore_previous_locale();
}
$rendered_sidebars = array_filter( $this->rendered_sidebars );
$rendered_widgets = array_filter( $this->rendered_widgets );
// Prepare Customizer settings to pass to JavaScript.
$settings = array(
'renderedSidebars' => array_fill_keys( array_keys( $rendered_sidebars ), true ),
'renderedWidgets' => array_fill_keys( array_keys( $rendered_widgets ), true ),
'registeredSidebars' => array_values( $gc_registered_sidebars ),
'registeredWidgets' => $gc_registered_widgets,
'l10n' => $l10n,
'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(),
);
foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
unset( $registered_widget['callback'] ); // May not be JSON-serializeable.
}
?>
<script type="text/javascript">
var _gcWidgetCustomizerPreviewSettings = <?php echo gc_json_encode( $settings ); ?>;
</script>
<?php
}