Plugin Directory

Changeset 2963465


Ignore:
Timestamp:
09/06/2023 08:22:18 AM (2 years ago)
Author:
thanhtd
Message:

Update

Location:
exmage-wp-image-links/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • exmage-wp-image-links/trunk/CHANGELOG.txt

    r2911544 r2963465  
     1/**1.0.16 - 2023.09.06**/
     2- Updated: Add stop processing button
     3
    14/**1.0.15 - 2023.05.12**/
    25- Updated: Keep exmage link of product when import product from csv
  • exmage-wp-image-links/trunk/exmage-wp-image-links.php

    r2911544 r2963465  
    44 * Plugin URI: https://villatheme.com/extensions/exmage-wordpress-image-links/
    55 * Description: Save storage by using external image URLs.
    6  * Version: 1.0.15
     6 * Version: 1.0.16
    77 * Author: VillaTheme(villatheme.com)
    88 * Author URI: https://villatheme.com
    99 * Text Domain: exmage-wp-image-links
    1010 * Copyright 2021-2023 VillaTheme.com. All rights reserved.
    11  * Tested up to: 6.2
     11 * Tested up to: 6.3
    1212 * Requires PHP: 7.0
    1313 **/
     14
    1415if ( ! defined( 'ABSPATH' ) ) {
    1516    exit;
    1617}
    1718
    18 define( 'EXMAGE_WP_IMAGE_LINKS_VERSION', '1.0.15' );
     19define( 'EXMAGE_WP_IMAGE_LINKS_VERSION', '1.0.16' );
    1920include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    2021define( 'EXMAGE_WP_IMAGE_LINKS_DIR', plugin_dir_path( __FILE__ ) );
     
    3233            add_action( 'plugins_loaded', array( $this, 'background_process' ) );
    3334            add_action( 'init', array( $this, 'init' ) );
     35            add_action( 'admin_init', array( $this, 'admin_init' ) );
    3436            add_action( 'admin_notices', array( $this, 'admin_notices' ) );
    3537            add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), PHP_INT_MAX );
    3638            add_action( 'wp_enqueue_media', array( $this, 'wp_enqueue_media' ), PHP_INT_MAX );
    3739            /*Short link to Add new media*/
    38             add_filter(
    39                 'plugin_action_links_exmage-wp-image-links/exmage-wp-image-links.php', array(
    40                     $this,
    41                     'settings_link'
    42                 )
    43             );
     40            add_filter( 'plugin_action_links_exmage-wp-image-links/exmage-wp-image-links.php', array( $this, 'settings_link' ) );
    4441            /*wp.media*/
    4542            add_action( 'post-upload-ui', array( $this, 'post_upload_ui' ), 20 );
     
    6158            add_filter( 'jetpack_photon_skip_image', array( $this, 'jetpack_photon_skip_image' ), 10, 3 );
    6259            /*WPML*/
    63             add_action( 'wpml_after_duplicate_attachment', array(
    64                 $this,
    65                 'wpml_after_duplicate_attachment'
    66             ), 10, 2 );
     60            add_action( 'wpml_after_duplicate_attachment', array( $this, 'wpml_after_duplicate_attachment' ), 10, 2 );
    6761
    6862            add_action( 'woocommerce_product_import_before_process_item', function () {
     
    8983        }
    9084
     85        public function stop_processing_button() {
     86            $href = add_query_arg( [ 'exmage_stop_processing' => 1, 'exmage_nonce' => wp_create_nonce( 'exmage_stop_processing' ) ] );
     87            printf( "<a href='%s' class='button' style='vertical-align: middle;'>%s</a>", esc_url( $href ), esc_html__( 'Stop processing', 'exmage-wp-image-links' ) );
     88        }
     89
    9190        /**
    9291         * Show status of background processing
    9392         */
    9493        public function admin_notices() {
     94            if ( get_site_option( 'exmage_background_process_image_kill_process' ) ) {
     95                return;
     96            }
     97
    9598            if ( self::$background_process->is_downloading() ) {
    9699                ?>
    97100                <div class="updated">
    98101                    <h4>
    99                         <?php printf( esc_html__( 'EXMAGE - WordPress Image Links: %s URLs are being processed in the background.', 'exmage-wp-image-links' ), self::$background_process->get_items_left() ) ?>
     102                        <?php
     103                        printf( esc_html__( 'EXMAGE - WordPress Image Links: %s URLs are being processed in the background.', 'exmage-wp-image-links' ), self::$background_process->get_items_left() );
     104                        $this->stop_processing_button();
     105                        ?>
    100106                    </h4>
    101107                </div>
     
    105111                <div class="updated">
    106112                    <h4>
    107                         <?php printf( esc_html__( 'EXMAGE - WordPress Image Links: %s URLs are in the queue.', 'exmage-wp-image-links' ), self::$background_process->get_items_left() ) ?>
     113                        <?php
     114                        printf( esc_html__( 'EXMAGE - WordPress Image Links: %s URLs are in the queue.', 'exmage-wp-image-links' ), self::$background_process->get_items_left() );
     115                        $this->stop_processing_button();
     116                        ?>
    108117                    </h4>
    109118                </div>
     
    118127                </div>
    119128                <?php
     129            }
     130        }
     131
     132        public function admin_init() {
     133            if ( isset( $_GET['exmage_stop_processing'], $_GET['exmage_nonce'] ) && wp_verify_nonce( $_GET['exmage_nonce'], 'exmage_stop_processing' ) ) {
     134                if ( ! empty( self::$background_process ) ) {
     135                    self::$background_process->kill_process();
     136                    $url = remove_query_arg( [ 'exmage_stop_processing', 'exmage_nonce' ] );
     137                    wp_safe_redirect( $url );
     138                    die;
     139                }
    120140            }
    121141        }
  • exmage-wp-image-links/trunk/includes/exmage-background-process.php

    r2846469 r2963465  
    6464            $this->delete_all_batches();
    6565            wp_clear_scheduled_hook( $this->cron_hook_identifier );
     66            update_site_option( $this->action . '_kill_process', true );
    6667        }
    6768    }
     
    141142        return $is_late;
    142143    }
     144
     145    protected function handle() {
     146        if ( get_site_option( $this->action . '_kill_process' ) ) {
     147            delete_site_option( $this->action . '_kill_process' );
     148            $this->delete_all_batches();
     149            $this->complete();
     150            wp_die();
     151        }
     152
     153        $this->lock_process();
     154
     155        do {
     156            $batch = $this->get_batch();
     157
     158            foreach ( $batch->data as $key => $value ) {
     159                $task = $this->task( $value );
     160
     161                if ( false !== $task ) {
     162                    $batch->data[ $key ] = $task;
     163                } else {
     164                    unset( $batch->data[ $key ] );
     165                }
     166
     167                if ( $this->time_exceeded() || $this->memory_exceeded() ) {
     168                    // Batch limits reached.
     169                    break;
     170                }
     171            }
     172
     173            // Update or delete current batch.
     174            if ( ! empty( $batch->data ) ) {
     175                $this->update( $batch->key, $batch->data );
     176            } else {
     177                $this->delete( $batch->key );
     178            }
     179        } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
     180
     181        $this->unlock_process();
     182
     183        // Start next batch or complete process.
     184        if ( ! $this->is_queue_empty() ) {
     185            $this->dispatch();
     186        } else {
     187            $this->complete();
     188        }
     189
     190        wp_die();
     191    }
     192
    143193}
  • exmage-wp-image-links/trunk/includes/support.php

    r2819412 r2963465  
    88    /**
    99     * Class VillaTheme_Support
    10      * 1.1.7
     10     * 1.1.8
    1111     */
    1212    class VillaTheme_Support {
    1313        protected $plugin_base_name;
    1414        protected $ads_data;
    15         protected $version = '1.1.7';
     15        protected $version = '1.1.8';
     16        protected $data = [];
    1617
    1718        public function __construct( $data ) {
     
    702703            $wp_admin_bar->add_node( array(
    703704                'id'     => 'villatheme_hide_toolbar',
    704                 'title'  => '<span style="font-family:dashicons" class="dashicons dashicons-dismiss"></span><span class="villatheme-hide-toolbar-button-title">Hide VillaTheme toolbar</span>',
     705                'title'  => '<span class="dashicons dashicons-dismiss"></span><span class="villatheme-hide-toolbar-button-title">Hide VillaTheme toolbar</span>',
    705706                'parent' => 'villatheme',
    706707                'href'   => add_query_arg( array( '_villatheme_nonce' => wp_create_nonce( 'villatheme_hide_toolbar' ) ) ),
     
    941942    }
    942943}
     944
     945if ( ! class_exists( 'VillaTheme_Require_Environment' ) ) {
     946    class VillaTheme_Require_Environment {
     947
     948        protected $args;
     949        protected $plugin_name;
     950        protected $notices = [];
     951
     952        public function __construct( $args ) {
     953            if ( ! did_action( 'plugins_loaded' ) ) {
     954                _doing_it_wrong( 'VillaTheme_Require_Environment', sprintf(
     955                /* translators: %s: plugins_loaded */
     956                    __( 'VillaTheme_Require_Environment should not be run before the %s hook.' ),
     957                    '<code>plugins_loaded</code>'
     958                ), '6.2.0' );
     959            }
     960
     961            $args = wp_parse_args( $args, [
     962                'plugin_name'     => '',
     963                'php_version'     => '',
     964                'wp_version'      => '',
     965                'wc_verison'      => '',
     966                'require_plugins' => [],
     967            ] );
     968
     969            $this->plugin_name = $args['plugin_name'];
     970
     971            $this->check( $args );
     972
     973            add_action( 'admin_notices', [ $this, 'notice' ] );
     974        }
     975
     976        protected function check( $args ) {
     977            if ( ! function_exists( 'install_plugin_install_status' ) ) {
     978                require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
     979            }
     980
     981            if ( ! function_exists( 'is_plugin_active' ) ) {
     982                require_once ABSPATH . 'wp-admin/includes/plugin.php';
     983            }
     984
     985            if ( ! empty( $args['php_version'] ) ) {
     986                $compatible_php = is_php_version_compatible( $args['php_version'] );
     987                if ( ! $compatible_php ) {
     988                    $this->notices[] = sprintf( "PHP version at least %s.", esc_html( $args['php_version'] ) );
     989                }
     990            }
     991
     992            if ( ! empty( $args['wp_version'] ) ) {
     993                $compatible_wp = is_wp_version_compatible( $args['wp_version'] );
     994                if ( ! $compatible_wp ) {
     995                    $this->notices[] = sprintf( "WordPress version at least %s.", esc_html( $args['wp_version'] ) );
     996                }
     997            }
     998
     999            if ( ! empty( $args['require_plugins'] ) ) {
     1000                foreach ( $args['require_plugins'] as $plugin ) {
     1001                    if ( empty( $plugin['version'] ) ) {
     1002                        $plugin['version'] = '';
     1003                    }
     1004
     1005                    $status              = install_plugin_install_status( $plugin );
     1006                    $require_plugin_name = $plugin['name'] ?? '';
     1007
     1008                    $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
     1009                    $requires_wp  = isset( $plugin['requires'] ) ? $plugin['requires'] : null;
     1010
     1011                    $compatible_php = is_php_version_compatible( $requires_php );
     1012                    $compatible_wp  = is_wp_version_compatible( $requires_wp );
     1013
     1014                    if ( ! $compatible_php || ! $compatible_wp ) {
     1015                        continue;
     1016                    }
     1017
     1018                    switch ( $status['status'] ) {
     1019
     1020                        case 'install':
     1021                            $this->notices[] = sprintf( "%s to be installed. <br><a href='%s' target='_blank' class='button button-primary' style='vertical-align: middle; margin-top: 5px;'>Install %s</a>",
     1022                                esc_html( $require_plugin_name ),
     1023                                esc_url( ! empty( $status['url'] ) ? $status['url'] : '#' ),
     1024                                esc_html( $require_plugin_name ) );
     1025
     1026                            break;
     1027
     1028                        default:
     1029
     1030                            if ( ! is_plugin_active( $status['file'] ) && current_user_can( 'activate_plugin', $status['file'] ) ) {
     1031                                $activate_url = add_query_arg(
     1032                                    [
     1033                                        '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
     1034                                        'action'   => 'activate',
     1035                                        'plugin'   => $status['file'],
     1036                                    ],
     1037                                    network_admin_url( 'plugins.php' )
     1038                                );
     1039
     1040                                $this->notices[] = sprintf( "%s is installed and activated. <br> <a href='%s' target='_blank' class='button button-primary' style='vertical-align: middle; margin-top: 5px;'>Active %s</a>",
     1041                                    esc_html( $require_plugin_name ),
     1042                                    esc_url( $activate_url ),
     1043                                    esc_html( $require_plugin_name ) );
     1044
     1045                            }
     1046
     1047                            if ( $plugin['slug'] == 'woocommerce' && ! empty( $args['wc_version'] ) && is_plugin_active( $status['file'] ) ) {
     1048                                $wc_current_version = get_option( 'woocommerce_version' );
     1049                                if ( ! version_compare( $wc_current_version, $args['wc_version'], '>=' ) ) {
     1050                                    $this->notices[] = sprintf( "WooCommerce version at least %s.", esc_html( $args['wc_version'] ) );
     1051                                }
     1052                            }
     1053
     1054                            break;
     1055                    }
     1056                }
     1057            }
     1058        }
     1059
     1060        public function notice() {
     1061            $screen = get_current_screen();
     1062
     1063            if ( ! current_user_can( 'manage_options' ) || $screen->id === 'update' ) {
     1064                return;
     1065            }
     1066
     1067            if ( ! empty( $this->notices ) ) {
     1068                ?>
     1069                <div class="error">
     1070                    <?php
     1071                    if ( count( $this->notices ) > 1 ) {
     1072                        printf( "<p>%s requires:</p>", esc_html( $this->plugin_name ) );
     1073                        ?>
     1074                        <ol>
     1075                            <?php
     1076                            foreach ( $this->notices as $notice ) {
     1077                                printf( "<li>%s</li>", wp_kses_post( $notice ) );
     1078                            }
     1079                            ?>
     1080                        </ol>
     1081                        <?php
     1082                    } else {
     1083                        printf( "<p>%s requires %s</p>", esc_html( $this->plugin_name ), wp_kses_post( current( $this->notices ) ) );
     1084                    }
     1085                    ?>
     1086                </div>
     1087                <?php
     1088            }
     1089        }
     1090
     1091        public function has_error() {
     1092            return ! empty( $this->notices );
     1093        }
     1094    }
     1095}
  • exmage-wp-image-links/trunk/readme.txt

    r2911544 r2963465  
    44Tags: ecommerce, elementor gallery with links, elementor image carousel link, woocommerce, woocommerce product image external url, wordpress, wordpress gallery custom links, wordpress gallery link, wordpress gallery with links, wordpress image links
    55Requires at least: 5.0.0
    6 Tested up to: 6.1
     6Tested up to: 6.3
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    161161== Changelog ==
    162162
     163/**1.0.16 - 2023.09.06**/
     164- Updated: Add stop processing button
     165
    163166/**1.0.15 - 2023.05.12**/
    164167- Updated: Keep exmage link of product when import product from csv
Note: See TracChangeset for help on using the changeset viewer.