Automattic\WooCommerce\Internal\DataStores\Orders
LegacyDataCleanup::get_tools_entries
Returns an array in format required by woocommerce_debug_tools register the cleanup tool in WC.
Method of the class: LegacyDataCleanup{}
No Hooks.
Returns
Array. Tools entries to register with WC.
Usage
$LegacyDataCleanup = new LegacyDataCleanup(); $LegacyDataCleanup->get_tools_entries();
LegacyDataCleanup::get_tools_entries() LegacyDataCleanup::get tools entries code WC 10.3.5
public function get_tools_entries() {
$orders_for_cleanup_exist = ! empty( $this->legacy_handler->get_orders_for_cleanup( array(), 1 ) );
$entry_id = $this->is_flag_set() ? 'hpos_legacy_cleanup_cancel' : 'hpos_legacy_cleanup';
$entry = array(
'name' => __( 'Clean up order data from legacy tables', 'woocommerce' ),
'desc' => __( 'This tool will clear the data from legacy order tables in WooCommerce.', 'woocommerce' ),
'requires_refresh' => true,
'button' => __( 'Clear data', 'woocommerce' ),
'disabled' => ! ( $this->can_run() && ( $orders_for_cleanup_exist || $this->is_flag_set() ) ),
);
if ( ! $this->can_run() ) {
$entry['desc'] .= '<br />';
$entry['desc'] .= sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
__( 'Only available when HPOS is authoritative and compatibility mode is disabled.', 'woocommerce' )
);
} else {
if ( $this->is_flag_set() ) {
$entry['status_text'] = sprintf(
'%1$s %2$s',
'<span class="dashicons dashicons-update spin"></span>',
__( 'Clearing data...', 'woocommerce' )
);
$entry['button'] = __( 'Cancel', 'woocommerce' );
$entry['callback'] = function() {
$this->toggle_flag( false );
return __( 'Order legacy data cleanup has been canceled.', 'woocommerce' );
};
} elseif ( ! $orders_for_cleanup_exist ) {
$entry['button'] = __( 'No orders in need of cleanup', 'woocommerce' );
} else {
$entry['callback'] = function() {
$this->toggle_flag( true );
return __( 'Order legacy data cleanup process has been started.', 'woocommerce' );
};
}
}
return array( $entry_id => $entry );
}