PageRenderTime 23ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/plugins/adminimize/inc-options/write_cp_options.php

https://bitbucket.org/codemen_iftekhar/codemen
PHP | 256 lines | 234 code | 13 blank | 9 comment | 17 complexity | 1ddac333b409231c86be8d0d42d0524a MD5 | raw file
  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. <div id="poststuff" class="ui-sortable meta-box-sortables">
  18. <div class="postbox">
  19. <div class="handlediv" title="<?php _e('Click to toggle'); ?>"><br/></div>
  20. <h3 class="hndle" id="config_edit_<?php echo $post_type; ?>">
  21. <?php _e('Write options', FB_ADMINIMIZE_TEXTDOMAIN ); echo ' - ' . $post_type_object->label; ?>
  22. </h3>
  23. <div class="inside">
  24. <br class="clear" />
  25. <table summary="config_edit_post" class="widefat">
  26. <thead>
  27. <tr>
  28. <th><?php _e('Write options', FB_ADMINIMIZE_TEXTDOMAIN ); echo ' - ' . $post_type_object->label ?></th>
  29. <?php
  30. foreach ( $user_roles_names as $role_name ) { ?>
  31. <th><?php _e('Deactivate for', FB_ADMINIMIZE_TEXTDOMAIN ); echo '<br/>' . $role_name; ?></th>
  32. <?php } ?>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <?php
  37. $metaboxes = array(
  38. '#contextual-help-link-wrap',
  39. '#screen-options-link-wrap',
  40. '#pageslugdiv',
  41. '#tagsdiv,#tagsdivsb,#tagsdiv-post_tag',
  42. '#formatdiv',
  43. '#categorydiv,#categorydivsb',
  44. '#category-add-toggle',
  45. '#passworddiv',
  46. '.side-info',
  47. '#notice',
  48. '#post-body h2',
  49. '#media-buttons, #wp-content-media-buttons',
  50. '#wp-word-count',
  51. '#slugdiv,#edit-slug-box',
  52. '#misc-publishing-actions',
  53. '#commentstatusdiv',
  54. '#editor-toolbar #edButtonHTML, #quicktags, #content-html'
  55. );
  56. foreach ( $GLOBALS['_wp_post_type_features'][$post_type] as $post_type_support => $key ) {
  57. if ( post_type_supports( $post_type, $post_type_support ) )
  58. if ( 'excerpt' === $post_type_support )
  59. $post_type_support = 'postexcerpt';
  60. if ( 'page-attributes' === $post_type_support )
  61. $post_type_support = 'pageparentdiv';
  62. if ( 'custom-fields' == $post_type_support )
  63. $post_type_support = 'postcustom';
  64. array_push(
  65. $metaboxes,
  66. '#' . $post_type_support . ', #' . $post_type_support . 'div, th.column-' . $post_type_support . ', td.' . $post_type_support
  67. ); // td for raw in edit screen
  68. }
  69. if ( function_exists('current_theme_supports') &&
  70. current_theme_supports( 'post-thumbnails', $post_type )
  71. )
  72. array_push($metaboxes, '#postimagediv');
  73. if (function_exists('sticky_add_meta_box'))
  74. array_push($metaboxes, '#poststickystatusdiv');
  75. // quick edit areas, id and class
  76. $quickedit_areas = array(
  77. 'div.row-actions, div.row-actions .inline',
  78. 'fieldset.inline-edit-col-left',
  79. 'fieldset.inline-edit-col-left label',
  80. 'fieldset.inline-edit-col-left label.inline-edit-author',
  81. 'fieldset.inline-edit-col-left .inline-edit-group',
  82. 'fieldset.inline-edit-col-center',
  83. 'fieldset.inline-edit-col-center .inline-edit-categories-label',
  84. 'fieldset.inline-edit-col-center .category-checklist',
  85. 'fieldset.inline-edit-col-right',
  86. 'fieldset.inline-edit-col-right .inline-edit-tags',
  87. 'fieldset.inline-edit-col-right .inline-edit-group',
  88. 'tr.inline-edit-save p.inline-edit-save'
  89. );
  90. $metaboxes = array_merge( $metaboxes, $quickedit_areas );
  91. $metaboxes_names = array(
  92. __('Help'),
  93. __('Screen Options'),
  94. __('Permalink', FB_ADMINIMIZE_TEXTDOMAIN ),
  95. __('Tags', FB_ADMINIMIZE_TEXTDOMAIN ),
  96. __('Format', FB_ADMINIMIZE_TEXTDOMAIN),
  97. __('Categories', FB_ADMINIMIZE_TEXTDOMAIN ),
  98. __('Add New Category', FB_ADMINIMIZE_TEXTDOMAIN ),
  99. __('Password Protect This Post', FB_ADMINIMIZE_TEXTDOMAIN ),
  100. __('Related, Shortcuts', FB_ADMINIMIZE_TEXTDOMAIN ),
  101. __('Messages', FB_ADMINIMIZE_TEXTDOMAIN ),
  102. __('h2: Advanced Options', FB_ADMINIMIZE_TEXTDOMAIN ),
  103. __('Media Buttons (all)', FB_ADMINIMIZE_TEXTDOMAIN ),
  104. __('Word count', FB_ADMINIMIZE_TEXTDOMAIN ),
  105. __('Post Slug', FB_ADMINIMIZE_TEXTDOMAIN),
  106. __('Publish Actions', FB_ADMINIMIZE_TEXTDOMAIN ),
  107. __('Discussion'),
  108. __('HTML Editor Button')
  109. );
  110. foreach ( $GLOBALS['_wp_post_type_features'][$post_type] as $post_type_support => $key ) {
  111. if ( post_type_supports( $post_type, $post_type_support ) )
  112. array_push( $metaboxes_names, ucfirst($post_type_support) );
  113. }
  114. if ( function_exists('current_theme_supports') &&
  115. current_theme_supports( 'post-thumbnails', 'post' )
  116. )
  117. array_push($metaboxes_names, __('Post Thumbnail', FB_ADMINIMIZE_TEXTDOMAIN) );
  118. if (function_exists('sticky_add_meta_box'))
  119. array_push($metaboxes_names, 'Post Sticky Status');
  120. // quick edit names
  121. $quickedit_names = array(
  122. '<strong>' .__('Quick Edit Link', FB_ADMINIMIZE_TEXTDOMAIN) . '</strong>',
  123. __('QE', FB_ADMINIMIZE_TEXTDOMAIN) . ' ' . __('Inline Edit Left', FB_ADMINIMIZE_TEXTDOMAIN),
  124. '&emsp;QE &rArr;' . ' ' . __('All Labels', FB_ADMINIMIZE_TEXTDOMAIN),
  125. '&emsp;QE &rArr;' . ' ' . __('Author'),
  126. '&emsp;QE &rArr;' . ' ' . __('Password and Private', FB_ADMINIMIZE_TEXTDOMAIN),
  127. __('QE', FB_ADMINIMIZE_TEXTDOMAIN) . ' ' . __('Inline Edit Center', FB_ADMINIMIZE_TEXTDOMAIN),
  128. '&emsp;QE &rArr;' . ' ' . __('Categories Title', FB_ADMINIMIZE_TEXTDOMAIN),
  129. '&emsp;QE &rArr;' . ' ' . __('Categories List', FB_ADMINIMIZE_TEXTDOMAIN),
  130. __('QE', FB_ADMINIMIZE_TEXTDOMAIN) . ' ' . __('Inline Edit Right', FB_ADMINIMIZE_TEXTDOMAIN),
  131. '&emsp;QE &rArr;' . ' ' . __('Tags'),
  132. '&emsp;QE &rArr;' . ' ' . __('Status, Sticky', FB_ADMINIMIZE_TEXTDOMAIN),
  133. __('QE', FB_ADMINIMIZE_TEXTDOMAIN) . ' ' . __('Cancel/Save Button', FB_ADMINIMIZE_TEXTDOMAIN)
  134. );
  135. $metaboxes_names = array_merge($metaboxes_names, $quickedit_names);
  136. // add own post options
  137. $_mw_adminimize_own_values_[$post_type] = _mw_adminimize_get_option_value(
  138. '_mw_adminimize_own_values_' . $post_type
  139. );
  140. $_mw_adminimize_own_values_[$post_type] = preg_split( "/\r\n/", $_mw_adminimize_own_values_[$post_type] );
  141. foreach ( (array) $_mw_adminimize_own_values_[$post_type] as $key => $_mw_adminimize_own_value_[$post_type] ) {
  142. $_mw_adminimize_own_value_[$post_type] = trim( $_mw_adminimize_own_value_[$post_type] );
  143. array_push( $metaboxes, $_mw_adminimize_own_value_[$post_type] );
  144. }
  145. $_mw_adminimize_own_options_[$post_type] = _mw_adminimize_get_option_value(
  146. '_mw_adminimize_own_options_' . $post_type
  147. );
  148. $_mw_adminimize_own_options_[$post_type] = preg_split( "/\r\n/", $_mw_adminimize_own_options_[$post_type] );
  149. foreach ( (array) $_mw_adminimize_own_options_[$post_type] as $key => $_mw_adminimize_own_option_[$post_type] ) {
  150. $_mw_adminimize_own_option_[$post_type] = trim( $_mw_adminimize_own_option_[$post_type] );
  151. array_push( $metaboxes_names, $_mw_adminimize_own_option_[$post_type] );
  152. }
  153. $x = 0;
  154. $class = '';
  155. foreach ($metaboxes as $index => $metabox) {
  156. if ( '' != $metabox ) {
  157. $class = ( ' class="alternate"' == $class ) ? '' : ' class="alternate"';
  158. $checked_user_role_ = array();
  159. foreach ($user_roles as $role) {
  160. $disabled_metaboxes_[$post_type . '_' . $role] = _mw_adminimize_get_option_value(
  161. 'mw_adminimize_disabled_metaboxes_' . $post_type . '_' . $role . '_items'
  162. );
  163. $checked_user_role_[$post_type . '_' . $role] = (
  164. isset($disabled_metaboxes_[$post_type . '_' . $role]) &&
  165. in_array($metabox, $disabled_metaboxes_[$post_type . '_' . $role])
  166. ) ? ' checked="checked"' : '';
  167. }
  168. echo '<tr' . $class . '>' . "\n";
  169. echo '<td>' . $metaboxes_names[$index] .
  170. ' <span style="color:#ccc; font-weight: 400;">(' . $metabox . ')</span> </td>' . "\n";
  171. foreach ($user_roles as $role) {
  172. echo '<td class="num"><input id="check_' .
  173. $post_type . $role . $x .'" type="checkbox"' .
  174. $checked_user_role_[$post_type . '_' . $role] .
  175. ' name="mw_adminimize_disabled_metaboxes_' . $post_type .
  176. '_'. $role .'_items[]" value="' . $metabox . '" /></td>' . "\n";
  177. }
  178. echo '</tr>' . "\n";
  179. $x ++;
  180. }
  181. }
  182. ?>
  183. </tbody>
  184. </table>
  185. <?php
  186. //your own post options
  187. ?>
  188. <br style="margin-top: 10px;" />
  189. <table summary="config_own_post" class="widefat">
  190. <thead>
  191. <tr>
  192. <th>
  193. <?php echo sprintf( __('Your own %s options', FB_ADMINIMIZE_TEXTDOMAIN ), $post_type_object->label );
  194. echo '<br />'; _e('ID or class', FB_ADMINIMIZE_TEXTDOMAIN ); ?>
  195. </th>
  196. <th><?php echo '<br />'; _e('Option', FB_ADMINIMIZE_TEXTDOMAIN ); ?></th>
  197. </tr>
  198. </thead>
  199. <tbody>
  200. <tr valign="top">
  201. <td colspan="2">
  202. <?php _e('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.', FB_ADMINIMIZE_TEXTDOMAIN ); ?>
  203. </td>
  204. </tr>
  205. <tr valign="top">
  206. <td>
  207. <textarea name="_mw_adminimize_own_options_<?php echo $post_type; ?>"
  208. cols="60" rows="3"
  209. id="_mw_adminimize_own_options_<?php echo $post_type; ?>"
  210. style="width: 95%;" ><?php echo _mw_adminimize_get_option_value('_mw_adminimize_own_options_' . $post_type ); ?></textarea>
  211. <br />
  212. <?php _e('Possible nomination for ID or class. Separate multiple nominations through a carriage return.', FB_ADMINIMIZE_TEXTDOMAIN ); ?>
  213. </td>
  214. <td>
  215. <textarea class="code" name="_mw_adminimize_own_values_<?php echo $post_type; ?>"
  216. cols="60" rows="3"
  217. id="_mw_adminimize_own_values_<?php echo $post_type; ?>"
  218. style="width: 95%;" ><?php echo _mw_adminimize_get_option_value('_mw_adminimize_own_values_' . $post_type ); ?></textarea>
  219. <br />
  220. <?php _e('Possible IDs or classes. Separate multiple values through a carriage return.', FB_ADMINIMIZE_TEXTDOMAIN ); ?>
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. <p id="submitbutton">
  226. <input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" />
  227. <input class="button button-primary" type="submit"
  228. name="_mw_adminimize_save"
  229. value="<?php _e('Update Options', FB_ADMINIMIZE_TEXTDOMAIN ); ?> &raquo;" />
  230. <input type="hidden" name="page_options" value="'dofollow_timeout'" />
  231. </p>
  232. <p><a class="alignright button" href="javascript:void(0);"
  233. onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;">
  234. <?php _e('scroll to top', FB_ADMINIMIZE_TEXTDOMAIN); ?></a>
  235. <br class="clear" />
  236. </p>
  237. </div>
  238. </div>
  239. </div>
  240. <?php } // end foreach ?>