| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Modal Window |
| 4 |
* Plugin URI: https://wordpress.org/plugins/modal-window/ |
| 5 |
* Description: Create popups. Insert any content. Trigger on anything. |
| 6 |
* Version: 3.2.2 |
| 7 |
* Author: Wow-Company |
| 8 |
* Author URI: https://wow-estore.com/author/admin/?author_downloads=true |
| 9 |
* License: GPL-2.0+ |
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 11 |
*/ |
| 12 |
if ( ! defined( 'WPINC' ) ) {die;} |
| 13 |
// Declaration Wow-Company class |
| 14 |
if( !class_exists( 'Wow_Company' )) { |
| 15 |
require_once plugin_dir_path( __FILE__ ) . 'asset/class-wow-company.php'; |
| 16 |
} |
| 17 |
if( !class_exists( 'WOW_DATA' )) { |
| 18 |
require_once plugin_dir_path( __FILE__ ) . 'include/class/data.php'; |
| 19 |
} |
| 20 |
if( !class_exists( 'JavaScriptPacker' )) { |
| 21 |
require_once plugin_dir_path( __FILE__ ) . 'include/class/packer.php'; |
| 22 |
} |
| 23 |
// Declaration of the plugin class |
| 24 |
if( !class_exists( 'Modal_Window_Class' ) ) { |
| 25 |
class Modal_Window_Class |
| 26 |
{ |
| 27 |
function __construct() { |
| 28 |
$this->name = 'Modal Window'; |
| 29 |
$this->version = '3.2.2'; |
| 30 |
$this->pluginname = dirname(plugin_basename(__FILE__)); |
| 31 |
$this->plugindir = plugin_dir_path( __FILE__ ); |
| 32 |
$this->pluginurl = plugin_dir_url( __FILE__ ); |
| 33 |
// activate & diactivate |
| 34 |
register_activation_hook( __FILE__, array($this, 'plugin_activate' ) ); |
| 35 |
register_deactivation_hook( __FILE__, array($this, 'plugin_deactivate') ); |
| 36 |
// admin pages |
| 37 |
add_action( 'admin_menu', array($this, 'add_menu_page') ); |
| 38 |
// show on front end |
| 39 |
add_shortcode('Wow-Modal-Windows', array($this, 'shortcode') ); |
| 40 |
add_action( 'wp_footer', array($this, 'display') ); |
| 41 |
// add general style |
| 42 |
add_action( 'wp_enqueue_scripts', array($this, 'plugin_scripts') ); |
| 43 |
// admin links |
| 44 |
add_filter( 'plugin_row_meta', array($this, 'row_meta'), 10, 4 ); |
| 45 |
add_filter( 'plugin_action_links', array($this, 'action_links'), 10, 2 ); |
| 46 |
// check asset folder |
| 47 |
add_filter( 'admin_init', array($this, 'asset_folder') ); |
| 48 |
} |
| 49 |
// Activate & diactivate |
| 50 |
function plugin_activate() { |
| 51 |
require_once plugin_dir_path( __FILE__ ) . 'include/activator.php'; |
| 52 |
} |
| 53 |
function plugin_deactivate() { |
| 54 |
require_once plugin_dir_path( __FILE__ ) . 'include/deactivator.php'; |
| 55 |
} |
| 56 |
// AdminPanel |
| 57 |
function add_menu_page() { |
| 58 |
add_submenu_page('wow-company', $this->name, $this->name, 'manage_options', $this->pluginname, array( $this, 'plugin_admin' )); |
| 59 |
} |
| 60 |
function plugin_admin() { |
| 61 |
$name = $this->name; |
| 62 |
$pluginname = $this->pluginname; |
| 63 |
$version = $this->version; |
| 64 |
global $wow_company_plugin; |
| 65 |
$wow_company_plugin = true; |
| 66 |
include_once( 'admin/partials/main.php' ); |
| 67 |
self:: plugin_admin_style_script(); |
| 68 |
} |
| 69 |
function plugin_admin_style_script() { |
| 70 |
// plugin sctyle & script |
| 71 |
wp_enqueue_style( $this->pluginname.'-style', $this->pluginurl . 'admin/css/style.css',false, $this->version); |
| 72 |
wp_enqueue_script($this->pluginname.'-script', $this->pluginurl . 'admin/js/script.js', array('jquery'), $this->version); |
| 73 |
// icon style |
| 74 |
wp_enqueue_style( $this->pluginname.'-icon', $this->pluginurl . 'asset/font-awesome/css/font-awesome.min.css', array(), '4.7.0' ); |
| 75 |
} |
| 76 |
// Show on Front end |
| 77 |
function shortcode($atts) { |
| 78 |
extract(shortcode_atts(array('id' => ""), $atts)); |
| 79 |
global $wpdb; |
| 80 |
$table = $wpdb->prefix . "modalsimple"; |
| 81 |
$sSQL = $wpdb->prepare("select * from $table WHERE id = %d", $id); |
| 82 |
$arrresult = $wpdb->get_results($sSQL); |
| 83 |
if (count($arrresult) > 0) { |
| 84 |
foreach ($arrresult as $key => $val) { |
| 85 |
ob_start(); |
| 86 |
include( 'public/partials/public.php' ); |
| 87 |
$path_style = $this->plugindir.'/asset/css/style-'.$val->id.'.css'; |
| 88 |
$path_script = $this->plugindir.'/asset/js/script-'.$val->id.'.js'; |
| 89 |
$file_style = $this->plugindir.'/admin/partials/generator/style.php'; |
| 90 |
$file_script = $this->plugindir.'/admin/partials/generator/script.php'; |
| 91 |
if (file_exists($file_style) && !file_exists($path_style)){ |
| 92 |
ob_start(); |
| 93 |
include ($file_style); |
| 94 |
$content_style = ob_get_contents(); |
| 95 |
ob_end_clean(); |
| 96 |
file_put_contents($path_style, $content_style); |
| 97 |
} |
| 98 |
if (file_exists($file_script) && !file_exists($path_script)){ |
| 99 |
ob_start(); |
| 100 |
include ($file_script); |
| 101 |
$content_script = ob_get_contents(); |
| 102 |
$packer = new JavaScriptPacker($content_script, 'Normal', true, false); |
| 103 |
$packed = $packer->pack(); |
| 104 |
ob_end_clean(); |
| 105 |
file_put_contents($path_script, $packed); |
| 106 |
} |
| 107 |
$popup = ob_get_contents(); |
| 108 |
ob_end_clean(); |
| 109 |
if ($val->use_cookies == 'yes'){ |
| 110 |
$namecookie = 'wow-modal-id-'.$val->id; |
| 111 |
if (!isset($_COOKIE[$namecookie])){ |
| 112 |
$popupcookie = true; |
| 113 |
wp_enqueue_script( $this->pluginname.'-cookie', $this->pluginurl . 'public/js/jquery.cookie.js', array( 'jquery' ), $this->version); |
| 114 |
} |
| 115 |
else { |
| 116 |
$popupcookie = false; |
| 117 |
} |
| 118 |
} |
| 119 |
if ($val->use_cookies == 'no'){ |
| 120 |
$popupcookie = true; |
| 121 |
} |
| 122 |
if ($popupcookie == true) { |
| 123 |
if (file_exists($path_style)) { |
| 124 |
wp_enqueue_style( $this->pluginname.'-style-'.$val->id, $this->pluginurl. 'asset/css/style-'.$val->id.'.css', null, $this->version); |
| 125 |
} |
| 126 |
if (file_exists($path_script)) { |
| 127 |
wp_enqueue_script( $this->pluginname.'-script-'.$val->id, $this->pluginurl. 'asset/js/script-'.$val->id.'.js', array( 'jquery' ), $this->version ); |
| 128 |
} |
| 129 |
wp_enqueue_style( $this->pluginname.'-font-awesome', $this->pluginurl . 'asset/font-awesome/css/font-awesome.min.css', array(), '4.7.0' ); |
| 130 |
|
| 131 |
return $popup; |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
} |
| 137 |
function display() { |
| 138 |
require plugin_dir_path( __FILE__ ) . 'public/display.php'; |
| 139 |
} |
| 140 |
// General plugin styles & scripts |
| 141 |
function plugin_scripts(){ |
| 142 |
wp_enqueue_style( $this->pluginname, plugin_dir_url( __FILE__ ) . 'public/css/style.css', array(), $this->version); |
| 143 |
} |
| 144 |
// Admin links |
| 145 |
function row_meta( $meta, $plugin_file ){ |
| 146 |
if( false === strpos( $plugin_file, basename(__FILE__) ) ) |
| 147 |
return $meta; |
| 148 |
$meta[] = '<a href="https://wow-estore.com/item/wow-modal-windows-pro/" target="_blank">Pro version</a>'; |
| 149 |
return $meta; |
| 150 |
} |
| 151 |
function action_links( $actions, $plugin_file ){ |
| 152 |
if( false === strpos( $plugin_file, basename(__FILE__) ) ) |
| 153 |
return $actions; |
| 154 |
$settings_link = '<a href="admin.php?page='. $this->pluginname .'">Settings</a>'; |
| 155 |
array_unshift( $actions, $settings_link ); |
| 156 |
return $actions; |
| 157 |
} |
| 158 |
// check asset folder |
| 159 |
function asset_folder(){ |
| 160 |
$path = plugin_dir_path( __FILE__ ).'asset'; |
| 161 |
if (!is_writable($path)) { |
| 162 |
echo "<div class='error' id='message'><p>Please set the 775 access rights (chmod 775) for the '".$path."</p> </div>"; |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
$plugin = new Modal_Window_Class(); |
| 167 |
} |