$name, 'available' => $available, ); if (!tinv_get_option('integrations', $slug)) { return; } if (!$available) { return; } if (class_exists('Addify_Woo_Hide_Price_Front')) { function tinvwl_check_class_action($tag, $class, $method) { global $wp_filter; if (isset($wp_filter[$tag])) { $len = strlen($method); foreach ($wp_filter[$tag] as $_priority => $actions) { if ($actions) { foreach ($actions as $function_key => $data) { if ($data) { if (substr($function_key, -$len) == $method) { if ($class !== '') { if (is_string($data['function'][0])) { $_class = $data['function'][0]; } elseif (is_object($data['function'][0])) { $_class = get_class($data['function'][0]); } else { return false; } if ($_class !== '' && $_class == $class) { return true; } } else { return true; } } } } } } } return false; } add_action('woocommerce_single_product_summary', 'tinvwl_afwhp_hooks', 31); add_action('woocommerce_single_variation', 'tinvwl_afwhp_hooks', 31); function tinvwl_afwhp_hooks() { $simple = tinvwl_check_class_action('woocommerce_single_product_summary', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement'); if ($simple) { add_action('woocommerce_single_product_summary', 'tinvwl_view_addto_html', 32); add_action('woocommerce_single_product_summary', 'tinvwl_view_addto_htmlout', 32); } $variable = tinvwl_check_class_action('woocommerce_single_variation', 'Addify_Woo_Hide_Price_Front', 'afwhp_custom_button_replacement'); if ($variable) { add_action('woocommerce_single_variation', 'tinvwl_view_addto_html', 32); add_action('woocommerce_single_variation', 'tinvwl_view_addto_htmlout', 32); ob_start(); ?> 'addify_whp', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); $rules = get_posts($args); foreach ($rules as $rule) { $afwhp_rule_type = get_post_meta(intval($rule->ID), 'afwhp_rule_type', true); $afwhp_hide_products = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_products', true)); $afwhp_hide_categories = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_categories', true)); $afwhp_hide_user_role = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_user_role', true)); $afwhp_is_hide_addtocart = get_post_meta(intval($rule->ID), 'afwhp_is_hide_addtocart', true); $afwhp_custom_button_text = get_post_meta(intval($rule->ID), 'afwhp_custom_button_text', true); $afwhp_custom_button_link = get_post_meta(intval($rule->ID), 'afwhp_custom_button_link', true); $afwhp_contact7_form = get_post_meta(intval($rule->ID), 'afwhp_contact7_form', true); $afwhp_hide_for_countries = unserialize(get_post_meta(intval($rule->ID), 'afwhp_hide_for_countries', true)); if (!empty($afwhp_hide_for_countries)) { //country if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = sanitize_meta('', $_SERVER['REMOTE_ADDR'], ''); } else { $ip = ''; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.geoplugin.net/json.gp?ip=' . $ip); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $ip_data_in = curl_exec($ch); // string curl_close($ch); $ip_data = json_decode($ip_data_in, true); $ip_data = str_replace('"', '"', $ip_data); // for PHP 5.2 see stackoverflow.com/questions/3110487/ if ($ip_data && null != $ip_data['geoplugin_countryCode']) { $country = $ip_data['geoplugin_countryCode']; } $curr_country = $country; } else { $curr_country = ''; } $istrue = false; if (!empty($afwhp_hide_for_countries) && in_array($curr_country, $afwhp_hide_for_countries)) { $iscountry = true; } elseif (empty($afwhp_hide_for_countries)) { $iscountry = true; } else { $iscountry = false; } $applied_on_all_products = get_post_meta($rule->ID, 'afwhp_apply_on_all_products', true); //Registered Users if ('afwhp_for_registered_users' == $afwhp_rule_type) { if (is_user_logged_in()) { // get Current User Role $curr_user = wp_get_current_user(); $user_data = get_user_meta($curr_user->ID); $curr_user_role = $curr_user->roles[0]; if ('yes' == $applied_on_all_products && empty($afwhp_hide_user_role)) { $istrue = true; } elseif ((is_array($afwhp_hide_user_role) && in_array($curr_user_role, $afwhp_hide_user_role)) && 'yes' == $applied_on_all_products) { $istrue = true; } elseif ((is_array($afwhp_hide_user_role) && in_array($curr_user_role, $afwhp_hide_user_role)) && (is_array($afwhp_hide_products) && in_array($product->get_id(), $afwhp_hide_products))) { $istrue = true; } //Products if ($istrue && $iscountry) { if ('yes' == $afwhp_is_hide_addtocart) { if ('' == $afwhp_custom_button_text) { echo ''; } else { if (!empty($afwhp_custom_button_link)) { echo '' . esc_attr($afwhp_custom_button_text) . ''; } elseif (!empty($afwhp_contact7_form)) { $contact7 = get_post($afwhp_contact7_form); $form_title = $contact7->post_title; ?>