Documentation / Tutorials / Quick Samples

Samples for using conditionals c. in shortcodes

/ Quick Samples / Samples for using conditionals c. in shortcodes

As we use if.* shortcodes in Awesome Enterprise, similarly we can use conditionals using “c.” within individual shortcodes to decide when they will get executed.

Here is a quick list of all the samples for using “c.*” conditions. These are Strict Checks, which means we match both the Value and the Datatype. if needed you can explicitly set the datatype.

Conditions for checking Equal & Not Equal

Conditions for checking Greater than & Less than

Conditions for checking Null

These checks use the is_null function of PHP

Conditions for checking Whitespaces

Conditions for checking Empty

It internally uses empty PHP function.

Conditions for checking Exists

Conditions for checking Contains

This is not a strict check, so it will not check for datatypes.

Conditions for checking User

This conditional can be used to check the capability of the current user. Behind the scene, it uses current_user_can WordPress function, so you can also check user capabilities. In the case of logged_in the “yes” is irrelevant, you can write “x” and it will still behave the same.

Conditions for checking Yes/No, True/False,  Odd/Even

As mentioned above they check for the data type as well, so yes/no is string comparison while true/false is bool and odd/even is an int comparison. You will have to cast them appropriately when doing the comparisons.

Conditions for checking Datatypes

Conditions for checking Device

This uses Mobile_Detect PHP class to check for the device.

Conditions for and.* & or.*

We can combine checks together using add.* & or.* conditionals as shown in examples below

Conditions for ignore

you can ignore the execution of any awesome shortcode by using c.ignore=yes, here “yes” is just a filler, to avoid the limitation of shortcode attributes.

 

Categories
Most Popular

Leave a Reply

Your email address will not be published.