Version Description
- Fix: Add Media button not working for custom post types
- Fix: Underscore.js dependency missing
- Fix: Undefined variable: current_color_scheme
- Fix: Root Folder missing in media upload dropdown
Download this release
Release Info
Developer | dfactory |
Plugin | Responsive Lightbox & Gallery |
Version | 2.2.2 |
Comparing to | |
See all releases |
Code changes from version 2.2.1 to 2.2.2
- includes/class-folders.php +92 -57
- includes/class-galleries.php +60 -14
- includes/class-remote-library.php +2 -1
- js/admin-folders.js +159 -154
- js/admin-galleries.js +3 -11
- js/admin-media.js +401 -399
- library/simplehtmldom/simple_html_dom.php +3 -1
- readme.txt +13 -7
- responsive-lightbox.php +5 -5
includes/class-folders.php
CHANGED
@@ -158,22 +158,40 @@ class Responsive_Lightbox_Folders {
|
|
158 |
* @return string
|
159 |
*/
|
160 |
private function get_folders( $taxonomy, $selected = 0 ) {
|
161 |
-
|
|
|
162 |
array(
|
163 |
-
'
|
164 |
-
'
|
165 |
-
'
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'hierarchical' => true,
|
169 |
-
'hide_if_empty' => false,
|
170 |
-
'echo' => false,
|
171 |
-
'selected' => (int) $selected,
|
172 |
-
'id' => 'rl_folders_upload_files',
|
173 |
-
'name' => 'rl_folders_upload_files_term_id',
|
174 |
-
'taxonomy' => $taxonomy
|
175 |
)
|
176 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
/**
|
@@ -185,23 +203,41 @@ class Responsive_Lightbox_Folders {
|
|
185 |
// get taxonomy
|
186 |
$taxonomy = Responsive_Lightbox()->options['folders']['media_taxonomy'];
|
187 |
|
188 |
-
//
|
189 |
-
|
190 |
array(
|
191 |
-
'
|
192 |
-
'
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
'hierarchical' => true,
|
197 |
-
'hide_if_empty' => false,
|
198 |
-
'echo' => false,
|
199 |
-
'selected' => isset( $_GET[$taxonomy] ) ? (int) $_GET[$taxonomy] : 0,
|
200 |
-
'id' => 'rl_folders_upload_files',
|
201 |
-
'name' => 'rl_folders_upload_files_term_id',
|
202 |
-
'taxonomy' => $taxonomy
|
203 |
)
|
204 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
206 |
|
207 |
/**
|
@@ -393,38 +429,40 @@ class Responsive_Lightbox_Folders {
|
|
393 |
$fields[$taxonomy] = $tax;
|
394 |
}
|
395 |
|
396 |
-
|
397 |
-
|
|
|
398 |
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
|
403 |
-
|
404 |
-
|
405 |
|
406 |
-
|
407 |
|
408 |
-
|
409 |
-
|
410 |
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
|
426 |
-
|
427 |
-
|
|
|
428 |
}
|
429 |
}
|
430 |
|
@@ -846,9 +884,6 @@ class Responsive_Lightbox_Folders {
|
|
846 |
$color = implode( ',', $rl->hex2rgb( $_wp_admin_css_colors[$current_color_scheme]->colors[3] ) );
|
847 |
}
|
848 |
|
849 |
-
// get all available colors from scheme name
|
850 |
-
$colors = $_wp_admin_css_colors[$current_color_scheme]->colors;
|
851 |
-
|
852 |
wp_add_inline_style(
|
853 |
'responsive-lightbox-folders-jstree',
|
854 |
'#rl-folders-tree-container .jstree .rl-folders-state-active.rl-folders-state-hover {
|
@@ -1003,7 +1038,7 @@ class Responsive_Lightbox_Folders {
|
|
1003 |
wp_register_script( 'responsive-lightbox-folders-jstree', RESPONSIVE_LIGHTBOX_URL . '/assets/jstree/jstree' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array(), $rl->defaults['version'], false );
|
1004 |
wp_register_script( 'responsive-lightbox-folders-perfect-scrollbar', RESPONSIVE_LIGHTBOX_URL . '/assets/perfect-scrollbar/perfect-scrollbar' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array(), $rl->defaults['version'], false );
|
1005 |
|
1006 |
-
wp_enqueue_script( 'responsive-lightbox-folders-admin', RESPONSIVE_LIGHTBOX_URL . '/js/admin-folders.js', array( 'jquery', 'jquery-ui-draggable', 'jquery-ui-droppable', 'media-
|
1007 |
|
1008 |
wp_localize_script(
|
1009 |
'responsive-lightbox-folders-admin',
|
158 |
* @return string
|
159 |
*/
|
160 |
private function get_folders( $taxonomy, $selected = 0 ) {
|
161 |
+
// get only 1 term to check if taxonomy is empty
|
162 |
+
$any_terms = get_terms(
|
163 |
array(
|
164 |
+
'taxonomy' => $taxonomy,
|
165 |
+
'hide_empty' => false,
|
166 |
+
'fields' => 'ids',
|
167 |
+
'hierarchical' => false,
|
168 |
+
'number' => 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
)
|
170 |
);
|
171 |
+
|
172 |
+
// prepare dropdown categories parameters
|
173 |
+
$args = array(
|
174 |
+
'orderby' => 'name',
|
175 |
+
'order' => 'asc',
|
176 |
+
'show_option_all' => __( 'Root Folder', 'responsive-lightbox' ),
|
177 |
+
'show_count' => false,
|
178 |
+
'hide_empty' => false,
|
179 |
+
'hierarchical' => true,
|
180 |
+
'hide_if_empty' => false,
|
181 |
+
'echo' => false,
|
182 |
+
'selected' => (int) $selected,
|
183 |
+
'id' => 'rl_folders_upload_files',
|
184 |
+
'name' => 'rl_folders_upload_files_term_id',
|
185 |
+
'taxonomy' => $taxonomy
|
186 |
+
);
|
187 |
+
|
188 |
+
// no terms?
|
189 |
+
if ( ! is_wp_error( $any_terms ) && empty( $any_terms ) ) {
|
190 |
+
$args['show_option_none'] = __( 'Root Folder', 'responsive-lightbox' );
|
191 |
+
$args['option_none_value'] = 0;
|
192 |
+
}
|
193 |
+
|
194 |
+
return wp_dropdown_categories( $args );
|
195 |
}
|
196 |
|
197 |
/**
|
203 |
// get taxonomy
|
204 |
$taxonomy = Responsive_Lightbox()->options['folders']['media_taxonomy'];
|
205 |
|
206 |
+
// get only 1 term to check if taxonomy is empty
|
207 |
+
$any_terms = get_terms(
|
208 |
array(
|
209 |
+
'taxonomy' => $taxonomy,
|
210 |
+
'hide_empty' => false,
|
211 |
+
'fields' => 'ids',
|
212 |
+
'hierarchical' => false,
|
213 |
+
'number' => 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
)
|
215 |
+
);
|
216 |
+
|
217 |
+
// prepare dropdown categories parameters
|
218 |
+
$args = array(
|
219 |
+
'orderby' => 'name',
|
220 |
+
'order' => 'asc',
|
221 |
+
'show_option_all' => __( 'Root Folder', 'responsive-lightbox' ),
|
222 |
+
'show_count' => false,
|
223 |
+
'hide_empty' => false,
|
224 |
+
'hierarchical' => true,
|
225 |
+
'hide_if_empty' => false,
|
226 |
+
'echo' => false,
|
227 |
+
'selected' => isset( $_GET[$taxonomy] ) ? (int) $_GET[$taxonomy] : 0,
|
228 |
+
'id' => 'rl_folders_upload_files',
|
229 |
+
'name' => 'rl_folders_upload_files_term_id',
|
230 |
+
'taxonomy' => $taxonomy
|
231 |
+
);
|
232 |
+
|
233 |
+
// no terms?
|
234 |
+
if ( ! is_wp_error( $any_terms ) && empty( $any_terms ) ) {
|
235 |
+
$args['show_option_none'] = __( 'Root Folder', 'responsive-lightbox' );
|
236 |
+
$args['option_none_value'] = 0;
|
237 |
+
}
|
238 |
+
|
239 |
+
// display select
|
240 |
+
echo '<p><label>' . __( 'Upload files to', 'responsive-lightbox' ) . ': ' . wp_dropdown_categories( $args ) . '</label></p>';
|
241 |
}
|
242 |
|
243 |
/**
|
429 |
$fields[$taxonomy] = $tax;
|
430 |
}
|
431 |
|
432 |
+
if ( Responsive_Lightbox()->options['folders']['media_tags'] && taxonomy_exists( 'rl_media_tag' ) ) {
|
433 |
+
// get taxonomy object
|
434 |
+
$tax = (array) get_taxonomy( 'rl_media_tag' );
|
435 |
|
436 |
+
if ( ! empty( $tax ) ) {
|
437 |
+
if ( ! $tax['public'] || ! $tax['show_ui'] )
|
438 |
+
return $fields;
|
439 |
|
440 |
+
if ( empty( $tax['args'] ) )
|
441 |
+
$tax['args'] = array();
|
442 |
|
443 |
+
$tags_html = '';
|
444 |
|
445 |
+
// get terms
|
446 |
+
$tags = wp_get_post_terms( $post->ID, 'rl_media_tag', array( 'fields' => 'id=>name' ) );
|
447 |
|
448 |
+
// valid terms?
|
449 |
+
if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) {
|
450 |
+
foreach ( $tags as $tag_name ) {
|
451 |
+
$tags_html .= '<option value="' . $tag_name . '" selected="selected">' . esc_html( $tag_name ) . '</li>';
|
452 |
+
}
|
453 |
+
} else
|
454 |
+
$tags = array();
|
455 |
|
456 |
+
// update input
|
457 |
+
$tax['input'] = 'html';
|
458 |
+
$tax['html'] = '
|
459 |
+
<select class="rl-media-tag-select2" multiple="multiple" name="attachments[' . $post->ID . '][rl_media_tag]">
|
460 |
+
' . $tags_html . '
|
461 |
+
</select>';
|
462 |
|
463 |
+
// update taxonomy
|
464 |
+
$fields['rl_media_tag'] = $tax;
|
465 |
+
}
|
466 |
}
|
467 |
}
|
468 |
|
884 |
$color = implode( ',', $rl->hex2rgb( $_wp_admin_css_colors[$current_color_scheme]->colors[3] ) );
|
885 |
}
|
886 |
|
|
|
|
|
|
|
887 |
wp_add_inline_style(
|
888 |
'responsive-lightbox-folders-jstree',
|
889 |
'#rl-folders-tree-container .jstree .rl-folders-state-active.rl-folders-state-hover {
|
1038 |
wp_register_script( 'responsive-lightbox-folders-jstree', RESPONSIVE_LIGHTBOX_URL . '/assets/jstree/jstree' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array(), $rl->defaults['version'], false );
|
1039 |
wp_register_script( 'responsive-lightbox-folders-perfect-scrollbar', RESPONSIVE_LIGHTBOX_URL . '/assets/perfect-scrollbar/perfect-scrollbar' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array(), $rl->defaults['version'], false );
|
1040 |
|
1041 |
+
wp_enqueue_script( 'responsive-lightbox-folders-admin', RESPONSIVE_LIGHTBOX_URL . '/js/admin-folders.js', array( 'jquery', 'underscore', 'jquery-ui-draggable', 'jquery-ui-droppable', 'media-models', 'responsive-lightbox-folders-jstree', 'responsive-lightbox-folders-perfect-scrollbar', 'tags-suggest' ), $rl->defaults['version'], false );
|
1042 |
|
1043 |
wp_localize_script(
|
1044 |
'responsive-lightbox-folders-admin',
|
includes/class-galleries.php
CHANGED
@@ -947,7 +947,7 @@ class Responsive_Lightbox_Galleries {
|
|
947 |
// assign main instance
|
948 |
$rl = Responsive_Lightbox();
|
949 |
|
950 |
-
wp_enqueue_script( 'responsive-lightbox-admin-gallery', RESPONSIVE_LIGHTBOX_URL . '/js/admin-gallery.js', array( 'jquery' ), $rl->defaults['version'], false );
|
951 |
|
952 |
wp_localize_script(
|
953 |
'responsive-lightbox-admin-gallery',
|
@@ -1160,7 +1160,7 @@ class Responsive_Lightbox_Galleries {
|
|
1160 |
array(
|
1161 |
'orderby' => 'name',
|
1162 |
'order' => 'asc',
|
1163 |
-
'show_option_none' => __( '
|
1164 |
'show_option_all' => false,
|
1165 |
'show_count' => false,
|
1166 |
'hide_empty' => false,
|
@@ -1175,7 +1175,7 @@ class Responsive_Lightbox_Galleries {
|
|
1175 |
)
|
1176 |
);
|
1177 |
} else
|
1178 |
-
$subhtml = '<select><option value="0">' . esc_html__( '
|
1179 |
|
1180 |
if ( isset( $args['include_children'] ) && $args['include_children'] ) {
|
1181 |
$subhtml .= '<label class="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children" for="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children"><input id="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children" type="checkbox" name="rl_gallery[' . $tab_id . '][' . $menu_item . '][' . $field . '][children]" value="true" ' . checked( $args['value']['children'], true, false ) . ' />' . esc_html__( 'Include children.', 'responsive-lightbox' ) . '</label>';
|
@@ -2032,7 +2032,7 @@ class Responsive_Lightbox_Galleries {
|
|
2032 |
'taxonomy' => $rl->options['folders']['media_taxonomy'],
|
2033 |
'folder' => array(
|
2034 |
'id' => 0,
|
2035 |
-
'children' => null
|
2036 |
)
|
2037 |
);
|
2038 |
|
@@ -2198,7 +2198,7 @@ class Responsive_Lightbox_Galleries {
|
|
2198 |
$folder_id = (int) $data[$menu_item]['folder']['id'];
|
2199 |
}
|
2200 |
|
2201 |
-
if ( $folder_id
|
2202 |
$include_children = false;
|
2203 |
|
2204 |
// null means folder was not changed
|
@@ -2216,14 +2216,48 @@ class Responsive_Lightbox_Galleries {
|
|
2216 |
}
|
2217 |
}
|
2218 |
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2227 |
array(
|
2228 |
'taxonomy' => $args['taxonomy'],
|
2229 |
'field' => 'term_id',
|
@@ -2231,7 +2265,18 @@ class Responsive_Lightbox_Galleries {
|
|
2231 |
'include_children' => $include_children,
|
2232 |
'operator' => 'IN'
|
2233 |
)
|
2234 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2235 |
);
|
2236 |
|
2237 |
// is it preview?
|
@@ -2644,6 +2689,7 @@ class Responsive_Lightbox_Galleries {
|
|
2644 |
// get images
|
2645 |
$images = $this->get_gallery_images( $post_id, $args );
|
2646 |
|
|
|
2647 |
$data = array();
|
2648 |
|
2649 |
if ( $menu_item === 'remote_library' ) {
|
947 |
// assign main instance
|
948 |
$rl = Responsive_Lightbox();
|
949 |
|
950 |
+
wp_enqueue_script( 'responsive-lightbox-admin-gallery', RESPONSIVE_LIGHTBOX_URL . '/js/admin-gallery.js', array( 'jquery', 'underscore' ), $rl->defaults['version'], false );
|
951 |
|
952 |
wp_localize_script(
|
953 |
'responsive-lightbox-admin-gallery',
|
1160 |
array(
|
1161 |
'orderby' => 'name',
|
1162 |
'order' => 'asc',
|
1163 |
+
'show_option_none' => __( 'Root Folder', 'responsive-lightbox' ),
|
1164 |
'show_option_all' => false,
|
1165 |
'show_count' => false,
|
1166 |
'hide_empty' => false,
|
1175 |
)
|
1176 |
);
|
1177 |
} else
|
1178 |
+
$subhtml = '<select id="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '" name="rl_gallery[' . $tab_id . '][' . $menu_item . '][' . $field . '][]" ><option value="0">' . esc_html__( 'Root Folder', 'responsive-lightbox' ) . '</option></select> ';
|
1179 |
|
1180 |
if ( isset( $args['include_children'] ) && $args['include_children'] ) {
|
1181 |
$subhtml .= '<label class="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children" for="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children"><input id="rl-' . $tab_id . '-' . $menu_item . '-' . $field . '-include-children" type="checkbox" name="rl_gallery[' . $tab_id . '][' . $menu_item . '][' . $field . '][children]" value="true" ' . checked( $args['value']['children'], true, false ) . ' />' . esc_html__( 'Include children.', 'responsive-lightbox' ) . '</label>';
|
2032 |
'taxonomy' => $rl->options['folders']['media_taxonomy'],
|
2033 |
'folder' => array(
|
2034 |
'id' => 0,
|
2035 |
+
'children' => null // do not change!
|
2036 |
)
|
2037 |
);
|
2038 |
|
2198 |
$folder_id = (int) $data[$menu_item]['folder']['id'];
|
2199 |
}
|
2200 |
|
2201 |
+
if ( $folder_id >= 0 ) {
|
2202 |
$include_children = false;
|
2203 |
|
2204 |
// null means folder was not changed
|
2216 |
}
|
2217 |
}
|
2218 |
|
2219 |
+
if ( $folder_id === 0 ) {
|
2220 |
+
if ( $include_children ) {
|
2221 |
+
$all_folders = get_terms(
|
2222 |
+
array(
|
2223 |
+
'taxonomy' => $args['taxonomy'],
|
2224 |
+
'hide_empty' => false,
|
2225 |
+
'fields' => 'ids',
|
2226 |
+
'hierarchical' => false,
|
2227 |
+
'number' => 0
|
2228 |
+
)
|
2229 |
+
);
|
2230 |
+
|
2231 |
+
$tax_query = array(
|
2232 |
+
'relation' => 'OR',
|
2233 |
+
array(
|
2234 |
+
'taxonomy' => $args['taxonomy'],
|
2235 |
+
'field' => 'term_id',
|
2236 |
+
'terms' => ( ! is_wp_error( $all_folders ) ) ? $all_folders : $folder_id,
|
2237 |
+
'include_children' => $include_children,
|
2238 |
+
'operator' => 'IN'
|
2239 |
+
),
|
2240 |
+
array(
|
2241 |
+
'taxonomy' => $args['taxonomy'],
|
2242 |
+
'field' => 'term_id',
|
2243 |
+
'terms' => $folder_id,
|
2244 |
+
'include_children' => $include_children,
|
2245 |
+
'operator' => 'NOT EXISTS'
|
2246 |
+
)
|
2247 |
+
);
|
2248 |
+
} else {
|
2249 |
+
$tax_query = array(
|
2250 |
+
array(
|
2251 |
+
'taxonomy' => $args['taxonomy'],
|
2252 |
+
'field' => 'term_id',
|
2253 |
+
'terms' => $folder_id,
|
2254 |
+
'include_children' => $include_children,
|
2255 |
+
'operator' => 'NOT EXISTS'
|
2256 |
+
)
|
2257 |
+
);
|
2258 |
+
}
|
2259 |
+
} else {
|
2260 |
+
$tax_query = array(
|
2261 |
array(
|
2262 |
'taxonomy' => $args['taxonomy'],
|
2263 |
'field' => 'term_id',
|
2265 |
'include_children' => $include_children,
|
2266 |
'operator' => 'IN'
|
2267 |
)
|
2268 |
+
);
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
// prepare query arguments
|
2272 |
+
$wp_query_args = array(
|
2273 |
+
'post_type' => 'attachment',
|
2274 |
+
'post_status' => 'inherit',
|
2275 |
+
'post_mime_type' => array( 'image/jpeg', 'image/gif', 'image/png' ),
|
2276 |
+
'nopaging' => true,
|
2277 |
+
'posts_per_page' => -1,
|
2278 |
+
'fields' => 'ids',
|
2279 |
+
'tax_query' => $tax_query
|
2280 |
);
|
2281 |
|
2282 |
// is it preview?
|
2689 |
// get images
|
2690 |
$images = $this->get_gallery_images( $post_id, $args );
|
2691 |
|
2692 |
+
// prepare JSON array
|
2693 |
$data = array();
|
2694 |
|
2695 |
if ( $menu_item === 'remote_library' ) {
|
includes/class-remote-library.php
CHANGED
@@ -152,7 +152,7 @@ class Responsive_Lightbox_Remote_Library {
|
|
152 |
// get main instance
|
153 |
$rl = Responsive_Lightbox();
|
154 |
|
155 |
-
wp_enqueue_script( 'rl-remote-library-media', RESPONSIVE_LIGHTBOX_URL . '/js/admin-media.js', array( 'jquery', 'media-
|
156 |
|
157 |
wp_localize_script(
|
158 |
'rl-remote-library-media',
|
@@ -164,6 +164,7 @@ class Responsive_Lightbox_Remote_Library {
|
|
164 |
'providersActive' => $this->get_active_providers(),
|
165 |
'allProviders' => __( 'All providers', 'responsive-lightbox' ),
|
166 |
'uploadAndInsert' => __( 'Upload and Insert', 'responsive-lightbox' ),
|
|
|
167 |
'filterByremoteLibrary' => __( 'Filter by remote library', 'responsive-lightbox' ),
|
168 |
'getUploadNonce' => wp_create_nonce( 'rl-remote-library-upload-image' )
|
169 |
)
|
152 |
// get main instance
|
153 |
$rl = Responsive_Lightbox();
|
154 |
|
155 |
+
wp_enqueue_script( 'rl-remote-library-media', RESPONSIVE_LIGHTBOX_URL . '/js/admin-media.js', array( 'jquery', 'media-models', 'underscore' ), $rl->defaults['version'] );
|
156 |
|
157 |
wp_localize_script(
|
158 |
'rl-remote-library-media',
|
164 |
'providersActive' => $this->get_active_providers(),
|
165 |
'allProviders' => __( 'All providers', 'responsive-lightbox' ),
|
166 |
'uploadAndInsert' => __( 'Upload and Insert', 'responsive-lightbox' ),
|
167 |
+
'uploadAndSelect' => __( 'Upload and Select', 'responsive-lightbox' ),
|
168 |
'filterByremoteLibrary' => __( 'Filter by remote library', 'responsive-lightbox' ),
|
169 |
'getUploadNonce' => wp_create_nonce( 'rl-remote-library-upload-image' )
|
170 |
)
|
js/admin-folders.js
CHANGED
@@ -11,187 +11,191 @@
|
|
11 |
event_data = {},
|
12 |
allow_modal_media_tag_saving = false;
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
// events
|
23 |
-
this.on( 'content:render', this.contentRender, this );
|
24 |
-
},
|
25 |
-
contentRender: function( view ) {
|
26 |
-
// valid view?
|
27 |
-
if ( view !== null ) {
|
28 |
-
// get all selects
|
29 |
-
var selects = view.toolbar.secondary.$el.find( 'select.attachment-filters' );
|
30 |
-
|
31 |
-
// fix it only for more then 2 selects (default wp)
|
32 |
-
if ( selects.length > 2 ) {
|
33 |
-
// calculate new width
|
34 |
-
var number = parseInt( 100 / selects.length ) - 2;
|
35 |
-
|
36 |
-
$( selects ).each( function( i, el ) {
|
37 |
-
$( el ).css( 'width', 'calc(' + number + '% - 12px)' );
|
38 |
-
} );
|
39 |
-
}
|
40 |
}
|
41 |
-
}
|
42 |
-
}
|
43 |
|
44 |
-
//
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
filters['all'] = {
|
90 |
-
text: rlFoldersArgs.all_terms,
|
91 |
priority: 1,
|
92 |
props: {
|
93 |
-
[rlFoldersArgs.taxonomy]:
|
94 |
'force_update': 0,
|
95 |
-
'include_children':
|
96 |
}
|
97 |
};
|
98 |
-
}
|
99 |
-
|
100 |
-
this.filters = filters;
|
101 |
-
}
|
102 |
-
} );
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
|
|
|
113 |
|
114 |
-
|
115 |
-
if ( this.model.get( 'id' ) !== 'rl-remote-library' ) {
|
116 |
-
this.toolbar.set( 'RLfoldersFilterLabel', new wp.media.view.Label( {
|
117 |
-
value: 'Filter by folder',
|
118 |
-
attributes: {
|
119 |
-
'for': 'media-attachment-rl-folders-filters'
|
120 |
-
},
|
121 |
-
priority: -75
|
122 |
-
} ).render() );
|
123 |
-
|
124 |
-
this.toolbar.set( 'RLfoldersAttachmentFilters', new RLWPMediaViewAttachmentFilters( {
|
125 |
-
controller: this.controller,
|
126 |
-
model: this.collection.props,
|
127 |
-
priority: -75
|
128 |
-
} ).render() );
|
129 |
}
|
130 |
-
}
|
131 |
-
} );
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
tags = [],
|
151 |
-
data = {};
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
156 |
|
157 |
-
|
158 |
-
|
|
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
data[ pair.name ] = pair.value;
|
163 |
-
} );
|
164 |
|
165 |
-
|
166 |
-
|
|
|
|
|
167 |
|
168 |
-
|
169 |
-
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
},
|
174 |
-
postSave: function() {
|
175 |
-
RLAttachmentCompat.postSave.apply( this, arguments );
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
$.extend( wp.Uploader.prototype, {
|
185 |
-
init: function() {
|
186 |
-
this.uploader.bind( 'BeforeUpload', function( file ) {
|
187 |
-
file.settings.multipart_params.rl_folders_upload_files_term_id = rl_folder_id;
|
188 |
-
} );
|
189 |
}
|
190 |
} );
|
191 |
-
}
|
192 |
|
193 |
-
// are we ready?
|
194 |
-
$( document ).ready( function() {
|
195 |
// do nothing for wp_enqueue_media
|
196 |
if ( rlFoldersArgs.page === 'media' ) {
|
197 |
// folder change
|
@@ -215,6 +219,7 @@
|
|
215 |
|
216 |
// initialize draggable
|
217 |
draggable( 'list' );
|
|
|
218 |
} else {
|
219 |
// add tree
|
220 |
$( '#wp-media-grid .error' ).after( rlFoldersArgs.template );
|
11 |
event_data = {},
|
12 |
allow_modal_media_tag_saving = false;
|
13 |
|
14 |
+
if ( typeof wp.Uploader !== 'undefined' ) {
|
15 |
+
// extend uploader to apply dynamic folder ID
|
16 |
+
$.extend( wp.Uploader.prototype, {
|
17 |
+
init: function() {
|
18 |
+
this.uploader.bind( 'BeforeUpload', function( file ) {
|
19 |
+
file.settings.multipart_params.rl_folders_upload_files_term_id = rl_folder_id;
|
20 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
+
} );
|
23 |
+
}
|
24 |
|
25 |
+
// are we ready?
|
26 |
+
$( document ).ready( function() {
|
27 |
+
var RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post;
|
28 |
+
|
29 |
+
// extend media frame
|
30 |
+
wp.media.view.MediaFrame.Post = RLWPMediaViewMediaFramePost.extend( {
|
31 |
+
initialize: function() {
|
32 |
+
// calling the initalize method from the current frame before adding new functionality
|
33 |
+
RLWPMediaViewMediaFramePost.prototype.initialize.apply( this, arguments );
|
34 |
+
|
35 |
+
// events
|
36 |
+
this.on( 'content:render', this.contentRender, this );
|
37 |
+
},
|
38 |
+
contentRender: function( view ) {
|
39 |
+
// valid view?
|
40 |
+
if ( view !== null ) {
|
41 |
+
// get all selects
|
42 |
+
var selects = view.toolbar.secondary.$el.find( 'select.attachment-filters' );
|
43 |
+
|
44 |
+
// fix it only for more then 2 selects (default wp)
|
45 |
+
if ( selects.length > 2 ) {
|
46 |
+
// calculate new width
|
47 |
+
var number = parseInt( 100 / selects.length ) - 2;
|
48 |
+
|
49 |
+
$( selects ).each( function( i, el ) {
|
50 |
+
$( el ).css( 'width', 'calc(' + number + '% - 12px)' );
|
51 |
+
} );
|
52 |
+
}
|
53 |
}
|
54 |
+
}
|
55 |
+
} );
|
56 |
+
|
57 |
+
// add new media folder filter
|
58 |
+
var RLWPMediaViewAttachmentFilters = wp.media.view.AttachmentFilters.extend( {
|
59 |
+
id: 'media-attachment-rl-folders-filters',
|
60 |
+
className: 'attachment-filters attachment-rl-folders-filter',
|
61 |
+
change: function() {
|
62 |
+
wp.media.view.AttachmentFilters.prototype.change.apply( this, arguments );
|
63 |
+
|
64 |
+
if ( grid_frame !== null )
|
65 |
+
grid_frame.controller.states.get( 'library' ).get( 'library' ).observe( wp.Uploader.queue );
|
66 |
+
},
|
67 |
+
createFilters: function() {
|
68 |
+
var filters = {},
|
69 |
+
term_id = 0,
|
70 |
+
terms = $( $.parseHTML( rlFoldersArgs.terms ) ).find( 'option' );
|
71 |
+
|
72 |
+
// root
|
73 |
+
var root = {
|
74 |
+
text: rlFoldersArgs.root,
|
|
|
|
|
75 |
priority: 1,
|
76 |
props: {
|
77 |
+
[rlFoldersArgs.taxonomy]: 0,
|
78 |
'force_update': 0,
|
79 |
+
'include_children': false
|
80 |
}
|
81 |
};
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
// media folder
|
84 |
+
if ( rlFoldersArgs.terms !== '' && terms.length > 0 ) {
|
85 |
+
filters[0] = root;
|
86 |
+
|
87 |
+
$( $.parseHTML( rlFoldersArgs.terms ) ).find('option').each( function( i, option ) {
|
88 |
+
term_id = parseInt( $(option).val() );
|
89 |
+
term_id = ( term_id === 0 ? 'all' : term_id );
|
90 |
+
last_priority = i + 2;
|
91 |
+
|
92 |
+
filters[term_id] = {
|
93 |
+
text: $( option ).text(),
|
94 |
+
priority: last_priority,
|
95 |
+
props: {
|
96 |
+
[rlFoldersArgs.taxonomy]: term_id,
|
97 |
+
'force_update': 0,
|
98 |
+
'include_children': false
|
99 |
+
}
|
100 |
+
};
|
101 |
+
} );
|
102 |
+
// all files
|
103 |
+
} else {
|
104 |
+
filters['all'] = {
|
105 |
+
text: rlFoldersArgs.all_terms,
|
106 |
+
priority: 1,
|
107 |
+
props: {
|
108 |
+
[rlFoldersArgs.taxonomy]: 'all',
|
109 |
+
'force_update': 0,
|
110 |
+
'include_children': true
|
111 |
+
}
|
112 |
+
};
|
113 |
|
114 |
+
filters[0] = root;
|
115 |
+
}
|
116 |
|
117 |
+
this.filters = filters;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
+
} );
|
|
|
120 |
|
121 |
+
var RLFoldersAttachmentsBrowser = wp.media.view.AttachmentsBrowser;
|
122 |
+
|
123 |
+
// extend AttachmentsBrowser
|
124 |
+
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend( {
|
125 |
+
createToolbar: function() {
|
126 |
+
// load the original toolbar
|
127 |
+
RLFoldersAttachmentsBrowser.prototype.createToolbar.call( this );
|
128 |
+
|
129 |
+
attachments_browser = this;
|
130 |
+
|
131 |
+
// skip remote library
|
132 |
+
if ( this.model.get( 'id' ) !== 'rl-remote-library' ) {
|
133 |
+
this.toolbar.set( 'RLfoldersFilterLabel', new wp.media.view.Label( {
|
134 |
+
value: 'Filter by folder',
|
135 |
+
attributes: {
|
136 |
+
'for': 'media-attachment-rl-folders-filters'
|
137 |
+
},
|
138 |
+
priority: -75
|
139 |
+
} ).render() );
|
140 |
+
|
141 |
+
this.toolbar.set( 'RLfoldersAttachmentFilters', new RLWPMediaViewAttachmentFilters( {
|
142 |
+
controller: this.controller,
|
143 |
+
model: this.collection.props,
|
144 |
+
priority: -75
|
145 |
+
} ).render() );
|
146 |
+
}
|
147 |
+
}
|
148 |
+
} );
|
149 |
|
150 |
+
// extend AttachmentCompat
|
151 |
+
var RLAttachmentCompat = {
|
152 |
+
save: wp.media.view.AttachmentCompat.prototype.save,
|
153 |
+
postSave: wp.media.view.AttachmentCompat.prototype.postSave
|
154 |
+
};
|
155 |
|
156 |
+
$.extend( wp.media.view.AttachmentCompat.prototype, {
|
157 |
+
save: function( event ) {
|
158 |
+
if ( ! allow_modal_media_tag_saving ) {
|
159 |
+
// RLAttachmentCompat.save.apply( this, arguments );
|
160 |
+
// this.$el.closest( '.attachment-details' ).removeClass( 'save-ready' ).addClass( 'save-waiting' );
|
161 |
|
162 |
+
return;
|
163 |
+
}
|
|
|
|
|
164 |
|
165 |
+
var select = $( '.rl-media-tag-select2' ),
|
166 |
+
selected = select.select2( 'data' ),
|
167 |
+
tags = [],
|
168 |
+
data = {};
|
169 |
|
170 |
+
for ( i = 0; i < selected.length; i++ ) {
|
171 |
+
tags.push( selected[i].id );
|
172 |
+
}
|
173 |
|
174 |
+
if ( event )
|
175 |
+
event.preventDefault();
|
|
|
|
|
176 |
|
177 |
+
// get serialized data
|
178 |
+
_.each( this.$el.serializeArray(), function( pair ) {
|
179 |
+
data[ pair.name ] = pair.value;
|
180 |
+
} );
|
181 |
|
182 |
+
// update rl media tag
|
183 |
+
data[select.attr( 'name' )] = tags.join( ',' );
|
184 |
|
185 |
+
this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
|
186 |
+
this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
|
|
|
|
|
|
|
187 |
|
188 |
+
// display spinner
|
189 |
+
this.$el.closest( '.attachment-details' ).removeClass( 'save-ready' ).addClass( 'save-waiting' );
|
190 |
+
},
|
191 |
+
postSave: function() {
|
192 |
+
RLAttachmentCompat.postSave.apply( this, arguments );
|
193 |
|
194 |
+
// hide spinner
|
195 |
+
this.$el.closest( '.attachment-details' ).addClass( 'save-ready' ).removeClass( 'save-waiting' );
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
} );
|
|
|
198 |
|
|
|
|
|
199 |
// do nothing for wp_enqueue_media
|
200 |
if ( rlFoldersArgs.page === 'media' ) {
|
201 |
// folder change
|
219 |
|
220 |
// initialize draggable
|
221 |
draggable( 'list' );
|
222 |
+
// grid
|
223 |
} else {
|
224 |
// add tree
|
225 |
$( '#wp-media-grid .error' ).after( rlFoldersArgs.template );
|
js/admin-galleries.js
CHANGED
@@ -514,36 +514,28 @@
|
|
514 |
var atts = subel.attr( 'name' ).slice( 0, -1 ).split( '][' ),
|
515 |
new_value = {},
|
516 |
last;
|
517 |
-
console.log( atts );
|
518 |
|
519 |
for ( var i = atts.length - nofa; i <= atts.length; i++ ) {
|
520 |
-
console.log( 1 );
|
521 |
-
// console.log( nofa );
|
522 |
var number = i - 1;
|
523 |
-
|
524 |
// first element?
|
525 |
if ( i === atts.length ) {
|
526 |
-
console.log( 2.1 );
|
527 |
// new_value2 .= '[' + atts[number] + ']';
|
528 |
new_value = response.data.data[atts[number]];
|
529 |
} else {
|
530 |
-
console.log( 2.2 );
|
531 |
last = new_value[atts[number]];
|
532 |
}
|
533 |
-
|
534 |
// remember last array
|
535 |
new_value = last;
|
536 |
-
|
537 |
// do not reset for last element
|
538 |
// if ( number > atts.length - nofa )
|
539 |
// new_value = {};
|
540 |
}
|
541 |
|
542 |
-
console.log( 5 );
|
543 |
// get new array
|
544 |
value = new_value;
|
545 |
-
console.log( value );
|
546 |
-
console.log( 6 );
|
547 |
} else
|
548 |
subel.val( response.data.data );
|
549 |
break;
|
514 |
var atts = subel.attr( 'name' ).slice( 0, -1 ).split( '][' ),
|
515 |
new_value = {},
|
516 |
last;
|
|
|
517 |
|
518 |
for ( var i = atts.length - nofa; i <= atts.length; i++ ) {
|
|
|
|
|
519 |
var number = i - 1;
|
520 |
+
|
521 |
// first element?
|
522 |
if ( i === atts.length ) {
|
|
|
523 |
// new_value2 .= '[' + atts[number] + ']';
|
524 |
new_value = response.data.data[atts[number]];
|
525 |
} else {
|
|
|
526 |
last = new_value[atts[number]];
|
527 |
}
|
528 |
+
|
529 |
// remember last array
|
530 |
new_value = last;
|
531 |
+
|
532 |
// do not reset for last element
|
533 |
// if ( number > atts.length - nofa )
|
534 |
// new_value = {};
|
535 |
}
|
536 |
|
|
|
537 |
// get new array
|
538 |
value = new_value;
|
|
|
|
|
539 |
} else
|
540 |
subel.val( response.data.data );
|
541 |
break;
|
js/admin-media.js
CHANGED
@@ -1,336 +1,434 @@
|
|
1 |
( function ( $ ) {
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
17 |
}
|
18 |
}
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
}
|
33 |
-
}
|
34 |
-
};
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
45 |
}
|
46 |
}
|
47 |
-
}
|
48 |
-
|
49 |
-
this.filters = filters;
|
50 |
-
}
|
51 |
-
} );
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
createToolbar: function() {
|
57 |
-
// load the original toolbar
|
58 |
-
RLWPMediaViewAttachmentsBrowser.prototype.createToolbar.call( this );
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
-
}
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
RLWPMediaViewMediaFramePost =
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
if ( props.size === 'thumbnail' ) {
|
131 |
-
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.thumbnail_width;
|
132 |
-
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.thumbnail_height;
|
133 |
-
} else {
|
134 |
-
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.width;
|
135 |
-
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.height;
|
136 |
}
|
|
|
|
|
|
|
137 |
}
|
138 |
|
139 |
-
|
140 |
-
return RLWPMediaEditorSendAttachment( props, attachment );
|
141 |
-
}
|
142 |
|
143 |
-
|
|
|
|
|
|
|
|
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
// send attachment to editor action?
|
148 |
-
if ( action === 'send-attachment-to-editor' && RLWPMediaViewMediaFramePost.remoteLibraryImage === true ) {
|
149 |
-
var attachmentID = data.attachment.id;
|
150 |
|
151 |
-
|
152 |
-
|
153 |
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
|
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
data.attachment.height = RLWPMediaViewMediaFramePost.currentAttachment.height;
|
163 |
|
164 |
-
|
165 |
-
|
|
|
166 |
|
167 |
-
//
|
168 |
-
|
169 |
}
|
170 |
|
171 |
-
//
|
172 |
-
|
173 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
contentRender: function() {
|
179 |
-
// get view content
|
180 |
-
var view = this.content.get();
|
181 |
|
182 |
-
|
183 |
-
if ( view !== null && 'model' in view && view.model.id === 'rl-remote-library' ) {
|
184 |
-
var contentState = this.state(),
|
185 |
-
contentSelection = contentState.get( 'selection' );
|
186 |
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
spinner = view.toolbar.get( 'spinner' );
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
spinner.show();
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
this.selectionStatusToolbar( toolbar );
|
202 |
-
|
203 |
-
// add upload button
|
204 |
-
toolbar.set( 'rl-upload-insert', {
|
205 |
-
style: 'primary',
|
206 |
-
priority: 80,
|
207 |
-
text: rlRemoteLibraryMedia.uploadAndInsert,
|
208 |
-
requires: { selection: true },
|
209 |
-
click: function() {
|
210 |
-
var state = controller.state(),
|
211 |
-
selection = state.get( 'selection' ),
|
212 |
-
image = selection.single(),
|
213 |
-
content = controller.content.get(),
|
214 |
-
attachment = content.attachments.$el.find( 'li[data-id="' + image.attributes.id + '"] .thumbnail' ),
|
215 |
-
attachment_image = attachment.find( '.centered' );
|
216 |
-
|
217 |
-
attachment_image.css( { opacity: 0.1, transition: 'opacity 500ms' } );
|
218 |
-
attachment_image.after( '<div class="media-progress-bar"><div style="width: 20%"></div></div>' );
|
219 |
-
|
220 |
-
var progress = attachment.find( '.media-progress-bar div' ),
|
221 |
-
transition = progress.css( 'transition' );
|
222 |
-
|
223 |
-
progress.css( 'transition', 'width 10s' ).animate( { width: "100%" }, 0 );
|
224 |
-
|
225 |
-
$.post( ajaxurl, {
|
226 |
-
action: 'rl_upload_image',
|
227 |
-
image: image.attributes,
|
228 |
-
post_id: rlRemoteLibraryMedia.postID,
|
229 |
-
rlnonce: rlRemoteLibraryMedia.getUploadNonce
|
230 |
-
} ).done( function( response ) {
|
231 |
-
progress.css( 'transition', 'width 0.5s' ).animate( { width: "100%" }, 0, function() {
|
232 |
-
attachment_image.css( { opacity: 1, transition: '' } );
|
233 |
-
|
234 |
-
$( this ).css( 'transition', transition );
|
235 |
-
|
236 |
-
// update attachment data
|
237 |
-
selection.models[0].attributes.id = parseInt( response.id );
|
238 |
-
selection.models[0].attributes.url = response.full[0];
|
239 |
-
selection.models[0].attributes.sizes.full.url = response.full[0];
|
240 |
-
|
241 |
-
// remove progress bar
|
242 |
-
progress.remove();
|
243 |
-
|
244 |
-
// close modal
|
245 |
-
controller.close();
|
246 |
-
|
247 |
-
// trigger insert event
|
248 |
-
state.trigger( ( gutenberg_active ? 'select' : 'insert' ), selection ).reset();
|
249 |
-
} );
|
250 |
-
} ).always( function( data ) {
|
251 |
-
//
|
252 |
-
} );
|
253 |
-
}
|
254 |
-
} );
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
259 |
|
260 |
-
|
|
|
261 |
|
262 |
-
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
|
|
|
|
|
267 |
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
-
|
272 |
-
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
// any results?
|
277 |
-
if ( result.images.length ) {
|
278 |
-
// add images to library
|
279 |
-
model.attributes.library.push( result.images );
|
280 |
|
281 |
-
|
282 |
-
|
|
|
283 |
|
284 |
-
|
285 |
-
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
this.handleScroll();
|
290 |
-
}
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
301 |
-
}
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
}
|
|
|
|
|
|
|
316 |
|
317 |
-
|
318 |
-
|
|
|
|
|
319 |
|
320 |
-
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
content.toolbar.get( 'spinner' ).show();
|
326 |
|
327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
RLRemoteLibraryContentView.blockScrolling = true;
|
329 |
|
330 |
// display spinner
|
331 |
-
|
332 |
|
333 |
-
var promise = remoteQuery(
|
334 |
|
335 |
promise.then(
|
336 |
result => {
|
@@ -342,16 +440,17 @@
|
|
342 |
// increase page number
|
343 |
RLWPMediaModelAttachments.media_page++;
|
344 |
|
|
|
345 |
RLRemoteLibraryContentView.blockScrolling = false;
|
346 |
RLRemoteLibraryContentView.responseData = result.data;
|
347 |
|
348 |
// last page?
|
349 |
if ( result.last === false )
|
350 |
-
|
351 |
}
|
352 |
|
353 |
// hide spinner
|
354 |
-
|
355 |
},
|
356 |
error => {
|
357 |
RLRemoteLibraryContentView.blockScrolling = false;
|
@@ -359,129 +458,32 @@
|
|
359 |
}
|
360 |
);
|
361 |
}
|
362 |
-
}
|
363 |
-
} );
|
364 |
-
|
365 |
-
var RLWPMediaViewSettingsAttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;
|
366 |
-
|
367 |
-
wp.media.view.Settings.AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay.extend( {
|
368 |
-
render: function() {
|
369 |
-
// remove medium size
|
370 |
-
if ( typeof this.options.attachment.attributes.remote_library_image !== 'undefined' && this.options.attachment.attributes.remote_library_image )
|
371 |
-
delete this.options.attachment.attributes.sizes.medium;
|
372 |
-
|
373 |
-
// load the original render function
|
374 |
-
RLWPMediaViewSettingsAttachmentDisplay.prototype.render.call( this );
|
375 |
-
|
376 |
-
return this;
|
377 |
-
}
|
378 |
-
} );
|
379 |
-
|
380 |
-
var RLWPMediaModelAttachments = wp.media.model.Attachments;
|
381 |
-
|
382 |
-
// add new attributes
|
383 |
-
RLWPMediaModelAttachments.media_page = 1;
|
384 |
-
RLWPMediaModelAttachments.media_provider = 'all';
|
385 |
-
RLWPMediaModelAttachments.media_search = '';
|
386 |
-
|
387 |
-
// extend media frame
|
388 |
-
wp.media.model.Attachments = RLWPMediaModelAttachments.extend( {
|
389 |
-
initialize: function() {
|
390 |
-
// calling the initalize method from the current frame before adding new functionality
|
391 |
-
RLWPMediaModelAttachments.prototype.initialize.apply( this, arguments );
|
392 |
-
|
393 |
-
// events
|
394 |
-
this.props.on( 'change', this.handleFilters );
|
395 |
-
},
|
396 |
-
handleFilters: function() {
|
397 |
-
// clear current collection
|
398 |
-
RLRemoteLibraryCollection.attributes.library.reset();
|
399 |
-
|
400 |
-
// clear current selection
|
401 |
-
RLRemoteLibraryCollection.get( 'selection' ).reset();
|
402 |
-
|
403 |
-
// hide uploader view
|
404 |
-
RLRemoteLibraryContentView.$el.find( '.uploader-inline' ).addClass( 'hidden' );
|
405 |
-
|
406 |
-
// reset page to first
|
407 |
-
RLWPMediaModelAttachments.media_page = 1;
|
408 |
-
|
409 |
-
// clear response data
|
410 |
-
RLRemoteLibraryContentView.responseData = [];
|
411 |
-
|
412 |
-
// make sure media provider is set
|
413 |
-
if ( typeof this.attributes.media_provider === 'undefined' )
|
414 |
-
RLWPMediaModelAttachments.media_provider = this.attributes.media_provider = 'all';
|
415 |
-
else
|
416 |
-
RLWPMediaModelAttachments.media_provider = this.attributes.media_provider;
|
417 |
-
|
418 |
-
// make sure search phrase is set
|
419 |
-
if ( typeof this.attributes.search === 'undefined' )
|
420 |
-
RLWPMediaModelAttachments.media_search = this.attributes.search = '';
|
421 |
-
else
|
422 |
-
RLWPMediaModelAttachments.media_search = this.attributes.search;
|
423 |
-
|
424 |
-
// disable scroll event
|
425 |
-
RLRemoteLibraryContentView.blockScrolling = true;
|
426 |
-
|
427 |
-
// display spinner
|
428 |
-
RLRemoteLibraryContentView.toolbar.get( 'spinner' ).show();
|
429 |
-
|
430 |
-
var promise = remoteQuery( this.attributes.media_provider, this.attributes.search, RLWPMediaModelAttachments.media_page, RLRemoteLibraryContentView.responseData );
|
431 |
-
|
432 |
-
promise.then(
|
433 |
-
result => {
|
434 |
-
// any results?
|
435 |
-
if ( result.images.length ) {
|
436 |
-
// add images to library
|
437 |
-
RLRemoteLibraryCollection.attributes.library.push( result.images );
|
438 |
-
|
439 |
-
// increase page number
|
440 |
-
RLWPMediaModelAttachments.media_page++;
|
441 |
-
|
442 |
-
// allow scrolling
|
443 |
-
RLRemoteLibraryContentView.blockScrolling = false;
|
444 |
-
RLRemoteLibraryContentView.responseData = result.data;
|
445 |
-
|
446 |
-
// last page?
|
447 |
-
if ( result.last === false )
|
448 |
-
RLRemoteLibraryContentView.views.parent.handleScroll();
|
449 |
-
}
|
450 |
-
|
451 |
-
// hide spinner
|
452 |
-
RLRemoteLibraryContentView.toolbar.get( 'spinner' ).hide();
|
453 |
-
},
|
454 |
-
error => {
|
455 |
-
RLRemoteLibraryContentView.blockScrolling = false;
|
456 |
-
RLRemoteLibraryContentView.responseData = [];
|
457 |
-
}
|
458 |
-
);
|
459 |
-
}
|
460 |
-
} );
|
461 |
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
|
|
|
|
478 |
reject( [] );
|
479 |
-
|
480 |
-
reject( [] );
|
481 |
} );
|
482 |
-
} );
|
483 |
|
484 |
-
|
485 |
-
|
|
|
486 |
|
487 |
} )( jQuery );
|
1 |
( function ( $ ) {
|
2 |
|
3 |
+
$( document ).on( 'ready', function() {
|
4 |
+
var gutenberg_active = typeof rlBlockEditor !== 'undefined';
|
5 |
|
6 |
+
if ( gutenberg_active ) {
|
7 |
+
RLWPMediaViewMediaFramePostTrigger = wp.media.view.MediaFrame.Post.prototype.trigger;
|
8 |
|
9 |
+
// extend MediaFrame.Post
|
10 |
+
wp.media.view.MediaFrame.Post.prototype.trigger = function( action ) {
|
11 |
+
RLWPMediaViewMediaFramePostTrigger.apply( this, Array.prototype.slice.call( arguments ) );
|
12 |
|
13 |
+
if ( action === 'open' ) {
|
14 |
+
if ( $( this.modal.clickedOpenerEl ).hasClass( 'rl-remote-library-media-button' ) )
|
15 |
+
this.setState( 'rl-remote-library' );
|
16 |
+
else if ( $( this.modal.clickedOpenerEl ).hasClass( 'rl-gallery-media-button' ) )
|
17 |
+
this.setState( 'rl-gallery' );
|
18 |
+
}
|
19 |
}
|
20 |
}
|
21 |
+
|
22 |
+
// add new media folder filter
|
23 |
+
var RLWPMediaViewAttachmentFilters = wp.media.view.AttachmentFilters.extend( {
|
24 |
+
id: 'media-attachment-rl-remote-library-filters',
|
25 |
+
className: 'attachment-filters attachment-rl-remote-library-filter',
|
26 |
+
createFilters: function() {
|
27 |
+
var filters = {
|
28 |
+
all: {
|
29 |
+
text: rlRemoteLibraryMedia.allProviders,
|
30 |
+
priority: 1,
|
31 |
+
props: {
|
32 |
+
media_provider: 'all'
|
33 |
+
}
|
34 |
}
|
35 |
+
};
|
|
|
36 |
|
37 |
+
// add active providers
|
38 |
+
for ( var i = 0; i < rlRemoteLibraryMedia.providersActive.length; i++ ) {
|
39 |
+
var provider = rlRemoteLibraryMedia.providersActive[i];
|
40 |
|
41 |
+
filters[provider] = {
|
42 |
+
text: rlRemoteLibraryMedia.providers[provider].name,
|
43 |
+
priority: i + 2,
|
44 |
+
props: {
|
45 |
+
media_provider: provider
|
46 |
+
}
|
47 |
}
|
48 |
}
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
this.filters = filters;
|
51 |
+
}
|
52 |
+
} );
|
|
|
|
|
|
|
53 |
|
54 |
+
var RLWPMediaViewAttachmentsBrowser = wp.media.view.AttachmentsBrowser;
|
55 |
+
|
56 |
+
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend( {
|
57 |
+
createToolbar: function() {
|
58 |
+
// load the original toolbar
|
59 |
+
RLWPMediaViewAttachmentsBrowser.prototype.createToolbar.call( this );
|
60 |
+
|
61 |
+
if ( this.model.get( 'id' ) === 'rl-remote-library' ) {
|
62 |
+
this.toolbar.set( 'RLremoteLibraryFilterLabel', new wp.media.view.Label( {
|
63 |
+
value: rlRemoteLibraryMedia.filterByremoteLibrary,
|
64 |
+
attributes: {
|
65 |
+
'for': 'media-attachment-rl-remote-library-filters'
|
66 |
+
},
|
67 |
+
priority: -75
|
68 |
+
} ).render() );
|
69 |
+
|
70 |
+
this.toolbar.set( 'RLremoteLibraryAttachmentFilters', new RLWPMediaViewAttachmentFilters( {
|
71 |
+
controller: this.controller,
|
72 |
+
model: this.collection.props,
|
73 |
+
priority: -75
|
74 |
+
} ).render() );
|
75 |
+
}
|
76 |
}
|
77 |
+
} );
|
78 |
+
|
79 |
+
var RLRemoteLibraryCollection,
|
80 |
+
RLRemoteLibraryContentView,
|
81 |
+
RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post,
|
82 |
+
attachment_defaults = {
|
83 |
+
width: 0,
|
84 |
+
height: 0
|
85 |
+
};
|
86 |
|
87 |
+
// add new attributes
|
88 |
+
RLWPMediaViewMediaFramePost.currentAttachment = attachment_defaults;
|
89 |
+
RLWPMediaViewMediaFramePost.remoteLibraryImage = false;
|
90 |
+
RLWPMediaViewMediaFramePost.requestHash = '';
|
91 |
+
|
92 |
+
// extend media frame
|
93 |
+
wp.media.view.MediaFrame.Post = RLWPMediaViewMediaFramePost.extend( {
|
94 |
+
initialize: function() {
|
95 |
+
// calling the initalize method from the current frame before adding new functionality
|
96 |
+
RLWPMediaViewMediaFramePost.prototype.initialize.apply( this, arguments );
|
97 |
+
|
98 |
+
// adding new state for remote library image
|
99 |
+
this.states.add( [
|
100 |
+
new wp.media.controller.Library( {
|
101 |
+
id: 'rl-remote-library',
|
102 |
+
title: 'Remote Library',
|
103 |
+
priority: 99,
|
104 |
+
toolbar: gutenberg_active ? 'select' : 'main-insert',
|
105 |
+
multiple: false,
|
106 |
+
editable: true,
|
107 |
+
allowLocalEdits: true,
|
108 |
+
library: new wp.media.model.Attachments(),
|
109 |
+
displaySettings: true,
|
110 |
+
displayUserSettings: true,
|
111 |
+
filterable: true,
|
112 |
+
searchable: true,
|
113 |
+
content: 'browse',
|
114 |
+
router: false,
|
115 |
+
date: false,
|
116 |
+
sortable: false,
|
117 |
+
type: 'image',
|
118 |
+
dragInfo: false,
|
119 |
+
menu: gutenberg_active ? false : 'default'
|
120 |
+
} )
|
121 |
+
] );
|
122 |
+
|
123 |
+
var RLWPMediaEditorSendAttachment = wp.media.editor.send.attachment;
|
124 |
+
|
125 |
+
// replace send attachment
|
126 |
+
wp.media.editor.send.attachment = function( props, attachment ) {
|
127 |
+
// remote library simulated attachment?
|
128 |
+
if ( typeof attachment.remote_library_image !== 'undefined' && attachment.remote_library_image === true ) {
|
129 |
+
RLWPMediaViewMediaFramePost.remoteLibraryImage = true;
|
130 |
+
|
131 |
+
if ( props.size === 'thumbnail' ) {
|
132 |
+
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.thumbnail_width;
|
133 |
+
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.thumbnail_height;
|
134 |
+
} else {
|
135 |
+
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.width;
|
136 |
+
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.height;
|
137 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
+
|
140 |
+
// return original function
|
141 |
+
return RLWPMediaEditorSendAttachment( props, attachment );
|
142 |
}
|
143 |
|
144 |
+
var RLWPMediaPost = wp.media.post;
|
|
|
|
|
145 |
|
146 |
+
// replace ajax request
|
147 |
+
wp.media.post = function( action, data ) {
|
148 |
+
// send attachment to editor action?
|
149 |
+
if ( action === 'send-attachment-to-editor' && RLWPMediaViewMediaFramePost.remoteLibraryImage === true ) {
|
150 |
+
var attachmentID = data.attachment.id;
|
151 |
|
152 |
+
// replace pseudo ID with generated thumbnial ID
|
153 |
+
data.attachment.id = parseInt( rlRemoteLibraryMedia.thumbnailID );
|
|
|
|
|
|
|
154 |
|
155 |
+
// set pseudo ID too
|
156 |
+
data.attachment.att_id = attachmentID;
|
157 |
|
158 |
+
// select this image as remote library one
|
159 |
+
data.attachment.remote_library_image = true;
|
160 |
|
161 |
+
// set new dimensions
|
162 |
+
data.attachment.width = RLWPMediaViewMediaFramePost.currentAttachment.width;
|
163 |
+
data.attachment.height = RLWPMediaViewMediaFramePost.currentAttachment.height;
|
164 |
|
165 |
+
// back to defaults
|
166 |
+
RLWPMediaViewMediaFramePost.currentAttachment = attachment_defaults;
|
|
|
167 |
|
168 |
+
// restore defaulkt behavior
|
169 |
+
RLWPMediaViewMediaFramePost.remoteLibraryImage = false;
|
170 |
+
}
|
171 |
|
172 |
+
// return original function
|
173 |
+
return RLWPMediaPost( action, data );
|
174 |
}
|
175 |
|
176 |
+
// events
|
177 |
+
this.on( 'activate', this.activateContent, this );
|
178 |
+
},
|
179 |
+
activateContent: function() {
|
180 |
+
// get view content
|
181 |
+
var view = this.content.get();
|
182 |
+
|
183 |
+
// valid remote library view?
|
184 |
+
if ( view !== null && 'model' in view && view.model.id === 'rl-remote-library' ) {
|
185 |
+
var contentState = this.state(),
|
186 |
+
contentSelection = contentState.get( 'selection' );
|
187 |
+
|
188 |
+
// clear selection
|
189 |
+
contentSelection.reset();
|
190 |
+
|
191 |
+
var toolbar = this.toolbar.get(),
|
192 |
+
controller = this,
|
193 |
+
spinner = view.toolbar.get( 'spinner' );
|
194 |
+
|
195 |
+
// display spinner
|
196 |
+
spinner.$el.css( 'marginLeft', '6px' );
|
197 |
+
spinner.show();
|
198 |
+
|
199 |
+
// hide uploader view
|
200 |
+
view.$el.find( '.uploader-inline' ).addClass( 'hidden' );
|
201 |
+
|
202 |
+
this.selectionStatusToolbar( toolbar );
|
203 |
+
|
204 |
+
// add upload button
|
205 |
+
toolbar.set( 'rl-upload-insert', {
|
206 |
+
style: 'primary',
|
207 |
+
priority: 20,
|
208 |
+
text: gutenberg_active ? rlRemoteLibraryMedia.uploadAndSelect : rlRemoteLibraryMedia.uploadAndInsert,
|
209 |
+
requires: { selection: true },
|
210 |
+
click: function() {
|
211 |
+
var state = controller.state(),
|
212 |
+
selection = state.get( 'selection' ),
|
213 |
+
image = selection.single(),
|
214 |
+
content = controller.content.get(),
|
215 |
+
attachment = content.attachments.$el.find( 'li[data-id="' + image.attributes.id + '"] .thumbnail' ),
|
216 |
+
attachment_image = attachment.find( '.centered' );
|
217 |
+
|
218 |
+
attachment_image.css( { opacity: 0.1, transition: 'opacity 500ms' } );
|
219 |
+
attachment_image.after( '<div class="media-progress-bar"><div style="width: 20%"></div></div>' );
|
220 |
+
|
221 |
+
var progress = attachment.find( '.media-progress-bar div' ),
|
222 |
+
transition = progress.css( 'transition' );
|
223 |
+
|
224 |
+
progress.css( 'transition', 'width 10s' ).animate( { width: "100%" }, 0 );
|
225 |
+
|
226 |
+
$.post( ajaxurl, {
|
227 |
+
action: 'rl_upload_image',
|
228 |
+
image: image.attributes,
|
229 |
+
post_id: rlRemoteLibraryMedia.postID,
|
230 |
+
rlnonce: rlRemoteLibraryMedia.getUploadNonce
|
231 |
+
} ).done( function( response ) {
|
232 |
+
progress.css( 'transition', 'width 0.5s' ).animate( { width: "100%" }, 0, function() {
|
233 |
+
attachment_image.css( { opacity: 1, transition: '' } );
|
234 |
+
|
235 |
+
$( this ).css( 'transition', transition );
|
236 |
+
|
237 |
+
// update attachment data
|
238 |
+
selection.models[0].attributes.id = parseInt( response.id );
|
239 |
+
selection.models[0].attributes.url = response.full[0];
|
240 |
+
selection.models[0].attributes.sizes.full.url = response.full[0];
|
241 |
+
|
242 |
+
// remove progress bar
|
243 |
+
progress.remove();
|
244 |
+
|
245 |
+
// close modal
|
246 |
+
controller.close();
|
247 |
+
|
248 |
+
// trigger insert event
|
249 |
+
state.trigger( ( gutenberg_active ? 'select' : 'insert' ), selection ).reset();
|
250 |
+
} );
|
251 |
+
} ).always( function( data ) {
|
252 |
+
//
|
253 |
+
} );
|
254 |
+
}
|
255 |
+
} );
|
256 |
|
257 |
+
RLRemoteLibraryContentView = view;
|
258 |
+
RLRemoteLibraryContentView.blockScrolling = false;
|
259 |
+
RLRemoteLibraryContentView.responseData = [];
|
|
|
|
|
|
|
260 |
|
261 |
+
var model = view.model.collection.get( 'rl-remote-library' );
|
|
|
|
|
|
|
262 |
|
263 |
+
// set scroll event
|
264 |
+
this.handleScroll = _.chain( this.handleScroll ).bind( view ).throttle( wp.media.isTouchDevice ? 300 : 200 ).value();
|
265 |
|
266 |
+
// bind scroll event
|
267 |
+
view.attachments.$el.on( 'scroll', this.handleScroll );
|
|
|
268 |
|
269 |
+
// assign model
|
270 |
+
RLRemoteLibraryCollection = model;
|
|
|
271 |
|
272 |
+
// run ajax calls for all providers
|
273 |
+
var promise = remoteQuery( 'all', '', 1, [] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
+
promise.then(
|
276 |
+
result => {
|
277 |
+
// any results?
|
278 |
+
if ( result.images.length ) {
|
279 |
+
// add images to library
|
280 |
+
model.attributes.library.push( result.images );
|
281 |
|
282 |
+
// increase page number
|
283 |
+
RLWPMediaModelAttachments.media_page++;
|
284 |
|
285 |
+
RLRemoteLibraryContentView.blockScrolling = false;
|
286 |
+
RLRemoteLibraryContentView.responseData = result.data;
|
287 |
|
288 |
+
// last page?
|
289 |
+
if ( result.last === false )
|
290 |
+
this.handleScroll();
|
291 |
+
}
|
292 |
|
293 |
+
// hide spinner
|
294 |
+
view.toolbar.get( 'spinner' ).hide();
|
295 |
+
},
|
296 |
+
error => {
|
297 |
+
RLRemoteLibraryContentView.blockScrolling = false;
|
298 |
+
RLRemoteLibraryContentView.responseData = [];
|
299 |
+
}
|
300 |
+
);
|
301 |
+
}
|
302 |
+
},
|
303 |
+
handleScroll: function() {
|
304 |
+
// is another scrolling pending?
|
305 |
+
if ( RLRemoteLibraryContentView.blockScrolling )
|
306 |
+
return;
|
307 |
+
|
308 |
+
var view = this.views.parent,
|
309 |
+
el = this.attachments.el,
|
310 |
+
scrollTop = el.scrollTop;
|
311 |
+
|
312 |
+
// the scroll event occurs on the document, but the element that should be checked is the document body
|
313 |
+
if ( el === document ) {
|
314 |
+
el = document.body;
|
315 |
+
scrollTop = $( document ).scrollTop();
|
316 |
+
}
|
317 |
|
318 |
+
if ( ! $( el ).is( ':visible' ) )
|
319 |
+
return;
|
320 |
|
321 |
+
// get content view
|
322 |
+
var content = view.content.get();
|
|
|
|
|
|
|
|
|
323 |
|
324 |
+
// show the spinner only if we are close to the bottom.
|
325 |
+
if ( el.scrollHeight - ( scrollTop + el.clientHeight ) < el.clientHeight / 3 )
|
326 |
+
content.toolbar.get( 'spinner' ).show();
|
327 |
|
328 |
+
if ( el.scrollHeight < scrollTop + ( el.clientHeight * 3 ) ) {
|
329 |
+
RLRemoteLibraryContentView.blockScrolling = true;
|
330 |
|
331 |
+
// display spinner
|
332 |
+
content.toolbar.get( 'spinner' ).show();
|
|
|
|
|
333 |
|
334 |
+
var promise = remoteQuery( RLWPMediaModelAttachments.media_provider, RLWPMediaModelAttachments.media_search, RLWPMediaModelAttachments.media_page, RLRemoteLibraryContentView.responseData );
|
335 |
+
|
336 |
+
promise.then(
|
337 |
+
result => {
|
338 |
+
// any results?
|
339 |
+
if ( result.images.length ) {
|
340 |
+
// add images to library
|
341 |
+
RLRemoteLibraryCollection.attributes.library.push( result.images );
|
342 |
+
|
343 |
+
// increase page number
|
344 |
+
RLWPMediaModelAttachments.media_page++;
|
345 |
+
|
346 |
+
RLRemoteLibraryContentView.blockScrolling = false;
|
347 |
+
RLRemoteLibraryContentView.responseData = result.data;
|
348 |
+
|
349 |
+
// last page?
|
350 |
+
if ( result.last === false )
|
351 |
+
view.handleScroll( result.data );
|
352 |
+
}
|
353 |
+
|
354 |
+
// hide spinner
|
355 |
+
content.toolbar.get( 'spinner' ).hide();
|
356 |
+
},
|
357 |
+
error => {
|
358 |
+
RLRemoteLibraryContentView.blockScrolling = false;
|
359 |
+
RLRemoteLibraryContentView.responseData = [];
|
360 |
+
}
|
361 |
+
);
|
362 |
+
}
|
363 |
}
|
364 |
+
} );
|
365 |
+
|
366 |
+
var RLWPMediaViewSettingsAttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;
|
367 |
+
|
368 |
+
wp.media.view.Settings.AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay.extend( {
|
369 |
+
render: function() {
|
370 |
+
// remove medium size
|
371 |
+
if ( typeof this.options.attachment.attributes.remote_library_image !== 'undefined' && this.options.attachment.attributes.remote_library_image )
|
372 |
+
delete this.options.attachment.attributes.sizes.medium;
|
373 |
+
|
374 |
+
// load the original render function
|
375 |
+
RLWPMediaViewSettingsAttachmentDisplay.prototype.render.call( this );
|
376 |
+
|
377 |
+
return this;
|
378 |
}
|
379 |
+
} );
|
380 |
+
|
381 |
+
var RLWPMediaModelAttachments = wp.media.model.Attachments;
|
382 |
|
383 |
+
// add new attributes
|
384 |
+
RLWPMediaModelAttachments.media_page = 1;
|
385 |
+
RLWPMediaModelAttachments.media_provider = 'all';
|
386 |
+
RLWPMediaModelAttachments.media_search = '';
|
387 |
|
388 |
+
// extend media frame
|
389 |
+
wp.media.model.Attachments = RLWPMediaModelAttachments.extend( {
|
390 |
+
initialize: function() {
|
391 |
+
// calling the initalize method from the current frame before adding new functionality
|
392 |
+
RLWPMediaModelAttachments.prototype.initialize.apply( this, arguments );
|
393 |
+
|
394 |
+
// events
|
395 |
+
this.props.on( 'change', this.handleFilters );
|
396 |
+
},
|
397 |
+
handleFilters: function() {
|
398 |
+
// clear current collection
|
399 |
+
RLRemoteLibraryCollection.attributes.library.reset();
|
400 |
+
|
401 |
+
// clear current selection
|
402 |
+
RLRemoteLibraryCollection.get( 'selection' ).reset();
|
403 |
+
|
404 |
+
// hide uploader view
|
405 |
+
RLRemoteLibraryContentView.$el.find( '.uploader-inline' ).addClass( 'hidden' );
|
406 |
|
407 |
+
// reset page to first
|
408 |
+
RLWPMediaModelAttachments.media_page = 1;
|
|
|
409 |
|
410 |
+
// clear response data
|
411 |
+
RLRemoteLibraryContentView.responseData = [];
|
412 |
+
|
413 |
+
// make sure media provider is set
|
414 |
+
if ( typeof this.attributes.media_provider === 'undefined' )
|
415 |
+
RLWPMediaModelAttachments.media_provider = this.attributes.media_provider = 'all';
|
416 |
+
else
|
417 |
+
RLWPMediaModelAttachments.media_provider = this.attributes.media_provider;
|
418 |
+
|
419 |
+
// make sure search phrase is set
|
420 |
+
if ( typeof this.attributes.search === 'undefined' )
|
421 |
+
RLWPMediaModelAttachments.media_search = this.attributes.search = '';
|
422 |
+
else
|
423 |
+
RLWPMediaModelAttachments.media_search = this.attributes.search;
|
424 |
+
|
425 |
+
// disable scroll event
|
426 |
RLRemoteLibraryContentView.blockScrolling = true;
|
427 |
|
428 |
// display spinner
|
429 |
+
RLRemoteLibraryContentView.toolbar.get( 'spinner' ).show();
|
430 |
|
431 |
+
var promise = remoteQuery( this.attributes.media_provider, this.attributes.search, RLWPMediaModelAttachments.media_page, RLRemoteLibraryContentView.responseData );
|
432 |
|
433 |
promise.then(
|
434 |
result => {
|
440 |
// increase page number
|
441 |
RLWPMediaModelAttachments.media_page++;
|
442 |
|
443 |
+
// allow scrolling
|
444 |
RLRemoteLibraryContentView.blockScrolling = false;
|
445 |
RLRemoteLibraryContentView.responseData = result.data;
|
446 |
|
447 |
// last page?
|
448 |
if ( result.last === false )
|
449 |
+
RLRemoteLibraryContentView.views.parent.handleScroll();
|
450 |
}
|
451 |
|
452 |
// hide spinner
|
453 |
+
RLRemoteLibraryContentView.toolbar.get( 'spinner' ).hide();
|
454 |
},
|
455 |
error => {
|
456 |
RLRemoteLibraryContentView.blockScrolling = false;
|
458 |
}
|
459 |
);
|
460 |
}
|
461 |
+
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
|
463 |
+
function remoteQuery( provider, phrase, page, response_data ) {
|
464 |
+
var promise = new Promise( ( resolve, reject ) => {
|
465 |
+
// set current request phrase
|
466 |
+
RLWPMediaViewMediaFramePost.requestHash = 'provider:' + provider + '|phrase:' + phrase;
|
467 |
+
|
468 |
+
$.post( ajaxurl, {
|
469 |
+
action: 'rl_remote_library_query',
|
470 |
+
media_provider: provider,
|
471 |
+
media_search: phrase,
|
472 |
+
media_page: page,
|
473 |
+
response_data: response_data
|
474 |
+
} ).done( function( response ) {
|
475 |
+
// valid request hash?
|
476 |
+
if ( RLWPMediaViewMediaFramePost.requestHash === 'provider:' + provider + '|phrase:' + phrase )
|
477 |
+
resolve( response );
|
478 |
+
else
|
479 |
+
reject( [] );
|
480 |
+
} ).fail( function() {
|
481 |
reject( [] );
|
482 |
+
} );
|
|
|
483 |
} );
|
|
|
484 |
|
485 |
+
return promise;
|
486 |
+
}
|
487 |
+
} );
|
488 |
|
489 |
} )( jQuery );
|
library/simplehtmldom/simple_html_dom.php
CHANGED
@@ -634,7 +634,9 @@ class simple_html_dom_node
|
|
634 |
// Check if ID matches
|
635 |
if ($pass && $id !== '' && isset($node->attr['id'])) {
|
636 |
// Note: Only consider the first ID (as browsers do)
|
637 |
-
$node_id = explode(' ', trim($node->attr['id']))[0];
|
|
|
|
|
638 |
|
639 |
if($id !== $node_id) { $pass = false; }
|
640 |
}
|
634 |
// Check if ID matches
|
635 |
if ($pass && $id !== '' && isset($node->attr['id'])) {
|
636 |
// Note: Only consider the first ID (as browsers do)
|
637 |
+
// $node_id = explode(' ', trim($node->attr['id']))[0];
|
638 |
+
$node_id = explode(' ', trim($node->attr['id']));
|
639 |
+
$node_id = $node_id[0];
|
640 |
|
641 |
if($id !== $node_id) { $pass = false; }
|
642 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.dfactory.eu/
|
|
4 |
Tags: responsive gallery plugin, lightbox, photo gallery, masonry, video gallery, gallery builder, image gallery
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 5.3
|
7 |
-
Stable tag: 2.2.
|
8 |
Requires PHP: 5.2.4
|
9 |
License: MIT License
|
10 |
License URI: http://opensource.org/licenses/MIT
|
@@ -27,7 +27,7 @@ Say goodbye to coding. With the built-in drag and drop Gallery builder, you will
|
|
27 |
|
28 |
= Vast Customization Options =
|
29 |
|
30 |
-
Responsive Lightbox and Gallery plugin is packed with customization options per each gallery and lightbox style so you can tweak them to suit your website
|
31 |
|
32 |
= SEO-Friendly and Lightweight =
|
33 |
|
@@ -116,15 +116,15 @@ Many users love to have different ways to customize their galleries. This bundle
|
|
116 |
|
117 |
= Will this plugin slow down my site? =
|
118 |
|
119 |
-
Responsive Lightbox and Gallery plugin is a lightweight WordPress gallery plugin built with performance and speed in mind. This means your page load time won
|
120 |
|
121 |
= How can I get the most of this plugin? =
|
122 |
|
123 |
-
Responsive Lightbox and Gallery plugin comes with plenty of documentation to guide you while creating and customizing your galleries. On top of that, you
|
124 |
|
125 |
= I need a specific style, layout or effect for my galleries. What should I do? =
|
126 |
|
127 |
-
Responsive Lightbox and Gallery plugin comes with many styles and effects already in it
|
128 |
|
129 |
== Installation ==
|
130 |
|
@@ -139,6 +139,12 @@ Responsive Lightbox and Gallery plugin comes with many styles and effects alread
|
|
139 |
|
140 |
== Changelog ==
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
= 2.2.1 =
|
143 |
* Fix: Invalid arguments passed in class-folders.php
|
144 |
|
@@ -434,5 +440,5 @@ Initial release
|
|
434 |
|
435 |
== Upgrade Notice ==
|
436 |
|
437 |
-
= 2.2.
|
438 |
-
* Fix:
|
4 |
Tags: responsive gallery plugin, lightbox, photo gallery, masonry, video gallery, gallery builder, image gallery
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 5.3
|
7 |
+
Stable tag: 2.2.2
|
8 |
Requires PHP: 5.2.4
|
9 |
License: MIT License
|
10 |
License URI: http://opensource.org/licenses/MIT
|
27 |
|
28 |
= Vast Customization Options =
|
29 |
|
30 |
+
Responsive Lightbox and Gallery plugin is packed with customization options per each gallery and lightbox style so you can tweak them to suit your website's audience with just a few clicks.
|
31 |
|
32 |
= SEO-Friendly and Lightweight =
|
33 |
|
116 |
|
117 |
= Will this plugin slow down my site? =
|
118 |
|
119 |
+
Responsive Lightbox and Gallery plugin is a lightweight WordPress gallery plugin built with performance and speed in mind. This means your page load time won't be affected.
|
120 |
|
121 |
= How can I get the most of this plugin? =
|
122 |
|
123 |
+
Responsive Lightbox and Gallery plugin comes with plenty of documentation to guide you while creating and customizing your galleries. On top of that, you'll find plenty of articles on how to add the lightbox effect, how to use the gallery builder, and much more! Need to fix a specific issue? Share it on our forum and get the answer you need!
|
124 |
|
125 |
= I need a specific style, layout or effect for my galleries. What should I do? =
|
126 |
|
127 |
+
Responsive Lightbox and Gallery plugin comes with many styles and effects already in it's free version and can be enhanced with 10+ premium extensions like Masonry Gallery Pro, Hidden Gallery, Slider Gallery, and many more. <a href="https://dfactory.eu/products/responsive-lightbox-gallery-extensions/?utm_source=repo&utm_medium=link&utm_campaign=responsive-lightbox-plugin-free">Check them all out here</a> and pick your preferred one!
|
128 |
|
129 |
== Installation ==
|
130 |
|
139 |
|
140 |
== Changelog ==
|
141 |
|
142 |
+
= 2.2.2 =
|
143 |
+
* Fix: Add Media button not working for custom post types
|
144 |
+
* Fix: Underscore.js dependency missing
|
145 |
+
* Fix: Undefined variable: current_color_scheme
|
146 |
+
* Fix: Root Folder missing in media upload dropdown
|
147 |
+
|
148 |
= 2.2.1 =
|
149 |
* Fix: Invalid arguments passed in class-folders.php
|
150 |
|
440 |
|
441 |
== Upgrade Notice ==
|
442 |
|
443 |
+
= 2.2.2 =
|
444 |
+
* Fix: Multiple bug fixes release
|
responsive-lightbox.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Responsive Lightbox & Gallery
|
4 |
Description: Responsive Lightbox & Gallery allows users to create galleries and view larger versions of images, galleries and videos in a lightbox (overlay) effect optimized for mobile devices.
|
5 |
-
Version: 2.2.
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
|
@@ -43,7 +43,7 @@ include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'fun
|
|
43 |
* Responsive Lightbox class.
|
44 |
*
|
45 |
* @class Responsive_Lightbox
|
46 |
-
* @version 2.2.
|
47 |
*/
|
48 |
class Responsive_Lightbox {
|
49 |
|
@@ -264,7 +264,7 @@ class Responsive_Lightbox {
|
|
264 |
'origin_left' => true,
|
265 |
'origin_top' => true
|
266 |
),
|
267 |
-
'version' => '2.2.
|
268 |
'activation_date' => ''
|
269 |
);
|
270 |
public $options = array();
|
@@ -1058,7 +1058,7 @@ class Responsive_Lightbox {
|
|
1058 |
|
1059 |
wp_enqueue_script( 'responsive-lightbox-admin-select2', RESPONSIVE_LIGHTBOX_URL . '/assets/select2/select2.full' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array( 'jquery' ), $this->defaults['version'] );
|
1060 |
|
1061 |
-
wp_enqueue_script( 'responsive-lightbox-admin-galleries', RESPONSIVE_LIGHTBOX_URL . '/js/admin-galleries.js', array( 'jquery', 'wp-color-picker' ), $this->defaults['version'] );
|
1062 |
|
1063 |
wp_localize_script(
|
1064 |
'responsive-lightbox-admin-galleries',
|
@@ -1157,7 +1157,7 @@ class Responsive_Lightbox {
|
|
1157 |
public function sidebar_admin_setup() {
|
1158 |
wp_enqueue_media();
|
1159 |
|
1160 |
-
wp_enqueue_script( 'responsive-lightbox-admin-widgets', RESPONSIVE_LIGHTBOX_URL . '/js/admin-widgets.js', array( 'jquery' ), $this->defaults['version'] );
|
1161 |
|
1162 |
wp_localize_script(
|
1163 |
'responsive-lightbox-admin-widgets',
|
2 |
/*
|
3 |
Plugin Name: Responsive Lightbox & Gallery
|
4 |
Description: Responsive Lightbox & Gallery allows users to create galleries and view larger versions of images, galleries and videos in a lightbox (overlay) effect optimized for mobile devices.
|
5 |
+
Version: 2.2.2
|
6 |
Author: dFactory
|
7 |
Author URI: http://www.dfactory.eu/
|
8 |
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
|
43 |
* Responsive Lightbox class.
|
44 |
*
|
45 |
* @class Responsive_Lightbox
|
46 |
+
* @version 2.2.2
|
47 |
*/
|
48 |
class Responsive_Lightbox {
|
49 |
|
264 |
'origin_left' => true,
|
265 |
'origin_top' => true
|
266 |
),
|
267 |
+
'version' => '2.2.2',
|
268 |
'activation_date' => ''
|
269 |
);
|
270 |
public $options = array();
|
1058 |
|
1059 |
wp_enqueue_script( 'responsive-lightbox-admin-select2', RESPONSIVE_LIGHTBOX_URL . '/assets/select2/select2.full' . ( ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.min' : '' ) . '.js', array( 'jquery' ), $this->defaults['version'] );
|
1060 |
|
1061 |
+
wp_enqueue_script( 'responsive-lightbox-admin-galleries', RESPONSIVE_LIGHTBOX_URL . '/js/admin-galleries.js', array( 'jquery', 'underscore', 'wp-color-picker' ), $this->defaults['version'] );
|
1062 |
|
1063 |
wp_localize_script(
|
1064 |
'responsive-lightbox-admin-galleries',
|
1157 |
public function sidebar_admin_setup() {
|
1158 |
wp_enqueue_media();
|
1159 |
|
1160 |
+
wp_enqueue_script( 'responsive-lightbox-admin-widgets', RESPONSIVE_LIGHTBOX_URL . '/js/admin-widgets.js', array( 'jquery', 'underscore' ), $this->defaults['version'] );
|
1161 |
|
1162 |
wp_localize_script(
|
1163 |
'responsive-lightbox-admin-widgets',
|