| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: LoftLoader |
| 4 | 4 | Plugin URI: http://www.loftocean.com/ |
| 5 | 5 | Description: An easy to use plugin to add an animated preloader to your website with fully customisations. |
| 6 | -Version: 2.0.0 | |
| 6 | +Version: 2.1.10 | |
| 7 | 7 | Author: Loft Ocean |
| 8 | 8 | Author URI: http://www.loftocean.com/ |
| 9 | 9 | Text Domain: loftloader |
| 10 | 10 | License: GPLv2 |
| @@ -13,9 +13,9 @@ | ||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * LoftLoader main file |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * @package LoftLoader |
| 19 | 19 | * @link http://www.loftocean.com/ |
| 20 | 20 | * @author Suihai Huang from Loft Ocean Team |
| 21 | 21 | */ |
| @@ -20,42 +20,42 @@ | ||
| 20 | 20 | * @author Suihai Huang from Loft Ocean Team |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | // Not allowed by directly accessing. |
| 24 | -if(!defined('ABSPATH')){ | |
| 25 | - die(esc_html__('Access not allowed!', 'loftloader')); | |
| 24 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 25 | + die( esc_html__( 'Access not allowed!', 'loftloader' ) ); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | -if(!class_exists('LoftLoader')){ | |
| 28 | +if ( ! class_exists( 'LoftLoader' ) ) { | |
| 29 | 29 | /** |
| 30 | 30 | * Define the constant used in this plugin |
| 31 | 31 | */ |
| 32 | - define('LOFTLOADER_ROOT', dirname(__FILE__) . '/'); | |
| 33 | - define('LOFTLOADER_NAME', plugin_basename( __FILE__ )); | |
| 34 | - define('LOFTLOADER_URI', plugin_dir_url( __FILE__ )); | |
| 35 | - define('LOFTLOADER_ASSET_VERSION', '2017030802'); | |
| 32 | + define( 'LOFTLOADER_ROOT', dirname( __FILE__ ) . '/' ); | |
| 33 | + define( 'LOFTLOADER_NAME', plugin_basename( __FILE__ ) ); | |
| 34 | + define( 'LOFTLOADER_URI', plugin_dir_url( __FILE__ ) ); | |
| 35 | + define( 'LOFTLOADER_ASSET_VERSION', '2019092302' ); | |
| 36 | 36 | |
| 37 | - class LoftLoader{ | |
| 38 | - public function __construct(){ | |
| 39 | - load_plugin_textdomain('loftloader'); | |
| 37 | + class LoftLoader { | |
| 38 | + public function __construct() { | |
| 39 | + load_plugin_textdomain( 'loftloader' ); | |
| 40 | 40 | |
| 41 | 41 | $this->load_upgrade(); |
| 42 | 42 | $this->load_customize(); |
| 43 | 43 | |
| 44 | - add_action('wp', array($this, 'load_front')); | |
| 45 | - add_action('admin_menu', array($this, 'admin_menu')); | |
| 46 | - add_filter('plugin_action_links_' . LOFTLOADER_NAME, array($this, 'plugin_action_links')); | |
| 44 | + add_action( 'wp', array( $this, 'load_front' ) ); | |
| 45 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); | |
| 46 | + add_filter( 'plugin_action_links_' . LOFTLOADER_NAME, array( $this, 'plugin_action_links' ) ); | |
| 47 | 47 | } |
| 48 | 48 | /** |
| 49 | 49 | * For LoftLoader customize, load the customize related functions |
| 50 | 50 | */ |
| 51 | - function load_upgrade(){ | |
| 51 | + function load_upgrade() { | |
| 52 | 52 | require_once LOFTLOADER_ROOT . 'inc/class-loftloader-upgrade.php'; |
| 53 | 53 | } |
| 54 | 54 | /** |
| 55 | 55 | * For LoftLoader upgrade, load the upgrade related functions |
| 56 | 56 | */ |
| 57 | - function load_customize(){ | |
| 57 | + function load_customize() { | |
| 58 | 58 | require_once LOFTLOADER_ROOT . 'inc/class-loftloader-customize.php'; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| @@ -60,9 +60,9 @@ | ||
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * For LoftLoader front, load the front end related functions |
| 63 | 63 | */ |
| 64 | - function load_front(){ | |
| 64 | + function load_front() { | |
| 65 | 65 | require_once LOFTLOADER_ROOT . 'inc/class-loftloader-front.php'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
| @@ -67,23 +67,23 @@ | ||
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Add new setting link to loftloader |
| 70 | 70 | */ |
| 71 | - function plugin_action_links($links){ | |
| 71 | + function plugin_action_links( $links ) { | |
| 72 | 72 | $customize_url = $this->get_customize_uri(); |
| 73 | 73 | $action_links = array( |
| 74 | 74 | 'settings' => '<a href="' . $customize_url . '" title="' . esc_attr__('View LoftLoader Settings', 'loftloader') . '">' . esc_html__('Settings', 'loftloader') . '</a>' |
| 75 | 75 | ); |
| 76 | - return array_merge($action_links, $links); | |
| 76 | + return array_merge( $action_links, $links ); | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Add an admin menu for loftloader |
| 81 | 81 | */ |
| 82 | - function admin_menu(){ | |
| 82 | + function admin_menu() { | |
| 83 | 83 | global $submenu; |
| 84 | 84 | $customize_url = $this->get_customize_uri(); |
| 85 | - $submenu['options-general.php'][] = array(esc_html__('LoftLoader Lite', 'loftloader'), 'manage_options', $customize_url, 'hide-if-no-customize'); | |
| 85 | + $submenu['options-general.php'][] = array( esc_html__( 'LoftLoader Lite', 'loftloader' ), 'manage_options', $customize_url, 'hide-if-no-customize' ); | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Helper function to get loftloader customize url |
| @@ -88,36 +88,42 @@ | ||
| 88 | 88 | /** |
| 89 | 89 | * Helper function to get loftloader customize url |
| 90 | 90 | * @return url loftloader customize uri |
| 91 | 91 | */ |
| 92 | - function get_customize_uri(){ | |
| 93 | - return add_query_arg(array('return' => urlencode(wp_unslash( $_SERVER['REQUEST_URI'])), 'plugin' => 'loftloader-lite'), 'customize.php'); | |
| 92 | + function get_customize_uri() { | |
| 93 | + $return_url = ''; | |
| 94 | + if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { | |
| 95 | + $return_url = urlencode( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); | |
| 96 | + } | |
| 97 | + return add_query_arg( array('return' => $return_url, 'plugin' => 'loftloader-lite' ), 'customize.php' ); | |
| 94 | 98 | } |
| 95 | 99 | } |
| 96 | 100 | |
| 97 | 101 | // Init loftloader lite |
| 98 | - add_action('after_setup_theme', 'loftloader_init'); | |
| 99 | - function loftloader_init(){ | |
| 100 | - if(!class_exists('LoftLoaderPro')){ | |
| 102 | + add_action( 'after_setup_theme', 'loftloader_init' ); | |
| 103 | + function loftloader_init() { | |
| 104 | + if ( ! class_exists( 'LoftLoader_Pro' ) ) { | |
| 101 | 105 | new LoftLoader(); |
| 102 | 106 | } |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | - add_action('plugins_loaded', 'loftloader_any_page'); | |
| 106 | - function loftloader_any_page(){ | |
| 107 | - $enable_any_page = get_option('loftloader_enable_any_page', ''); | |
| 108 | - if($enable_any_page === 'on'){ | |
| 109 | - require_once LOFTLOADER_ROOT . 'inc/class-loftloader-any-page.php'; | |
| 109 | + add_action( 'plugins_loaded', 'loftloader_any_page' ); | |
| 110 | + function loftloader_any_page() { | |
| 111 | + if ( ! class_exists( 'LoftLoader_Pro' ) ) { | |
| 112 | + $enable_any_page = get_option( 'loftloader_enable_any_page', '' ); | |
| 113 | + if ( $enable_any_page === 'on' ) { | |
| 114 | + require_once LOFTLOADER_ROOT . 'inc/any-page/class-loftloader-any-page.php'; | |
| 115 | + } | |
| 110 | 116 | } |
| 111 | 117 | } |
| 112 | 118 | |
| 113 | 119 | // Remove widget panels |
| 114 | - add_filter('customize_loaded_components', 'loftloader_remove_widget_panels', 1000, 2); | |
| 115 | - function loftloader_remove_widget_panels($components, $manager){ | |
| 116 | - if(!class_exists('LoftLoaderPro') && loftloader_is_customize($manager)){ | |
| 117 | - foreach($components as $i => $c){ | |
| 118 | - if(false !== $i){ | |
| 119 | - unset($components[$i]); | |
| 120 | + add_filter( 'customize_loaded_components', 'loftloader_remove_widget_panels', 1000 ); | |
| 121 | + function loftloader_remove_widget_panels( $components ) { | |
| 122 | + if ( ! class_exists( 'LoftLoader_Pro' ) && ( isset( $_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite' ) ) ) { | |
| 123 | + foreach ( $components as $i => $c ) { | |
| 124 | + if ( false !== $i ) { | |
| 125 | + unset( $components[ $i ] ); | |
| 120 | 126 | } |
| 121 | 127 | } |
| 122 | 128 | } |
| 123 | 129 | return $components; |
| @@ -127,11 +133,9 @@ | ||
| 127 | 133 | * Helper function to test on loftloader customize page |
| 128 | 134 | * |
| 129 | 135 | * @return boolean |
| 130 | 136 | */ |
| 131 | - function loftloader_is_customize($manager = false){ | |
| 137 | + function loftloader_is_customize() { | |
| 132 | 138 | global $wp_customize; |
| 133 | - $customize = empty($manager) ? $wp_customize : $manager; | |
| 134 | - | |
| 135 | - return (($customize instanceof WP_Customize_Manager) && ((isset($_GET['plugin']) && ($_GET['plugin'] === 'loftloader-lite')) || ($customize->is_preview() && !is_admin()))) || defined('DOING_AJAX'); | |
| 139 | + return ( isset($_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite') ) || ( isset( $wp_customize ) && $wp_customize->is_preview() && ! is_admin() ) || defined( 'DOING_AJAX' ); | |
| 136 | 140 | } |
| 137 | 141 | } |