PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / 3.8.0
TinyPNG – JPEG, PNG & WebP image compression v3.8.0
3.8.0 3.7.0 3.6.14 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.7.0 1.7.1 1.7.2 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.0.0 3.0.1 3.1.0 3.2.0 3.2.1 3.3 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.10 3.6.11 3.6.12 3.6.13 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
tiny-compress-images / src / class-tiny-wp-base.php
tiny-compress-images / src Last commit date
compatibility 2 months ago config 2 months ago css 7 months ago data 4 years ago images 4 years ago js 1 week ago vendor 6 months ago views 1 week ago class-tiny-apache-rewrite.php 2 months ago class-tiny-bulk-optimization.php 2 months ago class-tiny-cli.php 2 months ago class-tiny-compress-client.php 1 week ago class-tiny-compress-fopen.php 2 months ago class-tiny-compress.php 1 week ago class-tiny-conversion.php 4 months ago class-tiny-diagnostics.php 7 months ago class-tiny-exception.php 7 months ago class-tiny-helpers.php 2 months ago class-tiny-image-size.php 1 week ago class-tiny-image.php 1 week ago class-tiny-logger.php 2 months ago class-tiny-migrate.php 2 months ago class-tiny-notices.php 2 months ago class-tiny-php.php 2 months ago class-tiny-picture.php 2 months ago class-tiny-plugin.php 1 week ago class-tiny-settings.php 1 week ago class-tiny-source-base.php 1 week ago class-tiny-source-image.php 7 months ago class-tiny-source-picture.php 7 months ago class-tiny-wp-base.php 2 months ago
class-tiny-wp-base.php
111 lines
1 <?php
2 /*
3 * Tiny Compress Images - WordPress plugin.
4 * Copyright (C) 2015-2018 Tinify B.V.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 abstract class Tiny_WP_Base {
22 const NAME = 'tiny-compress-images';
23 const PREFIX = 'tinypng_';
24
25 private static $wp_version;
26
27 public static function wp_version() {
28 if ( is_null( self::$wp_version ) ) {
29 // Try to use unmodified version
30 include ABSPATH . WPINC . '/version.php';
31 if ( isset( $wp_version ) ) {
32 self::$wp_version = $wp_version;
33 } else {
34 self::$wp_version = $GLOBALS['wp_version'];
35 }
36 }
37 return self::$wp_version;
38 }
39
40 public static function check_wp_version( $version ) {
41 return floatval( self::wp_version() ) >= $version;
42 }
43
44 protected function is_xmlrpc_request() {
45 return defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST;
46 }
47
48 protected function doing_ajax_request() {
49 return defined( 'DOING_AJAX' ) && DOING_AJAX;
50 }
51
52 protected function is_cli() {
53 return defined( 'WP_CLI' ) && WP_CLI;
54 }
55
56 protected static function get_prefixed_name( $name ) {
57 return self::PREFIX . $name;
58 }
59
60 public function __construct() {
61 add_action( 'init', $this->get_method( 'init' ) );
62 add_action( 'rest_api_init', $this->get_method( 'rest_init' ) );
63
64 if ( self::is_xmlrpc_request() ) {
65 add_action( 'init', $this->get_method( 'xmlrpc_init' ) );
66 } elseif ( self::doing_ajax_request() ) {
67 add_action( 'admin_init', $this->get_method( 'ajax_init' ) );
68 } elseif ( is_admin() ) {
69 add_action( 'admin_init', $this->get_method( 'admin_init' ) );
70 add_action( 'admin_menu', $this->get_method( 'admin_menu' ) );
71 }
72
73 if ( self::is_cli() ) {
74 add_action( 'cli_init', $this->get_method( 'cli_init' ) );
75 }
76 }
77
78 protected function get_method( $name ) {
79 return array( $this, $name );
80 }
81
82 protected function get_static_method( $name ) {
83 return array( get_class( $this ), $name );
84 }
85
86 protected function get_user_id() {
87 return get_current_user_id();
88 }
89
90 public function init() {
91 }
92
93 public function xmlrpc_init() {
94 }
95
96 public function ajax_init() {
97 }
98
99 public function admin_init() {
100 }
101
102 public function admin_menu() {
103 }
104
105 public function rest_init() {
106 }
107
108 public function cli_init() {
109 }
110 }
111