PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.8
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.8
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 +45 -94 1.2.02.3.8 View file →
@@ -55,77 +55,21 @@
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 -
83 - /**
84 - * Enqueue Gutenberg block assets for both frontend + backend.
85 - *
86 - * @since 1.0.0
87 - */
88 - public function enqueue_block_assets() {
89 - if ( wp_script_is( AYG_SLUG . '-public', 'registered' ) ) {
90 - wp_enqueue_style( AYG_SLUG . '-public' );
91 - wp_enqueue_script( AYG_SLUG . '-public' );
92 - } else {
93 - // Styles
94 - wp_enqueue_style(
95 - AYG_SLUG . '-public',
96 - AYG_URL . 'public/assets/css/public.css',
97 - array(),
98 - AYG_VERSION,
99 - 'all'
100 - );
101 71
102 - // Scripts
103 - wp_enqueue_script(
104 - AYG_SLUG . '-public',
105 - AYG_URL . 'public/assets/js/public.js',
106 - array( 'jquery' ),
107 - AYG_VERSION,
108 - false
109 - );
110 -
111 - wp_localize_script(
112 - AYG_SLUG . '-public',
113 - 'ayg_public',
114 - array(
115 - 'ajax_url' => admin_url( 'admin-ajax.php' ),
116 - 'i18n' => array(
117 - 'show_more' => __( 'Show More', 'automatic-youtube-gallery' ),
118 - 'show_less' => __( 'Show Less', 'automatic-youtube-gallery' )
119 - ),
120 - 'players' => array()
121 - )
122 - );
123 - }
124 -
125 - do_action( 'ayg_enqueue_scripts' );
126 - }
127 -
128 72 /**
129 73 * Register our custom block.
130 74 *
131 75 * @since 1.0.0
@@ -130,39 +74,43 @@
130 74 *
131 75 * @since 1.0.0
132 76 */
133 77 public function register_block_type() {
134 - // Hook the post rendering to the block
135 - if ( function_exists( 'register_block_type' ) ) {
136 - $attributes = array(
137 - 'is_admin' => array(
138 - 'type' => 'boolean'
139 - )
140 - );
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 + );
141 90
142 - $fields = ayg_get_editor_fields();
91 + $fields = ayg_get_editor_fields();
143 92
144 - foreach ( $fields as $key => $section ) {
145 - foreach ( $section['fields'] as $field ) {
146 - $type = 'string';
93 + foreach ( $fields as $key => $section ) {
94 + foreach ( $section['fields'] as $field ) {
95 + $type = 'string';
147 96
148 - if ( 'number' == $field['type'] ) {
149 - $type = 'number';
150 - } elseif ( 'checkbox' == $field['type'] ) {
151 - $type = 'boolean';
152 - }
97 + if ( 'number' == $field['type'] ) {
98 + $type = 'number';
99 + } elseif ( 'checkbox' == $field['type'] ) {
100 + $type = 'boolean';
101 + }
153 102
154 - $attributes[ $field['name'] ] = array(
155 - 'type' => $type
156 - );
157 - }
103 + $attributes[ $field['name'] ] = array(
104 + 'type' => $type
105 + );
158 106 }
107 + }
159 108
160 - register_block_type( 'automatic-youtube-gallery/block', array(
161 - 'attributes' => $attributes,
162 - 'render_callback' => array( $this, 'render_block' ),
163 - ));
164 - }
109 + register_block_type( __DIR__ . '/build', array(
110 + 'attributes' => $attributes,
111 + 'render_callback' => array( $this, 'render_block' ),
112 + ) );
165 113 }
166 114
167 115 /**
168 116 * Render the block frontend.
@@ -171,19 +119,22 @@
171 119 * @param array $atts An associative array of attributes.
172 120 * @return string HTML output.
173 121 */
174 122 public function render_block( $atts ) {
175 - // If this is an autosave, our form has not been submitted, so we don't want to do anything
176 - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
177 - return;
123 + if ( ! empty( $atts['is_admin'] ) ) {
124 + $atts['autoplay'] = false;
178 125 }
179 126
180 - if ( ! empty( $atts['is_admin'] ) ) {
181 - $atts['autoplay'] = false;
182 - $atts['autoadvance'] = false;
127 + if ( ! empty( $atts['uid'] ) ) {
128 + $atts['uid'] = md5( $atts['uid'] );
183 129 }
184 130
185 - 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;
186 137 }
187 138
188 139 /**
189 140 * Clean attributes array.