function save_hook() { /** Incoming post data */ $postdata = $_POST; if (isset($postdata['nonce'])) { pl_verify_ajax($postdata['nonce']); } else { die('No Nonce set!'); } /** If doing an upload. */ if (isset($_FILES)) { $postdata['files'] = $_FILES; } /** Start response variable, sent back at end of request. */ $response = array(); /** Send back the data we recieved */ $response['post'] = $postdata; /** The saving hook */ $hook = $postdata['hook']; /** The specific thing to run ( not used? )*/ // $run = $postdata['run']; /** Page information TODO used? */ // $pageID = $postdata['pageID']; // $typeID = $postdata['typeID']; /** Debug information */ $response['dataAmount'] = isset($_SERVER['CONTENT_LENGTH']) ? (int) $_SERVER['CONTENT_LENGTH'] : 'No Value'; /** * Trigger hook, send the functions the data and response for update * If user is logged out then only do nopriv options */ if (pl_can_use_tools()) { $response = apply_filters('pl_server_' . $hook, $response, $postdata); $response = apply_filters('pl_server_nopriv_' . $hook, $response, $postdata); } else { $response = apply_filters('pl_server_nopriv_' . $hook, $response, $postdata); } /** JSON response for output and UI actions */ header('Content-Type: application/json'); echo json_encode(pl_convert_arrays_to_objects($response)); die; // don't forget this, always returns 0 w/o }
function pl_card_fav_callback() { /** Incoming post data */ $postdata = $_POST; if (isset($postdata['nonce'])) { pl_verify_ajax($postdata['nonce']); } else { die('No Nonce set!'); } //we send fav request to server... and do same locally $user_id = wp_get_current_user()->ID; $response = PL_Platform()->oauth->request('fav', array('slug' => $postdata['slug'])); update_user_meta($user_id, '_card_fav', (array) $response->favs); /** JSON response for output and UI actions */ header('Content-Type: application/json'); echo json_encode($response); exit; // don't forget this, always returns 0 w/o }
function ajax() { /** Incoming post data */ $postdata = $_POST; if (isset($postdata['nonce'])) { pl_verify_ajax($postdata['nonce']); } else { die('No Nonce!'); } /** Start response variable, sent back at end of request. */ $response = array('post' => $postdata); if (pl_can_use_tools()) { $response = apply_filters('pl_platform_server_' . $postdata['hook'], $response, $postdata); $response = apply_filters('pl_platform_server_nopriv_' . $postdata['hook'], $response, $postdata); } else { $response = apply_filters('pl_platform_server_nopriv_' . $postdata['hook'], $response, $postdata); } /** JSON response for output and UI actions */ header('Content-Type: application/json'); echo json_encode(pl_convert_arrays_to_objects($response)); die; // don't forget this, always returns 0 w/o }