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/wordpress/actions/delete-post.php +81 -0 5.8.4 → 6.0.3 View file →
@@ -1,0 +1,81 @@
1 +<?php
2 +/**
3 + * Delete Post
4 + *
5 + * @package AutomatorWP\Integrations\WordPress\Actions\Delete_Post_Action
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_WordPress_Delete_Post_Action extends AutomatorWP_Integration_Action {
13 +
14 + /**
15 + * Initialize the trigger
16 + *
17 + * @since 1.0.0
18 + */
19 + public function __construct( $integration ) {
20 +
21 + $this->integration = $integration;
22 + $this->action = $integration . '_delete_post_action';
23 +
24 + parent::__construct();
25 +
26 + }
27 +
28 + /**
29 + * Register the trigger
30 + *
31 + * @since 1.0.0
32 + */
33 + public function register() {
34 +
35 + automatorwp_register_action( $this->action, array(
36 + 'integration' => $this->integration,
37 + 'label' => __( 'Delete a post', 'automatorwp' ),
38 + 'select_option' => __( 'Delete <strong>a post</strong>', 'automatorwp' ),
39 + /* translators: %1$s: Post. */
40 + 'edit_label' => sprintf( __( 'Delete %1$s', 'automatorwp' ), '{post}' ),
41 + /* translators: %1$s: Post. */
42 + 'log_label' => sprintf( __( 'Delete %1$s', 'automatorwp' ), '{post}' ),
43 + 'options' => array(
44 + 'post' => automatorwp_utilities_post_option( array(
45 + 'post_type' => 'any',
46 + 'option_none_label' => __( 'any post', 'automatorwp' ),
47 + 'option_custom' => true,
48 + 'option_custom_desc' => __( 'Post ID', 'automatorwp' ),
49 + ) )
50 + ),
51 + ) );
52 +
53 + }
54 +
55 + /**
56 + * Action execution function
57 + *
58 + * @since 1.0.0
59 + *
60 + * @param stdClass $action The action object
61 + * @param int $user_id The user ID
62 + * @param array $action_options The action's stored options (with tags already passed)
63 + * @param stdClass $automation The action's automation object
64 + */
65 + public function execute( $action, $user_id, $action_options, $automation ) {
66 +
67 + $post_id = absint( $action_options['post'] );
68 +
69 + // Bail if not post ID provided
70 + if( $post_id === 0 ) {
71 + return;
72 + }
73 +
74 + wp_delete_post( $post_id, true );
75 +
76 + }
77 +
78 +}
79 +
80 +new AutomatorWP_WordPress_Delete_Post_Action( 'wordpress' );
81 +new AutomatorWP_WordPress_Delete_Post_Action( 'posts' );