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

PHP wp_send_json函数代码示例

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

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



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

示例1: facebook_login

 /**
  * Maps our FB response fields to the correct user fields as found in wp_update_user. Then
  * calls setUpNewFacebookUser, and passes the correct response via JSON to JS.
  *
  * @since 2.0.0
  *
  * @return  JSON    A JSON object
  */
 public function facebook_login()
 {
     check_ajax_referer('facebook-nonce', 'security');
     $user = array('username' => $_POST['fb_response']['id'], 'user_login' => $_POST['fb_response']['id'], 'first_name' => $_POST['fb_response']['first_name'], 'last_name' => $_POST['fb_response']['last_name'], 'email' => $_POST['fb_response']['email'], 'user_url' => $_POST['fb_response']['link'], 'fb_id' => $_POST['fb_response']['id']);
     if (empty($user['username'])) {
         $status = $this->_zm_alr_helpers->status('invalid_username');
         $user_id = false;
     } else {
         $user_obj = get_user_by('login', $user['user_login']);
         if ($user_obj == false) {
             $user_obj = $this->setupNewFacebookUser($user);
         }
         // A WP user account already exists that is NOT associated with a FB account
         if ($user_obj == 'existing_user_email') {
             $status = $this->_zm_alr_helpers->status('username_exists');
         } elseif ($user_obj) {
             $user_id = $user_obj->ID;
             wp_set_auth_cookie($user_id, true);
             $status = $this->_zm_alr_helpers->status('success_login');
         } else {
             $status = $this->_zm_alr_helpers->status('invalid_username');
         }
     }
     $status = array_merge($status, $this->registerRedirect($user['user_login']));
     wp_send_json($status);
 }
开发者ID:JustManG,项目名称:Kursovaya,代码行数:34,代码来源:ALRSocialFacebook.php


