PluginProbe
LoftLoader / 1.0.0
LoftLoader v1.0.0
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 / front / class-loftloader-front.php

class-loftloader-front.php in LoftLoader 1.0.0, at front/class-loftloader-front.php

85 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Not allowed by directly accessing.
3 if(!defined('ABSPATH')){
4 die('Access not allowed!');
5 }
6
7 /**
8 * Main class for front display
9 *
10 * @package LoftLoader
11 * @version 1.0
12 * @link http://www.loftocean.com/
13 * @author Suihai Huang from Loft Ocean Team
14
15 * @since version 1.0
16 */
17
18 if(!class_exists('LoftLoader_Front')){
19 class LoftLoader_Front{
20 private $loader_enabled; // Flag to tell whether loftloader enabled
21 private $loader_settings; // Get the loader settings
22 public function __construct(){
23 $this->get_settings();
24 if($this->loader_enabled){
25 add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
26 add_action('wp_head', array($this, 'loader_custom_styles'), 100);
27 add_action('wp_footer', array($this, 'show_loader_html'));
28 }
29 }
30 /**
31 * @description get the plugin settings
32 */
33 public function get_settings(){
34 $default = apply_filters('loftloader_settings_default_value', array());
35 $settings = get_option('loftloader-custom-settings', $default);
36 $this->loader_enabled = (!empty($settings['enable']) && ($settings['enable'] == 'on')) ? true : false;
37 $this->loader_settings = $settings;
38 }
39 /**
40 * @description enqueue the scripts and styles for front end
41 */
42 public function enqueue_scripts(){
43 wp_enqueue_script('loftloader-front-main', LOFTLOADER_JS_URI . 'front/loftloader.js', array('jquery'), '1.0', true);
44 wp_enqueue_style('loftloader-animation');
45 }
46 /**
47 * @description custom css for front end
48 */
49 public function loader_custom_styles(){
50 $styles = get_option('loftloader-custom-styles', '');
51 echo empty($styles) ? '' : '<style type="text/css">' . $styles . '</style>';
52 }
53 /**
54 * @description loftloader html
55 */
56 public function show_loader_html(){
57 $loader = $this->loader_settings['settings']; // Preloader settings
58 $background = $loader['background']; // Preloader background settings
59 $animation = $loader['animation']; // Preloader animation settings
60 $html = '<div id="loftloader-wrapper" class="' . $animation['type'] . '">';
61 $html .= '<div class="loader-inner"><div id="loader">';
62 $html .= in_array($animation['type'], array('pl-frame', 'pl-imgloading'))
63 ? '<span></span><img srcset="' . $animation['image']['url'] . '" src="' . $animation['image']['url'] . '" alt="preloder">' : '<span></span>';
64 $html .= '</div></div>';
65 switch($background['effect']){
66 case 'fade':
67 $html .= '<div class="loader-section section-fade"></div>';
68 break;
69 case 'slide-up':
70 $html .= '<div class="loader-section section-slide-up"></div>';
71 break;
72 case 'slide-up-down':
73 $html .= '<div class="loader-section section-up"></div>';
74 $html .= '<div class="loader-section section-down"></div>';
75 break;
76 default:
77 $html .= '<div class="loader-section section-left">';
78 $html .= '</div><div class="loader-section section-right"></div>';
79 }
80 $html .= '</div>';
81 echo $html;
82 }
83 }
84 new LoftLoader_Front();
85 }