'post', 'post_status' => 'publish', 'paged' => $page, 'posts_per_page' => 12, 's' => $search, ]; if ($tag) { $args['tag_slug__in'] = [$tag]; } $posts = new WP_Query($args); ob_start(); if ($posts -> have_posts()) { while ($posts -> have_posts()) { $posts -> the_post(); ?>

No Posts Found!"; } $result = ob_get_clean(); wp_reset_postdata(); $pagiation = insertPagination($page, $posts -> max_num_pages, true); echo json_encode(['result' => $result, 'pagination' => $pagiation]); wp_die(); } public function action_ws_resource_filter() { ob_start(); $page = (array_key_exists('page_id', $_POST) && !empty($_POST['page_id'])) ? $_POST['page_id'] : 1; $search = $_POST['search']; $type = $_POST['type']; $product = $_POST['product']; $industry = $_POST['industry']; $platform = $_POST['platform']; $sortOrder = !empty($_POST['sortOrder']) && $_POST['sortOrder'] == 'asc' ? 'ASC' : 'DESC'; $taxQuery = ['relation' => 'AND']; $postType = 'resources'; if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], '/case-studies') !== false) { $postType = 'case-study'; } $termName = $termDesc = ''; if ($type != '') { $typeTerm = get_term_by('slug', $type, 'resources_type'); if (!is_wp_error($typeTerm)) { $termName = $typeTerm -> name; $termDesc = $typeTerm -> description; } } if ($postType === 'resources' && !empty($type)) { $taxQuery[] = [ 'taxonomy' => 'resources_type', 'field' => 'slug', 'terms' => $type, ]; } if (!empty($product)) { $taxQuery[] = [ 'taxonomy' => 'wherescape-product', 'field' => 'slug', 'terms' => explode('|', $product), ]; } if (!empty($industry)) { $taxQuery[] = [ 'taxonomy' => 'industry', 'field' => 'slug', 'terms' => explode('|', $industry), ]; } if (!empty($platform)) { $taxQuery[] = [ 'taxonomy' => 'platform', 'field' => 'slug', 'terms' => explode('|', $platform), ]; } $resourceQuery = [ //'post_type' => 'resources', 'post_type' => $postType, 'post_status' => 'publish', 'paged' => $page, 'posts_per_page' => 12, 'order' => $sortOrder, 'orderby'=> 'date', 's' => $search, 'tax_query' => $taxQuery, ]; $resources = new WP_Query($resourceQuery); if ($resources -> have_posts()) { while ($resources -> have_posts()) { $resources -> the_post(); ?>
No Resources Found. "; } wp_reset_postdata(); $result = ob_get_clean(); $pagiation = insertPagination($page, $resources -> max_num_pages, true); echo json_encode(['result' => $result, 'pagination' => $pagiation, 'term' => ['name' => $termName, 'description' => $termDesc]]); die(); } public function action_ws_customer_filter() { ob_start(); $page = (array_key_exists('page_id', $_POST) && !empty($_POST['page_id'])) ? $_POST['page_id'] : 1; $search = $_POST['search']; $industry = $_POST['industry']; $platform = $_POST['platform']; $taxQuery = ['relation' => 'AND']; if (!empty($industry)) { $taxQuery[] = [ 'taxonomy' => 'industry', 'field' => 'slug', 'terms' => explode('|', $industry), ]; } if (!empty($platform)) { $taxQuery[] = [ 'taxonomy' => 'platform', 'field' => 'slug', 'terms' => explode('|', $platform), ]; } $customers = new WP_Query([ 'post_type' => 'customers', 'post_status' => 'publish', 'paged' => $page, 'posts_per_page' => 12, 's' => $search, 'tax_query' => $taxQuery, ]); if ($customers -> have_posts()) { while ($customers -> have_posts()) { $customers -> the_post(); ?>
No Customers Found. "; } wp_reset_postdata(); $result = ob_get_clean(); $pagiation = insertPagination($page, $customers -> max_num_pages); echo json_encode(['result' => $result, 'pagination' => $pagiation]); die(); } public function action_ws_get_country_field() { //? Check CSRF protection if (!wp_verify_nonce($_POST['csrf'], 'wherescape')) { echo json_encode(['status' => 'error', 'body' => 'CSRF Error']); die; } $ip = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR'); if (strpos($ip, ',')) { //? check if more than two IP addresses are available $ips = explode(',', $ip); $ip = reset($ips); } $ip = trim($ip); $apiKey = '6f625f9a9c9cda577f8926b67964d9d6'; $request = new WP_Http; $result = $request -> request("https://api.ipstack.com/$ip?access_key=$apiKey"); if (is_wp_error($result)) { echo json_encode(['status' => 'error', 'message' => 'Something went wrong with request!'.$result -> get_error_message()]); } else { $data = json_decode($result['body']); $stateCode = (in_array($data -> country_code, ['US', 'CA'])) ? $data -> region_code : ''; echo json_encode(['status' => 'success', 'country' => $data -> country_code, 'region_code' => $stateCode, 'ip' => $ip]); } die; } // public function add_cookie_script_if_divi_not_active() // { // if (!(array_key_exists('et_fb', $_GET) && is_user_logged_in() && current_user_can('edit_posts'))) { // echo ''; // } // } public function action_resources_is_featured_column_to_post_value($column, $post_id) { if ($column == 'featured_posts') { echo get_field('is_resources_featured_post', $post_id) ? 'Yes' : ''; } } public function action_resources_is_featured_column_to_post_value_sortable($query) { if (!is_admin() || !$query -> is_main_query()) { return; } if ('featured_posts' === $query -> get('orderby')) { $query -> set('orderby', 'meta_value'); $query -> set('meta_key', 'is_resources_featured_post'); } } public function action_events_settings_page() { if (function_exists('acf_add_options_page')) { acf_add_options_page([ 'page_title' => 'Events Settings', 'menu_title' => 'Events Settings', 'menu_slug' => 'events-settings-page', 'update_button' => 'save setting', 'parent_slug' => 'edit.php?post_type=events' ]); } } public function no_eloqua_form_customer_registration_form() { $secreteKey = '6Ldjdf4kAAAAAODlPJXSMtq99TltnlgLSkFPX0RA'; $captcha = $_POST['g-recaptcha-response']; $captchaRes = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secreteKey&response=$captcha&remoteip=".$_SERVER['REMOTE_ADDR']), true); if (!$captchaRes['success']) { echo json_encode(['status' => 'error', 'msg' => 'Failed to verify reCaptcha. Try again after sometime.']); wp_die(); } $fname = $_POST['FirstName']; $lname = $_POST['LastName']; $email = $_POST['Email']; $company = $_POST['Company']; $mobile = $_POST['BusinessPhone']; $country = $_POST['Country']; $state = $_POST['StateandProvince']; $city = $_POST['city']; $dateTime = date('dS M Y, h:i:sa'); $emailTo = 'support@wherescape.com'; $subject = "Customer Registration Form Submission from $email"; $body = " < b > First Name: $fname < br > Last Name: $lname < br > Email: $email < br > Company: $company < br > Mobile: $mobile < br > Country: $country < br > State: $state < br > City: $city < br > Submission Date-Time: $dateTime < br > "; $headers = array('Content-Type: text/html; charset=UTF-8'); $emailRes = wp_mail($emailTo, $subject, $body, $headers); $csvData = "$fname, $lname, $email, $company, $mobile, $country, $state, $city \r\n"; $fileRes = file_put_contents(get_stylesheet_directory(). '/failed_emails_customer_registration_log.csv', $csvData, FILE_APPEND); if (!$emailRes) { } if ($emailRes || $fileRes) { echo json_encode(['status' => 'success', 'msg' => 'Form submitted successfully!']); } else { echo json_encode(['status' => 'error', 'msg' => 'Something went wrong! Please try again later.']); } wp_die(); } } WS_Actions:: getInstance(); WhereScape® Blog | WhereScape
Select Page