Submit
Path:
~
/
home
/
getwphos
/
www
/
twinkletown
/
wp-content
/
backup
/
plugins
/
woocommerce
/
src
/
Internal
/
File Content:
AssignDefaultCategory.php
<?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' ); } } } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
Abilities
---
0755
AbilitiesApi
---
0755
AddressProvider
---
0755
Admin
---
0755
Agentic
---
0755
BatchProcessing
---
0755
CLI
---
0755
Caches
---
0755
ComingSoon
---
0755
CostOfGoodsSold
---
0755
Customers
---
0755
DataStores
---
0755
DependencyManagement
---
0755
Email
---
0755
EmailEditor
---
0755
Features
---
0755
Font
---
0755
Fulfillments
---
0755
Integrations
---
0755
Logging
---
0755
MCP
---
0755
Orders
---
0755
ProductAttributesLookup
---
0755
ProductDownloads
---
0755
ProductFilters
---
0755
ProductImage
---
0755
PushNotifications
---
0755
ReceiptRendering
---
0755
RestApi
---
0755
Settings
---
0755
StockNotifications
---
0755
Traits
---
0755
TransientFiles
---
0755
Utilities
---
0755
WCCom
---
0755
AssignDefaultCategory.php
2001 bytes
0644
Brands.php
1300 bytes
0644
DownloadPermissionsAdjuster.php
6678 bytes
0644
McStats.php
2149 bytes
0644
OrderCouponDataMigrator.php
8528 bytes
0644
RegisterHooksInterface.php
504 bytes
0644
RestApiControllerBase.php
8207 bytes
0644
RestApiParameterUtil.php
5854 bytes
0644
RestockRefundedItemsAdjuster.php
2129 bytes
0644
N4ST4R_ID | Naxtarrr