5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
30 if ( $request->is_admin() ) {
31 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', null, null,
$atts );
47 $atts = apply_filters(
'gravityview/shortcodes/gvfield/atts',
$atts );
50 gravityview()->log->error(
'View #{view_id} not found', array(
'view_id' =>
$atts[
'view_id'] ) );
51 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view, null, null,
$atts );
54 switch(
$atts[
'entry_id'] ):
62 add_filter(
'gravityview_get_entries', $filter =
function( $parameters,
$args,
$form_id ) {
63 if ( ! empty( $parameters[
'sorting'] ) ) {
67 $sort = &$parameters[
'sorting'];
68 $sort[
'direction'] = $sort[
'direction'] ==
'RAND' ? : ( $sort[
'direction'] ==
'ASC' ?
'DESC' :
'ASC' );
73 $parameters[
'sorting'] = array(
81 $entries = $view->get_entries( null );
82 remove_filter(
'gravityview_get_entries', $filter );
84 $entries = $view->get_entries( null );
87 if ( $sort = end(
$entries->sorts ) ) {
96 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry, null,
$atts );
100 if ( !
$entry = $view->get_entries( null )->first() ) {
101 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry, null,
$atts );
106 gravityview()->log->error(
'Entry #{entry_id} not found', array(
'view_id' =>
$atts[
'view_id'] ) );
107 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry, null,
$atts );
114 gravityview()->log->error(
'Field #{field_id} not found', array(
'view_id' =>
$atts[
'field_id'] ) );
115 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$field,
$atts );
118 if ( $view->form->ID !=
$entry[
'form_id'] ) {
119 gravityview()->log->error(
'Entry does not belong to view (form mismatch)' );
120 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$atts );
123 if ( post_password_required( $view->ID ) ) {
124 gravityview()->log->notice(
'Post password is required for View #{view_id}', array(
'view_id' => $view->ID ) );
125 return apply_filters(
'gravityview/shortcodes/gvfield/output', get_the_password_form( $view->ID ), $view,
$entry,
$atts );
128 if ( ! $view->form ) {
129 gravityview()->log->notice(
'View #{id} has no form attached to it.', array(
'id' => $view->ID ) );
135 if ( \
GVCommon::has_cap( array(
'edit_gravityviews',
'edit_gravityview' ), $view->ID ) ) {
136 $return = sprintf( __(
'This View is not configured properly. Start by <a href="%s">selecting a form</a>.',
'gk-gravityview' ), esc_url( get_edit_post_link( $view->ID,
false ) ) );
137 return apply_filters(
'gravityview/shortcodes/gvfield/output', $return, $view,
$entry,
$atts );
140 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$atts );
144 $public_states = get_post_stati( array(
'public' =>
true ) );
145 if ( ! in_array( $view->post_status, $public_states ) && ! \
GVCommon::has_cap(
'read_gravityview', $view->ID ) ) {
146 gravityview()->log->notice(
'The current user cannot access this View #{view_id}', array(
'view_id' => $view->ID ) );
147 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$atts );
151 if (
$entry[
'status'] !=
'active' ) {
152 gravityview()->log->notice(
'Entry ID #{entry_id} is not active', array(
'entry_id' =>
$entry->ID ) );
153 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$atts );
156 if ( $view->settings->get(
'show_only_approved' ) ) {
158 gravityview()->log->error(
'Entry ID #{entry_id} is not approved for viewing', array(
'entry_id' =>
$entry->ID ) );
159 return apply_filters(
'gravityview/shortcodes/gvfield/output',
'', $view,
$entry,
$atts );
165 $renderer = new \GV\Field_Renderer();
If this file is called directly, abort.
If this file is called directly, abort.
static by_id( $form, $field_id)
Get a by and Field ID.
gv_map_deep( $value, $callback)
Maps a function to all non-iterable elements of an array or an object.
If this file is called directly, abort.
If this file is called directly, abort.
static by_id( $post_id)
Construct a instance from a post ID.
static by_id( $field_id)
Get a from an internal Gravity Forms field ID.
if(empty( $created_by)) $form_id
gravityview()
The main GravityView wrapper function.
static by_id( $entry_id, $form_id=0)
Construct a instance by ID.
callback( $atts, $content='', $tag='')
Process and output the [gvfield] shortcode.
static is_approved( $status)
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()