コード例 #1
1
 function route_action()
 {
     $nonce_action = $_REQUEST['bpmod-action'];
     $action = $_REQUEST['bpmod-action'];
     if ('bulk_contents' == $_REQUEST['bpmod-action'] || 'bulk_users' == $_REQUEST['bpmod-action']) {
         $action .= '_' . $_REQUEST['bulk-action'];
     }
     $in_ajax = defined('DOING_AJAX');
     if ($in_ajax) {
         check_ajax_referer($nonce_action);
         $response_func = array(&$this, 'ajax_' . $action);
     } else {
         check_admin_referer($nonce_action);
         $response_func = array(&$this, 'action_' . $action);
         $this->redir = remove_query_arg(array('err_ids', 'marked_spammer', 'unmarked_spammer', 'content_ignored', 'content_moderated', 'content_deleted'), wp_get_referer());
     }
     $handle_func = array(&$this, 'handle_' . $action);
     $response_func = array(&$this, ($in_ajax ? 'ajax_' : 'action_') . $action);
     if (is_callable($handle_func)) {
         $result = (array) call_user_func($handle_func);
         if ($result && is_callable($response_func)) {
             call_user_func_array($response_func, $result);
         }
     }
     //fallback if nothing has been called
     if ($in_ajax) {
         die(-1);
     } else {
         bp_core_redirect($this->redir);
     }
 }
コード例 #2
0
ファイル: Ajax.php プロジェクト: wir/WP-Tiles
 public function get_posts()
 {
     $query = $_POST['query'];
     $hash = $this->get_query_hash($query);
     check_ajax_referer($hash);
     // $query is signed by nonce
     $wp_query = new \WP_Query($query);
     $posts = $wp_query->posts;
     if (!$posts) {
         exit('-1');
     }
     $posted_opts = $_POST['opts'];
     $opts = array('hide_title' => $this->_bool($posted_opts['hide_title']), 'link' => in_array($posted_opts['link'], array('post', 'file', 'thickbox', 'none')) ? $posted_opts['link'] : wp_tiles()->options->get_option('link'), 'byline_template' => wp_kses_post($posted_opts['byline_template']), 'byline_template_textonly' => $this->_bool($posted_opts['byline_template_textonly']), 'images_only' => $this->_bool($posted_opts['images_only']), 'image_size' => $posted_opts['image_size'], 'text_only' => $this->_bool($posted_opts['text_only']), 'link_new_window' => $this->_bool($posted_opts['link_new_window']));
     ob_start();
     wp_tiles()->render_tile_html($posts, $opts);
     $html = ob_get_contents();
     ob_end_clean();
     $ret = array('tiles' => $html);
     $max_page = $wp_query->max_num_pages;
     $next_page = intval($wp_query->get('paged')) + 1;
     // Is there another page?
     if ($next_page <= $max_page) {
         $ret['has_more'] = true;
         $query['paged'] = $next_page;
         $ret['_ajax_nonce'] = $this->get_query_nonce($query);
     } else {
         $ret['has_more'] = false;
     }
     $this->_return($ret);
 }
コード例 #3
0
 function ajax_refresh_static_posts()
 {
     check_ajax_referer('refreshstaticposts');
     if (isset($_POST['number'])) {
         $number = absint($_POST['number']);
         $action = sanitize_text_field($_POST['action']);
         $name = sanitize_text_field($_POST['name']);
         //Get the SRP widgets
         $settings = get_option($name);
         $widget = $settings[$number];
         //Get the new post IDs
         $widget = $this->build_posts(intval($widget['postlimit']), $widget);
         $post_ids = $widget['posts'];
         //Save the settings
         $settings[$number] = $widget;
         //Only save if user is admin
         if (is_user_logged_in() && current_user_can('administrator')) {
             update_option($name, $settings);
             //Let's clean up the cache
             //Update WP Super Cache if available
             if (function_exists("wp_cache_clean_cache")) {
                 @wp_cache_clean_cache('wp-cache-');
             }
         }
         //Build and send the response
         die($this->print_posts($post_ids, false));
     }
     exit;
 }
