Plugin Directory

Changeset 3401406


Ignore:
Timestamp:
11/23/2025 07:13:43 PM (4 months ago)
Author:
palashwpdev
Message:

Update to version 1.1.8 from GitHub

Location:
auto-delete-post
Files:
7 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • auto-delete-post/tags/1.1.8/assets/css/style.css

    r3386608 r3401406  
    33    margin-top: 10px !important;
    44}
     5.post-list-for-redirect-container,
     6.page-list-for-redirect-container {
     7    margin: 5px 0 10px 0;
     8}
  • auto-delete-post/tags/1.1.8/auto-delete-post.php

    r3387241 r3401406  
    66 * Plugin URI:        https://wordpress.org/plugin/auto-delete-post
    77 * Description:       This plugin automatically deletes a post after a certain time
    8  * Version:           1.1.7
     8 * Version:           1.1.8
    99 * Requires at least: 5.2
    1010 * Tested up to:      6.8.3
  • auto-delete-post/tags/1.1.8/controllers/ADP_Assets_Controller.php

    r3386608 r3401406  
    2222     * Enqueue admin assets
    2323     */
    24     public function enqueue_admin_assets() {       
     24    public function enqueue_admin_assets() {   
     25        wp_enqueue_style( 'select2', ADP_CSS . 'select2.min.css', [], ADP_VERSION, 'all' );   
    2526        wp_enqueue_style( 'adp-style', ADP_CSS . 'style.css', [], ADP_VERSION, 'all' );
    26 
     27       
     28        wp_enqueue_script(
     29            'select2',
     30            ADP_JS . 'select2.min.js',
     31            ['jquery'],
     32            null,
     33            true
     34        );
    2735        wp_enqueue_script(
    2836            'adp-script',
     
    3240            true
    3341        );
     42        wp_enqueue_script(
     43            'adp-admin-script',
     44            ADP_JS . 'admin.js',
     45            ['jquery','select2'],
     46            ADP_VERSION,
     47            true
     48        );
    3449    }
    3550}
  • auto-delete-post/tags/1.1.8/controllers/ADP_Post_Manager_Controller.php

    r3386608 r3401406  
    3939        add_action( 'adp_daily_cron', [ $this, 'process_deletions' ] );
    4040        add_action( 'admin_init', [ $this, 'process_deletions' ] ); // Also process on admin page loads for reliability
     41        add_action( 'template_redirect', [ $this, 'redirect_deleted_post' ] );
    4142    }
    4243
     
    125126        }
    126127    }
     128
     129    /**
     130     * Redirect deleted post to another post or page
     131     */
     132    public function redirect_deleted_post() {
     133        if ( ! is_404() ) return;
     134
     135        global $wp;
     136        $slug                   = $wp->request;
     137
     138        $adp_redirect_option    = get_option( 'adp_redirect_option', [] );
     139        $redirection_id         = $adp_redirect_option['id'];
     140        $adp_deleted_post_list  = get_option( 'adp_deleted_post_list', [] );
     141
     142        foreach( $adp_deleted_post_list as $post ) {
     143            if ( $post['post_slug'] === $slug ) {
     144                wp_safe_redirect( get_permalink( $redirection_id ), 301 );
     145                exit;
     146            }
     147        }
     148    }
    127149}
  • auto-delete-post/tags/1.1.8/models/ADP_Post_Model.php

    r3386608 r3401406  
    132132                $result = wp_delete_post( $post_id, false );
    133133            }
     134
     135            $this->save_post_slug_for_redirection( $post_id );
    134136           
    135137            $results[ $post_id ] = $result ? 'success' : 'failed';
     
    137139       
    138140        return $results;
     141    }
     142
     143     /**
     144     * Save all deleted post_slug in the database as an array
     145     */
     146    public function save_post_slug_for_redirection( $deletion_post_id ) {
     147        $deleted_post_slug          = get_post_field( 'post_name', $deletion_post_id );
     148        $deleted_post_slug_parts    = explode( '__trashed', $deleted_post_slug );
     149        $cleaned_slug               = $deleted_post_slug_parts[0];
     150        $deleted_post_details       = [
     151            'post_slug'    => $cleaned_slug,
     152            'time'         => current_time( 'timestamp' ),
     153        ];
     154
     155        $adp_deleted_post_list      = get_option( 'adp_deleted_post_list', [] );
     156        $adp_deleted_post_list[]    = $deleted_post_details;
     157        update_option( 'adp_deleted_post_list', $adp_deleted_post_list );
    139158    }
    140159
  • auto-delete-post/tags/1.1.8/models/ADP_Settings_Model.php

    r3386608 r3401406  
    5454        return update_option( self::DELETE_OPTION_KEY, $option );
    5555    }
     56
     57    /**
     58     * Option key for redirect settings
     59     */
     60    const REDIRECT_OPTION_KEY = 'adp_redirect_option';
     61
     62    /**
     63     * Get the redirect settings
     64     *
     65     * @return array Redirect settings
     66     */
     67    public function get_redirect_settings() {
     68        return get_option( self::REDIRECT_OPTION_KEY, [] );
     69    }
     70
     71    /**
     72     * Save redirect settings
     73     *
     74     * @param array $settings Redirect settings
     75     * @return bool True on success, false on failure
     76     */
     77    public function save_redirect_settings( $settings ) {
     78        return update_option( self::REDIRECT_OPTION_KEY, $settings );
     79    }
    5680}
  • auto-delete-post/tags/1.1.8/readme.txt

    r3387241 r3401406  
    22Contributors: palashwpdev
    33Donate link: https://buymeacoffee.com/palash_wp
    4 
    5 Tags: automatic post delete, automatic delete post, delete post, delete page, delete custom post type, post delete, delete post after a certain time, scheduled deletion, auto-expire content
     4Tags: auto delete post, delete post, delete page, delete custom post type, scheduled deletion
    65Requires PHP: 7.4
    76Requires at least: 5.2
    87Tested up to: 6.8.3
    9 Version: 1.1.7
    10 Stable tag: 1.1.7
     8Version: 1.1.8
     9Stable tag: 1.1.8
    1110License: GPLv2 or later
    1211License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2524*   Real-time reliable deletion processing
    2625*   Automatic removal of deletion schedule when posts are restored from trash
     26*   Set post redirection option trying to visit deleted post/page
    2727
    2828== Installation ==
     
    5454Yes, you can cancel an auto-deletion by removing the scheduled time from the post's edit screen or clearing the field in quick edit.
    5555
     56= Can I redirect my deleted post or pages? =
     57Yes, you can set a specific post or page for post redirection when user tries to visit deleted post/page.
     58
    5659== Screenshots ==
    5760
     
    60633. You can also select the time from the quick edit option, no need to go to the edit section of any post.
    61644. Select any post types where you want to enable this functionality and choose between moving to trash or permanent deletion in the plugin settings.
     655. Select any post or page that you may want to set as post redirection.
    6266
    6367== Changelog ==
     68= 1.1.8 =
     69* Added post redirection option after for deleted post/page
     70
     71= 1.1.7 =
     72* Updated the banner image
     73
    6474= 1.1.6 =
    6575* Fixed fatal error caused by missing main class initialization.
  • auto-delete-post/tags/1.1.8/vendor/composer/autoload_static.php

    r3387241 r3401406  
    1212
    1313    public static $prefixLengthsPsr4 = array (
    14         'A' => 
     14        'A' =>
    1515        array (
    1616            'AutoDeletePost\\' => 15,
     
    1919
    2020    public static $prefixDirsPsr4 = array (
    21         'AutoDeletePost\\' => 
     21        'AutoDeletePost\\' =>
    2222        array (
    2323            0 => __DIR__ . '/../..' . '/src',
  • auto-delete-post/tags/1.1.8/views/ADP_Settings_View.php

    r3386608 r3401406  
    2929            $delete_option = isset( $_POST['adp-delete-option'] ) ? sanitize_text_field( $_POST['adp-delete-option'] ) : '';
    3030            $model->save_delete_option( $delete_option );
    31            
     31
     32            // Process redirect settings
     33            $redirect_type = isset( $_POST['redirects_to_after_deletion'] ) ? sanitize_text_field( $_POST['redirects_to_after_deletion'] ) : '';
     34            $redirect_id = '';
     35            if ( $redirect_type === 'redirects_to_posts' && isset( $_POST['post_to_redirect'] ) ) {
     36                $redirect_id = sanitize_text_field( $_POST['post_to_redirect'] );
     37            } elseif ( $redirect_type === 'redirects_to_pages' && isset( $_POST['page_to_redirect'] ) ) {
     38                $redirect_id = sanitize_text_field( $_POST['page_to_redirect'] );
     39            }
     40            $redirect_settings = [
     41                'type' => $redirect_type,
     42                'id' => $redirect_id
     43            ];
     44            $model->save_redirect_settings( $redirect_settings );
     45
    3246            echo '<div class="notice notice-success is-dismissible"><p>';
    3347            esc_html_e( 'Settings saved successfully!', 'auto-delete-post' );
     
    3751        $selected_post_types = $model->get_selected_post_types();
    3852        $current_option = $model->get_delete_option(); // Default to 'move_to_trash'
     53        $redirect_settings = $model->get_redirect_settings();
    3954       
    4055        $post_types_args = [ 'public' => true ];
     
    99114                </table>
    100115               
     116                <h2><?php esc_html_e( 'Post Redirect', 'auto-delete-post' ); ?></h2>
     117                <table class="form-table">
     118                    <tr>
     119                        <th scope="row"><?php esc_html_e( 'Redirect Options', 'auto-delete-post' ); ?></th>
     120                        <td>
     121                            <fieldset>
     122                                <legend class="screen-reader-text"><span><?php esc_html_e( 'Redirect Options', 'auto-delete-post' ); ?></span></legend>
     123                                <label>
     124                                    <input name="redirects_to_after_deletion" type="radio" value="redirects_to_posts" <?php checked( $redirect_settings['type'] ?? '', 'redirects_to_posts' ); ?> />
     125                                    <?php esc_html_e( 'Redirects to Posts', 'auto-delete-post' ); ?>
     126                                </label><br>
     127                                <?php
     128                                    $post_args = [ 'post_type' => 'post' ];
     129                                    $all_posts = get_posts( $post_args );
     130                                ?>
     131                                <div class="post-list-for-redirect-container">
     132                                    <select class="post-list-for-redirect" name="post_to_redirect" <?php echo ( $redirect_settings['type'] ?? '' ) !== 'redirects_to_posts' ? 'disabled' : ''; ?>>
     133                                        <?php foreach( $all_posts as $post ) : ?>
     134                                        <option value="<?php echo esc_html( $post->ID ); ?>" <?php selected( $redirect_settings['id'] ?? '', $post->ID ); ?>>
     135                                            <?php echo esc_html( $post->post_title ); ?>
     136                                        </option>
     137                                        <?php endforeach; ?>
     138                                    </select>
     139                                </div>
     140                                <label>
     141                                    <input id="redirects_to_pages" type="radio" name="redirects_to_after_deletion" value="redirects_to_pages" <?php checked( $redirect_settings['type'] ?? '', 'redirects_to_pages' ); ?> />
     142                                    <?php esc_html_e( 'Redirect to Pages', 'auto-delete-post' ); ?>
     143                                </label>
     144                                <?php
     145                                    $page_args = [ 'post_type' => 'page' ];
     146                                    $all_pages = get_posts( $page_args  );
     147                                ?>
     148                                  <div class="page-list-for-redirect-container">
     149                                      <select class="page-list-for-redirect" name="page_to_redirect" <?php echo ( $redirect_settings['type'] ?? '' ) !== 'redirects_to_pages' ? 'disabled' : ''; ?>>
     150                                          <?php foreach( $all_pages as $page ) : ?>
     151                                          <option value="<?php echo esc_html( $page->ID ); ?>" <?php selected( $redirect_settings['id'] ?? '', $page->ID ); ?>>
     152                                              <?php echo esc_html( $page->post_title ); ?>
     153                                          </option>
     154                                          <?php endforeach; ?>
     155                                      </select>
     156                                  </div>
     157                            </fieldset>
     158                            <p class="description"><?php esc_html_e( 'Choose where post/pages should be redirected after deletion.', 'auto-delete-post' ); ?></p>
     159                        </td>
     160                    </tr>         
     161                </table>
     162
    101163                <?php submit_button( esc_html__( 'Save Settings', 'auto-delete-post' ), 'primary', 'adp_combined_submit' ); ?>
    102164            </form>
  • auto-delete-post/trunk/assets/css/style.css

    r3386608 r3401406  
    33    margin-top: 10px !important;
    44}
     5.post-list-for-redirect-container,
     6.page-list-for-redirect-container {
     7    margin: 5px 0 10px 0;
     8}
  • auto-delete-post/trunk/auto-delete-post.php

    r3387241 r3401406  
    66 * Plugin URI:        https://wordpress.org/plugin/auto-delete-post
    77 * Description:       This plugin automatically deletes a post after a certain time
    8  * Version:           1.1.7
     8 * Version:           1.1.8
    99 * Requires at least: 5.2
    1010 * Tested up to:      6.8.3
  • auto-delete-post/trunk/controllers/ADP_Assets_Controller.php

    r3386608 r3401406  
    2222     * Enqueue admin assets
    2323     */
    24     public function enqueue_admin_assets() {       
     24    public function enqueue_admin_assets() {   
     25        wp_enqueue_style( 'select2', ADP_CSS . 'select2.min.css', [], ADP_VERSION, 'all' );   
    2526        wp_enqueue_style( 'adp-style', ADP_CSS . 'style.css', [], ADP_VERSION, 'all' );
    26 
     27       
     28        wp_enqueue_script(
     29            'select2',
     30            ADP_JS . 'select2.min.js',
     31            ['jquery'],
     32            null,
     33            true
     34        );
    2735        wp_enqueue_script(
    2836            'adp-script',
     
    3240            true
    3341        );
     42        wp_enqueue_script(
     43            'adp-admin-script',
     44            ADP_JS . 'admin.js',
     45            ['jquery','select2'],
     46            ADP_VERSION,
     47            true
     48        );
    3449    }
    3550}
  • auto-delete-post/trunk/controllers/ADP_Post_Manager_Controller.php

    r3386608 r3401406  
    3939        add_action( 'adp_daily_cron', [ $this, 'process_deletions' ] );
    4040        add_action( 'admin_init', [ $this, 'process_deletions' ] ); // Also process on admin page loads for reliability
     41        add_action( 'template_redirect', [ $this, 'redirect_deleted_post' ] );
    4142    }
    4243
     
    125126        }
    126127    }
     128
     129    /**
     130     * Redirect deleted post to another post or page
     131     */
     132    public function redirect_deleted_post() {
     133        if ( ! is_404() ) return;
     134
     135        global $wp;
     136        $slug                   = $wp->request;
     137
     138        $adp_redirect_option    = get_option( 'adp_redirect_option', [] );
     139        $redirection_id         = $adp_redirect_option['id'];
     140        $adp_deleted_post_list  = get_option( 'adp_deleted_post_list', [] );
     141
     142        foreach( $adp_deleted_post_list as $post ) {
     143            if ( $post['post_slug'] === $slug ) {
     144                wp_safe_redirect( get_permalink( $redirection_id ), 301 );
     145                exit;
     146            }
     147        }
     148    }
    127149}
  • auto-delete-post/trunk/models/ADP_Post_Model.php

    r3386608 r3401406  
    132132                $result = wp_delete_post( $post_id, false );
    133133            }
     134
     135            $this->save_post_slug_for_redirection( $post_id );
    134136           
    135137            $results[ $post_id ] = $result ? 'success' : 'failed';
     
    137139       
    138140        return $results;
     141    }
     142
     143     /**
     144     * Save all deleted post_slug in the database as an array
     145     */
     146    public function save_post_slug_for_redirection( $deletion_post_id ) {
     147        $deleted_post_slug          = get_post_field( 'post_name', $deletion_post_id );
     148        $deleted_post_slug_parts    = explode( '__trashed', $deleted_post_slug );
     149        $cleaned_slug               = $deleted_post_slug_parts[0];
     150        $deleted_post_details       = [
     151            'post_slug'    => $cleaned_slug,
     152            'time'         => current_time( 'timestamp' ),
     153        ];
     154
     155        $adp_deleted_post_list      = get_option( 'adp_deleted_post_list', [] );
     156        $adp_deleted_post_list[]    = $deleted_post_details;
     157        update_option( 'adp_deleted_post_list', $adp_deleted_post_list );
    139158    }
    140159
  • auto-delete-post/trunk/models/ADP_Settings_Model.php

    r3386608 r3401406  
    5454        return update_option( self::DELETE_OPTION_KEY, $option );
    5555    }
     56
     57    /**
     58     * Option key for redirect settings
     59     */
     60    const REDIRECT_OPTION_KEY = 'adp_redirect_option';
     61
     62    /**
     63     * Get the redirect settings
     64     *
     65     * @return array Redirect settings
     66     */
     67    public function get_redirect_settings() {
     68        return get_option( self::REDIRECT_OPTION_KEY, [] );
     69    }
     70
     71    /**
     72     * Save redirect settings
     73     *
     74     * @param array $settings Redirect settings
     75     * @return bool True on success, false on failure
     76     */
     77    public function save_redirect_settings( $settings ) {
     78        return update_option( self::REDIRECT_OPTION_KEY, $settings );
     79    }
    5680}
  • auto-delete-post/trunk/readme.txt

    r3387241 r3401406  
    22Contributors: palashwpdev
    33Donate link: https://buymeacoffee.com/palash_wp
    4 
    5 Tags: automatic post delete, automatic delete post, delete post, delete page, delete custom post type, post delete, delete post after a certain time, scheduled deletion, auto-expire content
     4Tags: auto delete post, delete post, delete page, delete custom post type, scheduled deletion
    65Requires PHP: 7.4
    76Requires at least: 5.2
    87Tested up to: 6.8.3
    9 Version: 1.1.7
    10 Stable tag: 1.1.7
     8Version: 1.1.8
     9Stable tag: 1.1.8
    1110License: GPLv2 or later
    1211License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2524*   Real-time reliable deletion processing
    2625*   Automatic removal of deletion schedule when posts are restored from trash
     26*   Set post redirection option trying to visit deleted post/page
    2727
    2828== Installation ==
     
    5454Yes, you can cancel an auto-deletion by removing the scheduled time from the post's edit screen or clearing the field in quick edit.
    5555
     56= Can I redirect my deleted post or pages? =
     57Yes, you can set a specific post or page for post redirection when user tries to visit deleted post/page.
     58
    5659== Screenshots ==
    5760
     
    60633. You can also select the time from the quick edit option, no need to go to the edit section of any post.
    61644. Select any post types where you want to enable this functionality and choose between moving to trash or permanent deletion in the plugin settings.
     655. Select any post or page that you may want to set as post redirection.
    6266
    6367== Changelog ==
     68= 1.1.8 =
     69* Added post redirection option after for deleted post/page
     70
     71= 1.1.7 =
     72* Updated the banner image
     73
    6474= 1.1.6 =
    6575* Fixed fatal error caused by missing main class initialization.
  • auto-delete-post/trunk/vendor/composer/autoload_static.php

    r3387241 r3401406  
    1212
    1313    public static $prefixLengthsPsr4 = array (
    14         'A' => 
     14        'A' =>
    1515        array (
    1616            'AutoDeletePost\\' => 15,
     
    1919
    2020    public static $prefixDirsPsr4 = array (
    21         'AutoDeletePost\\' => 
     21        'AutoDeletePost\\' =>
    2222        array (
    2323            0 => __DIR__ . '/../..' . '/src',
  • auto-delete-post/trunk/views/ADP_Settings_View.php

    r3386608 r3401406  
    2929            $delete_option = isset( $_POST['adp-delete-option'] ) ? sanitize_text_field( $_POST['adp-delete-option'] ) : '';
    3030            $model->save_delete_option( $delete_option );
    31            
     31
     32            // Process redirect settings
     33            $redirect_type = isset( $_POST['redirects_to_after_deletion'] ) ? sanitize_text_field( $_POST['redirects_to_after_deletion'] ) : '';
     34            $redirect_id = '';
     35            if ( $redirect_type === 'redirects_to_posts' && isset( $_POST['post_to_redirect'] ) ) {
     36                $redirect_id = sanitize_text_field( $_POST['post_to_redirect'] );
     37            } elseif ( $redirect_type === 'redirects_to_pages' && isset( $_POST['page_to_redirect'] ) ) {
     38                $redirect_id = sanitize_text_field( $_POST['page_to_redirect'] );
     39            }
     40            $redirect_settings = [
     41                'type' => $redirect_type,
     42                'id' => $redirect_id
     43            ];
     44            $model->save_redirect_settings( $redirect_settings );
     45
    3246            echo '<div class="notice notice-success is-dismissible"><p>';
    3347            esc_html_e( 'Settings saved successfully!', 'auto-delete-post' );
     
    3751        $selected_post_types = $model->get_selected_post_types();
    3852        $current_option = $model->get_delete_option(); // Default to 'move_to_trash'
     53        $redirect_settings = $model->get_redirect_settings();
    3954       
    4055        $post_types_args = [ 'public' => true ];
     
    99114                </table>
    100115               
     116                <h2><?php esc_html_e( 'Post Redirect', 'auto-delete-post' ); ?></h2>
     117                <table class="form-table">
     118                    <tr>
     119                        <th scope="row"><?php esc_html_e( 'Redirect Options', 'auto-delete-post' ); ?></th>
     120                        <td>
     121                            <fieldset>
     122                                <legend class="screen-reader-text"><span><?php esc_html_e( 'Redirect Options', 'auto-delete-post' ); ?></span></legend>
     123                                <label>
     124                                    <input name="redirects_to_after_deletion" type="radio" value="redirects_to_posts" <?php checked( $redirect_settings['type'] ?? '', 'redirects_to_posts' ); ?> />
     125                                    <?php esc_html_e( 'Redirects to Posts', 'auto-delete-post' ); ?>
     126                                </label><br>
     127                                <?php
     128                                    $post_args = [ 'post_type' => 'post' ];
     129                                    $all_posts = get_posts( $post_args );
     130                                ?>
     131                                <div class="post-list-for-redirect-container">
     132                                    <select class="post-list-for-redirect" name="post_to_redirect" <?php echo ( $redirect_settings['type'] ?? '' ) !== 'redirects_to_posts' ? 'disabled' : ''; ?>>
     133                                        <?php foreach( $all_posts as $post ) : ?>
     134                                        <option value="<?php echo esc_html( $post->ID ); ?>" <?php selected( $redirect_settings['id'] ?? '', $post->ID ); ?>>
     135                                            <?php echo esc_html( $post->post_title ); ?>
     136                                        </option>
     137                                        <?php endforeach; ?>
     138                                    </select>
     139                                </div>
     140                                <label>
     141                                    <input id="redirects_to_pages" type="radio" name="redirects_to_after_deletion" value="redirects_to_pages" <?php checked( $redirect_settings['type'] ?? '', 'redirects_to_pages' ); ?> />
     142                                    <?php esc_html_e( 'Redirect to Pages', 'auto-delete-post' ); ?>
     143                                </label>
     144                                <?php
     145                                    $page_args = [ 'post_type' => 'page' ];
     146                                    $all_pages = get_posts( $page_args  );
     147                                ?>
     148                                  <div class="page-list-for-redirect-container">
     149                                      <select class="page-list-for-redirect" name="page_to_redirect" <?php echo ( $redirect_settings['type'] ?? '' ) !== 'redirects_to_pages' ? 'disabled' : ''; ?>>
     150                                          <?php foreach( $all_pages as $page ) : ?>
     151                                          <option value="<?php echo esc_html( $page->ID ); ?>" <?php selected( $redirect_settings['id'] ?? '', $page->ID ); ?>>
     152                                              <?php echo esc_html( $page->post_title ); ?>
     153                                          </option>
     154                                          <?php endforeach; ?>
     155                                      </select>
     156                                  </div>
     157                            </fieldset>
     158                            <p class="description"><?php esc_html_e( 'Choose where post/pages should be redirected after deletion.', 'auto-delete-post' ); ?></p>
     159                        </td>
     160                    </tr>         
     161                </table>
     162
    101163                <?php submit_button( esc_html__( 'Save Settings', 'auto-delete-post' ), 'primary', 'adp_combined_submit' ); ?>
    102164            </form>
Note: See TracChangeset for help on using the changeset viewer.