Wordpress - Grant Role Menus and Widgets - wordpress

I have a Wordpress configuration where I would like to allow a user to edit Menus and Widgets without exposing the Theme and Edit CSS options.
Can anyone point out how to do this? So far I have only been able to expose all of the "Appearance" menu in the dashboard to that user.

There are a few WP Capabilities that are used to control access to the themes appearance menu.
"edit_theme_options" - use to allow access to the widgets, menus and theme options, and to deny access to switch themes, or modify files in the theme.
$role = get_role( 'editor' );
$role->add_cap( 'edit_theme_options' );
"switch_themes" - allows access to switch themes.
edit_themes - allows to edit files in the theme.
NOTE: Because add_cap function saves settings in the database, they will stay until are removed with remove_cap function.

I've had good luck with the plugin Adminimize. It gives you the ability to control who sees what for every option in the admin menu and a lot more. It is very detailed and can be a little overwhelming at first, but it isn't as bad as it looks once you've spent a little time around it. Hope that helps and good luck.

Related

Custom WordPress Theme add in WordPress theme

How to add custom WordPress theme in WordPress theme using PHP, CSS, HTML...I tried
C:\Users\megha\Downloads\wordpress-5.8.zip\wordpress\wp-content\themes in this way to show theme but nothing happen ..then how to insert theme in wordpress
[Installing WordPress themes and plugins][1] is very simple. All you have to do is go to the WordPress dashboard, there you will have the menu on the left. Select plugins/themes.
You can also search the directory, and apply filters to find a theme or plugin that best suits your needs. Click on install, then click activate, and voila! It’s done, my friend. You have successfully manually installed a theme/plugin on your website!
To use full-site editing, hover your cursor on Appearance, and in the menu select Editor. Voila! You can now edit your homepage, and create a design you want. For those looking forward to design ideas or ready-made blocks, check out WordPress Patterns.
Most importantly, there is no restriction on the number of plugins you can use (unless you have managed hosting, as most do not allow some plugins, especially those that clash with their platform’s codes. Read more here: managed vs self-hosting).
So, you can pick any number of plugins you want, and don’t worry about how to customize WordPress plugins or how to update WordPress plugins. It’s very simple and happens at the click of a button. We’ll be coming up with more guides, clearing any remaining whiff of doubt you might have.

Add a custom dashboard to a wordpress site

I need to build a dashboard that will allow users to sign in/out and access/update their business account information.
WordPress has its own dashboard for publishing content but this is not what I am looking for.
Would it be easier for me to create a second site using a framework (Ruby on Rails) that makes this type of user access easier? Or is there a solution in WordPress that I am unaware of?
You can easily customize the existing WordPress dashboard. The items shown on the dashboard are determined by the function current_user_can(), so you can hide items by restricting the capabilities of the user using the function add_role(). You can add your own items by the function add_submenu_page().
It has been a while since I customized the WordPress dashboard but if I remember correctly I also had to use JavaScript and CSS to dynamically modify the DOM but this may be because I was doing something unusual. Anyway I think it was quite easy to do.
you can check out the following wordpress plugin for your requirement
https://wordpress.org/plugins/client-dash/

How to extend plugins into my theme directory or customize plugin without touching the core files in wordpress?

I would like to know if there was any methodologies to inherit or extend a plugin files to theme directory as woocommerce did and customize them without touching the base/core files. please share any links or thoughts
Thanks
You're looking for WordPress's add_action() and do_action() functions. WooCommerce, for example, makes use of these functions by using hooks and filters for templates and functions.
For example, WooCommerce does things like do_action( 'woocommerce_before_main_content' );. This means that you can "add and action", override functionality, remove actions, and generally customize things how you see fit.
Not all plugins and themes ship with this functionality; but browsing the source code can often reveal instances of this. It's more of a courtesy by developers.

Make Only Accessible to Feed URL on a WordPress Site

I'm wondering if it is possible to write a plugin which shows nothing but only let the visitor access the feed url. The admin page should be accessible by the administrator as well.
The background of this idea is that I've written a custom feed generator and implemented it in a WordPress site. Since the site is only for the feeds, I'd like to make the site invisible to the public except the feed outputs.
I'm aware that there are Maintenance Mode and Members Only plugins. The problem is that the maintenance mode prohibits feed access and the member only mode bans general visitors.
So I'm wondering if there is a simple way to do this. I'd like to avoid editing mod_rewrite because I'm planning to make it as a plugin if possible. If it is not realistic to do it without mod_rewrite, I will try editing mod_rewrite.
Thanks for your input.
If you never want anything to render this could easily be fixed using the template_redirect hook. For example:
function stop_rendering() {
exit;
}
add_action( 'template_redirect', 'stop_rendering');
So, basically you don't want the theme to render? What about /categories, /tags, /archives etc.?
If that's all you want to do, you could just create a blank theme with the style.css (blank besides the theme info comment block) and the index.php template.

Wordpress theme / plugin option page

Is there any substantial difference between the Pluign options or Theme options for admin ?
I can find a lot of good theme related tutorials (for options pages) - but not so much (or not so clear) plugins option page .
Does following the themes related tutorials will be substantial the same ?
(considering only activation / deactivation hooks would be different ? )
Edit I - just to clarify:
my question was more specifically, whether I could follow the "themes" tutorials for the settings, even if I need it for "plugins" - and if so, what exactly are the points which I would need to change / pay attention to ..
This weekend I wrote my first plugin after being a WP theme developer since 2007 and I was confronted with the same problems as you.
It turns out that the theme page basically just a simplified version of what you would do to create a plugin page. This often means that functions take lesser arguments and you have less to think about. But it's a double-edged sword since it gives you less freedom about what you wanna do.
E.g: Instead of add_theme_page() you would call add_menu_page() or add_submenu_page() depending on where you want your menu to appear. Comparing the arguments:
add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
Same goes for add_options_page() wich is a wrapper function add_submenu_page().
The second thing I noticed is the Settings API. As long as you follow the Codex you and your plugin are save since it takes away all of the actual settings form layout creation. This is what many tutorials out there spend their most energy in: creating hundreds of lines of code to layout forms. Settings API is kind of like a framework for that.
I checked all top google tutorial results for "wordpress theme options page" and only two of them used the Settings API (this and that one). So I recommend you do not follow most of the tutorials unless they use the Settings API.
That's it really. Creating a plugin settings in WordPress is nothing more than registering the menu item and rendering the settings via Settings API.
In WordPress the way the options are handled are quite similar for both themes and Plugins.
Also if you choose to put a particular option inside theme, then it will be active only as long as that particular theme is activated, the same applies for the Plugin as well.
If you want the functionality to be available only when the theme is activated, then you might have to place them inside theme and if you want it to be active across multiple themes, then you might want to put them inside a Plugin.
The other difference is that, themes might have some special hooks which may not be available for the Plugin.
Also the option/setting page for themes and Plugins are different.
This is depending on how a theme or plugin develop. Options are usually stored on the wp_options database. Both of them can benefit from it and substantially the same. But on other case, like a very large plugin, a developer would likely choose to create a TABLE and store the options there.

Resources