Changeset 3468920
- Timestamp:
- 02/24/2026 09:55:41 PM (5 weeks ago)
- Location:
- virtual-media-folders
- Files:
-
- 8 edited
- 1 copied
-
tags/1.8.1 (copied) (copied from virtual-media-folders/trunk)
-
tags/1.8.1/readme.txt (modified) (2 diffs)
-
tags/1.8.1/src/Admin.php (modified) (2 diffs)
-
tags/1.8.1/vendor/composer/installed.php (modified) (2 diffs)
-
tags/1.8.1/virtual-media-folders.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Admin.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/virtual-media-folders.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
virtual-media-folders/tags/1.8.1/readme.txt
r3468439 r3468920 4 4 Requires at least: 6.8 5 5 Tested up to: 6.9 6 Stable tag: 1.8. 06 Stable tag: 1.8.1 7 7 Requires PHP: 8.3 8 8 License: GPLv2 or later … … 130 130 131 131 == 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` 132 137 133 138 = 1.8.0 = -
virtual-media-folders/tags/1.8.1/src/Admin.php
r3468439 r3468920 38 38 add_action( 'wp_ajax_vmfo_move_to_folder', [ static::class, 'ajax_move_to_folder' ] ); 39 39 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 ); 41 41 add_action( 'admin_head-upload.php', [ static::class, 'add_help_tab' ] ); 42 42 add_action( 'admin_enqueue_scripts', [ static::class, 'add_critical_css' ] ); … … 190 190 191 191 /** 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; 207 245 } 208 246 -
virtual-media-folders/tags/1.8.1/vendor/composer/installed.php
r3468439 r3468920 2 2 'root' => array( 3 3 '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', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 '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', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
virtual-media-folders/tags/1.8.1/virtual-media-folders.php
r3468439 r3468920 15 15 * Plugin Name: Virtual Media Folders 16 16 * Description: Virtual folder organization and smart management for the WordPress Media Library. 17 * Version: 1.8. 017 * Version: 1.8.1 18 18 * Requires at least: 6.8 19 19 * Requires PHP: 8.3 -
virtual-media-folders/trunk/readme.txt
r3468439 r3468920 4 4 Requires at least: 6.8 5 5 Tested up to: 6.9 6 Stable tag: 1.8. 06 Stable tag: 1.8.1 7 7 Requires PHP: 8.3 8 8 License: GPLv2 or later … … 130 130 131 131 == 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` 132 137 133 138 = 1.8.0 = -
virtual-media-folders/trunk/src/Admin.php
r3468439 r3468920 38 38 add_action( 'wp_ajax_vmfo_move_to_folder', [ static::class, 'ajax_move_to_folder' ] ); 39 39 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 ); 41 41 add_action( 'admin_head-upload.php', [ static::class, 'add_help_tab' ] ); 42 42 add_action( 'admin_enqueue_scripts', [ static::class, 'add_critical_css' ] ); … … 190 190 191 191 /** 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; 207 245 } 208 246 -
virtual-media-folders/trunk/vendor/composer/installed.php
r3468439 r3468920 2 2 'root' => array( 3 3 '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', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 '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', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
virtual-media-folders/trunk/virtual-media-folders.php
r3468439 r3468920 15 15 * Plugin Name: Virtual Media Folders 16 16 * Description: Virtual folder organization and smart management for the WordPress Media Library. 17 * Version: 1.8. 017 * Version: 1.8.1 18 18 * Requires at least: 6.8 19 19 * Requires PHP: 8.3
Note: See TracChangeset
for help on using the changeset viewer.