PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.2
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.2
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 +41 -52 2.1.02.3.2 View file →
@@ -55,30 +55,19 @@
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' ),
66 + 'is_loading' => __( 'Loading...', 'automatic-youtube-gallery' )
78 67 )
79 - )
80 - );
68 + )
69 + );
81 70 }
82 71
83 72 /**
84 73 * Register our custom block.
@@ -85,42 +74,43 @@
85 74 *
86 75 * @since 1.0.0
87 76 */
88 77 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 - );
78 + if ( ! function_exists( 'register_block_type' ) ) {
79 + return false;
80 + }
81 +
82 + $attributes = array(
83 + 'is_admin' => array(
84 + 'type' => 'boolean'
85 + ),
86 + 'uid' => array(
87 + 'type' => 'string'
88 + )
89 + );
99 90
100 - $fields = ayg_get_editor_fields();
91 + $fields = ayg_get_editor_fields();
101 92
102 - foreach ( $fields as $key => $section ) {
103 - foreach ( $section['fields'] as $field ) {
104 - $type = 'string';
93 + foreach ( $fields as $key => $section ) {
94 + foreach ( $section['fields'] as $field ) {
95 + $type = 'string';
105 96
106 - if ( 'number' == $field['type'] ) {
107 - $type = 'number';
108 - } elseif ( 'checkbox' == $field['type'] ) {
109 - $type = 'boolean';
110 - }
97 + if ( 'number' == $field['type'] ) {
98 + $type = 'number';
99 + } elseif ( 'checkbox' == $field['type'] ) {
100 + $type = 'boolean';
101 + }
111 102
112 - $attributes[ $field['name'] ] = array(
113 - 'type' => $type
114 - );
115 - }
103 + $attributes[ $field['name'] ] = array(
104 + 'type' => $type
105 + );
116 106 }
107 + }
117 108
118 - register_block_type( 'automatic-youtube-gallery/block', array(
119 - 'attributes' => $attributes,
120 - 'render_callback' => array( $this, 'render_block' ),
121 - ));
122 - }
109 + register_block_type( __DIR__ . '/build', array(
110 + 'attributes' => $attributes,
111 + 'render_callback' => array( $this, 'render_block' ),
112 + ) );
123 113 }
124 114
125 115 /**
126 116 * Render the block frontend.
@@ -129,16 +119,10 @@
129 119 * @param array $atts An associative array of attributes.
130 120 * @return string HTML output.
131 121 */
132 122 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;
136 - }
137 -
138 123 if ( ! empty( $atts['is_admin'] ) ) {
139 124 $atts['autoplay'] = false;
140 - $atts['autoadvance'] = false;
141 125 }
142 126
143 127 if ( ! empty( $atts['uid'] ) ) {
144 128 $atts['uid'] = md5( $atts['uid'] );
@@ -143,9 +127,14 @@
143 127 if ( ! empty( $atts['uid'] ) ) {
144 128 $atts['uid'] = md5( $atts['uid'] );
145 129 }
146 130
147 - return ayg_build_gallery( $this->clean_attributes( $atts ) );
131 + // Output
132 + $output = '<div ' . get_block_wrapper_attributes() . '>';
133 + $output .= ayg_build_gallery( $this->clean_attributes( $atts ) );
134 + $output .= '</div>';
135 +
136 + return $output;
148 137 }
149 138
150 139 /**
151 140 * Clean attributes array.