GravityView  1.22.6
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Static Private Attributes
GVLogic_Shortcode Class Reference

Shortcode to handle showing/hiding content in merge tags. More...

Public Member Functions

 shortcode ( $atts=array(), $content=NULL, $shortcode_tag='')
 

Static Public Member Functions

static get_instance ()
 Instantiate! More...
 

Data Fields

 $atts = array()
 
 $comparison = ''
 
 $content = ''
 
 $else_content = ''
 
 $if = ''
 
 $is_match = false
 
 $operation = 'is'
 
 $passed_atts
 
 $passed_content
 
 $shortcode = 'gvlogic'
 

Private Member Functions

 __construct ()
 Add the WordPress hooks. More...
 
 add_hooks ()
 Register the shortcode. More...
 
 get_operators ( $with_values=false)
 Get array of supported operators. More...
 
 get_output ()
 Get the output for the shortcode, based on whether there's a matched value. More...
 
 parse_atts ()
 Process the attributes passed to the shortcode. More...
 
 process_elseif ( $before_else)
 Handle additional conditional logic inside the [else] pseudo-shortcode. More...
 
 set_content_and_else_content ()
 Check for [else] tag inside the shortcode content. More...
 
 set_is_match ()
 Does the if and the comparison match? GVCommon::matches_operation. More...
 
 set_operation ( $operation='')
 Set the operation for the shortcode. More...
 
 setup_operation_and_comparison ()
 Set the operation and comparison for the shortcode. More...
 

Static Private Attributes

static $instance
 
static $SUPPORTED_ARRAY_OPERATORS = array( 'in', 'not_in', 'isnot', 'contains' )
 
