Shortcode adding p and br tags

Not sure if this will be helpful to anyone else but the cause of the issue was a custom formatter the theme had: function my_formatter($content) { $new_content=””; $pattern_full=”{(\[raw\].*?\[/raw\])}is”; $pattern_contents=”{\[raw\](.*?)\[/raw\]}is”; $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ($pieces as $piece) { if (preg_match($pattern_contents, $piece, $matches)) { $new_content .= $matches[1]; } else { $new_content .= wptexturize(wpautop($piece)); } … Read more

How to Change the Entire WordPress Admin panel Look and Feel?

Here’s a great codex article on the topic of creating administration theme: http://codex.wordpress.org/Creating_Admin_Themes And back to your question, you will want to load different stylesheets for different user roles, so you have to check who the current user is. Pay attention, the check is done using current_user_can() function and checking for administrator is not being … Read more

Add rewrite rule to permalink structure

1. Add a new rewrite rule: add_action(‘init’, function() { add_rewrite_rule(‘^dog/([^/]+)/?$’, ‘index.php?cat=dog&name=$matches[1]’, ‘top’); }, 10, 0); 2. Filter the post link: add_filter(‘post_link’, function($post_link, $post, $leave_name = false, $sample = false) { if ( is_object_in_term($post->ID, ‘category’, ‘DOG’) ) { $post_link = str_replace($post->ID . ‘-‘, ”, $post_link); } return $post_link; }, 10, 4); Try it in your functions.php. … Read more

How to prevent newline from appearing in shortcode?

The <br> tag is coming from wpautop(), which is one of a number of display filters added to the content via wp-includes/default-filters.php: // Display filters add_filter( ‘the_content’, ‘wptexturize’ ); add_filter( ‘the_content’, ‘convert_smilies’, 20 ); add_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘shortcode_unautop’ ); add_filter( ‘the_content’, ‘prepend_attachment’ ); add_filter( ‘the_content’, ‘wp_make_content_images_responsive’ ); … // Shortcodes add_filter( ‘the_content’, … Read more

Customize plugin update “new version is available” text

Since the text is processed by _() function, then, of course, you can modify it using gettext filter. function change_update_notification_msg( $translated_text, $untranslated_text, $domain ) { if ( is_admin() ) { $texts = array( ‘There is a new version of %1$s available. <a href=”https://wordpress.stackexchange.com/questions/323927/%2$s” %3$s>View version %4$s details</a>.’ => ‘My custom notification. There is a new … Read more

How to add option box in “Edit Post” plugin API?

Below is the example of a couple of checkboxes to set custom field values: // register the meta box add_action( ‘add_meta_boxes’, ‘my_custom_field_checkboxes’ ); function my_custom_field_checkboxes() { add_meta_box( ‘my_meta_box_id’, // this is HTML id of the box on edit screen ‘My Plugin Checkboxes’, // title of the box ‘my_customfield_box_content’, // function to be called to display … Read more

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