コード例 #4
0
 /**
  * Upload
  * Ajax callback function
  *
  * @return string Error or (XML-)response
  */
 static function handle_upload()
 {
     global $wpdb;
     $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
     $field_id = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : '';
     check_ajax_referer("rwmb-upload-images_{$field_id}");
     // You can use WP's wp_handle_upload() function:
     $file = $_FILES['async-upload'];
     $file_attr = wp_handle_upload($file, array('test_form' => false));
     //Get next menu_order
     $meta = get_post_meta($post_id, $field_id, false);
     if (empty($meta)) {
         $next = 0;
     } else {
         $meta = implode(',', (array) $meta);
         $max = $wpdb->get_var("\n\t\t\t\t\tSELECT MAX(menu_order) FROM {$wpdb->posts}\n\t\t\t\t\tWHERE post_type = 'attachment'\n\t\t\t\t\tAND ID in ({$meta})\n\t\t\t\t");
         $next = is_numeric($max) ? (int) $max + 1 : 0;
     }
     $attachment = array('guid' => $file_attr['url'], 'post_mime_type' => $file_attr['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($file['name'])), 'post_content' => '', 'post_status' => 'inherit', 'menu_order' => $next);
     // Adds file as attachment to WordPress
     $id = wp_insert_attachment($attachment, $file_attr['file'], $post_id);
     if (!is_wp_error($id)) {
         wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file_attr['file']));
         // Save file ID in meta field
         add_post_meta($post_id, $field_id, $id, false);
         wp_send_json_success(self::img_html($id));
     }
     exit;
 }
コード例 #5
0
ファイル: migration.php プロジェクト: WackoMako/stonedape
function ubermenu_migration_nag_dismiss_callback()
{
    check_ajax_referer('ubermenu-nag-dismiss', 'nag_nonce');
    update_option(UBERMENU_PREFIX . 'migration_status', 'do-not-migrate');
    echo 1;
    die;
}
コード例 #6
0
function update_admin_status()
{
    global $wpdb;
    if (check_ajax_referer('pb-network-managers')) {
        $restricted = $wpdb->get_results('SELECT * FROM wp_sitemeta WHERE meta_key = "pressbooks_network_managers"');
        if ($restricted) {
            $restricted = maybe_unserialize($restricted[0]->meta_value);
        } else {
            $restricted = array();
        }
        $id = absint($_POST['admin_id']);
        if (1 === absint($_POST['status'])) {
            if (!in_array($id, $restricted)) {
                $restricted[] = $id;
            }
        } elseif (0 === absint($_POST['status'])) {
            if (($key = array_search($id, $restricted)) !== false) {
                unset($restricted[$key]);
            }
        }
        if (is_array($restricted) && !empty($restricted)) {
            update_site_option('pressbooks_network_managers', $restricted);
        } else {
            delete_site_option('pressbooks_network_managers');
        }
    }
}
コード例 #7
0
 public function check_license()
 {
     check_ajax_referer('wpv-check-license', 'nonce');
     global $wp_version;
     $raw_response = wp_remote_post($this->validate_api_url, array('body' => array('purchase_key' => $_POST['license-key']), 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url()));
     if (!is_wp_error($raw_response)) {
         if ($raw_response['response']['code'] >= 200 && $raw_response['response']['code'] < 300) {
             echo '<span style="color: green">';
             // xss ok
             _e('Valid Purchase Key Key', 'church-event');
             echo '</span>';
             // xss ok
         } else {
             echo '<span style="color: red">';
             // xss ok
             _e('Incorrect Purchase Key', 'church-event');
             echo '</span>';
             // xss ok
         }
     } else {
         echo '<span style="color: red">';
         // xss ok
         _e('Cannot validate Purchase Key. Please try again later. If the problem persists your server might not have the curl PHP extension enabled.', 'church-event');
         echo '</span>';
         // xss ok
     }
     die;
 }
コード例 #8
0
 /**
  * Poll Voting
  * @since 1.1
  * @version 1.1
  */
 public function vote_poll()
 {
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'polls' && is_user_logged_in()) {
         // Get Poll ID
         $poll_id = isset($_REQUEST['poll_id']) ? intval($_REQUEST['poll_id']) : 0;
         // Ensure Poll ID Is Valid
         if ($poll_id != 0) {
             // Verify Referer
             if (check_ajax_referer('poll_' . $poll_id . '-nonce', 'poll_' . $poll_id . '_nonce', false)) {
                 // Which View
                 switch ($_REQUEST['view']) {
                     case 'process':
                         $poll_aid = $_POST["poll_{$poll_id}"];
                         $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
                         if ($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
                             $check_voted = check_voted($poll_id);
                             if ($check_voted == 0) {
                                 $user_id = get_current_user_id();
                                 // Make sure we are not excluded
                                 if (!$this->core->exclude_user($user_id)) {
                                     $this->core->add_creds('poll_voting', $user_id, $this->prefs['creds'], $this->prefs['log'], $poll_id, array('ref_type' => 'poll'), $this->mycred_type);
                                 }
                             }
                         }
                         break;
                 }
             }
         }
     }
 }
コード例 #9
0
ファイル: postpicker.php プロジェクト: studio-montana/custom
/**
 * retrieve post
*/
function postpicker_ajax_postpicker_get_post()
{
    if (!check_ajax_referer('postpicker-ajax-nonce', 'ajaxNonce', false)) {
        die('Busted!');
    }
    $response = array('what' => 'postpicker_ajax_postpicker_get_post', 'action' => 'postpicker_ajax_postpicker_get_post', 'id' => '1');
    $results = "";
    $post_id = null;
    if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
        $post_id = $_POST['post_id'];
    }
    $asked_post = get_post($post_id);
    if ($asked_post) {
        global $post;
        $post = $asked_post;
        setup_postdata($post);
        ob_start();
        $postpick_item_template = locate_ressource(CUSTOM_PLUGIN_COMMONS_FOLDER . '/postpicker/templates/postpicker-item.php');
        if (!empty($postpick_item_template)) {
            include $postpick_item_template;
        }
        $results = ob_get_contents();
        ob_end_clean();
        wp_reset_postdata();
    }
    $response['data'] = $results;
    $xmlResponse = new WP_Ajax_Response($response);
    $xmlResponse->send();
    exit;
}
コード例 #10
0
function pmxi_wp_ajax_nested_merge()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can(PMXI_Plugin::$capabilities)) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    $input = new PMXI_Input();
    $post = $input->post(array('filePath' => ''));
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    /*$nested_file = array(
    		'file' => $filePath,
    		'source' => $realPath,
    		'xpath' => $customXpath,
    		'root_element' => $root_element,
    		'main_xml_field' => $main_xml_field,
    		'child_xml_field' => $child_xml_field
    	);		*/
    $nested_files = empty(PMXI_Plugin::$session->options['nested_files']) ? array() : json_decode(PMXI_Plugin::$session->options['nested_files'], true);
    $nested_files[] = $post['filePath'];
    $options = PMXI_Plugin::$session->options;
    $options['nested_files'] = json_encode($nested_files);
    PMXI_Plugin::$session->set('options', $options);
    PMXI_Plugin::$session->save_data();
    exit(json_encode(array('success' => true, 'nested_files' => $nested_files)));
    die;
}
コード例 #11
0
 /**
  * AJAX 'get_models' callback
  */
 public function ajax_get_models()
 {
     // check nonce
     check_ajax_referer('wpcm-dat-ajax-nonce', 'nonce');
     // check if make is set
     if (!isset($_POST['make'])) {
         return;
     }
     // make
     $make = absint($_POST['make']);
     // models array
     $models = array();
     // get raw models
     $models_raw = wp_car_manager()->service('make_model_manager')->get_models($make);
     // check & loop
     if (count($models_raw) > 0) {
         foreach ($models_raw as $model_raw) {
             // add to $models array
             $models[] = array('id' => $model_raw['id'], 'name' => $model_raw['name']);
         }
     }
     // send JSON
     wp_send_json($models);
     // bye
     exit;
 }
