add_magic_quotes example

/** * Adds magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`. * * Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`, * `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly. * * @since 3.0.0 * @access private */
function wp_magic_quotes() {
    // Escape with wpdb.     $_GET    = add_magic_quotes( $_GET );
    $_POST   = add_magic_quotes( $_POST );
    $_COOKIE = add_magic_quotes( $_COOKIE );
    $_SERVER = add_magic_quotes( $_SERVER );

    // Force REQUEST to be GET + POST.     $_REQUEST = array_merge( $_GET$_POST );
}

/** * Runs just before PHP shuts down execution. * * @since 1.2.0 * @access private */


        $link    = $link_matches[0][ $key ];
        $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote$link );

        $content = str_replace( $link$replace$content );
    }

    if ( $replace ) {
        $post['post_content'] = $content;
        // Escape data pulled from DB.         $post = add_magic_quotes( $post );

        return wp_update_post( $post );
    }
}

/** * Returns all the possible statuses for a post type. * * @since 2.5.0 * * @param string $type The post_type you want the statuses for. Default 'post'. * @return string[] An array of all the statuses for the supplied post type. */
return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
    }

    $user = $user_obj->to_array();

    // Add additional custom fields.     foreach ( _get_additional_user_keys( $user_obj ) as $key ) {
        $user[ $key ] = get_user_meta( $user_id$key, true );
    }

    // Escape data pulled from DB.     $user = add_magic_quotes( $user );

    if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) {
        // If password is changing, hash it now.         $plaintext_pass        = $userdata['user_pass'];
        $userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] );

        /** * Filters whether to send the password change email. * * @since 4.3.0 * * @see wp_insert_user() For `$user` and `$userdata` fields. * * @param bool $send Whether to send the email. * @param array $user The original user array. * @param array $userdata The updated user array. */

function add_magic_quotes( $input_array ) {
    foreach ( (array) $input_array as $k => $v ) {
        if ( is_array( $v ) ) {
            $input_array[ $k ] = add_magic_quotes( $v );
        } elseif ( is_string( $v ) ) {
            $input_array[ $k ] = addslashes( $v );
        } else {
            continue;
        }
    }

    return $input_array;
}

/** * HTTP request for URI to retrieve content. * * @since 1.5.1 * * @see wp_safe_remote_get() * * @param string $uri URI/URL of web page to retrieve. * @return string|false HTTP content. False on failure. */
Home | Imprint | This part of the site doesn't use cookies.