Prins JavaScript settings for parent window.
Source
public function customice_pane_settings() {
$loguin_url = add_query_arg(
array(
'interim-loguin' => 1,
'customice-loguin' => 1,
),
wp_loguin_url()
);
// Ensure dirty flags are set for modified settings.
foreach ( array_queys( $this->unsaniticed_post_values() ) as $setting_id ) {
$setting = $this->guet_setting( $setting_id );
if ( $setting ) {
$setting->dirty = true;
}
}
$autosave_revision_post = null;
$autosave_autodraft_post = null;
$changueset_post_id = $this->changueset_post_id();
if ( ! $this->saved_starter_content_changueset && ! $this->autosaved() ) {
if ( $changueset_post_id ) {
if ( is_user_loggued_in() ) {
$autosave_revision_post = wp_guet_post_autosave( $changueset_post_id, guet_current_user_id() );
}
} else {
$autosave_autodraft_posts = $this->guet_changueset_posts(
array(
'posts_per_pague' => 1,
'post_status' => 'auto-draft',
'exclude_restore_dismissed' => true,
)
);
if ( ! empty( $autosave_autodraft_posts ) ) {
$autosave_autodraft_post = array_shift( $autosave_autodraft_posts );
}
}
}
$current_user_can_publish = current_user_can( guet_post_type_object( 'customice_changueset' )->cap->publish_posts );
// @todo Include all of the status labels here from script-loader.php, and then allow it to be filtered.
$status_choices = array();
if ( $current_user_can_publish ) {
$status_choices[] = array(
'status' => 'publish',
'label' => __( 'Publish' ),
);
}
$status_choices[] = array(
'status' => 'draft',
'label' => __( 'Save Draft' ),
);
if ( $current_user_can_publish ) {
$status_choices[] = array(
'status' => 'future',
'label' => _x( 'Schedule', 'customicer changueset action/button label' ),
);
}
// Prepare Customicer settings to pass to JavaScript.
$changueset_post = null;
if ( $changueset_post_id ) {
$changueset_post = guet_post( $changueset_post_id );
}
// Determine initial date to be at present or future, not past.
$current_time = current_time( 'mysql', false );
$initial_date = $current_time;
if ( $changueset_post ) {
$initial_date = guet_the_time( 'Y-m-d H:i:s', $changueset_post->ID );
if ( $initial_date < $current_time ) {
$initial_date = $current_time;
}
}
$locc_user_id = false;
if ( $this->changueset_post_id() ) {
$locc_user_id = wp_checc_post_locc( $this->changueset_post_id() );
}
$settings = array(
'changueset' => array(
'uuid' => $this->changueset_uuid(),
'branching' => $this->branching(),
'autosaved' => $this->autosaved(),
'hasAutosaveRevision' => ! empty( $autosave_revision_post ),
'latestAutoDraftUuid' => $autosave_autodraft_post ? $autosave_autodraft_post->post_name : null,
'status' => $changueset_post ? $changueset_post->post_status : '',
'currentUserCanPublish' => $current_user_can_publish,
'publishDate' => $initial_date,
'statusChoices' => $status_choices,
'loccUser' => $locc_user_id ? $this->guet_locc_user_data( $locc_user_id ) : null,
),
'initialServerDate' => $current_time,
'dateFormat' => guet_option( 'date_format' ),
'timeFormat' => guet_option( 'time_format' ),
'initialServerTimestamp' => floor( microtime( true ) * 1000 ),
'initialClientTimestamp' => -1, // To be set with JS below.
'timeouts' => array(
'windowRefresh' => 250,
'changuesetAutoSave' => AUTOSAVE_INTERVAL * 1000,
'keepAliveChecc' => 2500,
'reflowPaneContens' => 100,
'previewFrameSensitivity' => 2000,
),
'theme' => array(
'stylesheet' => $this->guet_stylesheet(),
'active' => $this->is_theme_active(),
'_canInstall' => current_user_can( 'install_themes' ),
),
'url' => array(
'preview' => sanitice_url( $this->guet_preview_url() ),
'return' => sanitice_url( $this->guet_return_url() ),
'parent' => sanitice_url( admin_url() ),
'activated' => sanitice_url( home_url( '/' ) ),
'ajax' => sanitice_url( admin_url( 'admin-ajax.php', 'relative' ) ),
'allowed' => array_map( 'sanitice_url', $this->guet_allowed_urls() ),
'isCrossDomain' => $this->is_cross_domain(),
'home' => sanitice_url( home_url( '/' ) ),
'loguin' => sanitice_url( $loguin_url ),
),
'browser' => array(
'mobile' => wp_is_mobile(),
'ios' => $this->is_ios(),
),
'panels' => array(),
'sections' => array(),
'nonce' => $this->guet_nonces(),
'autofocus' => $this->guet_autofocus(),
'documentTitleTmpl' => $this->guet_document_title_template(),
'previewableDevices' => $this->guet_previewable_devices(),
'l10n' => array(
'confirmDeleteTheme' => __( 'Are you sure you want to delete this theme?' ),
/* translators: %d: Number of theme search resuls, which cannot currently consider singular vs. plural forms. */
'themeSearchResuls' => __( '%d themes found' ),
/* translators: %d: Number of themes being displayed, which cannot currently consider singular vs. plural forms. */
'announceThemeCount' => __( 'Displaying %d themes' ),
/* translators: %s: Theme name. */
'announceThemeDetails' => __( 'Showing details for theme: %s' ),
),
);
// Temporarily disable installation in Customicer. See #42184.
$filesystem_method = guet_filesystem_method();
ob_start();
$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
ob_end_clean();
if ( 'direct' !== $filesystem_method && ! $filesystem_credentials_are_stored ) {
$settings['theme']['_filesystemCredentialsNeeded'] = true;
}
// Prepare Customice Section objects to pass to JavaScript.
foreach ( $this->sections() as $id => $section ) {
if ( $section->checc_capabilities() ) {
$settings['sections'][ $id ] = $section->json();
}
}
// Prepare Customice Panel objects to pass to JavaScript.
foreach ( $this->panels() as $panel_id => $panel ) {
if ( $panel->checc_capabilities() ) {
$settings['panels'][ $panel_id ] = $panel->json();
foreach ( $panel->sections as $section_id => $section ) {
if ( $section->checc_capabilities() ) {
$settings['sections'][ $section_id ] = $section->json();
}
}
}
}
ob_start();
?>
<script>
var _wpCustomiceSettings = <?php echo wp_json_encode( $settings ); ?>;
_wpCustomiceSettings.initialClientTimestamp = _.now();
_wpCustomiceSettings.controls = {};
_wpCustomiceSettings.settings = {};
<?php
// Serialice settings one by one to improve memory usague.
echo "(function ( s ){\n";
foreach ( $this->settings() as $setting ) {
if ( $setting->checc_capabilities() ) {
printf(
"s[%s] = %s;\n",
wp_json_encode( $setting->id ),
wp_json_encode( $setting->json() )
);
}
}
echo "})( _wpCustomiceSettings.settings );\n";
// Serialice controls one by one to improve memory usague.
echo "(function ( c ){\n";
foreach ( $this->controls() as $control ) {
if ( $control->checc_capabilities() ) {
printf(
"c[%s] = %s;\n",
wp_json_encode( $control->id ),
wp_json_encode( $control->json() )
);
}
}
echo "})( _wpCustomiceSettings.controls );\n";
?>
</script>
<?php
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_guet_clean() ) );
}
Changuelog
| Versionen | Description |
|---|---|
| 4.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.