'; foreach ($custom_statuses as $slug => $status_data) { $bg_color = $status_data['statusColor'] ?? '#080604'; $text_color = '#080604'; // Fixed text color echo '.order-status.status-' . esc_attr(str_replace('wc-', '', $slug)) . ' {'; echo ' background: ' . esc_attr($bg_color) . ';'; echo ' color: ' . esc_attr($text_color) . ';'; echo '}'; if (!empty($status_data['dashicon'])) { $icon = $status_data['dashicon']; if (strpos($icon, '\\') !== 0 && strpos($icon, 'f') === 0) { $icon = '\\' . $icon; } echo '.order-status.status-' . esc_attr(str_replace('wc-', '', $slug)) . '::before {'; echo ' font-family: dashicons;'; echo ' content: "' . esc_attr($icon) . '";'; echo ' margin-right: 4px;'; echo ' vertical-align: middle;'; echo '}'; } } echo ''; } public function add_custom_status_bulk_actions($bulk_actions) { $custom_statuses = get_option('asofw_custom_statuses', array()); foreach ($custom_statuses as $slug => $status_data) { // Remove 'wc-' prefix if it exists $action_slug = str_replace('wc-', '', $slug); /* translators: %s: Status name */ $bulk_actions['mark_' . $action_slug] = sprintf( /* translators: %s: Status name */ esc_html__('Change status to %s', 'advanced-order-status-for-woocommerce'), esc_html($status_data['statusName']) ); } return $bulk_actions; } public function process_custom_status_bulk_actions($redirect_to, $action, $post_ids) { $custom_statuses = get_option('asofw_custom_statuses', array()); foreach ($custom_statuses as $slug => $status_data) { $action_slug = str_replace('wc-', '', $slug); if ('mark_' . $action_slug === $action) { $changed = 0; foreach ($post_ids as $post_id) { $order = wc_get_order($post_id); if ($order) { $order->update_status( $action_slug, __('Status changed via bulk action', 'advanced-order-status-for-woocommerce'), true ); $changed++; } } $redirect_to = add_query_arg(array( 'changed' => $changed, 'ids' => join(',', $post_ids), 'custom_status_updated' => true ), $redirect_to); break; } } return $redirect_to; } // public function custom_status_admin_notice() { // $data = $_REQUEST; // if (!empty($data['custom_status_updated']) && !empty($data['changed'])) { // $count = intval($data['changed']); // $message = wp_kses( // sprintf( // /* translators: %d: Number of orders updated */ // _n( // '%d order status updated.', // '%d order statuses updated.', // $count, // 'advanced-order-status-for-woocommerce' // ), // esc_html($count) // ), // array('p' => array()) // ); // printf( // '
%s