Plugin Directory

Changeset 3302346


Ignore:
Timestamp:
05/28/2025 03:42:45 PM (9 months ago)
Author:
betterranking
Message:

Update version 2.4.1 - Consistent naming and improved UI

Location:
delete-posts-by-url/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • delete-posts-by-url/trunk/assets/css/admin.css

    r3302285 r3302346  
    55}
    66
    7 .bdbu-header {
    8     display: flex;
    9     align-items: center;
    10     margin-bottom: 30px;
    11     gap: 20px;
     7.dpbu-header {
     8    margin-bottom: 20px;
     9    padding: 20px;
     10    background: #fff;
     11    border: 1px solid #ccd0d4;
     12    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    1213}
    1314
    14 .bdbu-logo {
     15.dpbu-header h1 {
     16    margin: 0;
     17    padding: 0;
     18    font-size: 23px;
     19    font-weight: 400;
     20    line-height: 1.3;
     21}
     22
     23.dpbu-logo {
    1524    width: 64px;
    1625    height: 64px;
     
    1827}
    1928
    20 .bdbu-branding {
    21     margin-left: auto;
    22     text-align: right;
     29.dpbu-branding {
     30    margin-top: 10px;
    2331    font-size: 13px;
    2432    color: #646970;
    2533}
    2634
    27 .bdbu-branding a {
     35.dpbu-branding a {
    2836    color: #2271b1;
    2937    text-decoration: none;
    3038}
    3139
    32 .bdbu-branding a:hover {
     40.dpbu-branding a:hover {
    3341    color: #135e96;
    3442}
    3543
    36 .bdbu-options {
     44.dpbu-options {
     45    margin-bottom: 20px;
     46    padding: 20px;
    3747    background: #fff;
    38     border: 1px solid #c3c4c7;
    39     border-radius: 4px;
    40     padding: 20px;
    41     margin-bottom: 30px;
     48    border: 1px solid #ccd0d4;
     49    box-shadow: 0 1px 1px rgba(0,0,0,.04);
     50}
     51
     52.dpbu-options label {
     53    display: block;
     54    margin-bottom: 10px;
    4255}
    4356
     
    5568}
    5669
    57 .bdbu-input {
     70.dpbu-input {
     71    margin-bottom: 20px;
     72    padding: 20px;
    5873    background: #fff;
    59     border: 1px solid #c3c4c7;
    60     border-radius: 4px;
    61     padding: 20px;
    62     margin-bottom: 30px;
     74    border: 1px solid #ccd0d4;
     75    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    6376}
    6477
     
    6881}
    6982
    70 .bdbu-progress {
    71     background: #fff;
    72     border: 1px solid #c3c4c7;
    73     border-radius: 4px;
    74     padding: 20px;
    75     margin-bottom: 30px;
     83.dpbu-examples {
     84    margin: 10px 0;
     85    padding-left: 20px;
     86    color: #646970;
    7687}
    7788
    78 .progress-bar {
     89.dpbu-progress {
     90    margin: 20px 0;
     91}
     92
     93.dpbu-progress .progress-bar {
    7994    height: 20px;
     95    background-color: #f0f0f1;
     96    border: 1px solid #c3c4c7;
     97    border-radius: 3px;
     98    overflow: hidden;
     99}
     100
     101.dpbu-progress .progress-bar div {
     102    height: 100%;
    80103    background-color: #2271b1;
    81104    width: 0;
    82     border-radius: 10px;
    83105    transition: width 0.3s ease;
    84106}
    85107
    86 .progress-text {
    87     text-align: center;
    88     margin-top: 10px;
    89     color: #646970;
     108.dpbu-results {
     109    margin-top: 20px;
     110    padding: 20px;
     111    background: #fff;
     112    border: 1px solid #ccd0d4;
     113    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    90114}
    91115
    92 .bdbu-results {
    93     background: #fff;
    94     border: 1px solid #c3c4c7;
    95     border-radius: 4px;
    96     padding: 20px;
     116.dpbu-results h3 {
     117    margin-top: 0;
     118}
     119
     120.dpbu-results .results-content {
     121    margin-top: 10px;
     122}
     123
     124.dpbu-results .success {
     125    color: #00a32a;
     126}
     127
     128.dpbu-results .error {
     129    color: #d63638;
    97130}
    98131
  • delete-posts-by-url/trunk/assets/js/admin.js

    r3302285 r3302346  
    11jQuery(document).ready(function($) {
    2     const form = $('#bdbu-delete-form');
    3     const progress = $('.bdbu-progress');
    4     const progressBar = $('.progress-bar');
    5     const progressText = $('.progress-text');
    6     const results = $('.bdbu-results');
    7     const resultsContent = $('.results-content');
     2    const form = $('#dpbu-delete-form');
     3    const progress = $('.dpbu-progress');
     4    const progressBar = progress.find('.progress-bar');
     5    const progressText = progress.find('.progress-text');
     6    const results = $('.dpbu-results');
     7    const resultsContent = results.find('.results-content');
    88    const submitButton = form.find('button[type="submit"]');
    99
     
    1111        e.preventDefault();
    1212
    13         const urls = $('textarea[name="urls"]').val().trim().split('\n').filter(url => url.trim());
    14         if (!urls.length) {
    15             displayError('Please enter at least one URL.');
     13        const urls = $('textarea[name="urls"]').val().trim();
     14        if (!urls) {
     15            alert(dpbuAdmin.messages.noUrls);
    1616            return;
    1717        }
    1818
    19         if (!confirm(bdbuAdmin.confirmMsg)) {
     19        if (!confirm(dpbuAdmin.confirmMsg)) {
    2020            return;
    2121        }
    2222
    2323        const formData = new FormData(this);
    24         formData.append('action', 'bdbu_process_urls');
    25         formData.append('nonce', bdbuAdmin.nonce);
     24        formData.append('action', 'dpbu_process_urls');
     25        formData.append('nonce', dpbuAdmin.nonce);
    2626
    2727        // Reset and show progress
    2828        progress.show();
     29        results.hide();
    2930        progressBar.width('0%');
    3031        progressText.text('Processing...');
    31         results.hide();
    32         resultsContent.empty();
    3332        submitButton.prop('disabled', true);
    3433
     
    4443
    4544        $.ajax({
    46             url: bdbuAdmin.ajaxurl,
     45            url: dpbuAdmin.ajaxurl,
    4746            type: 'POST',
    4847            data: formData,
     
    5554               
    5655                if (response.success) {
    57                     displayResults(response.data);
     56                    const data = response.data;
     57                    let html = '';
     58
     59                    if (data.deleted.length > 0) {
     60                        html += '<h4 class="success">Successfully Deleted:</h4><ul>';
     61                        data.deleted.forEach(function(item) {
     62                            html += '<li>' + item.title + ' (' + item.url + ')</li>';
     63                        });
     64                        html += '</ul>';
     65                    }
     66
     67                    if (data.failed.length > 0) {
     68                        html += '<h4 class="error">Failed to Delete:</h4><ul>';
     69                        data.failed.forEach(function(item) {
     70                            html += '<li>' + item.url + ' - ' + item.reason + '</li>';
     71                        });
     72                        html += '</ul>';
     73                    }
     74
     75                    if (data.not_found.length > 0) {
     76                        html += '<h4 class="error">Not Found:</h4><ul>';
     77                        data.not_found.forEach(function(url) {
     78                            html += '<li>' + url + '</li>';
     79                        });
     80                        html += '</ul>';
     81                    }
     82
     83                    resultsContent.html(html);
     84                    results.show();
    5885                } else {
    59                     displayError(response.data.message);
     86                    alert(response.data.message || 'An error occurred');
    6087                }
    6188            },
     
    74101    });
    75102
    76     function displayResults(data) {
    77         let html = '';
    78         let totalProcessed = data.deleted.length + data.failed.length + data.not_found.length;
    79 
    80         html += '<div class="notice notice-info"><p>' +
    81                'Processed ' + totalProcessed + ' URLs in total.</p></div>';
    82 
    83         if (data.deleted.length > 0) {
    84             html += '<div class="notice notice-success"><p>' +
    85                    data.deleted.length + ' posts have been deleted successfully:</p><ul>';
    86            
    87             data.deleted.forEach(function(item) {
    88                 html += '<li>' + escapeHtml(item.title) + ' (' + escapeHtml(item.url) + ')</li>';
    89             });
    90            
    91             html += '</ul></div>';
    92         }
    93 
    94         if (data.failed.length > 0) {
    95             html += '<div class="notice notice-error"><p>' +
    96                    'Failed to delete ' + data.failed.length + ' posts:</p><ul>';
    97            
    98             data.failed.forEach(function(item) {
    99                 html += '<li>' + escapeHtml(item.url) + ' - ' + escapeHtml(item.reason) + '</li>';
    100             });
    101            
    102             html += '</ul></div>';
    103         }
    104 
    105         if (data.not_found.length > 0) {
    106             html += '<div class="notice notice-warning"><p>' +
    107                    data.not_found.length + ' URLs could not be matched to posts:</p><ul>';
    108            
    109             data.not_found.forEach(function(url) {
    110                 html += '<li>' + escapeHtml(url) + '</li>';
    111             });
    112            
    113             html += '</ul></div>';
    114         }
    115 
    116         results.show();
    117         resultsContent.html(html);
    118 
    119         // Scroll to results
    120         $('html, body').animate({
    121             scrollTop: results.offset().top - 50
    122         }, 500);
    123     }
    124 
    125103    function displayError(message) {
    126104        const html = '<div class="notice notice-error"><p>' + escapeHtml(message) + '</p></div>';
  • delete-posts-by-url/trunk/delete-posts-by-url.php

    r3302285 r3302346  
    1818defined('ABSPATH') || exit;
    1919
    20 class BDBU_Delete_Posts {
     20class DPBU_Delete_Posts {
    2121    private static $instance = null;
    2222    private $deleted_items = [];
     
    3333        add_action('admin_menu', [$this, 'add_admin_menu']);
    3434        add_action('admin_enqueue_scripts', [$this, 'enqueue_assets']);
    35         add_action('wp_ajax_bdbu_process_urls', [$this, 'ajax_process_urls']);
     35        add_action('wp_ajax_dpbu_process_urls', [$this, 'ajax_process_urls']);
    3636    }
    3737
     
    4242
    4343        wp_enqueue_style(
    44             'bdbu-admin',
     44            'dpbu-admin',
    4545            plugins_url('assets/css/admin.css', __FILE__),
    4646            [],
    47             '2.0'
     47            '2.4.1'
    4848        );
    4949
    5050        wp_enqueue_script(
    51             'bdbu-admin',
     51            'dpbu-admin',
    5252            plugins_url('assets/js/admin.js', __FILE__),
    5353            ['jquery'],
    54             '2.0',
     54            '2.4.1',
    5555            true
    5656        );
    5757
    58         wp_localize_script('bdbu-admin', 'bdbuAdmin', [
     58        wp_localize_script('dpbu-admin', 'dpbuAdmin', [
    5959            'ajaxurl' => admin_url('admin-ajax.php'),
    60             'nonce' => wp_create_nonce('bdbu_process_urls'),
     60            'nonce' => wp_create_nonce('dpbu_process_urls'),
    6161            'confirmMsg' => __('Are you sure you want to delete these posts? This action cannot be undone.', 'delete-posts-by-url'),
    6262        ]);
     
    8787        ?>
    8888        <div class="wrap">
    89             <div class="bdbu-header">
     89            <div class="dpbu-header">
    9090                <img src="<?php echo esc_url(plugins_url('assets/images/icon-128x128.png', __FILE__)); ?>"
    9191                     alt="<?php echo esc_attr__('Delete Posts By URL', 'delete-posts-by-url'); ?>"
    9292                     class="bdbu-logo">
    9393                <h1><?php echo esc_html__('Delete Posts By URL', 'delete-posts-by-url'); ?></h1>
    94                 <div class="bdbu-branding">
     94                <div class="dpbu-branding">
    9595                    <?php echo sprintf(
    9696                        /* translators: %s: Better Ranking URL */
     
    107107            </div>
    108108
    109             <form id="bdbu-delete-form" method="post">
    110                 <div class="bdbu-options">
     109            <form id="dpbu-delete-form" method="post">
     110                <div class="dpbu-options">
    111111                    <h2><?php echo esc_html__('Options', 'delete-posts-by-url'); ?></h2>
    112112                   
     
    130130                </div>
    131131
    132                 <div class="bdbu-input">
     132                <div class="dpbu-input">
    133133                    <h2><?php echo esc_html__('URLs', 'delete-posts-by-url'); ?></h2>
    134134                    <p><?php echo esc_html__('Paste one URL per line:', 'delete-posts-by-url'); ?></p>
     135                    <p class="description"><?php echo esc_html__('Examples:', 'delete-posts-by-url'); ?></p>
     136                    <ul class="dpbu-examples">
     137                        <li><?php echo esc_html(home_url('/sample-post/')); ?> (<?php echo esc_html__('Absolute URL', 'delete-posts-by-url'); ?>)</li>
     138                        <li>/sample-post/ (<?php echo esc_html__('Relative URL', 'delete-posts-by-url'); ?>)</li>
     139                    </ul>
    135140                    <textarea name="urls" rows="10" cols="60" class="large-text"></textarea>
    136141                </div>
    137142
    138                 <div class="bdbu-progress" style="display: none;">
     143                <div class="dpbu-progress" style="display: none;">
    139144                    <div class="progress-bar"></div>
    140145                    <div class="progress-text"></div>
    141146                </div>
    142147
    143                 <div class="bdbu-results" style="display: none;">
     148                <div class="dpbu-results" style="display: none;">
    144149                    <h3><?php echo esc_html__('Results', 'delete-posts-by-url'); ?></h3>
    145150                    <div class="results-content"></div>
    146151                </div>
    147152
    148                 <?php wp_nonce_field('bdbu_process_urls', 'bdbu_nonce'); ?>
     153                <?php wp_nonce_field('dpbu_process_urls', 'dpbu_nonce'); ?>
    149154                <button type="submit" class="button button-primary">
    150155                    <?php echo esc_html__('Process URLs', 'delete-posts-by-url'); ?>
     
    156161
    157162    public function ajax_process_urls(): void {
    158         check_ajax_referer('bdbu_process_urls', 'nonce');
     163        check_ajax_referer('dpbu_process_urls', 'nonce');
    159164
    160165        if (!current_user_can('manage_options')) {
     
    277282// Initialize the plugin
    278283add_action('plugins_loaded', function() {
    279     BDBU_Delete_Posts::get_instance();
     284    DPBU_Delete_Posts::get_instance();
    280285});
Note: See TracChangeset for help on using the changeset viewer.