Plugin Directory

Changeset 3407121


Ignore:
Timestamp:
12/01/2025 05:53:02 PM (3 months ago)
Author:
shutterpressgallery
Message:

Update to version 1.1.0 from GitHub

Location:
shutterpress-migrate
Files:
4 added
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shutterpress-migrate/tags/1.1.0/README.txt

    r3401472 r3407121  
    44Tags: gallery, migrate, envira, nextgen, foogallery
    55Requires at least: 6.3
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.0.3
     8Stable tag: 1.1.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Migrate galleries from NextGEN, Envira, FooGallery and Modula to ShutterPress Gallery. Keep images, titles and featured photos with just one click.
     12Migrate galleries from NextGEN, Envira, FooGallery, Modula and GT3 to ShutterPress Gallery. Keep images, titles and featured photos with just one click.
    1313
    1414== Description ==
    1515
    1616ShutterPress 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
     18If you would like to import from a different gallery plugin, please contact us and we'll see if we can add support.
    1719
    1820**About ShutterPress Gallery**
     
    2628- FooGallery
    2729- Modula Gallery
     30- GT3 Photo Gallery - Galleries and Elementor Widgets
    2831
    2932**What gets imported**
     
    50532. Activate the plugin.
    51543. 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.
     554. Choose file handling, copy or move, select the target status, then click Import.
    5456
    5557== Frequently Asked Questions ==
     
    5759= What Plugins can i migrate from? =
    5860
    59 NextGen Gallery, Envira Gallery, FooGallery and Modula Gallery.
     61NextGen Gallery, Envira Gallery, FooGallery, Modula and GT3 Gallery.
    6062
    6163= What is ShutterPress Gallery? =
     
    7173
    7274== Changelog ==
     75
     76= 1.1.0 =
     77
     78* New - Added support for GT3 Photo Gallery - Galleries and Elementor Widgets
    7379
    7480= 1.0.3 =
  • shutterpress-migrate/tags/1.1.0/shutterpress-migrate.php

    r3401472 r3407121  
    1111 * Plugin URI:        https://shutterpress.io
    1212 * Description:       Imports galleries from NextGen, Envira, FooGallery and Modula
    13  * Version:           1.0.3
     13 * Version:           1.1.0
    1414 * Requires Plugins:  shutterpress-gallery
    1515 * Author:            ShutterPress
     
    2626}
    2727
    28 define( 'SP_MIGRATE_VERSION', '1.0.3' );
     28define( 'SP_MIGRATE_VERSION', '1.1.0' );
    2929define( 'SP_MIGRATE_DIR', plugin_dir_path( __FILE__ ) );
    3030define( 'SP_MIGRATE_URL', plugin_dir_url( __FILE__ ) );
  • shutterpress-migrate/tags/1.1.0/src/Admin/Shutterpress_Migrate_Admin_Page.php

    r3401472 r3407121  
    1616use Shutterpress\Gallery\Migrate\Plugins\Modula;
    1717use Shutterpress\Gallery\Migrate\Plugins\Nextgen;
     18use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor;
     19use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type;
    1820use Shutterpress\Gallery\Shutterpress_Gallery_Debug;
    1921
     
    119121            case 'foogallery':
    120122                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;
    121127            default:
    122128                return null;
     
    199205            }
    200206
    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 );
    217208            $st          = get_post_status( $rid );
    218209            $status      = $st ? ucfirst( $st ) : 'N/A';
     
    225216            }
    226217
    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 ) : '';
    229221            if ( $edit_link ) {
    230222                $admin_cell = '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'shutterpress-migrate' ) . '</a>';
     
    366358        $output .= $this->render_source_table( 'modula', 'Modula', $this->find_galleries_by_source( 'modula' ) );
    367359        $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' ) );
    368362
    369363        $output .= '</div>';
    370364        echo $output;
    371365    }
     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    }
    372401}
  • shutterpress-migrate/tags/1.1.0/src/Import/Shutterpress_Migrate_Import.php

    r3401472 r3407121  
    1616use Shutterpress\Gallery\Migrate\Plugins\Modula;
    1717use Shutterpress\Gallery\Migrate\Plugins\Nextgen;
     18use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor;
     19use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type;
    1820use InvalidArgumentException;
    1921
     
    101103        }
    102104        $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,
    107111        );
    108112        if ( ! isset( $map[ $source ] ) ) {
     
    472476            }
    473477
    474             if ( $this->is_already_imported( $source, $sid ) ) {
     478            if ( $this->is_already_imported( $source, $sid, $src_plugin ) ) {
    475479                $skipped[ $sid ] = 'already_imported';
    476480                continue;
     
    505509                }
    506510
     511                $import_meta_values = $this->build_import_meta_values( $source, $sid, $src_plugin );
     512
    507513                $new_id = $this->create_shutterpress_gallery(
    508514                    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,
    515522                    )
    516523                );
     
    551558     */
    552559    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();
    558566
    559567        $postarr = array(
     
    581589        }
    582590
    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        }
    584600
    585601        update_post_meta( $new_id, '_sp_gallery_images_array', $images );
     
    641657     * @return bool          True if already imported.
    642658     */
    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(
    646671            array(
    647672                'post_type'   => 'shutterpress-gallery',
     
    649674                'numberposts' => 1,
    650675                '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,
    658677            )
    659678        );
     
    680699        }
    681700    }
     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    }
    682727}
  • shutterpress-migrate/tags/1.1.0/src/Shutterpress_Migrate_REST.php

    r3401472 r3407121  
    5555                        'required'          => true,
    5656                        '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 );
    5858                        },
    5959                    ),
  • shutterpress-migrate/tags/1.1.0/vendor/composer/installed.php

    r3401472 r3407121  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',
     6        'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',
     16            'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • shutterpress-migrate/trunk/README.txt

    r3401472 r3407121  
    44Tags: gallery, migrate, envira, nextgen, foogallery
    55Requires at least: 6.3
    6 Tested up to: 6.8
     6Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.0.3
     8Stable tag: 1.1.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Migrate galleries from NextGEN, Envira, FooGallery and Modula to ShutterPress Gallery. Keep images, titles and featured photos with just one click.
     12Migrate galleries from NextGEN, Envira, FooGallery, Modula and GT3 to ShutterPress Gallery. Keep images, titles and featured photos with just one click.
    1313
    1414== Description ==
    1515
    1616ShutterPress 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
     18If you would like to import from a different gallery plugin, please contact us and we'll see if we can add support.
    1719
    1820**About ShutterPress Gallery**
     
    2628- FooGallery
    2729- Modula Gallery
     30- GT3 Photo Gallery - Galleries and Elementor Widgets
    2831
    2932**What gets imported**
     
    50532. Activate the plugin.
    51543. 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.
     554. Choose file handling, copy or move, select the target status, then click Import.
    5456
    5557== Frequently Asked Questions ==
     
    5759= What Plugins can i migrate from? =
    5860
    59 NextGen Gallery, Envira Gallery, FooGallery and Modula Gallery.
     61NextGen Gallery, Envira Gallery, FooGallery, Modula and GT3 Gallery.
    6062
    6163= What is ShutterPress Gallery? =
     
    7173
    7274== Changelog ==
     75
     76= 1.1.0 =
     77
     78* New - Added support for GT3 Photo Gallery - Galleries and Elementor Widgets
    7379
    7480= 1.0.3 =
  • shutterpress-migrate/trunk/shutterpress-migrate.php

    r3401472 r3407121  
    1111 * Plugin URI:        https://shutterpress.io
    1212 * Description:       Imports galleries from NextGen, Envira, FooGallery and Modula
    13  * Version:           1.0.3
     13 * Version:           1.1.0
    1414 * Requires Plugins:  shutterpress-gallery
    1515 * Author:            ShutterPress
     
    2626}
    2727
    28 define( 'SP_MIGRATE_VERSION', '1.0.3' );
     28define( 'SP_MIGRATE_VERSION', '1.1.0' );
    2929define( 'SP_MIGRATE_DIR', plugin_dir_path( __FILE__ ) );
    3030define( 'SP_MIGRATE_URL', plugin_dir_url( __FILE__ ) );
  • shutterpress-migrate/trunk/src/Admin/Shutterpress_Migrate_Admin_Page.php

    r3401472 r3407121  
    1616use Shutterpress\Gallery\Migrate\Plugins\Modula;
    1717use Shutterpress\Gallery\Migrate\Plugins\Nextgen;
     18use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor;
     19use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type;
    1820use Shutterpress\Gallery\Shutterpress_Gallery_Debug;
    1921
     
    119121            case 'foogallery':
    120122                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;
    121127            default:
    122128                return null;
     
    199205            }
    200206
    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 );
    217208            $st          = get_post_status( $rid );
    218209            $status      = $st ? ucfirst( $st ) : 'N/A';
     
    225216            }
    226217
    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 ) : '';
    229221            if ( $edit_link ) {
    230222                $admin_cell = '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'shutterpress-migrate' ) . '</a>';
     
    366358        $output .= $this->render_source_table( 'modula', 'Modula', $this->find_galleries_by_source( 'modula' ) );
    367359        $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' ) );
    368362
    369363        $output .= '</div>';
    370364        echo $output;
    371365    }
     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    }
    372401}
  • shutterpress-migrate/trunk/src/Import/Shutterpress_Migrate_Import.php

    r3401472 r3407121  
    1616use Shutterpress\Gallery\Migrate\Plugins\Modula;
    1717use Shutterpress\Gallery\Migrate\Plugins\Nextgen;
     18use Shutterpress\Gallery\Migrate\Plugins\Gt3_Elementor;
     19use Shutterpress\Gallery\Migrate\Plugins\Gt3_Post_Type;
    1820use InvalidArgumentException;
    1921
     
    101103        }
    102104        $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,
    107111        );
    108112        if ( ! isset( $map[ $source ] ) ) {
     
    472476            }
    473477
    474             if ( $this->is_already_imported( $source, $sid ) ) {
     478            if ( $this->is_already_imported( $source, $sid, $src_plugin ) ) {
    475479                $skipped[ $sid ] = 'already_imported';
    476480                continue;
     
    505509                }
    506510
     511                $import_meta_values = $this->build_import_meta_values( $source, $sid, $src_plugin );
     512
    507513                $new_id = $this->create_shutterpress_gallery(
    508514                    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,
    515522                    )
    516523                );
     
    551558     */
    552559    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();
    558566
    559567        $postarr = array(
     
    581589        }
    582590
    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        }
    584600
    585601        update_post_meta( $new_id, '_sp_gallery_images_array', $images );
     
    641657     * @return bool          True if already imported.
    642658     */
    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(
    646671            array(
    647672                'post_type'   => 'shutterpress-gallery',
     
    649674                'numberposts' => 1,
    650675                '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,
    658677            )
    659678        );
     
    680699        }
    681700    }
     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    }
    682727}
  • shutterpress-migrate/trunk/src/Shutterpress_Migrate_REST.php

    r3401472 r3407121  
    5555                        'required'          => true,
    5656                        '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 );
    5858                        },
    5959                    ),
  • shutterpress-migrate/trunk/vendor/composer/installed.php

    r3401472 r3407121  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',
     6        'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => '2f3703a613cefee8d0aca8d2b3acb8c4dc4d2dc2',
     16            'reference' => 'f7ca349c0b86d893cba7851b970e9c457e6fe62a',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.