PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.4
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.4
6.0.4 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 All 35 releases
← All changes | integrations/geodirectory/includes/triggers/place-added.php +80 -0 5.7.2 → 6.0.4 View file →
@@ -1,0 +1,80 @@
1 +<?php
2 +
3 +/**
4 + * Place Added
5 + *
6 + * @package AutomatorWP\Integrations\GeoDirectory\Triggers\Place_Added
7 + * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
8 + * @since 1.0.0
9 + */
10 +// Exit if accessed directly
11 +if (!defined('ABSPATH')) exit;
12 +
13 +class AutomatorWP_GeoDirectory_Place_Added extends AutomatorWP_Integration_Trigger
14 +{
15 +
16 + public $integration = 'geodirectory';
17 + public $trigger = 'geodirectory_place_added';
18 +
19 + /**
20 + * Register the trigger
21 + *
22 + * @since 1.0.0
23 + */
24 + public function register()
25 + {
26 +
27 + automatorwp_register_trigger($this->trigger, array(
28 + 'integration' => $this->integration,
29 + 'label' => __( 'User adds a new place', 'automatorwp' ),
30 + 'select_option' => __( 'User adds a new <strong>place</strong>', 'automatorwp' ),
31 + /* translators: %1$s: Number of times. */
32 + 'edit_label' => sprintf( __( 'User adds a new place %1$s time(s)', 'automatorwp' ), '{times}' ),
33 + 'log_label' => __( 'User adds a new place', 'automatorwp' ),
34 + 'action' => 'geodir_post_published',
35 + 'function' => array( $this, 'listener' ),
36 + 'priority' => 10,
37 + 'accepted_args' => 2,
38 + 'options' => array(
39 + 'times' => automatorwp_utilities_times_option(),
40 + ),
41 + 'tags' => array_merge(
42 + automatorwp_utilities_post_tags(),
43 + automatorwp_utilities_times_tag()
44 + )
45 + ));
46 + }
47 +
48 + /**
49 + * Trigger listener
50 + *
51 + * @since 1.0.0
52 + *
53 + * @param array $data
54 + */
55 + public function listener($gd_post, $data)
56 + {
57 + // Bail if place id is not provided
58 + if ( empty( $data ) ) {
59 + return;
60 + }
61 +
62 + $user_id = get_current_user_id();
63 +
64 + // Bail if user is not logged
65 + if ($user_id === 0) {
66 + return;
67 + }
68 +
69 + $post_id = $gd_post->ID;
70 +
71 + automatorwp_trigger_event(array(
72 + 'trigger' => $this->trigger,
73 + 'user_id' => $user_id,
74 + 'post_id' => $post_id
75 + ));
76 + }
77 +
78 +}
79 +
80 +new AutomatorWP_GeoDirectory_Place_Added();