| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
| 3 |
/* |
| 4 |
Plugin Name: Salert |
| 5 |
Plugin URI: https://wpoperation.com/plugins/salert/ |
| 6 |
Description: The plugin will generate fake sales notifications, which will help to boost your sales.Also works without WooCommerce Plugin. |
| 7 |
Version: 1.3.1 |
| 8 |
Tested up to: 7.0 |
| 9 |
Author: WPoperation |
| 10 |
Author URI: https://wpoperation.com/ |
| 11 |
License: GPL2 or later |
| 12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 13 |
Domain Path: /languages/ |
| 14 |
Text Domain: salert |
| 15 |
|
| 16 |
*/ |
| 17 |
|
| 18 |
defined('SALERT_FRONT_CSS_DIR') or define('SALERT_FRONT_CSS_DIR',plugin_dir_url(__FILE__).'/assets/frontend/css'); |
| 19 |
defined('SALERT_FRONT_JS_DIR') or define('SALERT_FRONT_JS_DIR',plugin_dir_url(__FILE__).'/assets/frontend/js'); |
| 20 |
defined('SALERT_BACK_CSS_DIR') or define('SALERT_BACK_CSS_DIR',plugin_dir_url(__FILE__).'/assets/backend/css'); |
| 21 |
defined('SALERT_BACK_JS_DIR') or define('SALERT_BACK_JS_DIR',plugin_dir_url(__FILE__).'/assets/backend/js'); |
| 22 |
defined('SALERT_PATH') or define('SALERT_PATH',plugin_dir_path(__FILE__)); |
| 23 |
defined('SALERT_DIR') or define('SALERT_DIR',plugin_dir_url(__FILE__)); |
| 24 |
defined('SALERT_VERSION') or define('SALERT_VERSION','1.3.1'); |
| 25 |
/* |
| 26 |
**Require File Directories |
| 27 |
*/ |
| 28 |
require_once SALERT_PATH.'inc/settings.php'; |
| 29 |
|
| 30 |
|
| 31 |
if(!class_exists('Salert')){ |
| 32 |
class Salert{ |
| 33 |
|
| 34 |
// Construtor to load all hooks |
| 35 |
public function __construct(){ |
| 36 |
add_action( 'init', array($this,'salert_init') ); |
| 37 |
add_action( 'admin_enqueue_scripts',array($this,'register_backend_assets') ); |
| 38 |
$salert_settings = get_option('salert_save_settings'); |
| 39 |
$show_popup = isset($salert_settings['popup-enable']) ? $salert_settings['popup-enable'] : 0; |
| 40 |
if($show_popup){ |
| 41 |
add_action( 'wp_enqueue_scripts', array($this, 'register_frontend_assets') ); |
| 42 |
add_action( 'wp_footer', array($this,'salert_display_wrapper' ) ); |
| 43 |
add_action( 'wp_ajax_salert_get_content', array($this,'salert_get_content' ) ); |
| 44 |
add_action( 'wp_ajax_nopriv_salert_get_content', array($this,'salert_get_content' ) ); |
| 45 |
} |
| 46 |
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'salert_pro_plugin_action_links') ); |
| 47 |
} |
| 48 |
|
| 49 |
// Register Text Domain |
| 50 |
public function salert_init(){ |
| 51 |
load_plugin_textdomain( 'salert', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 52 |
} |
| 53 |
|
| 54 |
//Registering of backend js and css |
| 55 |
public function register_backend_assets() { |
| 56 |
if( isset( $_GET['page'] ) && $_GET['page'] == 'salert-settings' ) { |
| 57 |
|
| 58 |
wp_enqueue_style( 'salert-admin-css', SALERT_BACK_CSS_DIR . '/salert-admin.css', array(), SALERT_VERSION ); |
| 59 |
wp_enqueue_style( 'animate-css', SALERT_BACK_CSS_DIR . '/animate.css', array(), SALERT_VERSION ); |
| 60 |
wp_enqueue_style( 'sweetalert-css', SALERT_BACK_CSS_DIR . '/sweetalert2.min.css', array(), SALERT_VERSION ); |
| 61 |
wp_enqueue_style( 'wp-color-picker' ); |
| 62 |
if ( function_exists( 'wp_enqueue_media' ) ) { |
| 63 |
wp_enqueue_media(); |
| 64 |
} |
| 65 |
wp_enqueue_script( 'sweetalert-core-js', SALERT_BACK_JS_DIR.'/core.js', array( 'jquery' ), SALERT_VERSION, true ); |
| 66 |
wp_enqueue_script( 'sweetalert2-js', SALERT_BACK_JS_DIR.'/sweetalert2.min.js', array( 'jquery', 'sweetalert-core-js' ), SALERT_VERSION, true ); |
| 67 |
wp_enqueue_script( 'salert-custom-js', SALERT_BACK_JS_DIR.'/custom.js', array( 'jquery' ), SALERT_VERSION, true ); |
| 68 |
wp_enqueue_script( 'salert-admin-js', SALERT_BACK_JS_DIR.'/salert-admin.js', array( 'jquery', 'wp-color-picker' ), SALERT_VERSION, true ); |
| 69 |
$js_info = array( |
| 70 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 71 |
'ajax_nonce' => wp_create_nonce('salert_ajax_nonce_wpop') |
| 72 |
); |
| 73 |
wp_localize_script( 'salert-custom-js', 'admin_settings', $js_info ); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
//Registering Frontend Assets |
| 78 |
public function register_frontend_assets(){ |
| 79 |
//styles |
| 80 |
wp_enqueue_style( 'animate-css', SALERT_BACK_CSS_DIR . '/animate.css', array(), SALERT_VERSION ); |
| 81 |
wp_enqueue_style( 'salert-main-css', SALERT_FRONT_CSS_DIR.'/style.css' ); |
| 82 |
|
| 83 |
//scripts |
| 84 |
wp_enqueue_script('salert-main-js',SALERT_FRONT_JS_DIR . '/main.js', array('jquery'), SALERT_VERSION); |
| 85 |
|
| 86 |
include(SALERT_PATH.'inc/dynamic-styles.php') ; |
| 87 |
} |
| 88 |
|
| 89 |
//Add display wrapper |
| 90 |
public function salert_display_wrapper(){ |
| 91 |
$salert_settings = get_option('salert_save_settings'); |
| 92 |
?> |
| 93 |
<div id="salertWrapper" class="sale_alert_wrapper"> |
| 94 |
<div class="popup_position <?php echo $salert_settings['popup-position'];?>"> |
| 95 |
<div class="popup_box"> |
| 96 |
<div class="popup_template animated clearfix" id="popup_template" style="display: none;"> |
| 97 |
<!-- Content will be loaded dynamically through ajax --> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
<?php |
| 103 |
} |
| 104 |
|
| 105 |
//Get salert contents |
| 106 |
public function salert_get_content(){ |
| 107 |
$path = SALERT_PATH. '/inc/display.php'; |
| 108 |
require_once($path); |
| 109 |
exit(); |
| 110 |
} |
| 111 |
|
| 112 |
public function salert_pro_plugin_action_links( $links ) { |
| 113 |
|
| 114 |
$links[] = '<a href="https://wpoperation.com/plugins/sale-alert/" target="_blank" style="color:#05c305; font-weight:bold;">'.esc_html__('Go Pro','salert').'</a>'; |
| 115 |
return $links; |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
$salert_object = new Salert(); //initialization of plugin |
| 120 |
} |