PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / 2.2.0
TinyPNG – JPEG, PNG & WebP image compression v2.2.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
config 9 years ago css 9 years ago data 9 years ago images 9 years ago js 9 years ago vendor 9 years ago views 9 years ago class-tiny-compress-client.php 9 years ago class-tiny-compress-fopen.php 9 years ago class-tiny-compress.php 9 years ago class-tiny-exception.php 9 years ago class-tiny-image-size.php 9 years ago class-tiny-image.php 9 years ago class-tiny-notices.php 9 years ago class-tiny-php.php 9 years ago class-tiny-plugin.php 9 years ago class-tiny-settings.php 9 years ago class-tiny-wp-base.php 9 years ago
class-tiny-wp-base.php
90 lines
1 <?php
2 /*
3 * Tiny Compress Images - WordPress plugin.
4 * Copyright (C) 2015-2017 Voormedia 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 static function get_prefixed_name( $name ) {
49 return self::PREFIX . $name;
50 }
51
52 public function __construct() {
53 add_action( 'init', $this->get_method( 'init' ) );
54 if ( self::is_xmlrpc_request() ) {
55 add_action( 'init', $this->get_method( 'xmlrpc_init' ) );
56 } elseif ( is_admin() ) {
57 add_action( 'admin_init', $this->get_method( 'admin_init' ) );
58 add_action( 'admin_menu', $this->get_method( 'admin_menu' ) );
59 }
60 }
61
62 protected function get_method( $name ) {
63 return array( $this, $name );
64 }
65
66 protected function get_static_method( $name ) {
67 return array( get_class( $this ), $name );
68 }
69
70 protected function get_user_id() {
71 return get_current_user_id();
72 }
73
74 protected function check_ajax_referer() {
75 return check_ajax_referer( 'tiny-compress', '_nonce', false );
76 }
77
78 public function init() {
79 }
80
81 public function xmlrpc_init() {
82 }
83
84 public function admin_init() {
85 }
86
87 public function admin_menu() {
88 }
89 }
90