static $SUPPORTED_CUSTOM_OPERATORS = array( 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains' )
 
static $SUPPORTED_NUMERIC_OPERATORS = array( 'greater_than', 'less_than' )
 
static $SUPPORTED_SCALAR_OPERATORS = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' )
 

Detailed Description

Shortcode to handle showing/hiding content in merge tags.

Works great with GravityView Custom Content fields

Definition at line 6 of file class-gvlogic-shortcode.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
private

Add the WordPress hooks.

Returns
void

Definition at line 99 of file class-gvlogic-shortcode.php.

References add_hooks().

Member Function Documentation

◆ add_hooks()

add_hooks ( )
private

Register the shortcode.

Returns
void

Definition at line 107 of file class-gvlogic-shortcode.php.

Referenced by __construct().

◆ get_instance()

static get_instance ( )
static

Instantiate!

Returns
GVLogic_Shortcode

Definition at line 86 of file class-gvlogic-shortcode.php.

Referenced by parse_atts().

◆ get_operators()

get_operators (   $with_values = false)
private

Get array of supported operators.

Parameters
bool$with_values
Returns
array

Definition at line 118 of file class-gvlogic-shortcode.php.

Referenced by parse_atts(), and set_operation().

◆ get_output()

get_output ( )
private

Get the output for the shortcode, based on whether there's a matched value.

Returns
string HTML/Text output of the shortcode
Runs Filter:
gravityview/gvlogic/output Modify the [gvlogic] output
Parameters
string$outputHTML/text output
GVLogic_Shortcode$thisThis class

Definition at line 253 of file class-gvlogic-shortcode.php.

References $content, $else_content, and $output.

Referenced by shortcode().

◆ parse_atts()

parse_atts ( )
private

Process the attributes passed to the shortcode.

Make sure they're valid

Returns
void
Runs Actions:
gravityview/gvlogic/parse_atts/after Modify shortcode attributes after it's been parsed
See also
https://gist.github.com/zackkatz/def9b295b80c4ae109760ffba200f498 for an example
Since
1.21.5
Parameters
GVLogic_Shortcode$thisThe GVLogic_Shortcode instance

Definition at line 364 of file class-gvlogic-shortcode.php.

References $atts, get_instance(), get_operators(), and shortcode().

Referenced by shortcode().

◆ process_elseif()

process_elseif (   $before_else)
private

Handle additional conditional logic inside the [else] pseudo-shortcode.

Since
1.21.2
Parameters
string$before_elseShortcode content before the [else] tag (if it exists)
Returns
bool|string False: No [else if] statements found. Otherwise, return the matched content.

Definition at line 317 of file class-gvlogic-shortcode.php.

Referenced by set_content_and_else_content().

◆ set_content_and_else_content()

set_content_and_else_content ( )
private

Check for [else] tag inside the shortcode content.

If exists, set the else_content variable. If not, use the else attribute passed by the shortcode, if exists.

Returns
void

Definition at line 286 of file class-gvlogic-shortcode.php.

References $else_content, $passed_content, and process_elseif().

Referenced by shortcode().

◆ set_is_match()

set_is_match ( )
private

Does the if and the comparison match? GVCommon::matches_operation.

Returns
void

Definition at line 244 of file class-gvlogic-shortcode.php.

References GVCommon\matches_operation().

Referenced by shortcode().

◆ set_operation()

set_operation (   $operation = '')
private

Set the operation for the shortcode.

Parameters
string$operation
Returns
bool True: it's an allowed operation type and was added. False: invalid operation type

Definition at line 139 of file class-gvlogic-shortcode.php.

References $operation, and get_operators().

Referenced by setup_operation_and_comparison().

◆ setup_operation_and_comparison()

setup_operation_and_comparison ( )
private

Set the operation and comparison for the shortcode.

Loop through each attribute passed to the shortcode and see if it's a valid operator. If so, set it. Example: [gvlogic if="{example}" greater_than="5"] greater_than will be set as the operator 5 will be set as the comparison value

Returns
bool True: we've got an operation and comparison value; False: no, we don't

Definition at line 166 of file class-gvlogic-shortcode.php.

References $value, and set_operation().

Referenced by shortcode().

◆ shortcode()

shortcode (   $atts = array(),
  $content = NULL,
  $shortcode_tag = '' 
)
Parameters
array$attsUser defined attributes in shortcode tag.
null$content
string$shortcode_tag
Returns
string|null

Deprecated in favor of gravityview()->request->is_admin().

Definition at line 188 of file class-gvlogic-shortcode.php.

References $atts, $content, $output, get_output(), gravityview(), GravityView_Plugin\is_admin(), parse_atts(), set_content_and_else_content(), set_is_match(), and setup_operation_and_comparison().

Referenced by parse_atts().

Field Documentation

◆ $atts

$atts = array()

Definition at line 32 of file class-gvlogic-shortcode.php.

Referenced by parse_atts(), and shortcode().

◆ $comparison

$comparison = ''

Definition at line 63 of file class-gvlogic-shortcode.php.

◆ $content

$content = ''

Definition at line 38 of file class-gvlogic-shortcode.php.

Referenced by get_output(), and shortcode().

◆ $else_content

$else_content = ''

Definition at line 45 of file class-gvlogic-shortcode.php.

Referenced by get_output(), and set_content_and_else_content().

◆ $if

$if = ''

Definition at line 57 of file class-gvlogic-shortcode.php.

◆ $instance

$instance
staticprivate

Definition at line 80 of file class-gvlogic-shortcode.php.

◆ $is_match

$is_match = false

Definition at line 75 of file class-gvlogic-shortcode.php.

◆ $operation

$operation = 'is'

Definition at line 69 of file class-gvlogic-shortcode.php.

Referenced by set_operation().

◆ $passed_atts

$passed_atts

Definition at line 20 of file class-gvlogic-shortcode.php.

◆ $passed_content

$passed_content

Definition at line 26 of file class-gvlogic-shortcode.php.

Referenced by set_content_and_else_content().

◆ $shortcode

$shortcode = 'gvlogic'

Definition at line 51 of file class-gvlogic-shortcode.php.

◆ $SUPPORTED_ARRAY_OPERATORS

$SUPPORTED_ARRAY_OPERATORS = array( 'in', 'not_in', 'isnot', 'contains' )
staticprivate

Definition at line 12 of file class-gvlogic-shortcode.php.

◆ $SUPPORTED_CUSTOM_OPERATORS

$SUPPORTED_CUSTOM_OPERATORS = array( 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains' )
staticprivate

Definition at line 14 of file class-gvlogic-shortcode.php.

◆ $SUPPORTED_NUMERIC_OPERATORS

$SUPPORTED_NUMERIC_OPERATORS = array( 'greater_than', 'less_than' )
staticprivate

Definition at line 10 of file class-gvlogic-shortcode.php.

◆ $SUPPORTED_SCALAR_OPERATORS

$SUPPORTED_SCALAR_OPERATORS = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' )
staticprivate

Definition at line 8 of file class-gvlogic-shortcode.php.


The documentation for this class was generated from the following file: