Moderation UI use WP Capabilities (PR)
-
This is a great and extremely useful plugin!
I’d like to suggest a feature that allows specifying a user’s role that can see the admin links. Currently the Settings menu is visible to anyone with ‘edit_posts’ capability, however the link goes to a blank page.
Here is a patch that does two things:
1. Change default permissions to
moderate_comments
.
2. Add another settings field that allows this to be changed.8c8
< Version: 1.5
—
> Version: 1.5-tag-capa
113c113
< if (!current_user_can(‘edit_posts’) || empty($options[‘disqus_shortname’])) {
—
> if (!(current_user_can(pipdisqus_get_moderator_capability()) || current_user_can(‘manage_options’)) || empty($options[‘disqus_shortname’])) {
135c135
< add_options_page(‘pipdisqus’, ‘pipDisqus’, ‘edit_posts’, ‘pipdisqus’, ‘pipdisqus_options_page’);
—
> add_options_page(‘pipdisqus’, ‘pipDisqus’, ‘manage_options’, ‘pipdisqus’, ‘pipdisqus_options_page’);
158a159,166
> add_settings_field(
> ‘disqus_capability’,
> __(‘Moderation Permission’, ‘pipdisqus’).’ (?)’,
> ‘disqus_capability_render’,
> ‘pipdisqus_pluginPage’,
> ‘pipdisqus_pluginPage_section’
> );
>
173a182,188
> function disqus_capability_render() {
> $disqus_capability = pipdisqus_get_moderator_capability();
> ?>
> <input type=”text” name=”pipdisqus_settings[disqus_capability]” value=”<?php echo esc_attr( $disqus_capability ); ?>”>
> <?php
> }
>
180a196,203
> function pipdisqus_get_moderator_capability() {
> $options = get_option(‘pipdisqus_settings’);
> $disqus_capability = ‘moderate_comments’;
> if (isset($options[‘disqus_capability’])) {
> $disqus_capability = trim(sanitize_text_field($options[‘disqus_capability’]));
> }
> return $disqus_capability;
> }
- The topic ‘Moderation UI use WP Capabilities (PR)’ is closed to new replies.