| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | if ( !current_user_can( 'manage_options' ) ) { |
| 8 | 8 | wp_die( __( 'You do not have sufficient permissions to access this page.' , SH_CD_SLUG ) ); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - $disable_if_not_premium_class = ( sh_cd_is_premium() ) ? '' : 'sh-cd-disabled'; | |
| 11 | + $disable_if_not_premium_class = ( SH_CD_IS_PREMIUM ) ? '' : 'sh-cd-disabled'; | |
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div id="icon-options-general" class="icon32"></div> |
| @@ -23,15 +23,15 @@ | ||
| 23 | 23 | |
| 24 | 24 | <div class="meta-box-sortables ui-sortable"> |
| 25 | 25 | |
| 26 | 26 | <div class="postbox"> |
| 27 | - <h3 class="postbox-header"> | |
| 28 | - <span> | |
| 29 | - <?php echo __( 'Settings', SH_CD_SLUG ); ?> | |
| 30 | - </span> | |
| 27 | + <h3 class="hndle"> | |
| 28 | + <span> | |
| 29 | + <?php echo __( SH_CD_PLUGIN_NAME . ' Settings', SH_CD_SLUG); ?> | |
| 30 | + </span> | |
| 31 | 31 | </h3> |
| 32 | 32 | <div class="inside"> |
| 33 | - <form method="post" action="options.php" class="sh-cd-settings"> | |
| 33 | + <form method="post" action="options.php"> | |
| 34 | 34 | <?php |
| 35 | 35 | |
| 36 | 36 | settings_fields( 'sh-cd-options-group' ); |
| 37 | 37 | do_settings_sections( 'sh-cd-options-group' ); |
| @@ -38,47 +38,19 @@ | ||
| 38 | 38 | |
| 39 | 39 | ?> |
| 40 | 40 | |
| 41 | 41 | <?php |
| 42 | - if ( false === sh_cd_is_premium() ) { | |
| 42 | + if ( false === SH_CD_IS_PREMIUM ) { | |
| 43 | 43 | sh_cd_display_pro_upgrade_notice(); |
| 44 | 44 | } |
| 45 | 45 | ?> |
| 46 | - <h3><?php echo __( 'User Experience' , SH_CD_SLUG); ?></h3> | |
| 47 | - <hr /> | |
| 48 | - <table class="form-table"> | |
| 49 | - <tr> | |
| 50 | - <th scope="row"><?php echo __( 'Default Editor' , SH_CD_SLUG); ?></th> | |
| 51 | - <?php $default_editor = sh_cd_default_editor_get(); ?> | |
| 52 | - <td> | |
| 53 | - <select id="sh-cd-option-default-editor" name="sh-cd-option-default-editor"> | |
| 54 | - <?php | |
| 55 | - foreach ( sh_cd_editors_options( false ) as $editor => $label ) { | |
| 56 | - printf( '<option value="%s" %s>%s</option>', esc_attr( $editor ), selected( $editor, $default_editor ), esc_html( $label ) ); | |
| 57 | - } | |
| 58 | - ?> | |
| 59 | - </select> | |
| 60 | - </td> | |
| 61 | - </tr> | |
| 62 | - <tr> | |
| 63 | - <th scope="row"><?php echo __( 'Tooltips enabled' , SH_CD_SLUG); ?></th> | |
| 64 | - <?php $is_enabled = sh_cd_tooltips_is_enabled(); ?> | |
| 65 | - <td> | |
| 66 | - <select id="sh-cd-option-tool-tips-enabled" name="sh-cd-option-tool-tips-enabled"> | |
| 67 | - <option value="yes" <?php selected( $is_enabled, true ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option> | |
| 68 | - <option value="no" <?php selected( $is_enabled, false ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option> | |
| 69 | - </select> | |
| 70 | - </td> | |
| 71 | - </tr> | |
| 72 | - </table> | |
| 73 | 46 | <h3><?php echo __( 'Permissions' , SH_CD_SLUG); ?></h3> |
| 74 | - <hr /> | |
| 75 | 47 | <table class="form-table"> |
| 76 | 48 | <tr class="<?php echo $disable_if_not_premium_class; ?>"> |
| 77 | 49 | <th scope="row"><?php echo __( 'Who can view and modify snippet shortcodes?' , SH_CD_SLUG); ?></th> |
| 78 | 50 | <?php $edit_permissions = sh_cd_permission_role(); ?> |
| 79 | 51 | <td> |
| 80 | - <select id="sh-cd-edit-permissions" name="sh-cd-edit-permissions" <?php disabled( sh_cd_is_premium(), false ); ?>> | |
| 52 | + <select id="sh-cd-edit-permissions" name="sh-cd-edit-permissions"> | |
| 81 | 53 | <option value="manage_options" <?php selected( $edit_permissions, 'manage_options' ); ?>><?php echo __( 'Administrators Only', SH_CD_SLUG ); ?></option> |
| 82 | 54 | <option value="read_private_posts" <?php selected( $edit_permissions, 'read_private_posts' ); ?>><?php echo __( 'Editors and above', SH_CD_SLUG ); ?></option> |
| 83 | 55 | <option value="publish_posts" <?php selected( $edit_permissions, 'publish_posts' ); ?>><?php echo __( 'Authors and above', SH_CD_SLUG ); ?></option> |
| 84 | 56 | </select> |
| @@ -85,33 +57,18 @@ | ||
| 85 | 57 | <p><?php echo __('Specify the minimum level of user role that can edit and view shortcodes.', SH_CD_SLUG)?></p> |
| 86 | 58 | </td> |
| 87 | 59 | </tr> |
| 88 | 60 | <tr class="<?php echo $disable_if_not_premium_class; ?>"> |
| 89 | - <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> | |
| 61 | + <th scope="row"><a href="https://snippet-shortcodes.yeken.uk/shortcodes/sc-db-value-by-id.html" target="_blank" rel="noopener">"sc-db-value-by-id"</a> <?php echo __( 'shortcode enabled', SH_CD_SLUG ); ?>?</th> | |
| 90 | 62 | <?php $is_enabled = sh_cd_is_shortcode_db_value_by_id_enabled(); ?> |
| 91 | 63 | <td> |
| 92 | - <select id="sh-cd-shortcode-db-value-by-id-enabled" name="sh-cd-shortcode-db-value-by-id-enabled" <?php disabled( sh_cd_is_premium(), false ); ?>> | |
| 64 | + <select id="sh-cd-shortcode-db-value-by-id-enabled" name="sh-cd-shortcode-db-value-by-id-enabled"> | |
| 93 | 65 | <option value="No" <?php selected( $is_enabled, false ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option> |
| 94 | 66 | <option value="Yes" <?php selected( $is_enabled, true ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option> |
| 95 | 67 | </select> |
| 96 | - <p><?php echo __('Should the Premium shortcode, [sv slug="db-value-by-id"] be enabled?', SH_CD_SLUG)?></p> | |
| 68 | + <p><?php echo __('Should the premium shortcode, [sv slug="sc-db-value-by-id"] be enabled?', SH_CD_SLUG)?></p> | |
| 97 | 69 | </td> |
| 98 | 70 | </tr> |
| 99 | - </table> | |
| 100 | - <h3><?php echo __( 'Utilities' , SH_CD_SLUG); ?></h3> | |
| 101 | - <hr /> | |
| 102 | - <table class="form-table"> | |
| 103 | - <tr class="<?php echo $disable_if_not_premium_class; ?>"> | |
| 104 | - <th scope="row"><?php echo __( 'Render-count analytics enabled?', SH_CD_SLUG ); ?></th> | |
| 105 | - <?php $render_count_enabled = sh_cd_is_render_count_enabled(); ?> | |
| 106 | - <td> | |
| 107 | - <select id="sh-cd-option-render-count-enabled" name="sh-cd-option-render-count-enabled" <?php disabled( sh_cd_is_premium(), false ); ?>> | |
| 108 | - <option value="yes" <?php selected( $render_count_enabled, true ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option> | |
| 109 | - <option value="no" <?php selected( $render_count_enabled, false ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option> | |
| 110 | - </select> | |
| 111 | - <p><?php echo __( 'Track how many times each shortcode has been rendered, shown on its edit screen. Disable this on a high-traffic site to avoid the extra database write on every shortcode render.', SH_CD_SLUG ); ?></p> | |
| 112 | - </td> | |
| 113 | - </tr> | |
| 114 | 71 | </table> |
| 115 | 72 | <?php submit_button(); ?> |
| 116 | 73 | </form> |
| 117 | 74 | </div> |
| @@ -131,49 +88,8 @@ | ||
| 131 | 88 | * Register fields to save |
| 132 | 89 | */ |
| 133 | 90 | function sh_cd_register_settings(){ |
| 134 | 91 | |
| 135 | - register_setting( 'sh-cd-options-group', 'sh-cd-edit-permissions', [ 'sanitize_callback' => 'sh_cd_sanitize_edit_permissions' ] ); | |
| 136 | - register_setting( 'sh-cd-options-group', 'sh-cd-shortcode-db-value-by-id-enabled', [ 'sanitize_callback' => 'sh_cd_sanitize_yes_no' ] ); | |
| 137 | - register_setting( 'sh-cd-options-group', 'sh-cd-option-tool-tips-enabled', [ 'sanitize_callback' => 'sh_cd_sanitize_tooltips_enabled' ] ); | |
| 138 | - register_setting( 'sh-cd-options-group', 'sh-cd-option-default-editor', [ 'sanitize_callback' => 'sh_cd_sanitize_default_editor' ] ); | |
| 139 | - register_setting( 'sh-cd-options-group', 'sh-cd-option-render-count-enabled', [ 'sanitize_callback' => 'sh_cd_sanitize_render_count_enabled' ] ); | |
| 140 | -} | |
| 141 | - | |
| 142 | -/** | |
| 143 | - * Sanitize the "who can view/edit shortcodes" permission role setting | |
| 144 | - */ | |
| 145 | -function sh_cd_sanitize_edit_permissions( $value ) { | |
| 146 | - | |
| 147 | - $allowed = [ 'manage_options', 'read_private_posts', 'publish_posts' ]; | |
| 148 | - | |
| 149 | - return ( true === in_array( $value, $allowed, true ) ) ? $value : 'manage_options'; | |
| 150 | -} | |
| 151 | - | |
| 152 | -/** | |
| 153 | - * Sanitize the "db-value-by-id" enabled setting | |
| 154 | - */ | |
| 155 | -function sh_cd_sanitize_yes_no( $value ) { | |
| 156 | - return ( 'Yes' === $value ) ? 'Yes' : 'No'; | |
| 157 | -} | |
| 158 | - | |
| 159 | -/** | |
| 160 | - * Sanitize the tooltips enabled setting | |
| 161 | - */ | |
| 162 | -function sh_cd_sanitize_tooltips_enabled( $value ) { | |
| 163 | - return ( 'yes' === $value ) ? 'yes' : 'no'; | |
| 164 | -} | |
| 165 | - | |
| 166 | -/** | |
| 167 | - * Sanitize the default editor setting | |
| 168 | - */ | |
| 169 | -function sh_cd_sanitize_default_editor( $value ) { | |
| 170 | - return ( true === sh_cd_editors_is_valid( $value ) ) ? $value : 'tinymce'; | |
| 171 | -} | |
| 172 | - | |
| 173 | -/** | |
| 174 | - * Sanitize the render-count analytics enabled setting | |
| 175 | - */ | |
| 176 | -function sh_cd_sanitize_render_count_enabled( $value ) { | |
| 177 | - return ( 'yes' === $value ) ? 'yes' : 'no'; | |
| 92 | + register_setting( 'sh-cd-options-group', 'sh-cd-edit-permissions' ); | |
| 93 | + register_setting( 'sh-cd-options-group', 'sh-cd-shortcode-db-value-by-id-enabled' ); | |
| 178 | 94 | } |
| 179 | 95 | add_action( 'admin_init', 'sh_cd_register_settings' ); |