コード例 #12
0
 public function submit()
 {
     check_ajax_referer('ninja_forms_display_nonce', 'security');
     if (!$this->_form_data) {
         if (function_exists('json_last_error') && function_exists('json_last_error_msg') && json_last_error()) {
             $this->_errors[] = json_last_error_msg();
         } else {
             $this->_errors[] = __('An unexpected error occurred.', 'ninja-forms');
         }
         $this->_respond();
     }
     $this->_form_id = $this->_data['form_id'] = $this->_form_data['id'];
     if (isset($this->_form_data['settings']['is_preview']) && $this->_form_data['settings']['is_preview']) {
         $this->_preview_data = get_user_option('nf_form_preview_' . $this->_form_id);
         if (!$this->_preview_data) {
             $this->_errors['preview'] = __('Preview does not exist.', 'ninja-forms');
             $this->_respond();
         }
     }
     $this->_data['settings'] = $this->_form_data['settings'];
     $this->_data['fields'] = $this->_form_data['fields'];
     $this->validate_fields();
     $this->process_fields();
     $this->process();
 }
コード例 #13
0
 /**
  * Get players.
  */
 public function get_players()
 {
     check_ajax_referer('sp-get-players', 'nonce');
     $team = sp_array_value($_POST, 'team');
     $league = sp_array_value($_POST, 'league');
     $season = sp_array_value($_POST, 'season');
     $index = sp_array_value($_POST, 'index', 1);
     $selected = sp_array_value($_POST, 'selected', array());
     $args = array('orderby' => 'menu_order');
     if ($team) {
         $args['meta_query'] = array(array('key' => 'sp_current_team', 'value' => sp_array_value($_POST, 'team')));
     }
     if ($league || $season) {
         $args['tax_query'] = array('relation' => 'AND');
         if ($league) {
             $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league);
         }
         if ($season) {
             $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season);
         }
     }
     $player_args = $args;
     $player_args['meta_key'] = 'sp_number';
     $player_args['orderby'] = 'meta_value_num';
     $player_args['order'] = 'ASC';
     $players = sp_get_posts('sp_player', $player_args);
     $staff = sp_get_posts('sp_staff', $args);
     $data = array('index' => $index);
     foreach ($players as $key => $value) {
         $players[$key]->post_title = sp_get_player_name_with_number($value->ID);
     }
     $data['players'] = $players;
     $data['staff'] = $staff;
     wp_send_json_success($data);
 }
コード例 #14
0
function cherry_prepare_download_backup_callback()
{
    check_ajax_referer('cherry_download_backup', 'wp_nonce_download_backup');
    if (!current_user_can('export')) {
        wp_die('You do not have permissions to do this', 'Error');
    }
    $file = isset($_GET['file']) ? $_GET['file'] : '';
    if (!$file) {
        wp_die('File not provided', 'Error');
    }
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        readfile($file);
    } else {
        echo theme_locals("unfortunately") . $theme_folder . theme_locals("please_try");
    }
    exit;
}
コード例 #15
0
 function preAjaxDispatch()
 {
     if (!check_ajax_referer($this->getAjaxActionValue(get_class($this)), 'action_security')) {
         throw new Exception("Security check failed");
     }
     return true;
 }
