PluginProbe
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs / 2.6.6
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs v2.6.6
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | inc/layout/functions.php +83 -0 2.6.12.6.6 View file →
@@ -117,5 +117,88 @@
117 117 $registry = Component_Registry::instance();
118 118 return $registry::pages();
119 119 }
120 120
121 +/**
122 + * Gets the registered headers.
123 + *
124 + * @return array Array of registered headers.
125 + */
126 +function blockspare_get_headers() {
127 + $registry = Component_Registry::instance();
128 + return $registry::headers();
129 +}
130 +
131 +/**
132 + * Gets the registered footers.
133 + *
134 + * @return array Array of registered footers.
135 + */
136 +function blockspare_get_footers() {
137 + $registry = Component_Registry::instance();
138 + return $registry::footers();
139 +}
140 +
141 +
142 +function blockspare_import_images_replace_url($content =''){
143 +
144 + preg_match_all( '#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $content, $match );
145 + $all_links = array_unique( $match[0] );
146 +
147 +
148 + if ( empty( $all_links ) ) {
149 + return $content;
150 + };
151 + $link_mapping = array();
152 + $image_links = array();
153 + $other_links = array();
154 + foreach ( $all_links as $key => $link ) {
155 + if ( blockspare_block_templates_is_valid_image( $link ) ) {
156 + if (
157 + false === strpos( $link, '-150x' ) &&
158 + false === strpos( $link, '-300x' ) &&
159 + false === strpos( $link, '-1024x' )
160 + ) {
161 + $image_links[] = $link;
162 + }
163 + } else {
164 +
165 +
166 + $other_links[] = $link;
167 + }
168 + }
169 +
170 +
171 + if ( ! empty( $image_links ) ) {
172 + foreach ( $image_links as $key => $image_url ) {
173 + // Download remote image.
174 + $image = array(
175 + 'url' => $image_url,
176 + 'id' => 0,
177 + );
178 + $downloaded_image = Blockspare_Design_Image_Importer::get_instance()->blockspare_import( $image );
179 +
180 +
181 + $link_mapping[ $image_url ] = $downloaded_image['url'];
182 + }
183 + }
184 + foreach ( $link_mapping as $old_url => $new_url ) {
185 + $content = str_replace( $old_url, $new_url, $content );
186 +
187 + // Replace the slashed URLs if any exist.
188 + $old_url = str_replace( '/', '/\\', $old_url );
189 + $new_url = str_replace( '/', '/\\', $new_url );
190 + $content = str_replace( $old_url, $new_url, $content );
191 + }
192 +
193 + return $content;
194 +
195 +
196 +
197 +
198 +}
199 +
200 +function blockspare_block_templates_is_valid_image( $link = '' ) {
201 + return preg_match( '/^((https?:\/\/)|(www\.))([a-z0-9-].?)+(:[0-9]+)?\/[\w\-]+\.(jpg|png|gif|jpeg)\/?$/i', $link );
202 +}
203 +
121 204