plugin updates

This commit is contained in:
Tony Volpe
2024-11-15 13:53:04 -05:00
parent 1293d604ca
commit 0238f0c4ca
2009 changed files with 163492 additions and 89543 deletions

View File

@@ -825,6 +825,8 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
update_imagify_option( 'api_key', $api_key );
delete_transient( 'imagify_user_cache' );
wp_send_json_success();
}
@@ -980,7 +982,7 @@ class Imagify_Admin_Ajax_Post extends Imagify_Admin_Ajax_Post_Deprecated {
} elseif ( $user->get_percent_unconsumed_quota <= 20 ) {
$user->best_plan_title = __( 'Oops, It\'s almost over!', 'imagify' );
} else {
$user->best_plan_title = __( 'You\'re new to Imagify?', 'imagify' );
$user->best_plan_title = __( 'Unlock Imagify\'s full potential', 'imagify' );
}
wp_send_json_success( $user );

View File

@@ -276,14 +276,14 @@ class Imagify_Assets extends Imagify_Assets_Deprecated {
* Loaded in the bulk optimization page.
*/
if ( imagify_is_screen( 'bulk' ) ) {
$this->enqueue_assets( [ 'pricing-modal', 'bulk' ] );
$this->enqueue_assets( 'bulk' );
}
/*
* Loaded in the settings page.
*/
if ( imagify_is_screen( 'imagify-settings' ) ) {
$this->enqueue_assets( [ 'sweetalert', 'notices', 'twentytwenty', 'pricing-modal', 'options' ] );
$this->enqueue_assets( [ 'sweetalert', 'notices', 'twentytwenty', 'options' ] );
}
/*
@@ -293,6 +293,8 @@ class Imagify_Assets extends Imagify_Assets_Deprecated {
$this->enqueue_assets( [ 'files-list', 'twentytwenty' ] );
}
$this->enqueue_assets( 'pricing-modal' );
/**
* Triggered after Imagify CSS and JS have been enqueued.
*

View File

@@ -36,11 +36,11 @@ class Imagify_Options extends Imagify_Abstract_Options {
'resize_larger_w' => 0,
'display_nextgen' => 0,
'display_nextgen_method' => 'picture',
'display_webp' => 0,
'display_webp_method' => 'picture',
'display_webp' => 0,
'display_webp_method' => 'picture',
'cdn_url' => '',
'disallowed-sizes' => [],
'admin_bar_menu' => 0,
'admin_bar_menu' => 1,
'partner_links' => 0,
'convert_to_avif' => 0,
'convert_to_webp' => 0,

View File

@@ -359,6 +359,8 @@ class Imagify_Settings {
return;
}
delete_transient( 'imagify_user_cache' );
// Handle API key validation cache and notices.
if ( Imagify_Requirements::is_api_key_valid( true ) ) {
Notices::dismiss_notice( 'wrong-api-key' );

View File

@@ -1,6 +1,7 @@
<?php
use Imagify\User\User;
use Imagify\Dependencies\WPMedia\PluginFamily\Model\PluginFamily;
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
@@ -120,16 +121,12 @@ class Imagify_Views {
add_action( 'network_admin_menu', [ $this, 'add_network_menus' ] );
}
// Action links in plugins list.
$basename = plugin_basename( IMAGIFY_FILE );
add_filter( 'plugin_action_links_' . $basename, [ $this, 'plugin_action_links' ] );
add_filter( 'network_admin_plugin_action_links_' . $basename, [ $this, 'plugin_action_links' ] );
// Save the "per page" option value from the files list screen.
add_filter( 'set-screen-option', [ 'Imagify_Files_List_Table', 'save_screen_options' ], 10, 3 );
// JS templates in footer.
add_action( 'admin_print_footer_scripts', [ $this, 'print_js_templates' ] );
add_action( 'admin_footer', [ $this, 'print_modal_payment' ] );
}
@@ -208,27 +205,6 @@ class Imagify_Views {
}
}
/** ----------------------------------------------------------------------------------------- */
/** PLUGIN ACTION LINKS ===================================================================== */
/** ----------------------------------------------------------------------------------------- */
/**
* Add links to the plugin row in the plugins list.
*
* @since 1.7
*
* @param array $actions An array of action links.
* @return array
*/
public function plugin_action_links( $actions ) {
array_unshift( $actions, sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( imagify_get_external_url( 'documentation' ) ), __( 'Documentation', 'imagify' ) ) );
array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url( 'bulk-optimization' ) ), __( 'Bulk Optimization', 'imagify' ) ) );
array_unshift( $actions, sprintf( '<a href="%s">%s</a>', esc_url( get_imagify_admin_url() ), __( 'Settings', 'imagify' ) ) );
return $actions;
}
/** ----------------------------------------------------------------------------------------- */
/** MAIN PAGE TEMPLATES ===================================================================== */
/** ----------------------------------------------------------------------------------------- */
@@ -239,7 +215,14 @@ class Imagify_Views {
* @since 1.7
*/
public function display_settings_page() {
$this->print_template( 'page-settings' );
$plugin_family = new PluginFamily();
$plugins_array = $plugin_family->get_filtered_plugins( 'imagify/imagify' );
$data = [
'plugin_family' => $plugins_array['uncategorized'],
];
$this->print_template( 'page-settings', $data );
}
/**
@@ -651,6 +634,36 @@ class Imagify_Views {
}
}
/**
* Print the payment modal.
*/
public function print_modal_payment() {
$this->print_template(
'modal-payment',
[
'attachments_number' => $this->get_attachments_number_modal(),
]
);
}
/**
* Get the number of attachments to display in the payment modal.
*
* @return int
*/
private function get_attachments_number_modal() {
$transient = get_transient( 'imagify_attachments_number_modal' );
if ( false !== $transient ) {
return $transient;
}
$attachments_number = imagify_count_attachments() + Imagify_Files_Stats::count_all_files();
set_transient( 'imagify_attachments_number_modal', $attachments_number, 1 * DAY_IN_SECONDS );
return $attachments_number;
}
/** ----------------------------------------------------------------------------------------- */
/** TOOLS =================================================================================== */

View File

@@ -86,6 +86,10 @@ class Imagify {
* @return object
*/
public function get_user() {
if ( empty( $this->api_key ) ) {
return new WP_Error( 'api_key_missing', __( 'API key required.', 'imagify' ) );
}
global $wp_current_filter;
if ( isset( static::$user ) ) {

View File

@@ -1,79 +0,0 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin uh?' );
add_action( 'admin_bar_menu', '_imagify_admin_bar', IMAGIFY_INT_MAX );
/**
* Add Imagify menu in the admin bar.
*
* @since 1.0
*
* @param object $wp_admin_bar WP_Admin_Bar instance, passed by reference.
*/
function _imagify_admin_bar( $wp_admin_bar ) {
if ( ! imagify_get_context( 'wp' )->current_user_can( 'manage' ) ) {
return;
}
if ( ! get_imagify_option( 'admin_bar_menu' ) ) {
return;
}
// Parent.
$wp_admin_bar->add_menu( array(
'id' => 'imagify',
'title' => 'Imagify',
'href' => get_imagify_admin_url(),
) );
// Settings.
$wp_admin_bar->add_menu(array(
'parent' => 'imagify',
'id' => 'imagify-settings',
'title' => __( 'Settings' ),
'href' => get_imagify_admin_url(),
) );
// Bulk Optimization.
if ( ! is_network_admin() ) {
$wp_admin_bar->add_menu(array(
'parent' => 'imagify',
'id' => 'imagify-bulk-optimization',
'title' => __( 'Bulk Optimization', 'imagify' ),
'href' => get_imagify_admin_url( 'bulk-optimization' ),
) );
}
// Documentation.
$wp_admin_bar->add_menu(array(
'parent' => 'imagify',
'id' => 'imagify-documentation',
'title' => __( 'Documentation', 'imagify' ),
'href' => imagify_get_external_url( 'documentation' ),
'meta' => array(
'target' => '_blank',
),
) );
// Rate it.
$wp_admin_bar->add_menu(array(
'parent' => 'imagify',
'id' => 'imagify-rate-it',
/* translators: %s is WordPress.org. */
'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ),
'href' => imagify_get_external_url( 'rate' ),
'meta' => array(
'target' => '_blank',
),
) );
// Quota & Profile informations.
if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT || ! get_imagify_option( 'api_key' ) ) {
return;
}
$wp_admin_bar->add_menu( array(
'parent' => 'imagify',
'id' => 'imagify-profile',
'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '<div id="wp-admin-bar-imagify-profile-loading" class="hide-if-no-js">' . __( 'Loading...', 'imagify' ) . '</div><div id="wp-admin-bar-imagify-profile-content" class="hide-if-no-js"></div>',
) );
}

View File

@@ -40,7 +40,30 @@ function update_imagify_user( $data ) {
* @return object
*/
function get_imagify_user() {
return imagify()->get_user();
$user = get_transient( 'imagify_user_cache' );
if ( false !== $user ) {
return $user;
}
$user = imagify()->get_user();
// Fill user object with missed details before saving the transient.
if ( is_wp_error( $user ) ) {
$user->id = 0;
$user->email = '';
$user->plan_id = 0;
$user->plan_label = '';
$user->quota = 0;
$user->extra_quota = 0;
$user->extra_quota_consumed = 0;
$user->consumed_current_month_quota = 0;
$user->next_date_update = null;
$user->is_active = false;
$user->is_monthly = false;
}
set_transient( 'imagify_user_cache', $user, 5 * MINUTE_IN_SECONDS );
return $user;
}
/**