diff --git a/assets/js/admin/products-admin.js b/assets/js/admin/products-admin.js
index ac9d209a2..7cf1afffd 100644
--- a/assets/js/admin/products-admin.js
+++ b/assets/js/admin/products-admin.js
@@ -667,76 +667,6 @@ jQuery( document ).ready( function( $ ) {
// toggle Sell on Instagram checkbox on page load
toggleFacebookSellOnInstagramSetting( isProductReadyForCommerce(), facebookSettingsPanel );
- let submitProductSave = false;
-
- $( 'form#post input[type="submit"]' ).on( 'click', function( e ) {
-
- if ( shouldShowMissingGoogleProductCategoryAlert() ) {
- return showMissingGoogleProductCategoryAlert( e );
- }
-
- if ( ! submitProductSave ) {
- e.preventDefault();
- } else {
- return true;
- }
-
- let $submitButton = $( this ),
- productID = parseInt( $( 'input#post_ID' ).val(), 10 ),
- productCat = [],
- // this query will get tags when not using checkboxes
- productTag = $( 'textarea[name="tax_input[product_tag]"]' ).length ? $( 'textarea[name="tax_input[product_tag]"]' ).val().split( ',' ) : [],
- syncEnabled = simpleProductSyncModeSelect.val() !== 'sync_disabled',
- varSyncEnabled = isSyncEnabledForVariableProduct();
-
- $( '#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked' ).each( function() {
- productCat.push( parseInt( $( this ).val(), 10 ) );
- } );
-
- // this query will get tags when using checkboxes
- $( '#taxonomy-product_tag input[name="tax_input[product_tag][]"]:checked' ).each( function() {
- productTag.push( parseInt( $( this ).val(), 10 ) );
- } );
-
- if ( productID > 0 ) {
-
- $.post( facebook_for_woocommerce_products_admin.ajax_url, {
- action: 'facebook_for_woocommerce_set_product_sync_prompt',
- security: facebook_for_woocommerce_products_admin.set_product_sync_prompt_nonce,
- sync_enabled: syncEnabled ? 'enabled' : 'disabled',
- var_sync_enabled: varSyncEnabled ? 'enabled' : 'disabled',
- product: productID,
- categories: productCat,
- tags: productTag
- }, function( response ) {
-
- // open modal if visibility checkbox is checked or if there are conflicting terms set for sync exclusion
- if ( response && ! response.success && syncEnabled ) {
-
- closeExistingModal();
-
- // open new modal, populate template with AJAX response data
- new $.WCBackboneModal.View( {
- target: 'facebook-for-woocommerce-modal',
- string: response.data
- } );
-
- } else {
-
- // no modal displayed: submit form as normal
- submitProductSave = true;
- $submitButton.trigger( 'click' );
- }
- } );
-
- } else {
-
- // no modal displayed: submit form as normal
- submitProductSave = true;
- $submitButton.trigger( 'click' );
- }
-
- } );
}
diff --git a/includes/AJAX.php b/includes/AJAX.php
index b5161a5fd..b92243f1d 100644
--- a/includes/AJAX.php
+++ b/includes/AJAX.php
@@ -34,8 +34,7 @@ class AJAX {
*/
public function __construct() {
- // maybe output a modal prompt when toggling product sync in bulk or individual product actions
- add_action( 'wp_ajax_facebook_for_woocommerce_set_product_sync_prompt', array( $this, 'handle_set_product_sync_prompt' ) );
+ // maybe output a modal prompt when toggling product sync in bulk
add_action( 'wp_ajax_facebook_for_woocommerce_set_product_sync_bulk_action_prompt', array( $this, 'handle_set_product_sync_bulk_action_prompt' ) );
// maybe output a modal prompt when setting excluded terms
@@ -158,111 +157,6 @@ public function get_sync_status() {
}
- /**
- * Maybe triggers a modal warning when the merchant toggles sync enabled status on a product.
- *
- * @internal
- *
- * @since 1.10.0
- */
- public function handle_set_product_sync_prompt() {
-
- check_ajax_referer( 'set-product-sync-prompt', 'security' );
-
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $product_id = isset( $_POST['product'] ) ? (int) wc_clean( wp_unslash( $_POST['product'] ) ) : 0;
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $sync_enabled = isset( $_POST['sync_enabled'] ) ? (string) wc_clean( wp_unslash( $_POST['sync_enabled'] ) ) : '';
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $var_sync_enabled = isset( $_POST['var_sync_enabled'] ) ? (string) wc_clean( wp_unslash( $_POST['var_sync_enabled'] ) ) : '';
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $product_cats = isset( $_POST['categories'] ) ? (array) wc_clean( wp_unslash( $_POST['categories'] ) ) : array();
- // phpcs:ignore WordPress.Security.NonceVerification.Recommended
- $product_tags = isset( $_POST['tags'] ) ? (array) wc_clean( wp_unslash( $_POST['tags'] ) ) : array();
-
- if ( $product_id > 0 && in_array( $var_sync_enabled, array( 'enabled', 'disabled' ), true ) && in_array( $sync_enabled, array( 'enabled', 'disabled' ), true ) ) {
-
- $product = wc_get_product( $product_id );
-
- if ( $product instanceof \WC_Product ) {
-
- if ( ( 'enabled' === $sync_enabled && ! $product->is_type( 'variable' ) ) || ( 'enabled' === $var_sync_enabled && $product->is_type( 'variable' ) ) ) {
-
- $has_excluded_terms = false;
-
- if ( $integration = facebook_for_woocommerce()->get_integration() ) {
-
- // Try with categories first, since we have already IDs.
- $has_excluded_terms = ! empty( $product_cats ) && array_intersect( $product_cats, $integration->get_excluded_product_category_ids() );
-
- // The form post can send an array with empty items, so filter them out.
- $product_tags = array_filter( $product_tags, 'strlen' );
-
- // Try next with tags, but WordPress only gives us tag names.
- if ( ! $has_excluded_terms && ! empty( $product_tags ) ) {
-
- $product_tag_ids = array();
-
- foreach ( $product_tags as $product_tag_name_or_id ) {
-
- $term = get_term_by( 'name', $product_tag_name_or_id, 'product_tag' );
-
- if ( $term instanceof \WP_Term ) {
-
- $product_tag_ids[] = $term->term_id;
-
- } else {
-
- $term = get_term( (int) $product_tag_name_or_id, 'product_tag' );
-
- if ( $term instanceof \WP_Term ) {
- $product_tag_ids[] = $term->term_id;
- }
- }
- }
-
- $has_excluded_terms = ! empty( $product_tag_ids ) && array_intersect( $product_tag_ids, $integration->get_excluded_product_tag_ids() );
- }
- }
-
- if ( $has_excluded_terms ) {
-
- ob_start();
-
- ?>
-
-
- sprintf(
- /* translators: Placeholder %s - tag */
- __( 'This product belongs to a category or tag that is excluded from the Facebook catalog sync. It will not sync to Facebook. %sTo sync this product to Facebook, click Go to Settings and remove the category or tag exclusion or click Cancel and update the product\'s category / tag assignments.', 'facebook-for-woocommerce' ),
- '
'
- ),
- 'buttons' => $buttons,
- )
- );
- }
- }
- }
- }
-
- wp_send_json_success();
- }
-
-
/**
* Maybe triggers a modal warning when the merchant toggles sync enabled status in bulk.
*
diff --git a/includes/Admin.php b/includes/Admin.php
index 4b00dea06..beb14d755 100644
--- a/includes/Admin.php
+++ b/includes/Admin.php
@@ -73,8 +73,6 @@ public function __construct() {
$this->product_sets = new Admin\Product_Sets();
// add a modal in admin product pages
add_action( 'admin_footer', array( $this, 'render_modal_template' ) );
- // may trigger the modal to open to warn the merchant about a conflict with the current product terms
- add_action( 'admin_footer', array( $this, 'validate_product_excluded_terms' ) );
// add admin notice to inform that disabled products may need to be deleted manually
add_action( 'admin_notices', array( $this, 'maybe_show_product_disabled_sync_notice' ) );
@@ -1518,58 +1516,4 @@ public function render_modal_template() {
}
- /**
- * Maybe triggers the modal to open on the product edit screen on page load.
- *
- * If the product is set to be synced in Facebook, but belongs to a term that is set to be excluded, the modal prompts the merchant for action.
- *
- * @internal
- *
- * @since 1.10.0
- */
- public function validate_product_excluded_terms() {
- global $current_screen, $post;
- if ( $post && $current_screen && $current_screen->id === 'product' ) :
- $product = wc_get_product( $post );
- if ( $product instanceof \WC_Product
- && Products::is_sync_enabled_for_product( $product )
- && Products::is_sync_excluded_for_product_terms( $product )
- ) :
- ?>
-
-