PageRenderTime 54ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/classes/PodsAdmin.php

https://github.com/BenjaminNolan/pods
PHP | 1990 lines | 1514 code | 329 blank | 147 comment | 338 complexity | 0982143b11e8987be15c74db666303e0 MD5 | raw file
Possible License(s): Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @package Pods
  4. */
  5. class PodsAdmin {
  6. /**
  7. * @var PodsAPI
  8. */
  9. private $api;
  10. /**
  11. * @var PodsData
  12. */
  13. private $data;
  14. /**
  15. * Setup and Handle Admin functionality
  16. *
  17. * @return \PodsAdmin
  18. *
  19. * @license http://www.gnu.org/licenses/gpl-2.0.html
  20. * @since 2.0
  21. */
  22. public function __construct () {
  23. $this->api = pods_api();
  24. $this->data = pods_data();
  25. // Scripts / Stylesheets
  26. add_action( 'admin_enqueue_scripts', array( $this, 'admin_head' ) );
  27. // AJAX $_POST fix
  28. add_action( 'admin_init', array( $this, 'admin_init' ), 9 );
  29. // Menus
  30. add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 );
  31. // AJAX for Admin
  32. add_action( 'wp_ajax_pods_admin', array( $this, 'admin_ajax' ) );
  33. add_action( 'wp_ajax_nopriv_pods_admin', array( $this, 'admin_ajax' ) );
  34. // Add Media Bar button for Shortcode
  35. add_action( 'media_buttons', array( $this, 'media_button' ), 12 );
  36. // Add the Pods capabilities
  37. add_filter( 'members_get_capabilities', array( $this, 'admin_capabilities' ) );
  38. add_action( 'admin_head-media-upload-popup', array( $this, 'register_media_assets' ) );
  39. }
  40. /**
  41. * Init the admin area
  42. *
  43. * @since 2.0
  44. */
  45. public function admin_init () {
  46. // Fix for plugins that *don't do it right* so we don't cause issues for users
  47. if ( defined( 'DOING_AJAX' ) && !empty( $_POST ) && ( in_array( pods_var( 'action', 'get' ), array( 'pods_admin', 'pods_relationship', 'pods_upload', 'pods_admin_components' ) ) || in_array( pods_var( 'action', 'post' ), array( 'pods_admin', 'pods_relationship', 'pods_upload', 'pods_admin_components' ) ) ) ) {
  48. foreach ( $_POST as $key => $value ) {
  49. if ( 'action' == $key )
  50. continue;
  51. unset( $_POST[ $key ] );
  52. $_POST[ '_podsfix_' . $key ] = $value;
  53. }
  54. }
  55. }
  56. /**
  57. * Attach requirements to admin header
  58. *
  59. * @since 2.0
  60. */
  61. public function admin_head () {
  62. wp_register_style( 'pods-admin', PODS_URL . 'ui/css/pods-admin.css', array(), PODS_VERSION );
  63. wp_register_script( 'pods-floatmenu', PODS_URL . 'ui/js/floatmenu.js', array(), PODS_VERSION );
  64. wp_register_script( 'pods-admin-importer', PODS_URL . 'ui/js/admin-importer.js', array(), PODS_VERSION );
  65. wp_register_style( 'pods-manage', PODS_URL . 'ui/css/pods-manage.css', array(), PODS_VERSION );
  66. wp_register_style( 'pods-wizard', PODS_URL . 'ui/css/pods-wizard.css', array(), PODS_VERSION );
  67. wp_register_script( 'pods-upgrade', PODS_URL . 'ui/js/jquery.pods.upgrade.js', array(), PODS_VERSION );
  68. if ( isset( $_GET[ 'page' ] ) ) {
  69. $page = $_GET[ 'page' ];
  70. if ( 'pods' == $page || ( false !== strpos( $page, 'pods-' ) && 0 === strpos( $page, 'pods-' ) ) ) {
  71. ?>
  72. <script type="text/javascript">
  73. var PODS_URL = "<?php echo PODS_URL; ?>";
  74. </script>
  75. <?php
  76. wp_enqueue_script( 'jquery' );
  77. wp_enqueue_script( 'jquery-ui-core' );
  78. wp_enqueue_script( 'jquery-ui-sortable' );
  79. wp_enqueue_style( 'jquery-ui' );
  80. wp_enqueue_script( 'pods-floatmenu' );
  81. wp_enqueue_style( 'pods-qtip' );
  82. wp_enqueue_script( 'jquery-qtip' );
  83. wp_enqueue_script( 'pods-qtip-init' );
  84. wp_enqueue_script( 'pods' );
  85. if ( 0 === strpos( $page, 'pods-manage-' ) || 0 === strpos( $page, 'pods-add-new-' ) )
  86. wp_enqueue_script( 'post' );
  87. elseif ( 0 === strpos( $page, 'pods-settings-' ) ) {
  88. wp_enqueue_script( 'post' );
  89. wp_enqueue_style( 'pods-admin' );
  90. }
  91. else
  92. wp_enqueue_style( 'pods-admin' );
  93. if ( 'pods-advanced' == $page ) {
  94. wp_register_style( 'pods-advanced', PODS_URL . 'ui/css/pods-advanced.css', array(), '1.0' );
  95. wp_enqueue_style( 'pods-advanced' );
  96. wp_enqueue_script( 'jquery-ui-effects-core', PODS_URL . 'ui/js/jquery-ui/jquery.effects.core.js', array( 'jquery' ), '1.8.8' );
  97. wp_enqueue_script( 'jquery-ui-effects-fade', PODS_URL . 'ui/js/jquery-ui/jquery.effects.fade.js', array( 'jquery' ), '1.8.8' );
  98. wp_enqueue_script( 'jquery-ui-dialog' );
  99. wp_register_script( 'pods-advanced', PODS_URL . 'ui/js/advanced.js', array(), PODS_VERSION );
  100. wp_enqueue_script( 'pods-advanced' );
  101. }
  102. elseif ( 'pods-packages' == $page )
  103. wp_enqueue_style( 'pods-wizard' );
  104. elseif ( 'pods-wizard' == $page || 'pods-upgrade' == $page || ( in_array( $page, array( 'pods', 'pods-add-new' ) ) && in_array( pods_var( 'action', 'get', 'manage' ), array( 'add', 'manage' ) ) ) ) {
  105. wp_enqueue_style( 'pods-wizard' );
  106. if ( 'pods-upgrade' == $page )
  107. wp_enqueue_script( 'pods-upgrade' );
  108. }
  109. }
  110. }
  111. }
  112. /**
  113. * Buld the admin menus
  114. *
  115. * @since 2.0
  116. */
  117. public function admin_menu () {
  118. $advanced_content_types = PodsMeta::$advanced_content_types;
  119. $taxonomies = PodsMeta::$taxonomies;
  120. $settings = PodsMeta::$settings;
  121. $all_pods = $this->api->load_pods( array( 'count' => true ) );
  122. if ( !PodsInit::$upgrade_needed || ( ( is_super_admin() || current_user_can( 'delete_users' ) ) && 1 == pods_var( 'pods_upgrade_bypass' ) ) ) {
  123. if ( !empty( $advanced_content_types ) ) {
  124. $submenu = array();
  125. $pods_pages = 0;
  126. foreach ( (array) $advanced_content_types as $pod ) {
  127. if ( !isset( $pod[ 'name' ] ) || !isset( $pod[ 'options' ] ) || empty( $pod[ 'fields' ] ) )
  128. continue;
  129. elseif ( !is_super_admin() && !current_user_can( 'delete_users' ) && !current_user_can( 'pods' ) && !current_user_can( 'pods_content' ) && !current_user_can( 'pods_add_' . $pod[ 'name' ] ) && !current_user_can( 'pods_edit_' . $pod[ 'name' ] ) && !current_user_can( 'pods_delete_' . $pod[ 'name' ] ) )
  130. continue;
  131. if ( 1 == pods_var( 'show_in_menu', $pod[ 'options' ], 0 ) ) {
  132. $page_title = pods_var_raw( 'label', $pod, ucwords( str_replace( '_', ' ', $pod[ 'name' ] ) ), null, true );
  133. $page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod );
  134. $menu_label = pods_var_raw( 'menu_name', $pod[ 'options' ], $page_title, null, true );
  135. $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
  136. $singular_label = pods_var_raw( 'label_singular', $pod[ 'options' ], pods_var_raw( 'label', $pod, ucwords( str_replace( '_', ' ', $pod[ 'name' ] ) ), null, true ), null, true );
  137. $plural_label = pods_var_raw( 'label', $pod, ucwords( str_replace( '_', ' ', $pod[ 'name' ] ) ), null, true );
  138. $menu_location = pods_var( 'menu_location', $pod[ 'options' ], 'objects' );
  139. $menu_location_custom = pods_var( 'menu_location_custom', $pod[ 'options' ], '' );
  140. $menu_position = pods_var_raw( 'menu_position', $pod[ 'options' ], '', null, true );
  141. $menu_icon = pods_evaluate_tags( pods_var_raw( 'menu_icon', $pod[ 'options' ], '', null, true ), true );
  142. if ( empty( $menu_position ) )
  143. $menu_position = null;
  144. $parent_page = null;
  145. if ( is_super_admin() || current_user_can( 'delete_users' ) || current_user_can( 'pods' ) || current_user_can( 'pods_content' ) || current_user_can( 'pods_edit_' . $pod[ 'name' ] ) || current_user_can( 'pods_delete_' . $pod[ 'name' ] ) ) {
  146. if ( !empty( $menu_location_custom ) ) {
  147. add_submenu_page( $menu_location_custom, $page_title, $menu_label, 'read', 'pods-manage-' . $pod[ 'name' ], array( $this, 'admin_content' ) );
  148. continue;
  149. }
  150. else {
  151. $pods_pages++;
  152. $parent_page = $page = 'pods-manage-' . $pod[ 'name' ];
  153. if ( empty( $menu_position ) )
  154. add_object_page( $page_title, $menu_label, 'read', $parent_page, '', $menu_icon );
  155. else
  156. add_menu_page( $page_title, $menu_label, 'read', $parent_page, '', $menu_icon, $menu_position );
  157. $all_title = $plural_label;
  158. $all_label = __( 'All', 'pods' ) . ' ' . $plural_label;
  159. if ( $page == pods_var( 'page', 'get' ) ) {
  160. if ( 'edit' == pods_var( 'action', 'get', 'manage' ) )
  161. $all_title = __( 'Edit', 'pods' ) . ' ' . $singular_label;
  162. elseif ( 'add' == pods_var( 'action', 'get', 'manage' ) )
  163. $all_title = __( 'Add New', 'pods' ) . ' ' . $singular_label;
  164. }
  165. add_submenu_page( $parent_page, $all_title, $all_label, 'read', $page, array( $this, 'admin_content' ) );
  166. }
  167. }
  168. if ( is_super_admin() || current_user_can( 'delete_users' ) || current_user_can( 'pods' ) || current_user_can( 'pods_content' ) || current_user_can( 'pods_add_' . $pod[ 'name' ] ) ) {
  169. $page = 'pods-add-new-' . $pod[ 'name' ];
  170. if ( null === $parent_page ) {
  171. $pods_pages++;
  172. $parent_page = $page;
  173. if ( empty( $menu_position ) )
  174. add_object_page( $page_title, $menu_label, 'read', $parent_page, '', $menu_icon );
  175. else
  176. add_menu_page( $page_title, $menu_label, 'read', $parent_page, '', $menu_icon, $menu_position );
  177. }
  178. $add_title = __( 'Add New', 'pods' ) . ' ' . $singular_label;
  179. $add_label = __( 'Add New', 'pods' );
  180. add_submenu_page( $parent_page, $add_title, $add_label, 'read', $page, array( $this, 'admin_content' ) );
  181. }
  182. }
  183. else
  184. $submenu[] = $pod;
  185. }
  186. $submenu = apply_filters( 'pods_admin_menu_secondary_content', $submenu );
  187. if ( !empty( $submenu ) && ( !defined( 'PODS_DISABLE_CONTENT_MENU' ) || !PODS_DISABLE_CONTENT_MENU ) ) {
  188. $parent_page = null;
  189. foreach ( $submenu as $item ) {
  190. $singular_label = pods_var_raw( 'label_singular', $item[ 'options' ], pods_var_raw( 'label', $item, ucwords( str_replace( '_', ' ', $item[ 'name' ] ) ), null, true ), null, true );
  191. $plural_label = pods_var_raw( 'label', $item, ucwords( str_replace( '_', ' ', $item[ 'name' ] ) ), null, true );
  192. if ( is_super_admin() || current_user_can( 'delete_users' ) || current_user_can( 'pods' ) || current_user_can( 'pods_content' ) || current_user_can( 'pods_edit_' . $item[ 'name' ] ) || current_user_can( 'pods_delete_' . $item[ 'name' ] ) ) {
  193. $page = 'pods-manage-' . $item[ 'name' ];
  194. if ( null === $parent_page ) {
  195. $parent_page = $page;
  196. add_menu_page( 'Pods', 'Pods', 'read', $parent_page, null, PODS_URL . 'ui/images/icon16.png', '58.5' );
  197. }
  198. $all_title = $plural_label;
  199. $all_label = __( 'Manage', 'pods' ) . ' ' . $plural_label;
  200. if ( $page == pods_var( 'page', 'get' ) ) {
  201. if ( 'edit' == pods_var( 'action', 'get', 'manage' ) )
  202. $all_title = __( 'Edit', 'pods' ) . ' ' . $singular_label;
  203. elseif ( 'add' == pods_var( 'action', 'get', 'manage' ) )
  204. $all_title = __( 'Add New', 'pods' ) . ' ' . $singular_label;
  205. }
  206. add_submenu_page( $parent_page, $all_title, $all_label, 'read', $page, array( $this, 'admin_content' ) );
  207. }
  208. elseif ( current_user_can( 'pods_add_' . $item[ 'name' ] ) ) {
  209. $page = 'pods-add-new-' . $item[ 'name' ];
  210. if ( null === $parent_page ) {
  211. $parent_page = $page;
  212. add_menu_page( 'Pods', 'Pods', 'read', $parent_page, null, PODS_URL . 'ui/images/icon16.png', '58.5' );
  213. }
  214. $add_title = __( 'Add New', 'pods' ) . ' ' . $singular_label;
  215. $add_label = __( 'Manage', 'pods' ) . ' ' . $plural_label;
  216. add_submenu_page( $parent_page, $add_title, $add_label, 'read', $page, array( $this, 'admin_content' ) );
  217. }
  218. }
  219. }
  220. }
  221. $submenu_items = array();
  222. if ( !empty( $taxonomies ) ) {
  223. foreach ( (array) $taxonomies as $pod ) {
  224. if ( !is_super_admin() && !current_user_can( 'delete_users' ) && !current_user_can( 'pods' ) && !current_user_can( 'pods_content' ) && !current_user_can( 'pods_edit_' . $pod[ 'name' ] ) )
  225. continue;
  226. $page_title = pods_var_raw( 'label', $pod, ucwords( str_replace( '_', ' ', $pod[ 'name' ] ) ), null, true );
  227. $page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod );
  228. $menu_label = pods_var_raw( 'menu_name', $pod[ 'options' ], $page_title, null, true );
  229. $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
  230. $menu_position = pods_var_raw( 'menu_position', $pod[ 'options' ], '', null, true );
  231. $menu_icon = pods_evaluate_tags( pods_var_raw( 'menu_icon', $pod[ 'options' ], '', null, true ), true );
  232. if ( empty( $menu_position ) )
  233. $menu_position = null;
  234. $menu_slug = 'edit-tags.php?taxonomy=' . $pod[ 'name' ];
  235. $menu_location = pods_var( 'menu_location', $pod[ 'options' ], 'default' );
  236. $menu_location_custom = pods_var( 'menu_location_custom', $pod[ 'options' ], '' );
  237. if ( 'default' == $menu_location )
  238. continue;
  239. $taxonomy_data = get_taxonomy( $pod[ 'name' ] );
  240. foreach ( (array) $taxonomy_data->object_type as $post_type ) {
  241. if ( 'post' == $post_type )
  242. remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . $pod[ 'name' ] );
  243. elseif ( 'attachment' == $post_type )
  244. remove_submenu_page( 'upload.php', 'edit-tags.php?taxonomy=' . $pod[ 'name' ] . '&amp;post_type=' . $post_type );
  245. else
  246. remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . $pod[ 'name' ] . '&amp;post_type=' . $post_type );
  247. }
  248. if ( 'settings' == $menu_location )
  249. add_options_page( $page_title, $menu_label, 'read', $menu_slug );
  250. elseif ( 'appearances' == $menu_location )
  251. add_theme_page( $page_title, $menu_label, 'read', $menu_slug );
  252. elseif ( 'objects' == $menu_location ) {
  253. if ( empty( $menu_position ) )
  254. add_object_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon );
  255. else
  256. add_menu_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon, $menu_position );
  257. }
  258. elseif ( 'top' == $menu_location )
  259. add_menu_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon, $menu_position );
  260. elseif ( 'submenu' == $menu_location && !empty( $menu_location_custom ) )
  261. $submenu_items[ $menu_location_custom ] = array( $menu_location_custom, $page_title, $menu_label, 'read', $menu_slug, '' );
  262. }
  263. }
  264. if ( !empty( $settings ) ) {
  265. foreach ( (array) $settings as $pod ) {
  266. if ( !is_super_admin() && !current_user_can( 'delete_users' ) && !current_user_can( 'pods' ) && !current_user_can( 'pods_content' ) && !current_user_can( 'pods_edit_' . $pod[ 'name' ] ) )
  267. continue;
  268. $page_title = pods_var_raw( 'label', $pod, ucwords( str_replace( '_', ' ', $pod[ 'name' ] ) ), null, true );
  269. $page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod );
  270. $menu_label = pods_var_raw( 'menu_name', $pod[ 'options' ], $page_title, null, true );
  271. $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
  272. $menu_position = pods_var_raw( 'menu_position', $pod[ 'options' ], '', null, true );
  273. $menu_icon = pods_evaluate_tags( pods_var_raw( 'menu_icon', $pod[ 'options' ], '', null, true ), true );
  274. if ( empty( $menu_position ) )
  275. $menu_position = null;
  276. $menu_slug = 'pods-settings-' . $pod[ 'name' ];
  277. $menu_location = pods_var( 'menu_location', $pod[ 'options' ], 'settings' );
  278. $menu_location_custom = pods_var( 'menu_location_custom', $pod[ 'options' ], '' );
  279. if ( 'settings' == $menu_location )
  280. add_options_page( $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ) );
  281. elseif ( 'appearances' == $menu_location )
  282. add_theme_page( $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ) );
  283. elseif ( 'objects' == $menu_location ) {
  284. if ( empty( $menu_position ) )
  285. add_object_page( $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ), $menu_icon );
  286. else
  287. add_menu_page( $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ), $menu_icon, $menu_position );
  288. }
  289. elseif ( 'top' == $menu_location )
  290. add_menu_page( $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ), $menu_icon, $menu_position );
  291. elseif ( 'submenu' == $menu_location && !empty( $menu_location_custom ) )
  292. $submenu_items[ $menu_location_custom ] = array( $menu_location_custom, $page_title, $menu_label, 'read', $menu_slug, array( $this, 'admin_content_settings' ) );
  293. }
  294. }
  295. foreach ( $submenu_items as $item ) {
  296. call_user_func_array( 'add_submenu_page', $item );
  297. }
  298. $admin_menus = array(
  299. 'pods' => array(
  300. 'label' => __( 'Edit Pods', 'pods' ),
  301. 'function' => array( $this, 'admin_setup' ),
  302. 'access' => 'pods'
  303. ),
  304. 'pods-add-new' => array(
  305. 'label' => __( 'Add New', 'pods' ),
  306. 'function' => array( $this, 'admin_setup' ),
  307. 'access' => 'pods'
  308. ),
  309. 'pods-components' => array(
  310. 'label' => __( 'Components', 'pods' ),
  311. 'function' => array( $this, 'admin_components' ),
  312. 'access' => 'pods_components'
  313. ),
  314. 'pods-settings' => array(
  315. 'label' => __( 'Settings', 'pods' ),
  316. 'function' => array( $this, 'admin_settings' ),
  317. 'access' => 'pods_settings'
  318. ),
  319. 'pods-help' => array(
  320. 'label' => __( 'Help', 'pods' ),
  321. 'function' => array( $this, 'admin_help' )
  322. )
  323. );
  324. if ( empty( $all_pods ) )
  325. unset( $admin_menus[ 'pods' ] );
  326. }
  327. else {
  328. $admin_menus = array(
  329. 'pods-upgrade' => array(
  330. 'label' => __( 'Upgrade', 'pods' ),
  331. 'function' => array( $this, 'admin_upgrade' ),
  332. 'access' => 'manage_options'
  333. ),
  334. 'pods-settings' => array(
  335. 'label' => __( 'Settings', 'pods' ),
  336. 'function' => array( $this, 'admin_settings' ),
  337. 'access' => 'pods_settings'
  338. ),
  339. 'pods-help' => array(
  340. 'label' => __( 'Help', 'pods' ),
  341. 'function' => array( $this, 'admin_help' )
  342. )
  343. );
  344. add_action( 'admin_notices', array( $this, 'upgrade_notice' ) );
  345. }
  346. $admin_menus = apply_filters( 'pods_admin_menu', $admin_menus );
  347. $parent = false;
  348. if ( !empty( $admin_menus ) && ( !defined( 'PODS_DISABLE_ADMIN_MENU' ) || !PODS_DISABLE_ADMIN_MENU ) ) {
  349. foreach ( $admin_menus as $page => $menu_item ) {
  350. if ( !is_super_admin() && !current_user_can( 'delete_users' ) && isset( $menu_item[ 'access' ] ) ) {
  351. $access = (array) $menu_item[ 'access' ];
  352. $ok = false;
  353. foreach ( $access as $cap ) {
  354. if ( current_user_can( $cap ) ) {
  355. $ok = true;
  356. break;
  357. }
  358. }
  359. if ( !$ok )
  360. continue;
  361. }
  362. // Don't just show the help page
  363. if ( false === $parent && 'pods-help' == $page )
  364. continue;
  365. if ( !isset( $menu_item[ 'label' ] ) )
  366. $menu_item[ 'label' ] = $page;
  367. if ( false === $parent ) {
  368. $parent = $page;
  369. $menu = __( 'Pods Admin', 'pods' );
  370. if ( 'pods-upgrade' == $parent )
  371. $menu = __( 'Pods Upgrade', 'pods' );
  372. add_menu_page( $menu, $menu, 'read', $parent, null, PODS_URL . 'ui/images/icon16.png' );
  373. }
  374. add_submenu_page( $parent, $menu_item[ 'label' ], $menu_item[ 'label' ], 'read', $page, $menu_item[ 'function' ] );
  375. if ( 'pods-components' == $page )
  376. PodsInit::$components->menu( $parent );
  377. }
  378. }
  379. }
  380. public function upgrade_notice () {
  381. echo '<div class="error fade"><p>';
  382. echo sprintf(
  383. __( '<strong>NOTICE:</strong> Pods %s requires your action to complete the upgrade. Please run the <a href="%s">Upgrade Wizard</a>.', 'pods' ),
  384. PODS_VERSION,
  385. admin_url( 'admin.php?page=pods-upgrade' )
  386. );
  387. echo '</p></div>';
  388. }
  389. /**
  390. * Create PodsUI content for the administration pages
  391. */
  392. public function admin_content () {
  393. $pod_name = str_replace( array( 'pods-manage-', 'pods-add-new-' ), '', $_GET[ 'page' ] );
  394. $pod = pods( $pod_name, pods_var( 'id', 'get', null, null, true ) );
  395. $default = 'manage';
  396. if ( false !== strpos( $_GET[ 'page' ], 'pods-add-new-' ) )
  397. $default = 'add';
  398. $actions_enabled = pods_var_raw( 'ui_actions_enabled', $pod->pod_data[ 'options' ] );
  399. if ( !empty( $actions_enabled ) )
  400. $actions_enabled = (array) $actions_enabled;
  401. else
  402. $actions_enabled = array();
  403. $available_actions = array(
  404. 'add',
  405. 'edit',
  406. 'duplicate',
  407. 'delete',
  408. 'reorder',
  409. 'export'
  410. );
  411. if ( !empty( $actions_enabled ) ) {
  412. $actions_disabled = array(
  413. 'view' => 'view'
  414. );
  415. foreach ( $available_actions as $action ) {
  416. if ( !in_array( $action, $actions_enabled ) )
  417. $actions_disabled[ $action ] = $action;
  418. }
  419. }
  420. else {
  421. $actions_disabled = array(
  422. 'duplicate' => 'duplicate',
  423. 'view' => 'view',
  424. 'export' => 'export'
  425. );
  426. if ( 1 == pods_var( 'ui_export', $pod->pod_data[ 'options' ], 0 ) )
  427. unset( $actions_disabled[ 'export' ] );
  428. }
  429. $author_restrict = false;
  430. if ( isset( $pod->fields[ 'author' ] ) && 'pick' == $pod->fields[ 'author' ][ 'type' ] && 'user' == $pod->fields[ 'author' ][ 'pick_object' ] )
  431. $author_restrict = 'author.ID';
  432. if ( !is_super_admin() && !current_user_can( 'delete_users' ) && !current_user_can( 'pods' ) && !current_user_can( 'pods_content' ) ) {
  433. if ( !current_user_can( 'pods_add_' . $pod_name ) ) {
  434. $actions_disabled[ 'add' ] = 'add';
  435. $default = 'manage';
  436. }
  437. if ( !$author_restrict && !current_user_can( 'pods_edit_' . $pod_name ) && !current_user_can( 'pods_edit_others_' . $pod_name ) )
  438. $actions_disabled[ 'edit' ] = 'edit';
  439. if ( !$author_restrict && !current_user_can( 'pods_delete_' . $pod_name ) && !current_user_can( 'pods_delete_others_' . $pod_name ) )
  440. $actions_disabled[ 'delete' ] = 'delete';
  441. if ( !current_user_can( 'pods_reorder_' . $pod_name ) )
  442. $actions_disabled[ 'reorder' ] = 'reorder';
  443. if ( !current_user_can( 'pods_export_' . $pod_name ) )
  444. $actions_disabled[ 'export' ] = 'export';
  445. }
  446. $_GET[ 'action' ] = pods_var( 'action', 'get', $default );
  447. $index = $pod->pod_data[ 'field_id' ];
  448. $label = __( 'ID', 'pods' );
  449. if ( isset( $pod->pod_data[ 'fields' ][ $pod->pod_data[ 'field_index' ] ] ) ) {
  450. $index = $pod->pod_data[ 'field_index' ];
  451. $label = $pod->pod_data[ 'fields' ][ $pod->pod_data[ 'field_index' ] ];
  452. }
  453. $manage = array(
  454. $index => $label
  455. );
  456. if ( isset( $pod->pod_data[ 'fields' ][ 'modified' ] ) )
  457. $manage[ 'modified' ] = $pod->pod_data[ 'fields' ][ 'modified' ][ 'label' ];
  458. $manage_fields = pods_var_raw( 'ui_fields_manage', $pod->pod_data[ 'options' ] );
  459. if ( !empty( $manage_fields ) ) {
  460. $manage_new = array();
  461. foreach ( $manage_fields as $manage_field ) {
  462. if ( isset( $pod->pod_data[ 'fields' ][ $manage_field ] ) )
  463. $manage_new[ $manage_field ] = $pod->pod_data[ 'fields' ][ $manage_field ];
  464. elseif ( isset( $pod->pod_data[ 'object_fields' ][ $manage_field ] ) )
  465. $manage_new[ $manage_field ] = $pod->pod_data[ 'object_fields' ][ $manage_field ];
  466. elseif ( $manage_field == $pod->pod_data[ 'field_id' ] ) {
  467. $field = array(
  468. 'name' => $manage_field,
  469. 'label' => 'ID',
  470. 'type' => 'number',
  471. 'width' => '8%'
  472. );
  473. $manage_new[ $manage_field ] = PodsForm::field_setup( $field, null, $field[ 'type' ] );
  474. }
  475. }
  476. if ( !empty( $manage_new ) )
  477. $manage = $manage_new;
  478. }
  479. $manage = apply_filters( 'pods_admin_ui_fields_' . $pod->pod, apply_filters( 'pods_admin_ui_fields', $manage, $pod->pod, $pod ), $pod->pod, $pod );
  480. $icon = pods_var_raw( 'ui_icon', $pod->pod_data[ 'options' ] );
  481. if ( !empty( $icon ) )
  482. $icon = pods_image_url( $icon, '32x32' );
  483. $filters = pods_var_raw( 'ui_filters', $pod->pod_data[ 'options' ] );
  484. if ( !empty( $filters ) ) {
  485. $filters_new = array();
  486. foreach ( $filters as $filter_field ) {
  487. if ( isset( $pod->pod_data[ 'fields' ][ $filter_field ] ) )
  488. $filters_new[ $filter_field ] = $pod->pod_data[ 'fields' ][ $filter_field ];
  489. elseif ( isset( $pod->pod_data[ 'object_fields' ][ $filter_field ] ) )
  490. $filters_new[ $filter_field ] = $pod->pod_data[ 'object_fields' ][ $filter_field ];
  491. }
  492. $filters = $filters_new;
  493. }
  494. $ui = array(
  495. 'pod' => $pod,
  496. 'fields' => array(
  497. 'manage' => $manage,
  498. 'add' => $pod->pod_data[ 'fields' ],
  499. 'edit' => $pod->pod_data[ 'fields' ],
  500. 'duplicate' => $pod->pod_data[ 'fields' ]
  501. ),
  502. 'icon' => $icon,
  503. 'actions_disabled' => $actions_disabled
  504. );
  505. if ( !empty( $filters ) ) {
  506. $ui[ 'fields' ][ 'search' ] = $filters;
  507. $ui[ 'filters' ] = array_keys( $filters );
  508. $ui[ 'filters_enhanced' ] = true;
  509. }
  510. $reorder_field = pods_var_raw( 'ui_reorder_field', $pod->pod_data[ 'options' ] );
  511. if ( in_array( 'reorder', $actions_enabled ) && !in_array( 'reorder', $actions_disabled ) && !empty( $reorder_field ) && ( ( !empty( $pod->pod_data[ 'object_fields' ] ) && isset( $pod->pod_data[ 'object_fields' ][ $reorder_field ] ) ) || isset( $pod->pod_data[ 'fields' ][ $reorder_field ] ) ) ) {
  512. $ui[ 'reorder' ] = array( 'on' => $reorder_field );
  513. $ui[ 'orderby' ] = $reorder_field;
  514. $ui[ 'orderby_dir' ] = 'ASC';
  515. }
  516. if ( !empty( $author_restrict ) )
  517. $ui[ 'restrict' ] = array( 'author_restrict' => $author_restrict );
  518. if ( !in_array( 'delete', $ui[ 'actions_disabled' ] ) ) {
  519. $ui[ 'actions_bulk' ] = array(
  520. 'delete' => array(
  521. 'label' => __( 'Delete', 'pods' )
  522. // callback not needed, Pods has this built-in for delete
  523. )
  524. );
  525. }
  526. if ( strlen( pods_var( 'detail_url', $pod->pod_data ) ) < 1 ) {
  527. $ui[ 'actions_custom' ] = array(
  528. 'view_url' => array(
  529. 'label' => 'View',
  530. 'link' => get_site_url() . '/' . pods_var( 'detail_url', $pod->pod_data[ 'options' ] )
  531. )
  532. );
  533. }
  534. // @todo Customize the Add New / Manage links to point to their correct menu items
  535. $ui = apply_filters( 'pods_admin_ui_' . $pod->pod, apply_filters( 'pods_admin_ui', $ui, $pod->pod, $pod ), $pod->pod, $pod );
  536. pods_ui( $ui );
  537. }
  538. /**
  539. * Create PodsUI content for the settings administration pages
  540. */
  541. public function admin_content_settings () {
  542. $pod_name = str_replace( 'pods-settings-', '', $_GET[ 'page' ] );
  543. $pod = pods( $pod_name );
  544. if ( 'custom' != pods_var( 'ui_style', $pod->pod_data[ 'options' ], 'settings', null, true ) ) {
  545. $actions_disabled = array(
  546. 'manage' => 'manage',
  547. 'add' => 'add',
  548. 'delete' => 'delete',
  549. 'duplicate' => 'duplicate',
  550. 'view' => 'view',
  551. 'export' => 'export'
  552. );
  553. $_GET[ 'action' ] = 'edit';
  554. $page_title = pods_var_raw( 'label', $pod->pod_data[ 'options' ], ucwords( str_replace( '_', ' ', $pod->pod_data[ 'name' ] ) ), null, true );
  555. $ui = array(
  556. 'pod' => $pod,
  557. 'fields' => array(
  558. 'edit' => $pod->pod_data[ 'fields' ]
  559. ),
  560. 'header' => array(
  561. 'edit' => $page_title
  562. ),
  563. 'label' => array(
  564. 'edit' => __( 'Save Changes', 'pods' )
  565. ),
  566. 'style' => pods_var( 'ui_style', $pod->pod_data[ 'options' ], 'settings', null, true ),
  567. 'icon' => pods_evaluate_tags( pods_var_raw( 'menu_icon', $pod->pod_data[ 'options' ] ), true ),
  568. 'actions_disabled' => $actions_disabled
  569. );
  570. $ui = apply_filters( 'pods_admin_ui_' . $pod->pod, apply_filters( 'pods_admin_ui', $ui, $pod->pod, $pod ), $pod->pod, $pod );
  571. // Force disabled actions, do not pass go, do not collect $two_hundred
  572. $ui[ 'actions_disabled' ] = $actions_disabled;
  573. pods_ui( $ui );
  574. }
  575. else {
  576. do_action( 'pods_admin_ui_custom', $pod );
  577. do_action( 'pods_admin_ui_custom_' . $pod->pod, $pod );
  578. }
  579. }
  580. /**
  581. * Add media button for Pods shortcode
  582. *
  583. * @param $context
  584. *
  585. * @return string
  586. */
  587. public function media_button ( $context = null ) {
  588. $current_page = basename( $_SERVER[ 'PHP_SELF' ] );
  589. $current_page = explode( '?', $current_page );
  590. $current_page = explode( '#', $current_page[ 0 ] );
  591. $current_page = $current_page[ 0 ];
  592. // Only show the button on post type pages
  593. if ( !in_array( $current_page, array( 'post-new.php', 'post.php' ) ) )
  594. return $context;
  595. add_action( 'admin_footer', array( $this, 'mce_popup' ) );
  596. echo '<a href="#TB_inline?width=640&inlineId=pods_shortcode_form" class="thickbox" id="add_pod_button" title="Pods Shortcode"><img src="' . PODS_URL . 'ui/images/icon16.png" alt="Pods Shortcode" /></a>';
  597. }
  598. /**
  599. * Enqueue assets for Media Library Popup
  600. */
  601. public function register_media_assets () {
  602. if ( 'pods_media_attachment' == pods_var( 'inlineId', 'get' ) )
  603. wp_enqueue_style( 'pods-attach' );
  604. }
  605. /**
  606. * Output Pods shortcode popup window
  607. */
  608. public function mce_popup () {
  609. pods_view( PODS_DIR . 'ui/admin/shortcode.php', compact( array_keys( get_defined_vars() ) ) );
  610. }
  611. /**
  612. * Handle main Pods Setup area for managing Pods and Fields
  613. */
  614. public function admin_setup () {
  615. $pods = $this->api->load_pods( array( 'fields' => false ) );
  616. $view = pods_var( 'view', 'get', 'all', null, true );
  617. if ( empty( $pods ) && !isset( $_GET[ 'action' ] ) )
  618. $_GET[ 'action' ] = 'add';
  619. if ( 'pods-add-new' == $_GET[ 'page' ] ) {
  620. if ( isset( $_GET[ 'action' ] ) && 'add' != $_GET[ 'action' ] )
  621. pods_redirect( pods_var_update( array( 'page' => 'pods', 'action' => $_GET[ 'action' ] ) ) );
  622. else
  623. $_GET[ 'action' ] = 'add';
  624. }
  625. elseif ( isset( $_GET[ 'action' ] ) && 'add' == $_GET[ 'action' ] )
  626. pods_redirect( pods_var_update( array( 'page' => 'pods-add-new', 'action' => '' ) ) );
  627. $types = array(
  628. 'post_type' => __( 'Post Type (extended)', 'pods' ),
  629. 'taxonomy' => __( 'Taxonomy (extended)', 'pods' ),
  630. 'cpt' => __( 'Custom Post Type', 'pods' ),
  631. 'ct' => __( 'Custom Taxonomy', 'pods' ),
  632. 'user' => __( 'User (extended)', 'pods' ),
  633. 'media' => __( 'Media (extended)', 'pods' ),
  634. 'comment' => __( 'Comments (extended)', 'pods' ),
  635. 'pod' => __( 'Advanced Content Type', 'pods' ),
  636. 'settings' => __( 'Custom Settings Page', 'pods' )
  637. );
  638. $row = false;
  639. $pod_types_found = array();
  640. foreach ( $pods as $k => &$pod ) {
  641. if ( isset( $types[ $pod[ 'type' ] ] ) ) {
  642. if ( in_array( $pod[ 'type' ], array( 'post_type', 'taxonomy' ) ) ) {
  643. if ( empty( $pod[ 'object' ] ) ) {
  644. if ( 'post_type' == $pod[ 'type' ] )
  645. $pod[ 'type' ] = 'cpt';
  646. else
  647. $pod[ 'type' ] = 'ct';
  648. }
  649. }
  650. if ( !isset( $pod_types_found[ $pod[ 'type' ] ] ) )
  651. $pod_types_found[ $pod[ 'type' ] ] = 1;
  652. else
  653. $pod_types_found[ $pod[ 'type' ] ]++;
  654. if ( 'all' != $view && $view != $pod[ 'type' ] ) {
  655. unset( $pods[ $k ] );
  656. continue;
  657. }
  658. $pod[ 'type' ] = $types[ $pod[ 'type' ] ];
  659. }
  660. elseif ( 'all' != $view )
  661. continue;
  662. $pod[ 'storage' ] = ucwords( $pod[ 'storage' ] );
  663. if ( $pod[ 'id' ] == pods_var( 'id' ) && 'delete' != pods_var( 'action' ) )
  664. $row = $pod;
  665. }
  666. if ( false === $row && 0 < pods_var( 'id' ) && 'delete' != pods_var( 'action' ) ) {
  667. pods_message( 'Pod not found', 'error' );
  668. unset( $_GET[ 'id' ] );
  669. unset( $_GET[ 'action' ] );
  670. }
  671. $ui = array(
  672. 'data' => $pods,
  673. 'row' => $row,
  674. 'total' => count( $pods ),
  675. 'total_found' => count( $pods ),
  676. 'icon' => PODS_URL . 'ui/images/icon32.png',
  677. 'items' => 'Pods',
  678. 'item' => 'Pod',
  679. 'fields' => array(
  680. 'manage' => array(
  681. 'label' => array( 'label' => __( 'Label', 'pods' ) ),
  682. 'name' => array( 'label' => __( 'Name', 'pods' ) ),
  683. 'type' => array( 'label' => __( 'Type', 'pods' ) ),
  684. 'storage' => array( 'label' => __( 'Storage Type', 'pods' ) )
  685. )
  686. ),
  687. 'actions_disabled' => array( 'view', 'export' ),
  688. 'actions_custom' => array(
  689. 'add' => array( $this, 'admin_setup_add' ),
  690. 'edit' => array( $this, 'admin_setup_edit' ),
  691. 'duplicate' => array( $this, 'admin_setup_duplicate' ),
  692. 'reset' => array(
  693. 'label' => __( 'Delete All Items', 'pods' ),
  694. 'confirm' => __( 'Are you sure you want to delete all items from this Pod? If this is an extended Pod, it will remove the original items extended too.', 'pods' ),
  695. 'callback' => array( $this, 'admin_setup_reset' )
  696. ),
  697. 'delete' => array( $this, 'admin_setup_delete' )
  698. ),
  699. 'action_links' => array(
  700. 'add' => pods_var_update( array( 'page' => 'pods-add-new', 'action' => '', 'id' => '', 'do' => '' ) )
  701. ),
  702. 'search' => false,
  703. 'searchable' => false,
  704. 'sortable' => true,
  705. 'pagination' => false
  706. );
  707. if ( 1 < count( $pod_types_found ) ) {
  708. $ui[ 'views' ] = array( 'all' => __( 'All', 'pods' ) );
  709. $ui[ 'view' ] = $view;
  710. $ui[ 'heading' ] = array( 'views' => __( 'Type', 'pods' ) );
  711. $ui[ 'filters_enhanced' ] = true;
  712. foreach ( $pod_types_found as $pod_type => $number_found ) {
  713. $ui[ 'views' ][ $pod_type ] = $types[ $pod_type ];
  714. }
  715. }
  716. pods_ui( $ui );
  717. }
  718. /**
  719. * Get the add page of an object
  720. *
  721. * @param $obj
  722. */
  723. public function admin_setup_add ( $obj ) {
  724. pods_view( PODS_DIR . 'ui/admin/setup-add.php', compact( array_keys( get_defined_vars() ) ) );
  725. }
  726. /**
  727. * Get the edit page of an object
  728. *
  729. * @param $duplicate
  730. * @param $obj
  731. */
  732. public function admin_setup_edit ( $duplicate, $obj ) {
  733. pods_view( PODS_DIR . 'ui/admin/setup-edit.php', compact( array_keys( get_defined_vars() ) ) );
  734. }
  735. public function admin_setup_edit_tabs ( $pod ) {
  736. $fields = true;
  737. $labels = false;
  738. $admin_ui = false;
  739. $advanced = false;
  740. if ( 'post_type' == pods_var( 'type', $pod ) && strlen( pods_var( 'object', $pod ) ) < 1 ) {
  741. $labels = true;
  742. $admin_ui = true;
  743. $advanced = true;
  744. }
  745. elseif ( 'taxonomy' == pods_var( 'type', $pod ) && strlen( pods_var( 'object', $pod ) ) < 1 ) {
  746. $labels = true;
  747. $admin_ui = true;
  748. $advanced = true;
  749. }
  750. elseif ( 'pod' == pods_var( 'type', $pod ) ) {
  751. $labels = true;
  752. $admin_ui = true;
  753. $advanced = true;
  754. }
  755. elseif ( 'settings' == pods_var( 'type', $pod ) ) {
  756. $labels = true;
  757. $admin_ui = true;
  758. }
  759. if ( 'none' == pods_var( 'storage', $pod, 'none', null, true ) && 'settings' != pods_var( 'type', $pod ) )
  760. $fields = false;
  761. $tabs = array();
  762. if ( $fields )
  763. $tabs[ 'manage-fields' ] = __( 'Manage Fields', 'pods' );
  764. if ( $labels )
  765. $tabs[ 'labels' ] = __( 'Labels', 'pods' );
  766. if ( $admin_ui )
  767. $tabs[ 'admin-ui' ] = __( 'Admin UI', 'pods' );
  768. if ( $advanced )
  769. $tabs[ 'advanced' ] = __( 'Advanced Options', 'pods' );
  770. if ( 'taxonomy' == pods_var( 'type', $pod ) && !$fields )
  771. $tabs[ 'extra-fields' ] = __( 'Extra Fields', 'pods' );
  772. $tabs = apply_filters( 'pods_admin_setup_edit_tabs', $tabs, $pod, compact( array( 'fields', 'labels', 'admin_ui', 'advanced' ) ) );
  773. return $tabs;
  774. }
  775. /**
  776. * Build list of admin screen options
  777. *
  778. * @return array
  779. */
  780. public function admin_setup_edit_options ( $pod ) {
  781. $options = array();
  782. // @todo fill this in
  783. $options[ 'labels' ] = array(
  784. 'temporary' => 'This has the fields hardcoded' // :(
  785. );
  786. if ( 'post_type' == $pod[ 'type' ] ) {
  787. $options[ 'admin-ui' ] = array(
  788. 'description' => array(
  789. 'label' => __( 'Post Type Description', 'pods' ),
  790. 'help' => __( 'A short descriptive summary of what the post type is.', 'pods' ),
  791. 'type' => 'text',
  792. 'default' => ''
  793. ),
  794. 'show_ui' => array(
  795. 'label' => __( 'Show Admin UI', 'pods' ),
  796. 'help' => __( 'help', 'pods' ),
  797. 'type' => 'boolean',
  798. 'default' => pods_var_raw( 'public', $pod, true ),
  799. 'boolean_yes_label' => ''
  800. ),
  801. 'show_in_menu' => array(
  802. 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
  803. 'help' => __( 'help', 'pods' ),
  804. 'type' => 'boolean',
  805. 'default' => pods_var_raw( 'public', $pod, true ),
  806. 'dependency' => true,
  807. 'boolean_yes_label' => ''
  808. ),
  809. 'menu_location_custom' => array(
  810. 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
  811. 'help' => __( 'help', 'pods' ),
  812. 'type' => 'text',
  813. 'depends-on' => array( 'show_in_menu' => true )
  814. ),
  815. 'menu_name' => array(
  816. 'label' => __( 'Menu Name', 'pods' ),
  817. 'help' => __( 'help', 'pods' ),
  818. 'type' => 'text',
  819. 'default' => '',
  820. 'depends-on' => array( 'show_in_menu' => true )
  821. ),
  822. 'menu_position' => array(
  823. 'label' => __( 'Menu Position', 'pods' ),
  824. 'help' => __( 'help', 'pods' ),
  825. 'type' => 'number',
  826. 'default' => 0,
  827. 'depends-on' => array( 'show_in_menu' => true )
  828. ),
  829. 'menu_icon' => array(
  830. 'label' => __( 'Menu Icon URL', 'pods' ),
  831. 'help' => __( 'help', 'pods' ),
  832. 'type' => 'text',
  833. 'default' => '',
  834. 'depends-on' => array( 'show_in_menu' => true )
  835. ),
  836. 'show_in_nav_menus' => array(
  837. 'label' => __( 'Show in Navigation Menus', 'pods' ),
  838. 'help' => __( 'help', 'pods' ),
  839. 'type' => 'boolean',
  840. 'default' => true,
  841. 'boolean_yes_label' => ''
  842. ),
  843. 'show_in_admin_bar' => array(
  844. 'label' => __( 'Show in Admin Bar "New" Menu', 'pods' ),
  845. 'help' => __( 'help', 'pods' ),
  846. 'type' => 'boolean',
  847. 'default' => true,
  848. 'boolean_yes_label' => ''
  849. )
  850. );
  851. $options[ 'advanced' ] = array(
  852. 'public' => array(
  853. 'label' => __( 'Public', 'pods' ),
  854. 'help' => __( 'help', 'pods' ),
  855. 'type' => 'boolean',
  856. 'default' => true,
  857. 'boolean_yes_label' => ''
  858. ),
  859. 'publicly_queryable' => array(
  860. 'label' => __( 'Publicly Queryable', 'pods' ),
  861. 'help' => __( 'help', 'pods' ),
  862. 'type' => 'boolean',
  863. 'default' => pods_var_raw( 'public', $pod, true ),
  864. 'boolean_yes_label' => ''
  865. ),
  866. 'exclude_from_search' => array(
  867. 'label' => __( 'Exclude from Search', 'pods' ),
  868. 'help' => __( 'help', 'pods' ),
  869. 'type' => 'boolean',
  870. 'default' => !pods_var_raw( 'public', $pod, true ),
  871. 'boolean_yes_label' => ''
  872. ),
  873. 'capability_type' => array(
  874. 'label' => __( 'User Capability', 'pods' ),
  875. 'help' => __( 'Uses these capabilties for access to this post type: edit_{capability}, read_{capability}, and delete_{capability}', 'pods' ),
  876. 'type' => 'pick',
  877. 'default' => 'post',
  878. 'data' => array(
  879. 'post' => 'post',
  880. 'page' => 'page',
  881. 'custom' => __( 'Custom Capability', 'pods' )
  882. ),
  883. 'dependency' => true
  884. ),
  885. 'capability_type_custom' => array(
  886. 'label' => __( 'Custom User Capability', 'pods' ),
  887. 'help' => __( 'help', 'pods' ),
  888. 'type' => 'text',
  889. 'default' => pods_var_raw( 'name', $pod ),
  890. 'depends-on' => array( 'capability_type' => 'custom' )
  891. ),
  892. 'capability_type_extra' => array(
  893. 'label' => __( 'Additional User Capabilities', 'pods' ),
  894. 'help' => __( 'Enables additional capabilities for this Post Type including: delete_{capability}s, delete_private_{capability}s, delete_published_{capability}s, delete_others_{capability}s, edit_private_{capability}s, and edit_published_{capability}s', 'pods' ),
  895. 'type' => 'boolean',
  896. 'default' => true,
  897. 'boolean_yes_label' => ''
  898. ),
  899. 'has_archive' => array(
  900. 'label' => __( 'Has Archive', 'pods' ),
  901. 'help' => __( 'help', 'pods' ),
  902. 'type' => 'boolean',
  903. 'default' => false,
  904. 'boolean_yes_label' => ''
  905. ),
  906. 'hierarchical' => array(
  907. 'label' => __( 'Hierarchical', 'pods' ),
  908. 'help' => __( 'help', 'pods' ),
  909. 'type' => 'boolean',
  910. 'default' => false,
  911. 'dependency' => true,
  912. 'boolean_yes_label' => ''
  913. ),
  914. 'label_parent_item_colon' => array(
  915. 'label' => __( '<strong>Label: </strong> Parent <span class="pods-slugged" data-sluggable="label_singular">Item</span>', 'pods' ),
  916. 'help' => __( 'help', 'pods' ),
  917. 'type' => 'text',
  918. 'default' => '',
  919. 'depends-on' => array( 'hierarchical' => true )
  920. ),
  921. 'label_parent' => array(
  922. 'label' => __( '<strong>Label: </strong> Parent', 'pods' ),
  923. 'help' => __( 'help', 'pods' ),
  924. 'type' => 'text',
  925. 'default' => '',
  926. 'depends-on' => array( 'hierarchical' => true )
  927. ),
  928. 'rewrite' => array(
  929. 'label' => __( 'Rewrite', 'pods' ),
  930. 'help' => __( 'help', 'pods' ),

Large files files are truncated, but you can click here to view the full file