コード例 #16
0
 public function submit()
 {
     check_ajax_referer('ninja_forms_display_nonce', 'security');
     register_shutdown_function(array($this, 'shutdown'));
     if (!$this->_form_data) {
         if (function_exists('json_last_error') && function_exists('json_last_error_msg') && json_last_error()) {
             $this->_errors[] = json_last_error_msg();
         } else {
             $this->_errors[] = __('An unexpected error occurred.', 'ninja-forms');
         }
         $this->_respond();
     }
     $this->_form_id = $this->_data['form_id'] = $this->_form_data['id'];
     if (isset($this->_form_data['settings']['is_preview']) && $this->_form_data['settings']['is_preview']) {
         $this->_preview_data = get_user_option('nf_form_preview_' . $this->_form_id);
         // Add preview field keys to form data.
         foreach ($this->_form_data['fields'] as $key => $field) {
             $field_id = $field['id'];
             $this->_form_data['fields'][$key]['key'] = $this->_preview_data['fields'][$field_id]['settings']['key'];
         }
         if (!$this->_preview_data) {
             $this->_errors['preview'] = __('Preview does not exist.', 'ninja-forms');
             $this->_respond();
         }
     }
     $this->_data['settings'] = $this->_form_data['settings'];
     $this->_data['extra'] = $this->_form_data['extra'];
     $this->_data['fields'] = $this->_form_data['fields'];
     $this->_data = apply_filters('ninja_forms_submit_data', $this->_data);
     $this->validate_fields();
     $this->process_fields();
     $this->process();
 }
コード例 #17
0
 /**
  * Ajax call when user clicks payment button
  */
 function do_payment()
 {
     check_ajax_referer('manual-payment-nonce', 'nonce');
     $user_id = $_POST["user_id"];
     $event_id = $_POST["event_id"];
     if (!$user_id or !$event_id) {
         die;
     }
     $payments = maybe_unserialize(stripslashes(Eab_EventModel::get_booking_meta($event_id, "manual_payment")));
     if (!is_array($payments)) {
         $payments = array();
     } else {
         foreach ($payments as $payment) {
             // Make a check
             if ($payment["id"] == $user_id) {
                 // User has a record before!?
                 die;
             }
         }
     }
     array_push($payments, array("id" => $user_id, "stat" => "pending"));
     $payments = array_filter(array_unique($payments));
     // Clear empty records, just in case
     Eab_EventModel::update_booking_meta($event_id, "manual_payment", serialize($payments));
     die;
 }
コード例 #18
0
 function ajax_response()
 {
     check_ajax_referer('ajax-custom-list-nonce', '_ajax_custom_list_nonce');
     $this->prepare_items();
     extract($this->_args);
     extract($this->_pagination_args, EXTR_SKIP);
     ob_start();
     if (!empty($_REQUEST['no_placeholder'])) {
         $this->display_rows();
     } else {
         $this->display_rows_or_placeholder();
     }
     $rows = ob_get_clean();
     ob_start();
     $this->print_column_headers();
     $headers = ob_get_clean();
     ob_start();
     $this->pagination('top');
     $pagination_top = ob_get_clean();
     ob_start();
     $this->pagination('bottom');
     $pagination_bottom = ob_get_clean();
     $response = array('rows' => $rows);
     $response['pagination']['top'] = $pagination_top;
     $response['pagination']['bottom'] = $pagination_bottom;
     $response['column_headers'] = $headers;
     if (isset($total_items)) {
         $response['total_items_i18n'] = sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items));
     }
     if (isset($total_pages)) {
         $response['total_pages'] = $total_pages;
         $response['total_pages_i18n'] = number_format_i18n($total_pages);
     }
     die(wp_json_encode($response));
 }
コード例 #19
0
function cmo_import_xml($demo_xml_file)
{
    if (function_exists('check_ajax_referer')) {
        check_ajax_referer(DEMO_IMPORTER_NONCE, 'security');
    }
    header('Content-type: text/html; charset=utf-8');
    define('WP_LOAD_IMPORTERS', true);
    require_once ABSPATH . 'wp-admin/includes/import.php';
    $import_error = false;
    if (!class_exists('WP_Importer')) {
        $wp_importer_file = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
        if (file_exists($wp_importer_file)) {
            require_once $wp_importer_file;
        } else {
            $import_error = true;
        }
    }
    if (!class_exists('WP_Import')) {
        require_once 'wordpress-importer/wordpress-importer.php';
    }
    if ($import_error || !class_exists('WP_Import')) {
        ajax_finish(false, __('Failed to load importer php files. Use WordPress Importer plugin to manually load demo content xml file.', 'cumulo'));
    }
    if (!is_file($demo_xml_file)) {
        ajax_finish(true, "done");
    }
    $wp_import = new WP_Import();
    $wp_import->fetch_attachments = true;
    set_time_limit(0);
    ob_start();
    $wp_import->import($demo_xml_file);
    ob_get_clean();
    ajax_finish(true, "done");
}
コード例 #20
0
/**
 * Save one product stock data 
 *
 */
