Plugin Directory

Changeset 3363897


Ignore:
Timestamp:
09/18/2025 10:28:13 AM (5 months ago)
Author:
theorcawp
Message:
  • Added - Freemius SDK
  • Updated - version 1.2
Location:
wc-delete-orders
Files:
460 added
2 edited

Legend:

Unmodified
Added
Removed
  • wc-delete-orders/trunk/readme.txt

    r2324977 r3363897  
    1 === WC Delete all orders ===
     1=== WC Delete orders ===
    22
    3 Contributors: rynald0s
     3Contributors: theorcawp
    44Tags: delete orders, bulk delete, orders
    5 Requires at least: 4.5.0
    6 Tested up to: 5.4.2
    7 Stable tag: 1.1
    8 WC requires at least: 3.0
    9 WC tested up to: 4.2.0
    10 License: GPLv3 or later License
    11 URI: http://www.gnu.org/licenses/gpl-3.0.html
     5Requires at least: 6.0
     6Requires PHP: 7.4
     7Tested up to: 6.8
     8Stable tag: 1.2
     9WC requires at least: 6.0
     10WC tested up to: 10.0.4
     11License: GPL-3.0-or-later
     12License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1213
    1314This plugin lets you nuke all existing orders — please use with caution!
     
    2930== Changelog ==
    3031
     32= 1.2 =
     33* Fixed   - Compatibility for WP 6.8+ and WC 10 +
     34* Updated - Version number
     35* Added   - Freemius SDK
     36
    3137= 1.0  = 
    3238* first release
  • wc-delete-orders/trunk/wc-delete-all-orders.php

    r2324977 r3363897  
    33/*
    44 Plugin Name: WC Delete orders
    5  Plugin URI: https://profiles.wordpress.org/rynald0s
     5 Plugin URI: https://profiles.wordpress.org/theorcawp
    66 Description: This plugin lets you nuke all orders — please use with caution!
    7  Author: Rynaldo Stoltz
    8  Author URI: http://rynaldo.com
    9  Version: 1.1
    10  License: GPLv3 or later License
    11  License URI: http://www.gnu.org/licenses/gpl-3.0.html
     7 Author: theorcawp
     8 Author URI: https://orcawp.com
     9 Version: 1.2
     10 Text Domain: wc-delete-orders
     11 License: GPLv2 or later
     12 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1213 */
    1314
     
    1617}
    1718
     19if ( ! function_exists( 'wdao_fs' ) ) {
     20    // Create a helper function for easy SDK access.
     21    function wdao_fs() {
     22        global $wdao_fs;
     23
     24        if ( ! isset( $wdao_fs ) ) {
     25            // Include Freemius SDK.
     26            require_once dirname( __FILE__ ) . '/freemius/start.php';
     27            $wdao_fs = fs_dynamic_init( array(
     28                'id'                  => '20471',
     29                'slug'                => 'wc-delete-all-orders',
     30                'type'                => 'plugin',
     31                'public_key'          => 'pk_f439331166e3a61ed7e1b4f726aad',
     32                'is_premium'          => false,
     33                'has_addons'          => false,
     34                'has_paid_plans'      => false,
     35                'menu'                => array(
     36                    'first-path'     => 'plugins.php',
     37                    'account'        => false,
     38                    'contact'        => false,
     39                    'support'        => false,
     40                ),
     41            ) );
     42        }
     43
     44        return $wdao_fs;
     45    }
     46
     47    // Init Freemius.
     48    wdao_fs();
     49    // Signal that SDK was initiated.
     50    do_action( 'wdao_fs_loaded' );
     51}
     52
     53
    1854if (!class_exists('WooCommerce_Delete_all_orders')) {
    1955  class WooCommerce_Delete_all_orders {
    2056    public static $instance;
     57    public $deleted = 0;
    2158
    2259    public static function init() {
     
    3774
    3875    public function wc_delete_orders() {
    39       global $wpdb;
    40       $ran = true;
    41       $sql = "DELETE FROM wp_woocommerce_order_itemmeta";
    42       $sql = "DELETE FROM wp_woocommerce_order_items";
    43       $sql = "DELETE FROM wp_posts WHERE post_type = 'shop_order'";
    44       $rows = $wpdb->query( $sql );
     76    global $wpdb;
    4577
    46       if( false !== $rows ) {
    47         $this->deleted = $rows;
    48         //add_action( 'admin_notices', array( $this, 'admin_notice_success' ) );
     78    // 1. Clear order item meta first (depends on order_items)
     79      // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     80    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_itemmeta" );
     81
     82    // 2. Clear order items
     83    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     84    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_items" );
     85
     86    // 3. Clear all HPOS core tables
     87    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     88    $rows =  $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_orders" );
     89    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     90    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_addresses" );
     91    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     92    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_operational_data" );
     93    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     94    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_product_lookup" );
     95    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching   
     96    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_stats" );
     97    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
     98    $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_order_tax_lookup" );
     99      if ( false !== $rows ) {
     100          $this->deleted = $rows;
     101          // add_action( 'admin_notices', array( $this, 'admin_notice_success' ) );
    49102      }
    50103    }
     
    56109    public function add_woocommerce_tool( $tools ) {
    57110      $tools['wc_delete_orders'] = array(
    58         'name'    => __( 'Delete all orders', 'woocommerce' ),
    59         'button'  => __( 'Delete all orders', 'woocommerce' ),
    60         'desc'    => __( 'This option will delete all your orders — please use with caution!', 'woocommerce' ),
     111        'name'    => esc_html__( 'Delete all orders', 'wc-delete-orders' ),
     112        'button'  => esc_html__( 'Delete all orders', 'wc-delete-orders' ),
     113        'desc'    => esc_html__( 'This option will delete all your orders — please use with caution!', 'wc-delete-orders' ),
    61114        'callback' => array( $this, 'debug_notice_success' ),
    62115      );
     
    91144      }
    92145
    93       if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) {
     146      if ( ! empty( $_GET['action'] ) && ! empty( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) )) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'debug_action' ) ) {
    94147        if( $_GET['action'] === 'wc_delete_orders' ) {
    95148          $this->wc_delete_orders();
     
    106159    ?>
    107160<div class="notice notice-success is-dismissible">
    108   <p><?php echo wp_sprintf( __('%d orders were deleted.', 'woocommerce'), $deleted ); ?></p>
     161 
     162  <p><?php
     163  // translators: %d is the number of orders deleted
     164   echo esc_html( sprintf( __( '%d orders were deleted.', 'wc-delete-orders' ), $deleted ) );
     165  ?></p>
    109166</div>
    110167    <?php
Note: See TracChangeset for help on using the changeset viewer.