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

Using wp_get_image_editor in a standalone script

Turns out I’m just silly. WP_Error was the undefined method, not resize. I was sending a bad image location through the resize function. How silly of me! It was working all along. I’ve included this on top $parse_uri = explode( ‘wp-content’, $_SERVER[‘SCRIPT_FILENAME’] ); require_once( $parse_uri[0] . ‘wp-load.php’ ); and this is my image resize function … Read more

nonces in custom oop plugin

check_admin_referer is a pluggable function which means it is defined after plugins are loaded so call your constructor or instantiate the object after or using plugins_loaded action hook. ex: class MyClass{ function __construct(){ if( isset($_POST[‘my_nonce_field’]) && check_admin_referer(‘my_nonce_action’, ‘my_nonce_field’)) $this->update_item(); } } add_action(‘plugins_loaded’,’newobj’); function newobj(){ $myclass = new MyClass; }

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