Created
December 8, 2025 09:27
-
-
Save webtoffee-git/f7c9957e1ff88be18ee02178f625bf25 to your computer and use it in GitHub Desktop.
Code snippet to disables the additional Category Mapping fields added by the WebToffee Product Feed & Sync Manager plugin (Facebook, Google, Fruugo, OnBuy, etc.) on the Product Category page - By WebToffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php //Do not copy this line of code | |
| add_action( 'admin_init', 'wt_remove_category_mapping_fields', 999 ); | |
| function wt_remove_category_mapping_fields() { | |
| global $wp_filter; | |
| // Remove Facebook Category field (function-based) | |
| remove_action( 'product_cat_edit_form_fields', 'wt_fbfeed_category_form_fields', 10 ); | |
| remove_action( 'product_cat_add_form_fields', 'wt_fbfeed_category_form_fields', 10 ); | |
| // Remove all callbacks from the hooks using global $wp_filter | |
| $hooks_to_clean = array( 'product_cat_edit_form_fields', 'product_cat_add_form_fields' ); | |
| foreach ( $hooks_to_clean as $hook ) { | |
| if ( isset( $wp_filter[ $hook ] ) && isset( $wp_filter[ $hook ]->callbacks[10] ) ) { | |
| foreach ( $wp_filter[ $hook ]->callbacks[10] as $callback_key => $callback_data ) { | |
| $callback = $callback_data['function']; | |
| // Remove Facebook field callback | |
| if ( is_string( $callback ) && $callback === 'wt_fbfeed_category_form_fields' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Remove Google field callback | |
| if ( is_array( $callback ) && | |
| isset( $callback[0] ) && | |
| is_string( $callback[0] ) && | |
| $callback[0] === 'Webtoffee_Product_Feed_Sync_Google' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Remove Fruugo field callback | |
| if ( is_array( $callback ) && | |
| isset( $callback[0] ) && | |
| is_string( $callback[0] ) && | |
| $callback[0] === 'Webtoffee_Product_Feed_Sync_Fruugo' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields_pro' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Remove OnBuy field callback | |
| if ( is_array( $callback ) && | |
| isset( $callback[0] ) && | |
| is_string( $callback[0] ) && | |
| $callback[0] === 'Webtoffee_Product_Feed_Sync_OnBuy' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields_pro' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Also check for object instances (when callback[0] is an object) | |
| if ( is_array( $callback ) && | |
| isset( $callback[0] ) && | |
| is_object( $callback[0] ) ) { | |
| $class_name = get_class( $callback[0] ); | |
| // Remove Google field callback (object instance) | |
| if ( $class_name === 'Webtoffee_Product_Feed_Sync_Google' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Remove Fruugo field callback (object instance) | |
| if ( $class_name === 'Webtoffee_Product_Feed_Sync_Fruugo' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields_pro' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| // Remove OnBuy field callback (object instance) | |
| if ( $class_name === 'Webtoffee_Product_Feed_Sync_OnBuy' && | |
| isset( $callback[1] ) && | |
| $callback[1] === 'wt_fbfeed_category_form_fields_pro' ) { | |
| unset( $wp_filter[ $hook ]->callbacks[10][ $callback_key ] ); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment