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 | includes/custom-tables/actions.php +91 -0 5.8.3 → 6.0.3 View file →
@@ -1,0 +1,91 @@
1 +<?php
2 +/**
3 + * Actions
4 + *
5 + * @package AutomatorWP\Custom_Tables\Actions
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 +/**
13 + * Custom Table Labels
14 + *
15 + * @since 1.0.0
16 + *
17 + * @return array
18 + */
19 +function automatorwp_actions_labels() {
20 +
21 + return array(
22 + 'singular' => __( 'Action', 'automatorwp' ),
23 + 'plural' => __( 'Actions', 'automatorwp' ),
24 + );
25 +
26 +}
27 +add_filter( 'ct_automatorwp_actions_labels', 'automatorwp_actions_labels' );
28 +
29 +/**
30 + * Parse query args for actions
31 + *
32 + * @since 1.0.0
33 + *
34 + * @param string $where
35 + * @param CT_Query $ct_query
36 + *
37 + * @return string
38 + */
39 +function automatorwp_actions_query_where( $where, $ct_query ) {
40 +
41 + global $ct_table;
42 +
43 + if( $ct_table->name !== 'automatorwp_actions' ) {
44 + return $where;
45 + }
46 +
47 + $table_name = $ct_table->db->table_name;
48 +
49 + // Shorthand
50 + $qv = $ct_query->query_vars;
51 +
52 + // Type
53 + $where .= automatorwp_custom_table_where( $qv, 'type', 'type', 'string' );
54 +
55 + // Automation ID
56 + $where .= automatorwp_custom_table_where( $qv, 'automation_id', 'automation_id', 'integer' );
57 +
58 + return $where;
59 +}
60 +add_filter( 'ct_query_where', 'automatorwp_actions_query_where', 10, 2 );
61 +
62 +/**
63 + * On delete an action
64 + *
65 + * @since 1.0.0
66 + *
67 + * @param int $object_id
68 + */
69 +function automatorwp_actions_delete_object( $object_id ) {
70 +
71 + global $wpdb, $ct_table;
72 +
73 + if( ! ( $ct_table instanceof CT_Table ) ) {
74 + return;
75 + }
76 +
77 + if( $ct_table->name !== 'automatorwp_actions' ) {
78 + return;
79 + }
80 +
81 + $logs = AutomatorWP()->db->logs;
82 + $logs_meta = AutomatorWP()->db->logs_meta;
83 +
84 + // Delete all logs assigned to this action
85 + $wpdb->query( "DELETE l FROM {$logs} AS l WHERE l.object_id = {$object_id} AND l.type = 'action'" );
86 +
87 + // Delete orphaned log metas
88 + $wpdb->query( "DELETE lm FROM {$logs_meta} lm LEFT JOIN {$logs} l ON l.id = lm.id WHERE l.id IS NULL" );
89 +
90 +}
91 +add_action( 'delete_object', 'automatorwp_actions_delete_object' );