WP_USERCREATESPOST::define_trigger()
Define and register the trigger by pushing it into the Automator object
Source Source
File: src/integrations/wp/triggers/wp-usercreatespost.php
public function define_trigger() { $all_post_types = Automator()->helpers->recipe->wp->options->all_post_types( null, 'WPPOSTTYPES', array( 'token' => false, 'is_ajax' => true, 'target_field' => 'WPTAXONOMIES', 'endpoint' => 'select_post_type_taxonomies', ) ); // now get regular post types. $args = array( 'public' => true, '_builtin' => true, ); $options = array(); $options['0'] = __( 'Any post type', 'uncanny-automator' ); $post_types = get_post_types( $args, 'object' ); if ( ! empty( $post_types ) ) { foreach ( $post_types as $post_type ) { $options[ $post_type->name ] = esc_html( $post_type->labels->singular_name ); } } $options = array_merge( $options, $all_post_types['options'] ); $all_post_types['options'] = $options; $relevant_tokens = array( 'POSTTITLE' => __( 'Post title', 'uncanny-automator' ), 'POSTID' => __( 'Post ID', 'uncanny-automator' ), 'POSTURL' => __( 'Post URL', 'uncanny-automator' ), 'POSTCONTENT' => __( 'Post content', 'uncanny-automator' ), ); $trigger = array( 'author' => Automator()->get_author_name( $this->trigger_code ), 'support_link' => Automator()->get_author_support_link( $this->trigger_code, 'integration/wordpress-core/' ), 'integration' => self::$integration, 'code' => $this->trigger_code, 'sentence' => sprintf( /* translators: Logged-in trigger - WordPress */ __( 'A user publishes a {{type of:%1$s}} post with {{a taxonomy term:%2$s}} in {{a taxonomy:%3$s}}', 'uncanny-automator' ), $this->trigger_meta, 'WPTAXONOMYTERM' . ':' . $this->trigger_meta, 'WPTAXONOMIES' . ':' . $this->trigger_meta ), /* translators: Logged-in trigger - WordPress */ 'select_option_name' => esc_attr__( 'A user publishes a {{type of}} post with {{a taxonomy term}} in {{a taxonomy}}', 'uncanny-automator' ), 'action' => 'transition_post_status', 'priority' => 90, 'accepted_args' => 3, 'validation_function' => array( $this, 'post_published' ), 'options' => array(), 'options_group' => array( $this->trigger_meta => array( $all_post_types, /* translators: Noun */ Automator()->helpers->recipe->field->select_field_ajax( 'WPTAXONOMIES', esc_attr__( 'Taxonomy', 'uncanny-automator' ), array(), '', '', false, true, array( 'target_field' => 'WPTAXONOMYTERM', 'endpoint' => 'select_terms_for_selected_taxonomy', ), $relevant_tokens ), Automator()->helpers->recipe->field->select_field( 'WPTAXONOMYTERM', esc_attr__( 'Taxonomy term', 'uncanny-automator' ) ), ), ), ); Automator()->register->trigger( $trigger ); return; }
Expand full source code Collapse full source code View on Github