php - Wordpress custom post type encoding -


i have problem encoding on saving custom post type in wordpress. when hit update, utf-8 characters (č, š, ž, ø, etc.) tranformed "u010d" , others.

the problem seems form. recieve broken characters through post.

i have saved file utf-8 encoding , have meta tag encoding in head of html.

what can fix this?

thank you!

edit:

i have accept-charset="utf-8" in form.

head: <meta http-equiv="content-type" content="text/html; charset=utf-8">

function:

add_action( 'save_post', 'layered_images_save_info' );  function layered_images_save_info( $post_id ) {  // verify nonce  if ( ! wp_verify_nonce( $_post['layered_images_box_nonce'], basename( __file__ ) ) ) {     return $post_id;  }  // check autosave  if ( defined('doing_autosave') && doing_autosave ) {     return $post_id;  } // check permissions  if ( 'layered_images' == $_post[ 'post_type'] && current_user_can( 'edit_post', $post_id ) ) {     /* save slider images */     //echo "";print_r($_post['gallery_img']);exit;     //$bla  = html_entity_decode($_post[ 'layer_titles' ], ent_quotes, "utf-8");     $gallery_images = ( isset( $_post[ 'gallery_img' ] ) ? $_post[ 'gallery_img' ] : '' );     $layer_opacity = ( isset( $_post[ 'layer_opacity' ] ) ? $_post[ 'layer_opacity' ] : '' );     $layer_color = ( isset( $_post[ 'layer_color' ] ) ? $_post[ 'layer_color' ] : '' );    //print_r($bla);exit;     $gallery_images = strip_tags( json_encode( $gallery_images ) );      $visible_layers = ( isset( $_post[ 'visible_layers' ] ) ? $_post[ 'visible_layers' ] : '' );     $visible_layers = strip_tags( json_encode( $visible_layers ) );      $visible_user_layers = ( isset( $_post[ 'visible_user_layers' ] ) ? $_post[ 'visible_user_layers' ] : '' );     $visible_user_layers = strip_tags( json_encode( $visible_user_layers ) );      $layer_titles = ( isset( $_post[ 'layer_titles' ] ) ? $_post[ 'layer_titles' ] : '' );     $layer_titles =  json_encode( $layer_titles ) ;      update_post_meta( $post_id, "_layer_gallery_images", $gallery_images );     update_post_meta( $post_id, "_layer_visible_layers", $visible_layers );     update_post_meta( $post_id, "_visible_user_layers", $visible_user_layers );     update_post_meta( $post_id, "_layer_titles", $layer_titles );     update_post_meta( $post_id, "_layer_opacity", $layer_opacity );     update_post_meta( $post_id, "_layer_color", $layer_color );   } else {     return $post_id;  } 

}

it appears saving unicode characters feature of json_encode. either force not that, with

json_encode( $text, json_unescaped_unicode ); 

as seen in topic: why php json_encode function convert utf-8 strings hexadecimal entities?

or don't use json_encode @ all. wp has own serializing method built in saving arrays in options , meta fields.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -