How to keep   non-breaking spaces in the visual editor?

This seems to do it: function allow_nbsp_in_tinymce( $mceInit ) { $mceInit[‘entities’] = ‘160,nbsp,38,amp,60,lt,62,gt’; $mceInit[‘entity_encoding’] = ‘named’; return $mceInit; } add_filter( ‘tiny_mce_before_init’, ‘allow_nbsp_in_tinymce’ ); Also see: https://www.tinymce.com/docs/configure/content-filtering/#entities Any improvement suggestions?

disable WP automatically inserted line breaks after an image

If this is how it looks: <img class=”alignleft size-medium wp-image-8530″ alt=”…” src=”#” width=”413″ height=”275″ /> <img class=”alignleft size-medium wp-image-8529″ alt=”…” src=”#” width=”413″ height=”275″ /> Then you have to put them together like this: <img class=”alignleft size-medium wp-image-8530″ alt=”…” src=”#” width=”413″ height=”275″ /><img class=”alignleft size-medium wp-image-8529″ alt=”…” src=”#” width=”413″ height=”275″ /> Because if you do this … Read more

How to include line-breaks in the_excerpt?

There is no filter that would allow you to set allowable tags not to be removed by the_excerpt(). Arguably a shortcoming of the core. Anyhow, the actual excerpt generation does not happen in that template tag but entirely elsewhere: Excerpts are generated by the function wp_trim_excerpt(), inside of which the excerpt filters you are already … Read more

Extra TinyMCE editor strips and tags?

I recently got this working. You should search and replace metaname with your meta box name. The key to maintaining formatting was using wpautop(); when saving the data. add_action( ‘add_meta_boxes’, ‘add_metaname_box’); add_action( ‘save_post’, ‘metaname_save’); function add_metaname_box() { add_meta_box( ‘metaname_id’, __( ‘metaname text’, ‘metaname_textdomain’), ‘metaname_custom_box’, ‘page’ ); } function metaname_custom_box() { global $post; wp_nonce_field( plugin_basename( __FILE__ … Read more

How to read a file without newlines?

You can read the whole file and split lines using str.splitlines: Or you can strip the newline by hand: Note: this last solution only works if the file ends with a newline, otherwise the last line will lose a character. This assumption is true in most cases (especially for files created by text editors, which often do add an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)