Plugin Directory

Changeset 3468920


Ignore:
Timestamp:
02/24/2026 09:55:41 PM (5 weeks ago)
Author:
PerS
Message:

Update to version 1.8.1 from GitHub

Location:
virtual-media-folders
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • virtual-media-folders/tags/1.8.1/readme.txt

    r3468439 r3468920  
    44Requires at least: 6.8
    55Tested up to: 6.9
    6 Stable tag: 1.8.0
     6Stable tag: 1.8.1
    77Requires PHP: 8.3
    88License: GPLv2 or later
     
    130130
    131131== Changelog ==
     132
     133= 1.8.1 =
     134* Added: `vmfo_upload_folder` filter for controlling folder assignment on upload
     135* Added: Attachment metadata now available to upload-folder filter callbacks
     136* Added: Add-ons can override the default folder by hooking `vmfo_upload_folder`
    132137
    133138= 1.8.0 =
  • virtual-media-folders/tags/1.8.1/src/Admin.php

    r3468439 r3468920  
    3838        add_action( 'wp_ajax_vmfo_move_to_folder', [ static::class, 'ajax_move_to_folder' ] );
    3939        add_action( 'wp_ajax_vmfo_bulk_move_to_folder', [ static::class, 'ajax_bulk_move_to_folder' ] );
    40         add_action( 'add_attachment', [ static::class, 'assign_default_folder' ] );
     40        add_filter( 'wp_generate_attachment_metadata', [ static::class, 'assign_default_folder' ], 10, 3 );
    4141        add_action( 'admin_head-upload.php', [ static::class, 'add_help_tab' ] );
    4242        add_action( 'admin_enqueue_scripts', [ static::class, 'add_critical_css' ] );
     
    190190
    191191    /**
    192      * Assign new uploads to the default folder if configured.
    193      *
    194      * @param int $attachment_id The newly uploaded attachment ID.
    195      * @return void
    196      */
    197     public static function assign_default_folder( int $attachment_id ): void {
    198         $default_folder = Settings::get( 'default_folder', 0 );
    199 
    200         if ( $default_folder > 0 ) {
    201             // Verify the folder exists
    202             $term = get_term( $default_folder, Taxonomy::TAXONOMY );
    203             if ( $term && ! is_wp_error( $term ) ) {
    204                 wp_set_object_terms( $attachment_id, [ $default_folder ], Taxonomy::TAXONOMY );
    205             }
    206         }
     192     * Assign new uploads to a folder.
     193     *
     194     * Hooked to 'wp_generate_attachment_metadata' so that attachment metadata
     195     * (dimensions, EXIF, etc.) is available to filter callbacks.
     196     *
     197     * The folder is determined by:
     198     * 1. The 'vmfo_upload_folder' filter (add-ons / custom code can override)
     199     * 2. The "Default folder for uploads" setting as fallback
     200     *
     201     * Returning 0 or false from the filter skips folder assignment.
     202     *
     203     * @since 1.8.1
     204     *
     205     * @param array  $metadata      Attachment metadata.
     206     * @param int    $attachment_id The attachment post ID.
     207     * @param string $context       Context: 'create' for new uploads.
     208     * @return array Unmodified metadata (this is a filter).
     209     */
     210    public static function assign_default_folder( array $metadata, int $attachment_id, string $context ): array {
     211        // Only process new uploads.
     212        if ( 'create' !== $context ) {
     213            return $metadata;
     214        }
     215
     216        $default_folder = (int) Settings::get( 'default_folder', 0 );
     217
     218        /**
     219         * Filter the folder term ID to assign to a newly uploaded attachment.
     220         *
     221         * Returning 0 or false skips folder assignment.
     222         * Returning an int assigns that folder term ID.
     223         *
     224         * @since 1.8.1
     225         *
     226         * @param int   $folder_id     The folder term ID (from settings, or 0).
     227         * @param int   $attachment_id The attachment post ID.
     228         * @param array $metadata      Attachment metadata (dimensions, EXIF, etc.).
     229         */
     230        $folder_id = (int) apply_filters( 'vmfo_upload_folder', $default_folder, $attachment_id, $metadata );
     231
     232        if ( $folder_id <= 0 ) {
     233            return $metadata;
     234        }
     235
     236        // Verify the folder exists.
     237        $term = get_term( $folder_id, Taxonomy::TAXONOMY );
     238        if ( ! $term || is_wp_error( $term ) ) {
     239            return $metadata;
     240        }
     241
     242        wp_set_object_terms( $attachment_id, [ $folder_id ], Taxonomy::TAXONOMY );
     243
     244        return $metadata;
    207245    }
    208246
  • virtual-media-folders/tags/1.8.1/vendor/composer/installed.php

    r3468439 r3468920  
    22    'root' => array(
    33        'name' => 'soderlind/virtual-media-folders',
    4         'pretty_version' => '1.8.0',
    5         'version' => '1.8.0.0',
    6         'reference' => '9ca13b38dcbceae67a067cfd4f9ac3ea66569e5a',
     4        'pretty_version' => '1.8.1',
     5        'version' => '1.8.1.0',
     6        'reference' => '8db901016d73815f9c0df1e3f27eaea048b19dd4',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'soderlind/virtual-media-folders' => array(
    14             'pretty_version' => '1.8.0',
    15             'version' => '1.8.0.0',
    16             'reference' => '9ca13b38dcbceae67a067cfd4f9ac3ea66569e5a',
     14            'pretty_version' => '1.8.1',
     15            'version' => '1.8.1.0',
     16            'reference' => '8db901016d73815f9c0df1e3f27eaea048b19dd4',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • virtual-media-folders/tags/1.8.1/virtual-media-folders.php

    r3468439 r3468920  
    1515 * Plugin Name: Virtual Media Folders
    1616 * Description: Virtual folder organization and smart management for the WordPress Media Library.
    17  * Version: 1.8.0
     17 * Version: 1.8.1
    1818 * Requires at least: 6.8
    1919 * Requires PHP: 8.3
  • virtual-media-folders/trunk/readme.txt

    r3468439 r3468920  
    44Requires at least: 6.8
    55Tested up to: 6.9
    6 Stable tag: 1.8.0
     6Stable tag: 1.8.1
    77Requires PHP: 8.3
    88License: GPLv2 or later
     
    130130
    131131== Changelog ==
     132
     133= 1.8.1 =
     134* Added: `vmfo_upload_folder` filter for controlling folder assignment on upload
     135* Added: Attachment metadata now available to upload-folder filter callbacks
     136* Added: Add-ons can override the default folder by hooking `vmfo_upload_folder`
    132137
    133138= 1.8.0 =
  • virtual-media-folders/trunk/src/Admin.php

    r3468439 r3468920  
    3838        add_action( 'wp_ajax_vmfo_move_to_folder', [ static::class, 'ajax_move_to_folder' ] );
    3939        add_action( 'wp_ajax_vmfo_bulk_move_to_folder', [ static::class, 'ajax_bulk_move_to_folder' ] );
    40         add_action( 'add_attachment', [ static::class, 'assign_default_folder' ] );
     40        add_filter( 'wp_generate_attachment_metadata', [ static::class, 'assign_default_folder' ], 10, 3 );
    4141        add_action( 'admin_head-upload.php', [ static::class, 'add_help_tab' ] );
    4242        add_action( 'admin_enqueue_scripts', [ static::class, 'add_critical_css' ] );
     
    190190
    191191    /**
    192      * Assign new uploads to the default folder if configured.
    193      *
    194      * @param int $attachment_id The newly uploaded attachment ID.
    195      * @return void
    196      */
    197     public static function assign_default_folder( int $attachment_id ): void {
    198         $default_folder = Settings::get( 'default_folder', 0 );
    199 
    200         if ( $default_folder > 0 ) {
    201             // Verify the folder exists
    202             $term = get_term( $default_folder, Taxonomy::TAXONOMY );
    203             if ( $term && ! is_wp_error( $term ) ) {
    204                 wp_set_object_terms( $attachment_id, [ $default_folder ], Taxonomy::TAXONOMY );
    205             }
    206         }
     192     * Assign new uploads to a folder.
     193     *
     194     * Hooked to 'wp_generate_attachment_metadata' so that attachment metadata
     195     * (dimensions, EXIF, etc.) is available to filter callbacks.
     196     *
     197     * The folder is determined by:
     198     * 1. The 'vmfo_upload_folder' filter (add-ons / custom code can override)
     199     * 2. The "Default folder for uploads" setting as fallback
     200     *
     201     * Returning 0 or false from the filter skips folder assignment.
     202     *
     203     * @since 1.8.1
     204     *
     205     * @param array  $metadata      Attachment metadata.
     206     * @param int    $attachment_id The attachment post ID.
     207     * @param string $context       Context: 'create' for new uploads.
     208     * @return array Unmodified metadata (this is a filter).
     209     */
     210    public static function assign_default_folder( array $metadata, int $attachment_id, string $context ): array {
     211        // Only process new uploads.
     212        if ( 'create' !== $context ) {
     213            return $metadata;
     214        }
     215
     216        $default_folder = (int) Settings::get( 'default_folder', 0 );
     217
     218        /**
     219         * Filter the folder term ID to assign to a newly uploaded attachment.
     220         *
     221         * Returning 0 or false skips folder assignment.
     222         * Returning an int assigns that folder term ID.
     223         *
     224         * @since 1.8.1
     225         *
     226         * @param int   $folder_id     The folder term ID (from settings, or 0).
     227         * @param int   $attachment_id The attachment post ID.
     228         * @param array $metadata      Attachment metadata (dimensions, EXIF, etc.).
     229         */
     230        $folder_id = (int) apply_filters( 'vmfo_upload_folder', $default_folder, $attachment_id, $metadata );
     231
     232        if ( $folder_id <= 0 ) {
     233            return $metadata;
     234        }
     235
     236        // Verify the folder exists.
     237        $term = get_term( $folder_id, Taxonomy::TAXONOMY );
     238        if ( ! $term || is_wp_error( $term ) ) {
     239            return $metadata;
     240        }
     241
     242        wp_set_object_terms( $attachment_id, [ $folder_id ], Taxonomy::TAXONOMY );
     243
     244        return $metadata;
    207245    }
    208246
  • virtual-media-folders/trunk/vendor/composer/installed.php

    r3468439 r3468920  
    22    'root' => array(
    33        'name' => 'soderlind/virtual-media-folders',
    4         'pretty_version' => '1.8.0',
    5         'version' => '1.8.0.0',
    6         'reference' => '9ca13b38dcbceae67a067cfd4f9ac3ea66569e5a',
     4        'pretty_version' => '1.8.1',
     5        'version' => '1.8.1.0',
     6        'reference' => '8db901016d73815f9c0df1e3f27eaea048b19dd4',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'soderlind/virtual-media-folders' => array(
    14             'pretty_version' => '1.8.0',
    15             'version' => '1.8.0.0',
    16             'reference' => '9ca13b38dcbceae67a067cfd4f9ac3ea66569e5a',
     14            'pretty_version' => '1.8.1',
     15            'version' => '1.8.1.0',
     16            'reference' => '8db901016d73815f9c0df1e3f27eaea048b19dd4',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
  • virtual-media-folders/trunk/virtual-media-folders.php

    r3468439 r3468920  
    1515 * Plugin Name: Virtual Media Folders
    1616 * Description: Virtual folder organization and smart management for the WordPress Media Library.
    17  * Version: 1.8.0
     17 * Version: 1.8.1
    1818 * Requires at least: 6.8
    1919 * Requires PHP: 8.3
Note: See TracChangeset for help on using the changeset viewer.