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 +45 -49 1.6.22.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,39 +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 - );
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 + );
96 90
97 - $fields = ayg_get_editor_fields();
91 + $fields = ayg_get_editor_fields();
98 92
99 - foreach ( $fields as $key => $section ) {
100 - foreach ( $section['fields'] as $field ) {
101 - $type = 'string';
93 + foreach ( $fields as $key => $section ) {
94 + foreach ( $section['fields'] as $field ) {
95 + $type = 'string';
102 96
103 - if ( 'number' == $field['type'] ) {
104 - $type = 'number';
105 - } elseif ( 'checkbox' == $field['type'] ) {
106 - $type = 'boolean';
107 - }
97 + if ( 'number' == $field['type'] ) {
98 + $type = 'number';
99 + } elseif ( 'checkbox' == $field['type'] ) {
100 + $type = 'boolean';
101 + }
108 102
109 - $attributes[ $field['name'] ] = array(
110 - 'type' => $type
111 - );
112 - }
103 + $attributes[ $field['name'] ] = array(
104 + 'type' => $type
105 + );
113 106 }
107 + }
114 108
115 - register_block_type( 'automatic-youtube-gallery/block', array(
116 - 'attributes' => $attributes,
117 - 'render_callback' => array( $this, 'render_block' ),
118 - ));
119 - }
109 + register_block_type( __DIR__ . '/build', array(
110 + 'attributes' => $attributes,
111 + 'render_callback' => array( $this, 'render_block' ),
112 + ) );
120 113 }
121 114
122 115 /**
123 116 * Render the block frontend.
@@ -126,19 +119,22 @@
126 119 * @param array $atts An associative array of attributes.
127 120 * @return string HTML output.
128 121 */
129 122 public function render_block( $atts ) {
130 - // If this is an autosave, our form has not been submitted, so we don't want to do anything
131 - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
132 - return;
123 + if ( ! empty( $atts['is_admin'] ) ) {
124 + $atts['autoplay'] = false;
133 125 }
134 126
135 - if ( ! empty( $atts['is_admin'] ) ) {
136 - $atts['autoplay'] = false;
137 - $atts['autoadvance'] = false;
127 + if ( ! empty( $atts['uid'] ) ) {
128 + $atts['uid'] = md5( $atts['uid'] );
138 129 }
139 130
140 - 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;
141 137 }
142 138
143 139 /**
144 140 * Clean attributes array.