updated plugin Menu Icons version 0.13.5

This commit is contained in:
2023-03-31 11:24:25 +00:00
committed by Gitium
parent 39646e6577
commit 97859556db
15 changed files with 228 additions and 40 deletions

View File

@ -1,3 +1,15 @@
##### [Version 3.2.40](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.39...v3.2.40) (2023-03-30)
- Add ROP upsell to all products
##### [Version 3.2.39](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.38...v3.2.39) (2023-03-17)
* Adds direct utility function for a direct support link.
##### [Version 3.2.38](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.37...v3.2.38) (2023-03-10)
Fix promotions path-breaking
##### [Version 3.2.37](https://github.com/Codeinwp/themeisle-sdk/compare/v3.2.36...v3.2.37) (2023-03-01)
Fix array casting

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-api', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '482f75f37b88f9ea2e79');
<?php return array('dependencies' => array('wp-api', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-plugins'), 'version' => '3d1ed0347f48fcdf607c');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.ti-sdk-om-notice{--wp-admin-theme-color:#3858e9;--wp-admin-theme-color-darker-10:#2e47ba;border-left-color:#3858e9;padding:0;position:relative}.ti-sdk-om-notice .content{align-items:center;background:hsla(0,0%,100%,.75);display:flex;padding:15px 20px}.ti-sdk-om-notice img{display:none;margin-right:20px;max-width:100px}.ti-sdk-om-notice .description{color:#000;font-size:14px;margin-bottom:20px}.ti-sdk-om-notice .actions{display:flex;gap:20px;margin-bottom:0;margin-top:auto}.ti-sdk-om-notice form{align-items:center;display:flex;gap:10px}.ti-sdk-om-notice .form-wrap{display:grid}.ti-sdk-om-notice .form-wrap span:not(.dashicons){font-weight:500;margin-bottom:5px}.ti-sdk-om-notice input{border-radius:0;min-width:250px}.ti-sdk-om-notice a.components-button{align-items:center;display:flex;justify-content:center}.ti-sdk-om-notice .is-link{align-items:center;display:flex;text-decoration:none}.ti-sdk-om-notice .is-link span{line-height:normal}.ti-sdk-om-notice .dashicons{margin-right:2px;text-decoration:none}.ti-sdk-om-notice .done{align-items:flex-start;display:flex;flex-direction:column}.ti-sdk-om-notice .done a{width:auto}@media screen and (min-width:768px){.ti-sdk-om-notice img{display:block}}.compat-field-optimole th{display:none!important}.compat-field-optimole td{width:100%!important}.compat-field-optimole .ti-sdk-om-notice{margin:0}.om-notice-dismiss{position:absolute;right:10px;text-decoration:none!important;top:10px}.om-notice-dismiss:before{content:none}.ti-om-stack-wrap .om-stack-notice{--wp-admin-theme-color:#3858e9;--wp-admin-theme-color-darker-10:#2e47ba;align-items:center;display:flex;flex-direction:column;padding:20px 10px;position:relative;text-align:center}.ti-om-stack-wrap .om-stack-notice>span{display:none}.ti-om-stack-wrap .om-stack-notice img{max-width:90px!important}.ti-om-stack-wrap .om-stack-notice h2{font-size:18px;font-weight:600;margin:30px auto 10px}.ti-om-stack-wrap .om-stack-notice p{font-size:13px;line-height:17px;margin:0 auto;max-width:250px}.ti-om-stack-wrap .om-stack-notice i{color:#757575;font-size:12px;margin-top:10px}.ti-om-stack-wrap .om-stack-notice .cta{margin:20px auto 0;padding:10px 25px!important}.ti-om-stack-wrap .om-stack-notice .om-notice-dismiss{color:inherit}.ti-om-stack-wrap .om-stack-notice input{border-radius:0}.ti-om-stack-wrap .om-stack-notice form{display:grid;gap:10px;margin-top:10px;place-items:center;width:75%}.ti-om-stack-wrap .om-stack-notice .done{display:grid;gap:10px;margin-top:15px}.ti-om-stack-wrap .om-stack-notice .done p{font-size:15px;font-weight:500}.ti-om-stack-wrap .om-stack-notice .om-progress{margin:20px 0}.block-editor-block-inspector .ti-om-stack-wrap{border-top:1px solid #e0e0e0}.om-progress{align-items:center;display:flex;font-size:14px;gap:5px}.om-progress .spin{animation:om-rotation 2s linear infinite}@keyframes om-rotation{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}}.ti-sdk-om-promo.hidden{display:none}.media-sidebar .ti-sdk-om-notice input{flex-grow:1;min-width:unset}.media-sidebar .ti-sdk-om-notice .description{margin-bottom:10px}.media-sidebar .ti-sdk-om-notice .content{padding:15px 10px}.media-sidebar .ti-sdk-om-notice .actions{gap:10px}.media-sidebar .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}.attachment-info .ti-sdk-om-notice input{flex-grow:1;min-width:unset}.attachment-info .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}@media screen and (min-width:1200px){.attachment-info .ti-sdk-om-notice form{flex-wrap:unset}}
.ti-sdk-om-notice{--wp-admin-theme-color:#3858e9;--wp-admin-theme-color-darker-10:#2e47ba;border-left-color:#3858e9;padding:0;position:relative}.ti-sdk-om-notice .content{align-items:center;background:hsla(0,0%,100%,.75);display:flex;padding:15px 20px}.ti-sdk-om-notice img{display:none;margin-right:20px;max-width:100px}.ti-sdk-om-notice .description{color:#000;font-size:14px;margin-bottom:20px}.ti-sdk-om-notice .actions{display:flex;gap:20px;margin-bottom:0;margin-top:auto}.ti-sdk-om-notice form{align-items:center;display:flex;gap:10px}.ti-sdk-om-notice .form-wrap{display:grid}.ti-sdk-om-notice .form-wrap span:not(.dashicons){font-weight:500;margin-bottom:5px}.ti-sdk-om-notice input{border-radius:0;min-width:250px}.ti-sdk-om-notice a.components-button{align-items:center;display:flex;justify-content:center}.ti-sdk-om-notice .is-link{align-items:center;display:flex;text-decoration:none}.ti-sdk-om-notice .is-link span{line-height:normal}.ti-sdk-om-notice .dashicons{margin-right:2px;text-decoration:none}.ti-sdk-om-notice .done{align-items:flex-start;display:flex;flex-direction:column}.ti-sdk-om-notice .done a{width:auto}@media screen and (min-width:768px){.ti-sdk-om-notice img{display:block}}.compat-field-optimole th{display:none!important}.compat-field-optimole td{width:100%!important}.compat-field-optimole .ti-sdk-om-notice{margin:0}.om-notice-dismiss{position:absolute;right:10px;text-decoration:none!important;top:10px}.om-notice-dismiss:before{content:none}.ti-om-stack-wrap .om-stack-notice{--wp-admin-theme-color:#3858e9;--wp-admin-theme-color-darker-10:#2e47ba;align-items:center;display:flex;flex-direction:column;padding:20px 10px;position:relative;text-align:center}.ti-om-stack-wrap .om-stack-notice>span{display:none}.ti-om-stack-wrap .om-stack-notice img{max-width:90px!important}.ti-om-stack-wrap .om-stack-notice h2{font-size:18px;font-weight:600;margin:30px auto 10px}.ti-om-stack-wrap .om-stack-notice p{font-size:13px;line-height:17px;margin:0 auto;max-width:250px}.ti-om-stack-wrap .om-stack-notice i{color:#757575;font-size:12px;margin-top:10px}.ti-om-stack-wrap .om-stack-notice .cta{margin:20px auto 0;padding:10px 25px!important}.ti-om-stack-wrap .om-stack-notice .om-notice-dismiss{color:inherit}.ti-om-stack-wrap .om-stack-notice input{border-radius:0}.ti-om-stack-wrap .om-stack-notice form{display:grid;gap:10px;margin-top:10px;place-items:center;width:75%}.ti-om-stack-wrap .om-stack-notice .done{display:grid;gap:10px;margin-top:15px}.ti-om-stack-wrap .om-stack-notice .done p{font-size:15px;font-weight:500}.ti-om-stack-wrap .om-stack-notice .om-progress{margin:20px 0}.block-editor-block-inspector .ti-om-stack-wrap{border-top:1px solid #e0e0e0}.om-progress{align-items:center;display:flex;font-size:14px;gap:5px}.om-progress .spin{-webkit-animation:om-rotation 2s linear infinite;animation:om-rotation 2s linear infinite}@-webkit-keyframes om-rotation{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes om-rotation{0%{transform:rotate(0deg)}to{transform:rotate(359deg)}}.ti-sdk-om-promo.hidden{display:none}.media-sidebar .ti-sdk-om-notice input{flex-grow:1;min-width:unset}.media-sidebar .ti-sdk-om-notice .description{margin-bottom:10px}.media-sidebar .ti-sdk-om-notice .content{padding:15px 10px}.media-sidebar .ti-sdk-om-notice .actions{gap:10px}.media-sidebar .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}.attachment-info .ti-sdk-om-notice input{flex-grow:1;min-width:unset}.attachment-info .ti-sdk-om-notice form{flex-wrap:wrap;justify-content:center}@media screen and (min-width:1200px){.attachment-info .ti-sdk-om-notice form{flex-wrap:unset}}.ti-sdk-rop-notice{padding:10px;position:relative}.ti-sdk-rop-notice .rop-notice-actions{display:flex;gap:10px}.ti-sdk-rop-notice p{padding:0 10px 0 0}

View File

@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
return;
}
// Current SDK version and path.
$themeisle_sdk_version = '3.2.37';
$themeisle_sdk_version = '3.2.40';
$themeisle_sdk_path = dirname( __FILE__ );
global $themeisle_sdk_max_version;
@ -29,7 +29,7 @@ if ( ! is_file( $themeisle_sdk_path . $themeisle_sdk_relative_licenser_path ) &&
add_filter( 'themeisle_sdk_required_files', 'themeisle_sdk_load_licenser_if_present' );
}
if ( ( is_null( $themeisle_sdk_max_path ) || version_compare( $themeisle_sdk_version, $themeisle_sdk_max_path ) == 0 ) &&
if ( ( is_null( $themeisle_sdk_max_path ) || version_compare( $themeisle_sdk_version, $themeisle_sdk_max_version ) == 0 ) &&
apply_filters( 'themeisle_sdk_should_overwrite_path', false, $themeisle_sdk_path, $themeisle_sdk_max_path ) ) {
$themeisle_sdk_max_path = $themeisle_sdk_path;
}
@ -173,3 +173,46 @@ if ( ! function_exists( 'tsdk_lkey' ) ) {
return \ThemeisleSDK\Modules\Licenser::key( $file );
}
}
if ( ! function_exists( 'tsdk_support_link' ) ) {
/**
* Get Themeisle Support URL.
*
* @param string $file Product basefile.
*
* @return false|string Return support URL or false if no license is active.
*/
function tsdk_support_link( $file ) {
if ( ! did_action( 'init' ) ) {
_doing_it_wrong( __FUNCTION__, 'tsdk_support_link() should not be called before the init action.', '3.2.39' );
}
$params = [];
if ( ! tsdk_lis_valid( $file ) ) {
return false;
}
$product = \ThemeisleSDK\Product::get( $file );
if ( ! $product->requires_license() ) {
return false;
}
static $site_params = null;
if ( $site_params === null ) {
if ( is_user_logged_in() && function_exists( 'wp_get_current_user' ) ) {
$current_user = wp_get_current_user();
$site_params['semail'] = urlencode( $current_user->user_email );
}
$site_params['swb'] = urlencode( home_url() );
global $wp_version;
$site_params['snv'] = urlencode( sprintf( 'WP-%s-PHP-%s', $wp_version, ( PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION ) ) );
}
$params['slkey'] = tsdk_lkey( $file );
$params['sprd'] = urlencode( $product->get_name() );
$params['svrs'] = urlencode( $product->get_version() );
return add_query_arg(
array_merge( $site_params, $params ),
'https://store.themeisle.com/direct-support/'
);
}
}

View File

@ -54,6 +54,13 @@ class Promotions extends Abstract_Module {
*/
private $option_optimole = 'themeisle_sdk_promotions_optimole_installed';
/**
* Option key for ROP promos.
*
* @var string
*/
private $option_rop = 'themeisle_sdk_promotions_rop_installed';
/**
* Loaded promotion.
*
@ -86,6 +93,7 @@ class Promotions extends Abstract_Module {
$this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
$promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
$promotions_to_load[] = 'optimole';
$promotions_to_load[] = 'rop';
$this->promotions = $this->get_promotions();
@ -152,6 +160,10 @@ class Promotions extends Abstract_Module {
if ( isset( $_GET['optimole_reference_key'] ) ) {
update_option( 'optimole_reference_key', sanitize_key( $_GET['optimole_reference_key'] ) );
}
if ( isset( $_GET['rop_reference_key'] ) ) {
update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) );
}
}
/**
@ -191,6 +203,16 @@ class Promotions extends Abstract_Module {
'default' => false,
)
);
register_setting(
'themeisle_sdk_settings',
$this->option_rop,
array(
'type' => 'boolean',
'sanitize_callback' => 'rest_sanitize_boolean',
'show_in_rest' => true,
'default' => false,
)
);
}
/**
@ -201,7 +223,12 @@ class Promotions extends Abstract_Module {
private function get_sdk_uri() {
global $themeisle_sdk_max_path;
if ( $this->product->is_plugin() ) {
/**
* $themeisle_sdk_max_path can point to the theme when the theme version is higher.
* hence we also need to check that the path does not point to the theme else this will break the URL.
* References: https://github.com/Codeinwp/neve-pro-addon/issues/2403
*/
if ( $this->product->is_plugin() && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) {
return plugins_url( '/', $themeisle_sdk_max_path . '/themeisle-sdk/' );
};
@ -235,8 +262,9 @@ class Promotions extends Abstract_Module {
*/
private function is_plugin_installed( $plugin ) {
static $allowed_keys = [
'otter-blocks' => 'otter-blocks/otter-blocks.php',
'optimole-wp' => 'optimole-wp/optimole-wp.php',
'otter-blocks' => 'otter-blocks/otter-blocks.php',
'optimole-wp' => 'optimole-wp/optimole-wp.php',
'tweet-old-post' => 'tweet-old-post/tweet-old-post.php',
];
if ( ! isset( $allowed_keys[ $plugin ] ) ) {
@ -260,8 +288,11 @@ class Promotions extends Abstract_Module {
$had_otter_from_promo = get_option( $this->option_otter, false );
$has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
$had_optimole_from_promo = get_option( $this->option_optimole, false );
$has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
$had_rop_from_promo = get_option( $this->option_rop, false );
$is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
$has_enough_attachments = $this->has_min_media_attachments();
$has_enough_old_posts = $this->has_old_posts();
$all = [
'optimole' => [
@ -300,6 +331,12 @@ class Promotions extends Abstract_Module {
'screen' => 'editor',
],
],
'rop' => [
'rop-posts' => [
'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
'screen' => 'edit-post',
],
],
];
foreach ( $all as $slug => $data ) {
@ -370,6 +407,7 @@ class Promotions extends Abstract_Module {
$is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
$is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
$is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
$is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
$return = [];
@ -397,6 +435,11 @@ class Promotions extends Abstract_Module {
unset( $this->promotions[ $slug ][ $key ] );
}
break;
case 'edit-post':
if ( ! $is_posts ) {
unset( $this->promotions[ $slug ][ $key ] );
}
break;
}
}
@ -420,6 +463,9 @@ class Promotions extends Abstract_Module {
if ( $this->get_upsells_dismiss_time( 'om-media' ) === false ) {
add_action( 'admin_notices', [ $this, 'render_optimole_dash_notice' ] );
}
if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) {
add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
}
return;
}
@ -439,6 +485,10 @@ class Promotions extends Abstract_Module {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'admin_notices', [ $this, 'render_optimole_dash_notice' ] );
break;
case 'rop-posts':
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
break;
}
}
@ -483,7 +533,9 @@ class Promotions extends Abstract_Module {
'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ),
'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ),
'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ),
// translators: %s is the product name.
'title' => esc_html( sprintf( __( 'Recommended by %s', 'textdomain' ), $this->product->get_name() ) ),
]
@ -492,6 +544,19 @@ class Promotions extends Abstract_Module {
wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/style-index.css', [ 'wp-components' ], $asset_file['version'] );
}
/**
* Render rop notice.
*/
public function render_rop_dash_notice() {
$screen = get_current_screen();
if ( ! isset( $screen->id ) || $screen->id !== 'edit-post' ) {
return;
}
echo '<div id="ti-rop-notice" class="notice notice-info ti-sdk-rop-notice"></div>';
}
/**
* Add promo to attachment modal.
*
@ -580,4 +645,54 @@ class Promotions extends Abstract_Module {
}
return $attachment_count > 50;
}
/**
* Check if the website has more than 100 posts and over 10 are over a year old.
*
* @return bool
*/
private function has_old_posts() {
if ( $this->debug ) {
return true;
}
$posts_count = get_transient( 'tsk_posts_count' );
// Create a new WP_Query object to get all posts
$args = array(
'post_type' => 'post',
'posts_per_page' => 101, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'fields' => 'ids',
'no_found_rows' => true,
);
if ( false === $posts_count ) {
$query = new \WP_Query( $args );
$total_posts = $query->post_count;
wp_reset_postdata();
// Count the number of posts older than 1 year
$one_year_ago = gmdate( 'Y-m-d H:i:s', strtotime( '-1 year' ) );
$args['date_query'] = array(
array(
'before' => $one_year_ago,
'inclusive' => true,
),
);
$query = new \WP_Query( $args );
$old_posts = $query->post_count;
wp_reset_postdata();
$posts_count = array(
'total_posts' => $total_posts,
'old_posts' => $old_posts,
);
set_transient( 'tsk_posts_count', $posts_count, DAY_IN_SECONDS );
}
// Check if there are more than 100 posts and more than 10 old posts
return $posts_count['total_posts'] > 100 && $posts_count['old_posts'] > 10;
}
}