How to restrict Front-End Editor on a page?

From the GitHub-Wiki The ‘front_end_editor_disable’-filter Use this filter if you want to completely disable the plugin for certain URLs. Callback arguments: bool $disable: The current state. Default: false You can use conditional tags: Conditionals tags return bool true/false, which means, if you want to disable it on a page, simply use is_page(), as it returns … 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

How to add media from front-end to an existing post?

@AboSami actually answered this question in an older post that was not showing up in my search diligence. While he was actually looking for something else his example code worked great. Here’s the script: <?php $post_id = $post->ID; if ( isset( $_POST[‘html-upload’] ) && !empty( $_FILES ) ) { require_once(ABSPATH . ‘wp-admin/includes/admin.php’); $id = media_handle_upload(‘async-upload’, … 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); }

Get names of authors who have edited a post

The WordPress function get_the_modified_author() will give you the author who last edited the current post. But if you want to list all the users that have edit the current post, you could try: function get_the_modified_authors_wpse_99226(){ global $wpdb; $authors = array(); $results = $wpdb->get_results( $wpdb->prepare(“SELECT post_author FROM $wpdb->posts WHERE (post_type=”%s” AND ID = %d) OR (post_type=”revision” … Read more

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

Deleting users from front-end with wp_delete_user()

You could use AJAX to request a custom ‘action’ and send the users’ ID. Alternatively ‘post’ the action and user ID to the same page. They are both essentially the same thing, but the former doesn’t require the page to be reloaded. There are plenty of topics on this site that deal with AJAX, so … Read more