Created
March 6, 2017 20:13
-
-
Save vovafeldman/870fca7e0b9a6d3d85adf2f1734ac1b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function _uninstall_plugin_event( $check_user = true ) { | |
$this->_logger->entrance( 'slug = ' . $this->_slug ); | |
if ( $check_user && ! current_user_can( 'activate_plugins' ) ) { | |
return; | |
} | |
$params = array(); | |
$uninstall_reason = null; | |
if ( isset( $this->_storage->uninstall_reason ) ) { | |
$uninstall_reason = $this->_storage->uninstall_reason; | |
$params['reason_id'] = $uninstall_reason->id; | |
$params['reason_info'] = $uninstall_reason->info; | |
} | |
if ( ! $this->is_registered() ) { | |
// Send anonymous uninstall event only if user submitted a feedback. | |
if ( isset( $uninstall_reason ) ) { | |
if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) { | |
$this->opt_in( false, false, false, false, true ); | |
} else { | |
$params['uid'] = $this->get_anonymous_id(); | |
$this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params ); | |
} | |
} | |
} else { | |
// Send uninstall event. | |
$this->send_install_update( array_merge( $params, array( | |
'is_active' => false, | |
'is_uninstalled' => true, | |
) ) ); | |
} | |
// @todo Decide if we want to delete plugin information from db. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment