| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Adminimize |
| 4 |
* @subpackage Custom Post type options |
| 5 |
* @author Frank Bültge |
| 6 |
*/ |
| 7 |
if ( ! function_exists( 'add_action' ) ) { |
| 8 |
echo "Hi there! I'm just a part of plugin, not much I can do when called directly."; |
| 9 |
exit; |
| 10 |
} |
| 11 |
// reset |
| 12 |
$post_type = ''; |
| 13 |
$args = array( 'public' => TRUE, '_builtin' => FALSE ); |
| 14 |
foreach ( get_post_types( $args ) as $post_type ) { |
| 15 |
$post_type_object = get_post_type_object( $post_type ); |
| 16 |
?> |
| 17 |
|
| 18 |
<div id="poststuff" class="ui-sortable meta-box-sortables"> |
| 19 |
<div class="postbox"> |
| 20 |
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div> |
| 21 |
<h3 class="hndle" id="config_edit_<?php echo $post_type; ?>"> |
| 22 |
<?php esc_attr_e( 'Write options', 'adminimize' ); |
| 23 |
echo ' - ' . $post_type_object->label; ?> |
| 24 |
</h3> |
| 25 |
|
| 26 |
<div class="inside"> |
| 27 |
<br class="clear" /> |
| 28 |
|
| 29 |
<table summary="config_edit_post" class="widefat"> |
| 30 |
<thead> |
| 31 |
<tr> |
| 32 |
<th><?php esc_attr_e( 'Write options', 'adminimize' ); |
| 33 |
echo ' - ' . $post_type_object->label ?></th> |
| 34 |
<?php |
| 35 |
foreach ( $user_roles_names as $role_name ) { ?> |
| 36 |
<th><?php esc_attr_e( 'Deactivate for', 'adminimize' ); |
| 37 |
echo '<br/>' . $role_name; ?></th> |
| 38 |
<?php } ?> |
| 39 |
</tr> |
| 40 |
<tr> |
| 41 |
<td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td> |
| 42 |
<?php |
| 43 |
foreach ( $user_roles_names as $role_name ) { |
| 44 |
$role_name = strtolower( $role_name ); |
| 45 |
$role_name = preg_replace( '/[^a-z0-9]+/', '', $role_name ); |
| 46 |
echo '<td class="num">'; |
| 47 |
echo '<input id="select_all" class="write_cp_options_' . $role_name |
| 48 |
. '" type="checkbox" name="" value="" />'; |
| 49 |
echo '</td>' . "\n"; |
| 50 |
} ?> |
| 51 |
</tr> |
| 52 |
</thead> |
| 53 |
|
| 54 |
<tbody> |
| 55 |
<?php |
| 56 |
$metaboxes = array( |
| 57 |
'#contextual-help-link-wrap', |
| 58 |
'#screen-options-link-wrap', |
| 59 |
'#pageslugdiv', |
| 60 |
'#tagsdiv,#tagsdivsb,#tagsdiv-post_tag', |
| 61 |
'#formatdiv', |
| 62 |
'#categorydiv,#categorydivsb', |
| 63 |
'#category-add-toggle', |
| 64 |
'#passworddiv', |
| 65 |
'.side-info', |
| 66 |
'#notice', |
| 67 |
'#post-body h2', |
| 68 |
'#media-buttons, #wp-content-media-buttons', |
| 69 |
'#wp-word-count', |
| 70 |
'#slugdiv,#edit-slug-box', |
| 71 |
'#misc-publishing-actions', |
| 72 |
'#commentstatusdiv', |
| 73 |
'#editor-toolbar #edButtonHTML, #quicktags, #content-html', |
| 74 |
); |
| 75 |
|
| 76 |
foreach ( $GLOBALS[ '_wp_post_type_features' ][ $post_type ] as $post_type_support => $key ) { |
| 77 |
if ( post_type_supports( $post_type, $post_type_support ) ) { |
| 78 |
if ( 'excerpt' === $post_type_support ) { |
| 79 |
$post_type_support = 'postexcerpt'; |
| 80 |
} |
| 81 |
} |
| 82 |
if ( 'page-attributes' === $post_type_support ) { |
| 83 |
$post_type_support = 'pageparentdiv'; |
| 84 |
} |
| 85 |
if ( 'custom-fields' == $post_type_support ) { |
| 86 |
$post_type_support = 'postcustom'; |
| 87 |
} |
| 88 |
|
| 89 |
$metaboxes[] = '#' . $post_type_support |
| 90 |
. ', #' . $post_type_support |
| 91 |
. 'div, th.column-' . $post_type_support |
| 92 |
. ', td.' . $post_type_support; // td for raw in edit screen |
| 93 |
} |
| 94 |
if ( function_exists( 'current_theme_supports' ) |
| 95 |
&& current_theme_supports( |
| 96 |
'post-thumbnails', $post_type |
| 97 |
) |
| 98 |
) { |
| 99 |
$metaboxes[] = '#postimagediv'; |
| 100 |
} |
| 101 |
if ( function_exists( 'sticky_add_meta_box' ) ) { |
| 102 |
$metaboxes[] = '#poststickystatusdiv'; |
| 103 |
} |
| 104 |
|
| 105 |
// quick edit areas, id and class |
| 106 |
$quickedit_areas = array( |
| 107 |
'div.row-actions, div.row-actions .inline', |
| 108 |
'fieldset.inline-edit-col-left', |
| 109 |
'fieldset.inline-edit-col-left label', |
| 110 |
'fieldset.inline-edit-col-left label.inline-edit-author', |
| 111 |
'fieldset.inline-edit-col-left .inline-edit-group', |
| 112 |
'fieldset.inline-edit-col-center', |
| 113 |
'fieldset.inline-edit-col-center .inline-edit-categories-label', |
| 114 |
'fieldset.inline-edit-col-center .category-checklist', |
| 115 |
'fieldset.inline-edit-col-right', |
| 116 |
'fieldset.inline-edit-col-right .inline-edit-tags', |
| 117 |
'fieldset.inline-edit-col-right .inline-edit-group', |
| 118 |
'tr.inline-edit-save p.inline-edit-save', |
| 119 |
); |
| 120 |
$metaboxes = array_merge( $metaboxes, $quickedit_areas ); |
| 121 |
|
| 122 |
$metaboxes_names = array( |
| 123 |
esc_attr__( 'Help' ), |
| 124 |
esc_attr__( 'Screen Options' ), |
| 125 |
esc_attr__( 'Permalink', 'adminimize' ), |
| 126 |
esc_attr__( 'Tags', 'adminimize' ), |
| 127 |
esc_attr__( 'Format', 'adminimize' ), |
| 128 |
esc_attr__( 'Categories', 'adminimize' ), |
| 129 |
esc_attr__( 'Add New Category', 'adminimize' ), |
| 130 |
esc_attr__( 'Password Protect This Post', 'adminimize' ), |
| 131 |
esc_attr__( 'Related, Shortcuts', 'adminimize' ), |
| 132 |
esc_attr__( 'Messages', 'adminimize' ), |
| 133 |
esc_attr__( 'h2: Advanced Options', 'adminimize' ), |
| 134 |
esc_attr__( 'Media Buttons (all)', 'adminimize' ), |
| 135 |
esc_attr__( 'Word count', 'adminimize' ), |
| 136 |
esc_attr__( 'Post Slug', 'adminimize' ), |
| 137 |
esc_attr__( 'Publish Actions', 'adminimize' ), |
| 138 |
esc_attr__( 'Discussion' ), |
| 139 |
esc_attr__( 'HTML Editor Button' ), |
| 140 |
); |
| 141 |
|
| 142 |
foreach ( $GLOBALS[ '_wp_post_type_features' ][ $post_type ] as $post_type_support => $key ) { |
| 143 |
if ( post_type_supports( $post_type, $post_type_support ) ) { |
| 144 |
$metaboxes_names[] = ucfirst( $post_type_support ); |
| 145 |
} |
| 146 |
} |
| 147 |
if ( function_exists( 'current_theme_supports' ) |
| 148 |
&& current_theme_supports( |
| 149 |
'post-thumbnails', 'post' |
| 150 |
) |
| 151 |
) { |
| 152 |
$metaboxes_names[] = esc_attr__( 'Post Thumbnail', 'adminimize' ); |
| 153 |
} |
| 154 |
if ( function_exists( 'sticky_add_meta_box' ) ) { |
| 155 |
$metaboxes_names[] = 'Post Sticky Status'; |
| 156 |
} |
| 157 |
|
| 158 |
// quick edit names |
| 159 |
$quickedit_names = array( |
| 160 |
'<strong>' . esc_attr__( 'Quick Edit Link', 'adminimize' ) . '</strong>', |
| 161 |
esc_attr__( 'QE', 'adminimize' ) . ' ' . esc_attr__( 'Inline Edit Left', 'adminimize' ), |
| 162 |
' QE ⇒' . ' ' . esc_attr__( 'All Labels', 'adminimize' ), |
| 163 |
' QE ⇒' . ' ' . esc_attr__( 'Author' ), |
| 164 |
' QE ⇒' . ' ' . esc_attr__( 'Password and Private', 'adminimize' ), |
| 165 |
esc_attr__( 'QE', 'adminimize' ) . ' ' . esc_attr__( 'Inline Edit Center', 'adminimize' ), |
| 166 |
' QE ⇒' . ' ' . esc_attr__( 'Categories Title', 'adminimize' ), |
| 167 |
' QE ⇒' . ' ' . esc_attr__( 'Categories List', 'adminimize' ), |
| 168 |
esc_attr__( 'QE', 'adminimize' ) . ' ' . esc_attr__( 'Inline Edit Right', 'adminimize' ), |
| 169 |
' QE ⇒' . ' ' . esc_attr__( 'Tags' ), |
| 170 |
' QE ⇒' . ' ' . esc_attr__( 'Status, Sticky', 'adminimize' ), |
| 171 |
esc_attr__( 'QE', 'adminimize' ) . ' ' . esc_attr__( 'Cancel/Save Button', 'adminimize' ), |
| 172 |
); |
| 173 |
$metaboxes_names = array_merge( $metaboxes_names, $quickedit_names ); |
| 174 |
|
| 175 |
// add own post options |
| 176 |
$_mw_adminimize_own_values_[ $post_type ] = _mw_adminimize_get_option_value( |
| 177 |
'_mw_adminimize_own_values_' . $post_type |
| 178 |
); |
| 179 |
$_mw_adminimize_own_values_[ $post_type ] = preg_split( |
| 180 |
"/\r\n/", $_mw_adminimize_own_values_[ $post_type ] |
| 181 |
); |
| 182 |
foreach ( (array) $_mw_adminimize_own_values_[ $post_type ] as $key => $_mw_adminimize_own_value_[ $post_type ] ) { |
| 183 |
$_mw_adminimize_own_value_[ $post_type ] = trim( $_mw_adminimize_own_value_[ $post_type ] ); |
| 184 |
$metaboxes[] = $_mw_adminimize_own_value_[ $post_type ]; |
| 185 |
} |
| 186 |
|
| 187 |
$_mw_adminimize_own_options_[ $post_type ] = _mw_adminimize_get_option_value( |
| 188 |
'_mw_adminimize_own_options_' . $post_type |
| 189 |
); |
| 190 |
$_mw_adminimize_own_options_[ $post_type ] = preg_split( |
| 191 |
"/\r\n/", $_mw_adminimize_own_options_[ $post_type ] |
| 192 |
); |
| 193 |
foreach ( (array) $_mw_adminimize_own_options_[ $post_type ] as $key => $_mw_adminimize_own_option_[ $post_type ] ) { |
| 194 |
$_mw_adminimize_own_option_[ $post_type ] = trim( $_mw_adminimize_own_option_[ $post_type ] ); |
| 195 |
$metaboxes_names[] = $_mw_adminimize_own_option_[ $post_type ]; |
| 196 |
} |
| 197 |
|
| 198 |
$x = 0; |
| 199 |
foreach ( $metaboxes as $index => $metabox ) { |
| 200 |
if ( '' !== $metabox ) { |
| 201 |
$checked_user_role_ = array(); |
| 202 |
foreach ( $user_roles as $role ) { |
| 203 |
$disabled_metaboxes_[ $post_type . '_' . $role ] = _mw_adminimize_get_option_value( |
| 204 |
'mw_adminimize_disabled_metaboxes_' . $post_type . '_' . $role . '_items' |
| 205 |
); |
| 206 |
$checked_user_role_[ $post_type . '_' . $role ] = ( |
| 207 |
isset( $disabled_metaboxes_[ $post_type . '_' . $role ] ) |
| 208 |
&& in_array( |
| 209 |
$metabox, $disabled_metaboxes_[ $post_type . '_' . $role ] |
| 210 |
) |
| 211 |
) ? ' checked="checked"' : ''; |
| 212 |
} |
| 213 |
echo '<tr>' . "\n"; |
| 214 |
echo '<td>' . $metaboxes_names[ $index ] . |
| 215 |
' <span>(' . $metabox . ')</span> </td>' . "\n"; |
| 216 |
foreach ( $user_roles as $role ) { |
| 217 |
echo '<td class="num">'; |
| 218 |
echo '<input id="check_' . |
| 219 |
$post_type . $role . $x . '" class="write_cp_options_' |
| 220 |
. preg_replace( '/[^a-z0-9]+/', '', $role ) . '" type="checkbox"' . |
| 221 |
$checked_user_role_[ $post_type . '_' . $role ] . |
| 222 |
' name="mw_adminimize_disabled_metaboxes_' . $post_type . |
| 223 |
'_' . $role . '_items[]" value="' . $metabox . '" />'; |
| 224 |
echo '</td>' . "\n"; |
| 225 |
} |
| 226 |
echo '</tr>' . "\n"; |
| 227 |
$x ++; |
| 228 |
} |
| 229 |
} |
| 230 |
?> |
| 231 |
</tbody> |
| 232 |
</table> |
| 233 |
|
| 234 |
<?php |
| 235 |
//your own post options |
| 236 |
?> |
| 237 |
<br style="margin-top: 10px;" /> |
| 238 |
<table summary="config_own_post" class="widefat"> |
| 239 |
<thead> |
| 240 |
<tr> |
| 241 |
<th> |
| 242 |
<?php echo sprintf( |
| 243 |
esc_attr__( 'Your own %s options', 'adminimize' ), $post_type_object->label |
| 244 |
); |
| 245 |
echo '<br />'; |
| 246 |
esc_attr_e( 'ID or class', 'adminimize' ); ?> |
| 247 |
</th> |
| 248 |
<th><?php echo '<br />'; |
| 249 |
esc_attr_e( 'Option', 'adminimize' ); ?></th> |
| 250 |
</tr> |
| 251 |
</thead> |
| 252 |
|
| 253 |
<tbody> |
| 254 |
<tr valign="top"> |
| 255 |
<td colspan="2"> |
| 256 |
<?php esc_attr_e( |
| 257 |
'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.', |
| 258 |
'adminimize' |
| 259 |
); ?> |
| 260 |
</td> |
| 261 |
</tr> |
| 262 |
<tr valign="top"> |
| 263 |
<td> |
| 264 |
<textarea name="_mw_adminimize_own_options_<?php echo $post_type; ?>" |
| 265 |
cols="60" rows="3" |
| 266 |
id="_mw_adminimize_own_options_<?php echo $post_type; ?>" |
| 267 |
style="width: 95%;"><?php echo _mw_adminimize_get_option_value( |
| 268 |
'_mw_adminimize_own_options_' . $post_type |
| 269 |
); ?></textarea> |
| 270 |
<br /> |
| 271 |
<?php esc_attr_e( |
| 272 |
'Possible nomination for ID or class. Separate multiple nominations through a carriage return.', |
| 273 |
'adminimize' |
| 274 |
); ?> |
| 275 |
</td> |
| 276 |
<td> |
| 277 |
<textarea class="code" name="_mw_adminimize_own_values_<?php echo $post_type; ?>" |
| 278 |
cols="60" rows="3" |
| 279 |
id="_mw_adminimize_own_values_<?php echo $post_type; ?>" |
| 280 |
style="width: 95%;"><?php echo _mw_adminimize_get_option_value( |
| 281 |
'_mw_adminimize_own_values_' . $post_type |
| 282 |
); ?></textarea> |
| 283 |
<br /> |
| 284 |
<?php esc_attr_e( |
| 285 |
'Possible IDs or classes. Separate multiple values through a carriage return.', |
| 286 |
'adminimize' |
| 287 |
); ?> |
| 288 |
</td> |
| 289 |
</tr> |
| 290 |
</tbody> |
| 291 |
</table> |
| 292 |
|
| 293 |
<p id="submitbutton"> |
| 294 |
<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" /> |
| 295 |
<input class="button button-primary" type="submit" |
| 296 |
name="_mw_adminimize_save" |
| 297 |
value="<?php esc_attr_e( 'Update Options', 'adminimize' ); ?> »" /> |
| 298 |
<input type="hidden" name="page_options" value="'dofollow_timeout'" /> |
| 299 |
</p> |
| 300 |
|
| 301 |
<p><a class="alignright button" href="javascript:void(0);" |
| 302 |
onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"> |
| 303 |
<?php esc_attr_e( 'scroll to top', 'adminimize' ); ?></a> |
| 304 |
<br class="clear" /> |
| 305 |
</p> |
| 306 |
|
| 307 |
</div> |
| 308 |
</div> |
| 309 |
</div> |
| 310 |
|
| 311 |
<?php } // end foreach ?> |