PM_POPUPSHOW::automator_option_updated( $return,  $item,  $meta_key,  $meta_value )


Source

File: src/integrations/popup-maker/actions/pm-popupshow.php

	public function automator_option_updated( $return, $item, $meta_key, $meta_value ) {

		$found_it = array();

		if ( isset( $item->post_type ) && 'uo-action' === $item->post_type ) {
			if ( 'POPUPID' === $meta_key ) {

				$popup = get_post( absint( $meta_value ) );
				// update Popup triggers
				$settings = get_post_meta( $popup->ID, 'popup_settings', true );

				if ( isset( $settings['triggers'] ) ) {

					foreach ( $settings['triggers'] as $trigger ) {
						if ( 'automator' === $trigger['type'] ) {
							foreach ( $trigger['settings'] as $key => $setting ) {
								if ( 'recipe' === $key && in_array( $item->post_parent, $setting ) ) {
									$found_it = true;
								}
							}
						}
					}
				}

				if ( ! $found_it ) {
					$settings['triggers'][] = [
						'type'     => 'automator',
						'settings' => [
							'cookie_name' => '',
							'recipe'      => [ $item->post_parent ],
						],
					];

					update_post_meta( $popup->ID, 'popup_settings', $settings );
				}

				return $return;
			}
		}

		return $return;
	}