get_button_args( $status );
$timestamp = time();
if ( ! $echo ) {
ob_start();
}
?>
license_key ) && 'activate' === $button['action'] ) : ?>
'deactivate',
'label' => __( 'Deactivate', 'easy-digital-downloads' ),
'class' => 'secondary',
);
}
return array(
'action' => 'activate',
'label' => __( 'Activate', 'easy-digital-downloads' ),
'class' => 'secondary',
);
}
/**
* Outputs the license key message.
*
* @since 3.1.1
* @return void
*/
private function do_message( $echo = true ) {
if ( empty( $this->message ) ) {
return '';
}
$classes = array(
'edd-license-data',
"edd-license-{$this->class}",
$this->license_status,
);
if ( ! $echo ) {
ob_start();
}
?>
license->license;
$messages = new \EDD\Licensing\Messages(
array(
'status' => $status,
'license_key' => $this->license_key,
'expires' => ! empty( $this->license->expires ) ? $this->license->expires : '',
'name' => $this->name,
)
);
$message = $messages->get_message();
if ( ! empty( $this->license ) ) {
$now = current_time( 'timestamp' );
$expiration = ! empty( $this->license->expires )
? strtotime( $this->license->expires, $now )
: false;
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
if ( false === $this->license->success ) {
$class = ! empty( $this->license->error ) ? $this->license->error : 'error';
$license_status = "license-{$class}-notice";
} else {
$class = 'valid';
if ( 'lifetime' === $this->license->expires ) {
$license_status = 'license-lifetime-notice';
} elseif ( ( $expiration > $now ) && ( $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) ) {
$license_status = 'license-expires-soon-notice';
} else {
$license_status = 'license-expiration-date-notice';
}
}
}
$pass_manager = $this->get_pass_manager();
if ( 'valid' !== $class && $pass_manager->has_pass_data && $this->is_included_in_pass() ) {
$this->included_in_pass = true;
$class = 'included-in-pass';
/* translators: the all acess pass name. */
$message = sprintf( __( 'Your %s gives you access to this extension.', 'easy-digital-downloads' ), '' . $pass_manager->get_pass_name() . '' );
}
$this->class = $class;
$this->message = $message;
$this->license_status = $license_status;
}
/**
* Whether a given product is included in the customer's active pass.
*
* @since 3.1.1
* @return bool
*/
private function is_included_in_pass() {
$pass_manager = $this->get_pass_manager();
// All Access and lifetime passes can access everything.
if ( $pass_manager->hasAllAccessPass() ) {
return true;
}
// If we don't know the item ID we can't assume anything.
if ( empty( $this->args['options']['item_id'] ) ) {
return false;
}
$api = new \EDD\Admin\Extensions\ExtensionsAPI();
$api_item_id = $this->args['options']['item_id'];
$product_data = $api->get_product_data( array(), $api_item_id );
if ( ! $product_data || empty( $product_data->categories ) ) {
return false;
}
return (bool) $pass_manager->can_access_categories( $product_data->categories );
}
/**
* Gets the pass manager.
*
* @return EDD\Admin\Pass_Manager
*/
private function get_pass_manager() {
if ( $this->pass_manager ) {
return $this->pass_manager;
}
$this->pass_manager = new Pass_Manager();
return $this->pass_manager;
}
}