Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WPR_Widget_Image extends WP_Widget_Media_Image {
- function __construct() {
- parent::__construct();
- add_filter( 'widget_media_image_instance_schema', array( $this, 'schema' ) );
- }
- function schema( $schema ) {
- return array_merge( array(
- 'template' => array(
- 'type' => 'string',
- 'enum' => array( 'default', 'parallax' ),
- 'default' => 'default',
- ),
- ), $schema );
- }
- public function enqueue_admin_scripts() {
- wp_enqueue_script( 'ruddie-image-widgets', WPR_URL . '/js/image-widget.js' );
- parent::enqueue_admin_scripts();
- }
- public function render_control_template_scripts() {
- parent::render_control_template_scripts();
- ?>
- <script type="text/html" id="tmpl-ruddie-image-setting">
- <label class="setting template">
- <span><?php _e( 'Template' ); ?></span>
- <select name="temlate" data-setting="template">
- <?php
- $templates = array(
- 'default' => __( 'Default' ),
- 'parallax' => __( 'Parallax' )
- );
- foreach ( $templates as $key => $label ) :
- ?>
- <option value="<?php echo esc_attr( $key ); ?>">
- <?php echo esc_html( $label ); ?>
- </option>
- <?php endforeach; ?>
- </select>
- </label>
- </script>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement