Add Media has stopped working in the front end since 4.5 update

I’ve fixed it by creating the following tiny plugin: <?php /* Plugin Name: Fix “Add Media” button in WordPress 4.5 Plugin URI: twitter.com/ojeffery Description: The 4.5 update of WordPress changed to the most recent version of JQuery, which broke the Add Media button when you call wp_editor via the front end. This tiny plugin fixes … Read more

Listing registered scripts

There’s a global variable called $wp_scripts which is an instance of the WP_Scripts class. It doesn’t have a public API for looking at registered or enqueued scripts, but you can look inside the object and see what’s going on. You can see all the registered scripts with: global $wp_scripts; var_dump( $wp_scripts->registered ); To see the … Read more

Prevent empty Post Title on form submit via front end post (wp_insert_post_)

Simply put the wp_insert_post call inside your conditional check so its only called if the post title is not empty, something like this: if (empty($_POST[‘my_title’])){ echo ‘error: please insert a title’; } else { $title = $_POST[‘my_title’]; $new_post = array( ‘post_title’ => $title, ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’); $pid = wp_insert_post($new_post); }

add_editor_style is not loading in frontend. Any solution?

Here is my solution: add_filter(‘the_editor_content’, “firmasite_tinymce_style”); function firmasite_tinymce_style($content) { add_editor_style(‘assets/css/custom.css’); // This is for front-end tinymce customization if ( ! is_admin() ) { global $editor_styles; $editor_styles = (array) $editor_styles; $stylesheet = (array) $stylesheet; $stylesheet[] = ‘assets/css/custom.css’; $editor_styles = array_merge( $editor_styles, $stylesheet ); } return $content; } Live Example: http://unsalkorkmaz.com/firmasite-social-buddypress-bbpress-theme-based-on-bootstrap/ Check comments wp_editor.. its loading bootstrap.css … Read more

get_delete_post_link redirect

To redirect after the use of get_delete_post_link() it’s probably easiest to hook into the trashed_post action: Code: add_action( ‘trashed_post’, ‘wpse132196_redirect_after_trashing’, 10 ); function wpse132196_redirect_after_trashing() { wp_redirect( home_url(‘/your-custom-slug’) ); exit; } Or you could make it dependent on the according $_GET variable by hooking into the the action parse_request: Code: add_action( ‘parse_request’, ‘wpse132196_redirect_after_trashing_get’ ); function wpse132196_redirect_after_trashing_get() … Read more

Stop/Pause WordPress Heartbeat using Javascript

Drivingralle, You are on the right trail here with your code. I’ve done some work in the JavaScript console, and my conclusion from debugging heartbeat.min.js temporarily (source came from heartbeat.js) is that settings.suspend is properly triggered on the ‘unload.wp-heartbeat’ event. However, I believe it to be a bug that the focused() function sets settings.suspend back … Read more

How to display TinyMCE without wp_editor()

If you don’t need wp_editor in front-end, I think its OK. Here a little bit different option settings with your tinymce init. I use this without wp_editor in front-end. <script> jQuery( document ).ready( function( $ ) { tinymce.init( { mode : “exact”, elements : ‘pre-details’, theme: “modern”, skin: “lightgray”, menubar : false, statusbar : false, … Read more