Plugin Directory

Changeset 2318858


Ignore:
Timestamp:
06/05/2020 09:29:47 AM (6 years ago)
Author:
cloudimage
Message:

Release 2.9.0

Location:
cloudimage/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cloudimage/trunk/README.txt

    r2306989 r2318858  
    66Tested up to: 5.4.0
    77Requires PHP: 5.6
    8 Stable tag: 2.8.9
     8Stable tag: 2.9.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    265265* Instagram widget fix
    266266
     267= 2.9.0 =
     268* Add options to choose if plugin should work when user is logged in
     269
    267270== Upgrade Notice ==
    268271* Upgrading from version 1 to 2 can show you warnings in the admin section
  • cloudimage/trunk/admin/class-cloudimage-admin.php

    r2292739 r2318858  
    169169
    170170        $valid['cloudimage_use_js_powered_mode'] = empty($input['use_js_powered_mode']) ? 0 : 1;
     171        $valid['cloudimage_use_for_logged_in_users'] = empty($input['use_for_logged_in_users']) ? 0 : 1;
    171172
    172173        return $valid;
  • cloudimage/trunk/admin/css/cloudimage-admin.css

    r2300710 r2318858  
    364364}
    365365
    366 #cloudimage-current-mode {
     366#cloudimage-current-mode, #cloudimage-user-mode {
    367367    display: inline-block;
    368368    font-size: 18px;
  • cloudimage/trunk/admin/partials/cloudimage-admin-display.php

    r2300710 r2318858  
    2020$domain = $options['cloudimage_domain'];
    2121$use_js_powered_mode = $options['cloudimage_use_js_powered_mode'];
     22$use_for_logged_in_users = $options['cloudimage_use_for_logged_in_users'];
     23
    2224?>
    2325
     
    137139                        </tr>
    138140
     141                        <!-- Use if user is logged in -->
     142                        <tr id="use-for-logged-in-users">
     143                            <th scope="row" class="titledesc">
     144                                <label for="<?php echo $this->plugin_name; ?>-use_for_logged_in_users">
     145                                    <div id="cloudimage-user-mode"><?php esc_attr_e('Use when logged in', 'cloudimage'); ?></div>
     146                                    <div class="tooltip">?
     147                                        <span class="tooltiptext"><?php esc_attr_e('Use Cloudimage even the user is logged-in. You need to adapt to your need in some scenarious, it is better to save CDN bandwidth.', 'cloudimage') ?></span>
     148                                    </div>
     149                                </label>
     150                            </th>
     151
     152                            <td class="forminp forminp-text">
     153                                <label class="switch">
     154                                    <input type="checkbox" id="<?php echo $this->plugin_name; ?>-use_for_logged_in_users"
     155                                           name="<?php echo $this->plugin_name; ?>[use_for_logged_in_users]" <?php checked($use_for_logged_in_users, 1); ?> >
     156                                    <span class="slider round"></span>
     157                                </label>
     158
     159                            </td>
     160                        </tr>
     161
    139162                        </tbody>
    140163                    </table>
  • cloudimage/trunk/cloudimage.php

    r2306989 r2318858  
    1212 * Plugin Name:       Cloudimage - Responsive Images as a Service
    1313 * Description:       The easiest way to <strong>deliver lightning fast images</strong> to your users.
    14  * Version:           2.8.9
     14 * Version:           2.9.0
    1515 * Author:            Cloudimage
    1616 * Author URI:        https://cloudimage.io
     
    3030 * Start at version 1.0.0
    3131 */
    32 define('CLOUDIMAGE_VERSION', '2.8.9');
     32define('CLOUDIMAGE_VERSION', '2.9.0');
    3333
    3434/**
  • cloudimage/trunk/includes/class-cloudimage.php

    r2306989 r2318858  
    8383            $this->version = CLOUDIMAGE_VERSION;
    8484        } else {
    85             $this->version = '2.8.9';
     85            $this->version = '2.9.0';
    8686        }
    8787        $this->plugin_name = 'cloudimage';
  • cloudimage/trunk/public/class-cloudimage-public.php

    r2306989 r2318858  
    6969    private $cloudimage_skip_classes;
    7070
     71    /**
     72     * Define if Cloudimage optimization should work when user is logged-in
     73     *
     74     * @since    2.9.0
     75     * @access   private
     76     * @var      int $cloudimage_use_in_admin 0 or 1 regarding is optimization should work when users are logged in
     77     */
     78    private $cloudimage_use_for_logged_in_users;
    7179
    7280    /**
     
    9098        $this->cloudimage_domain = $this->cloudimage_options['cloudimage_domain'];
    9199        $this->cloudimage_use_js_powered_mode = $this->cloudimage_options['cloudimage_use_js_powered_mode'];
     100
     101        $cloudimage_use_for_logged_in_users = isset($this->cloudimage_options['cloudimage_use_for_logged_in_users']) ? $this->cloudimage_options['cloudimage_use_for_logged_in_users'] : 0;
     102        $this->cloudimage_use_for_logged_in_users = $cloudimage_use_for_logged_in_users;
    92103    }
    93104
     
    143154    public function filter_cloudimage_wp_get_attachment_url($url, $post_id)
    144155    {
    145         if ($this->is_dev || !$this->cloudimage_domain || is_admin() || is_user_logged_in()) {
     156        # Check if we need to perform the optimization for the current user state (logged in or not)
     157        $logged_in_user = $this->cloudimage_check_logged_user();
     158
     159        if ($this->is_dev || !$this->cloudimage_domain || $logged_in_user) {
    146160            return $url;
    147161        }
     
    171185    public function filter_cloudimage_wp_calculate_image_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id)
    172186    {
    173         if ($this->is_dev || !$this->cloudimage_domain || is_admin() || is_user_logged_in()) {
    174 
     187        # Check if we need to perform the optimization for the current user state (logged in or not)
     188        $logged_in_user = $this->cloudimage_check_logged_user();
     189
     190        if ($this->is_dev || !$this->cloudimage_domain || $logged_in_user) {
     191            # Return original sources
    175192            return $sources;
    176193        }
     
    228245    public function filter_cloudimage_image_downsize($short_cut, $id, $size)
    229246    {
    230         if ($short_cut || $this->is_dev || !$this->cloudimage_domain || $this->cloudimage_use_js_powered_mode || is_admin() || is_user_logged_in()) {
     247        # Check if we need to perform the optimization for the current user state (logged in or not)
     248        $logged_in_user = $this->cloudimage_check_logged_user();
     249
     250        if ($short_cut || $this->is_dev || !$this->cloudimage_domain || $this->cloudimage_use_js_powered_mode || $logged_in_user) {
    231251            return false;
    232252        }
     
    895915    public function cloudimage_buffer_start()
    896916    {
    897         if ($this->cloudimage_use_js_powered_mode && !is_admin() && !is_user_logged_in()) {
     917        # Check if we need to perform the optimization for the current user state (logged in or not)
     918        $logged_in_user = $this->cloudimage_check_logged_user();
     919
     920        if ($this->cloudimage_use_js_powered_mode && !$logged_in_user) {
    898921            ob_start([$this, 'filter_cloudimage_the_content']);
    899922        }
     
    912935        return str_replace("/v7/", "/", $url);
    913936    }
     937
     938    /**
     939     * Function to return if we need to perform optimization with Cloudimage
     940     *
     941     * @return bool
     942     *
     943     * @since    2.9.0
     944     */
     945    public function cloudimage_check_logged_user()
     946    {
     947        if ((is_admin() || is_user_logged_in()) && !$this->cloudimage_use_for_logged_in_users) {
     948            return 1;
     949        }
     950
     951        return 0;
     952    }
    914953}
Note: See TracChangeset for help on using the changeset viewer.