PluginProbe
LoftLoader / 2.5.2
LoftLoader v2.5.2
trunk 1.0.0 1.0.1 1.0.2 2.0.0 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.3 2.3.1 2.3.2 2.3.3 All 34 releases
loftloader / loftloader.php

loftloader.php in LoftLoader 2.5.2, at loftloader.php

189 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: LoftLoader
4 Plugin URI: http://www.loftocean.com/
5 Description: An easy to use plugin to add an animated preloader to your website with fully customisations.
6 Version: 2.5.2
7 Requires PHP: 5.6
8 Requires at least: 6.0
9 Tested up to: 6.9
10 Author: Loft.Ocean
11 Author URI: http://www.loftocean.com/
12 Text Domain: loftloader
13 License: GPLv2
14 License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 */
16
17
18 /**
19 * LoftLoader main file
20 *
21 * @package LoftLoader
22 * @link http://www.loftocean.com/
23 * @author Suihai Huang from Loft Ocean Team
24 */
25
26 // Not allowed by directly accessing.
27 if ( ! defined( 'ABSPATH' ) ) {
28 die( esc_html__( 'Access not allowed!', 'loftloader' ) );
29 }
30
31 if ( ! class_exists( 'LoftLoader' ) ) {
32 /**
33 * Define the constant used in this plugin
34 */
35 define( 'LOFTLOADER_ROOT', dirname( __FILE__ ) . '/' );
36 define( 'LOFTLOADER_NAME', plugin_basename( __FILE__ ) );
37 define( 'LOFTLOADER_URI', plugin_dir_url( __FILE__ ) );
38 define( 'LOFTLOADER_ASSET_VERSION', '2025121501' );
39
40 class LoftLoader {
41 public function __construct() {
42 load_plugin_textdomain( 'loftloader' );
43
44 $this->load_upgrade();
45 $this->load_customize();
46
47 add_action( 'wp', array( $this, 'load_front' ) );
48 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
49 add_filter( 'plugin_action_links_' . LOFTLOADER_NAME, array( $this, 'plugin_action_links' ) );
50 }
51 /**
52 * For LoftLoader customize, load the customize related functions
53 */
54 function load_upgrade() {
55 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-upgrade.php';
56 }
57 /**
58 * For LoftLoader upgrade, load the upgrade related functions
59 */
60 function load_customize() {
61 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-customize.php';
62 }
63
64 /**
65 * For LoftLoader front, load the front end related functions
66 */
67 function load_front() {
68 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-front.php';
69 }
70
71 /**
72 * Add new setting link to loftloader
73 */
74 function plugin_action_links( $links ) {
75 $customize_url = $this->get_customize_uri();
76 $action_links = array(
77 'settings' => '<a href="' . $customize_url . '" title="' . esc_attr__('View LoftLoader Settings', 'loftloader') . '">' . esc_html__('Settings', 'loftloader') . '</a>'
78 );
79 return array_merge( $action_links, $links );
80 }
81
82 /**
83 * Add an admin menu for loftloader
84 */
85 function admin_menu() {
86 global $submenu;
87 $customize_url = $this->get_customize_uri();
88 $submenu['options-general.php'][] = array( esc_html__( 'LoftLoader Lite', 'loftloader' ), 'manage_options', $customize_url, 'hide-if-no-customize' );
89 }
90
91 /**
92 * Helper function to get loftloader customize url
93 * @return url loftloader customize uri
94 */
95 function get_customize_uri() {
96 $return_url = '';
97 if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
98 $return_url = urlencode( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
99 }
100 return add_query_arg( array('return' => $return_url, 'plugin' => 'loftloader-lite' ), 'customize.php' );
101 }
102 }
103
104 // Init loftloader lite
105 add_action( 'after_setup_theme', 'loftloader_init' );
106 function loftloader_init() {
107 if ( ! class_exists( 'LoftLoader_Pro' ) ) {
108 new LoftLoader();
109 }
110 }
111
112 add_action( 'plugins_loaded', 'loftloader_any_page' );
113 function loftloader_any_page() {
114 if ( ! class_exists( 'LoftLoader_Pro' ) ) {
115 $enable_any_page = get_option( 'loftloader_enable_any_page', '' );
116 if ( $enable_any_page === 'on' ) {
117 require_once LOFTLOADER_ROOT . 'inc/any-page/class-loftloader-any-page.php';
118 }
119 }
120 }
121
122 // Remove widget panels
123 add_filter( 'customize_loaded_components', 'loftloader_remove_widget_panels', 1000 );
124 function loftloader_remove_widget_panels( $components ) {
125 if ( ! class_exists( 'LoftLoader_Pro' ) && ( isset( $_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite' ) ) ) {
126 foreach ( $components as $i => $c ) {
127 if ( false !== $i ) {
128 unset( $components[ $i ] );
129 }
130 }
131 }
132 return $components;
133 }
134
135 /**
136 * Helper function to test on loftloader customize page
137 *
138 * @return boolean
139 */
140 function loftloader_is_customize() {
141 global $wp_customize;
142 return ( isset($_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite') ) || ( isset( $wp_customize ) && $wp_customize->is_preview() && ! is_admin() ) || defined( 'DOING_AJAX' );
143 }
144 }
145
146 /**
147 * Deletes saved data for the plugin unless setting to preserve
148 * settings is enabled
149 *
150 * @since 2.0 custom tables, custom images, and image directory deleted
151 * @since 1.0
152 */
153 function loftloader_plugin_uninstall() {
154 if ( ! current_user_can( 'activate_plugins' ) ) {
155 return;
156 }
157
158 if ( 'on' != get_option( 'loftloader_remove_settings', '' ) ) {
159 return;
160 }
161
162 global $wpdb;
163 $table_name = esc_sql( $wpdb->prefix . "postmeta" );
164 $result = $wpdb->query("
165 DELETE
166 FROM $table_name
167 WHERE meta_key = 'loftloader_page_shortcode';"
168 );
169
170 delete_option( 'loftloader_lite_version' );
171 delete_option( 'loftloader_main_switch' );
172 delete_option( 'loftloader_show_range' );
173 delete_option( 'loftloader_bg_color' );
174 delete_option( 'loftloader_bg_opacity' );
175 delete_option( 'loftloader_bg_animation' );
176 delete_option( 'loftloader_loader_type' );
177 delete_option( 'loftloader_loader_color' );
178 delete_option( 'loftloader_custom_img' );
179 delete_option( 'loftloader_img_width' );
180 delete_option( 'loftloader_show_close_timer' );
181 delete_option( 'loftloader_show_close_tip' );
182 delete_option( 'loftloader_max_load_time' );
183 delete_option( 'loftloader_inline_js' );
184 delete_option( 'loftloader_enable_any_page' );
185 delete_option( 'loftloader_remove_settings' );
186 }
187
188 register_deactivation_hook( __FILE__, 'loftloader_plugin_uninstall' );
189