Has anyone managed to integrate the wp_editor inside a widget?

As said I think it’s quite hard to find a reliable solution because you have to take care of so many things. I go either for the way proposed by Danny van Kooten: http://dannyvankooten.com/450/tinymce-wysiwyg-editor-in-wordpress-plugin/ add and open the editor in a thickbox or another way I’ve used once, using the widget “accessibility mode” for “advanced” … Read more

WordPress Capabilities: edit_user vs edit_users

I found a few references to edit_user as a capability, one of which is this: // Allow user to edit itself if ( ‘edit_user’ == $cap && isset( $args[0] ) && $user_id == $args[0] ) break; http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/capabilities.php#L1005 I believe the comment in that block of code answers this question. Per @PatJ, it looks like map_meta_cap … Read more

Cancel post save

I’d hooked to ‘wp_insert_post_empty_content’ filter. See https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/post.php#L2748 //hook at the very end of all filters to prevent other filters from overwriting your return value ( 99 should be high enaugh ) add_filter( ‘wp_insert_post_empty_content’, ‘my_cancel_post_save_function’, 99, 2 ); function my_cancel_post_save_function( $maybe_empty, $postarr ) { if ( true === wp_is_post_revision( $postarr[ ‘ID’ ] ) ) { //postarr … Read more

How to Loop Plugin Option Field Set?

I figured it out after a little work. To start, I ended up using a single callback: array($this, ‘txs_loop_callbacks’) using the same add_settings_field registration above. Then I altered the final argument in the field resgistration, making each unique to that specific field: array(‘field’ => ‘txs_opacity_’.$i). Then in the loop callback I stored each field’s HTML … Read more

What is the correct way for plugins to create tables with special charset/collation considerations?

I think this issue is handled by WooCommerce in their plugin. It also creates its own tables and this is how they take care of Collation part. (I am referring to file class-wc-install.php of WooCommerce). They have written following code in the create_tables function global $wpdb; $collate=””; if ( $wpdb->has_cap( ‘collation’ ) ) { if … Read more

Check the Version of an Enqueue’d External Library

I can’t find a nice way of doing it though wp_script_*, but you can go to the global directly: global $wp_scripts; $version = $wp_scripts->query( ‘jquery’ )->ver; Here the query returns the script’s _WP_Dependency object, and then we can get the version from it. (Annoyingly wp_script_is( …, ‘registered’ ) fetches the _WP_Dependency but then casts the … Read more