Custom map_meta_cap filter does not return [‘do_not_allow’]

I don’t know how to make it restrict access correctly. Try this, which uses get_post_ancestors(): function staby_cap_filter( $allcaps, $cap, $args, $user ) { // Get the current user’s roles. $roles = (array) $user->roles; /* Do nothing if: 1. The above roles doesn’t include ‘test’, or 2. edit_post is not the capability being checked, or 3. … Read more

HTML dropdown setting not showing last saved value in the database

The problem is this: selected(get_option(‘lp_actPage’, $slug)) selected needs 2 parameters, but you gave it 1, and get_option wants 1 parameter but you gave it 2. If we reformat this, the problem becomes much clearer: selected( get_option(‘lp_actPage’, $slug) ) What’s necessary is: selected( get_option(‘lp_actPage’) $slug ) Sidenote get_pages doesn’t use the normal post querying code, and … Read more

How to use the wpsnonce clone post link?

One option is to use wp_add_inline_script() to inline the action url to the page source. This can be done for example on the admin_enqueue_scripts action. In the example below I used admin_url() with wp_nonce_url() to retrieve the nonce wp-admin url and then added the query paramters to it with add_query_arg(). add_action( ‘admin_enqueue_scripts’, ‘my_admin_action_url’, 5 ); … Read more

Admin submenu issue with PHP not detecting two strings as equal

string(77) “edit-tags.php?taxonomy=acs-field-group-category&post_type=acs-field-group” string(73) “edit-tags.php?taxonomy=acs-field-group-category&post_type=acs-field-group” Same string, different length! No, they’re not the same string — if you had viewed the raw/server-generated HTML source, or used this instead of the var_dump($submenu_file);: echo ‘<pre>’; var_dump($submenu_file, $sub_item[2]); echo ‘</pre>’; Then you would have seen the correct string which uses &amp; instead of just &: string(77) “edit-tags.php?taxonomy=acs-field-group-category&amp;post_type=acs-field-group” So that … Read more

echo esc_url( get_permalink($post->ID) + complete the ID’s url

The best approach, from my point of view, is to use add_query_arg() function: $only_conent_url = add_query_arg( array( ‘content-only’ => 1 ), get_permalink( $post->ID ) ); And then you can escape it if you need: esc_url( $only_conent_url ); add_query_arg() takes the URL passed as second paramenter and append a properly formatted query string built from the … Read more