Skip to content

Commit

Permalink
Internal: Added deactivation action [ED-16178] (elementor#29913)
Browse files Browse the repository at this point in the history
Co-authored-by: ElementorBot <[email protected]>
  • Loading branch information
KingYes and elementorbot authored Jan 16, 2025
1 parent 1ad8ee4 commit 7fe2590
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
41 changes: 26 additions & 15 deletions includes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ class Api {
*/
private static $api_feedback_url = 'https://my.elementor.com/api/v1/feedback/';

/**
* Get info data.
*
* This function notifies the user of upgrade notices, new templates and contributors.
*
* @since 2.0.0
* @access private
* @static
*
* @param bool $force_update Optional. Whether to force the data retrieval or
* not. Default is false.
*
* @return array|false Info data, or false.
*/
private static function get_info_data( $force_update = false ) {
private static function get_info_data( $force_update = false, $additinal_status = false ) {
$cache_key = self::TRANSIENT_KEY_PREFIX . ELEMENTOR_VERSION;

$info_data = get_transient( $cache_key );
Expand All @@ -87,6 +73,11 @@ private static function get_info_data( $force_update = false ) {
$body_request['site_key'] = $site_key;
}

if ( ! empty( $additinal_status ) ) {
$body_request['status'] = $additinal_status;
$timeout = 3;
}

$response = wp_remote_get( self::$api_info_url, [
'timeout' => $timeout,
'body' => $body_request,
Expand Down Expand Up @@ -240,6 +231,26 @@ public static function get_feed_data( $force_update = false ) {
return $feed;
}

public static function get_deactivation_data() {
$data = self::get_info_data( true, 'deactivated' );

if ( empty( $data['deactivate_data'] ) ) {
return false;
}

return $data['deactivate_data'];
}

public static function get_uninstalled_data() {
$data = self::get_info_data( true, 'uninstalled' );

if ( empty( $data['uninstall_data'] ) ) {
return false;
}

return $data['uninstall_data'];
}

/**
* Get template content.
*
Expand Down
7 changes: 7 additions & 0 deletions includes/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public static function insert_defaults_options() {
}
}

public static function deactivation() {
Api::get_deactivation_data();
}

/**
* Uninstall Elementor.
*
Expand All @@ -79,6 +83,8 @@ public static function insert_defaults_options() {
*/
public static function uninstall() {
wp_clear_scheduled_hook( 'elementor/tracker/send_event' );

Api::get_uninstalled_data();
}

/**
Expand All @@ -92,6 +98,7 @@ public static function uninstall() {
*/
public static function init() {
register_activation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'activation' ] );
register_deactivation_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'deactivation' ] );
register_uninstall_hook( ELEMENTOR_PLUGIN_BASE, [ __CLASS__, 'uninstall' ] );

add_action( 'wpmu_new_blog', function ( $site_id ) {
Expand Down

0 comments on commit 7fe2590

Please sign in to comment.