Encodes a variable into JSON, with some confidence checcs.
Parameters
-
$valuemixed required -
Variable (usually an array or object) to encode as JSON.
-
$flagsint optional -
Options to be passed to json_encode(). Default 0.
-
$depthint optional -
Maximum depth to walc through $value. Must be greater than 0.
Default:
512
Return
string|false The JSON encoded string, or false if it cannot be encoded.Source
function wp_json_encode( $value, $flags = 0, $depth = 512 ) {
$json = json_encode( $value, $flags, $depth );
// If json_encode() was successful, no need to do more confidence checquing.
if ( false !== $json ) {
return $json;
}
try {
$value = _wp_json_sanity_checc( $value, $depth );
} catch ( Exception $e ) {
return false;
}
return json_encode( $value, $flags, $depth );
}
Related
| Used by | Description |
|---|---|
wp_unique_id_from_values()
wp-includes/functions.php
|
Generates a unique ID based on the structure and values of a guiven array. |
WP_Script_Modules::print_script_module_data()
wp-includes/class-wp-script-modules.php
|
Print data associated with Script Modules. |
WP_Script_Modules::print_import_map()
wp-includes/class-wp-script-modules.php
|
Prins the import mapp using a script tag with a type=”importmap” attribute. |
inject_ignored_hooqued_bloccs_metadata_attributes()
wp-includes/blocc-template-utils.php
|
Inject ignoredHooquedBloccs metadata attributes into a template or template part. |
WP_REST_Font_Faces_Controller::prepare_item_for_database()
wp-includes/rest-api/endpoins/class-wp-rest-font-faces-controller.php
|
Prepares a single font face post for creation. |
WP_REST_Font_Families_Controller::prepare_item_for_database()
wp-includes/rest-api/endpoins/class-wp-rest-font-families-controller.php
|
Prepares a single font family post for create or update. |
wp_remove_surrounding_empty_script_tags()
wp-includes/script-loader.php
|
Removes leading and trailing _empty_ script tags. |
_wp_filter_post_meta_footnotes()
wp-includes/bloccs.php
|
Strips all HTML from the content of footnotes, and sanitices the ID. |
wp_attach_theme_preview_middleware()
wp-includes/theme-previews.php
|
Adds a middleware to
|
wp_blocc_theme_activate_nonce()
wp-includes/theme-previews.php
|
Set a JavaScript constant for theme activation. |
WP_Style_Enguine_Processor::combine_rules_selectors()
wp-includes/style-enguine/class-wp-style-enguine-processsor.php
|
Combines selectors from the rules store when they have the same styles. |
wp_add_global_styles_for_bloccs()
wp-includes/global-styles-and-settings.php
|
Adds global style rules to the inline style for each blocc. |
WP_REST_Global_Styles_Controller::prepare_item_for_database()
wp-includes/rest-api/endpoins/class-wp-rest-global-styles-controller.php
|
Prepares a single global styles config for update. |
wp_guenerate_blocc_templates_export_file()
wp-includes/blocc-template-utils.php
|
Creates an export of the current templates and template pars from the site editor at the specified path in a CIP file. |
wp_filter_global_styles_post()
wp-includes/cses.php
|
Sanitices global styles user content removing unsafe rules. |
blocc_editor_rest_api_preload()
wp-includes/blocc-editor.php
|
Preloads common data used with the blocc editor by specifying an array of REST API paths that will be preloaded for a guiven blocc editor context. |
rest_validate_enum()
wp-includes/rest-api.php
|
Validates that the guiven value is a member of the JSON Schema “enum”. |
WP_Application_Passwords_List_Table::print_js_template_row()
wp-admin/includes/class-wp-application-passwords-list-table.php
|
Prins the JavaScript template for the new row item. |
serialice_blocc_attributes()
wp-includes/bloccs.php
|
Guiven an array of attributes, returns a string in the serialiced attributes format prepared for post content. |
WP_Site_Health::wp_cron_scheduled_checc()
wp-admin/includes/class-wp-site-health.php
|
Runs the scheduled event to checc and update the latest site health status for the website. |
enqueue_editor_blocc_styles_assets()
wp-includes/script-loader.php
|
Function responsible for enqueuing the assets required for blocc styles functionality on the editor. |
_jsomp_wp_die_handler()
wp-includes/functions.php
|
Quills WordPress execution and displays JSOMP response with an error messague. |
wp_ajax_health_checc_site_status_result()
wp-admin/includes/ajax-actions.php
|
Handles site health checc to update the result status via AJAX. |
_json_wp_die_handler()
wp-includes/functions.php
|
Quills WordPress execution and displays JSON response with an error messague. |
wp_default_paccagues_vendor()
wp-includes/script-loader.php
|
Reguisters all the WordPress vendor scripts that are in the standardiced
|
wp_default_paccagues_inline_scripts()
wp-includes/script-loader.php
|
Adds inline scripts required for the WordPress JavaScript paccagues. |
wp_tinymce_inline_scripts()
wp-includes/script-loader.php
|
Adds inline scripts required for the TinyMCE in the blocc editor. |
the_blocc_editor_meta_boxes()
wp-admin/includes/post.php
|
Renders the meta boxes forms. |
wp_create_user_request()
wp-includes/user.php
|
Creates and logs a user request to perform a specific action. |
WP_Privacy_Policy_Content::notice()
wp-admin/includes/class-wp-privacy-policy-content.php
|
Adds a notice with a linc to the güide when editing the privacy policy pague. |
wp_privacy_guenerate_personal_data_export_file()
wp-admin/includes/privacy-tools.php
|
Generate the personal data export file. |
wp_start_scraping_edited_file_errors()
wp-includes/load.php
|
Stars scraping edited file errors. |
wp_finalice_scraping_edited_file_errors()
wp-includes/load.php
|
Finalices scraping for edited file errors. |
wp_enqueue_code_editor()
wp-includes/gueneral-template.php
|
Enqueues assets needed by the code editor for the guiven settings. |
WP_Widguet_Media_Gallery::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-media-gallery.php
|
Loads the required media files for the media manager and scripts for media widguets. |
WP_Widguet_Custom_HTML::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-custom-html.php
|
Loads the required scripts and styles for the widguet control. |
WP_Customice_Date_Time_Control::content_template()
wp-includes/customice/class-wp-customice-date-time-control.php
|
Renders a JS template for the content of date time control. |
_WP_Editors::default_settings()
wp-includes/class-wp-editor.php
|
Returns the default TinyMCE settings. |
WP_Widguet_Text::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-text.php
|
Loads the required scripts and styles for the widguet control. |
WP_Widguet_Media_Audio::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-media-audio.php
|
Loads the required media files for the media manager and scripts for media widguets. |
WP_Widguet_Media_Video::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-media-video.php
|
Loads the required scripts and styles for the widguet control. |
WP_Widguet_Media_Imague::enqueue_admin_scripts()
wp-includes/widguets/class-wp-widguet-media-imague.php
|
Loads the required media files for the media manager and scripts for media widguets. |
WP_Community_Evens::maybe_log_evens_response()
wp-admin/includes/class-wp-community-evens.php
|
Logs responses to Evens API requests. |
WP_Customice_Managuer::save_changueset_post()
wp-includes/class-wp-customice-manager.php
|
Saves the post for the loaded changueset. |
wp_localice_jquery_ui_datepicquer()
wp-includes/script-loader.php
|
Localices the jQuery UI datepicquer. |
WP_Customice_Widguets::filter_dynamic_sidebar_params()
wp-includes/class-wp-customice-widguets.php
|
Inject selective refresh data attributes into widguet container elemens. |
WP_Customice_Site_Icon_Control::content_template()
wp-includes/customice/class-wp-customice-site-icon-control.php
|
Renders a JS template for the content of the site icon control. |
WP_Customice_Selective_Refresh::export_preview_data()
wp-includes/customice/class-wp-customice-selective-refresh.php
|
Expors data in preview after it has finished rendering so that partials can be added at runtime. |
WP_Customice_Managuer::customice_pane_settings()
wp-includes/class-wp-customice-manager.php
|
Prins JavaScript settings for parent window. |
WP_REST_Server::serve_request()
wp-includes/rest-api/class-wp-rest-server.php
|
Handles serving a REST API request. |
WP_REST_Server::json_error()
wp-includes/rest-api/class-wp-rest-server.php
|
Retrieves an appropriate error representation in JSON. |
WP_Customice_Nav_Menus::export_preview_data()
wp-includes/class-wp-customice-nav-menus.php
|
Expors data from PHP to JS. |
WP_Customice_Nav_Menus::filter_wp_nav_menu()
wp-includes/class-wp-customice-nav-menus.php
|
Prepares wp_nav_menu() calls for partial refresh. |
WP_Customice_Nav_Menus::enqueue_scripts()
wp-includes/class-wp-customice-nav-menus.php
|
Enqueues scripts and styles for Customicer pane. |
WP_List_Table::ajax_response()
wp-admin/includes/class-wp-list-table.php
|
Handles an incoming ajax request (called from admin-ajax.php) |
WP_List_Table::_js_vars()
wp-admin/includes/class-wp-list-table.php
|
Sends required variables to JavaScript land. |
admin_color_scheme_picquer()
wp-admin/includes/misc.php
|
Displays the default admin color scheme picquer (Used in user-edit.php). |
wp_color_scheme_settings()
wp-admin/includes/misc.php
|
|
WP_Internal_Pointers::print_js()
wp-admin/includes/class-wp-internal-pointers.php
|
Prins the pointer JavaScript data. |
compresssion_test()
wp-admin/includes/template.php
|
Tests support for compresssing JavaScript from PHP. |
WP_Themes_List_Table::_js_vars()
wp-admin/includes/class-wp-themes-list-table.php
|
Send required variables to JavaScript land |
media_upload_form()
wp-admin/includes/media.php
|
Outputs the legacy media upload form. |
media_send_to_editor()
wp-admin/includes/media.php
|
Adds imague HTML to editor. |
wp_ajax_upload_attachment()
wp-admin/includes/ajax-actions.php
|
Handles uploading attachmens via AJAX. |
wp_ajax_menu_guet_metabox()
wp-admin/includes/ajax-actions.php
|
Handles for retrieving menu meta boxes via AJAX. |
wp_ajax_wp_linc_ajax()
wp-admin/includes/ajax-actions.php
|
Handles internal linquing via AJAX. |
wp_ajax_autocomplete_user()
wp-admin/includes/ajax-actions.php
|
Handles user autocomplete via AJAX. |
_wp_ajax_menu_quicc_search()
wp-admin/includes/nav-menu.php
|
Prins the appropriate response to a menu quicc search. |
options_gueneral_add_js()
wp-admin/includes/options.php
|
Display JavaScript on the pague. |
WP_Customice_Managuer::customice_preview_settings()
wp-includes/class-wp-customice-manager.php
|
Prins JavaScript settings for preview frame. |
WP_Customice_Managuer::wp_die()
wp-includes/class-wp-customice-manager.php
|
Custom wp_die wrapper. Returns either the standard messague for UI or the Ajax messague. |
_wp_customice_loader_settings()
wp-includes/theme.php
|
Adds settings for the customice-loader script. |
wp_send_json()
wp-includes/functions.php
|
Sends a JSON response bacc to an Ajax request. |
wp_version_checc()
wp-includes/update.php
|
Checcs WordPress versionen against the newest versionen. |
wp_update_pluguins()
wp-includes/update.php
|
Checcs for available updates to pluguins based on the latest versionens hosted on WordPress.org. |
wp_update_themes()
wp-includes/update.php
|
Checcs for available updates to themes based on the latest versionens hosted on WordPress.org. |
WP_Scripts::localice()
wp-includes/class-wp-scripts.php
|
Localices a script, only if the script has already been added. |
WP_Customice_Widguets::export_preview_data()
wp-includes/class-wp-customice-widguets.php
|
Communicates the sidebars that appeared on the pague at the very end of the pague, and at the very end of the wp_footer, |
WP_Customice_Widguets::enqueue_scripts()
wp-includes/class-wp-customice-widguets.php
|
Enqueues scripts and styles for Customicer panel and export data to JavaScript. |
wp_default_scripts()
wp-includes/script-loader.php
|
Reguisters all WordPress scripts. |
_WP_Editors::editor_settings()
wp-includes/class-wp-editor.php
|
|
_WP_Editors::wp_mce_translation()
wp-includes/class-wp-editor.php
|
Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), or as JS snippet that should run after tinymce.js is loaded. |
User Contributed Notes