WP_VIEWPAGE::view_page()
Validation function when the trigger action is hit
Source Source
File: src/integrations/wp/triggers/wp-viewpage.php
public function view_page() { global $post; // Bail out if the page is not of a post type 'page'. if ( ! is_singular( 'page' ) ) { return; } // Bail out if post id is null. if ( ! isset ( $post->ID ) ) { return; } // Return if post id is zero or empty. Some plugins like BuddyPress overwrites post id. if ( empty( $post->ID ) ) { return; } if ( is_user_logged_in() ) { $user_id = get_current_user_id(); $args = [ 'code' => $this->trigger_code, 'meta' => $this->trigger_meta, 'post_id' => $post->ID, 'user_id' => $user_id, ]; if ( isset( Automator()->process ) && isset( Automator()->process->user ) && Automator()->process->user instanceof Automator_Recipe_Process_User ) { $arr = Automator()->process->user->maybe_add_trigger_entry( $args, false ); } else { $arr = Automator()->maybe_add_trigger_entry( $args, false ); } if ( $arr ) { foreach ( $arr as $result ) { if ( true === $result['result'] ) { if ( isset( Automator()->process ) && isset( Automator()->process->user ) && Automator()->process->user instanceof Automator_Recipe_Process_User ) { Automator()->process->user->maybe_trigger_complete( $result['args'] ); } else { Automator()->maybe_trigger_complete( $result['args'] ); } } } } } }
Expand full source code Collapse full source code View on Github