Add user role to generated plugin

If you look at the documentation for add_menu_page(), you’ll see the third argument is: The capability required for this menu to be displayed to the user. In WordPress you don’t require specific roles for permissions, you require a capability, and roles are collections of capabilities. Your menu page requires manage_options, which is only held by … Read more

Shortcode to update user meta

Basically, you can’t show the button and update the meta at the same moment. This has to be done in two separate requests as follows: Show the button whereever you want. It needs to be a form that submits to the same page (or an ajax call to another URL, but let’s keep it simple … Read more

WPDB: Update table

Now I have learned that the way I change the database is not safe regarding SQL injection. So I wonder where/how did you learn that? And other than that you should check if those two POST variables are actually set, your toggle_status() code looks fine to me, and $wpdb->update() is an easy way to update … Read more

Render Modula Plugin Shortcode On Ajax Request

I can only comment on this on a general level as I’m not familiar with the plugin you’re using. (This might also not be the best place to ask this kind of plugin related questions as 3rd party plugins are currently considered off-topic here on WPSE.) Majority of this kind of plugins I’ve encountered have … Read more

How to deploy gutenberg on my own [closed]

Yes, you need to search a bit for the build steps. You want Getting Started with Code Contribution: After installing Node, you can build Gutenberg by running the following from within the cloned repository: npm ci npm run build Note: The install scripts require Python to be installed and in the path of the local … Read more

Override plugin styles via my custom theme

Plugins don’t need to “get” styles. You just need to enqueue your own stylesheet with styles for the markup used by that plugin. If the plugin is on the front-end, your styles could even just be added to your child theme, or Appearance > Customize > Additional CSS. If the plugin elements you want to … Read more

Notice: Uninitialized string offset: 0 in social sharing mu-plugin

Your custom get_the_post_thumbnail_src() function returns a string and not an array, hence in the following code, $sb_thumb is not an array: $sb_thumb = get_the_post_thumbnail_src(get_the_post_thumbnail()); So the PHP notice in question occurred because you used $sb_thumb[0] in the following code, which appears twice in your wpvkp_social_buttons() function: $pinterestURL = ‘https://pinterest.com/pin/create/button/?url=”.$sb_url.”&media=”.$sb_thumb[0].”&description=’.$sb_title; And to get rid of the … Read more

Access a particular field in an array

Going by your array you could do something like this. This is the minimun code required to only get the medium size url The function that handles finding all medium urls function get_images_medium_urls (&$urls = [], $arr, $find = [‘medium’, ‘url’]) { foreach ($arr as $key => $value) { if ($key === $find[0]) $urls[] = … Read more