I'm inserting a post using wp_post_insert(). And my post's content looks like this: <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { ... } but on the insert process, Wordpress removes the data attribute. So above code becomes this: <img src="image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { ... } I've tried something like this but no luck: function my_filter_allowed_html($allowed, $context){ if (is_array($context)) { return $allowed; } if ($context === 'post') { $allowed['img']['data'] = true; $allowed['src']['data'] = true; } return $allowed; } add_filter('wp_kses_allowed_html', 'my_filter_allowed_html', 10, 2); How can I avoid …
I've set up a HTML editor for WordPress comments, and I want to change the allowed HTML tags for comments accordingly. Some of the HTML tags also have inline styling, or classes added. I only want to allow the styling and classes that I'm expecting, but I cannot get it to work. I want to allow only these custom classes and styles. <span class="spoiler">This is spoilered text</span> <span style="text-decoration: line-through;">This text has strikethrough</span> Non-working code: function custom_allowed_tags_comment() { global $allowedtags; …
I have this code in my function.php: add_action( 'init', 'blockusers_init' ); function blockusers_init() { if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { wp_redirect( 'http://madeeasy-online.com/zhile-2/dobavit-obyavlenie/', 302); exit; } } But I want 'moderator' to reach the admin-panel. What should I add to the code? Thank in advance, Sv
I would like to use $allowedposttags to allow extra HTML tags during entry submission. Can I allow all attributes for a specific tag using $allowedposttags? For example, the code below will allow iframe tags and the src, height, and width attributes in the iframe tags: $allowedposttags['iframe'] = array( 'src' => array(), 'height' => array(), 'width' => array() ); How can I allow all attributes in this example, not just src, height, and width?
I know that WordPress uses KSES to parse HTML and strip invalid XHTML so I took control of $allowedtags in my themes functions.php file inside a function then added 'target' keyed to an array which contains '_blank' keyed to an empty array. I thought this would work but my link still seems to not contain the target attribute? I have tried re saving the HTML also. Here is my code: function add_required_html_tags() { global $allowedtags; //tap into wordpress global array …
I am trying to allow the "onclick" attribute on links as well as some html tags such as iframe to the content displayed in posts and pages. In my theme's functions.php file, I tried removing filters such as wpautop function rm_wpautop($content) { global $post; // Get the keys and values of the custom fields: $rmwpautop = get_post_meta($post->ID, 'wpautop', true); // Remove the filter remove_filter('the_content', 'wpautop'); if ('false' === $rmwpautop) { } else { add_filter('the_content', 'wpautop'); } return $content; } // …
My webstie have custom post type created, and now I want to disable usage of any html tag in content editor, so only plain text is saved in database (and to remove content editor and html editor if possible). I found functions to remove (rich) content editor: add_filter('user_can_richedit' , create_function('' , 'return false;') , 50); And HTML editor remained. But even if I maange to remove HTML editor (this: http://prntscr.com/26uj6u ), users will be able to just type html tags …
this was kinda of a joke at the beginning but now I'm wondering if it's possible to use regex with the hook comment_form_defaults. Here is what I'm looking for : function remove_default_allowed_tags( $defaults) { $defaults = preg_replace('/<p class="form-allowed-tags">(.*?)<\/p>/','', $defaults); return $defaults; } add_filter('comment_form_defaults', 'remove_default_allowed_tags', 2); I know it can be easily done with something like this : $defaults['comment_notes_after'] = ''; return $defaults; But I just want to know if I can use my regex in this context and if not, …
WP uses $allowedtags to limit the set of allowable tags for comments.However, comments from administrators are unfiltered. What's the easiest way to ensure admin comments are also constrained to the tags contained in $allowedtags?