WP_Widget_Media::render_control_template_scripts() WordPress Method

This function is used to render control template scripts. The function makes use of the following templates: - media-widget-control-templates - media-widget-control-scripts These templates are located in the following directories: - wp-admin/js/widgets/ - wp-includes/js/media-widgets/ The function includes the following files: - media-widgets.js - wp-util.js The function is called by the following methods: - WP_Widget_Media::render_control() - WP_Widget_Media_Image::render_control() - WP_Widget_Media_Audio::render_control() - WP_Widget_Media_Video::render_control() The function does the following: - Renders the control template scripts. - Enqueues the media-widgets.js file. - Localizes the media widget with the following data: - { - l10n: { - add: wp.mediaWidgets.l10n.add, - edit: wp.mediaWidgets.l10n.edit, - remove: wp.mediaWidgets.l10n.remove, - URL: wp.mediaWidgets.l10n.URL, - title: wp.mediaWidgets.l10n.title, - artist: wp.mediaWidgets.l10n.artist, - album: wp.mediaWidgets.l10n.album, - caption: wp.mediaWidgets.l10n.caption, - alt: wp.mediaWidgets.l10n.alt, - dimensions: wp.mediaWidgets.l10n.dimensions, - uploadError: wp.mediaWidgets.l10n.uploadError, - }, - control: { - add: mediaControl.add, - edit: mediaControl.edit, - remove: mediaControl.remove, - update: mediaControl.update, - menu: mediaControl.menu, - }, - } - -The function then calls the following methods: - wp.mediaWidgets.init() - wp.mediaWidgets.render() - wp.mediaWidgets.mejs.init() The function returns the following: - The control template scripts.

WP_Widget_Media::render_control_template_scripts() #

Render form template scripts.


Source

File: wp-includes/widgets/class-wp-widget-media.php

	public function render_control_template_scripts() {
		?>
		<script type="text/html" id="tmpl-widget-media-<?php echo esc_attr( $this->id_base ); ?>-control">
			<# var elementIdPrefix = 'el' + String( Math.random() ) + '_' #>
			<p>
				<label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label>
				<input id="{{ elementIdPrefix }}title" type="text" class="widefat title">
			</p>
			<div class="media-widget-preview <?php echo esc_attr( $this->id_base ); ?>">
				<div class="attachment-media-view">
					<button type="button" class="select-media button-add-media not-selected">
						<?php echo esc_html( $this->l10n['add_media'] ); ?>
					</button>
				</div>
			</div>
			<p class="media-widget-buttons">
				<button type="button" class="button edit-media selected">
					<?php echo esc_html( $this->l10n['edit_media'] ); ?>
				</button>
			<?php if ( ! empty( $this->l10n['replace_media'] ) ) : ?>
				<button type="button" class="button change-media select-media selected">
					<?php echo esc_html( $this->l10n['replace_media'] ); ?>
				</button>
			<?php endif; ?>
			</p>
			<div class="media-widget-fields">
			</div>
		</script>
		<?php
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.