updated plugin Menu Icons
version 0.12.8
This commit is contained in:
@ -1,3 +1,25 @@
|
||||
##### [Version 3.2.20](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.19...v3.2.20) (2021-03-30)
|
||||
|
||||
add wp-config support
|
||||
|
||||
##### [Version 3.2.19](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.18...v3.2.19) (2021-03-12)
|
||||
|
||||
* Adds compatibility with latest PHPCS coding standards.
|
||||
* Adds compatibility with core auto-update.
|
||||
|
||||
##### [Version 3.2.18](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.17...v3.2.18) (2021-03-04)
|
||||
|
||||
* Fix regression on rollback order
|
||||
|
||||
##### [Version 3.2.17](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.16...v3.2.17) (2021-03-04)
|
||||
|
||||
* Fix compatibility with PHP 8 due to usort
|
||||
|
||||
##### [Version 3.2.16](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.15...v3.2.16) (2020-11-17)
|
||||
|
||||
* Fix long texts on rollback.
|
||||
* Fix RTL mode for uninstall feedback.
|
||||
|
||||
##### [Version 3.2.15](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.14...v3.2.15) (2020-07-23)
|
||||
|
||||
* remove no redundant module
|
||||
|
@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
return;
|
||||
}
|
||||
// Current SDK version and path.
|
||||
$themeisle_sdk_version = '3.2.15';
|
||||
$themeisle_sdk_version = '3.2.20';
|
||||
$themeisle_sdk_path = dirname( __FILE__ );
|
||||
|
||||
global $themeisle_sdk_max_version;
|
||||
|
@ -37,14 +37,14 @@ abstract class Abstract_Module {
|
||||
*
|
||||
* @return bool Should load module?
|
||||
*/
|
||||
public abstract function can_load( $product );
|
||||
abstract public function can_load( $product );
|
||||
|
||||
/**
|
||||
* Bootstrap the module.
|
||||
*
|
||||
* @param Product $product Product object.
|
||||
*/
|
||||
public abstract function load( $product );
|
||||
abstract public function load( $product );
|
||||
|
||||
/**
|
||||
* Check if the product is from partner.
|
||||
@ -63,4 +63,21 @@ abstract class Abstract_Module {
|
||||
|
||||
return array_key_exists( $product->get_slug(), Module_Factory::$slugs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for wp_remote_get on VIP environments.
|
||||
*
|
||||
* @param string $url Url to check.
|
||||
* @param array $args Option params.
|
||||
*
|
||||
* @return array|\WP_Error
|
||||
*/
|
||||
public function safe_get( $url, $args = array() ) {
|
||||
return function_exists( 'vip_safe_wp_remote_get' )
|
||||
? vip_safe_wp_remote_get( $url )
|
||||
: wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used.
|
||||
$url,
|
||||
$args
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class Module_Factory {
|
||||
*
|
||||
* @var Abstract_Module $module_object Module instance.
|
||||
*/
|
||||
$module_object = new $class( $product );
|
||||
$module_object = new $class( $product );
|
||||
|
||||
if ( ! $module_object->can_load( $product ) ) {
|
||||
continue;
|
||||
|
@ -96,7 +96,7 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
function add_widget() {
|
||||
public function add_widget() {
|
||||
global $wp_meta_boxes;
|
||||
if ( isset( $wp_meta_boxes['dashboard']['normal']['core']['themeisle'] ) ) {
|
||||
return;
|
||||
@ -114,7 +114,7 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
/**
|
||||
* Render widget content
|
||||
*/
|
||||
function render_dashboard_widget() {
|
||||
public function render_dashboard_widget() {
|
||||
$this->setup_feeds();
|
||||
if ( empty( $this->items ) || ! is_array( $this->items ) ) {
|
||||
return;
|
||||
@ -220,19 +220,21 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
<li class="ti-dw-feed-item">
|
||||
<a href="
|
||||
<?php
|
||||
echo add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'wpadmin',
|
||||
'utm_campaign' => 'feed',
|
||||
'utm_medium' => 'dashboard_widget',
|
||||
),
|
||||
$item['link']
|
||||
echo esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'wpadmin',
|
||||
'utm_campaign' => 'feed',
|
||||
'utm_medium' => 'dashboard_widget',
|
||||
),
|
||||
$item['link']
|
||||
)
|
||||
);
|
||||
?>
|
||||
" target="_blank">
|
||||
<span class="ti-dw-date-container"><span
|
||||
class="ti-dw-day-container"><?php echo date( 'd', $item['date'] ); ?></span> <span
|
||||
class="ti-dw-month-container"><?php echo substr( date( 'M', $item['date'] ), 0, 3 ); ?></span></span><?php echo $item['title']; ?>
|
||||
class="ti-dw-day-container"><?php echo esc_attr( gmdate( 'd', $item['date'] ) ); ?></span> <span
|
||||
class="ti-dw-month-container"><?php echo esc_attr( substr( gmdate( 'M', $item['date'] ), 0, 3 ) ); ?></span></span><?php echo esc_attr( $item['title'] ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
@ -275,26 +277,28 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
?>
|
||||
<div class="ti-dw-footer">
|
||||
<span class="ti-dw-recommend-item ">
|
||||
<span class="ti-dw-recommend"><?php echo apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( 'Popular %s', ucwords( $type ) ) ); ?>
|
||||
<span class="ti-dw-recommend"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_popular_label', sprintf( 'Popular %s', ucwords( $type ) ) ) ); ?>
|
||||
: </span>
|
||||
<?php
|
||||
echo trim(
|
||||
str_replace(
|
||||
array(
|
||||
'lite',
|
||||
'Lite',
|
||||
'(Lite)',
|
||||
'(lite)',
|
||||
),
|
||||
'',
|
||||
$recommend['name']
|
||||
echo esc_attr(
|
||||
trim(
|
||||
str_replace(
|
||||
array(
|
||||
'lite',
|
||||
'Lite',
|
||||
'(Lite)',
|
||||
'(lite)',
|
||||
),
|
||||
'',
|
||||
$recommend['name']
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
(<a class="thickbox open-plugin-details-modal"
|
||||
href="<?php echo $url . '&TB_iframe=true&width=600&height=500'; ?>"><?php echo apply_filters( 'themeisle_sdk_dashboard_install_label', 'Install' ); ?></a>)
|
||||
href="<?php echo esc_url( $url . '&TB_iframe=true&width=600&height=500' ); ?>"><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_install_label', 'Install' ) ); ?></a>)
|
||||
</span>
|
||||
<span class="ti-dw-powered-by"><span><?php echo apply_filters( 'themeisle_sdk_dashboard_widget_powered_by', esc_attr( sprintf( 'Powered by %s', $this->product->get_friendly_name() ) ) ); ?></span></span>
|
||||
<span class="ti-dw-powered-by"><span><?php echo esc_attr( apply_filters( 'themeisle_sdk_dashboard_widget_powered_by', sprintf( 'Powered by %s', $this->product->get_friendly_name() ) ) ); ?></span></span>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
@ -305,7 +309,7 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
* Setup feed items.
|
||||
*/
|
||||
private function setup_feeds() {
|
||||
if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) {
|
||||
if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
||||
// Load SimplePie Instance.
|
||||
$feed = fetch_feed( $this->feeds );
|
||||
// TODO report error when is an error loading the feed.
|
||||
@ -353,7 +357,7 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
/**
|
||||
* Contact the API and fetch the recommended plugins/themes
|
||||
*/
|
||||
function recommend_plugin_or_theme() {
|
||||
public function recommend_plugin_or_theme() {
|
||||
$products = $this->get_product_from_api();
|
||||
if ( ! is_array( $products ) ) {
|
||||
$products = array();
|
||||
@ -374,8 +378,8 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
*
|
||||
* @return array|mixed The list of products to use in recomended section.
|
||||
*/
|
||||
function get_product_from_api() {
|
||||
if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) {
|
||||
public function get_product_from_api() {
|
||||
if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
||||
$products = array();
|
||||
$all_themes = $this->get_themes_from_wporg( 'themeisle' );
|
||||
$all_plugins = $this->get_plugins_from_wporg( 'themeisle' );
|
||||
@ -429,8 +433,8 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
*
|
||||
* @return array The list of themes.
|
||||
*/
|
||||
function get_themes_from_wporg( $author ) {
|
||||
$products = wp_remote_get(
|
||||
public function get_themes_from_wporg( $author ) {
|
||||
$products = $this->safe_get(
|
||||
'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true'
|
||||
);
|
||||
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
||||
@ -450,8 +454,8 @@ class Dashboard_Widget extends Abstract_Module {
|
||||
*
|
||||
* @return array The list of plugins for the selected author.
|
||||
*/
|
||||
function get_plugins_from_wporg( $author ) {
|
||||
$products = wp_remote_get(
|
||||
public function get_plugins_from_wporg( $author ) {
|
||||
$products = $this->safe_get(
|
||||
'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true'
|
||||
);
|
||||
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
||||
|
@ -62,6 +62,12 @@ class Licenser extends Abstract_Module {
|
||||
* @var null Local license object.
|
||||
*/
|
||||
private $license_local = null;
|
||||
/**
|
||||
* Product namespace, used for fixed name filters/cli commands.
|
||||
*
|
||||
* @var string $namespace Product namespace.
|
||||
*/
|
||||
private $namespace = null;
|
||||
|
||||
/**
|
||||
* Disable wporg updates for premium products.
|
||||
@ -71,7 +77,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return mixed List of themes to check for update.
|
||||
*/
|
||||
function disable_wporg_update( $r, $url ) {
|
||||
public function disable_wporg_update( $r, $url ) {
|
||||
|
||||
if ( 0 !== strpos( $url, 'https://api.wordpress.org/themes/update-check/' ) ) {
|
||||
return $r;
|
||||
@ -83,7 +89,7 @@ class Licenser extends Abstract_Module {
|
||||
unset( $themes->themes->{$this->product->get_slug()} );
|
||||
|
||||
// Encode the updated JSON response.
|
||||
$r['body']['themes'] = json_encode( $themes );
|
||||
$r['body']['themes'] = wp_json_encode( $themes );
|
||||
|
||||
return $r;
|
||||
}
|
||||
@ -172,18 +178,18 @@ class Licenser extends Abstract_Module {
|
||||
<?php
|
||||
echo sprintf(
|
||||
'<p>%s<input class="themeisle-sdk-license-input %s" type="text" id="%s_license" name="%s_license" value="%s" /><a class="%s">%s</a> <button name="%s_btn_trigger" class="button button-primary themeisle-sdk-licenser-button-cta" value="yes" type="submit" >%s</button></p><p class="description">%s</p>%s',
|
||||
( ( 'valid' === $status ) ? sprintf( '<input type="hidden" value="%s" name="%s_license" />', $value, $this->product->get_key() ) : '' ),
|
||||
( ( 'valid' === $status ) ? sprintf( '<input type="hidden" value="%s" name="%s_license" />', esc_attr( $value ), esc_attr( $this->product->get_key() ) ) : '' ),
|
||||
( ( 'valid' === $status ) ? 'themeisle-sdk-text-input-valid' : '' ),
|
||||
$this->product->get_key(),
|
||||
( ( 'valid' === $status ) ? $this->product->get_key() . '_mask' : $this->product->get_key() ),
|
||||
( ( 'valid' === $status ) ? ( str_repeat( '*', 30 ) . substr( $value, - 5 ) ) : $value ),
|
||||
( 'valid' === $status ? 'themeisle-sdk-license-deactivate-cta' : 'themeisle-sdk-license-activate-cta' ),
|
||||
( 'valid' === $status ? $valid_string : $invalid_string ),
|
||||
$this->product->get_key(),
|
||||
( 'valid' === $status ? $deactivate_string : $activate_string ),
|
||||
sprintf( $license_message, '<a href="' . $this->get_api_url() . '">' . $this->get_distributor_name() . '</a> ', $this->product->get_type() ),
|
||||
empty( $error_message ) ? '' : sprintf( '<p style="color:#dd3d36">%s</p>', $error_message )
|
||||
);
|
||||
esc_attr( $this->product->get_key() ),
|
||||
esc_attr( ( ( 'valid' === $status ) ? $this->product->get_key() . '_mask' : $this->product->get_key() ) ),
|
||||
esc_attr( ( ( 'valid' === $status ) ? ( str_repeat( '*', 30 ) . substr( $value, - 5 ) ) : $value ) ),
|
||||
esc_attr( ( 'valid' === $status ? 'themeisle-sdk-license-deactivate-cta' : 'themeisle-sdk-license-activate-cta' ) ),
|
||||
esc_attr( 'valid' === $status ? $valid_string : $invalid_string ),
|
||||
esc_attr( $this->product->get_key() ),
|
||||
esc_attr( 'valid' === $status ? $deactivate_string : $activate_string ),
|
||||
sprintf( wp_kses_data( $license_message ), '<a href="' . esc_url( $this->get_api_url() ) . '">' . esc_attr( $this->get_distributor_name() ) . '</a> ', esc_attr( $this->product->get_type() ) ),
|
||||
wp_kses_data( empty( $error_message ) ? '' : sprintf( '<p style="color:#dd3d36">%s</p>', ( $error_message ) ) )
|
||||
) . wp_nonce_field( $this->product->get_key() . 'nonce', $this->product->get_key() . 'nonce_field', false, false );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
}
|
||||
|
||||
@ -210,17 +216,12 @@ class Licenser extends Abstract_Module {
|
||||
}
|
||||
|
||||
/**
|
||||
* License price id.
|
||||
* Return the last error message.
|
||||
*
|
||||
* @return int License plan.
|
||||
* @return mixed Error message.
|
||||
*/
|
||||
public function get_plan() {
|
||||
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
||||
if ( ! isset( $license_data->price_id ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int) $license_data->price_id;
|
||||
public function get_error() {
|
||||
return get_transient( $this->product->get_key() . 'act_err' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,12 +250,26 @@ class Licenser extends Abstract_Module {
|
||||
return $this->product->get_store_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* License price id.
|
||||
*
|
||||
* @return int License plan.
|
||||
*/
|
||||
public function get_plan() {
|
||||
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
||||
if ( ! isset( $license_data->price_id ) ) {
|
||||
return - 1;
|
||||
}
|
||||
|
||||
return (int) $license_data->price_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the admin notice regarding the license status.
|
||||
*
|
||||
* @return bool Should we show the notice ?
|
||||
*/
|
||||
function show_notice() {
|
||||
public function show_notice() {
|
||||
if ( ! is_admin() ) {
|
||||
return false;
|
||||
}
|
||||
@ -274,10 +289,10 @@ class Licenser extends Abstract_Module {
|
||||
<p><strong>
|
||||
<?php
|
||||
echo sprintf(
|
||||
$no_activations_string,
|
||||
$this->product->get_name(),
|
||||
$this->product->get_name(),
|
||||
'<a href="' . $this->get_api_url() . '" target="_blank">' . $this->get_distributor_name() . '</a>'
|
||||
wp_kses_data( $no_activations_string ),
|
||||
esc_attr( $this->product->get_name() ),
|
||||
esc_attr( $this->product->get_name() ),
|
||||
'<a href="' . esc_url( $this->get_api_url() ) . '" target="_blank">' . esc_attr( $this->get_distributor_name() ) . '</a>'
|
||||
);
|
||||
?>
|
||||
</strong>
|
||||
@ -292,7 +307,7 @@ class Licenser extends Abstract_Module {
|
||||
?>
|
||||
<div class="error">
|
||||
<p>
|
||||
<strong><?php echo sprintf( $expired_license_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->get_api_url() . '?license=' . $this->license_key ); ?> </strong>
|
||||
<strong><?php echo sprintf( wp_kses_data( $expired_license_string ), esc_attr( $this->product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() . '?license=' . $this->license_key ) ); ?> </strong>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
@ -304,7 +319,7 @@ class Licenser extends Abstract_Module {
|
||||
?>
|
||||
<div class="error">
|
||||
<p>
|
||||
<strong><?php echo sprintf( $no_valid_string, $this->product->get_name() . ' ' . $this->product->get_type(), $this->get_api_url(), admin_url( 'options-general.php' ) . '#' . $this->product->get_key() . '_license' ); ?> </strong>
|
||||
<strong><?php echo sprintf( wp_kses_data( $no_valid_string ), esc_attr( $this->product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() ), esc_url( admin_url( 'options-general.php' ) . '#' . $this->product->get_key() . '_license' ) ); ?> </strong>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
@ -335,7 +350,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function check_expiration() {
|
||||
public function check_expiration() {
|
||||
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
||||
if ( '' === $license_data ) {
|
||||
return false;
|
||||
@ -355,7 +370,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return string The renew url.
|
||||
*/
|
||||
function renew_url() {
|
||||
public function renew_url() {
|
||||
$license_data = get_option( $this->product->get_key() . '_license_data', '' );
|
||||
if ( '' === $license_data ) {
|
||||
return $this->get_api_url();
|
||||
@ -371,7 +386,7 @@ class Licenser extends Abstract_Module {
|
||||
* Run the license check call.
|
||||
*/
|
||||
public function product_valid() {
|
||||
if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) {
|
||||
if ( false !== ( $license = get_transient( $this->product->get_key() . '_license_data' ) ) ) { //phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
|
||||
return;
|
||||
}
|
||||
$license = $this->check_license();
|
||||
@ -423,42 +438,6 @@ class Licenser extends Abstract_Module {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the failed checks.
|
||||
*/
|
||||
private function increment_failed_checks() {
|
||||
$this->failed_checks ++;
|
||||
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the failed checks
|
||||
*/
|
||||
private function reset_failed_checks() {
|
||||
$this->failed_checks = 1;
|
||||
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set license validation error message.
|
||||
*
|
||||
* @param string $message Error message.
|
||||
*/
|
||||
public function set_error( $message = '' ) {
|
||||
set_transient( $this->product->get_key() . 'act_err', $message, MINUTE_IN_SECONDS );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last error message.
|
||||
*
|
||||
* @return mixed Error message.
|
||||
*/
|
||||
public function get_error() {
|
||||
return get_transient( $this->product->get_key() . 'act_err' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do license activation/deactivation.
|
||||
*
|
||||
@ -486,7 +465,7 @@ class Licenser extends Abstract_Module {
|
||||
|
||||
// Call the custom API.
|
||||
if ( 'check' === $action ) {
|
||||
$response = wp_remote_get( sprintf( '%slicense/check/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, rawurlencode( home_url() ), Loader::get_cache_token() ) );
|
||||
$response = $this->safe_get( sprintf( '%slicense/check/%s/%s/%s/%s', Product::API_URL, rawurlencode( $this->product->get_name() ), $license, rawurlencode( home_url() ), Loader::get_cache_token() ) );
|
||||
} else {
|
||||
$response = wp_remote_post(
|
||||
sprintf( '%slicense/%s/%s/%s', Product::API_URL, $action, rawurlencode( $this->product->get_name() ), $license ),
|
||||
@ -550,15 +529,42 @@ class Licenser extends Abstract_Module {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the failed checks
|
||||
*/
|
||||
private function reset_failed_checks() {
|
||||
$this->failed_checks = 1;
|
||||
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the failed checks.
|
||||
*/
|
||||
private function increment_failed_checks() {
|
||||
$this->failed_checks ++;
|
||||
update_option( $this->product->get_key() . '_failed_checks', $this->failed_checks );
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the license remotely.
|
||||
*/
|
||||
function process_license() {
|
||||
public function process_license() {
|
||||
// listen for our activate button to be clicked.
|
||||
if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
|
||||
return;
|
||||
}
|
||||
$license = $_POST[ $this->product->get_key() . '_license' ];
|
||||
if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] )
|
||||
|| ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
$license = isset( $_POST[ $this->product->get_key() . '_license' ] )
|
||||
? sanitize_text_field( $_POST[ $this->product->get_key() . '_license' ] )
|
||||
: '';
|
||||
|
||||
$response = $this->do_license_process( $license, 'toggle' );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$this->set_error( $response->get_error_message() );
|
||||
@ -568,14 +574,22 @@ class Licenser extends Abstract_Module {
|
||||
if ( true === $response ) {
|
||||
$this->set_error( '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set license validation error message.
|
||||
*
|
||||
* @param string $message Error message.
|
||||
*/
|
||||
public function set_error( $message = '' ) {
|
||||
set_transient( $this->product->get_key() . 'act_err', $message, MINUTE_IN_SECONDS );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Themes screen.
|
||||
*/
|
||||
function load_themes_screen() {
|
||||
public function load_themes_screen() {
|
||||
add_thickbox();
|
||||
add_action( 'admin_notices', array( &$this, 'update_nag' ) );
|
||||
}
|
||||
@ -583,7 +597,7 @@ class Licenser extends Abstract_Module {
|
||||
/**
|
||||
* Alter the nag for themes update.
|
||||
*/
|
||||
function update_nag() {
|
||||
public function update_nag() {
|
||||
$theme = wp_get_theme( $this->product->get_slug() );
|
||||
$api_response = get_transient( $this->product_key );
|
||||
if ( false === $api_response || ! isset( $api_response->new_version ) ) {
|
||||
@ -596,16 +610,16 @@ class Licenser extends Abstract_Module {
|
||||
echo '<div id="update-nag">';
|
||||
printf(
|
||||
'<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
|
||||
$theme->get( 'Name' ),
|
||||
$api_response->new_version,
|
||||
sprintf( '%s&TB_iframe=true&width=1024&height=800', $this->product->get_changelog() ),
|
||||
$theme->get( 'Name' ),
|
||||
$update_url,
|
||||
$update_onclick
|
||||
esc_attr( $theme->get( 'Name' ) ),
|
||||
esc_attr( $api_response->new_version ),
|
||||
esc_url( sprintf( '%s&TB_iframe=true&width=1024&height=800', $this->product->get_changelog() ) ),
|
||||
esc_attr( $theme->get( 'Name' ) ),
|
||||
esc_url( $update_url ),
|
||||
$update_onclick // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
|
||||
);
|
||||
echo '</div>';
|
||||
echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">';
|
||||
echo wpautop( $api_response->sections['changelog'] );
|
||||
echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">';
|
||||
echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) );
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
@ -617,7 +631,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function theme_update_transient( $value ) {
|
||||
public function theme_update_transient( $value ) {
|
||||
$update_data = $this->check_for_update();
|
||||
if ( $update_data ) {
|
||||
$value->response[ $this->product->get_slug() ] = $update_data;
|
||||
@ -631,7 +645,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return array|bool Either the update data or false in case of failure.
|
||||
*/
|
||||
function check_for_update() {
|
||||
public function check_for_update() {
|
||||
$update_data = get_transient( $this->product_key );
|
||||
|
||||
if ( false === $update_data ) {
|
||||
@ -669,7 +683,7 @@ class Licenser extends Abstract_Module {
|
||||
*/
|
||||
private function get_version_data() {
|
||||
|
||||
$response = wp_remote_get(
|
||||
$response = $this->safe_get(
|
||||
sprintf(
|
||||
'%slicense/version/%s/%s/%s/%s',
|
||||
Product::API_URL,
|
||||
@ -679,7 +693,7 @@ class Licenser extends Abstract_Module {
|
||||
rawurlencode( home_url() )
|
||||
),
|
||||
array(
|
||||
'timeout' => 15,
|
||||
'timeout' => 15, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout, Inherited by wp_remote_get only, for vip environment we use defaults.
|
||||
'sslverify' => false,
|
||||
)
|
||||
);
|
||||
@ -706,8 +720,8 @@ class Licenser extends Abstract_Module {
|
||||
/**
|
||||
* Delete the update transient
|
||||
*/
|
||||
function delete_theme_update_transient() {
|
||||
delete_transient( $this->product_key );
|
||||
public function delete_theme_update_transient() {
|
||||
return delete_transient( $this->product_key );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -727,6 +741,8 @@ class Licenser extends Abstract_Module {
|
||||
if ( false !== $api_response && is_object( $api_response ) && isset( $api_response->new_version ) ) {
|
||||
if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
|
||||
$_transient_data->response[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
|
||||
} else {
|
||||
$_transient_data->no_update[ $this->product->get_slug() . '/' . $this->product->get_file() ] = $api_response;
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +798,7 @@ class Licenser extends Abstract_Module {
|
||||
*
|
||||
* @return array $array
|
||||
*/
|
||||
function http_request_args( $args, $url ) {
|
||||
public function http_request_args( $args, $url ) {
|
||||
// If it is an https request and we are performing a package download, disable ssl verification.
|
||||
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
||||
$args['sslverify'] = false;
|
||||
@ -829,6 +845,7 @@ class Licenser extends Abstract_Module {
|
||||
$namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false );
|
||||
|
||||
if ( false !== $namespace ) {
|
||||
$this->namespace = $namespace;
|
||||
add_filter( 'themeisle_sdk_license_process_' . $namespace, [ $this, 'do_license_process' ], 10, 2 );
|
||||
add_filter( 'product_' . $namespace . '_license_status', [ $this, 'get_license_status' ], PHP_INT_MAX );
|
||||
add_filter( 'product_' . $namespace . '_license_key', [ $this->product, 'get_license' ] );
|
||||
@ -850,17 +867,17 @@ class Licenser extends Abstract_Module {
|
||||
]
|
||||
);
|
||||
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
||||
add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 );
|
||||
add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( $this->product->is_theme() ) {
|
||||
add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
|
||||
add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
|
||||
add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
|
||||
add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
|
||||
add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
|
||||
add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
|
||||
add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 );
|
||||
add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
|
||||
|
||||
return $this;
|
||||
|
||||
@ -870,42 +887,74 @@ class Licenser extends Abstract_Module {
|
||||
}
|
||||
|
||||
/**
|
||||
* Run license activation on plugin activate.
|
||||
* Register license fields for the products.
|
||||
*/
|
||||
public function auto_activate() {
|
||||
if ( ! current_user_can( 'switch_themes' ) ) {
|
||||
return;
|
||||
}
|
||||
$status = $this->get_license_status();
|
||||
if ( 'not_active' !== $status ) {
|
||||
return;
|
||||
}
|
||||
public function register_license_hooks() {
|
||||
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
||||
add_action( 'admin_init', array( $this, 'process_license' ) );
|
||||
add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
|
||||
add_action( 'admin_notices', array( $this, 'show_notice' ) );
|
||||
add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check license on filesystem.
|
||||
*
|
||||
* @return mixed License key.
|
||||
*/
|
||||
public function get_file_license() {
|
||||
|
||||
$license_file = dirname( $this->product->get_basefile() ) . '/license.json';
|
||||
|
||||
global $wp_filesystem;
|
||||
if ( ! is_file( $license_file ) ) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
\WP_Filesystem();
|
||||
$content = json_decode( $wp_filesystem->get_contents( $license_file ) );
|
||||
if ( ! is_object( $content ) ) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if ( ! isset( $content->key ) ) {
|
||||
return false;
|
||||
}
|
||||
return $content->key;
|
||||
}
|
||||
/**
|
||||
* Run license activation on plugin activate.
|
||||
*/
|
||||
public function auto_activate() {
|
||||
$status = $this->get_license_status();
|
||||
if ( 'not_active' !== $status ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->namespace ) ) {
|
||||
$license_key = apply_filters( 'product_' . $this->namespace . '_license_key_constant', '' );
|
||||
}
|
||||
|
||||
if ( empty( $license_key ) ) {
|
||||
$license_key = $this->get_file_license();
|
||||
}
|
||||
if ( empty( $license_key ) ) {
|
||||
return;
|
||||
}
|
||||
$this->license_local = $content;
|
||||
|
||||
|
||||
$this->license_local = $license_key;
|
||||
$lock_key = $this->product->get_key() . '_autoactivated';
|
||||
|
||||
if ( 'yes' === get_option( $lock_key, '' ) ) {
|
||||
return;
|
||||
}
|
||||
$response = $this->do_license_process( $content->key, 'activate' );
|
||||
if ( 'yes' === get_transient( $lock_key ) ) {
|
||||
return;
|
||||
}
|
||||
$response = $this->do_license_process( $license_key, 'activate' );
|
||||
|
||||
update_option( $lock_key, 'yes' );
|
||||
set_transient( $lock_key, 'yes', 6 * HOUR_IN_SECONDS );
|
||||
|
||||
if ( apply_filters( $this->product->get_key() . '_hide_license_notices', false ) ) {
|
||||
return;
|
||||
@ -922,7 +971,7 @@ class Licenser extends Abstract_Module {
|
||||
public function autoactivate_notice() {
|
||||
?>
|
||||
<div class="notice notice-success is-dismissible">
|
||||
<p><?php echo sprintf( '<strong>%s</strong> has been successfully activated using <strong>%s</strong> license !', $this->product->get_name(), str_repeat( '*', 20 ) . substr( $this->license_local->key, - 10 ) ); ?></p>
|
||||
<p><?php echo sprintf( '<strong>%s</strong> has been successfully activated using <strong>%s</strong> license !', esc_attr( $this->product->get_name() ), esc_attr( str_repeat( '*', 20 ) . substr( $this->license_local, - 10 ) ) ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@ -989,15 +1038,4 @@ class Licenser extends Abstract_Module {
|
||||
|
||||
\WP_CLI::halt( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register license fields for the products.
|
||||
*/
|
||||
public function register_license_hooks() {
|
||||
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
||||
add_action( 'admin_init', array( $this, 'process_license' ) );
|
||||
add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
|
||||
add_action( 'admin_notices', array( $this, 'show_notice' ) );
|
||||
add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) );
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Logger extends Abstract_Module {
|
||||
}
|
||||
$action_key = $this->product->get_key() . '_log_activity';
|
||||
if ( ! wp_next_scheduled( $action_key ) ) {
|
||||
wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key );
|
||||
wp_schedule_single_event( time() + ( wp_rand( 1, 24 ) * 3600 ), $action_key );
|
||||
}
|
||||
add_action( $action_key, array( $this, 'send_log' ) );
|
||||
|
||||
|
@ -84,7 +84,7 @@ class Notification extends Abstract_Module {
|
||||
$notification_html = self::get_notification_html( $notification_details );
|
||||
do_action( $notification_details['id'] . '_before_render' );
|
||||
|
||||
echo $notification_html;
|
||||
echo $notification_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, already escaped internally.
|
||||
|
||||
do_action( $notification_details['id'] . '_after_render' );
|
||||
self::render_snippets();
|
||||
@ -340,7 +340,7 @@ class Notification extends Abstract_Module {
|
||||
$.post(
|
||||
ajaxurl,
|
||||
{
|
||||
'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
|
||||
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
||||
'action': 'themeisle_sdk_dismiss_notice',
|
||||
'id': notification_id,
|
||||
'confirm': confirm
|
||||
@ -365,7 +365,7 @@ class Notification extends Abstract_Module {
|
||||
/**
|
||||
* Dismiss the notification.
|
||||
*/
|
||||
static function dismiss() {
|
||||
public static function dismiss() {
|
||||
check_ajax_referer( (string) __CLASS__, 'nonce' );
|
||||
|
||||
$id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : '';
|
||||
|
@ -64,7 +64,7 @@ class Recommendation extends Abstract_Module {
|
||||
* @param array $strings - list of translated strings.
|
||||
* @param array $preferences - list of preferences.
|
||||
*/
|
||||
function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) {
|
||||
public function render_products_box( $plugins_list, $themes_list, $strings, $preferences = array() ) {
|
||||
|
||||
if ( empty( $plugins_list ) && empty( $themes_list ) ) {
|
||||
return;
|
||||
@ -90,7 +90,7 @@ class Recommendation extends Abstract_Module {
|
||||
|
||||
foreach ( $list as $theme ) {
|
||||
echo '<div class="plugin_box">';
|
||||
echo ' <img class="theme-banner" src="' . $theme->screenshot_url . '">';
|
||||
echo ' <img class="theme-banner" src="' . esc_url( $theme->screenshot_url ) . '">';
|
||||
echo ' <div class="title-action-wrapper">';
|
||||
echo ' <span class="plugin-name">' . esc_html( $theme->custom_name ) . '</span>';
|
||||
if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) {
|
||||
@ -118,7 +118,7 @@ class Recommendation extends Abstract_Module {
|
||||
|
||||
foreach ( $list as $current_plugin ) {
|
||||
echo '<div class="plugin_box">';
|
||||
echo ' <img class="plugin-banner" src="' . $current_plugin->custom_image . '">';
|
||||
echo ' <img class="plugin-banner" src="' . esc_url( $current_plugin->custom_image ) . '">';
|
||||
echo ' <div class="title-action-wrapper">';
|
||||
echo ' <span class="plugin-name">' . esc_html( $current_plugin->custom_name ) . '</span>';
|
||||
if ( ! isset( $preferences['description'] ) || ( isset( $preferences['description'] ) && $preferences['description'] ) ) {
|
||||
@ -185,7 +185,7 @@ class Recommendation extends Abstract_Module {
|
||||
return $theme;
|
||||
}
|
||||
|
||||
$products = wp_remote_get(
|
||||
$products = $this->safe_get(
|
||||
'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[theme]=' . $slug . '&request[per_page]=1'
|
||||
);
|
||||
$products = json_decode( wp_remote_retrieve_body( $products ) );
|
||||
@ -246,7 +246,7 @@ class Recommendation extends Abstract_Module {
|
||||
* @return array|mixed|object
|
||||
*/
|
||||
private function call_plugin_api( $slug ) {
|
||||
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
|
||||
$call_api = get_transient( 'ti_plugin_info_' . $slug );
|
||||
|
||||
@ -303,27 +303,30 @@ class Recommendation extends Abstract_Module {
|
||||
}
|
||||
|
||||
.recommend-product .theme-banner {
|
||||
width:200px;
|
||||
width: 200px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.recommend-product .plugin-banner {
|
||||
width: 100px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.recommend-product .plugin_box .button span{
|
||||
.recommend-product .plugin_box .button span {
|
||||
|
||||
margin-top: 2px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
.recommend-product .plugin_box .button{
|
||||
margin-bottom:10px;
|
||||
|
||||
.recommend-product .plugin_box .button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.recommend-product .plugin_box {
|
||||
margin-bottom: 20px;
|
||||
padding-top: 5px;
|
||||
display: flex;
|
||||
box-shadow: 0px 0px 10px -5px rgba(0,0,0,0.55);
|
||||
box-shadow: 0px 0px 10px -5px rgba(0, 0, 0, 0.55);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
flex-direction: column;
|
||||
|
@ -120,7 +120,9 @@ class Rollback extends Abstract_Module {
|
||||
if ( empty( $url ) ) {
|
||||
return [];
|
||||
}
|
||||
$response = wp_remote_get( $url );
|
||||
$response = function_exists( 'wp_remote_get_wp_remote_get' )
|
||||
? wp_remote_get_wp_remote_get( $url )
|
||||
: wp_remote_get( $url ); //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return array();
|
||||
}
|
||||
@ -191,7 +193,7 @@ class Rollback extends Abstract_Module {
|
||||
* Start the rollback operation.
|
||||
*/
|
||||
public function start_rollback() {
|
||||
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) {
|
||||
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], $this->product->get_key() . '_rollback' ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
wp_nonce_ays( '' );
|
||||
}
|
||||
|
||||
@ -228,9 +230,12 @@ class Rollback extends Abstract_Module {
|
||||
|
||||
$transient = get_transient( $this->product->get_key() . '_warning_rollback' );
|
||||
|
||||
// Style fix for the api link that gets outside the content.
|
||||
echo '<style>body#error-page{word-break:break-word;}</style>';
|
||||
|
||||
if ( false === $transient ) {
|
||||
set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
|
||||
$plugin = $plugin_folder . '/' . $plugin_file;
|
||||
$nonce = 'upgrade-plugin_' . $plugin;
|
||||
@ -241,7 +246,7 @@ class Rollback extends Abstract_Module {
|
||||
delete_transient( $this->product->get_key() . '_warning_rollback' );
|
||||
wp_die(
|
||||
'',
|
||||
$title,
|
||||
esc_attr( $title ),
|
||||
array(
|
||||
'response' => 200,
|
||||
)
|
||||
@ -268,9 +273,12 @@ class Rollback extends Abstract_Module {
|
||||
|
||||
$transient = get_transient( $this->product->get_key() . '_warning_rollback' );
|
||||
|
||||
// Style fix for the api link that gets outside the content.
|
||||
echo '<style>body#error-page{word-break:break-word;}</style>';
|
||||
|
||||
if ( false === $transient ) {
|
||||
set_transient( $this->product->get_key() . '_warning_rollback', 'in progress', 30 );
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$title = sprintf( apply_filters( $this->product->get_key() . '_rollback_message', 'Rolling back %s to v%s' ), $this->product->get_name(), $version );
|
||||
$theme = $folder . '/style.css';
|
||||
$nonce = 'upgrade-theme_' . $theme;
|
||||
@ -281,7 +289,7 @@ class Rollback extends Abstract_Module {
|
||||
delete_transient( $this->product->get_key() . '_warning_rollback' );
|
||||
wp_die(
|
||||
'',
|
||||
$title,
|
||||
esc_attr( $title ),
|
||||
array(
|
||||
'response' => 200,
|
||||
)
|
||||
@ -335,7 +343,7 @@ class Rollback extends Abstract_Module {
|
||||
* @return bool Which version is greater?
|
||||
*/
|
||||
public function sort_rollback_array( $a, $b ) {
|
||||
return version_compare( $a['version'], $b['version'], '<' ) > 0;
|
||||
return version_compare( $b['version'], $a['version'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -805,7 +805,7 @@ class Translate extends Abstract_Module {
|
||||
$translations = get_transient( $cache_key );
|
||||
|
||||
if ( false === $translations ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
||||
$translations = translations_api(
|
||||
$product->get_type() . 's',
|
||||
array(
|
||||
|
@ -132,7 +132,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
/**
|
||||
* Loads the additional resources
|
||||
*/
|
||||
function load_resources() {
|
||||
public function load_resources() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! $screen || ! in_array( $screen->id, array( 'theme-install', 'plugins' ) ) ) {
|
||||
@ -178,7 +178,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
echo wp_kses_post( $info_disclosure_link );
|
||||
echo wp_kses_post( $this->get_disclosure_labels() );
|
||||
echo '<div class="buttons">';
|
||||
echo get_submit_button(
|
||||
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function has an internal sanitization.
|
||||
$button_submit,
|
||||
'secondary',
|
||||
$this->product->get_key() . 'ti-deactivate-yes',
|
||||
@ -236,7 +236,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
}
|
||||
|
||||
.ti-feedback .popup--form input[type="radio"] {
|
||||
margin: 0 10px 0 0;
|
||||
<?php echo is_rtl() ? 'margin: 0 0 0 10px;' : 'margin: 0 10px 0 0;'; ?>
|
||||
}
|
||||
|
||||
.ti-feedback .popup--form input[type="radio"]:checked ~ textarea {
|
||||
@ -314,7 +314,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
}
|
||||
|
||||
.ti-feedback .buttons input:last-child {
|
||||
margin-left: auto;
|
||||
<?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?>
|
||||
}
|
||||
|
||||
.ti-theme-uninstall-feedback-drawer {
|
||||
@ -366,13 +366,19 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
border: 20px solid #23A1CE;
|
||||
left: -10px;
|
||||
top: 50%;
|
||||
border-top: 20px solid transparent;
|
||||
border-bottom: 20px solid transparent;
|
||||
border-left: 0;
|
||||
transform: translateY(-50%);
|
||||
<?php
|
||||
echo is_rtl() ?
|
||||
'right: -10px;
|
||||
border-top: 20px solid transparent;
|
||||
border-left: 20px solid #23A1CE;
|
||||
border-bottom: 20px solid transparent;' :
|
||||
'left: -10px;
|
||||
border-top: 20px solid transparent;
|
||||
border-right: 20px solid #23A1CE;
|
||||
border-bottom: 20px solid transparent;';
|
||||
?>
|
||||
}
|
||||
|
||||
.ti-plugin-uninstall-feedback-popup {
|
||||
@ -380,7 +386,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
position: absolute;
|
||||
white-space: normal;
|
||||
width: 400px;
|
||||
left: 100%;
|
||||
<?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?>
|
||||
top: -15px;
|
||||
}
|
||||
|
||||
@ -408,7 +414,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
display: block;
|
||||
}
|
||||
|
||||
tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate {
|
||||
tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@ -469,20 +475,20 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
var radio = $(this);
|
||||
if (radio.parent().find('textarea').length > 0 &&
|
||||
radio.parent().find('textarea').val().length === 0) {
|
||||
$('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
radio.parent().find('textarea').on('keyup', function (e) {
|
||||
if ($(this).val().length === 0) {
|
||||
$('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
} else {
|
||||
$('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) {
|
||||
$('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@ -490,7 +496,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
'.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked');
|
||||
$.post(ajaxurl, {
|
||||
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
|
||||
'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
|
||||
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
||||
'id': selectedOption.parent().attr('ti-option-id'),
|
||||
'msg': selectedOption.parent().find('textarea').val(),
|
||||
'type': 'theme',
|
||||
@ -523,12 +529,12 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
<li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>">
|
||||
<input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>">
|
||||
<label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>">
|
||||
<?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?>
|
||||
<?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?>
|
||||
</label>
|
||||
<?php
|
||||
if ( array_key_exists( 'type', $attributes ) ) {
|
||||
$placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : '';
|
||||
echo '<textarea width="100%" rows="' . $inputs_row_map[ $attributes['type'] ] . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>';
|
||||
echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>';
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
@ -561,13 +567,13 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
echo wp_kses_post( $info_disclosure_link );
|
||||
echo wp_kses_post( $this->get_disclosure_labels() );
|
||||
echo '<div class="buttons">';
|
||||
echo get_submit_button(
|
||||
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped.
|
||||
$button_cancel,
|
||||
'secondary',
|
||||
$this->product->get_key() . 'ti-deactivate-no',
|
||||
false
|
||||
);
|
||||
echo get_submit_button(
|
||||
echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped.
|
||||
$button_submit,
|
||||
'primary',
|
||||
$this->product->get_key() . 'ti-deactivate-yes',
|
||||
@ -596,7 +602,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
<script type="text/javascript" id="ti-deactivate-js">
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
var targetElement = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a';
|
||||
var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a';
|
||||
var redirectUrl = $(targetElement).attr('href');
|
||||
if ($('.ti-feedback-overlay').length === 0) {
|
||||
$('body').prepend('<div class="ti-feedback-overlay"></div>');
|
||||
@ -622,20 +628,20 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
var radio = $(this);
|
||||
if (radio.parent().find('textarea').length > 0 &&
|
||||
radio.parent().find('textarea').val().length === 0) {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
radio.parent().find('textarea').on('keyup', function (e) {
|
||||
if ($(this).val().length === 0) {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled');
|
||||
} else {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-no').on('click', function (e) {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(targetElement).unbind('click');
|
||||
@ -646,7 +652,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
}
|
||||
});
|
||||
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) {
|
||||
$('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
$(targetElement).unbind('click');
|
||||
@ -654,7 +660,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
'<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked');
|
||||
var data = {
|
||||
'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>',
|
||||
'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
|
||||
'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
|
||||
'id': selectedOption.parent().attr('ti-option-id'),
|
||||
'msg': selectedOption.parent().find('textarea').val(),
|
||||
'type': 'plugin',
|
||||
@ -719,7 +725,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
*
|
||||
* @param array $options The options array.
|
||||
*/
|
||||
function randomize_options( $options ) {
|
||||
public function randomize_options( $options ) {
|
||||
$new = array();
|
||||
$keys = array_keys( $options );
|
||||
shuffle( $keys );
|
||||
@ -734,7 +740,7 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
/**
|
||||
* Called when the deactivate button is clicked.
|
||||
*/
|
||||
function post_deactivate() {
|
||||
public function post_deactivate() {
|
||||
check_ajax_referer( (string) __CLASS__, 'nonce' );
|
||||
|
||||
$this->post_deactivate_or_cancel();
|
||||
@ -748,8 +754,8 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
$this->call_api(
|
||||
array(
|
||||
'type' => 'deactivate',
|
||||
'id' => $_POST['id'],
|
||||
'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '',
|
||||
'id' => sanitize_key( $_POST['id'] ),
|
||||
'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '',
|
||||
)
|
||||
);
|
||||
wp_send_json( [] );
|
||||
@ -760,14 +766,14 @@ class Uninstall_Feedback extends Abstract_Module {
|
||||
* Called when the deactivate/cancel button is clicked.
|
||||
*/
|
||||
private function post_deactivate_or_cancel() {
|
||||
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) {
|
||||
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
||||
return;
|
||||
}
|
||||
if ( 'theme' !== $_POST['type'] ) {
|
||||
if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
||||
return;
|
||||
}
|
||||
|
||||
set_transient( 'ti_sdk_pause_' . $_POST['key'], true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );
|
||||
set_transient( 'ti_sdk_pause_' . sanitize_text_field( $_POST['key'] ), true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );//phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function.
|
||||
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ class Product {
|
||||
*
|
||||
* @return string $name The normalized string.
|
||||
*/
|
||||
static function key_ready_name( $string ) {
|
||||
public static function key_ready_name( $string ) {
|
||||
return str_replace( '-', '_', strtolower( trim( $string ) ) );
|
||||
}
|
||||
|
||||
|
@ -13,25 +13,25 @@ namespace ThemeisleSDK;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$products = apply_filters( 'themeisle_sdk_products', array() );
|
||||
$path = dirname( __FILE__ );
|
||||
$files_to_load = [
|
||||
$path . '/src/' . 'Loader.php',
|
||||
$path . '/src/' . 'Product.php',
|
||||
$products = apply_filters( 'themeisle_sdk_products', array() );
|
||||
$themeisle_library_path = dirname( __FILE__ );
|
||||
$files_to_load = [
|
||||
$themeisle_library_path . '/src/Loader.php',
|
||||
$themeisle_library_path . '/src/Product.php',
|
||||
|
||||
$path . '/src/' . 'Common/Abstract_module.php',
|
||||
$path . '/src/' . 'Common/Module_factory.php',
|
||||
$themeisle_library_path . '/src/Common/Abstract_module.php',
|
||||
$themeisle_library_path . '/src/Common/Module_factory.php',
|
||||
|
||||
$path . '/src/' . 'Modules/Dashboard_widget.php',
|
||||
$path . '/src/' . 'Modules/Rollback.php',
|
||||
$path . '/src/' . 'Modules/Uninstall_feedback.php',
|
||||
$path . '/src/' . 'Modules/Licenser.php',
|
||||
$path . '/src/' . 'Modules/Endpoint.php',
|
||||
$path . '/src/' . 'Modules/Notification.php',
|
||||
$path . '/src/' . 'Modules/Logger.php',
|
||||
$path . '/src/' . 'Modules/Translate.php',
|
||||
$path . '/src/' . 'Modules/Review.php',
|
||||
$path . '/src/' . 'Modules/Recommendation.php',
|
||||
$themeisle_library_path . '/src/Modules/Dashboard_widget.php',
|
||||
$themeisle_library_path . '/src/Modules/Rollback.php',
|
||||
$themeisle_library_path . '/src/Modules/Uninstall_feedback.php',
|
||||
$themeisle_library_path . '/src/Modules/Licenser.php',
|
||||
$themeisle_library_path . '/src/Modules/Endpoint.php',
|
||||
$themeisle_library_path . '/src/Modules/Notification.php',
|
||||
$themeisle_library_path . '/src/Modules/Logger.php',
|
||||
$themeisle_library_path . '/src/Modules/Translate.php',
|
||||
$themeisle_library_path . '/src/Modules/Review.php',
|
||||
$themeisle_library_path . '/src/Modules/Recommendation.php',
|
||||
];
|
||||
|
||||
$files_to_load = array_merge( $files_to_load, apply_filters( 'themeisle_sdk_required_files', [] ) );
|
||||
|
Reference in New Issue
Block a user