5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
21 public static $backend = null;
45 $endpoint = self::get_endpoint_name();
48 if ( in_array( array( EP_PERMALINK | EP_PERMALINK | EP_ROOT, $endpoint, $endpoint ), $wp_rewrite->endpoints ) ) {
52 add_rewrite_endpoint( $endpoint, EP_PAGES | EP_PERMALINK | EP_ROOT );
68 $endpoint = apply_filters(
'gravityview_directory_endpoint',
'entry' );
70 return sanitize_title( $endpoint );
82 public static function by_id( $entry_id ) {
108 if ( is_null( $request ) ) {
116 $view_id = is_null ( $view ) ? null : $view->ID;
121 if ( ! $request->is_view(
false ) ) {
124 if ( is_object( $post ) && is_numeric( $post->ID ) ) {
125 $permalink = get_permalink( $post->ID );
127 $view_collection = View_Collection::from_post( $post );
129 if( 1 < $view_collection->count() ) {
136 if ( is_null( $permalink ) ) {
137 $permalink = get_permalink(
$view_id );
146 $permalink = apply_filters(
'gravityview_directory_link', $permalink, $request->is_view(
false ) ?
$view_id : ( $post ? $post->ID : null ) );
150 $entry_slug = $this->get_slug(
true, $view, $request, $track_directory );
153 if ( get_option(
'permalink_structure' ) && ! is_preview() ) {
158 $link_parts = explode(
'?', $permalink );
160 $query = ! empty( $link_parts[1] ) ?
'?' . $link_parts[1] :
'';
162 $permalink = trailingslashit( $link_parts[0] ) . $entry_endpoint_name .
'/'.
$entry_slug .
'/' . $query;
167 if ( $track_directory ) {
168 if ( ! empty( $_GET[
'pagenum'] ) ) {
169 $args[
'pagenum'] = intval( $_GET[
'pagenum'] );
172 if ( $sort = Utils::_GET(
'sort' ) ) {
173 $args[
'sort'] = $sort;
174 $args[
'dir'] = Utils::_GET(
'dir' );
178 $permalink = add_query_arg(
$args, $permalink );
188 return apply_filters(
'gravityview/entry/permalink', $permalink, $this, $view, $request );
208 public function get_slug( $apply_filter =
false, \
GV\
View $view = null, \
GV\
Request $request = null, $track_directory =
true ) {
212 if( ! $apply_filter ) {
225 $entry_slug = apply_filters(
'gravityview/entry/slug',
$entry_slug, $this, $view, $request, $track_directory );
252 if ( ! $this->is_multi() ) {
255 return Utils::get( $this,
$field->form_id, $fallback );
If this file is called directly, abort.
get_permalink(\GV\View $view=null, \GV\Request $request=null, $track_directory=true)
Return the link to this entry in the supplied context.
If this file is called directly, abort.
as_entry()
Return the backing entry object.
static get_endpoint_name()
Return the endpoint name for a single Entry.
is_multi()
Is this a multi-entry (joined entry).
static by_id( $entry_id)
Construct a instance by ID.
from_field( $field, $fallback=null)
If this is a Multi_Entry filter it by Field.
If this file is called directly, abort.
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
If this file is called directly, abort.
gravityview()
The main GravityView wrapper function.
get_slug( $apply_filter=false, \GV\View $view=null, \GV\Request $request=null, $track_directory=true)
Get the entry slug.
static add_rewrite_endpoint()
Adds the necessary rewrites for single Entries.