| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Preloader |
| 4 |
* Version: 2.0.0 |
| 5 |
* Description: The ultimate Preloader plugin for WordPress. Smart, flexible, and made for easy control. Add a preloader to your website easily in only 3 steps. |
| 6 |
* Author: Alobaidi |
| 7 |
* Author URI: https://wp-plugins.in/PreloaderPlugin |
| 8 |
* Plugin URI: https://wp-plugins.in/PreloaderPlugin |
| 9 |
* Text Domain: the-preloader |
| 10 |
* Domain Path: /languages |
| 11 |
* Requires at least: 5.3.0 |
| 12 |
* Requires PHP: 7.4 |
| 13 |
* License: GPLv2 or later |
| 14 |
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 15 |
* |
| 16 |
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
| 17 |
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume |
| 18 |
* that you can use any other version of the GPL. |
| 19 |
* |
| 20 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without |
| 21 |
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 22 |
*/ |
| 23 |
|
| 24 |
if ( !defined('ABSPATH') ) { |
| 25 |
exit; // Exit if accessed directly |
| 26 |
} |
| 27 |
|
| 28 |
// Define plugin constants |
| 29 |
define('THE_PRELOADER_PLUGIN_ID', 'the_preloader'); |
| 30 |
define('THE_PRELOADER_PLUGIN_VERSION', '2.0.0'); |
| 31 |
define('THE_PRELOADER_PLUGIN_PATH', plugin_dir_path(__FILE__)); |
| 32 |
define('THE_PRELOADER_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 33 |
define('THE_PRELOADER_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
| 34 |
|
| 35 |
// Add custom link to plugin meta row. |
| 36 |
function the_preloader_plugin_row_meta($links, $file) { |
| 37 |
if ( strpos( $file, 'preloader.php' ) !== false ) { |
| 38 |
$custom_link = array( |
| 39 |
sprintf( |
| 40 |
// translators: %1$s and %2$s are link tags |
| 41 |
esc_html__('%1$sPlugin Reference%2$s', 'the-preloader'), |
| 42 |
'<a href="https://wp-plugins.in/PreloaderPlugin" target="_blank">', |
| 43 |
'</a>' |
| 44 |
) |
| 45 |
); |
| 46 |
$links = array_merge($links, $custom_link); |
| 47 |
} |
| 48 |
return $links; |
| 49 |
} |
| 50 |
add_filter('plugin_row_meta', 'the_preloader_plugin_row_meta', 10, 2); |
| 51 |
|
| 52 |
// Add settings link before activate/deactivate plugin links. |
| 53 |
function the_preloader_plugin_action_links($actions, $plugin_file){ |
| 54 |
static $plugin; |
| 55 |
|
| 56 |
if ( !isset($plugin) ){ |
| 57 |
$plugin = plugin_basename(__FILE__); |
| 58 |
} |
| 59 |
|
| 60 |
if ($plugin == $plugin_file) { |
| 61 |
$custom_link = '<a href="' . admin_url('admin.php?page=' . THE_PRELOADER_PLUGIN_ID) . '">'.esc_html__('Settings', 'the-preloader').'</a>'; |
| 62 |
$actions = array_merge(array($custom_link), $actions); |
| 63 |
} |
| 64 |
|
| 65 |
return $actions; |
| 66 |
} |
| 67 |
add_filter('plugin_action_links', 'the_preloader_plugin_action_links', 10, 5); |
| 68 |
|
| 69 |
// Plugin initialization |
| 70 |
function the_preloader_init() { |
| 71 |
// Load text domain for translations |
| 72 |
load_plugin_textdomain('the-preloader', false, dirname(THE_PRELOADER_PLUGIN_BASENAME) . '/languages'); |
| 73 |
|
| 74 |
if ( !class_exists('The_Preloader_Core') ) { |
| 75 |
// Load main class file first |
| 76 |
require_once THE_PRELOADER_PLUGIN_PATH . 'includes/inc-classes.php'; |
| 77 |
|
| 78 |
// Initialize main plugin class |
| 79 |
$The_Preloader_Main = The_Preloader_Core::get_instance(); |
| 80 |
$The_Preloader_Main->initialize(); |
| 81 |
} |
| 82 |
} |
| 83 |
add_action('plugins_loaded', 'the_preloader_init'); |