| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') or die('Jog on!'); |
| 4 |
|
| 5 |
function sh_cd_settings_page_generic() { |
| 6 |
|
| 7 |
if ( !current_user_can( 'manage_options' ) ) { |
| 8 |
wp_die( __( 'You do not have sufficient permissions to access this page.' , SH_CD_SLUG ) ); |
| 9 |
} |
| 10 |
|
| 11 |
$disable_if_not_premium_class = ( SH_CD_IS_PREMIUM ) ? '' : 'sh-cd-disabled'; |
| 12 |
|
| 13 |
?> |
| 14 |
|
| 15 |
<div id="icon-options-general" class="icon32"></div> |
| 16 |
|
| 17 |
<div id="poststuff"> |
| 18 |
|
| 19 |
<div id="post-body" class="metabox-holder columns-3 yk-mt-settings"> |
| 20 |
|
| 21 |
<!-- main content --> |
| 22 |
<div id="post-body-content"> |
| 23 |
|
| 24 |
<div class="meta-box-sortables ui-sortable"> |
| 25 |
|
| 26 |
<div class="postbox"> |
| 27 |
<h3 class="hndle"> |
| 28 |
<span> |
| 29 |
<?php echo __( SH_CD_PLUGIN_NAME . ' Settings', SH_CD_SLUG); ?> |
| 30 |
</span> |
| 31 |
</h3> |
| 32 |
<div class="inside"> |
| 33 |
<form method="post" action="options.php"> |
| 34 |
<?php |
| 35 |
|
| 36 |
settings_fields( 'sh-cd-options-group' ); |
| 37 |
do_settings_sections( 'sh-cd-options-group' ); |
| 38 |
|
| 39 |
?> |
| 40 |
|
| 41 |
<?php |
| 42 |
if ( false === SH_CD_IS_PREMIUM ) { |
| 43 |
sh_cd_display_pro_upgrade_notice(); |
| 44 |
} |
| 45 |
?> |
| 46 |
<h3><?php echo __( 'Permissions' , SH_CD_SLUG); ?></h3> |
| 47 |
<table class="form-table"> |
| 48 |
<tr class="<?php echo $disable_if_not_premium_class; ?>"> |
| 49 |
<th scope="row"><?php echo __( 'Who can view and modify snippet shortcodes?' , SH_CD_SLUG); ?></th> |
| 50 |
<?php |
| 51 |
$edit_permissions = sh_cd_permission_role(); |
| 52 |
?> |
| 53 |
<td> |
| 54 |
<select id="sh-cd-edit-permissions" name="sh-cd-edit-permissions"> |
| 55 |
<option value="manage_options" <?php selected( $edit_permissions, 'manage_options' ); ?>><?php echo __( 'Administrators Only', SH_CD_SLUG ); ?></option> |
| 56 |
<option value="read_private_posts" <?php selected( $edit_permissions, 'read_private_posts' ); ?>><?php echo __( 'Editors and above', SH_CD_SLUG ); ?></option> |
| 57 |
<option value="publish_posts" <?php selected( $edit_permissions, 'publish_posts' ); ?>><?php echo __( 'Authors and above', SH_CD_SLUG ); ?></option> |
| 58 |
</select> |
| 59 |
<p><?php echo __('Specify the minimum level of user role that can edit and view shortcodes.', SH_CD_SLUG)?></p> |
| 60 |
</td> |
| 61 |
</tr> |
| 62 |
</table> |
| 63 |
<?php submit_button(); ?> |
| 64 |
</form> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<!-- #poststuff --> |
| 71 |
|
| 72 |
</div> <!-- .wrap --> |
| 73 |
|
| 74 |
<?php |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Register fields to save |
| 80 |
*/ |
| 81 |
function sh_cd_register_settings(){ |
| 82 |
|
| 83 |
register_setting( 'sh-cd-options-group', 'sh-cd-edit-permissions' ); |
| 84 |
} |
| 85 |
add_action( 'admin_init', 'sh_cd_register_settings' ); |
| 86 |
|