PluginProbe
LoftLoader / 2.1.7
LoftLoader v2.1.7
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.1.7, at loftloader.php

140 lines 4.1 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.1.7
7 Author: Loft Ocean
8 Author URI: http://www.loftocean.com/
9 Text Domain: loftloader
10 License: GPLv2
11 License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 */
13
14
15 /**
16 * LoftLoader main file
17 *
18 * @package LoftLoader
19 * @link http://www.loftocean.com/
20 * @author Suihai Huang from Loft Ocean Team
21 */
22
23 // Not allowed by directly accessing.
24 if ( ! defined( 'ABSPATH' ) ) {
25 die( esc_html__( 'Access not allowed!', 'loftloader' ) );
26 }
27
28 if ( ! class_exists( 'LoftLoader' ) ) {
29 /**
30 * Define the constant used in this plugin
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', '2019051401' );
36
37 class LoftLoader {
38 public function __construct() {
39 load_plugin_textdomain( 'loftloader' );
40
41 $this->load_upgrade();
42 $this->load_customize();
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' ) );
47 }
48 /**
49 * For LoftLoader customize, load the customize related functions
50 */
51 function load_upgrade() {
52 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-upgrade.php';
53 }
54 /**
55 * For LoftLoader upgrade, load the upgrade related functions
56 */
57 function load_customize() {
58 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-customize.php';
59 }
60
61 /**
62 * For LoftLoader front, load the front end related functions
63 */
64 function load_front() {
65 require_once LOFTLOADER_ROOT . 'inc/class-loftloader-front.php';
66 }
67
68 /**
69 * Add new setting link to loftloader
70 */
71 function plugin_action_links( $links ) {
72 $customize_url = $this->get_customize_uri();
73 $action_links = array(
74 'settings' => '<a href="' . $customize_url . '" title="' . esc_attr__('View LoftLoader Settings', 'loftloader') . '">' . esc_html__('Settings', 'loftloader') . '</a>'
75 );
76 return array_merge( $action_links, $links );
77 }
78
79 /**
80 * Add an admin menu for loftloader
81 */
82 function admin_menu() {
83 global $submenu;
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' );
86 }
87
88 /**
89 * Helper function to get loftloader customize url
90 * @return url loftloader customize uri
91 */
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' );
98 }
99 }
100
101 // Init loftloader lite
102 add_action( 'after_setup_theme', 'loftloader_init' );
103 function loftloader_init() {
104 if ( ! class_exists( 'LoftLoaderPro' ) ) {
105 new LoftLoader();
106 }
107 }
108
109 add_action( 'plugins_loaded', 'loftloader_any_page' );
110 function loftloader_any_page() {
111 $enable_any_page = get_option( 'loftloader_enable_any_page', '' );
112 if ( $enable_any_page === 'on' ) {
113 require_once LOFTLOADER_ROOT . 'inc/any-page/class-loftloader-any-page.php';
114 }
115 }
116
117 // Remove widget panels
118 add_filter( 'customize_loaded_components', 'loftloader_remove_widget_panels', 1000 );
119 function loftloader_remove_widget_panels( $components ) {
120 if ( ! class_exists( 'LoftLoaderPro' ) && ( isset( $_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite' ) ) ) {
121 foreach ( $components as $i => $c ) {
122 if ( false !== $i ) {
123 unset( $components[ $i ] );
124 }
125 }
126 }
127 return $components;
128 }
129
130 /**
131 * Helper function to test on loftloader customize page
132 *
133 * @return boolean
134 */
135 function loftloader_is_customize() {
136 global $wp_customize;
137 return ( isset($_GET['plugin'] ) && ( $_GET['plugin'] === 'loftloader-lite') ) || ( isset( $wp_customize ) && $wp_customize->is_preview() && ! is_admin() ) || defined( 'DOING_AJAX' );
138 }
139 }
140