Services Review
Most novice traders look for the right software to improve their game. Read our reviews and find out how each software can help you in trading. Detailed and honest opinions from our experts await you!
add_action('wp_ajax_hc_loadmore', 'hc_loadmore_callback'); add_action('wp_ajax_nopriv_hc_loadmore', 'hc_loadmore_callback'); function hc_loadmore_callback() { $args = unserialize(stripslashes($_POST['query'])); $args['paged'] = $_POST['page'] * 1 + 1; // следующая страница query_posts($args); global $n; $n = 1; // если посты есть if (have_posts()) : if (!empty($args['s']) || is_author()) : $path = 'template-parts/loops/search'; else : $ISsearch = false; if ($args['taxonomy'] == 'bonus-cat') { $path = 'template-parts/loops/bonus'; } else { switch ($args['post_type']) { case 'bonus': $path = 'template-parts/loops/bonus'; break; default: if (is_category()) $path = 'template-parts/loops/posts'; else $path = 'template-parts/loops/posts-archive'; break; } } endif; while (have_posts()): the_post(); get_template_part($path); endwhile; endif; wp_die(); } function hc_loadmore($box, $name) { $name = 'More'; global $wp_query; if ($wp_query->max_num_pages > 1) { ?> wp_enqueue_script('loadmore-js', get_template_directory_uri() . '/inc/loadmore/loadmore.js', array('jquery-core', 'jquery'), null, true); ?> } } add_action('wp_ajax_callback_sendpulse', 'callback_sendpulse'); add_action('wp_ajax_nopriv_callback_sendpulse', 'callback_sendpulse'); function callback_sendpulse() { $response = array(); // if ( empty($_POST['email']) || empty($_POST['confidentiality']) ) { if ( empty($_POST['email']) ) { $response['error'] = 'Enter your email'; $response['code'] = 1; wp_die(json_encode($response)); } if ( !is_email($_POST['email']) ) { $response['error'] = 'Invalid email.'; $response['code'] = 10; wp_die(json_encode($response)); } require("src/ApiInterface.php"); require("src/ApiClient.php"); require("src/Storage/TokenStorageInterface.php"); require("src/Storage/FileStorage.php"); require("src/Storage/SessionStorage.php"); require("src/Storage/MemcachedStorage.php"); require("src/Storage/MemcacheStorage.php"); // API credentials from https://login.sendpulse.com/settings/#api define('API_USER_ID', 'bdb63a2a3ce356940d72bad481983589'); define('API_SECRET', '618da125a934f3b969ad44c6eae5a408'); define('PATH_TO_ATTACH_FILE', '/home/g/geparo123/thetrader.bet/public_html/wp-content/themes/thetrader/inc/sendpulse/'); if ( !class_exists('ApiClient', false) ) { $response['error'] = 'An error has occurred. Please contact the administrator.'; $response['code'] = 100; wp_die(json_encode($response)); } $book = 'Subscribe from the site'; $data = add_new_email($_POST['email'], $book); if ( !empty($data) && $data->result == true ) { $response['success'] = 'Congratulations, you have subscribed to the newsletter.'; wp_die(json_encode($response)); } else { $response['error'] = 'An error has occurred. Please contact the administrator.'; $response['code'] = 200; wp_die(json_encode($response)); } wp_die(json_encode($response)); } function add_new_email($email, $bookName) { $SPApiClient = new ApiClient(API_USER_ID, API_SECRET, new FileStorage()); $bookID = find_address_book($bookName); $emails = array( 'email' => $email, ); // $additionalParams = array( // 'confirmation' => 'force', // ); $response = $SPApiClient->addEmails($bookID, $emails); return $response; } function find_address_book($bookName) { $json = file_get_contents(PATH_TO_ATTACH_FILE . 'books.txt'); if ( !empty($json) ) { $json = json_decode($json, true); $bookID = array_search($bookName, $json); } if ( empty($bookID) ) : $bookID = create_address_book($bookName); endif; return $bookID; } function create_address_book($bookName) { $SPApiClient = new ApiClient(API_USER_ID, API_SECRET, new FileStorage()); $bookID = $SPApiClient->createAddressBook($bookName); if ( !ctype_digit($bookID) ) { $books = $SPApiClient->listAddressBooks(); $key = array_search( $bookName, array_column($books, 'name') ); $bookID = $books[$key]->id; if ( !ctype_digit($bookID) ) { $response['error'] = 'An error has occurred. Please contact the administrator. Code: ' . json_encode($books); $response['code'] = 500; wp_die(json_encode($response)); } } $json = file_get_contents(PATH_TO_ATTACH_FILE . 'books.txt'); if ( !empty($json) ) $json = json_decode($json, true); $json[$bookID] = $bookName; file_put_contents( PATH_TO_ATTACH_FILE . 'books.txt', json_encode($json) ); return $bookID; }
Most novice traders look for the right software to improve their game. Read our reviews and find out how each software can help you in trading. Detailed and honest opinions from our experts await you!