| 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="postbox-header"> |
| 28 |
<span> |
| 29 |
<?php echo __( 'Settings', SH_CD_SLUG ); ?> |
| 30 |
</span> |
| 31 |
</h3> |
| 32 |
<div class="inside"> |
| 33 |
<form method="post" action="options.php" class="sh-cd-settings"> |
| 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 __( 'User Experience' , SH_CD_SLUG); ?></h3> |
| 47 |
<table class="form-table"> |
| 48 |
<tr> |
| 49 |
<th scope="row"><?php echo __( 'Default Editor' , SH_CD_SLUG); ?></th> |
| 50 |
<?php $default_editor = sh_cd_default_editor_get(); ?> |
| 51 |
<td> |
| 52 |
<select id="sh-cd-option-default-editor" name="sh-cd-option-default-editor"> |
| 53 |
<?php |
| 54 |
foreach ( sh_cd_editors_options( false ) as $editor => $label ) { |
| 55 |
printf( '<option value="%s" %s>%s</option>', esc_attr( $editor ), selected( $editor, $default_editor ), esc_html( $label ) ); |
| 56 |
} |
| 57 |
?> |
| 58 |
</select> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
<tr> |
| 62 |
<th scope="row"><?php echo __( 'Tooltips enabled' , SH_CD_SLUG); ?></th> |
| 63 |
<?php $is_enabled = sh_cd_tooltips_is_enabled(); ?> |
| 64 |
<td> |
| 65 |
<select id="sh-cd-option-tool-tips-enabled" name="sh-cd-option-tool-tips-enabled"> |
| 66 |
<option value="yes" <?php selected( $is_enabled, true ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option> |
| 67 |
<option value="no" <?php selected( $is_enabled, false ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option> |
| 68 |
</select> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
</table> |
| 72 |
<h3><?php echo __( 'Permissions' , SH_CD_SLUG); ?></h3> |
| 73 |
<table class="form-table"> |
| 74 |
<tr class="<?php echo $disable_if_not_premium_class; ?>"> |
| 75 |
<th scope="row"><?php echo __( 'Who can view and modify snippet shortcodes?' , SH_CD_SLUG); ?></th> |
| 76 |
<?php $edit_permissions = sh_cd_permission_role(); ?> |
| 77 |
<td> |
| 78 |
<select id="sh-cd-edit-permissions" name="sh-cd-edit-permissions"> |
| 79 |
<option value="manage_options" <?php selected( $edit_permissions, 'manage_options' ); ?>><?php echo __( 'Administrators Only', SH_CD_SLUG ); ?></option> |
| 80 |
<option value="read_private_posts" <?php selected( $edit_permissions, 'read_private_posts' ); ?>><?php echo __( 'Editors and above', SH_CD_SLUG ); ?></option> |
| 81 |
<option value="publish_posts" <?php selected( $edit_permissions, 'publish_posts' ); ?>><?php echo __( 'Authors and above', SH_CD_SLUG ); ?></option> |
| 82 |
</select> |
| 83 |
<p><?php echo __('Specify the minimum level of user role that can edit and view shortcodes.', SH_CD_SLUG)?></p> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
<tr class="<?php echo $disable_if_not_premium_class; ?>"> |
| 87 |
<th scope="row"><a href="https://yeken.gitbook.io/snippet-shortcodes/features/ready-made/premium/database-values-by-id" target="_blank" rel="noopener">"db-value-by-id"</a> <?php echo __( 'shortcode enabled', SH_CD_SLUG ); ?>?</th> |
| 88 |
<?php $is_enabled = sh_cd_is_shortcode_db_value_by_id_enabled(); ?> |
| 89 |
<td> |
| 90 |
<select id="sh-cd-shortcode-db-value-by-id-enabled" name="sh-cd-shortcode-db-value-by-id-enabled"> |
| 91 |
<option value="No" <?php selected( $is_enabled, false ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option> |
| 92 |
<option value="Yes" <?php selected( $is_enabled, true ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option> |
| 93 |
</select> |
| 94 |
<p><?php echo __('Should the Premium shortcode, [sv slug="db-value-by-id"] be enabled?', SH_CD_SLUG)?></p> |
| 95 |
</td> |
| 96 |
</tr> |
| 97 |
</table> |
| 98 |
<?php submit_button(); ?> |
| 99 |
</form> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
</div> |
| 103 |
</div> |
| 104 |
</div> |
| 105 |
<!-- #poststuff --> |
| 106 |
|
| 107 |
</div> <!-- .wrap --> |
| 108 |
|
| 109 |
<?php |
| 110 |
|
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Register fields to save |
| 115 |
*/ |
| 116 |
function sh_cd_register_settings(){ |
| 117 |
|
| 118 |
register_setting( 'sh-cd-options-group', 'sh-cd-edit-permissions' ); |
| 119 |
register_setting( 'sh-cd-options-group', 'sh-cd-shortcode-db-value-by-id-enabled' ); |
| 120 |
register_setting( 'sh-cd-options-group', 'sh-cd-option-tool-tips-enabled' ); |
| 121 |
register_setting( 'sh-cd-options-group', 'sh-cd-option-default-editor' ); |
| 122 |
} |
| 123 |
add_action( 'admin_init', 'sh_cd_register_settings' ); |
| 124 |
|