function amt_detect_ecommerce_product() { // Get the options the DB $options = get_option("add_meta_tags_opts"); // WooCommerce product if ($options["extended_support_woocommerce"] == "1" && amt_is_woocommerce_product()) { // Filter product data meta tags add_filter('amt_product_data_twitter_cards', 'amt_product_data_tc_woocommerce', 10, 2); add_filter('amt_product_data_opengraph', 'amt_product_data_og_woocommerce', 10, 2); if ($options["schemaorg_force_jsonld"] == "0") { add_filter('amt_product_data_schemaorg', 'amt_product_data_schemaorg_woocommerce', 10, 2); } else { add_filter('amt_product_data_jsonld_schemaorg', 'amt_product_data_jsonld_schemaorg_woocommerce', 10, 2); } return true; // Easy-Digital-Downloads product } elseif ($options["extended_support_edd"] == "1" && amt_is_edd_product()) { add_filter('amt_product_data_twitter_cards', 'amt_product_data_tc_edd', 10, 2); add_filter('amt_product_data_opengraph', 'amt_product_data_og_edd', 10, 2); if ($options["schemaorg_force_jsonld"] == "0") { add_filter('amt_product_data_schemaorg', 'amt_product_data_schemaorg_edd', 10, 2); } else { add_filter('amt_product_data_jsonld_schemaorg', 'amt_product_data_jsonld_schemaorg_edd', 10, 2); } return true; } return false; }
function amt_detect_ecommerce_product($default) { // First and important check. // $default is a boolean variable which indicates if custom content has been // detected by any previous filter. // Check if custom content has already been detected by another filter. // If such content has been detected, just return $default (should be true) // and *do not* add any metadata filters. // This check is mandatory in order the detection mechanism to work correctly. if ($default) { return $default; } // Get the options the DB $options = get_option("add_meta_tags_opts"); // WooCommerce product if ($options["extended_support_woocommerce"] == "1" && amt_is_woocommerce_product()) { // Filter product data meta tags add_filter('amt_product_data_twitter_cards', 'amt_product_data_tc_woocommerce', 10, 2); add_filter('amt_product_data_opengraph', 'amt_product_data_og_woocommerce', 10, 2); if ($options["schemaorg_force_jsonld"] == "0") { add_filter('amt_product_data_schemaorg', 'amt_product_data_schemaorg_woocommerce', 10, 2); } else { add_filter('amt_product_data_jsonld_schemaorg', 'amt_product_data_jsonld_schemaorg_woocommerce', 10, 2); } return true; // Easy-Digital-Downloads product } elseif ($options["extended_support_edd"] == "1" && amt_is_edd_product()) { add_filter('amt_product_data_twitter_cards', 'amt_product_data_tc_edd', 10, 2); add_filter('amt_product_data_opengraph', 'amt_product_data_og_edd', 10, 2); if ($options["schemaorg_force_jsonld"] == "0") { add_filter('amt_product_data_schemaorg', 'amt_product_data_schemaorg_edd', 10, 2); } else { add_filter('amt_product_data_jsonld_schemaorg', 'amt_product_data_jsonld_schemaorg_edd', 10, 2); } return true; } return false; }