• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_send_json_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_send_json_error函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_send_json_error函数的具体用法?PHP wp_send_json_error怎么用?PHP wp_send_json_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_send_json_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: do_forgot_password_ajax

function do_forgot_password_ajax()
{
    if (isset($_POST['forgot_password_form_submitted']) && isset($_POST['forgot_password_form_nonce_field']) && wp_verify_nonce($_POST['forgot_password_form_nonce_field'], 'forgot_password_form_submitted')) {
        if (isset($_POST['username'])) {
            $username = sanitize_text_field($_REQUEST['username']);
            $user = get_user_by('login', $username);
            if (!$user) {
                $return = array('message' => "Sorry the username you provided is not registered");
                wp_send_json_error($return);
            } else {
                // Send an email that the account has been created
                do_action('cloderia_user_reset_password', $username);
                $return = array('message' => "A new password has been sent to your email");
                wp_send_json_success($return);
            }
        } else {
            $return = array('message' => "Please provide a valid username");
            wp_send_json_error($return);
        }
    } else {
        $message = "Invalid form operation.";
        $return = array('message' => $message);
        wp_send_json_error($return);
    }
}
开发者ID:ebanfa,项目名称:shadow-plugin-theme,代码行数:25,代码来源:content-signin-ajax.php


示例2: wpml_save_term

 /**
  * Ajax handler for adding a term via Ajax.
  */
 public static function wpml_save_term()
 {
     if (!wpml_is_action_authenticated('wpml_save_term')) {
         wp_send_json_error('Wrong Nonce');
     }
     global $sitepress;
     $lang = filter_input(INPUT_POST, 'term_language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     $taxonomy = filter_input(INPUT_POST, 'taxonomy');
     $slug = filter_input(INPUT_POST, 'slug');
     $name = filter_input(INPUT_POST, 'name');
     $trid = filter_input(INPUT_POST, 'trid', FILTER_SANITIZE_NUMBER_INT);
     $description = filter_input(INPUT_POST, 'description');
     $new_term_object = false;
     if ($name !== "" && $taxonomy && $trid && $lang) {
         $args = array('taxonomy' => $taxonomy, 'lang_code' => $lang, 'term' => $name, 'trid' => $trid, 'overwrite' => true);
         if ($slug) {
             $args['slug'] = $slug;
         }
         if ($description) {
             $args['description'] = $description;
         }
         $res = WPML_Terms_Translations::create_new_term($args);
         if ($res && isset($res['term_taxonomy_id'])) {
             /* res holds the term taxonomy id, we return the whole term objects to the ajax call */
             $new_term_object = get_term_by('term_taxonomy_id', (int) $res['term_taxonomy_id'], $taxonomy);
             $lang_details = $sitepress->get_element_language_details($new_term_object->term_taxonomy_id, 'tax_' . $new_term_object->taxonomy);
             $new_term_object->trid = $lang_details->trid;
             $new_term_object->language_code = $lang_details->language_code;
             WPML_Terms_Translations::icl_save_term_translation_action($taxonomy, $res);
         }
     }
     wp_send_json_success($new_term_object);
 }
开发者ID:edgarter,项目名称:wecare,代码行数:36,代码来源:wpml-post-edit-ajax.class.php


示例3: send_json_error

 public static function send_json_error($data, $send_non_200)
 {
     if ($send_non_200) {
         header('HTTP/1.0 400');
     }
     wp_send_json_error($data);
 }
开发者ID:pradyumnasagar,项目名称:pratechsha,代码行数:7,代码来源:class.clef-ajax.php


示例4: ajax_image_crop

 public function ajax_image_crop()
 {
     $res = false;
     if (!current_user_can('edit_posts') || empty($_REQUEST["nonce"]) || !wp_verify_nonce($_REQUEST["nonce"], 'pe_theme_image_crop')) {
         wp_send_json_error();
         wp_die(0);
     }
     $id = $_REQUEST["id"];
     $idx = $_REQUEST["idx"];
     $size = $_REQUEST["size"];
     list($w, $h) = explode("x", $size);
     $crop = $_REQUEST["crop"];
     $orig = $_REQUEST["orig"];
     $res = $this->master->image->crop($orig, $crop, $w, $h);
     if (!empty($res["cburl"])) {
         $res["idx"] = absint($idx);
         $meta = get_post_meta($id, PE_THEME_META, true);
         if (empty($meta)) {
             $meta = new StdClass();
             $meta->thumbnails = new StdClass();
         }
         $meta->thumbnails->thumbs[$size] = $crop;
         update_post_meta($id, PE_THEME_META, $this->update_attachment_metadata($meta, $id, null));
     }
     wp_send_json_success($res);
     wp_die(0);
 }
开发者ID:JeffreyBue,项目名称:jb,代码行数:27,代码来源:PeThemeThumbnail.php


示例5: cue_ajax_parse_shortcode

/**
 * Parse the Cue shortcode for display within a TinyMCE view.
 *
 * @since 1.3.0
 */
function cue_ajax_parse_shortcode()
{
    global $wp_scripts;
    if (empty($_POST['shortcode'])) {
        wp_send_json_error();
    }
    $shortcode = do_shortcode(wp_unslash($_POST['shortcode']));
    if (empty($shortcode)) {
        wp_send_json_error(array('type' => 'no-items', 'message' => __('No items found.')));
    }
    $head = '';
    $styles = wpview_media_sandbox_styles();
    foreach ($styles as $style) {
        $head .= '<link type="text/css" rel="stylesheet" href="' . $style . '">';
    }
    $head .= '<link rel="stylesheet" href="' . CUE_URL . 'assets/css/cue.min.css' . '">';
    $head .= '<style type="text/css">.cue-tracks { max-height: none;}</style>';
    if (!empty($wp_scripts)) {
        $wp_scripts->done = array();
    }
    ob_start();
    echo $shortcode;
    wp_print_scripts('cue');
    wp_send_json_success(array('head' => $head, 'body' => ob_get_clean()));
}
开发者ID:jondcampbell,项目名称:cue,代码行数:30,代码来源:ajax.php


示例6: icl_get_job_original_field_content

function icl_get_job_original_field_content()
{
    global $iclTranslationManagement;
    if (!wpml_is_action_authenticated('icl_get_job_original_field_content')) {
        die('Wrong Nonce');
    }
    $job_id = filter_input(INPUT_POST, 'tm_editor_job_id', FILTER_SANITIZE_NUMBER_INT);
    $field = filter_input(INPUT_POST, 'tm_editor_job_field');
    $data = array();
    $job = $job_id !== null && $field !== null ? $job = $iclTranslationManagement->get_translation_job($job_id) : null;
    $elements = $job && isset($job->elements) ? $job->elements : array();
    foreach ($elements as $element) {
        $sanitized_type = sanitize_title($element->field_type);
        if ($field === 'icl_all_fields' || $sanitized_type === $field) {
            // if we find a field by that name we need to decode its contents according to its format
            $field_contents = TranslationManagement::decode_field_data($element->field_data, $element->field_format);
            if (is_scalar($field_contents)) {
                $field_contents = strpos($field_contents, "\n") !== false ? wpautop($field_contents) : $field_contents;
                $data[] = array('field_type' => $sanitized_type, 'field_data' => $field_contents);
            }
        }
    }
    if ((bool) $data !== false) {
        wp_send_json_success($data);
    } else {
        wp_send_json_error(0);
    }
}
开发者ID:ryuqing,项目名称:cake,代码行数:28,代码来源:ajax.php


示例7: apiErrors

 /**
  * List of simple error messages 
  * 
  * @param string $code
  * @return string json response with appropriate error code
  */
 function apiErrors($code)
 {
     switch ($code) {
         case 'method':
             $data = array('messages' => 'GET is currently the only request method accepted, as of v1 of the API.', 'documentation' => '/api/v1/docs');
             break;
         case 'resource':
             $data = array('messages' => 'The API requires a valid resource in order to return a response. Try looking for \'books\'', 'documentation' => '/api/v1/docs');
             break;
         case 'version':
             $data = array('messages' => 'The version you\'re requesting is not supported. Current version of the API is v1', 'documentation' => '/api/v1/docs');
             break;
         case 'format':
             $data = array('messages' => 'The format that is being requested is not supported. Try \'json\'', 'documentation' => '/api/v1/docs');
             break;
         case 'empty':
             $data = array('messages' => 'There are no records that can be returned with the request that was made', 'documentation' => '/api/v1/docs');
             break;
         case 'offset':
             $data = array('messages' => 'The offset is a larger value than the number of books available', 'documentation' => '/api/v1/docs');
             break;
         default:
             $data = array('messages' => 'Something went wrong with your API request', 'documentation' => '/api/v1/docs');
     }
     return wp_send_json_error($data);
 }
开发者ID:jflowers45,项目名称:pressbooks,代码行数:32,代码来源:class-pb-api.php


示例8: x_demo_content_setup_ajax_callback

function x_demo_content_setup_ajax_callback()
{
    // Uncomment to simulate a timeout
    // header("HTTP/1.0 408 Request Timeout"); die();
    //
    // Get API data.
    //
    $errorMessage = __('We&apos;re sorry, the demo failed to finish importing.', '__x__');
    if (!isset($_POST['demo'])) {
        wp_send_json_error(array('message' => $errorMessage, 'debug_message' => 'POST data missing demo.'));
    }
    $request = wp_remote_get($_POST['demo']);
    if (is_wp_error($request)) {
        wp_send_json_error(array('message' => $errorMessage, 'debug_message' => $request->get_error_message()));
    }
    //
    // API data.
    //
    $data = json_decode($request['body'], true);
    if (!is_array($data)) {
        wp_send_json_error(array('message' => $errorMessage, 'debug_message' => 'Requested demo is improperly formatted.'));
    }
    //
    // Run demo setup.
    //
    $error = false;
    ob_start();
    include_once 'setup.php';
    if ($error !== false) {
        wp_send_json_error(array('message' => $errorMessage, 'debug_message' => $error, 'buffer' => ob_get_clean()));
    }
    ob_clean();
    wp_send_json_success();
}
开发者ID:skywindzz,项目名称:blue_leopard,代码行数:34,代码来源:ajax-handler.php


示例9: ajax_get_data

 /**
  * Ajax callback to get data for overview widget
  */
 public function ajax_get_data()
 {
     if (!check_ajax_referer('get-data', false, false)) {
         wp_send_json_error();
     }
     wp_send_json_success($this->get_data(intval($_GET['user']), strip_tags($_GET['from']), strip_tags($_GET['to'])));
 }
开发者ID:rilwis,项目名称:user-visit-log,代码行数:10,代码来源:dashboard.php


示例10: install

 /**
  * Tries to install the plugin
  *
  * @access public
  */
 public function install()
 {
     $this->check_capabilities();
     $download = $_POST['download'];
     $license = $_POST['license'];
     $message = __('An Error Occured', 'maera');
     $download_type = $this->_check_download($download);
     /**
      * Throw error of the product is not free and license it empty
      */
     if (empty($download) || empty($license) && 'free' !== $download_type) {
         wp_send_json_error($message);
     }
     /**
      * Install the plugin if it's free
      */
     if ('free' === $download_type) {
         $installed = $this->_install_plugin($download, "");
         wp_send_json_success($installed);
     }
     /**
      * Check for license and then install if it's a valid licens
      */
     if ($this->_check_license($license, $download)) {
         $installed = $this->_install_plugin($download, $license);
         wp_send_json_success($installed);
     } else {
         wp_send_json_error(__('Invalid License', 'maera'));
     }
 }
开发者ID:wpmu,项目名称:maera,代码行数:35,代码来源:class-Maera_EDD_RI_Client.php


示例11: ajax_save

 static function ajax_save()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-save', Kanban::get_instance()->settings->basename)) || !is_user_logged_in()) {
         wp_send_json_error();
     }
     do_action(sprintf('%s_before_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug));
     $user_id_author = isset($_POST['user_id_author']) ? $_POST['user_id_author'] : get_current_user_id();
     if (empty($_POST['user_id_worked'])) {
         $_POST['user_id_worked'] = $user_id_author;
     }
     try {
         $operator = substr($_POST['operator'], 0, 1) == '-' ? '-' : '+';
         $val = sprintf('%s%s', $operator, abs(floatval($_POST['operator'])));
     } catch (Exception $e) {
         wp_send_json_error(array('message' => sprintf('Error saving %s', str_replace('_', ' ', self::$slug))));
     }
     eval(sprintf('$hours = 0%s;', $val));
     $data = array('task_id' => $_POST['task']['id'], 'worked_dt_gmt' => Kanban_Utils::mysql_now_gmt(), 'hours' => $hours, 'status_is' => $_POST['task']['status_id'], 'user_id_author' => $user_id_author, 'user_id_worked' => $_POST['user_id_worked']);
     $is_successful = self::_insert($data);
     do_action(sprintf('%s_after_%s_ajax_save', Kanban::get_instance()->settings->basename, self::$slug));
     if (!empty($_POST['comment'])) {
         do_action(sprintf('%s_before_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug));
         Kanban_Comment::add($_POST['comment'], 'system', $_POST['task']['id']);
         do_action(sprintf('%s_after_%s_ajax_comment_save', Kanban::get_instance()->settings->basename, self::$slug));
     }
     if ($is_successful) {
         wp_send_json_success(array('message' => sprintf('%s saved', str_replace('_', ' ', self::$slug))));
     } else {
         wp_send_json_error(array('message' => sprintf('Error saving %s', str_replace('_', ' ', self::$slug))));
     }
 }
开发者ID:cs-team,项目名称:kanban,代码行数:31,代码来源:class-task_hour.php


示例12: create_duplicate

 function create_duplicate($project_id)
 {
     //Get all data post type project, message, task_list, milestone
     $prev_pro_data = $this->fatch_projcet_data($project_id);
     $new_pro_arg = $this->fill_array($prev_pro_data[$project_id]);
     //create duplicate new project
     $new_pro_id = $this->insert_duplicate($new_pro_arg, $project_id);
     if (!$new_pro_id) {
         wp_send_json_error('Unknown Error', 'cpm');
     }
     //remove project post type from data array
     unset($prev_pro_data[$project_id]);
     foreach ($prev_pro_data as $prev_post_id => $post_obj) {
         if ($post_obj->post_type == 'milestone') {
             $args = $this->fill_array($post_obj, $new_pro_id);
             //Insert message, task list and milestone
             $new_milestone_id[$post_obj->ID] = $this->insert_duplicate($args, $post_obj->ID);
             unset($prev_pro_data[$prev_post_id]);
         }
     }
     foreach ($prev_pro_data as $prev_post_id => $post_obj) {
         $args = $this->fill_array($post_obj, $new_pro_id);
         $new_milestone_id = isset($new_milestone_id) ? $new_milestone_id : array();
         //Insert message, task list and milestone
         $id = $this->insert_duplicate($args, $post_obj->ID, $new_milestone_id);
         //If post type task list then fatch task and insert duplicate
         if ($post_obj->post_type == 'task_list') {
             $task = array('post_parent' => $post_obj->ID, 'post_type' => 'task', 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'ID');
             $task_data = get_children($task);
             $this->insert_duplicate_task($task_data, $id);
         }
     }
     return $new_pro_id;
 }
开发者ID:javalidigital,项目名称:multipla,代码行数:34,代码来源:duplicate.php


示例13: get_posts_by_letter_rendered

function get_posts_by_letter_rendered($first_letter = NULL, $limit = NULL)
{
    global $wp_query;
    /** Validating parameters **/
    $first_letter = (!$first_letter and isset($_POST['letter'])) ? $_POST['letter'] : $first_letter;
    $first_letter = (!$first_letter and !isset($_POST['letter'])) ? 'A' : $first_letter;
    $limit = ($limit === NULL and isset($_POST['limit'])) ? $_POST['limit'] : $limit;
    $limit = ($limit === NULL and !isset($_POST['limit'])) ? -1 : $limit;
    // $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $paged = detect_page_from_url();
    $args = array('post_type' => 'realizadores', 'post_status' => 'publish', 'posts_per_page' => $limit, 'paged' => $paged, 'tax_query' => array(array('taxonomy' => 'letters', 'field' => 'name', 'terms' => $first_letter)));
    $query_to_render = new WP_Query($args);
    //Start recording echoed values
    $echoed = '';
    ob_start();
    global $post;
    ob_start();
    echo "<h2>{$first_letter}</h2>";
    if ($query_to_render->have_posts()) {
        while ($query_to_render->have_posts()) {
            $query_to_render->the_post();
            setup_postdata($post);
            get_template_part('templates/feed', 'small-item');
        }
    }
    wp_reset_postdata();
    echo "<div class='end_of_letter' data-letter='{$first_letter}'></div>";
    $echoed = ob_get_contents();
    ob_end_clean();
    if ($echoed !== '') {
        wp_send_json_success(json_encode($echoed));
    }
    wp_send_json_error();
}
开发者ID:MusicForMyself,项目名称:auto_loader_html,代码行数:34,代码来源:autoloader.php


示例14: jo_save_flow_star

 /**
  * Saves star/unstar value for Flows on Recent Flows page
  *
  *@since 	  1.0.0
  *@param      Gets parameters form AJAX $_POST
  */
 public function jo_save_flow_star()
 {
     global $wpdb;
     //get flow id
     $flow_id = (int) $_POST['flow_id'];
     //get if flow was starred and invert
     if (isset($_POST['is_starred'])) {
         //make sure value is 1 or null and invert value
         if ($_POST['is_starred'] == 1 || $_POST['is_starred'] == '1') {
             $is_starred = false;
         } elseif ($_POST['is_starred'] == null || $_POST['is_starred'] == false) {
             $is_starred = 1;
         } else {
             wp_send_json_error(array('jo_success' => false, 'message' => 'star value 1 or null'));
         }
     } else {
         $is_starred = false;
     }
     // Update the meta field in the database.
     $is_success = update_post_meta($flow_id, 'jumpoff_flow_flag', $is_starred);
     if ($is_success) {
         $message = 'UPDATED ' . $flow_id . ' jumpoff_flow_flag ' . $is_starred . ' | ' . $_POST['is_starred'];
     } else {
         $message = 'not updated ' . $flow_id . ' jumpoff_flow_flag ' . $is_starred . ' | ' . $_POST['is_starred'];
     }
     $starred = get_post_meta($flow_id, 'jumpoff_flow_flag', false);
     $starred = $starred[0];
     wp_send_json_success(array('success' => $is_success, 'message' => $message, 'starred' => $starred, 'id' => $flow_id));
 }
开发者ID:jqlee85,项目名称:jumpoff,代码行数:35,代码来源:class-jumpoff-ajax.php


示例15: hoo_api

 public function hoo_api()
 {
     global $post;
     // /if the page contains the hoo-api shortcode send json and exit :}
     if (is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'hoo-api')) {
         $locations_repo = $this->entity_manager->getRepository('Hoo\\Model\\Location');
         $json_response = array();
         $date = isset($_GET['date']) ? new \DateTime($_GET['date']) : new \DateTime(date('Y-m-d'));
         if (isset($_GET['location_id'])) {
             $location = Location::get_location_by_id_or_shortname($_GET['location_id'], $this->entity_manager);
             if (!$location) {
                 return wp_send_json_error('Not Found');
             }
             $hours = $location->get_hours_for_date($date);
             $json_response['location'] = $location->to_api_response();
             $json_response['location']['address'] = $location->address->to_api_response();
             $json_response['hours'] = $hours ? $hours->to_api_response() : null;
             $json_response['weekly'] = $location->get_weekly_hours();
         } else {
             $locations_repo = $this->entity_manager->getRepository('Hoo\\Model\\Location');
             foreach ($locations_repo->findBy(array('is_visible' => true)) as $location) {
                 $hours = $location->get_hours_for_date($date);
                 $json_response[]['location'] = $location->to_api_response();
                 $json_response[]['location']['address'] = $location->address->to_api_response();
                 $json_response[]['hours'] = $hours ? $hours->to_api_response() : null;
                 $json_response[]['weekly'] = $location->get_weekly_hours();
             }
         }
         wp_send_json($json_response);
         exit;
     }
 }
开发者ID:UNC-Libraries,项目名称:Hours-of-Operation,代码行数:32,代码来源:Shortcode.php


示例16: block_direct_cron

 /**
  * Block direct cron execution as early as possible
  */
 public function block_direct_cron()
 {
     if (false !== stripos($_SERVER['REQUEST_URI'], '/wp-cron.php') || false !== stripos($_SERVER['SCRIPT_NAME'], '/wp-cron.php')) {
         status_header(403);
         wp_send_json_error(new \WP_Error('forbidden', sprintf(__('Normal cron execution is blocked when the %s plugin is active.', 'automattic-cron-control'), 'Cron Control')), array('status' => 400));
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:10,代码来源:class-main.php


示例17: ajax_handler

 public function ajax_handler($data)
 {
     CS_Shortcode_Preserver::init();
     if ($this->sandbox_the_content) {
         CS_Shortcode_Preserver::sandbox('cs_render_the_content');
     }
     add_filter('cs_preserve_shortcodes_no_wrap', '__return_true');
     $this->orchestrator = $this->plugin->component('Element_Orchestrator');
     $this->orchestrator->load_elements();
     $this->mk1 = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
     global $post;
     if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
         wp_send_json_error(array('message' => 'post_id not set'));
     }
     setup_postdata($post);
     $this->enqueue_extractor = $this->plugin->loadComponent('Enqueue_Extractor');
     $this->enqueue_extractor->start();
     if (isset($data['raw_markup'])) {
         $this->raw_markup = (bool) $data['raw_markup'];
     }
     if (!isset($data['batch'])) {
         wp_send_json_error(array('message' => 'No element data recieved'));
     }
     $jobs = $this->batch($data['batch']);
     $scripts = $this->enqueue_extractor->get_scripts();
     if (is_wp_error($jobs)) {
         wp_send_json_error(array('message' => $jobs->get_error_message()));
     }
     $result = array('jobs' => $jobs, 'scripts' => $scripts);
     //Suppress PHP error output unless debugging
     if (CS()->common()->isDebug()) {
         return wp_send_json_success($result);
     }
     return @wp_send_json_success($result);
 }
开发者ID:bitflipper1,项目名称:ghcontracting,代码行数:35,代码来源:class-builder-renderer.php


示例18: ajax_post

 /**
  * Pass global $post object.
  *
  * @link https://github.com/iseulde/wp-front-end-editor/pull/228
  */
 function ajax_post()
 {
     require_once ABSPATH . '/wp-admin/includes/post.php';
     if (!wp_verify_nonce($_POST['_wpnonce'], 'update-post_' . $_POST['post_ID'])) {
         wp_send_json_error(array('message' => __('You are not allowed to edit this item.')));
     }
     $_POST['post_title'] = strip_tags($_POST['post_title']);
     $post_id = edit_post();
     if (isset($_POST['save']) || isset($_POST['publish'])) {
         $status = get_post_status($post_id);
         if (isset($_POST['publish'])) {
             switch ($status) {
                 case 'pending':
                     $message = 8;
                     break;
                 case 'future':
                     $message = 9;
                     break;
                 default:
                     $message = 6;
             }
         } else {
             $message = 'draft' == $status ? 10 : 1;
         }
     } else {
         $message = 4;
     }
     // MOD by CAC
     global $post;
     // end MOD
     $post = get_post($post_id);
     wp_send_json_success(array('message' => $this->get_message($post, $message), 'post' => $post, 'processedPostContent' => apply_filters('the_content', $post->post_content)));
 }
开发者ID:sheesh,项目名称:social-paper,代码行数:38,代码来源:class-cacsp-fee.php


示例19: ajax

 public function ajax()
 {
     $apiArgs = isset($_GET["apiArgs"]) ? $_GET["apiArgs"] : array();
     if (!$apiArgs) {
         wp_send_json_error(array("error" => "MISSING_APIARGS"));
         exit;
     }
     if (empty($apiArgs["since_id"]) || !is_numeric($apiArgs["since_id"])) {
         wp_send_json_error(array("error" => "MISSING_SINCE_ID"));
         exit;
     }
     // $since_id = isset( $_GET["since_id"] ) ? absint($_GET["since_id"]) : null;
     $logQueryArgs = $apiArgs;
     $logQuery = new SimpleHistoryLogQuery();
     $answer = $logQuery->query($logQueryArgs);
     // Use our own repsonse array instead of $answer to keep size down
     $json_data = array();
     $numNewRows = isset($answer["total_row_count"]) ? $answer["total_row_count"] : 0;
     $json_data["num_new_rows"] = $numNewRows;
     $json_data["num_mysql_queries"] = get_num_queries();
     if ($numNewRows) {
         // We have new rows
         // Append strings
         $textRowsFound = sprintf(_n('1 new event', '%d new events', $numNewRows, 'simple-history'), $numNewRows);
         $json_data["strings"] = array("newRowsFound" => $textRowsFound);
     }
     wp_send_json_success($json_data);
 }
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:28,代码来源:SimpleHistoryNewRowsNotifier.php


示例20: api_endpoint_template_redirect

 /**
  * Handles template redirect requests. Checks if endpoint is valid and if
  * user should be authenticated, routes request to proper handler function
  */
 function api_endpoint_template_redirect()
 {
     global $wp_query;
     if (empty($wp_query->query_vars[static::$rewrite_endpoint])) {
         return;
     }
     //allows use of DOING_AJAX content just like admin-ajax requests
     define('DOING_AJAX', true);
     $api = explode('/', $wp_query->query_vars[static::$rewrite_endpoint]);
     $endpoint = array_shift($api);
     $admin = in_array($endpoint, static::$admin_endpoints);
     $is_function = function_exists($endpoint);
     $is_method = method_exists($this, $endpoint);
     if (!in_array($endpoint, static::$front_endpoints) && !$admin) {
         wp_send_json_error('Endpoint does not exist. Verify Endpoint exists. You may need to flush rewrites manually.');
     }
     if (!$is_function && !$is_method) {
         wp_send_json_error('Endpoint function/method does not exist.');
     }
     if ($admin && !$this->is_user_admin()) {
         wp_send_json_error('This is an Admin Endpoint. You must be logged in to access it.');
     }
     if ($is_method) {
         call_user_func_array(array($this, $endpoint), $api);
     }
     if ($is_function) {
         call_user_func($endpoint, $api);
     }
 }
开发者ID:mrbobbybryant,项目名称:wp-api-endpoints,代码行数:33,代码来源:class-base-api.php



注:本文中的wp_send_json_error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_send_json_success函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_send_json函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap