Plugin Directory

Changeset 3047640


Ignore:
Timestamp:
03/08/2024 07:25:52 AM (2 years ago)
Author:
wedos
Message:

page caching improvements, rest api improvements

Location:
wgpwpp/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • wgpwpp/trunk/README.txt

    r3046829 r3047640  
    55Requires at least: 5.6
    66Tested up to: 6.4
    7 Stable tag: 1.1.2
     7Stable tag: 1.1.3
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    112112
    113113== Changelog ==
     114= v1.1.3 =
     115* Page caching improvements
     116* REST API improvements
     117
    114118= v1.1.2 =
    115119* Page caching improvements
  • wgpwpp/trunk/admin/class-wgpwpp-cache-setting.php

    r3046829 r3047640  
    104104        $this->plugin->admin_section->notices->warning($text)->render();
    105105      }
    106       elseif ($cache_plugins_detection['advanced-cache'])
     106      elseif ($cache_plugins_detection['advanced-caching'])
    107107      {
    108108        $text = __('It seems there is activated another page caching plugin. We strongly recommend to deactivate all other page caching plugins before activating our page caching to avoid incompatibilities.', 'wgpwpp');
  • wgpwpp/trunk/admin/class-wgpwpp-verification.php

    r3045994 r3047640  
    2323
    2424    /**
    25      * Plugin instance
    26      *
    27      * @since 1.0.0
    28      * @var Wgpwpp
    29      */
    30     private Wgpwpp $plugin;
    31 
    32     /**
    3325     * Authorization controller instance
    3426     *
     
    4840    public function __construct(Wgpwpp $plugin, Wgpwpp_Authorization $authorization)
    4941    {
    50         $this->plugin = $plugin;
     42        parent::__construct($plugin);
    5143        $this->authorization = $authorization;
    5244
  • wgpwpp/trunk/includes/class-wgpwpp-notify.php

    r3045994 r3047640  
    2020  const SCOPE = 'wgp_wp_notify';
    2121
    22   /**
    23    * Main plugin class
    24    *
    25    * @since 1.1.0
    26    * @var Wgpwpp
    27    */
    28   private Wgpwpp $plugin;
    29 
    3022
    3123  /**
     
    3830  public function __construct(Wgpwpp $plugin)
    3931  {
    40     $this->plugin = $plugin;
     32    parent::__construct($plugin);
    4133    $this->define_hooks();
    4234  }
  • wgpwpp/trunk/includes/class-wgpwpp-rest-api.php

    r3045994 r3047640  
    3838  const AUTHORIZATION_SERVER_TIMEOUT = 5;
    3939
     40  /**
     41   * Main plugin class
     42   *
     43   * @since 1.1.3
     44   * @var Wgpwpp
     45   */
     46  protected Wgpwpp $plugin;
     47
     48
     49  /**
     50   * Constructor
     51   *
     52   * @since 1.1.3
     53   * @param Wgpwpp $plugin
     54   */
     55  public function __construct(Wgpwpp $plugin)
     56  {
     57    $this->plugin = $plugin;
     58  }
     59
    4060
    4161  /**
     
    5373
    5474    if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200)
     75    {
     76      $this->log('Failed to get allowed IP address list', $response, Wgpwpp_Log::TYPE_ERROR);
    5577      return NULL;
     78    }
    5679
    5780    $ips = json_decode($response['body']);
    5881    if (!$ips)
     82    {
     83      $this->log('Failed to get allowed IP address list', $response, Wgpwpp_Log::TYPE_ERROR);
    5984      return NULL;
     85    }
    6086
    6187    return $ips;
     
    78104    $server_ip = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : NULL;
    79105    if (!$server_ip)
     106    {
     107      $this->log('Failed to get origin server IP address', $_SERVER, Wgpwpp_Log::TYPE_ERROR);
    80108      throw new Exception("Failed to get origin server IP address", 2);
     109    }
    81110
    82111    $is_ip_allowed = false;
     
    98127
    99128    if (!$is_ip_allowed)
     129    {
     130      $this->log('Not allowed origin IP address. Unauthorized request.', $server_ip, Wgpwpp_Log::TYPE_ERROR);
    100131      throw new Exception("Not allowed origin IP address: ".$server_ip, 3);
     132    }
    101133  }
    102134
     
    113145    $headers = $request->get_headers();
    114146    if (!isset($headers['authorization']) || !is_array($headers['authorization']) || !count($headers['authorization']))
     147    {
     148      $this->log('Missing authorization header. Unauthorized request.', $request, Wgpwpp_Log::TYPE_ERROR);
    115149      return NULL;
     150    }
    116151
    117152    $authorization = current($headers['authorization']);
     
    151186    // chyba API volání
    152187    if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200)
     188    {
     189      $this->log('Failed to verify authorization token. Unable to contact authorization server.', $response, Wgpwpp_Log::TYPE_ERROR);
    153190      throw new Exception("Authorization server connection failure", 1);
     191    }
    154192
    155193    $response_data = json_decode($response['body'], true);
     
    158196      $msg = $response_data['msg'] ?? '';
    159197      $msg = $response_data['data']['error_description'] ?? $msg;
     198      $this->log('Invalid authorization token.', $response_data, Wgpwpp_Log::TYPE_ERROR);
    160199      throw new Exception('Invalid token. '.$msg, 2);
    161200    }
     
    207246    return true;
    208247  }
     248
     249
     250  /**
     251   * Log for WP REST API
     252   *
     253   * @since 1.1.3
     254   * @param string $msg
     255   * @param WP_Error|mixed $data
     256   * @param string $type
     257   * @return void
     258   */
     259  private function log(string $msg, $data = NULL, string $type = Wgpwpp_Log::TYPE_INFO)
     260  {
     261    $msg = "\tWP REST API :: ".$msg;
     262    $this->plugin->log->write($msg, $data, $type);
     263  }
    209264}
  • wgpwpp/trunk/includes/class-wgpwpp-wp-cache.php

    r3046829 r3047640  
    804804    }
    805805
    806     return ['advanced-caching' => $advanced_caching, 'wp_cache_constant' => $wp_cache_constant, 'known-cache-plugins' => $known_cache_plugins,];
     806    return [
     807      'advanced-caching' => $advanced_caching,
     808      'wp_cache_constant' => $wp_cache_constant,
     809      'known-cache-plugins' => $known_cache_plugins,
     810    ];
    807811  }
    808812
  • wgpwpp/trunk/includes/class-wgpwpp-wpinfo.php

    r3045994 r3047640  
    2020  const SCOPE = 'wgp-wp-info';
    2121
    22   /**
    23    * Plugin main class
    24    * @var Wgpwpp
    25    */
    26   private $plugin;
    27 
    2822
    2923  /**
     
    3529  public function __construct(Wgpwpp $plugin)
    3630  {
    37     $this->plugin = $plugin;
    38 
     31    parent::__construct($plugin);
    3932    $this->define_hooks();
    4033  }
  • wgpwpp/trunk/includes/wpcache/advanced-cache.php

    r3045994 r3047640  
    1313}
    1414
     15if (!file_exists($filename))
     16  return;
     17
    1518include_once( $filename );
  • wgpwpp/trunk/loader.php

    r3046829 r3047640  
    1111 * Rename this for your plugin and update it as you release new versions.
    1212 */
    13 const WGPWPP_VERSION = '1.1.2';
     13const WGPWPP_VERSION = '1.1.3';
    1414const WGPWPP_PLUGIN_NAME = 'wgpwpp';
    1515const WGPWPP_PLUGIN_FILE = __FILE__;
  • wgpwpp/trunk/wgpwpp.php

    r3046829 r3047640  
    1717 * Plugin URI:        https://www.wedos.com/protection/#wgp-plugin
    1818 * Description:       Activate and use the WEDOS Global service. WEDOS Global brings global security for your WordPress website, ensures low latency and minimal loading time.
    19  * Version:           1.1.2
     19 * Version:           1.1.3
    2020 * Requires at least: 5.6
    2121 * Requires PHP:      7.4
Note: See TracChangeset for help on using the changeset viewer.