Noptin_Automation_Rule::init( object $data )

Sets up object properties.


Parameters Parameters

$data

(object) (Required) Rule DB row object.


Top ↑

Source Source

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

	public function init( $data ) {

        if ( empty( $data ) ) {
            return;
        }
        
        foreach ( get_object_vars( $data ) as $key => $var ) {
            if ( property_exists( $this, $key ) ) {
                $this->$key = $this->make_bool( maybe_unserialize( $var ) );
            }
        }

        // Fill defaults.
        $trigger = noptin()->automation_rules->get_trigger( $this->trigger_id );

        if ( ! empty( $trigger ) && is_array( $trigger->get_settings() ) ) {

            foreach ( $trigger->get_settings() as $key => $args ) {
                if ( ! isset( $this->trigger_settings[ $key ] ) && isset( $args['default'] ) ) {
                    $this->trigger_settings[ $key ] = $args['default'];
                }
            }

        }

        $action = noptin()->automation_rules->get_action( $this->action_id );

        if ( ! empty( $action ) && is_array( $action->get_settings() ) ) {

            foreach ( $action->get_settings() as $key => $args ) {
                if ( ! isset( $this->action_settings[ $key ] ) && isset( $args['default'] ) ) {
                    $this->action_settings[ $key ] = $args['default'];
                }
            }

        }

    }


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