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
automatorwp / integrations / wp-all-import / includes / triggers / import-success.php

import-success.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.3, at integrations/wp-all-import/includes/triggers/import-success.php

140 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * File Downloaded
4 *
5 * @package AutomatorWP\Integrations\WP_All_Import\Triggers\Import_Success
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_WP_All_Import_Success extends AutomatorWP_Integration_Trigger {
13
14 public $integration = 'wp_all_import';
15 public $trigger = 'wp_all_import_success';
16
17 /**
18 * Register the trigger
19 *
20 * @since 1.0.0
21 */
22 public function register() {
23
24 automatorwp_register_trigger( $this->trigger, array(
25 'integration' => $this->integration,
26 'label' => __( 'User completes an import', 'automatorwp' ),
27 'select_option' => __( 'User <strong>completes</strong> an import', 'automatorwp' ),
28 /* translators: %1$s: %1$s: Number of times. */
29 'edit_label' => sprintf( __( 'User completes an import %1$s time(s)', 'automatorwp' ), '{times}' ),
30 'log_label' => __( 'User completes an import', 'automatorwp' ),
31 'action' => 'pmxi_after_xml_import',
32 'function' => array( $this, 'listener' ),
33 'priority' => 10,
34 'accepted_args' => 2,
35 'options' => array(
36 'times' => automatorwp_utilities_times_option(),
37 ),
38 'tags' => array_merge(
39 automatorwp_wp_all_import_tags(),
40 automatorwp_utilities_times_tag()
41 )
42 ) );
43
44 }
45
46 /**
47 * Trigger listener
48 *
49 * @since 1.0.0
50 *
51 * @param int $import_id
52 * @param object $import
53 *
54 */
55 public function listener( $import_id, $import ) {
56
57 $user_id = get_current_user_id();
58
59 // Bail if user is not logged
60 if ($user_id === 0) {
61 return;
62 }
63
64 if ( empty( $import_id ) ) {
65 return false;
66 }
67
68 $history = automatorwp_wp_all_import_get_services( $import_id );
69
70 foreach ( $history as $tags ) {
71 $history_id = $tags['id'];
72 $import_type = $tags['type'];
73 $import_time_run = $tags['time_run'];
74 $import_date = $tags['date'];
75 $import_summary = $tags['summary'];
76 }
77
78 // Trigger import completed
79 automatorwp_trigger_event( array(
80 'trigger' => $this->trigger,
81 'user_id' => $user_id,
82 'import_id' => $import_id,
83 'history_id' => $history_id,
84 'import_type' => $import_type,
85 'import_time_run' => $import_time_run,
86 'import_date' => $import_date,
87 'import_summary' => $import_summary,
88 ) );
89
90 }
91
92 /**
93 * Register the required hooks
94 *
95 * @since 1.0.0
96 */
97 public function hooks() {
98
99 // Log meta data
100 add_filter( 'automatorwp_user_completed_trigger_log_meta', array( $this, 'log_meta' ), 10, 6 );
101
102 parent::hooks();
103 }
104
105 /**
106 * Trigger custom log meta
107 *
108 * @since 1.0.0
109 *
110 * @param array $log_meta Log meta data
111 * @param stdClass $trigger The trigger object
112 * @param int $user_id The user ID
113 * @param array $event Event information
114 * @param array $trigger_options The trigger's stored options
115 * @param stdClass $automation The trigger's automation object
116 *
117 * @return array
118 */
119 function log_meta( $log_meta, $trigger, $user_id, $event, $trigger_options, $automation ) {
120
121 // Bail if action type don't match this action
122 if( $trigger->type !== $this->trigger ) {
123 return $log_meta;
124 }
125
126 $log_meta['import_id'] = ( isset( $event['import_id'] ) ? $event['import_id'] : '' );
127 $log_meta['history_id'] = ( isset( $event['history_id'] ) ? $event['history_id'] : '' );
128 $log_meta['import_type'] = ( isset( $event['import_type'] ) ? $event['import_type'] : '' );
129 $log_meta['import_time_run'] = ( isset( $event['import_time_run'] ) ? $event['import_time_run'] : '' );
130 $log_meta['import_date'] = ( isset( $event['import_date'] ) ? $event['import_date'] : '' );
131 $log_meta['import_summary'] = ( isset( $event['import_summary'] ) ? $event['import_summary'] : '' );
132
133 return $log_meta;
134
135 }
136
137 }
138
139
140 new AutomatorWP_WP_All_Import_Success();