installed plugin Easy Digital Downloads version 3.1.0.3

This commit is contained in:
2022-11-27 15:03:07 +00:00
committed by Gitium
parent 555673545b
commit c5dce2cec6
1200 changed files with 238970 additions and 0 deletions

View File

@ -0,0 +1,125 @@
<?php
/**
* Notice
*
* @package easy-digital-downloads
* @copyright Copyright (c) 2021, Sandhills Development, LLC
* @license GPL2+
* @since 2.10.6
*/
namespace EDD\Admin\Promos\Notices;
use EDD\Admin\Promos\PromoHandler;
abstract class Notice {
/**
* Action hook for displaying the notice.
*/
const DISPLAY_HOOK = 'admin_notices';
/**
* The priority for the display hook.
*/
const DISPLAY_PRIORITY = 10;
/**
* Type of promotional notice.
*/
const TYPE = 'top-of-page';
/**
* Whether or not the notice can be dismissed.
*/
const DISMISSIBLE = true;
/**
* The capability required to view/dismiss the notice.
*/
const CAPABILITY = 'manage_options';
/**
* Displays the notice content.
*
* @return void
*/
abstract protected function _display();
/**
* Generates a unique ID for this notice.
* It's the class name (without the namespace) and with underscores converted to hyphens.
*
* @since 2.10.6
*
* @return string
*/
public function get_id() {
return strtolower( str_replace( '_', '-', basename( str_replace( '\\', '/', get_class( $this ) ) ) ) );
}
/**
* Determines whether or not the notice should be displayed.
* Typically individual notices should not override this method, as it combines
* a dismissal check and custom display logic (`_should_display()`). Custom logic
* should go in `_should_display()`.
*
* @since 2.10.6
*
* @return bool
*/
public function should_display() {
return current_user_can( static::CAPABILITY ) && ! PromoHandler::is_dismissed( $this->get_id() ) && $this->_should_display();
}
/**
* Duration (in seconds) that the notice is dismissed for.
* `0` means it's dismissed permanently.
*
* @return int
*/
public static function dismiss_duration() {
return 0;
}
/**
* Individual notices can override this method to control display logic.
*
* @since 2.10.6
*
* @return bool
*/
protected function _should_display() {
return true;
}
/**
* Displays the notice.
* Individual notices typically should not override this method, as it contains
* all the notice wrapper logic. Instead, notices should override `_display()`
*
* @since 2.10.6
* @return void
*/
public function display() {
?>
<div
id="edd-admin-notice-<?php echo esc_attr( $this->get_id() ); ?>"
class="edd-admin-notice-<?php echo esc_attr( sanitize_html_class( static::TYPE ) ); ?> edd-promo-notice"
data-nonce="<?php echo esc_attr( wp_create_nonce( 'edd-dismiss-notice-' . $this->get_id() ) ); ?>"
data-id="<?php echo esc_attr( $this->get_id() ); ?>"
data-lifespan="<?php echo esc_attr( static::dismiss_duration() ); ?>"
>
<?php $this->_display(); ?>
<?php if ( static::DISMISSIBLE ) : ?>
<button class="button-link edd-promo-notice-dismiss">
&times;
<span class="screen-reader-text"><?php esc_html_e( 'Dismiss notice', 'easy-digital-downloads' ); ?></span>
</button>
<?php endif; ?>
</div>
<?php
}
}

View File

