PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.6.4
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.6.4
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
← All changes | block/block.php +51 -54 2.2.02.6.4 View file →
@@ -55,30 +55,18 @@
55 55 }
56 56 }
57 57 }
58 58
59 - // Scripts
60 - wp_enqueue_script(
61 - 'ayg-block-js',
62 - plugins_url( '/block/dist/blocks.build.js', dirname( __FILE__ ) ),
63 - array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
64 - filemtime( plugin_dir_path( __DIR__ ) . 'block/dist/blocks.build.js' ),
65 - true
66 - );
67 -
68 59 wp_localize_script(
69 - 'ayg-block-js',
70 - 'ayg_block',
60 + 'wp-block-editor',
61 + 'ayg_block',
71 62 array(
72 63 'options' => $fields,
73 64 'i18n' => array(
74 - 'block_description' => __( 'Create automated YouTube galleries.', 'automatic-youtube-gallery' ),
75 - 'block_title' => __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
76 - 'selected_color' => __( 'Selected Color', 'automatic-youtube-gallery' ),
77 - 'spinner_message' => __( 'Waiting to finish your block configuration. This delay is to avoid frequent YouTube API calls.', 'automatic-youtube-gallery' )
65 + 'selected_color' => __( 'Selected Color', 'automatic-youtube-gallery' )
78 66 )
79 - )
80 - );
67 + )
68 + );
81 69 }
82 70
83 71 /**
84 72 * Register our custom block.
@@ -85,42 +73,43 @@
85 73 *
86 74 * @since 1.0.0
87 75 */
88 76 public function register_block_type() {
89 - // Hook the post rendering to the block
90 - if ( function_exists( 'register_block_type' ) ) {
91 - $attributes = array(
92 - 'is_admin' => array(
93 - 'type' => 'boolean'
94 - ),
95 - 'uid' => array(
96 - 'type' => 'string'
97 - )
98 - );
77 + if ( ! function_exists( 'register_block_type' ) ) {
78 + return false;
79 + }
80 +
81 + $attributes = array(
82 + 'is_admin' => array(
83 + 'type' => 'boolean'
84 + ),
85 + 'uid' => array(
86 + 'type' => 'string'
87 + )
88 + );
99 89
100 - $fields = ayg_get_editor_fields();
90 + $fields = ayg_get_editor_fields();
101 91
102 - foreach ( $fields as $key => $section ) {
103 - foreach ( $section['fields'] as $field ) {
104 - $type = 'string';
92 + foreach ( $fields as $key => $section ) {
93 + foreach ( $section['fields'] as $field ) {
94 + $type = 'string';
105 95
106 - if ( 'number' == $field['type'] ) {
107 - $type = 'number';
108 - } elseif ( 'checkbox' == $field['type'] ) {
109 - $type = 'boolean';
110 - }
96 + if ( 'number' == $field['type'] ) {
97 + $type = 'number';
98 + } elseif ( 'checkbox' == $field['type'] ) {
99 + $type = 'boolean';
100 + }
111 101
112 - $attributes[ $field['name'] ] = array(
113 - 'type' => $type
114 - );
115 - }
102 + $attributes[ $field['name'] ] = array(
103 + 'type' => $type
104 + );
116 105 }
106 + }
117 107
118 - register_block_type( 'automatic-youtube-gallery/block', array(
119 - 'attributes' => $attributes,
120 - 'render_callback' => array( $this, 'render_block' ),
121 - ));
122 - }
108 + register_block_type( __DIR__ . '/build', array(
109 + 'attributes' => $attributes,
110 + 'render_callback' => array( $this, 'render_block' ),
111 + ) );
123 112 }
124 113
125 114 /**
126 115 * Render the block frontend.
@@ -129,23 +118,31 @@
129 118 * @param array $atts An associative array of attributes.
130 119 * @return string HTML output.
131 120 */
132 121 public function render_block( $atts ) {
133 - // If this is an autosave, our form has not been submitted, so we don't want to do anything
134 - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
135 - return;
122 + if ( ! empty( $atts['is_admin'] ) ) {
123 + $atts['autoplay'] = false;
136 124 }
137 125
138 - if ( ! empty( $atts['is_admin'] ) ) {
139 - $atts['autoplay'] = false;
140 - $atts['autoadvance'] = false;
126 + // Deprecated since v2.5.8. Retained for backward compatibility.
127 + if ( ! empty( $atts['uid'] ) ) {
128 + $atts['deprecated_uid'] = md5( $atts['uid'] );
129 + unset( $atts['uid'] );
141 130 }
142 131
143 - if ( ! empty( $atts['uid'] ) ) {
144 - $atts['uid'] = md5( $atts['uid'] );
132 + // If popup is enabled and type is video, force theme to popup
133 + if ( isset( $atts['popup'] ) && ! empty( $atts['popup'] ) ) {
134 + if ( isset( $atts['type'] ) && 'video' == $atts['type'] ) {
135 + $atts['theme'] = 'popup';
136 + }
145 137 }
146 138
147 - return ayg_build_gallery( $this->clean_attributes( $atts ) );
139 + // Output
140 + $output = '<div ' . get_block_wrapper_attributes() . '>';
141 + $output .= ayg_build_gallery( $this->clean_attributes( $atts ) );
142 + $output .= '</div>';
143 +
144 + return $output;
148 145 }
149 146
150 147 /**
151 148 * Clean attributes array.