Plugin Directory

Changeset 3248934


Ignore:
Timestamp:
03/01/2025 05:16:48 PM (13 months ago)
Author:
stefacchio
Message:

init v1.0.4

Location:
auto-attachments-cleaner/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • auto-attachments-cleaner/trunk/README.txt

    r3211918 r3248934  
    55Requires at least: 5.0
    66Tested up to: 6.7
    7 Stable Tag: 1.0.3
     7Stable Tag: 1.0.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626
    2727= When are attachments deleted? =
     28When the post is permanently deleted from the trash or the trash is emptied
    2829
    29 When the post is permanently deleted from the trash or the trash is emptied
     30= Are all thumbnails created by wordpress also deleted? =
     31Yes, a native WordPress function is used for deleting images, which also deletes all thumbnails created
     32
     33= Is Woo Commerce supported? =
     34Yes Woo Commerce is supported, all plugin that works with Custom Post Type are compatible.
    3035
    3136
     
    35402. Plugin settings
    36413. Where plugin works (trash)
     424. Warning notice on Trash Page
    3743
    3844== Changelog ==
     45
     46= 1.0.4 =
     47* [NEW] - Introduced Warning notice on Empty Trash button and on post row actions near to 'permanently delete' link
     48
     49= 1.0.3 =
     50* [FIX] - Bug Fix
    3951
    4052= 1.0.2 =
  • auto-attachments-cleaner/trunk/assets/css/admin-style.css

    r3211918 r3248934  
    2626    border-bottom: none;
    2727}
     28
     29.aac-notice-warning{
     30    background: #fff;
     31    border: 1px solid #c3c4c7;
     32    border-left-color: #dba617;
     33    border-left-width: 4px;
     34    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
     35    margin: 5px 0;
     36    padding: 2px 5px 3px 5px;
     37    font-size: 12px;
     38    font-weight: 500;
     39    color: #da0000;
     40}
     41
     42
     43.aac-notice-warning.hidden{
     44    display: none;
     45}
     46
     47
     48.hentry:hover .aac-notice-warning.hidden{
     49    display: block;
     50}
  • auto-attachments-cleaner/trunk/auto-attachments-cleaner.php

    r3211918 r3248934  
    99 * Plugin URI:        https://www.stefanofattori.it/wordpress/plugins/
    1010 * Description:       Automatically deletes attachments (images, videos, files etc...) linked to a page, post or custom post type when it is deleted.
    11  * Version:           1.0.3
     11 * Version:           1.0.4
    1212 * Requires at least: 5.0
    1313 * Requires PHP:      7.0
     
    3131 * Start at version 1.0.0 and use SemVer - https://semver.org
    3232 */
    33 define( 'AUTO_ATTACHMENTS_CLEANER_VERSION', '1.0.3' );
     33define( 'AUTO_ATTACHMENTS_CLEANER_VERSION', '1.0.4' );
    3434
    3535
     
    7171        add_action( 'before_delete_post', [ $this, 'delete_post_attachments' ] );
    7272        add_action( 'admin_notices', [ $this, 'display_attachments_deletion_notice' ], 20 );
     73
     74
     75        // Show Warning Notice on permantly deleting post
     76        add_filter( 'post_row_actions', [ $this, 'add_delete_attachments_notice_to_post_row' ], 99, 2 );
     77        add_filter( 'page_row_actions', [ $this, 'add_delete_attachments_notice_to_post_row' ], 99, 2 );
     78
     79        // Show Warning Notice on near to Empty Trash button
     80        add_action( 'manage_posts_extra_tablenav', [ $this, 'add_delete_attachments_notice_to_empty_trash_button' ] );
     81        add_action( 'manage_pages_extra_tablenav', [ $this, 'add_delete_attachments_notice_to_empty_trash_button' ] );
    7382    }
    7483
     
    131140        );
    132141    }
     142
     143
     144
     145    /**
     146     * Show a warning notice near to Empty Trash button on top of the trash page
     147     * @param mixed $which
     148     * @return void
     149     */
     150    public function add_delete_attachments_notice_to_empty_trash_button( $which ) {
     151        global $typenow; // Actual Post Type
     152
     153        // Check the post type and user settings
     154        $selected_post_types = get_option( 'auto_attachments_cleaner_post_types', [] );
     155
     156        if ( isset( $_GET['post_status'] ) && $_GET['post_status'] === 'trash' && in_array( $typenow, $selected_post_types, true ) ) {
     157            if ( $which === 'top' ) {
     158                echo '<div class="alignleft aac-notice-warning"><span>'
     159                    . esc_html__( '⚠️ Caution: Emptying the trash will also irreversibly delete all related attachments of each post!', 'auto-attachments-cleaner' )
     160                    . '</span></div>';
     161            }
     162        }
     163    }
     164
     165
     166    /**
     167     * Show a warning notice near to each post row
     168     * @param mixed $actions
     169     * @param mixed $post
     170     */
     171    public function add_delete_attachments_notice_to_post_row( $actions, $post ) {
     172        // Check the post type and user settings
     173        $post_type = get_post_type( $post->ID );
     174        $selected_post_types = get_option( 'auto_attachments_cleaner_post_types', [] );
     175
     176        if ( in_array( $post_type, $selected_post_types, true ) ) {
     177            if ( get_query_var( 'post_status' ) === 'trash' && isset( $actions['delete'] ) ) {
     178                $actions['aac-notice'] = '<div class="aac-notice-warning hidden"><span>' . esc_html__( '⚠️ Caution: permanently deleting this post will also irreversibly delete all related attachments!', 'auto-attachments-cleaner' ) . '</span></div>';
     179            }
     180        }
     181        return $actions;
     182    }
     183
    133184
    134185
Note: See TracChangeset for help on using the changeset viewer.