'wc_order_created', 'object_type' => 'wc_order', 'object_id' => (int) $order_id, 'object_title' => sprintf( '#%d', $order_id ), 'description' => sprintf( /* translators: 1: order ID, 2: formatted order total */ __( 'WooCommerce order #%1$d created (total %2$s).', 'activitypilot' ), $order_id, $order ? wp_strip_all_tags( $order->get_formatted_order_total() ) : '' ), 'severity' => 'success', 'context' => $order ? array( 'status' => $order->get_status(), 'total' => $order->get_total(), 'currency' => $order->get_currency(), 'email' => $order->get_billing_email(), ) : array(), ) ); } ); add_action( 'woocommerce_order_status_changed', function ( $order_id, $from, $to ) { APWPM_Logger::log( array( 'action_type' => 'wc_order_status', 'object_type' => 'wc_order', 'object_id' => (int) $order_id, 'object_title' => sprintf( '#%d', $order_id ), 'description' => sprintf( /* translators: 1: order ID, 2: previous status, 3: new status */ __( 'Order #%1$d status: %2$s → %3$s', 'activitypilot' ), $order_id, $from, $to ), 'severity' => 'info', 'context' => array( 'from' => $from, 'to' => $to ), ) ); }, 10, 3 ); add_action( 'woocommerce_refund_created', function ( $refund_id ) { APWPM_Logger::log( array( 'action_type' => 'wc_refund', 'object_type' => 'wc_refund', 'object_id' => (int) $refund_id, 'object_title' => sprintf( '#%d', $refund_id ), 'description' => __( 'A WooCommerce refund was issued.', 'activitypilot' ), 'severity' => 'warning', ) ); } ); add_action( 'woocommerce_update_product', function ( $product_id ) { $title = get_the_title( $product_id ); APWPM_Logger::log( array( 'action_type' => 'wc_product_updated', 'object_type' => 'product', 'object_id' => (int) $product_id, 'object_title' => $title, 'description' => sprintf( /* translators: %s: product title */ __( 'Product updated: %s', 'activitypilot' ), $title ), 'severity' => 'info', ) ); } ); } /* ---------------------- ACF ---------------------- */ protected static function acf() { if ( ! function_exists( 'acf_get_field_group' ) ) { return; } add_action( 'acf/update_field_group', function ( $group ) { APWPM_Logger::log( array( 'action_type' => 'acf_group_updated', 'object_type' => 'acf_group', 'object_id' => isset( $group['ID'] ) ? (int) $group['ID'] : 0, 'object_title' => $group['title'] ?? '', 'description' => sprintf( /* translators: %s: ACF field group title */ __( 'ACF field group "%s" updated.', 'activitypilot' ), $group['title'] ?? '' ), 'severity' => 'info', ) ); } ); add_action( 'acf/delete_field_group', function ( $group ) { APWPM_Logger::log( array( 'action_type' => 'acf_group_deleted', 'object_type' => 'acf_group', 'object_id' => isset( $group['ID'] ) ? (int) $group['ID'] : 0, 'object_title' => $group['title'] ?? '', 'description' => sprintf( /* translators: %s: ACF field group title */ __( 'ACF field group "%s" deleted.', 'activitypilot' ), $group['title'] ?? '' ), 'severity' => 'warning', ) ); } ); } /* ---------------------- WPForms ---------------------- */ protected static function wpforms() { add_action( 'wpforms_process_complete', function ( $fields, $entry, $form_data, $entry_id ) { $title = $form_data['settings']['form_title'] ?? ( $form_data['settings']['form_name'] ?? '' ); APWPM_Logger::log( array( 'action_type' => 'wpforms_submission', 'object_type' => 'form', 'object_id' => (int) $entry_id, 'object_title' => $title, 'description' => sprintf( /* translators: %s: form title */ __( 'WPForms submission received for "%s".', 'activitypilot' ), $title ), 'severity' => 'info', ) ); }, 10, 4 ); } /* ---------------------- Gravity Forms ---------------------- */ protected static function gravity_forms() { add_action( 'gform_after_submission', function ( $entry, $form ) { APWPM_Logger::log( array( 'action_type' => 'gravity_submission', 'object_type' => 'form', 'object_id' => isset( $entry['id'] ) ? (int) $entry['id'] : 0, 'object_title' => $form['title'] ?? '', 'description' => sprintf( /* translators: %s: form title */ __( 'Gravity Forms submission received for "%s".', 'activitypilot' ), $form['title'] ?? '' ), 'severity' => 'info', ) ); }, 10, 2 ); } /* ---------------------- Contact Form 7 ---------------------- */ protected static function contact_form_7() { add_action( 'wpcf7_mail_sent', function ( $contact_form ) { $title = $contact_form && method_exists( $contact_form, 'title' ) ? $contact_form->title() : ''; APWPM_Logger::log( array( 'action_type' => 'cf7_submission', 'object_type' => 'form', 'object_title' => $title, 'description' => sprintf( /* translators: %s: form title */ __( 'CF7 form "%s" submission email sent.', 'activitypilot' ), $title ), 'severity' => 'info', ) ); } ); } /* ---------------------- SEO plugins ---------------------- */ protected static function seo() { $yoast_options = array( 'wpseo', 'wpseo_titles', 'wpseo_social', 'wpseo_internallinks' ); foreach ( $yoast_options as $opt ) { add_action( "update_option_{$opt}", function ( $old, $new ) use ( $opt ) { APWPM_Logger::log( array( 'action_type' => 'seo_setting_updated', 'object_type' => 'seo_option', 'object_title' => $opt, 'description' => sprintf( /* translators: %s: option name */ __( 'Yoast SEO option "%s" was updated.', 'activitypilot' ), $opt ), 'severity' => 'info', 'context' => array( 'plugin' => 'yoast', 'option' => $opt ), ) ); }, 10, 2 ); } $rank_options = array( 'rank-math-options-general', 'rank-math-options-titles', 'rank-math-options-sitemap' ); foreach ( $rank_options as $opt ) { add_action( "update_option_{$opt}", function ( $old, $new ) use ( $opt ) { APWPM_Logger::log( array( 'action_type' => 'seo_setting_updated', 'object_type' => 'seo_option', 'object_title' => $opt, 'description' => sprintf( /* translators: %s: option name */ __( 'Rank Math option "%s" was updated.', 'activitypilot' ), $opt ), 'severity' => 'info', 'context' => array( 'plugin' => 'rank-math', 'option' => $opt ), ) ); }, 10, 2 ); } } /* ---------------------- Builders ---------------------- */ protected static function builders() { // Elementor. add_action( 'elementor/document/after_save', function ( $document, $data ) { if ( ! method_exists( $document, 'get_main_id' ) ) { return; } $post_id = $document->get_main_id(); APWPM_Logger::log( array( 'action_type' => 'elementor_save', 'object_type' => 'elementor_doc', 'object_id' => (int) $post_id, 'object_title' => get_the_title( $post_id ), 'description' => sprintf( /* translators: %s: post title */ __( 'Elementor saved post "%s".', 'activitypilot' ), get_the_title( $post_id ) ), 'severity' => 'info', ) ); }, 10, 2 ); // Divi. add_action( 'et_save_post', function ( $post_id ) { APWPM_Logger::log( array( 'action_type' => 'divi_save', 'object_type' => 'divi_layout', 'object_id' => (int) $post_id, 'object_title' => get_the_title( $post_id ), 'description' => sprintf( /* translators: %s: post title */ __( 'Divi builder saved "%s".', 'activitypilot' ), get_the_title( $post_id ) ), 'severity' => 'info', ) ); } ); // Gutenberg reusable blocks. add_action( 'save_post_wp_block', function ( $post_id, $post, $update ) { APWPM_Logger::log( array( 'action_type' => $update ? 'block_updated' : 'block_created', 'object_type' => 'block', 'object_id' => (int) $post_id, 'object_title' => $post->post_title, 'description' => sprintf( /* translators: 1: block title, 2: action (created or updated) */ __( 'Reusable block "%1$s" was %2$s.', 'activitypilot' ), $post->post_title, $update ? 'updated' : 'created' ), 'severity' => 'info', ) ); }, 10, 3 ); } }