get_col_charset example


    protected function process_field_charsets( $data$table ) {
        foreach ( $data as $field => $value ) {
            if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
                /* * We can skip this field if we know it isn't a string. * This checks %d/%f versus ! %s because its sprintf() could take more. */
                $value['charset'] = false;
            } else {
                $value['charset'] = $this->get_col_charset( $table$field );
                if ( is_wp_error( $value['charset'] ) ) {
                    return false;
                }
            }

            $data[ $field ] = $value;
        }

        return $data;
    }

    
'post_modified_gmt',
        'post_parent',
        'menu_order',
        'post_mime_type',
        'guid'
    );

    $emoji_fields = array( 'post_title', 'post_content', 'post_excerpt' );

    foreach ( $emoji_fields as $emoji_field ) {
        if ( isset( $data[ $emoji_field ] ) ) {
            $charset = $wpdb->get_col_charset( $wpdb->posts, $emoji_field );

            if ( 'utf8' === $charset ) {
                $data[ $emoji_field ] = wp_encode_emoji( $data[ $emoji_field ] );
            }
        }
    }

    if ( 'attachment' === $post_type ) {
        /** * Filters attachment post data before it is updated in or added to the database. * * @since 3.9.0 * @since 5.4.1 The `$unsanitized_postarr` parameter was added. * @since 6.0.0 The `$update` parameter was added. * * @param array $data An array of slashed, sanitized, and processed attachment post data. * @param array $postarr An array of slashed and sanitized attachment post data, but not processed. * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data * as originally passed to wp_insert_post(). * @param bool $update Whether this is an existing attachment post being updated. */
Home | Imprint | This part of the site doesn't use cookies.