PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
← All changes | integrations/automatorwp/automations/all-posts.php +69 -0 5.7.2 → 6.0.3 View file →
@@ -1,0 +1,69 @@
1 +<?php
2 +/**
3 + * All Posts
4 + *
5 + * @package AutomatorWP\Integrations\WordPress\Automations\All_Posts
6 + * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.0.0
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +class AutomatorWP_All_Posts_Automation extends AutomatorWP_Automation_Loop {
13 +
14 + public $integration = 'automatorwp';
15 + public $type = 'all-posts';
16 +
17 + public function register() {
18 +
19 + // Automation type args
20 + $this->args = array(
21 + 'image' => AUTOMATORWP_URL . 'assets/img/automatorwp-all-posts-logo.svg',
22 + 'label' => __( 'All posts', 'automatorwp' ),
23 + 'desc' => __( 'Run actions on a filtered group of posts.', 'automatorwp' ),
24 + // Automation loop specific args
25 + 'labels' => array(
26 + 'singular' => __( 'Post', 'automatorwp' ),
27 + 'plural' => __( 'Posts', 'automatorwp' ),
28 + ),
29 + 'required_trigger' => 'automatorwp_all_posts',
30 + );
31 + }
32 +
33 + public function process_items( $items_ids, $automation, $trigger, $trigger_options ) {
34 +
35 + global $automatorwp_event;
36 +
37 + // Set up a false event since the following functions require it
38 + $automatorwp_event = array(
39 + 'post_id' => 0,
40 + 'user_id' => 0,
41 + );
42 +
43 + foreach ( $items_ids as $item_id ) {
44 +
45 + $post_id = absint( $item_id );
46 + $user_id = absint( get_post_field( 'post_author', $post_id ) );
47 + $automatorwp_event['post_id'] = $post_id;
48 + $automatorwp_event['user_id'] = $user_id;
49 +
50 + foreach( $trigger_options as $option => $value ) {
51 + // Replace all tags by their replacements
52 + $trigger_options[$option] = automatorwp_parse_automation_tags( $automation->id, $user_id, $value );
53 + }
54 +
55 + // Check if user deserves the trigger filters
56 + if( ! automatorwp_user_deserves_trigger_filters( $trigger, $user_id, $automatorwp_event, $trigger_options, $automation ) ) {
57 + continue;
58 + }
59 +
60 + // Execute all automation actions
61 + automatorwp_execute_all_automation_actions( $automation, $user_id, $automatorwp_event );
62 +
63 + }
64 +
65 + }
66 +
67 +}
68 +
69 +new AutomatorWP_All_Posts_Automation();