Is there a faster way than wp_insert_post to add content to a blog

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

What does $_registered_pages do?

$_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

Adding JS function as third parameter in do_action

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

WordPress removing data attributes for scheduled post

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

URL rewriting must be activated manually for my plugin

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

calling jquery function on plugin page

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

Can I use the different settings sections over different pages using the save options group?

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