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-2016 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 |