function stock_manager_save_one_product_stock_data()
{
    if (current_user_can('manage_woocommerce')) {
        $product_id = sanitize_text_field($_POST['product']);
        check_ajax_referer('wsm-ajax-nonce-' . $product_id, 'secure');
        $sku = sanitize_text_field($_POST['sku']);
        $manage_stock = sanitize_text_field($_POST['manage_stock']);
        $stock_status = sanitize_text_field($_POST['stock_status']);
        $backorders = sanitize_text_field($_POST['backorders']);
        $stock = sanitize_text_field($_POST['stock']);
        $weight = sanitize_text_field($_POST['weight']);
        update_post_meta($product_id, '_sku', $sku);
        update_post_meta($product_id, '_manage_stock', $manage_stock);
        update_post_meta($product_id, '_stock_status', $stock_status);
        update_post_meta($product_id, '_backorders', $backorders);
        $_product = wc_get_product($product_id);
        //Set stock via product class
        $_product->set_stock($stock);
        if (!empty($_POST['regular_price'])) {
            $price = sanitize_text_field($_POST['regular_price']);
            if (!empty($_POST['sales_price'])) {
                $sale_price = sanitize_text_field($_POST['sales_price']);
                wsm_save_price($product_id, $price, $sale_price);
            } else {
                wsm_save_price($product_id, $price);
            }
        }
        update_post_meta($product_id, '_weight', $weight);
    }
    exit;
}
コード例 #21
0
 /**
  * Save an image
  */
 public function save_image()
 {
     check_ajax_referer(self::NONCE_SAVE_IMAGE, 'nonce');
     $attachment_id = isset($_POST['attachment_id']) ? absint($_POST['attachment_id']) : false;
     if ($this->is_attachment($attachment_id)) {
         // faces
         if (isset($_POST['faces'])) {
             if ($_POST['faces']) {
                 update_post_meta($attachment_id, 'faces', $_POST['faces']);
             } else {
                 delete_post_meta($attachment_id, 'faces');
             }
         }
         // hotspots
         if (isset($_POST['hotspots'])) {
             if ($_POST['hotspots']) {
                 update_post_meta($attachment_id, 'hotspots', $_POST['hotspots']);
             } else {
                 delete_post_meta($attachment_id, 'hotspots');
             }
         }
         // regenerate thumbs
         $resized = MEAUH_Attachment::regenerate($attachment_id);
         if ($resized) {
             wp_send_json_success(array('resized' => $resized));
         }
     } else {
         wp_send_json_error();
     }
 }
コード例 #22
0
 /**
  * Hook into admin AJAX to delete a link
  *
  * @access public
  * @return void
  */
 public function run()
 {
     // id,
     if (!isset($_POST['id'])) {
         exit;
     }
     // Post id into $post_id
     $post_id = $_POST['id'];
     // Check nonce
     check_ajax_referer('rp4wp-ajax-nonce-omgrandomword', 'nonce');
     // Check if user is allowed to do this
     if (!current_user_can('edit_posts')) {
         return;
     }
     //  Load post
     $target_post = get_post($post_id);
     // Only delete post type we control
     if ($target_post->post_type != RP4WP_Constants::LINK_PT) {
         return;
     }
     // Delete link
     $post_link_manager = new RP4WP_Post_Link_Manager();
     $post_link_manager->delete($target_post->ID);
     // Generate JSON response
     $response = json_encode(array('success' => true));
     header('Content-Type: application/json');
     echo $response;
     // Bye
     exit;
 }
