Noptin_Automation_Rule::get_rule( int $id )

Retrieves a rule from the database or cache.


Parameters Parameters

$id

(int) (Required) The rule id.


Top ↑

Source Source

File: includes/automation-rules/class-noptin-automation-rule.php

	public static function get_rule( $id ) {
        global $wpdb;

        $rule  = wp_cache_get( $id, 'noptin_automation_rules' );

        if ( ! empty( $rule ) ) {
            return $rule;
        }

        $table = noptin()->automation_rules->get_table();
		$rule  = $wpdb->get_row(
			$wpdb->prepare(
				"SELECT * FROM $table WHERE id = %d LIMIT 1",
				$id
			)
        );
        
        if ( ! empty( $rule ) ) {
            wp_cache_set( $rule->id, $rule, 'noptin_automation_rules', 10 );
        }
        
        return $rule;

    }


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.8Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation