Changeset 3407121
- Timestamp:
- 12/01/2025 05:53:02 PM (3 months ago)
- Location:
- shutterpress-migrate
- Files:
-
- 4 added
- 12 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from shutterpress-migrate/trunk)
-
tags/1.1.0/README.txt (modified) (5 diffs)
-
tags/1.1.0/shutterpress-migrate.php (modified) (2 diffs)
-
tags/1.1.0/src/Admin/Shutterpress_Migrate_Admin_Page.php (modified) (5 diffs)
-
tags/1.1.0/src/Import/Shutterpress_Migrate_Import.php (modified) (9 diffs)
-
tags/1.1.0/src/Plugins/Gt3_Elementor.php (added)
-
tags/1.1.0/src/Plugins/Gt3_Post_Type.php (added)
-
tags/1.1.0/src/Shutterpress_Migrate_REST.php (modified) (1 diff)
-
tags/1.1.0/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/README.txt (modified) (5 diffs)
-
trunk/shutterpress-migrate.php (modified) (2 diffs)
-
trunk/src/Admin/Shutterpress_Migrate_Admin_Page.php (modified) (5 diffs)
-
trunk/src/Import/Shutterpress_Migrate_Import.php (modified) (9 diffs)
-
trunk/src/Plugins/Gt3_Elementor.php (added)
-
trunk/src/Plugins/Gt3_Post_Type.php (added)
-
trunk/src/Shutterpress_Migrate_REST.php (modified) (1 diff)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shutterpress-migrate/tags/1.1.0/README.txt
r3401472 r3407121 4 4 Tags: gallery, migrate, envira, nextgen, foogallery 5 5 Requires at least: 6.3 6 Tested up to: 6. 86 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1. 0.38 Stable tag: 1.1.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 12 Migrate galleries from NextGEN, Envira, FooGallery and Modulato ShutterPress Gallery. Keep images, titles and featured photos with just one click.12 Migrate galleries from NextGEN, Envira, FooGallery, Modula and GT3 to ShutterPress Gallery. Keep images, titles and featured photos with just one click. 13 13 14 14 == Description == 15 15 16 16 ShutterPress Migrate makes switching to ShutterPress Gallery fast and frustration-free. It scans your existing galleries, recreates them inside ShutterPress with proper attachments and metadata, and moves or copies back all your images into the WordPress media library. Perfect for photographers upgrading to a modern gallery system. 17 18 If you would like to import from a different gallery plugin, please contact us and we'll see if we can add support. 17 19 18 20 **About ShutterPress Gallery** … … 26 28 - FooGallery 27 29 - Modula Gallery 30 - GT3 Photo Gallery - Galleries and Elementor Widgets 28 31 29 32 **What gets imported** … … 50 53 2. Activate the plugin. 51 54 3. Go to ShutterPress Gallery, Import. 52 4. Click Scan, select the galleries you want to import. 53 5. Choose file handling, copy or move, select the target status, then click Import. 55 4. Choose file handling, copy or move, select the target status, then click Import. 54 56 55 57 == Frequently Asked Questions == … … 57 59 = What Plugins can i migrate from? = 58 60 59 NextGen Gallery, Envira Gallery, FooGallery and ModulaGallery.61 NextGen Gallery, Envira Gallery, FooGallery, Modula and GT3 Gallery. 60 62 61 63 = What is ShutterPress Gallery? = … … 71 73 72 74 == Changelog == 75 76 = 1.1.0 = 77 78 * New - Added support for GT3 Photo Gallery - Galleries and Elementor Widgets 73 79 74 80 = 1.0.3 = -
shutterpress-migrate/tags/1.1.0/shutterpress-migrate.php
r3401472 r3407121 11 11 * Plugin URI: https://shutterpress.io 12 12 * Description: Imports galleries from NextGen, Envira, FooGallery and Modula 13 * Version: 1. 0.313 * Version: 1.1.0 14 14 * Requires Plugins: shutterpress-gallery 15 15 * Author: ShutterPress … … 26 26 } 27 27 28 define( 'SP_MIGRATE_VERSION', '1. 0.3' );28 define( 'SP_MIGRATE_VERSION', '1.1.0' ); 29 29 define( 'SP_MIGRATE_DIR', plugin_dir_path( __FILE__ ) ); 30 30 define( 'SP_MIGRATE_URL', plugin_dir_url( __FILE__ ) ); -
shutterpress-migrate/tags/1.1.0/src/Admin/Shutterpress_Migrate_Admin_Page.php
r3401472 r3407121 16 16 use Shutterpress\Gallery\Migrate\Plugins\Modula; 17 17 use Shutterpress\Gallery\Migrate\Plugins\Nextgen; 18 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor; 19 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type; 18 20 use Shutterpress\Gallery\Shutterpress_Gallery_Debug; 19 21 … … 119 121 case 'foogallery': 120 122 return class_exists( Foogallery::class ) ? new Foogallery() : null; 123 case 'gt3_elementor': 124 return class_exists( Gt3_Elementor::class ) ? new Gt3_Elementor() : null; 125 case 'gt3_cpt': 126 return class_exists( Gt3_Post_Type::class ) ? new Gt3_Post_Type() : null; 121 127 default: 122 128 return null; … … 199 205 } 200 206 201 $imported = get_posts( 202 array( 203 'post_type' => 'shutterpress-gallery', 204 'post_status' => 'any', 205 'meta_query' => array( 206 array( 207 'key' => '_sp_gallery_imported_from', 208 'value' => $source_slug . ':' . $rid, 209 'compare' => '=', 210 ), 211 ), 212 'numberposts' => 1, 213 'fields' => 'ids', 214 ) 215 ); 216 $is_imported = ! empty( $imported ); 207 $is_imported = $this->is_imported_entry( $source_slug, $rid, $row ); 217 208 $st = get_post_status( $rid ); 218 209 $status = $st ? ucfirst( $st ) : 'N/A'; … … 225 216 } 226 217 227 $admin_cell = esc_html__( 'None', 'shutterpress-migrate' ); 228 $edit_link = get_edit_post_link( $rid ); 218 $admin_cell = esc_html__( 'None', 'shutterpress-migrate' ); 219 $admin_target = isset( $row['post_id'] ) ? (int) $row['post_id'] : $rid; 220 $edit_link = $admin_target ? get_edit_post_link( $admin_target ) : ''; 229 221 if ( $edit_link ) { 230 222 $admin_cell = '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'shutterpress-migrate' ) . '</a>'; … … 366 358 $output .= $this->render_source_table( 'modula', 'Modula', $this->find_galleries_by_source( 'modula' ) ); 367 359 $output .= $this->render_source_table( 'foogallery', 'FooGallery', $this->find_galleries_by_source( 'foogallery' ) ); 360 $output .= $this->render_source_table( 'gt3_elementor', 'GT3 Elementor', $this->find_galleries_by_source( 'gt3_elementor' ) ); 361 $output .= $this->render_source_table( 'gt3_cpt', 'GT3 Galleries', $this->find_galleries_by_source( 'gt3_cpt' ) ); 368 362 369 363 $output .= '</div>'; 370 364 echo $output; 371 365 } 366 367 /** 368 * Determine if a source gallery has already been imported. 369 * 370 * @param string $source_slug Source slug. 371 * @param int $rid Primary identifier. 372 * @param array $row Row data for alias lookup. 373 * @return bool 374 */ 375 private function is_imported_entry( string $source_slug, int $rid, array $row = array() ): bool { 376 $ids = array( $rid ); 377 if ( isset( $row['legacy_id'] ) && $row['legacy_id'] ) { 378 $ids[] = (int) $row['legacy_id']; 379 } 380 381 $meta_query = array( 'relation' => 'OR' ); 382 foreach ( array_unique( $ids ) as $id ) { 383 $meta_query[] = array( 384 'key' => '_sp_gallery_imported_from', 385 'value' => $source_slug . ':' . (int) $id, 386 'compare' => '=', 387 ); 388 } 389 390 $imported = get_posts( 391 array( 392 'post_type' => 'shutterpress-gallery', 393 'post_status' => 'any', 394 'meta_query' => $meta_query, 395 'numberposts' => 1, 396 'fields' => 'ids', 397 ) 398 ); 399 return ! empty( $imported ); 400 } 372 401 } -
shutterpress-migrate/tags/1.1.0/src/Import/Shutterpress_Migrate_Import.php
r3401472 r3407121 16 16 use Shutterpress\Gallery\Migrate\Plugins\Modula; 17 17 use Shutterpress\Gallery\Migrate\Plugins\Nextgen; 18 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor; 19 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type; 18 20 use InvalidArgumentException; 19 21 … … 101 103 } 102 104 $map = array( 103 'foogallery' => Foogallery::class, 104 'nextgen' => Nextgen::class, 105 'envira' => Envira::class, 106 'modula' => Modula::class, 105 'foogallery' => Foogallery::class, 106 'nextgen' => Nextgen::class, 107 'envira' => Envira::class, 108 'modula' => Modula::class, 109 'gt3_elementor' => Gt3_Elementor::class, 110 'gt3_cpt' => Gt3_Post_Type::class, 107 111 ); 108 112 if ( ! isset( $map[ $source ] ) ) { … … 472 476 } 473 477 474 if ( $this->is_already_imported( $source, $sid ) ) {478 if ( $this->is_already_imported( $source, $sid, $src_plugin ) ) { 475 479 $skipped[ $sid ] = 'already_imported'; 476 480 continue; … … 505 509 } 506 510 511 $import_meta_values = $this->build_import_meta_values( $source, $sid, $src_plugin ); 512 507 513 $new_id = $this->create_shutterpress_gallery( 508 514 array( 509 'title' => $title, 510 'status' => $dst_status, 511 'images' => $images, 512 'source' => $source, 513 'source_id' => $sid, 514 'featured_id' => $featured_id, 515 'title' => $title, 516 'status' => $dst_status, 517 'images' => $images, 518 'source' => $source, 519 'source_id' => $sid, 520 'featured_id' => $featured_id, 521 'import_meta_values' => $import_meta_values, 515 522 ) 516 523 ); … … 551 558 */ 552 559 private function create_shutterpress_gallery( array $args ) { 553 $title = (string) ( $args['title'] ?? 'Untitled Gallery' ); 554 $status = (string) ( $args['status'] ?? 'draft' ); 555 $images = array_values( array_filter( array_map( 'intval', (array) ( $args['images'] ?? array() ) ) ) ); 556 $source = sanitize_key( $args['source'] ?? '' ); 557 $source_id = (int) ( $args['source_id'] ?? 0 ); 560 $title = (string) ( $args['title'] ?? 'Untitled Gallery' ); 561 $status = (string) ( $args['status'] ?? 'draft' ); 562 $images = array_values( array_filter( array_map( 'intval', (array) ( $args['images'] ?? array() ) ) ) ); 563 $source = sanitize_key( $args['source'] ?? '' ); 564 $source_id = (int) ( $args['source_id'] ?? 0 ); 565 $import_meta_values = isset( $args['import_meta_values'] ) ? (array) $args['import_meta_values'] : array(); 558 566 559 567 $postarr = array( … … 581 589 } 582 590 583 add_post_meta( $new_id, '_sp_gallery_imported_from', $source . ':' . $source_id, true ); 591 $primary_meta = $source . ':' . $source_id; 592 add_post_meta( $new_id, '_sp_gallery_imported_from', $primary_meta, true ); 593 foreach ( $import_meta_values as $meta_value ) { 594 $meta_value = (string) $meta_value; 595 if ( $meta_value === '' || $meta_value === $primary_meta ) { 596 continue; 597 } 598 add_post_meta( $new_id, '_sp_gallery_imported_from', $meta_value ); 599 } 584 600 585 601 update_post_meta( $new_id, '_sp_gallery_images_array', $images ); … … 641 657 * @return bool True if already imported. 642 658 */ 643 private function is_already_imported( string $source, int $id ): bool { 644 $source = sanitize_key( $source ); 645 $posts = get_posts( 659 private function is_already_imported( string $source, int $id, $plugin = null ): bool { 660 $values = $this->build_import_meta_values( $source, $id, $plugin ); 661 $meta = array( 'relation' => 'OR' ); 662 foreach ( $values as $value ) { 663 $meta[] = array( 664 'key' => '_sp_gallery_imported_from', 665 'value' => $value, 666 'compare' => '=', 667 ); 668 } 669 670 $posts = get_posts( 646 671 array( 647 672 'post_type' => 'shutterpress-gallery', … … 649 674 'numberposts' => 1, 650 675 'fields' => 'ids', 651 'meta_query' => array( 652 array( 653 'key' => '_sp_gallery_imported_from', 654 'value' => $source . ':' . $id, 655 'compare' => '=', 656 ), 657 ), 676 'meta_query' => $meta, 658 677 ) 659 678 ); … … 680 699 } 681 700 } 701 702 /** 703 * Build list of meta values representing imported identifiers. 704 * 705 * @param string $source Source slug. 706 * @param int $id Primary identifier. 707 * @param object|nil $plugin Source plugin helper. 708 * @return array 709 */ 710 private function build_import_meta_values( string $source, int $id, $plugin = null ): array { 711 $slug = sanitize_key( $source ); 712 $ids = array( (int) $id ); 713 714 if ( $plugin && method_exists( $plugin, 'get_import_id_aliases' ) ) { 715 $ids = array_merge( $ids, array_map( 'intval', (array) $plugin->get_import_id_aliases( $id ) ) ); 716 } 717 718 $values = array(); 719 foreach ( array_unique( $ids ) as $value_id ) { 720 if ( $value_id > 0 ) { 721 $values[] = $slug . ':' . $value_id; 722 } 723 } 724 725 return array_values( array_unique( $values ) ); 726 } 682 727 } -
shutterpress-migrate/tags/1.1.0/src/Shutterpress_Migrate_REST.php
r3401472 r3407121 55 55 'required' => true, 56 56 'validate_callback' => function ( $v ) { 57 return in_array( $v, array( 'envira', 'nextgen', 'modula', 'foogallery', 'robo_gallery' ), true );57 return in_array( $v, array( 'envira', 'nextgen', 'modula', 'foogallery', 'robo_gallery', 'gt3_elementor', 'gt3_cpt' ), true ); 58 58 }, 59 59 ), -
shutterpress-migrate/tags/1.1.0/vendor/composer/installed.php
r3401472 r3407121 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',6 'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',16 'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
shutterpress-migrate/trunk/README.txt
r3401472 r3407121 4 4 Tags: gallery, migrate, envira, nextgen, foogallery 5 5 Requires at least: 6.3 6 Tested up to: 6. 86 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1. 0.38 Stable tag: 1.1.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 12 Migrate galleries from NextGEN, Envira, FooGallery and Modulato ShutterPress Gallery. Keep images, titles and featured photos with just one click.12 Migrate galleries from NextGEN, Envira, FooGallery, Modula and GT3 to ShutterPress Gallery. Keep images, titles and featured photos with just one click. 13 13 14 14 == Description == 15 15 16 16 ShutterPress Migrate makes switching to ShutterPress Gallery fast and frustration-free. It scans your existing galleries, recreates them inside ShutterPress with proper attachments and metadata, and moves or copies back all your images into the WordPress media library. Perfect for photographers upgrading to a modern gallery system. 17 18 If you would like to import from a different gallery plugin, please contact us and we'll see if we can add support. 17 19 18 20 **About ShutterPress Gallery** … … 26 28 - FooGallery 27 29 - Modula Gallery 30 - GT3 Photo Gallery - Galleries and Elementor Widgets 28 31 29 32 **What gets imported** … … 50 53 2. Activate the plugin. 51 54 3. Go to ShutterPress Gallery, Import. 52 4. Click Scan, select the galleries you want to import. 53 5. Choose file handling, copy or move, select the target status, then click Import. 55 4. Choose file handling, copy or move, select the target status, then click Import. 54 56 55 57 == Frequently Asked Questions == … … 57 59 = What Plugins can i migrate from? = 58 60 59 NextGen Gallery, Envira Gallery, FooGallery and ModulaGallery.61 NextGen Gallery, Envira Gallery, FooGallery, Modula and GT3 Gallery. 60 62 61 63 = What is ShutterPress Gallery? = … … 71 73 72 74 == Changelog == 75 76 = 1.1.0 = 77 78 * New - Added support for GT3 Photo Gallery - Galleries and Elementor Widgets 73 79 74 80 = 1.0.3 = -
shutterpress-migrate/trunk/shutterpress-migrate.php
r3401472 r3407121 11 11 * Plugin URI: https://shutterpress.io 12 12 * Description: Imports galleries from NextGen, Envira, FooGallery and Modula 13 * Version: 1. 0.313 * Version: 1.1.0 14 14 * Requires Plugins: shutterpress-gallery 15 15 * Author: ShutterPress … … 26 26 } 27 27 28 define( 'SP_MIGRATE_VERSION', '1. 0.3' );28 define( 'SP_MIGRATE_VERSION', '1.1.0' ); 29 29 define( 'SP_MIGRATE_DIR', plugin_dir_path( __FILE__ ) ); 30 30 define( 'SP_MIGRATE_URL', plugin_dir_url( __FILE__ ) ); -
shutterpress-migrate/trunk/src/Admin/Shutterpress_Migrate_Admin_Page.php
r3401472 r3407121 16 16 use Shutterpress\Gallery\Migrate\Plugins\Modula; 17 17 use Shutterpress\Gallery\Migrate\Plugins\Nextgen; 18 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor; 19 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type; 18 20 use Shutterpress\Gallery\Shutterpress_Gallery_Debug; 19 21 … … 119 121 case 'foogallery': 120 122 return class_exists( Foogallery::class ) ? new Foogallery() : null; 123 case 'gt3_elementor': 124 return class_exists( Gt3_Elementor::class ) ? new Gt3_Elementor() : null; 125 case 'gt3_cpt': 126 return class_exists( Gt3_Post_Type::class ) ? new Gt3_Post_Type() : null; 121 127 default: 122 128 return null; … … 199 205 } 200 206 201 $imported = get_posts( 202 array( 203 'post_type' => 'shutterpress-gallery', 204 'post_status' => 'any', 205 'meta_query' => array( 206 array( 207 'key' => '_sp_gallery_imported_from', 208 'value' => $source_slug . ':' . $rid, 209 'compare' => '=', 210 ), 211 ), 212 'numberposts' => 1, 213 'fields' => 'ids', 214 ) 215 ); 216 $is_imported = ! empty( $imported ); 207 $is_imported = $this->is_imported_entry( $source_slug, $rid, $row ); 217 208 $st = get_post_status( $rid ); 218 209 $status = $st ? ucfirst( $st ) : 'N/A'; … … 225 216 } 226 217 227 $admin_cell = esc_html__( 'None', 'shutterpress-migrate' ); 228 $edit_link = get_edit_post_link( $rid ); 218 $admin_cell = esc_html__( 'None', 'shutterpress-migrate' ); 219 $admin_target = isset( $row['post_id'] ) ? (int) $row['post_id'] : $rid; 220 $edit_link = $admin_target ? get_edit_post_link( $admin_target ) : ''; 229 221 if ( $edit_link ) { 230 222 $admin_cell = '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'shutterpress-migrate' ) . '</a>'; … … 366 358 $output .= $this->render_source_table( 'modula', 'Modula', $this->find_galleries_by_source( 'modula' ) ); 367 359 $output .= $this->render_source_table( 'foogallery', 'FooGallery', $this->find_galleries_by_source( 'foogallery' ) ); 360 $output .= $this->render_source_table( 'gt3_elementor', 'GT3 Elementor', $this->find_galleries_by_source( 'gt3_elementor' ) ); 361 $output .= $this->render_source_table( 'gt3_cpt', 'GT3 Galleries', $this->find_galleries_by_source( 'gt3_cpt' ) ); 368 362 369 363 $output .= '</div>'; 370 364 echo $output; 371 365 } 366 367 /** 368 * Determine if a source gallery has already been imported. 369 * 370 * @param string $source_slug Source slug. 371 * @param int $rid Primary identifier. 372 * @param array $row Row data for alias lookup. 373 * @return bool 374 */ 375 private function is_imported_entry( string $source_slug, int $rid, array $row = array() ): bool { 376 $ids = array( $rid ); 377 if ( isset( $row['legacy_id'] ) && $row['legacy_id'] ) { 378 $ids[] = (int) $row['legacy_id']; 379 } 380 381 $meta_query = array( 'relation' => 'OR' ); 382 foreach ( array_unique( $ids ) as $id ) { 383 $meta_query[] = array( 384 'key' => '_sp_gallery_imported_from', 385 'value' => $source_slug . ':' . (int) $id, 386 'compare' => '=', 387 ); 388 } 389 390 $imported = get_posts( 391 array( 392 'post_type' => 'shutterpress-gallery', 393 'post_status' => 'any', 394 'meta_query' => $meta_query, 395 'numberposts' => 1, 396 'fields' => 'ids', 397 ) 398 ); 399 return ! empty( $imported ); 400 } 372 401 } -
shutterpress-migrate/trunk/src/Import/Shutterpress_Migrate_Import.php
r3401472 r3407121 16 16 use Shutterpress\Gallery\Migrate\Plugins\Modula; 17 17 use Shutterpress\Gallery\Migrate\Plugins\Nextgen; 18 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor; 19 use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type; 18 20 use InvalidArgumentException; 19 21 … … 101 103 } 102 104 $map = array( 103 'foogallery' => Foogallery::class, 104 'nextgen' => Nextgen::class, 105 'envira' => Envira::class, 106 'modula' => Modula::class, 105 'foogallery' => Foogallery::class, 106 'nextgen' => Nextgen::class, 107 'envira' => Envira::class, 108 'modula' => Modula::class, 109 'gt3_elementor' => Gt3_Elementor::class, 110 'gt3_cpt' => Gt3_Post_Type::class, 107 111 ); 108 112 if ( ! isset( $map[ $source ] ) ) { … … 472 476 } 473 477 474 if ( $this->is_already_imported( $source, $sid ) ) {478 if ( $this->is_already_imported( $source, $sid, $src_plugin ) ) { 475 479 $skipped[ $sid ] = 'already_imported'; 476 480 continue; … … 505 509 } 506 510 511 $import_meta_values = $this->build_import_meta_values( $source, $sid, $src_plugin ); 512 507 513 $new_id = $this->create_shutterpress_gallery( 508 514 array( 509 'title' => $title, 510 'status' => $dst_status, 511 'images' => $images, 512 'source' => $source, 513 'source_id' => $sid, 514 'featured_id' => $featured_id, 515 'title' => $title, 516 'status' => $dst_status, 517 'images' => $images, 518 'source' => $source, 519 'source_id' => $sid, 520 'featured_id' => $featured_id, 521 'import_meta_values' => $import_meta_values, 515 522 ) 516 523 ); … … 551 558 */ 552 559 private function create_shutterpress_gallery( array $args ) { 553 $title = (string) ( $args['title'] ?? 'Untitled Gallery' ); 554 $status = (string) ( $args['status'] ?? 'draft' ); 555 $images = array_values( array_filter( array_map( 'intval', (array) ( $args['images'] ?? array() ) ) ) ); 556 $source = sanitize_key( $args['source'] ?? '' ); 557 $source_id = (int) ( $args['source_id'] ?? 0 ); 560 $title = (string) ( $args['title'] ?? 'Untitled Gallery' ); 561 $status = (string) ( $args['status'] ?? 'draft' ); 562 $images = array_values( array_filter( array_map( 'intval', (array) ( $args['images'] ?? array() ) ) ) ); 563 $source = sanitize_key( $args['source'] ?? '' ); 564 $source_id = (int) ( $args['source_id'] ?? 0 ); 565 $import_meta_values = isset( $args['import_meta_values'] ) ? (array) $args['import_meta_values'] : array(); 558 566 559 567 $postarr = array( … … 581 589 } 582 590 583 add_post_meta( $new_id, '_sp_gallery_imported_from', $source . ':' . $source_id, true ); 591 $primary_meta = $source . ':' . $source_id; 592 add_post_meta( $new_id, '_sp_gallery_imported_from', $primary_meta, true ); 593 foreach ( $import_meta_values as $meta_value ) { 594 $meta_value = (string) $meta_value; 595 if ( $meta_value === '' || $meta_value === $primary_meta ) { 596 continue; 597 } 598 add_post_meta( $new_id, '_sp_gallery_imported_from', $meta_value ); 599 } 584 600 585 601 update_post_meta( $new_id, '_sp_gallery_images_array', $images ); … … 641 657 * @return bool True if already imported. 642 658 */ 643 private function is_already_imported( string $source, int $id ): bool { 644 $source = sanitize_key( $source ); 645 $posts = get_posts( 659 private function is_already_imported( string $source, int $id, $plugin = null ): bool { 660 $values = $this->build_import_meta_values( $source, $id, $plugin ); 661 $meta = array( 'relation' => 'OR' ); 662 foreach ( $values as $value ) { 663 $meta[] = array( 664 'key' => '_sp_gallery_imported_from', 665 'value' => $value, 666 'compare' => '=', 667 ); 668 } 669 670 $posts = get_posts( 646 671 array( 647 672 'post_type' => 'shutterpress-gallery', … … 649 674 'numberposts' => 1, 650 675 'fields' => 'ids', 651 'meta_query' => array( 652 array( 653 'key' => '_sp_gallery_imported_from', 654 'value' => $source . ':' . $id, 655 'compare' => '=', 656 ), 657 ), 676 'meta_query' => $meta, 658 677 ) 659 678 ); … … 680 699 } 681 700 } 701 702 /** 703 * Build list of meta values representing imported identifiers. 704 * 705 * @param string $source Source slug. 706 * @param int $id Primary identifier. 707 * @param object|nil $plugin Source plugin helper. 708 * @return array 709 */ 710 private function build_import_meta_values( string $source, int $id, $plugin = null ): array { 711 $slug = sanitize_key( $source ); 712 $ids = array( (int) $id ); 713 714 if ( $plugin && method_exists( $plugin, 'get_import_id_aliases' ) ) { 715 $ids = array_merge( $ids, array_map( 'intval', (array) $plugin->get_import_id_aliases( $id ) ) ); 716 } 717 718 $values = array(); 719 foreach ( array_unique( $ids ) as $value_id ) { 720 if ( $value_id > 0 ) { 721 $values[] = $slug . ':' . $value_id; 722 } 723 } 724 725 return array_values( array_unique( $values ) ); 726 } 682 727 } -
shutterpress-migrate/trunk/src/Shutterpress_Migrate_REST.php
r3401472 r3407121 55 55 'required' => true, 56 56 'validate_callback' => function ( $v ) { 57 return in_array( $v, array( 'envira', 'nextgen', 'modula', 'foogallery', 'robo_gallery' ), true );57 return in_array( $v, array( 'envira', 'nextgen', 'modula', 'foogallery', 'robo_gallery', 'gt3_elementor', 'gt3_cpt' ), true ); 58 58 }, 59 59 ), -
shutterpress-migrate/trunk/vendor/composer/installed.php
r3401472 r3407121 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',6 'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',16 'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.