PHP code example of soderlind / vmfa-migrate

1. Go to this page and download the library: Download soderlind/vmfa-migrate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soderlind / vmfa-migrate example snippets


add_action( 'init', function () {
    register_taxonomy( 'media_tag', 'attachment', [
        'label'        => __( 'Media Tags' ),
        'public'       => true,
        'hierarchical' => false,
        'show_ui'      => true,
        'show_in_rest' => true,
    ] );
} );

$terms = get_the_terms( $attachment_id, 'media_tag' );
if ( $terms && ! is_wp_error( $terms ) ) {
    foreach ( $terms as $term ) {
        echo esc_html( $term->name );
    }
}

$attachments = get_posts( [
    'post_type'   => 'attachment',
    'post_status' => 'inherit',
    'tax_query'   => [
        [
            'taxonomy' => 'media_tag',
            'field'    => 'slug',
            'terms'    => 'nature',
        ],
    ],
] );

add_filter( 'vmfa_migrate_drivers', function( array $drivers ): array {
    $drivers[] = MyCustomDriver::class;
    return $drivers;
} );