/components/Pages.php

  1. <?php 
  2. /** 
  3. * Name: Pages 
  4. * 
  5. * Description: Creates advanced URL structures using wildcards in order to enable the front-end display of Pods Advanced Content Types. Not recommended for use with other content types. 
  6. * 
  7. * Version: 2.3 
  8. * 
  9. * Category: Advanced 
  10. * 
  11. * Menu Page: edit.php?post_type=_pods_page 
  12. * Menu Add Page: post-new.php?post_type=_pods_page 
  13. * 
  14. * @package Pods\Components 
  15. * @subpackage Pages 
  16. */ 
  17.  
  18. if ( class_exists( 'Pods_Pages' ) ) 
  19. return; 
  20.  
  21. class Pods_Pages extends PodsComponent { 
  22.  
  23. /** 
  24. * Current Pod Page 
  25. * 
  26. * @var array 
  27. * 
  28. * @since 2.0 
  29. */ 
  30. static $exists = null; 
  31.  
  32. /** 
  33. * Object type 
  34. * 
  35. * @var string 
  36. * 
  37. * @since 2.0 
  38. */ 
  39. private $object_type = '_pods_page'; 
  40.  
  41. /** 
  42. * Whether the page has been checked already 
  43. * 
  44. * @var bool 
  45. * 
  46. * @since 2.1 
  47. */ 
  48. static $checked = false; 
  49.  
  50. /** 
  51. * Keep track of if pods_content has been called yet 
  52. * 
  53. * @var bool 
  54. * 
  55. * @since 2.3 
  56. */ 
  57. static $content_called = false; 
  58.  
  59. /** 
  60. * Do things like register/enqueue scripts and stylesheets 
  61. * 
  62. * @since 2.0 
  63. */ 
  64. public function __construct () { 
  65. add_shortcode( 'pods-content', array( $this, 'shortcode' ) ); 
  66.  
  67. $args = array( 
  68. 'label' => 'Pod Pages',  
  69. 'labels' => array( 'singular_name' => 'Pod Page' ),  
  70. 'public' => false,  
  71. 'can_export' => false,  
  72. 'show_ui' => true,  
  73. 'show_in_menu' => false,  
  74. 'query_var' => false,  
  75. 'rewrite' => false,  
  76. 'has_archive' => false,  
  77. 'hierarchical' => false,  
  78. 'supports' => array( 'title', 'author', 'revisions' ),  
  79. 'menu_icon' => 'dashicons-pods' 
  80. ); 
  81.  
  82. if ( !pods_is_admin() ) 
  83. $args[ 'capability_type' ] = 'pods_page'; 
  84.  
  85. $args = PodsInit::object_label_fix( $args, 'post_type' ); 
  86.  
  87. register_post_type( $this->object_type, apply_filters( 'pods_internal_register_post_type_object_page', $args ) ); 
  88.  
  89. add_filter( 'post_type_link', array( $this, 'post_type_link' ), 10, 2 ); 
  90.  
  91. if ( !is_admin() ) 
  92. add_action( 'load_textdomain', array( $this, 'page_check' ), 12 ); 
  93. else { 
  94. add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 ); 
  95.  
  96. add_action( 'dbx_post_advanced', array( $this, 'edit_page_form' ), 10 ); 
  97.  
  98. add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) ); 
  99. add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 ); 
  100. add_filter( 'update_post_metadata', array( $this, 'save_meta' ), 10, 4 ); 
  101.  
  102. add_action( 'pods_meta_save_pre_post__pods_page', array( $this, 'fix_filters' ), 10, 5 ); 
  103. add_action( 'post_updated', array( $this, 'clear_cache' ), 10, 3 ); 
  104. add_action( 'delete_post', array( $this, 'clear_cache' ), 10, 1 ); 
  105. add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2 ); 
  106. add_filter( 'bulk_actions-edit-' . $this->object_type, array( $this, 'remove_bulk_actions' ) ); 
  107.  
  108. add_filter( 'builder_layout_filter_non_layout_post_types', array( $this, 'disable_builder_layout' ) ); 
  109.  
  110. /** 
  111. * Pod Page Content Shortcode support for use anywhere that supports WP Shortcodes 
  112. * 
  113. * @param array $tags An associative array of shortcode properties 
  114. * @param string $content Not currently used 
  115. * 
  116. * @return string 
  117. * @since 2.3.9 
  118. */ 
  119. public function shortcode ( $tags, $content = null ) { 
  120. if ( !isset( $tags[ 'page' ] ) || empty( $tags[ 'page' ] ) ) 
  121. $tags[ 'page' ] = null; 
  122.  
  123. $pods_page = Pods_Pages::exists( $tags[ 'page' ] ); 
  124.  
  125. if ( empty( $pods_page ) ) 
  126. return '<p>Pods Page not found</p>'; 
  127.  
  128. return Pods_Pages::content( true, $pods_page ); 
  129.  
  130. /** 
  131. * Disable this Post Type from appearing in the Builder layouts list 
  132. * 
  133. * @param array $post_types 
  134. * @return array 
  135. */ 
  136. public function disable_builder_layout ( $post_types ) { 
  137. $post_types[] = $this->object_type; 
  138.  
  139. return $post_types; 
  140.  
  141. /** 
  142. * Update Post Type messages 
  143. * 
  144. * @param array $messages 
  145. * 
  146. * @return array 
  147. * @since 2.0.2 
  148. */ 
  149. public function setup_updated_messages ( $messages ) { 
  150. global $post, $post_ID; 
  151.  
  152. $post_type = get_post_type_object( $this->object_type ); 
  153.  
  154. $labels = $post_type->labels; 
  155.  
  156. $messages[ $post_type->name ] = array( 
  157. 1 => sprintf( __( '%s updated. <a href="%s">%s</a>', 'pods' ), $labels->singular_name, esc_url( get_permalink( $post_ID ) ), $labels->view_item ),  
  158. 2 => __( 'Custom field updated.', 'pods' ),  
  159. 3 => __( 'Custom field deleted.', 'pods' ),  
  160. 4 => sprintf( __( '%s updated.', 'pods' ), $labels->singular_name ),  
  161. /** translators: %s: date and time of the revision */ 
  162. 5 => isset( $_GET[ 'revision' ] ) ? sprintf( __( '%s restored to revision from %s', 'pods' ), $labels->singular_name, wp_post_revision_title( (int) $_GET[ 'revision' ], false ) ) : false,  
  163. 6 => sprintf( __( '%s published. <a href="%s">%s</a>', 'pods' ), $labels->singular_name, esc_url( get_permalink( $post_ID ) ), $labels->view_item ),  
  164. 7 => sprintf( __( '%s saved.', 'pods' ), $labels->singular_name ),  
  165. 8 => sprintf( __( '%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'pods' ),  
  166. $labels->singular_name,  
  167. esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ),  
  168. $labels->singular_name 
  169. ),  
  170. 9 => sprintf( __( '%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'pods' ),  
  171. $labels->singular_name,  
  172. // translators: Publish box date format, see http://php.net/date 
  173. date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ),  
  174. esc_url( get_permalink( $post_ID ) ),  
  175. $labels->singular_name 
  176. ),  
  177. 10 => sprintf( __( '%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'pods' ), $labels->singular_name, esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ), $labels->singular_name ) 
  178. ); 
  179.  
  180. if ( false === (boolean) $post_type->public ) { 
  181. $messages[ $post_type->name ][ 1 ] = sprintf( __( '%s updated.', 'pods' ), $labels->singular_name ); 
  182. $messages[ $post_type->name ][ 6 ] = sprintf( __( '%s published.', 'pods' ), $labels->singular_name ); 
  183. $messages[ $post_type->name ][ 8 ] = sprintf( __( '%s submitted.', 'pods' ), $labels->singular_name ); 
  184. $messages[ $post_type->name ][ 9 ] = sprintf( __( '%s scheduled for: <strong>%1$s</strong>.', 'pods' ),  
  185. $labels->singular_name,  
  186. // translators: Publish box date format, see http://php.net/date 
  187. date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ) 
  188. ); 
  189. $messages[ $post_type->name ][ 10 ] = sprintf( __( '%s draft updated.', 'pods' ), $labels->singular_name ); 
  190.  
  191. return $messages; 
  192.  
  193. /** 
  194. * Enqueue styles 
  195. * 
  196. * @since 2.0 
  197. */ 
  198. public function admin_assets () { 
  199. wp_enqueue_style( 'pods-admin' ); 
  200.  
  201. /** 
  202. * Fix filters, specifically removing balanceTags 
  203. * 
  204. * @since 2.0.1 
  205. */ 
  206. public function fix_filters ( $data, $pod = null, $id = null, $groups = null, $post = null ) { 
  207. remove_filter( 'content_save_pre', 'balanceTags', 50 ); 
  208.  
  209. /** 
  210. * Remove unused row actions 
  211. * 
  212. * @since 2.0.5 
  213. */ 
  214. public function remove_row_actions ( $actions, $post ) { 
  215. global $current_screen; 
  216.  
  217. if ( !is_object( $current_screen ) || $this->object_type != $current_screen->post_type ) 
  218. return $actions; 
  219.  
  220. if ( isset( $actions[ 'view' ] ) ) 
  221. unset( $actions[ 'view' ] ); 
  222.  
  223. if ( isset( $actions[ 'inline hide-if-no-js' ] ) ) 
  224. unset( $actions[ 'inline hide-if-no-js' ] ); 
  225.  
  226. // W3 Total Cache 
  227. if ( isset( $actions[ 'pgcache_purge' ] ) ) 
  228. unset( $actions[ 'pgcache_purge' ] ); 
  229.  
  230. return $actions; 
  231.  
  232. /** 
  233. * Remove unused bulk actions 
  234. * 
  235. * @since 2.0.5 
  236. */ 
  237. public function remove_bulk_actions ( $actions ) { 
  238. if ( isset( $actions[ 'edit' ] ) ) 
  239. unset( $actions[ 'edit' ] ); 
  240.  
  241. return $actions; 
  242.  
  243. /** 
  244. * Clear cache on save 
  245. * 
  246. * @since 2.0 
  247. */ 
  248. public function clear_cache ( $data, $pod = null, $id = null, $groups = null, $post = null ) { 
  249. $old_post = $id; 
  250.  
  251. if ( !is_object( $id ) ) 
  252. $old_post = null; 
  253.  
  254. if ( is_object( $post ) && $this->object_type != $post->post_type ) 
  255. return; 
  256.  
  257. if ( !is_array( $data ) && 0 < $data ) { 
  258. $post = $data; 
  259. $post = get_post( $post ); 
  260.  
  261. if ( $this->object_type == $post->post_type ) { 
  262. pods_transient_clear( 'pods_object_pages' ); 
  263.  
  264. if ( is_object( $old_post ) && $this->object_type == $old_post->post_type ) 
  265. pods_cache_clear( $old_post->post_title, 'pods_object_page_wildcard' ); 
  266.  
  267. pods_cache_clear( $post->post_title, 'pods_object_page_wildcard' ); 
  268.  
  269. self::flush_rewrites(); 
  270.  
  271. /** 
  272. * Change post title placeholder text 
  273. * 
  274. * @since 2.0 
  275. */ 
  276. public function set_title_text ( $text, $post ) { 
  277. return __( 'Enter URL here', 'pods' ); 
  278.  
  279. /** 
  280. * Edit page form 
  281. * 
  282. * @since 2.0 
  283. */ 
  284. public function edit_page_form () { 
  285. global $post_type; 
  286.  
  287. if ( $this->object_type != $post_type ) 
  288. return; 
  289.  
  290. add_filter( 'enter_title_here', array( $this, 'set_title_text' ), 10, 2 ); 
  291.  
  292. /** 
  293. * Filter permalinks and adjust for pod pages 
  294. * 
  295. * @param $post_link 
  296. * @param $post 
  297. * 
  298. * @return mixed 
  299. */ 
  300. public function post_type_link ( $post_link, $post ) { 
  301. if ( empty( $post ) || $this->object_type != $post->post_type ) 
  302. return $post_link; 
  303.  
  304. $post_link = get_site_url() . '/'; 
  305.  
  306. if ( false === strpos( $post->post_title, '*' ) ) 
  307. $post_link .= trim( $post->post_title, '/ ' ) . '/'; 
  308.  
  309. return $post_link; 
  310.  
  311. /** 
  312. * Add meta boxes to the page 
  313. * 
  314. * @since 2.0 
  315. */ 
  316. public function add_meta_boxes () { 
  317. $pod = array( 
  318. 'name' => $this->object_type,  
  319. 'type' => 'post_type' 
  320. ); 
  321.  
  322. if ( isset( PodsMeta::$post_types[ $pod[ 'name' ] ] ) ) 
  323. return; 
  324.  
  325. if ( !function_exists( 'get_page_templates' ) ) 
  326. include_once ABSPATH . 'wp-admin/includes/theme.php'; 
  327.  
  328. $page_templates = apply_filters( 'pods_page_templates', get_page_templates() ); 
  329.  
  330. $page_templates[ __( '-- Page Template --', 'pods' ) ] = ''; 
  331.  
  332. $page_templates[ __( 'Custom (uses only Pod Page content)', 'pods' ) ] = '_custom'; 
  333.  
  334. if ( !in_array( 'pods.php', $page_templates ) && locate_template( array( 'pods.php', false ) ) ) 
  335. $page_templates[ __( 'Pods (Pods Default)', 'pods' ) ] = 'pods.php'; 
  336.  
  337. if ( !in_array( 'page.php', $page_templates ) && locate_template( array( 'page.php', false ) ) ) 
  338. $page_templates[ __( 'Page (WP Default)', 'pods' ) ] = 'page.php'; 
  339.  
  340. if ( !in_array( 'index.php', $page_templates ) && locate_template( array( 'index.php', false ) ) ) 
  341. $page_templates[ __( 'Index (WP Fallback)', 'pods' ) ] = 'index.php'; 
  342.  
  343. ksort( $page_templates ); 
  344.  
  345. $page_templates = array_flip( $page_templates ); 
  346.  
  347. $fields = array( 
  348. array( 
  349. 'name' => 'page_title',  
  350. 'label' => __( 'Page Title', 'pods' ),  
  351. 'type' => 'text' 
  352. ),  
  353. array( 
  354. 'name' => 'code',  
  355. 'label' => __( 'Page Code', 'pods' ),  
  356. 'type' => 'code',  
  357. 'attributes' => array( 
  358. 'id' => 'content' 
  359. ),  
  360. 'label_options' => array( 
  361. 'attributes' => array( 
  362. 'for' => 'content' 
  363. ),  
  364. array( 
  365. 'name' => 'precode',  
  366. 'label' => __( 'Page Precode', 'pods' ),  
  367. 'type' => 'code',  
  368. 'help' => __( 'Precode will run before your theme outputs the page. It is expected that this value will be a block of PHP. You must open the PHP tag here, as we do not open it for you by default.', 'pods' ) 
  369. ),  
  370. array( 
  371. 'name' => 'page_template',  
  372. 'label' => __( 'Page Template', 'pods' ),  
  373. 'type' => 'pick',  
  374. 'data' => $page_templates 
  375. ); 
  376.  
  377. pods_group_add( $pod, __( 'Page', 'pods' ), $fields, 'normal', 'high' ); 
  378.  
  379. $associated_pods = array( 
  380. 0 => __( '-- Select a Pod --', 'pods' ) 
  381. ); 
  382.  
  383. $all_pods = pods_api()->load_pods( array( 'names' => true ) ); 
  384.  
  385. if ( !empty( $all_pods ) ) { 
  386. foreach ( $all_pods as $pod_name => $pod_label ) { 
  387. $associated_pods[ $pod_name ] = $pod_label . ' (' . $pod_name . ')'; 
  388. else 
  389. $associated_pods[ 0 ] = __( 'None Found', 'pods' ); 
  390.  
  391. $fields = array( 
  392. array( 
  393. 'name' => 'pod',  
  394. 'label' => __( 'Associated Pod', 'pods' ),  
  395. 'default' => 0,  
  396. 'type' => 'pick',  
  397. 'data' => $associated_pods,  
  398. 'dependency' => true 
  399. ),  
  400. array( 
  401. 'name' => 'pod_slug',  
  402. 'label' => __( 'Wildcard Slug', 'pods' ),  
  403. 'help' => __( 'Setting the Wildcard Slug is an easy way to setup a detail page. You can use the special tag {@url.2} to match the *third* level of the URL of a Pod Page named "first/second/*" part of the pod page. This is functionally the same as using pods_v_sanitized( 2, "url" ) in PHP.', 'pods' ),  
  404. 'type' => 'text',  
  405. 'excludes-on' => array( 'pod' => 0 ) 
  406. ) 
  407. ); 
  408.   
  409. pods_group_add( $pod, __( 'Pod Association', 'pods' ), $fields, 'normal', 'high' ); 
  410.   
  411. $fields = array( 
  412. array( 
  413. 'name' => 'admin_only',  
  414. 'label' => __( 'Restrict access to Admins?', 'pods' ),  
  415. 'default' => 0,  
  416. 'type' => 'boolean',  
  417. 'dependency' => true 
  418. ),  
  419. array( 
  420. 'name' => 'restrict_role',  
  421. 'label' => __( 'Restrict access by Role?', 'pods' ),  
  422. 'help' => array( 
  423. __( '<h6>Roles</h6> Roles are assigned to users to provide them access to specific functionality in WordPress. Please see the Roles and Capabilities component in Pods for an easy tool to add your own roles and edit existing ones.', 'pods' ),  
  424. 'http://codex.wordpress.org/Roles_and_Capabilities' 
  425. ),  
  426. 'default' => 0,  
  427. 'type' => 'boolean',  
  428. 'dependency' => true 
  429. ),  
  430. array( 
  431. 'name' => 'roles_allowed',  
  432. 'label' => __( 'Role(s) Allowed', 'pods' ),  
  433. 'type' => 'pick',  
  434. 'pick_object' => 'role',  
  435. 'pick_format_type' => 'multi',  
  436. 'pick_format_multi' => 'autocomplete',  
  437. 'pick_ajax' => false,  
  438. 'default' => '',  
  439. 'depends-on' => array( 
  440. 'restrict_role' => true 
  441. ) 
  442. ),  
  443. array( 
  444. 'name' => 'restrict_capability',  
  445. 'label' => __( 'Restrict access by Capability?', 'pods' ),  
  446. 'help' => array( 
  447. __( '<h6>Capabilities</h6> Capabilities denote access to specific functionality in WordPress, and are assigned to specific User Roles. Please see the Roles and Capabilities component in Pods for an easy tool to add your own capabilities and roles.', 'pods' ),  
  448. 'http://codex.wordpress.org/Roles_and_Capabilities' 
  449. ),  
  450. 'default' => 0,  
  451. 'type' => 'boolean',  
  452. 'dependency' => true 
  453. ),  
  454. array( 
  455. 'name' => 'capability_allowed',  
  456. 'label' => __( 'Capability Allowed', 'pods' ),  
  457. 'type' => 'pick',  
  458. 'pick_object' => 'capability',  
  459. 'pick_format_type' => 'multi',  
  460. 'pick_format_multi' => 'autocomplete',  
  461. 'pick_ajax' => false,  
  462. 'default' => '',  
  463. 'depends-on' => array( 
  464. 'restrict_capability' => true 
  465. ) 
  466. ),  
  467. array( 
  468. 'name' => 'restrict_redirect',  
  469. 'label' => __( 'Redirect if Restricted?', 'pods' ),  
  470. 'default' => 0,  
  471. 'type' => 'boolean',  
  472. 'dependency' => true 
  473. ),  
  474. array( 
  475. 'name' => 'restrict_redirect_login',  
  476. 'label' => __( 'Redirect to WP Login page', 'pods' ),  
  477. 'default' => 0,  
  478. 'type' => 'boolean',  
  479. 'dependency' => true,  
  480. 'depends-on' => array( 
  481. 'restrict_redirect' => true 
  482. ) 
  483. ),  
  484. array( 
  485. 'name' => 'restrict_redirect_url',  
  486. 'label' => __( 'Redirect to a Custom URL', 'pods' ),  
  487. 'default' => '',  
  488. 'type' => 'text',  
  489. 'depends-on' => array( 
  490. 'restrict_redirect' => true,  
  491. 'restrict_redirect_login' => false 
  492. ) 
  493. ),  
  494. ); 
  495.   
  496. pods_group_add( $pod, __( 'Restrict Access', 'pods' ), $fields, 'normal', 'high' ); 
  497. } 
  498.   
  499. /** 
  500. * Get the fields 
  501. * 
  502. * @param null $_null 
  503. * @param int $post_ID 
  504. * @param string $meta_key 
  505. * @param bool $single 
  506. * 
  507. * @return array|bool|int|mixed|null|string|void 
  508. */ 
  509. public function get_meta ( $_null, $post_ID = null, $meta_key = null, $single = false ) { 
  510. if ( 'code' == $meta_key ) { 
  511. $post = get_post( $post_ID ); 
  512.  
  513. if ( is_object( $post ) && $this->object_type == $post->post_type ) 
  514. return $post->post_content; 
  515.  
  516. return $_null; 
  517.  
  518. /** 
  519. * Save the fields 
  520. * 
  521. * @param $_null 
  522. * @param int $post_ID 
  523. * @param string $meta_key 
  524. * @param null $meta_value 
  525. * 
  526. * @return bool|int|null 
  527. */ 
  528. public function save_meta ( $_null, $post_ID = null, $meta_key = null, $meta_value = null ) { 
  529. if ( 'code' == $meta_key ) { 
  530. $post = get_post( $post_ID ); 
  531.  
  532. if ( is_object( $post ) && $this->object_type == $post->post_type ) { 
  533. $postdata = array( 
  534. 'ID' => $post_ID,  
  535. 'post_content' => $meta_value 
  536. ); 
  537.  
  538. remove_filter( current_filter(), array( $this, __FUNCTION__ ), 10 ); 
  539.  
  540. $revisions = false; 
  541.  
  542. if ( has_action( 'pre_post_update', 'wp_save_post_revision' ) ) { 
  543. remove_action( 'pre_post_update', 'wp_save_post_revision' ); 
  544.  
  545. $revisions = true; 
  546.  
  547. wp_update_post( (object) $postdata ); // objects will be automatically sanitized 
  548.  
  549. if ( $revisions ) 
  550. add_action( 'pre_post_update', 'wp_save_post_revision' ); 
  551.  
  552. return true; 
  553.  
  554. return $_null; 
  555.  
  556. /** 
  557. * Flush Pod Page Rewrite cache 
  558. * 
  559. * @return array Pod Page Rewrites 
  560. * 
  561. * @since 2.3.4 
  562. */ 
  563. public static function flush_rewrites () { 
  564. $args = array( 
  565. 'post_type' => '_pods_page',  
  566. 'nopaging' => true,  
  567. 'posts_per_page' => -1,  
  568. 'post_status' => 'publish',  
  569. 'order' => 'ASC',  
  570. 'orderby' => 'title' 
  571. ); 
  572.  
  573. $pod_pages = get_posts( $args ); 
  574.  
  575. $pod_page_rewrites = array(); 
  576.  
  577. foreach ( $pod_pages as $pod_page ) { 
  578. $pod_page_rewrites[ $pod_page->ID ] = $pod_page->post_title; 
  579.  
  580. uksort( $pod_page_rewrites, 'pods_page_length_sort' ); 
  581.  
  582. pods_transient_set( 'pods_object_page_rewrites', $pod_page_rewrites ); 
  583.  
  584. $pod_page_rewrites = array_flip( $pod_page_rewrites ); 
  585.  
  586. return $pod_page_rewrites; 
  587.  
  588. /** 
  589. * Check to see if Pod Page exists and return data 
  590. * 
  591. * $uri not required, if NULL then returns REQUEST_URI matching Pod Page 
  592. * 
  593. * @param string $uri The Pod Page URI to check if exists 
  594. * 
  595. * @return array|bool 
  596. */ 
  597. public static function exists ( $uri = null ) { 
  598. if ( null === $uri ) { 
  599. $uri = parse_url( pods_current_url() ); 
  600. $uri = $uri[ 'path' ]; 
  601. else { 
  602. $uri = explode( '?', $uri ); 
  603. $uri = explode( '#', $uri[ 0 ] ); 
  604. $uri = $uri[ 0 ]; 
  605.  
  606. $home = parse_url( get_home_url() ); 
  607.  
  608. if ( !empty( $home ) && isset( $home[ 'path' ] ) && '/' != $home[ 'path' ] ) 
  609. $uri = substr( $uri, strlen( $home[ 'path' ] ) ); 
  610.  
  611. $uri = trim( $uri, '/' ); 
  612. $uri_depth = count( array_filter( explode( '/', $uri ) ) ) - 1; 
  613.  
  614. $pods_page_exclusions = array( 
  615. 'wp-admin',  
  616. 'wp-content',  
  617. 'wp-includes',  
  618. 'index.php',  
  619. 'wp-login.php',  
  620. 'wp-signup.php' 
  621. ); 
  622.  
  623. $pods_page_exclusions = apply_filters( 'pods_page_exclusions', $pods_page_exclusions ); 
  624.  
  625. if ( is_admin() || empty( $uri ) ) 
  626. return false; 
  627.  
  628. foreach ( $pods_page_exclusions as $exclusion ) { 
  629. if ( 0 === strpos( $uri, $exclusion ) ) 
  630. return false; 
  631.  
  632. $object = apply_filters( 'pods_page_exists', false, $uri ); 
  633. if ( !empty ( $object ) ) { 
  634. return $object; 
  635.  
  636. if ( false === strpos( $uri, '*' ) && ! apply_filters( 'pods_page_regex_matching', false ) ) { 
  637. $object = pods_by_title( $uri, ARRAY_A, '_pods_page', 'publish' ); 
  638.  
  639. $wildcard = false; 
  640.  
  641. if ( empty( $object ) ) { 
  642. if ( false === strpos( $uri, '*' ) ) { 
  643. $object = pods_cache_get( $uri, 'pods_object_page_wildcard' ); 
  644.  
  645. if ( !empty( $object ) ) 
  646. return $object; 
  647.  
  648. $pod_page_rewrites = pods_transient_get( 'pods_object_page_rewrites' ); 
  649.  
  650. if ( empty( $pod_page_rewrites ) ) 
  651. $pod_page_rewrites = self::flush_rewrites(); 
  652. else 
  653. $pod_page_rewrites = array_flip( $pod_page_rewrites ); 
  654.  
  655. $found_rewrite_page_id = 0; 
  656.  
  657. if ( !empty( $pod_page_rewrites ) ) { 
  658. foreach ( $pod_page_rewrites as $pod_page => $pod_page_id ) { 
  659. if ( !apply_filters( 'pods_page_regex_matching', false ) ) { 
  660. if ( false === strpos( $pod_page, '*' ) ) 
  661. continue; 
  662.  
  663. $depth_check = strlen( $pod_page ) - strlen( str_replace( '/', '', $pod_page ) ); 
  664.  
  665. $pod_page = preg_quote( $pod_page, '/' ); 
  666.  
  667. $pod_page = str_replace( '\\*', '(.*)', $pod_page ); 
  668.  
  669. if ( $uri_depth == $depth_check && preg_match( '/^' . $pod_page . '$/', $uri ) ) { 
  670. $found_rewrite_page_id = $pod_page_id; 
  671.  
  672. break; 
  673. elseif ( preg_match( '/^' . str_replace( '/', '\\/', $pod_page ) . '$/', $uri ) ) { 
  674. $found_rewrite_page_id = $pod_page_id; 
  675.  
  676. break; 
  677.  
  678. if ( !empty( $found_rewrite_page_id ) ) { 
  679. $object = get_post( $found_rewrite_page_id, ARRAY_A ); 
  680.  
  681. if ( empty( $object ) || '_pods_page' != $object[ 'post_type' ] ) 
  682. $object = false; 
  683.  
  684. $wildcard = true; 
  685.  
  686. if ( !empty( $object ) ) { 
  687. $object = array( 
  688. 'id' => $object[ 'ID' ],  
  689. 'uri' => $object[ 'post_title' ],  
  690. 'code' => $object[ 'post_content' ],  
  691. 'phpcode' => $object[ 'post_content' ], // phpcode is deprecated 
  692. 'precode' => get_post_meta( $object[ 'ID' ], 'precode', true ),  
  693. 'page_template' => get_post_meta( $object[ 'ID' ], 'page_template', true ),  
  694. 'title' => get_post_meta( $object[ 'ID' ], 'page_title', true ),  
  695. 'options' => array( 
  696. 'admin_only' => (boolean) get_post_meta( $object[ 'ID' ], 'admin_only', true ),  
  697. 'restrict_role' => (boolean) get_post_meta( $object[ 'ID' ], 'restrict_role', true ),  
  698. 'restrict_capability' => (boolean) get_post_meta( $object[ 'ID' ], 'restrict_capability', true ),  
  699. 'roles_allowed' => get_post_meta( $object[ 'ID' ], 'roles_allowed', true ),  
  700. 'capability_allowed' => get_post_meta( $object[ 'ID' ], 'capability_allowed', true ),  
  701. 'restrict_redirect' => (boolean) get_post_meta( $object[ 'ID' ], 'restrict_redirect', true ),  
  702. 'restrict_redirect_login' => (boolean) get_post_meta( $object[ 'ID' ], 'restrict_redirect_login', true ),  
  703. 'restrict_redirect_url' => get_post_meta( $object[ 'ID' ], 'restrict_redirect_url', true ),  
  704. 'pod' => get_post_meta( $object[ 'ID' ], 'pod', true ),  
  705. 'pod_slug' => get_post_meta( $object[ 'ID' ], 'pod_slug', true ),  
  706. ); 
  707.  
  708. if ( $wildcard ) 
  709. pods_cache_set( $uri, $object, 'pods_object_page_wildcard', 3600 ); 
  710.  
  711. return $object; 
  712.  
  713. return false; 
  714.  
  715. /** 
  716. * Check if a Pod Page exists 
  717. */ 
  718. public function page_check () { 
  719. if ( self::$checked ) 
  720. return; 
  721.  
  722. global $pods; 
  723.  
  724. // Fix any global confusion wherever this runs 
  725. if ( isset( $pods ) && !isset( $GLOBALS[ 'pods' ] ) ) 
  726. $GLOBALS[ 'pods' ] =& $pods; 
  727. elseif ( !isset( $pods ) && isset( $GLOBALS[ 'pods' ] ) ) 
  728. $pods =& $GLOBALS[ 'pods' ]; 
  729.  
  730. if ( !defined( 'PODS_DISABLE_POD_PAGE_CHECK' ) || !PODS_DISABLE_POD_PAGE_CHECK ) { 
  731. if ( null === self::$exists ) 
  732. self::$exists = pod_page_exists(); 
  733.  
  734. if ( false !== self::$exists ) { 
  735. $pods = apply_filters( 'pods_global', $pods, self::$exists ); 
  736.  
  737. if ( !is_wp_error( $pods ) && ( is_object( $pods ) || 404 != $pods ) ) { 
  738. add_action( 'template_redirect', array( $this, 'template_redirect' ) ); 
  739. add_filter( 'redirect_canonical', '__return_false' ); 
  740. add_action( 'wp_head', array( $this, 'wp_head' ) ); 
  741. add_filter( 'wp_title', array( $this, 'wp_title' ), 0, 3 ); 
  742. add_filter( 'body_class', array( $this, 'body_class' ), 0, 1 ); 
  743. add_filter( 'status_header', array( $this, 'status_header' ) ); 
  744. add_action( 'after_setup_theme', array( $this, 'precode' ) ); 
  745. add_action( 'wp', array( $this, 'silence_404' ), 1 ); 
  746.  
  747. // Genesis theme integration 
  748. add_action( 'genesis_loop', 'pods_content', 11 ); 
  749.  
  750. self::$checked = true; 
  751.  
  752. /** 
  753. * Output Pod Page Content 
  754. * 
  755. * @param bool $return Whether to return or not (default is to echo) 
  756. * 
  757. * @return string 
  758. */ 
  759. public static function content ( $return = false, $pods_page = false ) { 
  760. if ( empty( $pods_page ) ) 
  761. $pods_page = self::$exists; 
  762.  
  763. $content = false; 
  764.  
  765. if ( $pods_page == self::$exists && self::$content_called ) 
  766. return $content; 
  767.  
  768. if ( !empty( $pods_page ) ) { 
  769. /** 
  770. * @var $pods \Pods 
  771. */ 
  772. global $pods; 
  773.  
  774. // Fix any global confusion wherever this runs 
  775. if ( isset( $pods ) && !isset( $GLOBALS[ 'pods' ] ) ) 
  776. $GLOBALS[ 'pods' ] =& $pods; 
  777. elseif ( !isset( $pods ) && isset( $GLOBALS[ 'pods' ] ) ) 
  778. $pods =& $GLOBALS[ 'pods' ]; 
  779.  
  780. if ( 0 < strlen( trim( $pods_page[ 'code' ] ) ) ) 
  781. $content = trim( $pods_page[ 'code' ] ); 
  782.  
  783. ob_start(); 
  784.  
  785. do_action( 'pods_content_pre', $pods_page, $content ); 
  786.  
  787. if ( 0 < strlen( $content ) ) { 
  788. if ( false !== strpos( $content, '<?' ) && ( !defined( 'PODS_DISABLE_EVAL' ) || !PODS_DISABLE_EVAL ) ) { 
  789. pods_deprecated( 'Pod Page PHP code has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1' ); 
  790.  
  791. eval( "?>$content" ); 
  792. elseif ( is_object( $pods ) && !empty( $pods->id ) ) 
  793. echo $pods->do_magic_tags( $content ); 
  794. else 
  795. echo $content; 
  796.  
  797. do_action( 'pods_content_post', $pods_page, $content ); 
  798.  
  799. $content = ob_get_clean(); 
  800.  
  801. if ( $pods_page == self::$exists ) 
  802. self::$content_called = true; 
  803.  
  804. $content = apply_filters( 'pods_content', $content, $pods_page ); 
  805.  
  806. if ( $return ) 
  807. return $content; 
  808.  
  809. echo $content; 
  810.  
  811. /** 
  812. * Run any precode for current Pod Page 
  813. */ 
  814. public function precode () { 
  815. global $pods; 
  816.  
  817. // Fix any global confusion wherever this runs 
  818. if ( isset( $pods ) && !isset( $GLOBALS[ 'pods' ] ) ) 
  819. $GLOBALS[ 'pods' ] =& $pods; 
  820. elseif ( !isset( $pods ) && isset( $GLOBALS[ 'pods' ] ) ) 
  821. $pods =& $GLOBALS[ 'pods' ]; 
  822.  
  823. if ( false !== self::$exists ) { 
  824. $permission = pods_permission( self::$exists[ 'options' ] ); 
  825.  
  826. $permission = (boolean) apply_filters( 'pods_pages_permission', $permission, self::$exists ); 
  827.  
  828. if ( $permission ) { 
  829. $content = false; 
  830.  
  831. if ( !is_object( $pods ) && 404 != $pods && 0 < strlen( pods_var( 'pod', self::$exists[ 'options' ] ) ) ) { 
  832. $slug = pods_var_raw( 'pod_slug', self::$exists[ 'options' ], null, null, true ); 
  833.  
  834. // Handle special magic tags 
  835. if ( 0 < strlen( $slug ) ) { 
  836. $slug = pods_evaluate_tags( $slug, true ); 
  837.  
  838. $pods = pods( pods_var( 'pod', self::$exists[ 'options' ] ), $slug ); 
  839.  
  840. // Auto 404 handling if item doesn't exist 
  841. if ( 0 < strlen( $slug ) && !$pods->exists() && apply_filters( 'pods_pages_auto_404', true, $slug, $pods, self::$exists ) ) { 
  842. $pods = 404; 
  843.  
  844. if ( 0 < strlen( trim( self::$exists[ 'precode' ] ) ) ) 
  845. $content = self::$exists[ 'precode' ]; 
  846.  
  847. if ( false !== $content && ( !defined( 'PODS_DISABLE_EVAL' ) || !PODS_DISABLE_EVAL ) ) { 
  848. pods_deprecated( 'Pod Page Precode has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1' ); 
  849.  
  850. eval( "?>$content" ); 
  851.  
  852. do_action( 'pods_page_precode', self::$exists, $pods, $content ); 
  853. elseif ( self::$exists[ 'options' ][ 'restrict_redirect' ] ) { 
  854. $redirect_url = ''; 
  855.  
  856. if ( self::$exists[ 'options' ][ 'restrict_redirect_login' ] ) { 
  857. $redirect_url = wp_login_url( pods_current_url() ); 
  858. elseif ( !empty( self::$exists[ 'options' ][ 'restrict_redirect_url' ] ) ) { 
  859. $redirect_url = self::$exists[ 'options' ][ 'restrict_redirect_url' ]; 
  860.  
  861. if ( !empty( $redirect_url ) ) { 
  862. wp_redirect( $redirect_url ); 
  863. die(); 
  864.  
  865. if ( !$permission || ( !is_object( $pods ) && ( 404 == $pods || is_wp_error( $pods ) ) ) ) { 
  866. remove_action( 'template_redirect', array( $this, 'template_redirect' ) ); 
  867. remove_action( 'wp_head', array( $this, 'wp_head' ) ); 
  868. remove_filter( 'redirect_canonical', '__return_false' ); 
  869. remove_filter( 'wp_title', array( $this, 'wp_title' ) ); 
  870. remove_filter( 'body_class', array( $this, 'body_class' ) ); 
  871. remove_filter( 'status_header', array( $this, 'status_header' ) ); 
  872. remove_action( 'wp', array( $this, 'silence_404' ), 1 ); 
  873.  
  874. /** 
  875. * 
  876. */ 
  877. public function wp_head () { 
  878. global $pods; 
  879.  
  880. do_action( 'pods_wp_head' ); 
  881.  
  882. if ( !defined( 'PODS_DISABLE_VERSION_OUTPUT' ) || !PODS_DISABLE_VERSION_OUTPUT ) { 
  883. ?> 
  884. <!-- Pods Framework <?php echo esc_html( PODS_VERSION ); ?> --> 
  885. <?php 
  886. if ( ( !defined( 'PODS_DISABLE_META' ) || !PODS_DISABLE_META ) && is_object( $pods ) && !is_wp_error( $pods ) ) { 
  887.  
  888. if ( isset( $pods->meta ) && is_array( $pods->meta ) && !empty( $pods->meta ) ) { 
  889. foreach ( $pods->meta as $name => $content ) { 
  890. if ( 'title' == $name ) 
  891. continue; 
  892. ?> 
  893. <meta name="<?php echo esc_attr( $name ); ?>" content="<?php echo esc_attr( $content ); ?>" /> 
  894. <?php 
  895.  
  896. if ( isset( $pods->meta_properties ) && is_array( $pods->meta_properties ) && !empty( $pods->meta_properties ) ) { 
  897. foreach ( $pods->meta_properties as $property => $content ) { 
  898. ?> 
  899. <meta property="<?php echo esc_attr( $property ); ?>" content="<?php echo esc_attr( $content ); ?>" /> 
  900. <?php 
  901.  
  902. if ( isset( $pods->meta_extra ) && 0 < strlen( $pods->meta_extra ) ) 
  903. echo $pods->meta_extra; 
  904.  
  905. /** 
  906. * @param $title 
  907. * @param $sep 
  908. * @param $seplocation 
  909. * 
  910. * @return mixed|void 
  911. */ 
  912. public function wp_title ( $title, $sep, $seplocation ) { 
  913. global $pods; 
  914.  
  915. $page_title = trim( self::$exists[ 'title' ] ); 
  916.  
  917. if ( 0 < strlen( $page_title ) ) { 
  918. if ( is_object( $pods ) && !is_wp_error( $pods ) ) 
  919. $page_title = $pods->do_magic_tags( $page_title ); 
  920.  
  921. $title = ( 'right' == $seplocation ) ? "{$page_title} {$sep} " : " {$sep} {$page_title}"; 
  922. elseif ( strlen( trim( $title ) ) < 1 ) { 
  923. $uri = explode( '?', $_SERVER[ 'REQUEST_URI' ] ); 
  924. $uri = preg_replace( '@^([/]?)(.*?)([/]?)$@', '$2', $uri[ 0 ] ); 
  925. $uri = preg_replace( '@(-|_)@', ' ', $uri ); 
  926. $uri = explode( '/', $uri ); 
  927.  
  928. $title = ''; 
  929.  
  930. foreach ( $uri as $key => $page_title ) { 
  931. $title .= ( 'right' == $seplocation ) ? ucwords( $page_title ) . " {$sep} " : " {$sep} " . ucwords( $page_title ); 
  932.  
  933. if ( ( !defined( 'PODS_DISABLE_META' ) || !PODS_DISABLE_META ) && is_object( $pods ) && !is_wp_error( $pods ) && isset( $pods->meta ) && is_array( $pods->meta ) && isset( $pods->meta[ 'title' ] ) ) 
  934. $title = $pods->meta[ 'title' ]; 
  935.  
  936. return apply_filters( 'pods_title', $title, $sep, $seplocation, self::$exists ); 
  937.  
  938. /** 
  939. * @param $classes 
  940. * 
  941. * @return mixed|void 
  942. */ 
  943. public function body_class ( $classes ) { 
  944. global $pods; 
  945.  
  946. if ( defined( 'PODS_DISABLE_BODY_CLASSES' ) && PODS_DISABLE_BODY_CLASSES ) 
  947. return $classes; 
  948.  
  949. $classes[] = 'pods'; 
  950.  
  951. $uri = explode( '?', self::$exists[ 'uri' ] ); 
  952. $uri = explode( '#', $uri[ 0 ] ); 
  953.  
  954. $class = str_replace( array( '*', '/' ), array( '_w_', '-' ), $uri[ 0 ] ); 
  955. $class = sanitize_title( $class ); 
  956. $class = str_replace( array( '_', '--', '--' ), '-', $class ); 
  957. $class = trim( $class, '-' ); 
  958.  
  959. $classes[] = 'pod-page-' . $class; 
  960.  
  961. if ( is_object( $pods ) && !is_wp_error( $pods ) ) { 
  962. $class = sanitize_title( $pods->pod ); 
  963. $class = str_replace( array( '_', '--', '--' ), '-', $class ); 
  964. $class = trim( $class, '-' ); 
  965. $classes[] = 'pod-' . $class; 
  966.  
  967. if ( is_object( $pods ) && !is_wp_error( $pods ) && isset( $pods->body_classes ) ) 
  968. $classes[] = $pods->body_classes; 
  969.  
  970. return apply_filters( 'pods_body_class', $classes, $uri ); 
  971.  
  972. /** 
  973. * @return string 
  974. */ 
  975. public function status_header () { 
  976. return $_SERVER[ 'SERVER_PROTOCOL' ] . ' 200 OK'; 
  977.  
  978. /** 
  979. * 
  980. */ 
  981. public function silence_404 () { 
  982. global $wp_query; 
  983.  
  984. $wp_query->query_vars[ 'error' ] = ''; 
  985. $wp_query->is_404 = false; 
  986.  
  987. /** 
  988. * 
  989. */ 
  990. public function template_redirect () { 
  991. global $pods; 
  992.  
  993. if ( false !== self::$exists ) { 
  994. /** 
  995. * Create pods.php in your theme directory, and 
  996. * style it to suit your needs. Some helpful functions: 
  997. * 
  998. * get_header() 
  999. * pods_content() 
  1000. * get_sidebar() 
  1001. * get_footer() 
  1002. */ 
  1003. $template = self::$exists[ 'page_template' ]; 
  1004. $template = apply_filters( 'pods_page_template', $template, self::$exists ); 
  1005.  
  1006. $render_function = apply_filters( 'pods_template_redirect', null, $template, self::$exists ); 
  1007.  
  1008. do_action( 'pods_page', $template, self::$exists ); 
  1009.  
  1010. if ( '_custom' == $template ) 
  1011. pods_content(); 
  1012. elseif ( null !== $render_function && is_callable( $render_function ) ) 
  1013. call_user_func( $render_function, $template, self::$exists ); 
  1014. elseif ( ( !defined( 'PODS_DISABLE_DYNAMIC_TEMPLATE' ) || !PODS_DISABLE_DYNAMIC_TEMPLATE ) && is_object( $pods ) && !is_wp_error( $pods ) && isset( $pods->page_template ) && !empty( $pods->page_template ) && '' != locate_template( array( $pods->page_template ), true ) ) { 
  1015. $template = $pods->page_template; 
  1016. // found the template and included it, we're good to go! 
  1017. elseif ( !empty( self::$exists[ 'page_template' ] ) && '' != locate_template( array( self::$exists[ 'page_template' ] ), true ) ) { 
  1018. $template = self::$exists[ 'page_template' ]; 
  1019. // found the template and included it, we're good to go! 
  1020. else { 
  1021. $default_templates = array(); 
  1022.  
  1023. $uri = explode( '?', self::$exists[ 'uri' ] ); 
  1024. $uri = explode( '#', $uri[ 0 ] ); 
  1025.  
  1026. $page_path = explode( '/', $uri[ 0 ] ); 
  1027.  
  1028. while ( $last = array_pop( $page_path ) ) { 
  1029. $file_name = str_replace( '*', '-w-', implode( '/', $page_path ) . '/' . $last ); 
  1030. $sanitized = sanitize_title( $file_name ); 
  1031.  
  1032. $default_templates[] = 'pods/' . trim( str_replace( '--', '-', $sanitized ), ' -' ) . '.php'; 
  1033. $default_templates[] = 'pods-' . trim( str_replace( '--', '-', $sanitized ), ' -' ) . '.php'; 
  1034.  
  1035. $default_templates[] = 'pods.php'; 
  1036.  
  1037. $default_templates = apply_filters( 'pods_page_default_templates', $default_templates ); 
  1038.  
  1039. $template = locate_template( $default_templates, true ); 
  1040.  
  1041. if ( '' != $template ) { 
  1042. // found the template and included it, we're good to go! 
  1043. else { 
  1044. $template = false; 
  1045.  
  1046. // templates not found in theme, default output 
  1047. do_action( 'pods_page_default', $template, self::$exists ); 
  1048.  
  1049. get_header(); 
  1050. pods_content(); 
  1051. get_sidebar(); 
  1052. get_footer(); 
  1053.  
  1054. do_action( 'pods_page_end', $template, self::$exists ); 
  1055.  
  1056. exit; 
  1057.  
  1058. /** 
  1059. * Find out if the current page is a Pod Page 
  1060. * 
  1061. * @param string $uri The Pod Page URI to check if currently on 
  1062. * 
  1063. * @return bool 
  1064. * @since 1.7.5 
  1065. */ 
  1066. function is_pod_page ( $uri = null ) { 
  1067. if ( false !== Pods_Pages::$exists && ( null === $uri || $uri == Pods_Pages::$exists[ 'uri' ] || $uri == Pods_Pages::$exists[ 'id' ] ) ) 
  1068. return true; 
  1069.  
  1070. return false; 
  1071.  
  1072. /** 
  1073. * Check for a specific page template for the current pod page 
  1074. * 
  1075. * @param string $template The theme template file 
  1076. * 
  1077. * @return bool 
  1078. * @since 2.3.7 
  1079. */ 
  1080. function is_pod_page_template ( $template = null ) { 
  1081. if ( false !== Pods_Pages::$exists && $template == Pods_Pages::$exists[ 'page_template' ] ) 
  1082. return true; 
  1083.  
  1084. return false; 
  1085.  
  1086. /** 
  1087. * Get the current Pod Page URI 
  1088. * 
  1089. * @return string|bool 
  1090. * @since 2.3.3 
  1091. */ 
  1092. function get_pod_page_uri () { 
  1093. $pod_page = Pods_Pages::exists(); 
  1094.  
  1095. if ( !empty( $pod_page ) ) 
  1096. return $pod_page[ 'uri' ]; 
  1097.  
  1098. return false; 
  1099.  
  1100. /** 
  1101. * Check to see if Pod Page exists and return data 
  1102. * 
  1103. * $uri not required, if NULL then returns REQUEST_URI matching Pod Page 
  1104. * 
  1105. * @param string $uri The Pod Page URI to check if exists 
  1106. * 
  1107. * @return array 
  1108. * 
  1109. * @since 1.7.5 
  1110. */ 
  1111. function pod_page_exists ( $uri = null ) { 
  1112. return Pods_Pages::exists( $uri ); 
  1113.  
  1114. /** 
  1115. * Output Pod Page Content 
  1116. * 
  1117. * @param bool $return Whether to return or not (default is to echo) 
  1118. * 
  1119. * @return string 
  1120. * 
  1121. * @since 1.7.0 
  1122. */ 
  1123. function pods_content ( $return = false, $pods_page = false ) { 
  1124. return Pods_Pages::content( $return, $pods_page ); 
  1125.  
  1126. /** 
  1127. * Sort an array by length of items, descending, for use with uksort() 
  1128. * 
  1129. * @param string $a First array item 
  1130. * @param string $b Second array item 
  1131. * 
  1132. * @return int Length difference 
  1133. * 
  1134. * @since 2.3.4 
  1135. */ 
  1136. function pods_page_length_sort ( $a, $b ) { 
  1137. return strlen( $b ) - strlen( $a ); 
  1138.  
  1139. /** 
  1140. * Flush Pod Page Rewrite cache 
  1141. * 
  1142. * @return array Pod Page Rewrites 
  1143. * 
  1144. * @since 2.3.4 
  1145. */ 
  1146. function pods_page_flush_rewrites () { 
  1147. return Pods_Pages::flush_rewrites(); 
  1148.  
  1149. /** 
  1150. * Deprecated global variable 
  1151. */ 
  1152. $GLOBALS[ 'pod_page_exists' ] =& Pods_Pages::$exists; 
.