示例2: run

 /**
  * AJAX callback method
  *
  * @return void
  */
 public function run()
 {
     // check nonce
     $this->check_nonce();
     // check if make is set
     if (!isset($_GET['make'])) {
         return;
     }
     // make
     $make = absint($_GET['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;
 }
开发者ID:valeriosouza,项目名称:wp-car-manager,代码行数:31,代码来源:GetModels.php


示例3: moxie_press_endpoint_data

function moxie_press_endpoint_data()
{
    global $wp_query;
    // get query vars
    $json = $wp_query->get('json');
    $name = $wp_query->get('name');
    // use this template redirect only if json is requested
    if ($json != 'true') {
        return;
    }
    // build the query
    $movie_data = array();
    // default args
    $args = array('post_type' => 'movie', 'posts_per_page' => 100);
    if ($name != '') {
        $args['name'] = $name;
    }
    // add name if provided in query
    // check if this particular request is cached, if not, perform the query
    if (false === ($moxie_cached_request = get_transient('moxie_cached_request_' . json_encode($args)))) {
        $moxie_cached_request = new WP_Query($args);
        set_transient('moxie_cached_request_' . json_encode($args), $moxie_cached_request);
    }
    // prepare the object we want to send as response
    if ($moxie_cached_request->have_posts()) {
        while ($moxie_cached_request->have_posts()) {
            $moxie_cached_request->the_post();
            $id = get_the_ID();
            $movie_data[] = array('id' => $id, 'title' => get_the_title(), 'poster_url' => get_post_meta($id, 'moxie_press_poster_url', true), 'rating' => get_post_meta($id, 'moxie_press_rating', true), 'year' => get_post_meta($id, 'moxie_press_year', true), 'short_description' => get_post_meta($id, 'moxie_press_description', true), 'mdbid' => get_post_meta($id, 'moxie_press_mdbid', true));
        }
        wp_reset_postdata();
    }
    // send json data using built-in WP function
    wp_send_json(array('data' => $movie_data));
}
开发者ID:camilodelvasto,项目名称:MoxiePress,代码行数:35,代码来源:json-api.php


示例4: ompf_portfolio_ajax

function ompf_portfolio_ajax()
{
    $out = array('error' => 0);
    $args = array();
    if (isset($_POST['portfolio_id']) && $_POST['portfolio_id']) {
        $args['portfolio_post_id'] = $_POST['portfolio_id'];
    } else {
        $out['error'] = 1;
        wp_send_json($out);
    }
    if (isset($_POST['category_id']) && $_POST['category_id']) {
        $args['category_id'] = $_POST['category_id'];
    }
    if (isset($_POST['paged']) && ($paged = intval($_POST['paged']))) {
        $args['query_args']['paged'] = $paged;
    }
    $portfolio = ompf_get_portfolio_thumbnails($args);
    $out['html'] = $portfolio['html'];
    if ($portfolio['pagination'] == 'pages') {
        $out['html_pagination'] = ompf_pagination_links($portfolio['paged'], $portfolio['max_num_pages'], array('empty_href' => true));
    } elseif ($portfolio['pagination'] == 'scroll') {
        $out['html_pagination'] = ompf_loadmore_link($portfolio['paged'], $portfolio['max_num_pages'], array('empty_href' => true));
    } else {
        $out['html_pagination'] = '';
    }
    wp_send_json($out);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:27,代码来源:portfolio-ajax.php


示例5: action_handler

 /**
  * Handle action requests.
  *
  * @return array|void Output JSON if DOING_AJAX, otherwise return an array
  */
 public function action_handler()
 {
     $response = array('success' => false, 'error' => null);
     if (empty($_POST['action']) || empty($_POST['name'])) {
         return false;
     }
     $action = $_POST['action'];
     $name = $_POST['name'];
     $result = false;
     switch ($action) {
         case 'carbon_add_sidebar':
             $result = $this->add_sidebar($name);
             break;
         case 'carbon_remove_sidebar':
             $result = $this->remove_sidebar($name);
             break;
     }
     if (is_wp_error($result)) {
         $response['error'] = $result->get_error_message();
     } else {
         $response['success'] = (bool) $result;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         wp_send_json($response);
     } else {
         return $response;
     }
 }
开发者ID:alispx,项目名称:jogja-core,代码行数:33,代码来源:Sidebar_Manager.php


示例6: audiotheme_ajax_is_new_venue

/**
 * Check for an existing venue with the same name.
 *
 * @since 1.0.0
 */
function audiotheme_ajax_is_new_venue()
{
    global $wpdb;
    $sql = $wpdb->prepare("SELECT post_title FROM {$wpdb->posts} WHERE post_type='audiotheme_venue' AND post_title=%s ORDER BY post_title ASC LIMIT 1", stripslashes($_GET['name']));
    $venue = $wpdb->get_col($sql);
    wp_send_json($venue);
}
开发者ID:sewmyheadon,项目名称:audiotheme,代码行数:12,代码来源:ajax.php


示例7: ajax_subscribeform_action_callback

function ajax_subscribeform_action_callback()
{
    global $wpdb;
    $error = '';
    $status = 'error';
    parse_str($_POST['data'], $_POST);
    //error_log(print_R($_POST,true));
    if (empty($_POST['email'])) {
        $error = 'All fields are required to enter.';
    } else {
        if (!wp_verify_nonce($_POST['_acf_nonce'], 'ajax_contactform')) {
            $error = __('Verification error, try again.', 'fws-ajax-contact-form');
        } else {
            $firstname = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
            $lastname = filter_var($_POST['lastname'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
            $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
            $email_check = check_email_address_mailgun($email);
            if ($email_check == 1) {
                $status = 'success';
                $wpdb->insert($wpdb->prefix . "signups", array('title' => $_POST['title'] == 'Other' && trim($_POST['other_title']) !== '' ? $_POST['other_title'] : $_POST['title'], 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'submittedtime' => date('Y-m-d H:i:s')));
                $error = 'Thanks for signing up for campaign updates. We hope you find them useful. ';
            } else {
                $error = $email_check;
            }
        }
    }
    $resp = array('status' => $status, 'errmessage' => $error);
    wp_send_json($resp);
}
开发者ID:parsonsc,项目名称:dofe,代码行数:29,代码来源:subscribe.php


示例8: ajax_hello_world

 public function ajax_hello_world()
 {
     $response = new stdClass();
     $response->hello = 'world';
     $response->time = current_time('mysql');
     wp_send_json($response);
 }
开发者ID:petenelson,项目名称:extending-wp-rest-api,代码行数:7,代码来源:class-extending-wp-rest-api-admin-ajax.php


示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->setData();
     $this->getList();
     wp_send_json(array('status' => 'success', 'list' => $this->list));
 }
开发者ID:andyUA,项目名称:kabmin-new,代码行数:7,代码来源:FavoriteList.php


示例10: tlpFmSettingsUpdate

 function tlpFmSettingsUpdate()
 {
     global $TLPfoodmenu;
     $error = true;
     if ($TLPfoodmenu->verifyNonce()) {
         $data = array();
         if ($_REQUEST['general']) {
             $general['slug'] = isset($_REQUEST['general']['slug']) ? $_REQUEST['general']['slug'] ? sanitize_title_with_dashes($_REQUEST['general']['slug']) : 'food-menu' : 'food-menu';
             $general['character_limit'] = isset($_REQUEST['general']['character_limit']) ? $_REQUEST['general']['character_limit'] ? intval($_REQUEST['general']['character_limit']) : 150 : 150;
             $general['em_display_col'] = $_REQUEST['general']['em_display_col'] ? esc_attr($_REQUEST['general']['em_display_col']) : 2;
             $general['currency'] = $_REQUEST['general']['currency'] ? esc_attr($_REQUEST['general']['currency']) : null;
             $general['currency_position'] = $_REQUEST['general']['currency_position'] ? esc_attr($_REQUEST['general']['currency_position']) : null;
             $data['general'] = $general;
             $TLPfoodmenu->activate();
         }
         if ($_REQUEST['others']) {
             $others['css'] = $_REQUEST['others']['css'] ? esc_attr($_REQUEST['others']['css']) : null;
             $data['others'] = $others;
         }
         update_option($TLPfoodmenu->options['settings'], $data);
         $error = false;
         $msg = __('Settings successfully updated', TLP_FOOD_MENU_SLUG);
     } else {
         $msg = __('Security Error !!', TLP_FOOD_MENU_SLUG);
     }
     $response = array('error' => $error, 'msg' => $msg);
     wp_send_json($response);
     die;
 }
开发者ID:dorkyhuman,项目名称:things,代码行数:29,代码来源:FmSettings.php


示例11: zn_mailchimp_subscribe

function zn_mailchimp_subscribe()
{
    $return = array();
    if (isset($_POST['email']) && isset($_POST['mailchimp_list'])) {
        if ($mailchimp_api = zget_option('mailchimp_api', 'general_options')) {
            if (is_email($_POST['email'])) {
                require_once THEME_BASE . '/framework/classes/class-mailchimp.php';
                $mailchimp = new ZnMailChimp($mailchimp_api);
                $email = $_POST['email'];
                $mailchimp_data = array('id' => $_POST['mailchimp_list'], 'email' => array('email' => $_POST['email']));
                // NAME FIELD
                if (isset($_POST['name'])) {
                    $mailchimp_data['merge_vars']['NAME'] = $_POST['name'];
                }
                // WEBSITE FIELD
                if (isset($_POST['website'])) {
                    $mailchimp_data['merge_vars']['WEBSITE'] = $_POST['website'];
                }
                $message = $mailchimp->call('lists/subscribe', $mailchimp_data);
                if (!empty($message['error'])) {
                    $return['error'] = true;
                    $return['message'] = '<div class="alert alert-success alert-dismissable">' . $message['error'] . '</div>';
                } else {
                    //print_z($mailchimp_data);
                    $return['message'] = '<div class="alert alert-success alert-dismissable">' . __('Thank you for subscribing !', 'zn_framework') . '</div>';
                }
            } else {
                $return['error'] = true;
                $return['message'] = '<div class="alert alert-danger alert-dismissable">' . __('Please enter a valid email address !', 'zn_framework') . '</div>';
            }
        }
    }
    wp_send_json($return);
}
开发者ID:fjbeteiligung,项目名称:development,代码行数:34,代码来源:theme_ajax.php


示例12: 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


示例13: cropImageWithFaceDectection

function cropImageWithFaceDectection($metadata, $attachment_id)
{
    if (!isset($metadata['sizes'])) {
        return $metadata;
    }
    $upload_path = wp_upload_dir();
    $path = $upload_path['basedir'];
    //handle the different media upload directory structures
    if (isset($path)) {
        $file = trailingslashit($upload_path['basedir'] . '/') . $metadata['file'];
    } else {
        $file = trailingslashit($upload_path['path']) . $metadata['file'];
    }
    $client = new Client('5e3a3ac24363af113e04a58c61637ea4', 'sXA4iYYphLzg1z8IAcFAtPf8UdcXKwHm', 'http://apicn.faceplusplus.com');
    /** @var \FaceCrop\Type\Face[] $result */
    $result = $client->detect('http://showbizviet.vn/upload/files/data/2013/8/2/18/466473/1825600192_cham-soc-da-chuan-nhu-ngoc-trinh%202.jpg');
    $height = $result[0]->getPosition()->getHeight();
    $width = $result[0]->getPosition()->getWidth();
    $leftEye = $result[0]->getPosition()->getEyeLeft();
    $mouthRight = $result[0]->getPosition()->getMouthRight();
    $editor = wp_get_image_editor($file);
    $startX = $leftEye->x / $width * 100;
    $startY = $leftEye->y / $height * 100;
    $editor->crop($startX - 100, $startY - 100, 500, 300, 500, 300, false);
    $result = $editor->save($file);
    wp_send_json(array($result, $file));
    return $metadata;
}
开发者ID:nguyenvanduocit,项目名称:WP-Smart-Crop,代码行数:28,代码来源:wp_face_crop.php


示例14: woo_king_get_cart

function woo_king_get_cart()
{
    global $woocommerce;
    $cart_data = '<div class="shopping_cart_inner"><ul>';
    if (WC()->cart->cart_contents_count == 0) {
        $cart_data .= '<li class="no-product-in-cart">No products in the cart.</li>';
    }
    foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
        $_product = apply_filters('woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key);
        $product_id = apply_filters('woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key);
        if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_cart_item_visible', true, $cart_item, $cart_item_key)) {
            if ($_product->is_sold_individually()) {
                $product_quantity = 1;
            } else {
                $product_quantity = $cart_item['quantity'];
            }
            $thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key);
            $cart_data .= '<li><a href="' . $_product->get_permalink($cart_item) . '">' . $thumbnail . $_product->get_title() . '</a>
			<span class="quantity">' . $product_quantity . ' x ' . WC()->cart->get_product_price($_product) . '</span></li>';
        }
    }
    $cart_data .= '</ul>';
    $cart_data .= '<div class="king-cart-footer"><a class="k-cart-button" href="' . $woocommerce->cart->get_cart_url() . '">Cart <i class="fa fa-shopping-cart"></i></a><span class="total">Total: ' . WC()->cart->get_cart_total() . '</span></div>';
    $cart_data .= '</div>';
    $data = array('cart_content' => $cart_data, 'count' => WC()->cart->cart_contents_count, 'total' => WC()->cart->get_cart_total());
    wp_send_json($data);
}
开发者ID:pivotlearning,项目名称:wpsite,代码行数:27,代码来源:woo-functions.php


示例15: run

 public function run()
 {
     // Check nonce
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'sp_ajax_sc_gpp')) {
         echo '-1';
         return;
     }
     $identifier = esc_sql($_POST['identifier']);
     $ptl_manager = new SP_Connection_Manager();
     if (isset($_POST['by_slug']) && 'true' == $_POST['by_slug']) {
         $ptl = $ptl_manager->get_link_by_slug($identifier);
     } else {
         $ptl = $ptl_manager->get_link($identifier);
     }
     // Get children
     $parent_posts = get_posts(array('post_type' => $ptl->get_child(), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC'));
     $json_posts = array();
     if (count($parent_posts) > 0) {
         foreach ($parent_posts as $parent_post) {
             $json_posts[$parent_post->ID] = $parent_post->post_title;
         }
     }
     // Send the JSON
     wp_send_json($json_posts);
     exit;
     // Better safe than sorry lol
 }
开发者ID:jmead,项目名称:trucell-cms,代码行数:27,代码来源:class-hook-ajax-get-child-posts.php


示例16: actionSaveImage

 public function actionSaveImage()
 {
     if (!empty($_POST['imageUrl'])) {
         $url = \parse_url($_POST['imageUrl']);
         if ($curlDescriptor = \curl_init($_POST['imageUrl'])) {
             \curl_setopt($curlDescriptor, CURLOPT_HEADER, 0);
             \curl_setopt($curlDescriptor, CURLOPT_RETURNTRANSFER, 1);
             \curl_setopt($curlDescriptor, CURLOPT_BINARYTRANSFER, 1);
             $rawImage = \curl_exec($curlDescriptor);
             \curl_close($curlDescriptor);
             if ($rawImage) {
                 include_once ABSPATH . 'wp-admin/includes/image.php';
                 include_once ABSPATH . 'wp-admin/includes/file.php';
                 include_once ABSPATH . 'wp-admin/includes/media.php';
                 $wpFileType = \wp_check_filetype(\basename($url['path']), null);
                 $tmpDir = \ini_get('upload_tmp_dir') ? \ini_get('upload_tmp_dir') : \sys_get_temp_dir();
                 $tempName = $tmpDir . '/' . \uniqid() . '.' . $wpFileType['ext'];
                 \file_put_contents($tempName, $rawImage);
                 $_FILES['async-upload'] = array('name' => \trim(\str_replace(' ', '', basename($tempName))), 'type' => $wpFileType['type'], 'tmp_name' => $tempName, 'error' => 0, 'size' => \filesize($tempName));
                 \media_handle_upload('async-upload', 0, array(), array('test_form' => false, 'action' => 'upload-attachment'));
                 \wp_send_json(array('status' => 'success'));
             }
         }
     }
     \wp_send_json(array('status' => 'error'));
 }
开发者ID:sharpfuryz,项目名称:zoommy_wordpress,代码行数:26,代码来源:Helper.php


示例17: motopressCESetError

function motopressCESetError($message = '')
{
    global $motopressCESettings;
    header('HTTP/1.1 500 Internal Server Error');
    wp_send_json(array('debug' => $motopressCESettings ? $motopressCESettings['debug'] : false, 'message' => $message));
    exit;
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:7,代码来源:functions.php


示例18: wl_core_send_json

/**
 * Wordlift wrapper for wl_send_json function
 * @see https://codex.wordpress.org/Function_Reference/wp_send_json
 * Ensure output buffer is cleaned
 */
function wl_core_send_json($response)
{
    if (ob_get_contents()) {
        ob_clean();
    }
    return wp_send_json($response);
}
开发者ID:Byrlyne,项目名称:wordlift-plugin,代码行数:12,代码来源:wordlift_core_functions.php


示例19: process_access_token_request

 protected function process_access_token_request()
 {
     if (array_key_exists('code', $_REQUEST) && array_key_exists('post_id', $_REQUEST)) {
         global $pms_post_protected;
         global $pms_session;
         $post_id = intval($_REQUEST['post_id']);
         $settings = $this->get_settings();
         $url = Postmatic_Social_Gplus_Authenticator::$ACCESS_URL;
         $client_id = $settings[Postmatic_Social_Gplus_Authenticator::$CLIENT_ID];
         $client_secret = $settings[Postmatic_Social_Gplus_Authenticator::$CLIENT_SECRET];
         $query_string = $this->to_query_string(array('code' => $_REQUEST['code'], 'client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => $this->get_oauth_callback(), 'grant_type' => 'authorization_code'));
         $response = wp_remote_post(esc_url_raw($url), array('body' => $query_string, 'sslverify' => false));
         if (is_wp_error($response)) {
             $error_string = $response->get_error_message();
             throw new Exception($error_string);
         } else {
             $response_body = json_decode($response['body'], true);
             if ($response_body && is_array($response_body) && array_key_exists('access_token', $response_body)) {
                 $access_token = $response_body['access_token'];
                 $user_details = $this->get_user_details($access_token);
                 $pms_session['user'] = $user_details;
                 $pms_post_protected = true;
                 $user_details['disconnect_content'] = $GLOBALS['postmatic-social']->disconnect_content($user_details, $post_id);
                 wp_send_json($user_details);
                 die;
             } else {
                 throw new Exception(__('Missing the access_token parameter', 'postmatic-social'));
             }
         }
     } else {
         die;
     }
 }
开发者ID:johnpuddephatt,项目名称:postmatic-social,代码行数:33,代码来源:Postmatic_Social_Gplus_Authenticator.php


示例20: process_ajax_request

 /**
  * Handle Post Customizer AJAX requests
  *
  * @access public
  * @since 0.1.0
  */
 public function process_ajax_request()
 {
     check_ajax_referer('post-customizer');
     if (empty($_POST['post_customizer_action'])) {
         return;
     }
     if ('get_sidebar' == $_POST['post_customizer_action']) {
         if (empty($_POST['post_id'])) {
             return;
         }
         $data = array('sidebarHTML' => $this->_render_sidebar_data($_POST['post_id']));
     } elseif ('save_field' == $_POST['post-customizer_action'] && !empty($_POST['field']) && !empty($_POST['post_id'])) {
         $data = array();
         switch ($_POST['field']) {
             case 'post_title':
             case 'post_content':
                 wp_update_post(array('ID' => $_POST['post_id'], $_POST['field'] => $_POST['data']));
                 $data['changed'] = $_POST['field'];
                 $data['value'] = $_POST['data'];
                 break;
         }
     } else {
         //Error!
     }
     wp_send_json($data);
 }
开发者ID:resarahman,项目名称:Post-Customizer,代码行数:32,代码来源:class-post-customizer.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_send_json_error函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_scripts函数代码示例发布时间: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