__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* AssignDefaultCategory class file.
*/
namespace Automattic\WooCommerce\Internal;
defined( 'ABSPATH' ) || exit;
/**
* Class to assign default category to products.
*/
class AssignDefaultCategory {
/**
* Class initialization, to be executed when the class is resolved by the container.
*
* @internal
*/
final public function init() {
add_action( 'wc_schedule_update_product_default_cat', array( $this, 'maybe_assign_default_product_cat' ) );
}
/**
* When a product category is deleted, we need to check
* if the product has no categories assigned. Then assign
* it a default category. We delay this with a scheduled
* action job to not block the response.
*
* @return void
*/
public function schedule_action() {
WC()->queue()->schedule_single(
time(),
'wc_schedule_update_product_default_cat',
array(),
'wc_update_product_default_cat'
);
}
/**
* Assigns default product category for products
* that have no categories.
*
* @return void
*/
public function maybe_assign_default_product_cat() {
global $wpdb;
$default_category = get_option( 'default_product_cat', 0 );
if ( $default_category ) {
$affected_rows = $wpdb->query(
$wpdb->prepare(
"INSERT INTO {$wpdb->term_relationships} (object_id, term_taxonomy_id)
SELECT DISTINCT posts.ID, %s FROM {$wpdb->posts} posts
LEFT JOIN
(
SELECT object_id FROM {$wpdb->term_relationships} term_relationships
LEFT JOIN {$wpdb->term_taxonomy} term_taxonomy ON term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id
WHERE term_taxonomy.taxonomy = 'product_cat'
) AS tax_query
ON posts.ID = tax_query.object_id
WHERE posts.post_type = 'product'
AND tax_query.object_id IS NULL",
$default_category
)
);
if ( $affected_rows > 0 ) {
wp_cache_flush();
delete_transient( 'wc_term_counts' );
wp_update_term_count_now( array( $default_category ), 'product_cat' );
}
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Abilities | Folder | 0775 |
|
|
| AbilitiesApi | Folder | 0775 |
|
|
| AddressProvider | Folder | 0775 |
|
|
| Admin | Folder | 0775 |
|
|
| Agentic | Folder | 0775 |
|
|
| BatchProcessing | Folder | 0775 |
|
|
| CLI | Folder | 0775 |
|
|
| Caches | Folder | 0775 |
|
|
| ComingSoon | Folder | 0775 |
|
|
| CostOfGoodsSold | Folder | 0775 |
|
|
| Customers | Folder | 0775 |
|
|
| DataStores | Folder | 0775 |
|
|
| DependencyManagement | Folder | 0775 |
|
|
| Folder | 0775 |
|
||
| EmailEditor | Folder | 0775 |
|
|
| Features | Folder | 0775 |
|
|
| Font | Folder | 0775 |
|
|
| Fulfillments | Folder | 0775 |
|
|
| Integrations | Folder | 0775 |
|
|
| Logging | Folder | 0775 |
|
|
| MCP | Folder | 0775 |
|
|
| Orders | Folder | 0775 |
|
|
| ProductAttributesLookup | Folder | 0775 |
|
|
| ProductDownloads | Folder | 0775 |
|
|
| ProductFilters | Folder | 0775 |
|
|
| ProductImage | Folder | 0775 |
|
|
| PushNotifications | Folder | 0775 |
|
|
| ReceiptRendering | Folder | 0775 |
|
|
| RestApi | Folder | 0775 |
|
|
| Settings | Folder | 0775 |
|
|
| StockNotifications | Folder | 0775 |
|
|
| Traits | Folder | 0775 |
|
|
| TransientFiles | Folder | 0775 |
|
|
| Utilities | Folder | 0775 |
|
|
| WCCom | Folder | 0775 |
|
|
| AssignDefaultCategory.php | File | 1.95 KB | 0664 |
|
| Brands.php | File | 1.27 KB | 0664 |
|
| DownloadPermissionsAdjuster.php | File | 6.52 KB | 0664 |
|
| McStats.php | File | 2.1 KB | 0664 |
|
| OrderCouponDataMigrator.php | File | 8.33 KB | 0664 |
|
| RegisterHooksInterface.php | File | 504 B | 0664 |
|
| RestApiControllerBase.php | File | 8.01 KB | 0664 |
|
| RestApiParameterUtil.php | File | 5.72 KB | 0664 |
|
| RestockRefundedItemsAdjuster.php | File | 2.08 KB | 0664 |
|