Make substitute in all WordPress posts

There are many ways to do this here a couple: 1) You can use something like: Better search and replace plugin here: https://wordpress.org/plugins/better-search-replace/ or SAFE SEARCH AND REPLACE ON DATABASE WITH SERIALIZED DATA script here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Both of these with serialize the data, which is important for many themes and plugins. There is a good … Read more

Is it possible to “comment out” text in a post?

There may be plugins that supply some kind of commenting functionality, similar to how Google Docs allows you to annotate parts of a document. Within WordPress directly, you could use the “Text Editor” view and HTML comments. The downside here is that the HTML comments will be visible if someone goes to the page and … Read more

Limiting allowed html elements/strip harmful scripts from editor

Adjust HTML-Filter: <?php function fb_change_mce_options($initArray) { // Comma separated string od extendes tags // Command separated string of extended elements $ext=”pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]”; if ( isset( $initArray[‘extended_valid_elements’] ) ) { $initArray[‘extended_valid_elements’] .= ‘,’ . $ext; } else { $initArray[‘extended_valid_elements’] = $ext; } // maybe; set tiny paramter verify_html //$initArray[‘verify_html’] = false; return $initArray; } add_filter(‘tiny_mce_before_init’, ‘fb_change_mce_options’); ?> … Read more

How to get Text Selection in WordPress Editor

The visual editor is an TinyMCE implementation. The first way to repace a selected text, is to write a plugin for the TinyMCE. If you do not want to write a plugin, use the tinyMCE object: add_action( ‘admin_footer’, ‘tinyNagging’ ); function tinyNagging() { echo ‘ <script type=”text/javascript”> jQuery(document).ready( function() { window.setInterval( function(){ var selectedText = … Read more

Disable “preview changes” button

Please replace $post_type with your post_type in question, e.g. post, page, cpt_slug,… The function echoing the meta box with the preview button is called post_submit_meta_box. The condition to show the button is set with the function is_post_type_viewable. Following that: If the {$post_type}s flags publicly_queryable or _builtin and public are set to true the preview button … Read more

How can I automatically set a post slug based on the post title during post publish?

As long as haven’t touched the slug WordPress will generate a new one after you entered a title. Update To change other peoples slugs use a filter (not tested!): add_filter( ‘wp_insert_post_data’, ‘prevent_numeric_slugs’, 10, 1 ); function prevent_numeric_slugs( $post_data ) { if ( ! isset ( $post_data[‘post_title’] ) or ! is_numeric( $post_data[‘post_name’] ) ) { // … Read more

Hide tag and category boxes from the post editor

Using remove metabox function you can do this. Simply put this inside your themes functions.php file at very end. NOTE – unwrap <?php ?> if necessary. <?php function wpse60590_remove_metaboxes() { remove_meta_box( ‘categorydiv’ , ‘post’ , ‘normal’ ); remove_meta_box( ‘tagsdiv-post_tag’ , ‘post’ , ‘normal’ ); } add_action( ‘admin_menu’ , ‘wpse60590_remove_metaboxes’ ); ?>

How to get value of selected page template in Gutenberg editor?

I slightly modified SkyShab’s code, because it fired template change event on page load and it didn’t fire when template was changed to default (since getEditedPostAttribute( ‘template’ ) is then ”, which equals to null when testing for template change) const { select, subscribe } = wp.data; class PageTemplateSwitcher { constructor() { this.template = null; … Read more

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