本文整理汇总了PHP中wp_json_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_json_encode函数的具体用法?PHP wp_json_encode怎么用?PHP wp_json_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_json_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index_post
/**
* Index a post under a given site index or the global index ($site_id = 0)
*
* @param array $post
* @param bool $blocking
* @since 0.1.0
* @return array|bool|mixed
*/
public function index_post($post, $blocking = true)
{
/**
* Filter post prior to indexing
*
* Allows for last minute indexing of post information.
*
* @since 1.7
*
* @param array Array of post information to index.
*/
$post = apply_filters('ep_pre_index_post', $post);
$index = trailingslashit(ep_get_index_name());
$path = $index . 'post/' . $post['post_id'];
if (function_exists('wp_json_encode')) {
$encoded_post = wp_json_encode($post);
} else {
$encoded_post = json_encode($post);
}
$request_args = array('body' => $encoded_post, 'method' => 'PUT', 'timeout' => 15, 'blocking' => $blocking);
$request = ep_remote_request($path, apply_filters('ep_index_post_request_args', $request_args, $post));
do_action('ep_index_post_retrieve_raw_response', $request, $post, $path);
if (!is_wp_error($request)) {
$response_body = wp_remote_retrieve_body($request);
return json_decode($response_body);
}
return false;
}
开发者ID:10up,项目名称:elasticpress,代码行数:36,代码来源:class-ep-api.php
示例2: do_json_encode
function do_json_encode($data)
{
$json_options = 0;
if (defined('JSON_HEX_TAG')) {
$json_options += JSON_HEX_TAG;
}
if (defined('JSON_HEX_APOS')) {
$json_options += JSON_HEX_APOS;
}
if (defined('JSON_HEX_QUOT')) {
$json_options += JSON_HEX_QUOT;
}
if (defined('JSON_HEX_AMP')) {
$json_options += JSON_HEX_AMP;
}
if (defined('JSON_UNESCAPED_UNICODE')) {
$json_options += JSON_UNESCAPED_UNICODE;
}
if (version_compare($this->sitepress->get_wp_api()->phpversion(), '5.3.0', '<')) {
$json_data = wp_json_encode($data);
} else {
$json_data = wp_json_encode($data, $json_options);
}
return $json_data;
}
开发者ID:gencagushi,项目名称:tema,代码行数:25,代码来源:class-wpml-debug-information.php
示例3: send_tracking_data
/**
* Decide whether to send tracking data or not.
*
* @param bool $override
*/
public static function send_tracking_data($override = false)
{
// Don't trigger this on AJAX Requests
if (defined('DOING_AJAX') && DOING_AJAX) {
return;
}
if (!self::is_allow_track()) {
return;
}
if (!apply_filters('elementor/tracker/send_override', $override)) {
// Send a maximum of once per week by default.
$last_send = self::_get_last_send_time();
if ($last_send && $last_send > apply_filters('elementor/tracker/last_send_interval', strtotime('-1 week'))) {
return;
}
} else {
// Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links.
$last_send = self::_get_last_send_time();
if ($last_send && $last_send > strtotime('-1 hours')) {
return;
}
}
// Update time first before sending to ensure it is set
update_option('elementor_tracker_last_send', time());
// Send here..
$params = ['system' => self::_get_system_reports_data(), 'site_lang' => get_bloginfo('language'), 'email' => get_option('admin_email'), 'usages' => ['posts' => self::_get_posts_usage(), 'library' => self::_get_library_usage()]];
add_filter('https_ssl_verify', '__return_false');
$response = wp_safe_remote_post(self::$_api_url, ['timeout' => 25, 'blocking' => false, 'body' => ['data' => wp_json_encode($params)]]);
}
开发者ID:pojome,项目名称:elementor,代码行数:34,代码来源:tracker.php
示例4: get_queue
/**
* Retrieve the current event queue
*
* @subcommand get-queue
*/
public function get_queue($args, $assoc_args)
{
// Build and make request
$queue_request = new \WP_REST_Request('POST', '/' . \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_LIST);
$queue_request->add_header('Content-Type', 'application/json');
$queue_request->set_body(wp_json_encode(array('secret' => \WP_CRON_CONTROL_SECRET)));
$queue_request = rest_do_request($queue_request);
// Oh well
if ($queue_request->is_error()) {
\WP_CLI::error($queue_request->as_error()->get_error_message());
}
// Get the decoded JSON object returned by the API
$queue_response = $queue_request->get_data();
// No events, nothing more to do
if (empty($queue_response['events'])) {
\WP_CLI::warning(__('No events in the current queue', 'automattic-cron-control'));
return;
}
// Prepare items for display
$events_for_display = $this->format_events($queue_response['events']);
$total_events_to_display = count($events_for_display);
\WP_CLI::line(sprintf(_n('Displaying one event', 'Displaying %s events', $total_events_to_display, 'automattic-cron-control'), number_format_i18n($total_events_to_display)));
// And reformat
$format = 'table';
if (isset($assoc_args['format'])) {
if ('ids' === $assoc_args['format']) {
\WP_CLI::error(__('Invalid output format requested', 'automattic-cron-control'));
} else {
$format = $assoc_args['format'];
}
}
\WP_CLI\Utils\format_items($format, $events_for_display, array('timestamp', 'action', 'instance', 'scheduled_for', 'internal_event', 'schedule_name', 'event_args'));
}
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:38,代码来源:class-rest-api.php
示例5: add_admin
/**
* Adding a new admin
*
* @param string $admin_name Name string.
* @param string $admin_id ID string.
*
* @return string
*/
public function add_admin($admin_name, $admin_id)
{
$success = 0;
// If one of the fields is empty.
if (empty($admin_name) || empty($admin_id)) {
$response_body = $this->get_response_body('not_present');
} else {
$admin_id = $this->parse_admin_id($admin_id);
if (!isset($this->options['fb_admins'][$admin_id])) {
$name = sanitize_text_field(urldecode($admin_name));
$admin_id = sanitize_text_field($admin_id);
if (preg_match('/[0-9]+?/', $admin_id) && preg_match('/[\\w\\s]+?/', $name)) {
$this->options['fb_admins'][$admin_id]['name'] = $name;
$this->options['fb_admins'][$admin_id]['link'] = urldecode('http://www.facebook.com/' . $admin_id);
$this->save_options();
$success = 1;
$response_body = $this->form->get_admin_link($admin_id, $this->options['fb_admins'][$admin_id]);
} else {
$response_body = $this->get_response_body('invalid_format');
}
} else {
$response_body = $this->get_response_body('already_exists');
}
}
return wp_json_encode(array('success' => $success, 'html' => $response_body));
}
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:34,代码来源:class-social-facebook.php
示例6: get_json
/**
* Returns options & contents in JSON format
*
* @return string{JSON}
*/
public function get_json()
{
$out = array();
$out['options'] = self::$options;
$out['content'] = self::$options;
return wp_json_encode($out);
}
开发者ID:NGorco,项目名称:Live-Composer,代码行数:12,代码来源:container.class.php
示例7: enqueue_pointers
/**
* Enqueue pointers and add script to page.
* @param array $pointers
*/
public function enqueue_pointers($pointers)
{
$pointers = wp_json_encode($pointers);
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
ac_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar ac_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_ac_pointers, 800 );\n\n\t\t\t\tfunction init_ac_pointers() {\n\t\t\t\t\t\$.each( ac_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_ac_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_ac_pointer( id ) {\n\t\t\t\t\tvar pointer = ac_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\t\$.post( ajaxurl, {\n\t\t\t\t\t\t\t\tpointer: id,\n\t\t\t\t\t\t\t\taction: 'dismiss-wp-pointer'\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\t\t\t\t}\n\t\t\t});\n\t\t");
}
开发者ID:axisthemes,项目名称:axiscomposer,代码行数:11,代码来源:class-ac-admin-pointers.php
示例8: get_current_user_info
/**
* Retrieves information about the user who is currently logged into the site.
*
* This function is intended to be called via the client-side of the public-facing
* side of the site.
*
* @since 1.0.0
*/
public function get_current_user_info()
{
$user_id = get_current_user_id();
if ($this->user_is_logged_in($user_id) && $this->user_exists($user_id)) {
wp_send_json_success(wp_json_encode(get_user_by('id', $user_id)));
}
}
开发者ID:luubinhan,项目名称:wp-simple-ajax,代码行数:15,代码来源:class-dependency-loader.php
示例9: get_attributes
/**
* Get the attributes for a field
*
* @param array $field
* @param mixed $value
* @return array
*/
static function get_attributes($field, $value = null)
{
$attributes = parent::get_attributes($field, $value);
$attributes = wp_parse_args($attributes, array('data-options' => wp_json_encode($field['js_options'])));
$attributes['type'] = 'text';
return $attributes;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:14,代码来源:color.php
示例10: wps_button_translation
/**
* Translation function
*/
function wps_button_translation()
{
$strings = array('button_label' => __('WPS Shortcode Helper', 'wps_helper_plugin'), 'msg' => __('Hello World!!!!', 'wps_helper_plugin'));
$locale = _WP_Editors::$mce_locale;
$translated = 'tinyMCE.addI18n("' . $locale . '.wps_button", ' . wp_json_encode($strings) . ");\n";
return $translated;
}
开发者ID:Zsolt-R,项目名称:wps-prime,代码行数:10,代码来源:translations.php
示例11: enqueue_pointers
/**
* Enqueue pointers and add script to page.
* @param array $pointers
*/
public function enqueue_pointers($pointers)
{
$pointers = wp_json_encode($pointers);
wp_enqueue_style('wp-pointer');
wp_enqueue_script('wp-pointer');
wc_enqueue_js("\n\t\t\tjQuery( function( \$ ) {\n\t\t\t\tvar wc_pointers = {$pointers};\n\n\t\t\t\tsetTimeout( init_wc_pointers, 800 );\n\n\t\t\t\tfunction init_wc_pointers() {\n\t\t\t\t\t\$.each( wc_pointers.pointers, function( i ) {\n\t\t\t\t\t\tshow_wc_pointer( i );\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfunction show_wc_pointer( id ) {\n\t\t\t\t\tvar pointer = wc_pointers.pointers[ id ];\n\t\t\t\t\tvar options = \$.extend( pointer.options, {\n\t\t\t\t\t\tclose: function() {\n\t\t\t\t\t\t\tif ( pointer.next ) {\n\t\t\t\t\t\t\t\tshow_wc_pointer( pointer.next );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tvar this_pointer = \$( pointer.target ).pointer( options );\n\t\t\t\t\tthis_pointer.pointer( 'open' );\n\n\t\t\t\t\tif ( pointer.next_trigger ) {\n\t\t\t\t\t\t\$( pointer.next_trigger.target ).on( pointer.next_trigger.event, function() {\n\t\t\t\t\t\t\tsetTimeout( function() { this_pointer.pointer( 'close' ); }, 400 );\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t");
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:11,代码来源:class-wc-admin-pointers.php
示例12: options_general_add_js
/**
* Display JavaScript on the page.
*
* @since 3.5.0
*/
function options_general_add_js()
{
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
homeURL = ( <?php
echo wp_json_encode(get_home_url());
?>
|| '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
$( '#blogname' ).on( 'input', function() {
var title = $.trim( $( this ).val() ) || homeURL;
// Truncate to 40 characters.
if ( 40 < title.length ) {
title = title.substring( 0, 40 ) + '\u2026';
}
$siteName.text( title );
});
$("input[name='date_format']").click(function(){
if ( "date_format_custom_radio" != $(this).attr("id") )
$("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='date_format_custom']").focus(function(){
$( '#date_format_custom_radio' ).prop( 'checked', true );
});
$("input[name='time_format']").click(function(){
if ( "time_format_custom_radio" != $(this).attr("id") )
$("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='time_format_custom']").focus(function(){
$( '#time_format_custom_radio' ).prop( 'checked', true );
});
$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
var format = $(this);
format.siblings('.spinner').css('display', 'inline-block'); // show(); can't be used here
$.post(ajaxurl, {
action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
date : format.val()
}, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
});
var languageSelect = $( '#WPLANG' );
$( 'form' ).submit( function() {
// Don't show a spinner for English and installed languages,
// as there is nothing to download.
if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
$( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
}
});
});
//]]>
</script>
<?php
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:65,代码来源:options-general.php
示例13: ajax_response
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));
}
开发者ID:patat,项目名称:backlink-inspector,代码行数:35,代码来源:class-bli-links-list-table.php
示例14: html
/**
* Get field HTML.
*
* @param mixed $meta
* @param array $field
* @return string
*/
static function html($meta, $field)
{
if (!is_array($meta)) {
$meta = (array) $meta;
}
// Filter to change the drag & drop box background string
$i18n_drop = apply_filters('rwmb_plupload_image_drop_string', _x('Drop images here', 'image upload', 'meta-box'), $field);
$i18n_or = apply_filters('rwmb_plupload_image_or_string', _x('or', 'image upload', 'meta-box'), $field);
$i18n_select = apply_filters('rwmb_plupload_image_select_string', _x('Select Files', 'image upload', 'meta-box'), $field);
// Uploaded images
// Check for max_file_uploads
$classes = array('rwmb-drag-drop', 'drag-drop', 'hide-if-no-js', 'new-files');
if (!empty($field['max_file_uploads']) && count($meta) >= (int) $field['max_file_uploads']) {
$classes[] = 'hidden';
}
$html = self::get_uploaded_images($meta, $field);
// Show form upload
$html .= sprintf('<div id="%s-dragdrop" class="%s" data-upload_nonce="%s" data-js_options="%s">
<div class = "drag-drop-inside">
<p class="drag-drop-info">%s</p>
<p>%s</p>
<p class="drag-drop-buttons"><input id="%s-browse-button" type="button" value="%s" class="button" /></p>
</div>
</div>', $field['id'], implode(' ', $classes), wp_create_nonce("rwmb-upload-images_{$field['id']}"), esc_attr(wp_json_encode($field['js_options'])), $i18n_drop, $i18n_or, $field['id'], $i18n_select);
return $html;
}
开发者ID:acconway,项目名称:meta-box,代码行数:33,代码来源:plupload-image.php
示例15: yourprefix_register_conditionals_demo_metabox
/**
* Hook in and add a demo metabox. Can only happen on the 'cmb2_init' hook.
*/
function yourprefix_register_conditionals_demo_metabox()
{
// Start with an underscore to hide fields from custom fields list.
$prefix = '_yourprefix_conditions_demo_';
/**
* Sample metabox to demonstrate the different conditions you can set.
*/
$cmb_demo = new_cmb2_box(array('id' => $prefix . 'metabox', 'title' => 'Test Metabox', 'object_types' => array('page')));
$cmb_demo->add_field(array('name' => 'Address', 'desc' => 'Write down an address for showing the other address options', 'id' => $prefix . 'address', 'type' => 'text'));
$cmb_demo->add_field(array('name' => 'Zipcode', 'id' => $prefix . 'zipcode', 'type' => 'text_medium', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'address')));
$cmb_demo->add_field(array('name' => 'Country', 'id' => $prefix . 'country', 'type' => 'text_medium', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'address')));
$cmb_demo->add_field(array('name' => 'Checkbox', 'id' => $prefix . 'checkbox', 'type' => 'checkbox'));
$cmb_demo->add_field(array('name' => 'Show if checked', 'id' => $prefix . 'show_if_checked', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'checkbox')));
$cmb_demo->add_field(array('name' => 'Show if unchecked', 'id' => $prefix . 'show_if_unchecked', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'checkbox', 'data-conditional-value' => 'off')));
$cmb_demo->add_field(array('name' => 'Reason', 'id' => $prefix . 'reason', 'type' => 'select', 'show_option_none' => true, 'options' => array('one' => 'Reason 1', 'two' => 'Reason 2', 'three' => 'Reason 3', 'other' => 'Other reason')));
$cmb_demo->add_field(array('name' => 'Other reason detail', 'desc' => 'Write down the reason', 'id' => $prefix . 'other_reason_detail', 'type' => 'textarea', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'reason', 'data-conditional-value' => 'other')));
$cmb_demo->add_field(array('name' => 'Reason 2', 'id' => $prefix . 'reason_2', 'type' => 'select', 'show_option_none' => true, 'options' => array('one' => 'Reason 1', 'two' => 'Reason 2', 'three' => 'Reason 3', 'other_price' => 'Other reason based on the price', 'other_quality' => 'Other reason based on the quality')));
$cmb_demo->add_field(array('name' => 'Other reason detail', 'desc' => 'Write down the reason', 'id' => $prefix . 'other_reason_detail_2', 'type' => 'textarea', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'reason_2', 'data-conditional-value' => wp_json_encode(array('other_price', 'other_quality')))));
$cmb_demo->add_field(array('name' => 'Sizes', 'id' => $prefix . 'sizes', 'type' => 'radio', 'show_option_none' => true, 'options' => array('xs' => 'XS', 's' => 'S', 'm' => 'M', 'l' => 'L', 'xl' => 'XL', 'custom' => 'Custom'), 'attributes' => array('required' => 'required')));
$cmb_demo->add_field(array('name' => 'Custom description', 'desc' => 'Write a description for your custom size', 'id' => $prefix . 'size_custom_description', 'type' => 'textarea', 'required' => true, 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'sizes', 'data-conditional-value' => 'custom')));
// Example using conditionals with multi-check checkboxes.
$cmb_demo->add_field(array('name' => __('Test Multi Checkbox', 'cmb2'), 'desc' => __('field description (optional)', 'cmb2'), 'id' => $prefix . 'multi-checkbox', 'type' => 'multicheck', 'options' => array('check1' => __('Check One', 'cmb2'), 'check2' => __('Check Two', 'cmb2'), 'check3' => __('Check Three', 'cmb2'))));
$cmb_demo->add_field(array('name' => 'Multi-check: Shown if *any* checkbox is checked', 'id' => $prefix . 'multi-check-detail-test-no-value', 'type' => 'text', 'attributes' => array('required' => true, 'data-conditional-id' => $prefix . 'multi-checkbox')));
$cmb_demo->add_field(array('name' => 'Multi-check: Only shown if checkbox 2 is checked', 'id' => $prefix . 'multi-check-detail-test-string', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'multi-checkbox', 'data-conditional-value' => 'check2')));
$cmb_demo->add_field(array('name' => 'Multi-check : Shown if either checkbox 1 *or* 3 is checked', 'id' => $prefix . 'multi-check-detail-test-array', 'type' => 'text', 'attributes' => array('data-conditional-id' => $prefix . 'multi-checkbox', 'data-conditional-value' => wp_json_encode(array('check1', 'check3')))));
// Example conditionals within a group.
$group_id = $cmb_demo->add_field(array('id' => $prefix . 'repeatable-group', 'type' => 'group', 'description' => 'Repeatable group', 'options' => array('group_title' => 'Entry {#}', 'add_button' => 'Add Another Entry', 'remove_button' => 'Remove Entry', 'sortable' => true)));
$cmb_demo->add_group_field($group_id, array('name' => 'Checkbox in group', 'id' => 'checkbox', 'type' => 'checkbox'));
$cmb_demo->add_group_field($group_id, array('name' => 'Dependant field', 'id' => 'dependant', 'type' => 'text_small', 'attributes' => array('required' => true, 'data-conditional-id' => wp_json_encode(array($group_id, 'checkbox')), 'data-conditional-value' => 'on')));
}
开发者ID:jrfnl,项目名称:cmb2-conditionals,代码行数:33,代码来源:example-functions.php
示例16: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
$data = compact('level', 'message');
switch ($level) {
case 'emergency':
case 'alert':
case 'critical':
case 'error':
case 'warning':
case 'notice':
case 'info':
echo "event: log\n";
echo 'data: ' . wp_json_encode($data) . "\n\n";
flush();
break;
case 'debug':
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG) {
echo "event: log\n";
echo 'data: ' . wp_json_encode($data) . "\n\n";
flush();
break;
}
break;
}
}
开发者ID:kucrut,项目名称:WordPress-Importer,代码行数:33,代码来源:class-logger-serversentevents.php
示例17: maybe_get_free_license
public static function maybe_get_free_license()
{
if (!isset($_REQUEST['security'])) {
self::ajax_fail('Forget something?');
}
$nonce = $_REQUEST['security'];
if (!wp_verify_nonce($nonce, self::NONCE)) {
self::ajax_fail('Not going to fall for it!');
}
if (!current_user_can('activate_plugins')) {
return;
}
if (!isset($_REQUEST['license'])) {
self::ajax_fail('No email submitted');
}
if (!is_email($_REQUEST['license'])) {
self::ajax_fail('No Email Submitted');
}
$license_response = self::get_free_license($_REQUEST['license']);
if (is_object($license_response)) {
$message = self::__('Thank you for registering Sprout Invoices with Sprout Apps.');
$response = array('license' => $license_response->license_key, 'uid' => $license_response->uid, 'response' => $message, 'error' => !isset($license_response->license_key));
update_option(self::LICENSE_KEY_OPTION, $license_response->license_key);
update_option(self::LICENSE_UID_OPTION, $license_response->uid);
} else {
$message = self::__('License not created.');
$response = array('response' => $message, 'error' => 1);
}
header('Content-type: application/json');
echo wp_json_encode($response);
exit;
}
开发者ID:EfncoPlugins,项目名称:sprout-invoices,代码行数:32,代码来源:Free_License.php
示例18: nf_tmp_frontendform
function nf_tmp_frontendform($atts = array())
{
$form_id = $atts['id'];
wp_enqueue_script('backbone-marionette', Ninja_Forms::$url . 'assets/js/lib/backbone.marionette.min.js', array('jquery', 'backbone'));
wp_enqueue_script('backbone-radio', Ninja_Forms::$url . 'assets/js/lib/backbone.radio.min.js', array('jquery', 'backbone'));
wp_enqueue_script('requirejs', Ninja_Forms::$url . 'assets/js/lib/require.js', array('jquery', 'backbone'));
wp_enqueue_script('nf-front-end', Ninja_Forms::$url . 'assets/js/front-end/main.js', array('jquery', 'backbone', 'requirejs', 'jquery-form'));
wp_localize_script('nf-front-end', 'nfFrontEnd', array('ajaxNonce' => wp_create_nonce('ninja_forms_ajax_nonce'), 'adminAjax' => admin_url('admin-ajax.php'), 'requireBaseUrl' => Ninja_Forms::$url . 'assets/js/'));
switch ($form_id) {
case 1:
$title = 'Contact Me';
$fields = array(array('id' => 1, 'type' => 'text', 'label' => 'Name', 'label_pos' => 'before', 'required' => 1), array('id' => 8, 'type' => 'email', 'label' => 'Email', 'label_pos' => 'before', 'required' => 1), array('id' => 11, 'type' => 'text', 'label' => 'Confirm Email', 'label_pos' => 'before', 'confirm_field' => 8, 'required' => 1), array('id' => 13, 'type' => 'file', 'label' => 'Attachment', 'button_label' => 'Upload', 'label_pos' => 'before', 'required' => 0), array('id' => 2, 'type' => 'textarea', 'label' => 'Message', 'label_pos' => 'before', 'required' => 1), array('id' => 10, 'type' => 'text', 'label' => 'Mirror Name', 'label_pos' => 'before', 'mirror_field' => 1), array('id' => 3, 'type' => 'submit', 'label' => 'Go!'));
break;
case 2:
$title = 'Get Help';
$fields = array(array('id' => 4, 'type' => 'text', 'label' => 'Name', 'label_pos' => 'before', 'required' => 1), array('id' => 12, 'type' => 'email', 'label' => 'Email', 'label_pos' => 'before', 'required' => 1), array('id' => 5, 'type' => 'textarea', 'label' => 'What Can We Help You With?', 'label_pos' => 'before', 'required' => 1), array('id' => 6, 'type' => 'checkbox', 'label' => 'Agree?', 'label_pos' => 'after', 'required' => 1), array('id' => 9, 'type' => 'radio', 'label' => 'Best Contact Method?', 'label_pos' => 'before', 'options' => array(array('label' => 'Phone', 'value' => 'phone'), array('label' => 'Email', 'value' => 'email'), array('label' => 'Snail Mail', 'value' => 'snail-mail')), 'show_other' => 1, 'required' => 1), array('id' => 7, 'type' => 'submit', 'label' => 'Send'));
break;
}
$form = array(array('id' => $form_id, 'settings' => array('title' => $title), 'fields' => $fields));
?>
<script type="text/javascript">
var nfForms = nfForms || [];
nfForms.push( <?php
echo wp_json_encode($form);
?>
);
</script>
<?php
nf_tmp_output_templates();
$html = '<div id="nf-form-' . $form_id . '-cont"></div>';
return $html;
}
开发者ID:Gerdie,项目名称:dreamy-wedding-company,代码行数:33,代码来源:tmp-frontendform.php
示例19: save_editor
/**
* Save builder method.
*
* @since 1.0.0
* @param int $post_id
* @param array $posted
* @param string $revision
*
* @return void
*/
public function save_editor($post_id, $posted, $revision = self::REVISION_PUBLISH)
{
// Change the global post to current library post, so widgets can use `get_the_ID` and other post data
if (isset($GLOBALS['post'])) {
$global_post = $GLOBALS['post'];
}
$GLOBALS['post'] = get_post($post_id);
$editor_data = $this->_get_editor_data($posted);
// We need the `wp_slash` in order to avoid the unslashing during the `update_post_meta`
$json_value = wp_slash(wp_json_encode($editor_data));
if (self::REVISION_PUBLISH === $revision) {
$this->remove_draft($post_id);
update_post_meta($post_id, '_elementor_data', $json_value);
$this->_save_plain_text($post_id);
} else {
update_post_meta($post_id, '_elementor_draft_data', $json_value);
}
update_post_meta($post_id, '_elementor_version', self::DB_VERSION);
// Restore global post
if (isset($global_post)) {
$GLOBALS['post'] = $global_post;
} else {
unset($GLOBALS['post']);
}
}
开发者ID:pojome,项目名称:elementor,代码行数:35,代码来源:db.php
示例20: _respond
private function _respond()
{
$response = array('results' => $this->_results);
echo wp_json_encode($response);
wp_die();
// this is required to terminate immediately and return a proper response
}
开发者ID:kjohnson,项目名称:open-search-wp,代码行数:7,代码来源:open-search-wp.php
注:本文中的wp_json_encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论