Delete a specific item menu when I deactivate my plugin
WordPress automatically handles that if you force delete the page instead of thrashing it. The following function takes a parameter to force delete -> wp_delete_post( $postid, $force_delete )
WordPress automatically handles that if you force delete the page instead of thrashing it. The following function takes a parameter to force delete -> wp_delete_post( $postid, $force_delete )
The best way to include an external library is to put it in your plugins folder. Then just use require_once() wherever you need it. Depending on the size of the plugin and your type of programing this might be in the main plugin file or wherever you need that functionality.
You can access the database with an INSERT statement and add multiple rows at once. Something like this pseudo-code: INSERT INTO $wpdb->posts ( `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_status`, `post_name`, `post_modified`, `guid`, `post_type`, `post_mime_type` ) VALUES ( $user_id, $current_date,$current_date_gmt, $content1 ), ( $user_id, $current_date,$current_date_gmt, $content2 ), ( $user_id, $current_date,$current_date_gmt, $content3 ) ; Make sure to … Read more
$_registered_pages is a temporary container for all registered admin menu pages. It is filled in add_menu_page() and add_submenu_page() and used used later in user_can_access_admin_page(). The leading underscore indicates you should not use it for anything. It is private and might change its name any time without warning. So do not use it in your own … Read more
You have to filter ‘get_comment’. The filter is part of the function with the same name. It is called in wp-admin/comment.php?action=editcomment and the comment is passed to the edit form where you see the email. The parameter is a comment object, you can change the email value here.
First, your callback must be PHP: function myjsfunction_callback() { ?> <script>myjsfunction();</script> <?php } Second, you can add multiple callbacks to one action: add_action( ‘myhelp’, ‘myjsfunction_callback’ ); add_action( ‘myhelp’, ‘mysecondfunction’ ); Now, you can call do_action() without parameter … do_action( ‘myhelp’ ); … and both callbacks will be executed. I reply to your comment: You can … Read more
Found the answer. I hope this would be useful to others that might have this problem in the future. All you have to do is remove the content_save_pre filter and content_filtered_save_pre this will remove all Kses input form content filters. //temporarily disable remove_filter(‘content_save_pre’, ‘wp_filter_post_kses’); remove_filter(‘content_filtered_save_pre’, ‘wp_filter_post_kses’); wp_update_post($post); //bring it back once you’re done posting add_filter(‘content_save_pre’, … Read more
Whenever I create a plugin that needs permalinks enabled i check on the plugin activation and if its not set i display a message for the user: // Add Check if permalinks are set on plugin activation register_activation_hook( __FILE__, ‘is_permalink_activate’ ); function is_permalink_activate() { //add notice if user needs to enable permalinks if (! get_option(‘permalink_structure’) … Read more
You can review the explanation here to include any script here function my_enqueue($hook) { if( ‘edit.php’ != $hook ) return; wp_enqueue_script( ‘my_custom_script’, plugins_url(‘/myscript.js’, __FILE__) ); } add_action( ‘admin_enqueue_scripts’, ‘my_enqueue’ ); The above code will add the script in all your admin pages. In order to identify the page you may follow this: if (isset($_GET[‘page’]) && … Read more
The solution is to merge existing options before saving options in case not all options are presented on the page we are about save. So in the end of $sanitize_callback in register_setting function just before I return the data I call below function where $existing are all existing options saved in database. function merge_options( $existing, … Read more