aw2_if

This shortcode is used to check conditions and execute blocks wrapped inside it . aw2_if can be thought as an equivalent to ‘if(x=y){}’. It provides us with basic ability to execute conditional block within our modules.

All these conditions can also be applied to other shortcodes directly,as a shortcut, and they execute if conditions are true.

aw2_if provides two ways to do conditional checks, direct check shortcuts

attributes:

  • true:
    Used to see if value specified is true, ‘true’ or 1.
  • false:
    Used to see if value specified is false,’false’, 0 or null.
  • odd:
    Used to see if value specified is Odd.
  • even:
    Used to see if value specified is Odd.
  • empty:
    Check if value specified is empty.
  • not_empty:
    Checks if value specified is not empty.
  • request_exists:
    Checks if value specified is present within $_REQUEST or WordPress query_var.
  • request_not_exists:
    Checks if value specified is not present within $_REQUEST or query_var.
  • param_exists:
    Checks if value specified is set using aw2_set_param.
  • param_not_exists:
    Checks if value specified is not set using aw2_set_param.
  • current_user_can:
    You can check if current user has capabilites to perform certain action, it uses WordPress function current_user_can to checck, if user has the capabilites, shortcode is executed.
  • current_user_cant:
    You can check if current user does not have capabilites to perform certain action, it uses WordPress function current_user_can to checck, if user does have the capabilites, shortcode is executed.

Examples of using aw2_if

We also have option to do comparisons between two expression by evaluation of shortcodes with aw2_if.

attributes:

  • cond,equal:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘equal’. If they are euqal shortcode is executed.
  • cond,not_equal:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘not_equal’. If they are not equal shortcode is executed.
  • cond,greater:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘greater’. If they are greater, shortcode is executed.
  • cond,less:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘less’. If they are less, shortcode is executed.
  • cond,greaterequal:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘greaterequal’. If they are ‘greater then or equal’, shortcode is executed.
  • cond,lessequal:
    Value specified to ‘cond’ evaluated and compared against value specified to ‘lessequal’. If they are ‘less then or equal’, shortcode is executed.
  • terms,equal:
    Used to check if in a comma separated string one of the values is there. Primarily used for checking presence of a term within taxonomy terms
  • terms,not_equal :
    Used to check if a value is not present in a comma separated string given to terms. Primarily used for checking presence of a term within taxonomy terms.

Examples