useDeactivationFeedback(); /** * Fire-and-forget lifecycle event to PackEdge (install/uninstall counts). * Carries only the plugin/WP/PHP version (no personal or site data) so it * needs no analytics consent. Non-blocking; never affects activation. * * @param string $event Event name (e.g. product.installed). * @param array $properties Optional extra properties. * @return void */ function ajaxpress_packedge_event( $event, $properties = array() ) { wp_remote_post( AJAXPRESS_PACKEDGE_API . '/public/v1/event', array( 'timeout' => 4, 'blocking' => false, 'headers' => array( 'Content-Type' => 'application/json' ), 'body' => wp_json_encode( array( 'public_key' => AJAXPRESS_PACKEDGE_PUBLIC_KEY, 'event' => $event, 'slug' => AJAXPRESS_PACKEDGE_SLUG, 'site' => wp_parse_url( home_url(), PHP_URL_HOST ), 'properties' => array_merge( array( 'version' => AJAXPRESS_VERSION, 'wp_version' => get_bloginfo( 'version' ), 'php_version' => phpversion(), ), (array) $properties ), ) ), ) ); } /** * Plugin activation hook. * Reset diagnostic permission on activation. * * @return void */ function ajaxpress_plugin_activation() { delete_option( 'ajaxpress_diagnostic_permission' ); // Lifecycle install count (always; no personal data, no consent needed). ajaxpress_packedge_event( 'product.installed' ); // Reset tour state for all users on activation. delete_metadata( 'user', 0, 'ajaxpress_tour_completed', '', true ); delete_metadata( 'user', 0, 'ajaxpress_tour_mode', '', true ); delete_metadata( 'user', 0, 'ajaxpress_tour_dismissed_at', '', true ); // Ensure classes are loaded. if ( ! class_exists( '\AjaxPress\Options' ) ) { require_once __DIR__ . '/includes/common/abstract-class-base.php'; require_once __DIR__ . '/includes/common/class-options.php'; } // Reset premium settings if license is not active. $license = get_option( 'ajaxpress_license', [] ); $is_license_active = ! empty( $license['key'] ) && 'active' === ( isset( $license['status'] ) ? $license['status'] : '' ); if ( ! $is_license_active ) { $options = new \AjaxPress\Options(); $options->reset_premium_settings(); } } register_activation_hook( AJAXPRESS, 'ajaxpress_plugin_activation' ); /** * Plugin deactivation hook - lifecycle uninstall count. The deactivation modal * (deactivate.js) handles the optional reason as feedback; this just records the * count so analytics don't depend on the user going through the modal. * * @return void */ function ajaxpress_plugin_deactivation() { // The SDK deactivation modal appends ?packedge_dm=1 and sends its own // (richer) uninstalled event; skip here to avoid double-counting. if ( isset( $_REQUEST['packedge_dm'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only marker, not a state change. return; } ajaxpress_packedge_event( 'product.uninstalled' ); } register_deactivation_hook( AJAXPRESS, 'ajaxpress_plugin_deactivation' ); /** * Manipulating the plugin will NOT allow you * to access premium features. * * Visit https://arraystory.com/ajaxpress/?ref=dev-discount for special 90% discount for developers. */