12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Sep 24, 2019

How to register a custom condition in a functionality plugin

Sridhar Katakam

The code given in the official Oxygen documentation as well as in all the tutorials on this site for registering custom conditions is supposed to be added as a Code Snippet.

There could be times when you want to instead have this code coming from a functionality plugin like My Custom Functionality.

This members-only tutorial provides information on how to register an Oxygen condition from a plugin.

If we take the Is Mobile condition as an example, you would need to change

if ( function_exists( 'oxygen_vsb_register_condition' ) ) {

	if ( ! class_exists( 'Mobile_Detect' ) ) {
		return;
	}

	oxygen_vsb_register_condition(
		// Condition Name
		'Is Mobile',

		// Values: The array of pre-set values the user can choose from.
		// Set the custom key's value to true to allow users to input custom values.
		array( 
			'options' => array( 'true', 'false' ),
			'custom' => false
		),

		// Operators
		array( '==' ),
		
		// Callback Function: Name of function that will be used to handle the condition
		'wpdd_is_mobile_fallback',

		// Condition Category: Default ones are Archive, Author, Other, Post, User
		'Other'
	);

}

to

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right