-
Notifications
You must be signed in to change notification settings - Fork 1
/
theme-options-for-editors.php
53 lines (44 loc) · 1.45 KB
/
theme-options-for-editors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Theme options for editors
* Description: Allow editors to change theme options.
* Plugin URI: http://marketpress.com/?p=17582
* Author: MarketPress, Thomas Scholz
* Author URI: http://marketpress.com/
* Licence: GPL 2
* License URI: http://opensource.org/licenses/GPL-2.0
* Version: 2013.10.22
*/
register_activation_hook( __FILE__, 'marketpress_theme_options_for_editors' );
add_action( 'admin_notices', 'marketpress_deactivate_theme_options_for_editors', 0 );
/**
* Add new capability to "editor" role.
*
* @wp-hook "activate_" . __FILE__
* @return void
*/
function marketpress_theme_options_for_editors() {
global $wp_roles;
if ( empty ( $wp_roles ) )
$wp_roles = new WP_Roles;
$wp_roles->add_cap( 'editor', 'edit_theme_options' );
}
/**
* Print an explanation and deactivate this plugin.
*
* @wp-hook admin_notices
* @return void
*/
function marketpress_deactivate_theme_options_for_editors() {
// Suppress default activation message.
unset( $_GET['activate'] );
$name = get_file_data( __FILE__, array ( 'Plugin Name' ), 'plugin' );
?>
<div class="updated">
<p>Editors can change theme options now.<br>
This is a permanent option, so you don’t need the plugin running anymore.</p>
<p><b><?php echo $name[0]; ?></b> has been deactivated.</p>
</div>
<?php
deactivate_plugins( plugin_basename( __FILE__ ) );
}