Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coding Standards Fixes #1028

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generic_Plugin_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ function w3tc_ga(){dataLayer.push(arguments);}
'w3tc_install_date': '<?php echo esc_attr( get_option( 'w3tc_install_date' ) ); ?>',
'w3tc_pro': '<?php echo Util_Environment::is_w3tc_pro( $this->_config ) ? 1 : 0; ?>',
'w3tc_has_key': '<?php $this->_config->get_string( 'plugin.license_key' ) ? 1 : 0; ?>',
'w3tc_pro_c': '<?php echo defined( 'W3TC_PRO') && W3TC_PRO ? 1 : 0; ?>',
'w3tc_pro_c': '<?php echo defined( 'W3TC_PRO' ) && W3TC_PRO ? 1 : 0; ?>',
'w3tc_enterprise_c': '<?php echo defined( 'W3TC_ENTERPRISE' ) && W3TC_ENTERPRISE ? 1 : 0; ?>',
'w3tc_plugin_type': '<?php echo esc_attr( $this->_config->get_string( 'plugin.type' ) ); ?>',
}
Expand Down
2 changes: 1 addition & 1 deletion Generic_WidgetBoldGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static function should_show_widget() {
);

foreach ( $plugins as $plugin ) {
if ( in_array( $plugin, $backup_plugins ) ) {
if ( in_array( $plugin, $backup_plugins, true ) ) {
return false;
}
}
Expand Down
166 changes: 110 additions & 56 deletions Licensing_AdminActions.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,80 @@
<?php
namespace W3TC;

/**
* File: Licensing_AdminActions.php
*
* @package W3TC
*/

namespace W3TC;

/**
* Class Licensing_AdminActions
*
* phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
*/
class Licensing_AdminActions {

/**
* Config
*
* @var Config
*/
private $_config = null;

function __construct() {
/**
* Initializes the Licensing_AdminActions class.
*
* @return void
*/
public function __construct() {
$this->_config = Dispatcher::config();
}



/**
* test action
* Handles the purchase of a plugin license.
*
* @return void
*/
function w3tc_licensing_buy_plugin() {
$data_src = $this->param( 'data_src' );
public function w3tc_licensing_buy_plugin() {
$data_src = $this->param( 'data_src' );
$renew_key = $this->param( 'renew_key' );
$client_id = $this->param( 'client_id' );

$iframe_url = Licensing_Core::purchase_url( $data_src, $renew_key,
$client_id );
$iframe_url = Licensing_Core::purchase_url( $data_src, $renew_key, $client_id );

include W3TC_INC_DIR . '/lightbox/purchase.php';
}



/**
* Retrieves and sanitizes a request parameter.
*
* @param string $name The name of the parameter to retrieve.
*
* @return string The sanitized parameter value.
*/
private function param( $name ) {
$param = Util_Request::get_string( $name );
return preg_replace( '/[^0-9a-zA-Z._\-]/', '', isset( $param ) ? $param : '' );
}

/**
* Self test action
* Handles the upgrade of a plugin license.
*
* @return void
*/
function w3tc_licensing_upgrade() {
$data_src = $this->param( 'data_src' );
public function w3tc_licensing_upgrade() {
$data_src = $this->param( 'data_src' );
$renew_key = $this->param( 'renew_key' );
$client_id = $this->param( 'client_id' );

include W3TC_INC_DIR . '/lightbox/upgrade.php';
}



function w3tc_licensing_check_key() {
/**
* Checks and activates the license key.
*
* @return void
*/
public function w3tc_licensing_check_key() {
$state = Dispatcher::config_state();
$state->set( 'license.next_check', 0 );
$state->save();
Expand All @@ -56,9 +83,12 @@ function w3tc_licensing_check_key() {
Util_Admin::redirect( array(), true );
}



function w3tc_licensing_reset_rooturi() {
/**
* Resets the root URI for the license.
*
* @return void
*/
public function w3tc_licensing_reset_rooturi() {
$license_key = $this->_config->get_string( 'plugin.license_key' );

$state = Dispatcher::config_state();
Expand All @@ -70,64 +100,88 @@ function w3tc_licensing_reset_rooturi() {
$license = Licensing_Core::check_license( $license_key, W3TC_VERSION );
if ( $license ) {
$status = $license->license_status;
if ( substr( $status . '.', 0, 7 ) == 'active.' ) {
Util_Admin::redirect_with_custom_messages2( array(
'notes' => array( 'Your license has been reset already. Activated for this website now.' )
), true );
if ( 'active.' === substr( $status . '.', 0, 7 ) ) {
Util_Admin::redirect_with_custom_messages2(
array(
'notes' => array( 'Your license has been reset already. Activated for this website now.' ),
),
true
);
}
}

$r = Licensing_Core::reset_rooturi(
$this->_config->get_string( 'plugin.license_key' ), W3TC_VERSION );
$r = Licensing_Core::reset_rooturi( $this->_config->get_string( 'plugin.license_key' ), W3TC_VERSION );

if ( isset( $r->status ) && $r->status == 'done' ) {
Util_Admin::redirect_with_custom_messages2( array(
'notes' => array( 'Email with a link for license reset was sent to you' )
), true );
if ( isset( $r->status ) && 'done' === $r->status ) {
Util_Admin::redirect_with_custom_messages2(
array(
'notes' => array( 'Email with a link for license reset was sent to you' ),
),
true
);
} else {
Util_Admin::redirect_with_custom_messages2( array(
'errors' => array( 'Failed to reset license' )
), true );
Util_Admin::redirect_with_custom_messages2(
array(
'errors' => array( 'Failed to reset license' ),
),
true
);
}
}



static public function w3tc_licensing_terms_accept() {
/**
* Accepts the terms and conditions of the license.
*
* @return void
*/
public static function w3tc_licensing_terms_accept() {
Licensing_Core::terms_accept();

Util_Admin::redirect_with_custom_messages2( array(
'notes' => array( 'Terms have been accepted' )
), true );
Util_Admin::redirect_with_custom_messages2(
array(
'notes' => array( 'Terms have been accepted' ),
),
true
);
}



static public function w3tc_licensing_terms_decline() {
/**
* Declines the terms and conditions of the license.
*
* @return void
*/
public static function w3tc_licensing_terms_decline() {
$c = Dispatcher::config();
if ( !Util_Environment::is_w3tc_pro( $c ) ) {
if ( ! Util_Environment::is_w3tc_pro( $c ) ) {
$state_master = Dispatcher::config_state_master();
$state_master->set( 'license.community_terms', 'decline' );
$state_master->save();
} else {
// not called in this mode
}

Util_Admin::redirect_with_custom_messages2( array(
'notes' => array( 'Terms have been declined' )
), true );
Util_Admin::redirect_with_custom_messages2(
array(
'notes' => array( 'Terms have been declined' ),
),
true
);
}



static public function w3tc_licensing_terms_refresh() {
/**
* Refreshes the acceptance or postponement of license terms.
*
* @return void
*/
public static function w3tc_licensing_terms_refresh() {
$state = Dispatcher::config_state();
$state->set( 'license.next_check', 0 );
$state->set( 'license.terms', 'postpone' );
$state->save();

Util_Admin::redirect_with_custom_messages2( array(
'notes' => array( 'Thank you for your reaction' )
), true );
Util_Admin::redirect_with_custom_messages2(
array(
'notes' => array( 'Thank you for your reaction' ),
),
true
);
}
}
Loading