⚡ NEW: Changeset/ - Collection

Changeset 3200269


Ignore:
Timestamp:
12/01/2024 03:55:43 PM (13 months ago)
Author:
lanacodes
Message:

Version update

Location:
lana-downloads-manager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lana-downloads-manager/trunk/lana-downloads-manager.php

    r3004462 r3200269  
    44 * Plugin URI: https://lana.codes/product/lana-downloads-manager/
    55 * Description: Downloads Manager with counter and log.
    6  * Version: 1.8.2
     6 * Version: 1.9.0
    77 * Author: Lana Codes
    88 * Author URI: https://lana.codes/
     
    1212
    1313defined( 'ABSPATH' ) or die();
    14 define( 'LANA_DOWNLOADS_MANAGER_VERSION', '1.8.2' );
     14define( 'LANA_DOWNLOADS_MANAGER_VERSION', '1.9.0' );
    1515define( 'LANA_DOWNLOADS_MANAGER_DIR_URL', plugin_dir_url( __FILE__ ) );
    1616define( 'LANA_DOWNLOADS_MANAGER_DIR_PATH', plugin_dir_path( __FILE__ ) );
     
    390390
    391391add_action( 'init', 'lana_downloads_manager_update_custom_post_type' );
     392
     393/**
     394 * Lana Downloads Manager
     395 * delete the lana download assigned files before deleting the post
     396 *
     397 * @param $post_id
     398 * @param $post
     399 */
     400function lana_downloads_manager_delete_lana_download_files_before_delete_post( $post_id, $post ) {
     401
     402    if ( ! $post ) {
     403        return;
     404    }
     405
     406    if ( ! is_a( $post, 'WP_Post' ) ) {
     407        return;
     408    }
     409
     410    if ( 'lana_download' != $post->post_type ) {
     411        return;
     412    }
     413
     414    if ( ! apply_filters( 'lana_downloads_manager_delete_lana_download_files', true ) ) {
     415        return;
     416    }
     417
     418    $attachments = get_children( array(
     419        'post_parent' => $post_id,
     420        'post_type'   => 'attachment',
     421    ) );
     422
     423    if ( ! empty( $attachments ) ) {
     424        foreach ( $attachments as $attachment ) {
     425            wp_delete_attachment( $attachment->ID, true );
     426        }
     427    }
     428}
     429
     430add_action( 'before_delete_post', 'lana_downloads_manager_delete_lana_download_files_before_delete_post', 10, 2 );
    392431
    393432/**
  • lana-downloads-manager/trunk/readme.txt

    r3004462 r3200269  
    44Tags: download, download manager, file manager, download counter
    55Requires at least: 4.0
    6 Tested up to: 6.4
    7 Stable tag: 1.8.2
     6Tested up to: 6.7
     7Stable tag: 1.9.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5757
    5858== Changelog ==
     59
     60= 1.9.0 =
     61* add function to delete the lana download assigned files before deleting the post
    5962
    6063= 1.8.2 =
     
    196199== Upgrade Notice ==
    197200
     201= 1.9.0 =
     202This version improves functionality. Upgrade recommended.
     203
    198204= 1.8.2 =
    199205This version fixes log pager. Upgrade recommended.
Note: See TracChangeset for help on using the changeset viewer.