| @@ -1,13 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Global options area on the settings page. | |
| 4 | - * | |
| 5 | 3 | * @package Adminimize |
| 6 | 4 | * @subpackage Global Options |
| 7 | 5 | * @author Frank Bültge |
| 8 | 6 | */ |
| 9 | - | |
| 10 | 7 | if ( ! function_exists( 'add_action' ) ) { |
| 11 | 8 | echo "Hi there! I'm just a part of plugin, not much I can do when called directly."; |
| 12 | 9 | exit; |
| 13 | 10 | } |
| @@ -14,60 +11,40 @@ | ||
| 14 | 11 | ?> |
| 15 | 12 | |
| 16 | 13 | <div id="poststuff" class="ui-sortable meta-box-sortables"> |
| 17 | 14 | <div class="postbox"> |
| 18 | - <h3 class="hndle ui-sortable-handle" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>" id="global_options"><?php esc_attr_e( 'Global options', 'adminimize' ); ?></h3> | |
| 15 | + <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div> | |
| 16 | + <h3 class="hndle" id="global_options"><?php esc_attr_e( 'Global options', 'adminimize' ); ?></h3> | |
| 19 | 17 | |
| 20 | 18 | <div class="inside"> |
| 21 | - <br class="clear"/> | |
| 19 | + <br class="clear" /> | |
| 22 | 20 | |
| 23 | 21 | <table summary="config_edit_post" class="widefat"> |
| 24 | - <colgroup> | |
| 25 | - <?php | |
| 26 | - $col = 0; | |
| 27 | - if ( ! isset( $user_roles_names ) ) { | |
| 28 | - $user_roles_names = _mw_adminimize_get_all_user_roles_names(); | |
| 29 | - } | |
| 30 | - foreach ( $user_roles_names as $role_name ) { | |
| 31 | - // phpcs:disable | |
| 32 | - echo '<col class="col' . $col . '">' . "\n"; | |
| 33 | - $col ++; | |
| 34 | - } | |
| 35 | - ?> | |
| 36 | - </colgroup> | |
| 37 | 22 | <thead> |
| 38 | 23 | <tr> |
| 39 | 24 | <th><?php esc_attr_e( 'Option', 'adminimize' ); ?></th> |
| 40 | 25 | <?php |
| 41 | - foreach ( $user_roles_names as $role_name ) { | |
| 42 | - ?> | |
| 43 | - <th> | |
| 44 | - <?php | |
| 45 | - esc_attr_e( 'Deactivate for', 'adminimize' ); | |
| 46 | - echo '<br/>' . esc_html( $role_name ); | |
| 47 | - ?> | |
| 48 | - </th> | |
| 26 | + foreach ( $user_roles_names as $role_name ) { ?> | |
| 27 | + <th><?php esc_attr_e( 'Deactivate for', 'adminimize' ); | |
| 28 | + echo '<br/>' . $role_name; ?></th> | |
| 49 | 29 | <?php } ?> |
| 50 | 30 | </tr> |
| 51 | 31 | <tr> |
| 52 | 32 | <td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td> |
| 53 | 33 | <?php |
| 54 | - if ( ! isset( $user_roles ) ) { | |
| 55 | - $user_roles = _mw_adminimize_get_all_user_roles(); | |
| 56 | - } | |
| 57 | - foreach ( $user_roles as $role_slug ) { | |
| 34 | + foreach ( $user_roles_names as $role_name ) { | |
| 35 | + $role_name = strtolower( $role_name ); | |
| 36 | + $role_name = preg_replace( '/[^a-z0-9]+/', '', $role_name ); | |
| 58 | 37 | echo '<td class="num">'; |
| 59 | - echo '<input id="select_all" class="global_options_' . esc_attr( $role_slug ) | |
| 60 | - . '" type="checkbox" name="" value="" />'; | |
| 38 | + echo '<input id="select_all" class="global_options_' . $role_name | |
| 39 | + . '" type="checkbox" name="" value="" />'; | |
| 61 | 40 | echo '</td>' . "\n"; |
| 62 | - } | |
| 63 | - ?> | |
| 41 | + } ?> | |
| 64 | 42 | </tr> |
| 65 | 43 | </thead> |
| 66 | 44 | |
| 67 | 45 | <tbody> |
| 68 | 46 | <?php |
| 69 | - $disabled_global_option_ = array(); | |
| 70 | 47 | foreach ( $user_roles as $role ) { |
| 71 | 48 | $disabled_global_option_[ $role ] = _mw_adminimize_get_option_value( |
| 72 | 49 | 'mw_adminimize_disabled_global_option_' . $role . '_items' |
| 73 | 50 | ); |
| @@ -96,9 +73,9 @@ | ||
| 96 | 73 | $_mw_adminimize_own_values = _mw_adminimize_get_option_value( '_mw_adminimize_own_values' ); |
| 97 | 74 | $_mw_adminimize_own_values = preg_split( "/\r\n/", $_mw_adminimize_own_values ); |
| 98 | 75 | foreach ( (array) $_mw_adminimize_own_values as $key => $_mw_adminimize_own_value ) { |
| 99 | 76 | $_mw_adminimize_own_value = trim( $_mw_adminimize_own_value ); |
| 100 | - $global_options[] = $_mw_adminimize_own_value; | |
| 77 | + $global_options[] = $_mw_adminimize_own_value; | |
| 101 | 78 | } |
| 102 | 79 | |
| 103 | 80 | $_mw_adminimize_own_options = _mw_adminimize_get_option_value( '_mw_adminimize_own_options' ); |
| 104 | 81 | $_mw_adminimize_own_options = preg_split( "/\r\n/", $_mw_adminimize_own_options ); |
| @@ -103,9 +80,9 @@ | ||
| 103 | 80 | $_mw_adminimize_own_options = _mw_adminimize_get_option_value( '_mw_adminimize_own_options' ); |
| 104 | 81 | $_mw_adminimize_own_options = preg_split( "/\r\n/", $_mw_adminimize_own_options ); |
| 105 | 82 | foreach ( (array) $_mw_adminimize_own_options as $key => $_mw_adminimize_own_option ) { |
| 106 | 83 | $_mw_adminimize_own_option = trim( $_mw_adminimize_own_option ); |
| 107 | - $global_options_names[] = $_mw_adminimize_own_option; | |
| 84 | + $global_options_names[] = $_mw_adminimize_own_option; | |
| 108 | 85 | } |
| 109 | 86 | |
| 110 | 87 | $x = 0; |
| 111 | 88 | foreach ( $global_options as $index => $global_option ) { |
| @@ -113,21 +90,21 @@ | ||
| 113 | 90 | if ( empty( $global_option ) ) { |
| 114 | 91 | continue; |
| 115 | 92 | } |
| 116 | 93 | |
| 117 | - $global_option = esc_attr( $global_option ); | |
| 118 | - | |
| 119 | 94 | $checked_user_role_ = array(); |
| 120 | - foreach ( (array) $user_roles as $role ) { | |
| 121 | - $checked_user_role_[ $role ] = _mw_adminimize_is_checked( $global_option, $disabled_global_option_[ $role ] ); | |
| 95 | + foreach ( $user_roles as $role ) { | |
| 96 | + $checked_user_role_[ $role ] = ( isset( $disabled_global_option_[ $role ] ) | |
| 97 | + && in_array( $global_option, $disabled_global_option_[ $role ] ) ) ? ' checked="checked"' | |
| 98 | + : ''; | |
| 122 | 99 | } |
| 123 | 100 | echo '<tr>' . "\n"; |
| 124 | 101 | echo '<td>' . $global_options_names[ $index ] . ' <span>(' . $global_option . ')</span> </td>' . "\n"; |
| 125 | - foreach ( (array) $user_roles as $role ) { | |
| 102 | + foreach ( $user_roles as $role ) { | |
| 126 | 103 | echo '<td class="num"><input id="check_post' . $role . $x . '" class="global_options_' |
| 127 | - . preg_replace( '/[^a-z0-9_-]+/', '', $role ) . '" type="checkbox" ' | |
| 128 | - . $checked_user_role_[ $role ] . ' name="mw_adminimize_disabled_global_option_' | |
| 129 | - . $role . '_items[]" value="' . $global_option . '" /></td>' . "\n"; | |
| 104 | + . preg_replace( '/[^a-z0-9]+/', '', $role ) . '" type="checkbox"' | |
| 105 | + . $checked_user_role_[ $role ] . ' name="mw_adminimize_disabled_global_option_' | |
| 106 | + . $role . '_items[]" value="' . $global_option . '" /></td>' . "\n"; | |
| 130 | 107 | } |
| 131 | 108 | echo '</tr>' . "\n"; |
| 132 | 109 | $x ++; |
| 133 | 110 | |
| @@ -136,66 +113,50 @@ | ||
| 136 | 113 | </tbody> |
| 137 | 114 | </table> |
| 138 | 115 | |
| 139 | 116 | <?php |
| 140 | - // your own global options. | |
| 117 | + //your own global options | |
| 141 | 118 | ?> |
| 142 | - <br style="margin-top: 10px;"/> | |
| 119 | + <br style="margin-top: 10px;" /> | |
| 143 | 120 | <table summary="config_edit_post" class="widefat"> |
| 144 | 121 | <thead> |
| 145 | 122 | <tr> |
| 146 | - <th> | |
| 147 | - <?php | |
| 148 | - esc_attr_e( 'Your own options', 'adminimize' ); | |
| 123 | + <th><?php esc_attr_e( 'Your own options', 'adminimize' ); | |
| 149 | 124 | echo '<br />'; |
| 150 | - esc_attr_e( 'Option name', 'adminimize' ); | |
| 151 | - ?> | |
| 152 | - </th> | |
| 153 | - <th> | |
| 154 | - <?php | |
| 155 | - echo '<br />'; | |
| 156 | - esc_attr_e( 'Selector, ID or class', 'adminimize' ); | |
| 157 | - ?> | |
| 158 | - </th> | |
| 125 | + esc_attr_e( 'ID or class', 'adminimize' ); ?></th> | |
| 126 | + <th><?php echo '<br />'; | |
| 127 | + esc_attr_e( 'Option', 'adminimize' ); ?></th> | |
| 159 | 128 | </tr> |
| 160 | 129 | </thead> |
| 161 | 130 | |
| 162 | 131 | <tbody> |
| 163 | 132 | <tr valign="top"> |
| 164 | - <td colspan="2"> | |
| 165 | - <?php | |
| 166 | - esc_attr_e( | |
| 133 | + <td colspan="2"><?php esc_attr_e( | |
| 167 | 134 | 'It is possible to add your own IDs or classes from elements and tags. You can find IDs and classes with the FireBug Add-on for Firefox. Assign a value and the associate name per line.', |
| 168 | 135 | 'adminimize' |
| 169 | - ); | |
| 170 | - ?> | |
| 171 | - </td> | |
| 136 | + ); ?></td> | |
| 172 | 137 | </tr> |
| 173 | 138 | <tr valign="top"> |
| 174 | 139 | <td> |
| 175 | - <label for="_mw_adminimize_own_options"></label> | |
| 176 | 140 | <textarea name="_mw_adminimize_own_options" cols="60" rows="3" |
| 177 | - id="_mw_adminimize_own_options" style="width: 95%;"><?php | |
| 178 | - echo _mw_adminimize_get_option_value('_mw_adminimize_own_options' ); ?></textarea> | |
| 179 | - <br/> | |
| 180 | - <?php | |
| 181 | - esc_attr_e( | |
| 141 | + id="_mw_adminimize_own_options" style="width: 95%;"><?php echo _mw_adminimize_get_option_value( | |
| 142 | + '_mw_adminimize_own_options' | |
| 143 | + ); ?></textarea> | |
| 144 | + <br /> | |
| 145 | + <?php esc_attr_e( | |
| 182 | 146 | 'Possible nomination for ID or class. Separate multiple nominations through a carriage return.', |
| 183 | 147 | 'adminimize' |
| 184 | - ); | |
| 185 | - ?> | |
| 148 | + ); ?> | |
| 186 | 149 | </td> |
| 187 | 150 | <td> |
| 188 | - <label for="_mw_adminimize_own_values"></label> | |
| 189 | 151 | <textarea class="code" name="_mw_adminimize_own_values" cols="60" rows="3" |
| 190 | - id="_mw_adminimize_own_values" style="width: 95%;"><?php | |
| 191 | - echo _mw_adminimize_get_option_value('_mw_adminimize_own_values' ); ?></textarea> | |
| 192 | - <br/> | |
| 193 | - <?php | |
| 194 | - esc_attr_e( | |
| 152 | + id="_mw_adminimize_own_values" style="width: 95%;"><?php echo _mw_adminimize_get_option_value( | |
| 153 | + '_mw_adminimize_own_values' | |
| 154 | + ); ?></textarea> | |
| 155 | + <br /> | |
| 156 | + <?php esc_attr_e( | |
| 195 | 157 | 'Possible IDs or classes. Separate multiple values through a carriage return.', 'adminimize' |
| 196 | - ); | |
| 197 | - ?> | |
| 158 | + ); ?> | |
| 198 | 159 | </td> |
| 199 | 160 | </tr> |
| 200 | 161 | </tbody> |
| 201 | 162 | </table> |
| @@ -200,28 +161,20 @@ | ||
| 200 | 161 | </tbody> |
| 201 | 162 | </table> |
| 202 | 163 | |
| 203 | 164 | <p id="submitbutton"> |
| 204 | - <input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert"/> | |
| 205 | - <input class="button button-primary" type="submit" name="_mw_adminimize_save" value=" | |
| 206 | - <?php | |
| 207 | - esc_attr_e( | |
| 165 | + <input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" /> | |
| 166 | + <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e( | |
| 208 | 167 | 'Update Options', 'adminimize' |
| 209 | - ); | |
| 210 | - ?> | |
| 211 | - »"/><input type="hidden" name="page_options" value="'dofollow_timeout'"/> | |
| 168 | + ); ?> »" /><input type="hidden" name="page_options" value="'dofollow_timeout'" /> | |
| 212 | 169 | </p> |
| 213 | 170 | |
| 214 | 171 | <p> |
| 215 | - <a class="alignright button adminimize-scroltop" href="#" | |
| 216 | - style="margin:3px 0 0 30px;"> | |
| 217 | - <?php | |
| 218 | - esc_attr_e( | |
| 172 | + <a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" | |
| 173 | + style="margin:3px 0 0 30px;"><?php esc_attr_e( | |
| 219 | 174 | 'scroll to top', 'adminimize' |
| 220 | - ); | |
| 221 | - ?> | |
| 222 | - </a> | |
| 223 | - <br class="clear"/> | |
| 175 | + ); ?></a> | |
| 176 | + <br class="clear" /> | |
| 224 | 177 | </p> |
| 225 | 178 | |
| 226 | 179 | </div> |
| 227 | 180 | </div> |