PluginProbe
Assistant – Every Day Productivity Apps / 1.2.0
Assistant – Every Day Productivity Apps v1.2.0
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
← All changes | backend/src/Controllers/Cloud/Libraries/LibraryItemPostController.php +22 -17 0.7.11.2.0 View file →
@@ -73,13 +73,13 @@
73 73 [
74 74 'methods' => \WP_REST_Server::CREATABLE,
75 75 'callback' => [ $this, 'sync_to_library' ],
76 76 'args' => [
77 - 'id' => [
77 + 'id' => [
78 78 'required' => true,
79 79 'type' => 'number',
80 80 ],
81 - 'item_id' => [
81 + 'item_id' => [
82 82 'required' => true,
83 83 'type' => 'number',
84 84 ],
85 85 ],
@@ -109,9 +109,9 @@
109 109 [
110 110 'methods' => \WP_REST_Server::CREATABLE,
111 111 'callback' => [ $this, 'import_post_thumb_from_library' ],
112 112 'args' => [
113 - 'post_id' => [
113 + 'post_id' => [
114 114 'required' => true,
115 115 'type' => 'number',
116 116 ],
117 117 ],
@@ -128,9 +128,9 @@
128 128 [
129 129 'methods' => \WP_REST_Server::CREATABLE,
130 130 'callback' => [ $this, 'import_post_media_from_library' ],
131 131 'args' => [
132 - 'post_id' => [
132 + 'post_id' => [
133 133 'required' => true,
134 134 'type' => 'number',
135 135 ],
136 136 ],
@@ -147,9 +147,9 @@
147 147 [
148 148 'methods' => \WP_REST_Server::CREATABLE,
149 149 'callback' => [ $this, 'sync_from_library' ],
150 150 'args' => [
151 - 'id' => [
151 + 'id' => [
152 152 'required' => true,
153 153 'type' => 'number',
154 154 ],
155 155 ],
@@ -284,12 +284,13 @@
284 284 $id = $request->get_param( 'id' );
285 285 $item_id = $request->get_param( 'item_id' );
286 286 $post = get_post( $id );
287 287 $client = new CloudClient;
288 + $data = $this->get_save_data( $request, $post );
288 289
289 290 return $client->libraries->update_item(
290 291 $item_id,
291 - $this->get_save_data( $request, $post )
292 + $data
292 293 );
293 294 }
294 295
295 296 /**
@@ -337,9 +338,9 @@
337 338 }
338 339
339 340 $this->import_post_meta_from_library( $new_post_id, $item->data->meta );
340 341 $this->import_post_terms_from_library( $new_post_id, $item->data->terms );
341 - $this->regenerate_builder_cache( $item );
342 + $this->regenerate_builder_cache( $new_post_id, $item );
342 343
343 344 return rest_ensure_response(
344 345 $this->posts->transform(
345 346 get_post( $new_post_id )
@@ -382,9 +383,9 @@
382 383 }
383 384
384 385 $this->import_post_meta_from_library( $post_id, $item->data->meta );
385 386 $this->import_post_terms_from_library( $post_id, $item->data->terms );
386 - $this->regenerate_builder_cache( $item );
387 + $this->regenerate_builder_cache( $post_id, $item );
387 388
388 389 return rest_ensure_response(
389 390 $this->posts->transform(
390 391 get_post( $post_id )
@@ -409,14 +410,15 @@
409 410 foreach ( $meta as $meta_key => $meta_value ) {
410 411 if ( metadata_exists( 'post', $post_id, $meta_key ) ) {
411 412 delete_metadata( 'post', $post_id, $meta_key );
412 413 }
413 -
414 - foreach ( $meta_value as $value ) {
415 - $value = addslashes( $value );
416 - // @codingStandardsIgnoreStart
417 - $wpdb->query( "INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value) values ({$post_id}, '{$meta_key}', '{$value}')" );
418 - // @codingStandardsIgnoreEnd
414 + if ( is_array( $meta_value ) && count( $meta_value ) !== 0 ) {
415 + foreach ( $meta_value as $value ) {
416 + $value = addslashes( $value );
417 + // @codingStandardsIgnoreStart
418 + $wpdb->query( "INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value) values ({$post_id}, '{$meta_key}', '{$value}')" );
419 + // @codingStandardsIgnoreEnd
420 + }
419 421 }
420 422 }
421 423 }
422 424
@@ -439,9 +441,9 @@
439 441
440 442 foreach ( $terms as $term ) {
441 443 if ( ! isset( $term->name ) || ! isset( $term->taxonomy ) ) {
442 444 continue;
443 - } else if ( ! taxonomy_exists( $term->taxonomy ) ) {
445 + } elseif ( ! taxonomy_exists( $term->taxonomy ) ) {
444 446 continue;
445 447 } elseif ( ! isset( $taxonomy_terms ) ) {
446 448 $taxonomy_terms[ $term->taxonomy ] = [];
447 449 }
@@ -462,9 +464,9 @@
462 464 );
463 465 $term_id = $is_hierarchical ? $new_term['term_taxonomy_id'] : $term->name;
464 466 }
465 467
466 - $taxonomy_terms[ $term->taxonomy ] = $term_id;
468 + $taxonomy_terms[ $term->taxonomy ][] = $term_id;
467 469 }
468 470
469 471 foreach ( $taxonomy_terms as $taxonomy => $terms ) {
470 472 wp_delete_object_term_relationships( $post_id, $taxonomy );
@@ -638,11 +640,14 @@
638 640 *
639 641 * @param object $item
640 642 * @return void
641 643 */
642 - public function regenerate_builder_cache( $item ) {
644 + public function regenerate_builder_cache( $post_id, $item ) {
643 645 $meta = (array) $item->data->meta;
644 646
647 + if ( isset( $meta['_fl_builder_data'] ) && class_exists( 'FLBuilderModel' ) ) {
648 + \FLBuilderModel::delete_all_asset_cache( $post_id );
649 + }
645 650 if ( isset( $meta['_elementor_data'] ) && class_exists( 'Elementor\Plugin' ) ) {
646 651 \Elementor\Plugin::$instance->files_manager->clear_cache();
647 652 }
648 653 }