コード例 #23
0
function pmxi_wp_ajax_auto_detect_sf()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('result' => array(), 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can(PMXI_Plugin::$capabilities)) {
        exit(json_encode(array('result' => array(), 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    $input = new PMXI_Input();
    $fieldName = $input->post('name', '');
    $post_type = $input->post('post_type', 'post');
    global $wpdb;
    $result = array();
    if ($fieldName) {
        if ($post_type == 'import_users') {
            $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT usermeta.meta_value\n\t\t\t\tFROM " . $wpdb->usermeta . " as usermeta\n\t\t\t\tWHERE usermeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A);
        } else {
            $values = $wpdb->get_results("\n\t\t\t\tSELECT DISTINCT postmeta.meta_value\n\t\t\t\tFROM " . $wpdb->postmeta . " as postmeta\n\t\t\t\tWHERE postmeta.meta_key='" . $fieldName . "'\n\t\t\t", ARRAY_A);
        }
        if (!empty($values)) {
            foreach ($values as $key => $value) {
                if (!empty($value['meta_value']) and is_serialized($value['meta_value'])) {
                    $v = unserialize($value['meta_value']);
                    if (!empty($v) and is_array($v)) {
                        foreach ($v as $skey => $svalue) {
                            $result[] = array('key' => $skey, 'val' => maybe_serialize($svalue));
                        }
                        break;
                    }
                }
            }
        }
    }
    exit(json_encode(array('result' => $result)));
}
コード例 #24
0
ファイル: cache.php プロジェクト: vsalx/rattieinfo
/**
 * Clears cache completely, via ajax
 *
 * @since 1.5
 */
function file_gallery_clear_cache_manual()
{
    check_ajax_referer('file-gallery-clear_cache');
    file_gallery_clear_cache();
    _e("You have successfully cleared the File Gallery cache.", "file-gallery");
    exit;
}
コード例 #25
0
function load_more_posts_callback()
{
    check_ajax_referer('pan_travel_blog', 'token');
    try {
        $offset = $_POST['offset'];
        $number = $_POST['number'];
        $loop = new WP_Query(array('post_type' => 'travel_blogs', 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'travel_blog_start_date', 'offset' => $offset, 'posts_per_page' => $number));
        if ($loop->have_posts()) {
            while ($loop->have_posts()) {
                $loop->the_post();
                ?>
				<?php 
                get_template_part('parts/content', 'travelblog');
                ?>
			<?php 
            }
        } else {
            ?>
			<p><?php 
            _e('Sorry, no posts matched your criteria.');
            ?>
</p>
		<?php 
        }
        wp_reset_postdata();
    } catch (Exception $e) {
        echo 'Errors';
    }
    wp_die();
}
コード例 #26
0
 public function run()
 {
     global $wpdb;
     // Check nonce
     check_ajax_referer('rp4wp-ajax-nonce-omgrandomword', 'nonce');
     // Check if user is allowed to do this
     if (!current_user_can('edit_posts')) {
         return;
     }
     // Check if the items are set
     if (!isset($_POST['rp4wp_items'])) {
         return;
     }
     // Boom
     $items = explode(',', $_POST['rp4wp_items']);
     // Check if there are items posted
     if (count($items) == 0) {
         return;
     }
     // Change order
     $counter = 0;
     foreach ($items as $item_id) {
         $wpdb->update($wpdb->posts, array('menu_order' => $counter), array('ID' => $item_id));
         $counter++;
     }
     // Generate JSON response
     $response = json_encode(array('success' => true));
     header('Content-Type: application/json');
     echo $response;
     // Bye
     exit;
 }
コード例 #27
0
function pmxi_wp_ajax_save_import_functions()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can('manage_options')) {
        exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
    }
    $uploads = wp_upload_dir();
    $functions = $uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_IMPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
    $input = new PMXI_Input();
    $post = $input->post('data', '');
    $response = wp_remote_post('http://phpcodechecker.com/api', array('body' => array('code' => $post)));
    if (is_wp_error($response)) {
        $error_message = $response->get_error_message();
        exit(json_encode(array('result' => false, 'msg' => $error_message)));
        die;
    } else {
        $body = json_decode(wp_remote_retrieve_body($response), true);
        if ($body['errors'] === 'TRUE') {
            exit(json_encode(array('result' => false, 'msg' => $body['syntax']['message'])));
            die;
        } elseif ($body['errors'] === 'FALSE') {
            if (strpos($post, "<?php") === false || strpos($post, "?>") === false) {
                exit(json_encode(array('result' => false, 'msg' => __('PHP code must be wrapped in "&lt;?php" and "?&gt;"', 'wp_all_import_plugin'))));
                die;
            } else {
                file_put_contents($functions, $post);
            }
        }
    }
    exit(json_encode(array('result' => true, 'msg' => __('File has been successfully updated.', 'wp_all_import_plugin'))));
    die;
}
コード例 #28
0
ファイル: ajax.php プロジェクト: socialray/surfied-2-0
/**
 * Catches an activity to delete if js is enabled
 *
 * @package BP Reshare
 * @since    1.0
 *
 * @uses  check_ajax_referer() for security reasons
 * @uses  bp_activity_get_specific() to fetch the activity to delete
 * @uses  buddyreshare_reset_metas() to reset some metas for the parent activity
 * @uses  bp_activity_delete() to delete the reshare
 */
