Edit File by line
/home/barbar84/www/wp-inclu...
File: functions.php
?>
[3500] Fix | Delete
<title><?php echo $title; ?></title>
[3501] Fix | Delete
<style type="text/css">
[3502] Fix | Delete
html {
[3503] Fix | Delete
background: #f1f1f1;
[3504] Fix | Delete
}
[3505] Fix | Delete
body {
[3506] Fix | Delete
background: #fff;
[3507] Fix | Delete
border: 1px solid #ccd0d4;
[3508] Fix | Delete
color: #444;
[3509] Fix | Delete
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
[3510] Fix | Delete
margin: 2em auto;
[3511] Fix | Delete
padding: 1em 2em;
[3512] Fix | Delete
max-width: 700px;
[3513] Fix | Delete
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
[3514] Fix | Delete
box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
[3515] Fix | Delete
}
[3516] Fix | Delete
h1 {
[3517] Fix | Delete
border-bottom: 1px solid #dadada;
[3518] Fix | Delete
clear: both;
[3519] Fix | Delete
color: #666;
[3520] Fix | Delete
font-size: 24px;
[3521] Fix | Delete
margin: 30px 0 0 0;
[3522] Fix | Delete
padding: 0;
[3523] Fix | Delete
padding-bottom: 7px;
[3524] Fix | Delete
}
[3525] Fix | Delete
#error-page {
[3526] Fix | Delete
margin-top: 50px;
[3527] Fix | Delete
}
[3528] Fix | Delete
#error-page p,
[3529] Fix | Delete
#error-page .wp-die-message {
[3530] Fix | Delete
font-size: 14px;
[3531] Fix | Delete
line-height: 1.5;
[3532] Fix | Delete
margin: 25px 0 20px;
[3533] Fix | Delete
}
[3534] Fix | Delete
#error-page code {
[3535] Fix | Delete
font-family: Consolas, Monaco, monospace;
[3536] Fix | Delete
}
[3537] Fix | Delete
ul li {
[3538] Fix | Delete
margin-bottom: 10px;
[3539] Fix | Delete
font-size: 14px ;
[3540] Fix | Delete
}
[3541] Fix | Delete
a {
[3542] Fix | Delete
color: #0073aa;
[3543] Fix | Delete
}
[3544] Fix | Delete
a:hover,
[3545] Fix | Delete
a:active {
[3546] Fix | Delete
color: #006799;
[3547] Fix | Delete
}
[3548] Fix | Delete
a:focus {
[3549] Fix | Delete
color: #124964;
[3550] Fix | Delete
-webkit-box-shadow:
[3551] Fix | Delete
0 0 0 1px #5b9dd9,
[3552] Fix | Delete
0 0 2px 1px rgba(30, 140, 190, 0.8);
[3553] Fix | Delete
box-shadow:
[3554] Fix | Delete
0 0 0 1px #5b9dd9,
[3555] Fix | Delete
0 0 2px 1px rgba(30, 140, 190, 0.8);
[3556] Fix | Delete
outline: none;
[3557] Fix | Delete
}
[3558] Fix | Delete
.button {
[3559] Fix | Delete
background: #f3f5f6;
[3560] Fix | Delete
border: 1px solid #016087;
[3561] Fix | Delete
color: #016087;
[3562] Fix | Delete
display: inline-block;
[3563] Fix | Delete
text-decoration: none;
[3564] Fix | Delete
font-size: 13px;
[3565] Fix | Delete
line-height: 2;
[3566] Fix | Delete
height: 28px;
[3567] Fix | Delete
margin: 0;
[3568] Fix | Delete
padding: 0 10px 1px;
[3569] Fix | Delete
cursor: pointer;
[3570] Fix | Delete
-webkit-border-radius: 3px;
[3571] Fix | Delete
-webkit-appearance: none;
[3572] Fix | Delete
border-radius: 3px;
[3573] Fix | Delete
white-space: nowrap;
[3574] Fix | Delete
-webkit-box-sizing: border-box;
[3575] Fix | Delete
-moz-box-sizing: border-box;
[3576] Fix | Delete
box-sizing: border-box;
[3577] Fix | Delete
[3578] Fix | Delete
vertical-align: top;
[3579] Fix | Delete
}
[3580] Fix | Delete
[3581] Fix | Delete
.button.button-large {
[3582] Fix | Delete
line-height: 2.30769231;
[3583] Fix | Delete
min-height: 32px;
[3584] Fix | Delete
padding: 0 12px;
[3585] Fix | Delete
}
[3586] Fix | Delete
[3587] Fix | Delete
.button:hover,
[3588] Fix | Delete
.button:focus {
[3589] Fix | Delete
background: #f1f1f1;
[3590] Fix | Delete
}
[3591] Fix | Delete
[3592] Fix | Delete
.button:focus {
[3593] Fix | Delete
background: #f3f5f6;
[3594] Fix | Delete
border-color: #007cba;
[3595] Fix | Delete
-webkit-box-shadow: 0 0 0 1px #007cba;
[3596] Fix | Delete
box-shadow: 0 0 0 1px #007cba;
[3597] Fix | Delete
color: #016087;
[3598] Fix | Delete
outline: 2px solid transparent;
[3599] Fix | Delete
outline-offset: 0;
[3600] Fix | Delete
}
[3601] Fix | Delete
[3602] Fix | Delete
.button:active {
[3603] Fix | Delete
background: #f3f5f6;
[3604] Fix | Delete
border-color: #7e8993;
[3605] Fix | Delete
-webkit-box-shadow: none;
[3606] Fix | Delete
box-shadow: none;
[3607] Fix | Delete
}
[3608] Fix | Delete
[3609] Fix | Delete
<?php
[3610] Fix | Delete
if ( 'rtl' === $text_direction ) {
[3611] Fix | Delete
echo 'body { font-family: Tahoma, Arial; }';
[3612] Fix | Delete
}
[3613] Fix | Delete
?>
[3614] Fix | Delete
</style>
[3615] Fix | Delete
</head>
[3616] Fix | Delete
<body id="error-page">
[3617] Fix | Delete
<?php endif; // ! did_action( 'admin_head' ) ?>
[3618] Fix | Delete
<?php echo $message; ?>
[3619] Fix | Delete
</body>
[3620] Fix | Delete
</html>
[3621] Fix | Delete
<?php
[3622] Fix | Delete
if ( $parsed_args['exit'] ) {
[3623] Fix | Delete
die();
[3624] Fix | Delete
}
[3625] Fix | Delete
}
[3626] Fix | Delete
[3627] Fix | Delete
/**
[3628] Fix | Delete
* Kills WordPress execution and displays Ajax response with an error message.
[3629] Fix | Delete
*
[3630] Fix | Delete
* This is the handler for wp_die() when processing Ajax requests.
[3631] Fix | Delete
*
[3632] Fix | Delete
* @since 3.4.0
[3633] Fix | Delete
* @access private
[3634] Fix | Delete
*
[3635] Fix | Delete
* @param string $message Error message.
[3636] Fix | Delete
* @param string $title Optional. Error title (unused). Default empty.
[3637] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3638] Fix | Delete
*/
[3639] Fix | Delete
function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
[3640] Fix | Delete
// Set default 'response' to 200 for Ajax requests.
[3641] Fix | Delete
$args = wp_parse_args(
[3642] Fix | Delete
$args,
[3643] Fix | Delete
array( 'response' => 200 )
[3644] Fix | Delete
);
[3645] Fix | Delete
[3646] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3647] Fix | Delete
[3648] Fix | Delete
if ( ! headers_sent() ) {
[3649] Fix | Delete
// This is intentional. For backward-compatibility, support passing null here.
[3650] Fix | Delete
if ( null !== $args['response'] ) {
[3651] Fix | Delete
status_header( $parsed_args['response'] );
[3652] Fix | Delete
}
[3653] Fix | Delete
nocache_headers();
[3654] Fix | Delete
}
[3655] Fix | Delete
[3656] Fix | Delete
if ( is_scalar( $message ) ) {
[3657] Fix | Delete
$message = (string) $message;
[3658] Fix | Delete
} else {
[3659] Fix | Delete
$message = '0';
[3660] Fix | Delete
}
[3661] Fix | Delete
[3662] Fix | Delete
if ( $parsed_args['exit'] ) {
[3663] Fix | Delete
die( $message );
[3664] Fix | Delete
}
[3665] Fix | Delete
[3666] Fix | Delete
echo $message;
[3667] Fix | Delete
}
[3668] Fix | Delete
[3669] Fix | Delete
/**
[3670] Fix | Delete
* Kills WordPress execution and displays JSON response with an error message.
[3671] Fix | Delete
*
[3672] Fix | Delete
* This is the handler for wp_die() when processing JSON requests.
[3673] Fix | Delete
*
[3674] Fix | Delete
* @since 5.1.0
[3675] Fix | Delete
* @access private
[3676] Fix | Delete
*
[3677] Fix | Delete
* @param string $message Error message.
[3678] Fix | Delete
* @param string $title Optional. Error title. Default empty.
[3679] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3680] Fix | Delete
*/
[3681] Fix | Delete
function _json_wp_die_handler( $message, $title = '', $args = array() ) {
[3682] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3683] Fix | Delete
[3684] Fix | Delete
$data = array(
[3685] Fix | Delete
'code' => $parsed_args['code'],
[3686] Fix | Delete
'message' => $message,
[3687] Fix | Delete
'data' => array(
[3688] Fix | Delete
'status' => $parsed_args['response'],
[3689] Fix | Delete
),
[3690] Fix | Delete
'additional_errors' => $parsed_args['additional_errors'],
[3691] Fix | Delete
);
[3692] Fix | Delete
[3693] Fix | Delete
if ( ! headers_sent() ) {
[3694] Fix | Delete
header( "Content-Type: application/json; charset={$parsed_args['charset']}" );
[3695] Fix | Delete
if ( null !== $parsed_args['response'] ) {
[3696] Fix | Delete
status_header( $parsed_args['response'] );
[3697] Fix | Delete
}
[3698] Fix | Delete
nocache_headers();
[3699] Fix | Delete
}
[3700] Fix | Delete
[3701] Fix | Delete
echo wp_json_encode( $data );
[3702] Fix | Delete
if ( $parsed_args['exit'] ) {
[3703] Fix | Delete
die();
[3704] Fix | Delete
}
[3705] Fix | Delete
}
[3706] Fix | Delete
[3707] Fix | Delete
/**
[3708] Fix | Delete
* Kills WordPress execution and displays JSONP response with an error message.
[3709] Fix | Delete
*
[3710] Fix | Delete
* This is the handler for wp_die() when processing JSONP requests.
[3711] Fix | Delete
*
[3712] Fix | Delete
* @since 5.2.0
[3713] Fix | Delete
* @access private
[3714] Fix | Delete
*
[3715] Fix | Delete
* @param string $message Error message.
[3716] Fix | Delete
* @param string $title Optional. Error title. Default empty.
[3717] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3718] Fix | Delete
*/
[3719] Fix | Delete
function _jsonp_wp_die_handler( $message, $title = '', $args = array() ) {
[3720] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3721] Fix | Delete
[3722] Fix | Delete
$data = array(
[3723] Fix | Delete
'code' => $parsed_args['code'],
[3724] Fix | Delete
'message' => $message,
[3725] Fix | Delete
'data' => array(
[3726] Fix | Delete
'status' => $parsed_args['response'],
[3727] Fix | Delete
),
[3728] Fix | Delete
'additional_errors' => $parsed_args['additional_errors'],
[3729] Fix | Delete
);
[3730] Fix | Delete
[3731] Fix | Delete
if ( ! headers_sent() ) {
[3732] Fix | Delete
header( "Content-Type: application/javascript; charset={$parsed_args['charset']}" );
[3733] Fix | Delete
header( 'X-Content-Type-Options: nosniff' );
[3734] Fix | Delete
header( 'X-Robots-Tag: noindex' );
[3735] Fix | Delete
if ( null !== $parsed_args['response'] ) {
[3736] Fix | Delete
status_header( $parsed_args['response'] );
[3737] Fix | Delete
}
[3738] Fix | Delete
nocache_headers();
[3739] Fix | Delete
}
[3740] Fix | Delete
[3741] Fix | Delete
$result = wp_json_encode( $data );
[3742] Fix | Delete
$jsonp_callback = $_GET['_jsonp'];
[3743] Fix | Delete
echo '/**/' . $jsonp_callback . '(' . $result . ')';
[3744] Fix | Delete
if ( $parsed_args['exit'] ) {
[3745] Fix | Delete
die();
[3746] Fix | Delete
}
[3747] Fix | Delete
}
[3748] Fix | Delete
[3749] Fix | Delete
/**
[3750] Fix | Delete
* Kills WordPress execution and displays XML response with an error message.
[3751] Fix | Delete
*
[3752] Fix | Delete
* This is the handler for wp_die() when processing XMLRPC requests.
[3753] Fix | Delete
*
[3754] Fix | Delete
* @since 3.2.0
[3755] Fix | Delete
* @access private
[3756] Fix | Delete
*
[3757] Fix | Delete
* @global wp_xmlrpc_server $wp_xmlrpc_server
[3758] Fix | Delete
*
[3759] Fix | Delete
* @param string $message Error message.
[3760] Fix | Delete
* @param string $title Optional. Error title. Default empty.
[3761] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3762] Fix | Delete
*/
[3763] Fix | Delete
function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) {
[3764] Fix | Delete
global $wp_xmlrpc_server;
[3765] Fix | Delete
[3766] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3767] Fix | Delete
[3768] Fix | Delete
if ( ! headers_sent() ) {
[3769] Fix | Delete
nocache_headers();
[3770] Fix | Delete
}
[3771] Fix | Delete
[3772] Fix | Delete
if ( $wp_xmlrpc_server ) {
[3773] Fix | Delete
$error = new IXR_Error( $parsed_args['response'], $message );
[3774] Fix | Delete
$wp_xmlrpc_server->output( $error->getXml() );
[3775] Fix | Delete
}
[3776] Fix | Delete
if ( $parsed_args['exit'] ) {
[3777] Fix | Delete
die();
[3778] Fix | Delete
}
[3779] Fix | Delete
}
[3780] Fix | Delete
[3781] Fix | Delete
/**
[3782] Fix | Delete
* Kills WordPress execution and displays XML response with an error message.
[3783] Fix | Delete
*
[3784] Fix | Delete
* This is the handler for wp_die() when processing XML requests.
[3785] Fix | Delete
*
[3786] Fix | Delete
* @since 5.2.0
[3787] Fix | Delete
* @access private
[3788] Fix | Delete
*
[3789] Fix | Delete
* @param string $message Error message.
[3790] Fix | Delete
* @param string $title Optional. Error title. Default empty.
[3791] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3792] Fix | Delete
*/
[3793] Fix | Delete
function _xml_wp_die_handler( $message, $title = '', $args = array() ) {
[3794] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3795] Fix | Delete
[3796] Fix | Delete
$message = htmlspecialchars( $message );
[3797] Fix | Delete
$title = htmlspecialchars( $title );
[3798] Fix | Delete
[3799] Fix | Delete
$xml = <<<EOD
[3800] Fix | Delete
<error>
[3801] Fix | Delete
<code>{$parsed_args['code']}</code>
[3802] Fix | Delete
<title><![CDATA[{$title}]]></title>
[3803] Fix | Delete
<message><![CDATA[{$message}]]></message>
[3804] Fix | Delete
<data>
[3805] Fix | Delete
<status>{$parsed_args['response']}</status>
[3806] Fix | Delete
</data>
[3807] Fix | Delete
</error>
[3808] Fix | Delete
[3809] Fix | Delete
EOD;
[3810] Fix | Delete
[3811] Fix | Delete
if ( ! headers_sent() ) {
[3812] Fix | Delete
header( "Content-Type: text/xml; charset={$parsed_args['charset']}" );
[3813] Fix | Delete
if ( null !== $parsed_args['response'] ) {
[3814] Fix | Delete
status_header( $parsed_args['response'] );
[3815] Fix | Delete
}
[3816] Fix | Delete
nocache_headers();
[3817] Fix | Delete
}
[3818] Fix | Delete
[3819] Fix | Delete
echo $xml;
[3820] Fix | Delete
if ( $parsed_args['exit'] ) {
[3821] Fix | Delete
die();
[3822] Fix | Delete
}
[3823] Fix | Delete
}
[3824] Fix | Delete
[3825] Fix | Delete
/**
[3826] Fix | Delete
* Kills WordPress execution and displays an error message.
[3827] Fix | Delete
*
[3828] Fix | Delete
* This is the handler for wp_die() when processing APP requests.
[3829] Fix | Delete
*
[3830] Fix | Delete
* @since 3.4.0
[3831] Fix | Delete
* @since 5.1.0 Added the $title and $args parameters.
[3832] Fix | Delete
* @access private
[3833] Fix | Delete
*
[3834] Fix | Delete
* @param string $message Optional. Response to print. Default empty.
[3835] Fix | Delete
* @param string $title Optional. Error title (unused). Default empty.
[3836] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3837] Fix | Delete
*/
[3838] Fix | Delete
function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) {
[3839] Fix | Delete
list( $message, $title, $parsed_args ) = _wp_die_process_input( $message, $title, $args );
[3840] Fix | Delete
[3841] Fix | Delete
if ( $parsed_args['exit'] ) {
[3842] Fix | Delete
if ( is_scalar( $message ) ) {
[3843] Fix | Delete
die( (string) $message );
[3844] Fix | Delete
}
[3845] Fix | Delete
die();
[3846] Fix | Delete
}
[3847] Fix | Delete
[3848] Fix | Delete
if ( is_scalar( $message ) ) {
[3849] Fix | Delete
echo (string) $message;
[3850] Fix | Delete
}
[3851] Fix | Delete
}
[3852] Fix | Delete
[3853] Fix | Delete
/**
[3854] Fix | Delete
* Processes arguments passed to wp_die() consistently for its handlers.
[3855] Fix | Delete
*
[3856] Fix | Delete
* @since 5.1.0
[3857] Fix | Delete
* @access private
[3858] Fix | Delete
*
[3859] Fix | Delete
* @param string|WP_Error $message Error message or WP_Error object.
[3860] Fix | Delete
* @param string $title Optional. Error title. Default empty.
[3861] Fix | Delete
* @param string|array $args Optional. Arguments to control behavior. Default empty array.
[3862] Fix | Delete
* @return array {
[3863] Fix | Delete
* Processed arguments.
[3864] Fix | Delete
*
[3865] Fix | Delete
* @type string $0 Error message.
[3866] Fix | Delete
* @type string $1 Error title.
[3867] Fix | Delete
* @type array $2 Arguments to control behavior.
[3868] Fix | Delete
* }
[3869] Fix | Delete
*/
[3870] Fix | Delete
function _wp_die_process_input( $message, $title = '', $args = array() ) {
[3871] Fix | Delete
$defaults = array(
[3872] Fix | Delete
'response' => 0,
[3873] Fix | Delete
'code' => '',
[3874] Fix | Delete
'exit' => true,
[3875] Fix | Delete
'back_link' => false,
[3876] Fix | Delete
'link_url' => '',
[3877] Fix | Delete
'link_text' => '',
[3878] Fix | Delete
'text_direction' => '',
[3879] Fix | Delete
'charset' => 'utf-8',
[3880] Fix | Delete
'additional_errors' => array(),
[3881] Fix | Delete
);
[3882] Fix | Delete
[3883] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[3884] Fix | Delete
[3885] Fix | Delete
if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
[3886] Fix | Delete
if ( ! empty( $message->errors ) ) {
[3887] Fix | Delete
$errors = array();
[3888] Fix | Delete
foreach ( (array) $message->errors as $error_code => $error_messages ) {
[3889] Fix | Delete
foreach ( (array) $error_messages as $error_message ) {
[3890] Fix | Delete
$errors[] = array(
[3891] Fix | Delete
'code' => $error_code,
[3892] Fix | Delete
'message' => $error_message,
[3893] Fix | Delete
'data' => $message->get_error_data( $error_code ),
[3894] Fix | Delete
);
[3895] Fix | Delete
}
[3896] Fix | Delete
}
[3897] Fix | Delete
[3898] Fix | Delete
$message = $errors[0]['message'];
[3899] Fix | Delete
if ( empty( $args['code'] ) ) {
[3900] Fix | Delete
$args['code'] = $errors[0]['code'];
[3901] Fix | Delete
}
[3902] Fix | Delete
if ( empty( $args['response'] ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['status'] ) ) {
[3903] Fix | Delete
$args['response'] = $errors[0]['data']['status'];
[3904] Fix | Delete
}
[3905] Fix | Delete
if ( empty( $title ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['title'] ) ) {
[3906] Fix | Delete
$title = $errors[0]['data']['title'];
[3907] Fix | Delete
}
[3908] Fix | Delete
[3909] Fix | Delete
unset( $errors[0] );
[3910] Fix | Delete
$args['additional_errors'] = array_values( $errors );
[3911] Fix | Delete
} else {
[3912] Fix | Delete
$message = '';
[3913] Fix | Delete
}
[3914] Fix | Delete
}
[3915] Fix | Delete
[3916] Fix | Delete
$have_gettext = function_exists( '__' );
[3917] Fix | Delete
[3918] Fix | Delete
// The $title and these specific $args must always have a non-empty value.
[3919] Fix | Delete
if ( empty( $args['code'] ) ) {
[3920] Fix | Delete
$args['code'] = 'wp_die';
[3921] Fix | Delete
}
[3922] Fix | Delete
if ( empty( $args['response'] ) ) {
[3923] Fix | Delete
$args['response'] = 500;
[3924] Fix | Delete
}
[3925] Fix | Delete
if ( empty( $title ) ) {
[3926] Fix | Delete
$title = $have_gettext ? __( 'WordPress &rsaquo; Error' ) : 'WordPress &rsaquo; Error';
[3927] Fix | Delete
}
[3928] Fix | Delete
if ( empty( $args['text_direction'] ) || ! in_array( $args['text_direction'], array( 'ltr', 'rtl' ), true ) ) {
[3929] Fix | Delete
$args['text_direction'] = 'ltr';
[3930] Fix | Delete
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
[3931] Fix | Delete
$args['text_direction'] = 'rtl';
[3932] Fix | Delete
}
[3933] Fix | Delete
}
[3934] Fix | Delete
[3935] Fix | Delete
if ( ! empty( $args['charset'] ) ) {
[3936] Fix | Delete
$args['charset'] = _canonical_charset( $args['charset'] );
[3937] Fix | Delete
}
[3938] Fix | Delete
[3939] Fix | Delete
return array( $message, $title, $args );
[3940] Fix | Delete
}
[3941] Fix | Delete
[3942] Fix | Delete
/**
[3943] Fix | Delete
* Encode a variable into JSON, with some sanity checks.
[3944] Fix | Delete
*
[3945] Fix | Delete
* @since 4.1.0
[3946] Fix | Delete
* @since 5.3.0 No longer handles support for PHP < 5.6.
[3947] Fix | Delete
*
[3948] Fix | Delete
* @param mixed $data Variable (usually an array or object) to encode as JSON.
[3949] Fix | Delete
* @param int $options Optional. Options to be passed to json_encode(). Default 0.
[3950] Fix | Delete
* @param int $depth Optional. Maximum depth to walk through $data. Must be
[3951] Fix | Delete
* greater than 0. Default 512.
[3952] Fix | Delete
* @return string|false The JSON encoded string, or false if it cannot be encoded.
[3953] Fix | Delete
*/
[3954] Fix | Delete
function wp_json_encode( $data, $options = 0, $depth = 512 ) {
[3955] Fix | Delete
$json = json_encode( $data, $options, $depth );
[3956] Fix | Delete
[3957] Fix | Delete
// If json_encode() was successful, no need to do more sanity checking.
[3958] Fix | Delete
if ( false !== $json ) {
[3959] Fix | Delete
return $json;
[3960] Fix | Delete
}
[3961] Fix | Delete
[3962] Fix | Delete
try {
[3963] Fix | Delete
$data = _wp_json_sanity_check( $data, $depth );
[3964] Fix | Delete
} catch ( Exception $e ) {
[3965] Fix | Delete
return false;
[3966] Fix | Delete
}
[3967] Fix | Delete
[3968] Fix | Delete
return json_encode( $data, $options, $depth );
[3969] Fix | Delete
}
[3970] Fix | Delete
[3971] Fix | Delete
/**
[3972] Fix | Delete
* Perform sanity checks on data that shall be encoded to JSON.
[3973] Fix | Delete
*
[3974] Fix | Delete
* @ignore
[3975] Fix | Delete
* @since 4.1.0
[3976] Fix | Delete
* @access private
[3977] Fix | Delete
*
[3978] Fix | Delete
* @see wp_json_encode()
[3979] Fix | Delete
*
[3980] Fix | Delete
* @throws Exception If depth limit is reached.
[3981] Fix | Delete
*
[3982] Fix | Delete
* @param mixed $data Variable (usually an array or object) to encode as JSON.
[3983] Fix | Delete
* @param int $depth Maximum depth to walk through $data. Must be greater than 0.
[3984] Fix | Delete
* @return mixed The sanitized data that shall be encoded to JSON.
[3985] Fix | Delete
*/
[3986] Fix | Delete
function _wp_json_sanity_check( $data, $depth ) {
[3987] Fix | Delete
if ( $depth < 0 ) {
[3988] Fix | Delete
throw new Exception( 'Reached depth limit' );
[3989] Fix | Delete
}
[3990] Fix | Delete
[3991] Fix | Delete
if ( is_array( $data ) ) {
[3992] Fix | Delete
$output = array();
[3993] Fix | Delete
foreach ( $data as $id => $el ) {
[3994] Fix | Delete
// Don't forget to sanitize the ID!
[3995] Fix | Delete
if ( is_string( $id ) ) {
[3996] Fix | Delete
$clean_id = _wp_json_convert_string( $id );
[3997] Fix | Delete
} else {
[3998] Fix | Delete
$clean_id = $id;
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function