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

How to get term link that crosses different custom post types?

This code display all posts of all categories of genre taxonomy for custom post type book. Now, For different custom post type (author, product ) you have to change Custom Post Type Name inside $arg of WP_Query(). You will get term link using get_term_link($catterm) function or you can use also get_the_term_list(). $args = array( ‘number’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)