function buddyreshare_ajax_delete_reshare()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_ajax_referer('buddyreshare_delete', 'nonce');
    $response = array('result' => 'error', 'message' => __('OOps, error while trying to delete your reshare..', 'bp-reshare'));
    $reshare_id = intval($_POST['activity']);
    if (empty($reshare_id)) {
        $response['message'] = __('The reshare was not found.', 'bp-reshare');
        exit(json_encode($response));
    }
    $reshare_to_delete = bp_activity_get_specific(array('activity_ids' => $reshare_id));
    if (empty($reshare_to_delete)) {
        $response['message'] = __('The reshare was not found.', 'bp-reshare');
        exit(json_encode($response));
    }
    $reshare = $reshare_to_delete['activities'][0];
    $reset = buddyreshare_reset_metas($reshare->secondary_item_id, $reshare->user_id);
    if (empty($reset)) {
        $response['message'] = __('Unable to reset the properties of the reshared activity', 'bp-reshare');
        exit(json_encode($response));
    }
    $deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
    if (!empty($deleted_reshare)) {
        do_action('buddyreshare_reshare_deleted', $reshare_id);
        $response['result'] = 'success';
        $response['message'] = __('Reshare successfully deleted.', 'bp-reshare');
    } else {
        do_action('buddyreshare_reshare_deleted_error', $reshare_id);
    }
    exit(json_encode($response));
}
コード例 #29
0
 /**
  * Stores user's preference to hide the submit message via AJAX
  */
 function hide()
 {
     check_ajax_referer($this->parent->slug_ . '_hide_submit', '_ajax_nonce-' . $this->parent->slug . '-hide-submit');
     //note: option will be global
     update_user_option(get_current_user_ID(), 'infinite-scroll-hide-submit', true, true);
     die(1);
 }
コード例 #30
0
 public function run()
 {
     // check nonce
     check_ajax_referer(RP4WP_Constants::NONCE_AJAX, 'nonce');
     // get the rel amount
     $rel_amount = isset($_POST['rel_amount']) ? $_POST['rel_amount'] : 3;
     // get the related post age
     $post_age = isset($_POST['rp4wp_related_posts_age']) ? $_POST['rp4wp_related_posts_age'] : 0;
     // check if Post Type is set
     if (!isset($_POST['pt'])) {
         echo 'No Post Type set!';
         exit;
     }
     // post Type
     $post_type = $_POST['pt'];
     if (isset(RP4WP::get()->settings['general_' . $post_type])) {
         // set the correct options from step 3
         $options = RP4WP::get()->settings['general_' . $post_type]->get_options();
         $options['automatic_linking_post_amount'] = $rel_amount;
         $options['max_post_age'] = $post_age;
         update_option('rp4wp_general_' . $post_type, $options);
     }
     // success
     echo 'success';
     exit;
 }