@ -0,0 +1,187 @@
<?php
/**
* Dashboard Review Notice
*
* @package easy-digital-downloads
* @copyright Copyright (c) 2021, Easy Digital Downloads
* @license GPL2+
* @since 2.11.4
*/
namespace EDD\Admin\Promos\Notices;
class Five_Star_Review_Dashboard extends Notice {
/**
* Action hook for displaying the notice.
*/
const DISPLAY_HOOK = 'edd_dashboard_sales_widget';
/**
* Type of promotional notice.
*/
const TYPE = 'dashboard';
/**
* Capability required to view or dismiss the notice.
*/
const CAPABILITY = 'manage_shop_settings';
/**
* The current screen.
*
* @var string
*/
protected $screen = 'dashboard';
/**
* The ID of the notice. Defined specifically here as we intend to use it twice.
*
* @since 2.11.4
* @return string
*/
public function get_id() {
return 'five-star-review';
}
/**
* Display the notice.
*
* @since 2.11.4
* @return void
*/
public function display() {
?>
<div
id="edd-admin-notice-<?php echo esc_attr( $this->get_id() ); ?>"
class="edd-admin-notice-<?php echo esc_attr( sanitize_html_class( static::TYPE ) ); ?> edd-promo-notice"
data-nonce="<?php echo esc_attr( wp_create_nonce( 'edd-dismiss-notice-' . $this->get_id() ) ); ?>"
data-id="<?php echo esc_attr( $this->get_id() ); ?>"
data-lifespan="<?php echo esc_attr( static::dismiss_duration() ); ?>"
>
<?php
$this->_display();
?>
</div>
<?php
}
/**
* The promo notice content.
*
* @since 2.11.4
* @return void
*/
public function _display() {
?>
<div class="edd-review-step edd-review-step-1">
<p><?php esc_html_e( 'Hey, I noticed you\'ve made quite a few sales with Easy Digital Downloads! Are you enjoying Easy Digital Downloads?', 'easy-digital-downloads' ); ?></p>
<div class="edd-review-actions">
<button class="button-primary edd-review-switch-step" data-step="3"><?php esc_html_e( 'Yes', 'easy-digital-downloads' ); ?></button><br />
<button class="button-link edd-review-switch-step" data-step="2"><?php esc_html_e( 'Not Really', 'easy-digital-downloads' ); ?></button>
</div>
</div>
<div class="edd-review-step edd-review-step-2" style="display:none;">
<p><?php esc_html_e( 'We\'re sorry to hear you aren\'t enjoying Easy Digital Downloads. We would love a chance to improve. Could you take a minute and let us know what we can do better?', 'easy-digital-downloads' ); ?></p>
<div class="edd-review-actions">
<a href="<?php echo esc_url( $this->url() ); ?>" class="button button-secondary edd-promo-notice-dismiss" target="_blank"><?php esc_html_e( 'Give Feedback', 'easy-digital-downloads' ); ?></a><br>
<button class="button-link edd-promo-notice-dismiss"><?php esc_html_e( 'No thanks', 'easy-digital-downloads' ); ?></button>
</div>
</div>
<div class="edd-review-step edd-review-step-3" style="display:none;">
<p><?php esc_html_e( 'That\'s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'easy-digital-downloads' ); ?></p>
<p><strong><?php echo wp_kses( __( '~ Chris Klosowski<br>President of Easy Digital Downloads', 'easy-digital-downloads' ), array( 'br' => array() ) ); ?></strong></p>
<div class="edd-review-actions">
<a href="https://wordpress.org/support/plugin/easy-digital-downloads/reviews/?filter=5#new-post" class="button button-primary edd-promo-notice-dismiss" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Ok, you deserve it!', 'easy-digital-downloads' ); ?></a><br>
<button class="button-link edd-promo-notice-dismiss"><?php esc_html_e( 'No thanks', 'easy-digital-downloads' ); ?></button>
</div>
</div>
<img alt="" class="edd-peeking" src="<?php echo esc_url( EDD_PLUGIN_URL . 'assets/images/edd-peeking.png' ); ?>" />
<script type="text/javascript">
document.addEventListener( 'DOMContentLoaded', function() {
var steps = document.querySelectorAll( '.edd-review-switch-step' );
steps.forEach( function(step) {
step.addEventListener( 'click', function ( e ) {
e.preventDefault();
var target = this.getAttribute( 'data-step' );
if ( target ) {
var notice = this.closest( '.edd-promo-notice' );
var review_step = notice.querySelector( '.edd-review-step-' + target );
if ( review_step ) {
var thisStep = this.closest( '.edd-review-step' );
eddFadeOut( thisStep );
eddFadeIn( review_step );
}
}
} )
} )
function eddFadeIn( element ) {
var op = 0;
element.style.opacity = op;
element.style.display = 'block';
var timer = setInterval( function () {
if ( op >= 1 ) {
clearInterval( timer );
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ')';
op = op + 0.1;
}, 80 );
}
function eddFadeOut( element ) {
var op = 1;
var timer = setInterval( function () {
if ( op <= 0 ) {
element.style.display = 'none';
clearInterval( timer );
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ')';
op = op - 0.1;
}, 80 );
}
} );
</script>
<?php
}
/**
* Whether the notice should display.
*
* @since 2.11.4
* @return bool
*/
protected function _should_display() {
$activated = edd_get_activation_date();
// Do not show if EDD was activated less than 30 days ago.
if ( ! is_numeric( $activated ) || ( $activated + ( DAY_IN_SECONDS * 30 ) ) > time() ) {
return false;
}
// @todo Change this to edd_count_orders in 3.0
$payments = edd_count_payments();
return isset( $payments->publish ) && $payments->publish >= 15;
}
/**
* Builds the UTM parameters for the URLs.
*
* @since 2.11.4
*
* @return string
*/
private function url() {
$url = edd_link_helper(
'https://easydigitaldownloads.com/plugin-feedback/',
array(
'utm_medium' => 'feedback-' . static::TYPE,
'utm_content' => 'give-feedback',
)
);
return $url;
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* Settings Review Notice
*
* @package easy-digital-downloads
* @copyright Copyright (c) 2021, Easy Digital Downloads
* @license GPL2+
* @since 2.11.4
*/
namespace EDD\Admin\Promos\Notices;
class Five_Star_Review_Settings extends Five_Star_Review_Dashboard {
/**
* Action hook for displaying the notice.
*/
const DISPLAY_HOOK = 'admin_notices';
/**
* Type of promotional notice.
*/
const TYPE = 'admin-notice';
/**
* The current screen.
*
* @var string
*/
protected $screen = 'plugin-settings-page';
/**
* Display the notice.
* This extends the parent method because the container classes are different.
*
* @since 2.11.4
* @return void
*/
public function display() {
?>
<div
id="edd-admin-notice-<?php echo esc_attr( $this->get_id() ); ?>"
class="notice notice-info edd-admin-notice-<?php echo esc_attr( sanitize_html_class( static::TYPE ) ); ?> edd-promo-notice"
data-nonce="<?php echo esc_attr( wp_create_nonce( 'edd-dismiss-notice-' . $this->get_id() ) ); ?>"
data-id="<?php echo esc_attr( $this->get_id() ); ?>"
data-lifespan="<?php echo esc_attr( static::dismiss_duration() ); ?>"
>
<?php
parent::_display();
?>
</div>
<?php
}
/**
* Whether the notice should display.
* This extends the general method as this notice should only display on EDD settings screens.
*
* @since 2.11.4
* @return bool
*/
protected function _should_display() {
if ( ! edd_is_admin_page( 'settings' ) ) {
return false;
}
return parent::_should_display();
}
}

View File

@ -0,0 +1,266 @@
<?php
/**
* License Upgrade Notice
*
* @package easy-digital-downloads
* @copyright Copyright (c) 2021, Sandhills Development, LLC
* @license GPL2+
* @since 2.10.6
*/
namespace EDD\Admin\Promos\Notices;
use EDD\Admin\Pass_Manager;
class License_Upgrade_Notice extends Notice {
const DISPLAY_HOOK = 'in_admin_header';
/**
* Number of EDD license keys that have been entered.
* Not validated to make sure they're actually active; this is
* just an indicator if any licenses exist at all.
*
* @var array
*/
private $number_license_keys;
/**
* @var Pass_Manager
*/
private $pass_manager;
/**
* License_Upgrade_Notice constructor.
*/
public function __construct() {
global $edd_licensed_products;
$this->number_license_keys = is_array( $edd_licensed_products ) ? count( $edd_licensed_products ) : 0;
$this->pass_manager = new Pass_Manager();
}
/**
* This notice lasts 90 days.
*
* @return int
*/
public static function dismiss_duration() {
return 3 * MONTH_IN_SECONDS;
}
/**
* Determines if the current page is an EDD admin page.
*
* @return bool
*/
private function is_edd_admin_page() {
if ( defined( 'EDD_DOING_TESTS' ) && EDD_DOING_TESTS ) {
return true;
}
$screen = get_current_screen();
if ( ! $screen instanceof \WP_Screen || 'dashboard' === $screen->id || ! edd_is_admin_page( '', '', false ) ) {
return false;
}
return true;
}
/**
* @inheritDoc
*
* @return bool
*/
protected function _should_display() {
if ( ! $this->is_edd_admin_page() ) {
return false;
}
// Someone with no license keys entered always sees a notice.
if ( 0 === $this->number_license_keys ) {
return true;
}
// If we have no pass data yet, don't show the notice because we don't yet know what it should say.
if ( ! $this->pass_manager->has_pass_data ) {
return false;
}
// If someone has an extended pass or higher, and has an active AffiliateWP license, don't show.
try {
if (
$this->pass_manager->has_pass() &&
Pass_Manager::pass_compare( $this->pass_manager->highest_pass_id, Pass_Manager::EXTENDED_PASS_ID, '>=' ) &&
$this->has_affiliate_wp_license() &&
$this->has_mi_license()
) {
return false;
}
} catch ( \Exception $e ) {
return true;
}
return true;
}
/**
* Determines whether or not AffiliateWP is installed and has a license key.
*
* @since 2.10.6
*
* @return bool
*/
private function has_affiliate_wp_license() {
if ( ! function_exists( 'affiliate_wp' ) ) {
return false;
}
return (bool) affiliate_wp()->settings->get( 'license_key' );
}
/**
* Determines whether or not MonsterInsights is installed and has a license key.
*
* @since 2.11.6
*
* @return bool
*/
private function has_mi_license() {
if ( ! class_exists( 'MonsterInsights' ) ) {
return false;
}
$mi_license = \MonsterInsights::$instance->license->get_license_key();
return ! empty( $mi_license );
}
/**
* @inheritDoc
*/
protected function _display() {
try {
if ( 0 === $this->number_license_keys ) {
$utm_parameters = $this->query_args( 'core' );
$link_url = $this->build_url(
'https://easydigitaldownloads.com/lite-upgrade/',
$utm_parameters
);
$help_url = edd_link_helper(
'https://easydigitaldownloads.com/what-is-an-edd-pass/',
array(
'utm_medium' => 'top-promo',
'utm_content' => 'what-is-a-pass',
)
);
// No license keys active at all.
printf(
/* Translators: %1$s opening anchor tag; %2$s closing anchor tag */
__( 'You are using the free version of Easy Digital Downloads. %1$sPurchase a pass%2$s to get email marketing tools and recurring payments. %3$sAlready have a Pass?%4$s', 'easy-digital-downloads' ),
'<a href="' . $link_url . '" target="_blank">',
'</a>',
'<a href="' . $help_url . '" target="_blank">',
'</a>'
);
} elseif ( ! $this->pass_manager->highest_pass_id ) {
$utm_parameters = $this->query_args( 'extension-license' );
$link_url = $this->build_url(
'https://easydigitaldownloads.com/your-account/',
$utm_parameters
);
// Individual product license active, but no pass.
printf(
/* Translators: %1$s opening anchor tag; %2$s closing anchor tag */
__( 'For access to additional Easy Digital Downloads extensions to grow your store, consider %1$spurchasing a pass%2$s.', 'easy-digital-downloads' ),
'<a href="' . $link_url . '" target="_blank">',
'</a>'
);
} elseif ( Pass_Manager::pass_compare( $this->pass_manager->highest_pass_id, Pass_Manager::PERSONAL_PASS_ID, '=' ) ) {
$utm_parameters = $this->query_args( 'personal-pass' );
$link_url = $this->build_url(
'https://easydigitaldownloads.com/your-account/',
$utm_parameters
);
// Personal pass active.
printf(
/* Translators: %1$s opening anchor tag; %2$s closing anchor tag */
__( 'You are using Easy Digital Downloads with a Personal Pass. Consider %1$supgrading%2$s to get recurring payments and more.', 'easy-digital-downloads' ),
'<a href="' . $link_url . '" target="_blank">',
'</a>'
);
} elseif ( Pass_Manager::pass_compare( $this->pass_manager->highest_pass_id, Pass_Manager::EXTENDED_PASS_ID, '>=' ) ) {
if ( ! $this->has_affiliate_wp_license() ) {
$link_url = edd_link_helper(
'https://affiliatewp.com',
array(
'utm_medium' => 'top-promo',
'utm_content' => 'affiliate-wp',
)
);
printf(
/* Translators: %1$s opening anchor tag; %2$s closing anchor tag */
__( 'Grow your business and make more money with affiliate marketing. %1$sGet AffiliateWP%2$s', 'easy-digital-downloads' ),
'<a href="' . $link_url . '" target="_blank">',
'</a>'
);
} elseif( ! $this->has_mi_license() ) {
printf(
/* Translators: %1$s opening anchor tag; %2$s closing anchor tag */
__( 'Gain access to powerful insights to grow your traffic and revenue. %1$sGet MonsterInsights%2$s', 'easy-digital-downloads' ),
'<a href="' . esc_url( 'https://monsterinsights.com?utm_campaign=xsell&utm_source=eddplugin&utm_content=top-promo' ) . '" target="_blank">',
'</a>'
);
}
}
} catch ( \Exception $e ) {
// If we're in here, that means we have an invalid pass ID... what should we do? :thinking:.
}
}
/**
* Builds the UTM parameters for the URLs.
*
* @since 2.10.6
*
* @param string $upgrade_from License type upgraded from.
* @param string $source Current page.
*
* @return string[]
*/
private function query_args( $upgrade_from, $source = '' ) {
return array(
'utm_medium' => 'top-promo',
'utm_content' => 'upgrade-from-' . urlencode( $upgrade_from ),
);
}
/**
* Build a link with UTM parameters
*
* @since 3.1
*
* @param string $url The Base URL.
* @param array $utm_parameters The UTM tags for the URL.
*
* @return string
*/
private function build_url( $url, $utm_parameters ) {
return esc_url(
edd_link_helper(
$url,
$utm_parameters
)
);
}
}