PluginProbe
LoftLoader / 2.5.1
LoftLoader v2.5.1
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.1, at loftloader.php

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