GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
class-gv-view.php
Go to the documentation of this file.
1 <?php
2 namespace GV;
3 
4 /** If this file is called directly, abort. */
5 if ( ! defined( 'GRAVITYVIEW_DIR' ) )
6  die();
7 
8 /**
9  * The default GravityView View class.
10  *
11  * Houses all base View functionality.
12  */
13 class View {
14 
15  /**
16  * Register the gravityview WordPress Custom Post Type.
17  *
18  * @internal
19  * @return void
20  */
21  public static function register_post_type() {
22 
23  /** Register only once */
24  if ( post_type_exists( 'gravityview' ) )
25  return;
26 
27  /**
28  * @filter `gravityview_is_hierarchical` Make GravityView Views hierarchical by returning TRUE
29  * This will allow for Views to be nested with Parents and also allows for menu order to be set in the Page Attributes metabox
30  * @since 1.13
31  * @param boolean $is_hierarchical Default: false
32  */
33  $is_hierarchical = (bool)apply_filters( 'gravityview_is_hierarchical', false );
34 
35  $supports = array( 'title', 'revisions' );
36 
37  if ( $is_hierarchical ) {
38  $supports[] = 'page-attributes';
39  }
40 
41  /**
42  * @filter `gravityview_post_type_supports` Modify post type support values for `gravityview` post type
43  * @see add_post_type_support()
44  * @since 1.15.2
45  * @param array $supports Array of features associated with a functional area of the edit screen. Default: 'title', 'revisions'. If $is_hierarchical, also 'page-attributes'
46  * @param[in] boolean $is_hierarchical Do Views support parent/child relationships? See `gravityview_is_hierarchical` filter.
47  */
48  $supports = apply_filters( 'gravityview_post_type_support', $supports, $is_hierarchical );
49 
50  /** Register Custom Post Type - gravityview */
51  $labels = array(
52  'name' => _x( 'Views', 'Post Type General Name', 'gravityview' ),
53  'singular_name' => _x( 'View', 'Post Type Singular Name', 'gravityview' ),
54  'menu_name' => _x( 'Views', 'Menu name', 'gravityview' ),
55  'parent_item_colon' => __( 'Parent View:', 'gravityview' ),
56  'all_items' => __( 'All Views', 'gravityview' ),
57  'view_item' => _x( 'View', 'View Item', 'gravityview' ),
58  'add_new_item' => __( 'Add New View', 'gravityview' ),
59  'add_new' => __( 'New View', 'gravityview' ),
60  'edit_item' => __( 'Edit View', 'gravityview' ),
61  'update_item' => __( 'Update View', 'gravityview' ),
62  'search_items' => __( 'Search Views', 'gravityview' ),
63  'not_found' => \GravityView_Admin::no_views_text(),
64  'not_found_in_trash' => __( 'No Views found in Trash', 'gravityview' ),
65  'filter_items_list' => __( 'Filter Views list', 'gravityview' ),
66  'items_list_navigation' => __( 'Views list navigation', 'gravityview' ),
67  'items_list' => __( 'Views list', 'gravityview' ),
68  'view_items' => __( 'See Views', 'gravityview' ),
69  'attributes' => __( 'View Attributes', 'gravityview' ),
70  );
71  $args = array(
72  'label' => __( 'view', 'gravityview' ),
73  'description' => __( 'Create views based on a Gravity Forms form', 'gravityview' ),
74  'labels' => $labels,
75  'supports' => $supports,
76  'hierarchical' => $is_hierarchical,
77  /**
78  * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
79  * @see https://codex.wordpress.org/Function_Reference/register_post_type#public
80  * @since 1.15.2
81  * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true`
82  * @param int $view_id The ID of the View currently being requested. `0` for general setting
83  */
84  'public' => apply_filters( 'gravityview_direct_access', gravityview()->plugin->is_compatible(), 0 ),
85  'show_ui' => gravityview()->plugin->is_compatible(),
86  'show_in_menu' => gravityview()->plugin->is_compatible(),
87  'show_in_nav_menus' => true,
88  'show_in_admin_bar' => true,
89  'menu_position' => 17,
90  'menu_icon' => '',
91  'can_export' => true,
92  /**
93  * @filter `gravityview_has_archive` Enable Custom Post Type archive?
94  * @since 1.7.3
95  * @param boolean False: don't have frontend archive; True: yes, have archive. Default: false
96  */
97  'has_archive' => apply_filters( 'gravityview_has_archive', false ),
98  'exclude_from_search' => true,
99  'rewrite' => array(
100  /**
101  * @filter `gravityview_slug` Modify the url part for a View.
102  * @see http://docs.gravityview.co/article/62-changing-the-view-slug
103  * @param string $slug The slug shown in the URL
104  */
105  'slug' => apply_filters( 'gravityview_slug', 'view' )
106  ),
107  'capability_type' => 'gravityview',
108  'map_meta_cap' => true,
109  );
110 
111  register_post_type( 'gravityview', $args );
112  }
113 }
$labels
static no_views_text()
Get text for no views found.
Definition: class-admin.php:69
The default GravityView View class.
gravityview()
"GRAVITYVIEW_DIR" "../" Require core
static register_post_type()
Register the gravityview WordPress Custom Post Type.