| 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: 1.0.2 |
| 7 |
Author: Loft Ocean |
| 8 |
Author URI: http://www.loftocean.com/ |
| 9 |
Text Domain: loftloader |
| 10 |
Domain Path: /languages |
| 11 |
License: GPLv2 |
| 12 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
*/ |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* LoftLoader main file |
| 18 |
* |
| 19 |
* @package LoftLoader |
| 20 |
* @link http://www.loftocean.com/ |
| 21 |
* @author Suihai Huang from Loft Ocean Team |
| 22 |
*/ |
| 23 |
|
| 24 |
// Not allowed by directly accessing. |
| 25 |
if(!defined('ABSPATH')){ |
| 26 |
die('Access not allowed!'); |
| 27 |
} |
| 28 |
|
| 29 |
if(!class_exists('LoftLoader')){ |
| 30 |
register_activation_hook(__FILE__, 'loftloader_activate'); // |
| 31 |
register_deactivation_hook(__FILE__, 'loftloader_deactivate'); |
| 32 |
/* |
| 33 |
* Update the plugin version for initial version |
| 34 |
*/ |
| 35 |
function loftloader_activate(){ |
| 36 |
update_option('loftloader_plugin_version', '1.0.2'); |
| 37 |
} |
| 38 |
/** |
| 39 |
* Do nothing for initial version |
| 40 |
*/ |
| 41 |
function loftloader_deactivate(){ } |
| 42 |
/** |
| 43 |
* Define the constant used in this plugin |
| 44 |
*/ |
| 45 |
define('LOFTLOADER_ROOT', dirname(__FILE__) . '/'); |
| 46 |
define('LOFTLOADER_NAME', plugin_basename( __FILE__ )); |
| 47 |
define('LOFTLOADER_URI', plugin_dir_url( __FILE__ )); |
| 48 |
define('LOFTLOADER_JS_URI', LOFTLOADER_URI . 'js/'); |
| 49 |
define('LOFTLOADER_CSS_URI', LOFTLOADER_URI . 'css/'); |
| 50 |
|
| 51 |
/** |
| 52 |
* Main plugin class |
| 53 |
* @since version 1.0.0 |
| 54 |
*/ |
| 55 |
class LoftLoader{ |
| 56 |
public function __construct(){ |
| 57 |
load_plugin_textdomain('loftloader', false, dirname(plugin_basename(__FILE__)) . '/languages/'); // Load the text domain |
| 58 |
$this->load_configs(); |
| 59 |
add_action('init', array($this, 'load_settings')); // Load the plugin settings |
| 60 |
add_action('wp', array($this, 'load_front')); // Load the front main class |
| 61 |
add_action('wp_enqueue_scripts', array($this, 'enqueue_loader_styles')); |
| 62 |
add_action('admin_enqueue_scripts', array($this, 'enqueue_loader_styles')); |
| 63 |
} |
| 64 |
/** |
| 65 |
* @description load configuration files |
| 66 |
*/ |
| 67 |
public function load_configs(){ |
| 68 |
require_once LOFTLOADER_ROOT . 'configs/loftloader-config.php'; |
| 69 |
} |
| 70 |
/** |
| 71 |
* @description load plugin settings main class |
| 72 |
*/ |
| 73 |
public function load_settings(){ |
| 74 |
is_admin() ? require_once LOFTLOADER_ROOT . 'settings/class-loftloader-settings.php' : ''; |
| 75 |
} |
| 76 |
/** |
| 77 |
* @description load plugin front main class |
| 78 |
*/ |
| 79 |
public function load_front(){ |
| 80 |
!is_admin() ? require_once LOFTLOADER_ROOT . 'front/class-loftloader-front.php' : ''; |
| 81 |
} |
| 82 |
/** |
| 83 |
* @description register the loader style css for both plugin setting page and front end |
| 84 |
*/ |
| 85 |
public function enqueue_loader_styles(){ |
| 86 |
wp_register_style('loftloader-animation', LOFTLOADER_CSS_URI . 'loftloader-animation.css', array(), '20161015'); |
| 87 |
} |
| 88 |
} |
| 89 |
new LoftLoader(); // Enable LoftLoader |
| 90 |
} |
| 91 |
?> |
| 92 |
|