5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
27 parent::add(
'gvlogic2' );
28 parent::add(
'gvlogic3' );
29 parent::add(
'gvlogicelse' );
44 if ( $request->is_admin() ) {
45 return apply_filters(
'gravityview/shortcodes/gvlogic/output',
'',
$atts );
58 gravityview()->log->error(
'$atts->if/logged_in is empty.', array(
'data' =>
$atts ) );
59 return apply_filters(
'gravityview/shortcodes/gvlogic/output',
'',
$atts );
66 if (
false === $operator && is_null(
$value ) ) {
67 if (
false !==
$atts[
'if'] ) {
68 $match = $authed && ! in_array( strtolower(
$atts[
'if'] ), array(
'',
'0',
'false',
'no' ) );
79 $and_values = explode(
'&&',
$value );
80 $or_values = explode(
'||',
$value );
83 if (
sizeof( $and_values ) > 1 ) {
86 foreach ( $and_values as $and_value ) {
93 } elseif (
sizeof( $or_values ) > 1 ) {
96 foreach ( $or_values as $or_value ) {
101 if ( ( $authed && $match ) || ( $authed && ( ! $match && in_array( $operator, array(
'isnot',
'not_contains',
'not_in' ) ) ) ) ) {
116 $output = \GFCommon::replace_variables(
$output, array(), array(),
false,
true,
false );
118 return apply_filters(
'gravityview/shortcodes/gvlogic/output',
$output,
$atts );
132 if ( is_null( $needs_login ) ) {
136 return ! $needs_login ^ is_user_logged_in();
150 if ( in_array( $op, array(
'if',
'else' ) ) ) {
154 if ( in_array( $op, $valid_ops,
true ) ) {
173 if ( in_array( $op, array(
'if',
'else' ) ) ) {
177 if ( in_array( $op, $valid_ops,
true ) ) {
195 if ( ! $match && ! empty(
$atts[
'else'] ) ) {
196 return $atts[
'else'];
207 if ( ! preg_match(
'#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s',
$content, $matches ) ) {
216 list( $_, $before_shortcode, $shortcode, $_, $after_shortcode ) = $matches;
219 $if .= $before_shortcode;
221 $else .= $before_shortcode;
224 if ( 0 === strpos( $shortcode,
'[else]' ) && 0 === $opens ) {
230 }
else if ( $match && 0 === strpos( $shortcode,
'[else if' ) && 0 === $opens ) {
235 if ( 0 === strpos( $shortcode,
'[gvlogic' ) ) {
239 if ( 0 === strpos( $shortcode,
'[/gvlogic' ) ) {
254 gravityview()->log->debug(
'[gvlogic] output parsing:', array(
262 while ( ( $position = strpos( $if,
'[else if=' ) ) !==
false ) {
264 $sentinel = wp_generate_password( 32,
false );
265 $if = substr( $if, $position );
267 $result = do_shortcode( preg_replace(
'#\[else if#',
'[gvlogic if', $if, 1 ) .
"[else]{$sentinel}[/gvlogic]" );
268 if ( $result !== $sentinel ) {
272 $if = substr( $if, 1 );
276 return $match ? $if : $else;
288 'is',
'isnot',
'contains',
'starts_with',
'ends_with',
289 'greater_than',
'less_than',
'in',
'not_in',
290 'contains',
'equals',
'greater_than_or_is',
'greater_than_or_equals',
291 'less_than_or_is',
'less_than_or_equals',
'not_contains',
294 if ( $with_values ) {
295 return array_combine(
297 array_fill( 0, count( $operators ),
'' )
311 $supplied_atts = ! empty(
$atts ) ?
$atts : array();
313 $atts = shortcode_atts( array(
320 $atts = array_intersect_key( $supplied_atts,
$atts );
323 if ( isset(
$atts[
'if'] ) && is_string(
$atts[
'if'] ) ) {
329 if ( isset(
$atts[
'logged_in'] ) ) {
331 if ( in_array( strtolower(
$atts[
'logged_in'] ), array(
'0',
'false',
'no' ) ) ) {
332 $atts[
'logged_in'] =
false;
334 $atts[
'logged_in'] =
true;
345 return apply_filters(
'gravityview/gvlogic/atts',
$atts );
callback( $atts, $content='', $tag='')
Process and output the [gvfield] shortcode.
authorized( $atts)
Are we authorized to follow the if path?
If this file is called directly, abort.
static matches_operation( $val1, $val2, $operation)
Wrapper for the GFFormsModel::matches_operation() method that adds additional comparisons, including: 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains', 'in', and 'not_in'.
get_operators( $with_values=false)
Get array of supported operators.
get_value( $atts)
Fetch the value.
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.
get_operator( $atts)
Fetch the operator.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
get_output( $match, $atts, $content)
Get the output content.
gravityview()
The main GravityView wrapper function.
parse_atts( $atts, $content, $tag)
Process the attributes passed to the shortcode.