CSS properties in textarea in the Customizer

As it happens, I was literally just doing some stuff with the customizer. You can use the following class to get what you need.. WP_Customize_Code_Editor_Control I’ll include it in the control ready to go. $wp_customize->add_control( new WP_Customize_Code_Editor_Control( $wp_customize, ‘favorite_html’, array( ‘label’ => ‘Theme CSS’, ‘description’ => ”, ‘code_type’ => ‘text/css’, ‘section’ => ‘section_id’, ‘settings’ => … Read more

Custom JS text area in customizer is being formatted wrong in document

@sam-skirrow just posting here what we did to fix this… WordPress 4.1 requires us to use a sanitize_callback filter when creating settings for the customizer (with good reason). Since you’re using the kirki framework to create these customizer settings, kirki detects that this is a textarea field and so it automatically applies the esc_textarea filter. … Read more

sanitize vimeo embed code?

You need to add a custom validation/sanitization callback, and hook it into publish_post (and/or draft_post and/or future_post, as applicable). For example: <?php function wpse_44807_update_custom_post_meta() { // Globalize the $post object global $post; // If our custom post meta key is set, sanitize it; // otherwise, return false $my_post_custom = ( isset( $_POST[‘_my_post_custom’] ? wp_filter_nohtml_kses( $_POST[‘_my_post_custom’] … Read more

Disable formatting on textarea

Add a priority to push your function to the end of the hook queue. add_action(‘the_content’, ‘my_plugin_content_hook’, 1000); Then, in your get_special_content function you will need to apply wpautop manually to the content to which you want it applied. function get_special_content() { $text=””; $autopeed = ‘content to autop’; $text .= apply_filters(‘wpautop’,$autopeed); $text .= “your textarea code”; … Read more

Alternative to esc_textarea

esc_textarea shouldn’t strip out newlines — It’s just a thin wrapper around htmlspecialchars: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/formatting.php#L2536 <?php function esc_textarea( $text ) { $safe_text = htmlspecialchars( $text, ENT_QUOTES ); return apply_filters( ‘esc_textarea’, $safe_text, $text ); } That said, there are lots of options. What do you want your users to do have the ability to post? esc_html will … Read more

How to stop wordpress from mangling HTML in a metabox textarea

I’v re-worked your code. I’ll try to explain some of the changes after the code block add_action(“admin_menu”, “tf_book_deets_create”); function tf_book_deets_create(){ add_meta_box(‘tf_book_details’, ‘Book Details’, ‘tf_book_details’, ‘books’); } function tf_book_details () { global $post; $tf_book_media = get_post_meta($post->ID, “tf_book_media”, true); $tf_book_review = get_post_meta($post->ID, “tf_book_review”, true); ?> <div class=”admin_meta”> <ul> <li><label>Reviews:</label><textarea rows=”5″ cols=”70″ name=”tf_book_review”><?php echo esc_textarea($tf_book_review); ?></textarea></li> <li><label>Media:</label><textarea rows=”5″ … Read more

How to add text to comment form #content textarea?

You can filter ‘comment_form_defaults’ to change the textarea. You get an array with the default fields as argument: add_filter( ‘comment_form_defaults’, ‘wpse_67503_textarea_insert’ ); function wpse_67503_textarea_insert( $fields ) { if ( /* your condition */ ) { $fields[‘comment_field’] = str_replace( ‘</textarea>’, ‘EXTRA CONTENT</textarea>’, $fields[‘comment_field’] ); } return $fields; }