| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Slider Ultimate |
| 4 |
Plugin URI: http://www.EtoileWebDesign.com/plugins/ |
| 5 |
Description: A plugin that lets you create a slider, using posts, WooCommerce or Ultimate Product Catalog products |
| 6 |
Author: Etoile Web Design |
| 7 |
Author URI: http://www.EtoileWebDesign.com/plugins/ |
| 8 |
Terms and Conditions: http://www.etoilewebdesign.com/plugin-terms-and-conditions/ |
| 9 |
Text Domain: ultimate-slider |
| 10 |
Version: 1.1.3 |
| 11 |
*/ |
| 12 |
|
| 13 |
global $ewd_us_message; |
| 14 |
global $US_Full_Version; |
| 15 |
global $EWD_US_Version; |
| 16 |
|
| 17 |
$EWD_US_Version = '1.1.0a'; |
| 18 |
|
| 19 |
define( 'EWD_US_CD_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 20 |
define( 'EWD_US_CD_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 21 |
|
| 22 |
register_activation_hook(__FILE__,'Set_EWD_US_Options'); |
| 23 |
register_activation_hook(__FILE__,'EWD_US_Show_Dashboard_Link'); |
| 24 |
|
| 25 |
if ( is_admin() ){ |
| 26 |
add_action('admin_head', 'EWD_US_Admin_Options'); |
| 27 |
add_action('widgets_init', 'Update_EWD_US_Content'); |
| 28 |
add_action('admin_notices', 'EWD_US_Error_Notices'); |
| 29 |
} |
| 30 |
|
| 31 |
function EWD_US_localization_setup() { |
| 32 |
load_plugin_textdomain('ultimate-slider', false, dirname(plugin_basename(__FILE__)) . '/lang/'); |
| 33 |
} |
| 34 |
add_action('after_setup_theme', 'EWD_US_localization_setup'); |
| 35 |
|
| 36 |
function EWD_US_Admin_Options() { |
| 37 |
global $EWD_US_Version; |
| 38 |
|
| 39 |
wp_enqueue_script('ewd-us-review-ask', plugins_url("js/ewd-us-dashboard-review-ask.js", __FILE__), array('jquery'), $EWD_US_Version); |
| 40 |
|
| 41 |
wp_enqueue_style( 'ewd-us-admin', plugins_url("ultimate-slider/css/Admin.css"), $EWD_US_Version); |
| 42 |
wp_enqueue_style( 'spectrum', plugins_url("ultimate-slider/css/spectrum.css")); |
| 43 |
} |
| 44 |
|
| 45 |
function EWD_US_Enable_Sub_Menu() { |
| 46 |
add_submenu_page('edit.php?post_type=ultimate_slider', 'Slider Options', 'Settings', 'edit_posts', 'us-options', 'EWD_US_Output_Options_Page'); |
| 47 |
} |
| 48 |
add_action('admin_menu' , 'EWD_US_Enable_Sub_Menu'); |
| 49 |
|
| 50 |
|
| 51 |
function EWD_US_Make_Posts_Sortable($hook) { |
| 52 |
global $post; |
| 53 |
global $EWD_US_Version; |
| 54 |
if (is_object($post)) {$post_type = $post->post_type; } |
| 55 |
else { $post_type = ""; } |
| 56 |
if ($hook == 'edit.php' or $hook == 'post-new.php' or $hook == 'post.php' or $hook == 'ultimate_slider_page_us-options' or $hook == 'widgets.php') { |
| 57 |
if ($post_type == 'ultimate_slider' or $hook == 'ultimate_slider_page_us-options' or $hook == 'widgets.php') { |
| 58 |
wp_enqueue_script( 'jquery-ui-core' ); |
| 59 |
wp_enqueue_script( 'jquery-ui-sortable' ); |
| 60 |
wp_enqueue_script( 'ultimate-slider-admin', plugins_url('ultimate-slider/js/ultimate-slider-admin.js'), array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), $EWD_US_Version, true); |
| 61 |
wp_enqueue_script( 'spectrum', plugins_url('ultimate-slider/js/spectrum.js'), array('jquery'), true); |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
add_action( 'admin_enqueue_scripts', 'EWD_US_Make_Posts_Sortable', 10, 1 ); |
| 66 |
|
| 67 |
add_action( 'wp_enqueue_scripts', 'EWD_US_Add_Stylesheet' ); |
| 68 |
function EWD_US_Add_Stylesheet() { |
| 69 |
global $EWD_US_Version; |
| 70 |
|
| 71 |
wp_enqueue_style( 'ewd-us-main', plugins_url("ultimate-slider/css/ewd-us-main.css"), $EWD_US_Version); |
| 72 |
wp_enqueue_style( 'ewd-ulb-main', plugins_url("ultimate-slider/css/ewd-ulb-main.css"), $EWD_US_Version); |
| 73 |
} |
| 74 |
|
| 75 |
// Add settings link on plugin page |
| 76 |
function EWD_US_plugin_settings_link($links) { |
| 77 |
$settings_link = '<a href="edit.php?post_type=ultimate_slider">Settings</a>'; |
| 78 |
array_unshift($links, $settings_link); |
| 79 |
return $links; |
| 80 |
} |
| 81 |
$plugin = plugin_basename(__FILE__); |
| 82 |
add_filter("plugin_action_links_$plugin", 'EWD_US_plugin_settings_link' ); |
| 83 |
|
| 84 |
add_action( 'wp_enqueue_scripts', 'Add_EWD_US_FrontEnd_Scripts' ); |
| 85 |
function Add_EWD_US_FrontEnd_Scripts() { |
| 86 |
global $EWD_US_Version; |
| 87 |
wp_register_script( 'ultimate-slider', plugins_url('ultimate-slider/js/ultimate-slider.js'), array('jquery'), $EWD_US_Version, true); |
| 88 |
|
| 89 |
$Autoplay_Slideshow = get_option('EWD_US_Autoplay_Slideshow'); |
| 90 |
$Autoplay_Delay = get_option('EWD_US_Autoplay_Delay'); |
| 91 |
$Autoplay_Interval = get_option("EWD_US_Autoplay_Interval"); |
| 92 |
$Slide_Transition_Effect = get_option("EWD_US_Slide_Transition_Effect"); |
| 93 |
$Transition_Time = get_option("EWD_US_Transition_Time"); |
| 94 |
$Aspect_Ratio = get_option("EWD_US_Aspect_Ratio"); |
| 95 |
$Mobile_Aspect_Ratio = get_option("EWD_US_Mobile_Aspect_Ratio"); |
| 96 |
$Carousel = get_option("EWD_US_Carousel"); |
| 97 |
$Carousel_Columns = get_option("EWD_US_Carousel_Columns"); |
| 98 |
$Carousel_Link_To_Full = get_option("EWD_US_Carousel_Link_To_Full"); |
| 99 |
$Carousel_Advance = get_option("EWD_US_Carousel_Advance"); |
| 100 |
$Title_Animate = get_option("EWD_US_Title_Animate"); |
| 101 |
$Lightbox = get_option("EWD_US_Lightbox"); |
| 102 |
$Timer_Bar = get_option("EWD_US_Timer_Bar"); |
| 103 |
$Force_Full_Width = get_option("EWD_US_Force_Full_Width"); |
| 104 |
$Autoplay_Pause_Hover = get_option("EWD_US_Autoplay_Pause_Hover"); |
| 105 |
|
| 106 |
$Aspect_Fraction = EWD_US_Get_Aspect_Fraction($Aspect_Ratio); |
| 107 |
$Mobile_Aspect_Fraction = EWD_US_Get_Aspect_Fraction($Mobile_Aspect_Ratio); |
| 108 |
|
| 109 |
$Data_Array = array( 'autoplay_slideshow' => $Autoplay_Slideshow, |
| 110 |
'autoplay_delay' => $Autoplay_Delay, |
| 111 |
'autoplay_interval' => $Autoplay_Interval, |
| 112 |
'slide_transition_effect' => $Slide_Transition_Effect, |
| 113 |
'transition_time' => $Transition_Time, |
| 114 |
'aspect_ratio' => $Aspect_Fraction, |
| 115 |
'mobile_aspect_ratio' => $Mobile_Aspect_Fraction, |
| 116 |
'slider_carousel' => $Carousel, |
| 117 |
'carousel_columns' => $Carousel_Columns, |
| 118 |
'carousel_link_to_full' => $Carousel_Link_To_Full, |
| 119 |
'carousel_advance' => $Carousel_Advance, |
| 120 |
'title_animate' => $Title_Animate, |
| 121 |
'lightbox' => $Lightbox, |
| 122 |
'timer_bar' => $Timer_Bar, |
| 123 |
'force_full_width' => $Force_Full_Width, |
| 124 |
'autoplay_pause_hover' => $Autoplay_Pause_Hover |
| 125 |
); |
| 126 |
wp_localize_script( 'ultimate-slider', 'ewd_us_php_data', $Data_Array ); |
| 127 |
|
| 128 |
wp_enqueue_script('ultimate-slider'); |
| 129 |
|
| 130 |
wp_enqueue_script( 'iframe-clicks', plugins_url('ultimate-slider/js/jquery.iframetracker.js'), array('jquery'), true); |
| 131 |
if ($Lightbox == "Yes") { |
| 132 |
wp_enqueue_script( 'ultimate-lightbox', plugins_url('ultimate-slider/js/ultimate-lightbox.js'), array('jquery'), $EWD_US_Version, true); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
function EWD_US_Get_Aspect_Fraction($Aspect_Ratio) { |
| 137 |
if ($Aspect_Ratio == "3_1") {$Aspect_Fraction = .333333333;} |
| 138 |
if ($Aspect_Ratio == "16_7") {$Aspect_Fraction = .444444444;} |
| 139 |
if ($Aspect_Ratio == "2_1") {$Aspect_Fraction = .5;} |
| 140 |
if ($Aspect_Ratio == "16_9") {$Aspect_Fraction = .5625;} |
| 141 |
if ($Aspect_Ratio == "3_2") {$Aspect_Fraction = .666666666;} |
| 142 |
if ($Aspect_Ratio == "4_3") {$Aspect_Fraction = .75;} |
| 143 |
if ($Aspect_Ratio == "1_1") {$Aspect_Fraction = 1;} |
| 144 |
|
| 145 |
return $Aspect_Fraction; |
| 146 |
} |
| 147 |
|
| 148 |
$US_Full_Version = get_option("EWD_US_Full_Version"); |
| 149 |
|
| 150 |
if (isset($_GET['post_type']) and $_GET['post_type'] == 'ultimate_slider' and ($US_Full_Version != "Yes" or get_option("EWD_US_Trial_Happening") == "Yes")) {add_action("admin_notices", "EWD_US_Upgrade_Box");} |
| 151 |
if (isset($_GET['post_type']) and $_GET['post_type'] == 'ultimate_slider' and isset($_POST['EWD_US_Upgrade_To_Full']) and $US_Full_Version == "Yes") {add_action("admin_notices", "EWD_US_Upgrade_Notice");} |
| 152 |
|
| 153 |
if (isset($_POST['EWD_US_Upgrade_To_Full'])) { |
| 154 |
add_action('admin_init', 'EWD_US_Upgrade_To_Full'); |
| 155 |
} |
| 156 |
|
| 157 |
function EWD_US_Show_Dashboard_Link() { |
| 158 |
set_transient('ewd-us-admin-install-notice', true, 5); |
| 159 |
} |
| 160 |
|
| 161 |
$Show_TinyMCE = get_option("EWD_US_Show_TinyMCE"); |
| 162 |
if ($Show_TinyMCE == "Yes") { |
| 163 |
add_filter( 'mce_buttons', 'EWD_US_Register_TinyMCE_Buttons' ); |
| 164 |
add_filter( 'mce_external_plugins', 'EWD_US_Register_TinyMCE_Javascript' ); |
| 165 |
add_action('admin_head', 'EWD_US_Output_TinyMCE_Vars'); |
| 166 |
} |
| 167 |
|
| 168 |
function EWD_US_Register_TinyMCE_Buttons( $buttons ) { |
| 169 |
array_push( $buttons, 'separator', 'US_Shortcodes' ); |
| 170 |
return $buttons; |
| 171 |
} |
| 172 |
|
| 173 |
function EWD_US_Register_TinyMCE_Javascript( $plugin_array ) { |
| 174 |
$plugin_array['US_Shortcodes'] = plugins_url( '/js/tinymce-plugin.js',__FILE__ ); |
| 175 |
|
| 176 |
return $plugin_array; |
| 177 |
} |
| 178 |
|
| 179 |
function EWD_US_Output_TinyMCE_Vars() { |
| 180 |
global $US_Full_Version; |
| 181 |
|
| 182 |
$Categories = get_terms('ultimate_slider_categories', array('hide_empty' => false)); |
| 183 |
if ($Categories) { |
| 184 |
foreach ($Categories as $Category) { |
| 185 |
$Category_Array_Item['Category_Name'] = $Category->name; |
| 186 |
$Category_Array_Item['Category_Slug'] = $Category->slug; |
| 187 |
|
| 188 |
$Categories_Array[] = $Category_Array_Item; |
| 189 |
} |
| 190 |
} |
| 191 |
$WC_Categories = get_terms('product_cat', array('hide_empty' => false)); |
| 192 |
if ($WC_Categories) { |
| 193 |
foreach ($WC_Categories as $Category) { |
| 194 |
$Category_Array_Item['Category_Name'] = $Category->name; |
| 195 |
$Category_Array_Item['Category_Slug'] = $Category->slug; |
| 196 |
|
| 197 |
$WC_Categories_Array[] = $Category_Array_Item; |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
echo "<script type='text/javascript'>"; |
| 202 |
echo "var us_premium = '" . $US_Full_Version . "';\n"; |
| 203 |
echo "var slider_categories = " . json_encode($Categories_Array) . ";\n"; |
| 204 |
echo "var woocommerce_categories = " . json_encode($WC_Categories_Array) . ";\n"; |
| 205 |
echo "</script>"; |
| 206 |
} |
| 207 |
|
| 208 |
function US_Post_Edit_Styles( $hook_suffix ){ |
| 209 |
$cpt = 'ultimate_slider'; |
| 210 |
if( in_array( $hook_suffix, array('post.php', 'post-new.php') ) ){ |
| 211 |
$screen = get_current_screen(); |
| 212 |
if( is_object( $screen ) && $cpt == $screen->post_type ){ |
| 213 |
wp_enqueue_style( 'ewd-us-post-edit-styles', plugins_url("ultimate-slider/css/ewd-us-post-edit-styles.css")); |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
add_action('admin_enqueue_scripts', 'US_Post_Edit_Styles'); |
| 218 |
|
| 219 |
include "blocks/ewd-us-blocks.php"; |
| 220 |
include "Functions/EWD_US_Add_Meta_Boxes.php"; |
| 221 |
include "Functions/EWD_US_Add_Order_Column.php"; |
| 222 |
include "Functions/EWD_US_Deactivation_Survey.php"; |
| 223 |
include "Functions/EWD_US_Error_Notices.php"; |
| 224 |
include "Functions/EWD_US_Full_Upgrade.php"; |
| 225 |
include "Functions/EWD_US_Output_Options_Page.php"; |
| 226 |
include "Functions/EWD_US_Process_Ajax.php"; |
| 227 |
include "Functions/EWD_US_Register_Custom_Posttype.php"; |
| 228 |
include "Functions/EWD_US_Upgrade_Box.php"; |
| 229 |
include "Functions/EWD_US_Version_Reversion.php"; |
| 230 |
include "Functions/EWD_US_Widgets.php"; |
| 231 |
include "Functions/EWD_US_WooCommerce.php"; |
| 232 |
include "Functions/Update_EWD_US_Admin_Databases.php"; |
| 233 |
include "Functions/Update_EWD_US_Content.php"; |
| 234 |
include "Functions/EWD_US_Styling.php"; |
| 235 |
include "Functions/EWD_US_Add_Views_Column.php"; |
| 236 |
|
| 237 |
include "Shortcodes/Display_Slider.php"; |
| 238 |
|
| 239 |
if (get_option('EWD_US_Version') != $EWD_US_Version) { |
| 240 |
Set_EWD_US_Options(); |
| 241 |
} |
| 242 |
|
| 243 |
function Set_EWD_US_Options() { |
| 244 |
global $US_Full_Version; |
| 245 |
global $EWD_US_Version; |
| 246 |
|
| 247 |
if (get_option("EWD_US_Autoplay_Slideshow") == "") {update_option("EWD_US_Autoplay_Slideshow", "Yes");} |
| 248 |
if (get_option("EWD_US_Autoplay_Delay") == "") {update_option("EWD_US_Autoplay_Delay", 6);} |
| 249 |
if (get_option("EWD_US_Autoplay_Interval") == "") {update_option("EWD_US_Autoplay_Interval", 4);} |
| 250 |
if (get_option("EWD_US_Transition_Time") == "") {update_option("EWD_US_Transition_Time", 1);} |
| 251 |
if (get_option("EWD_US_Aspect_Ratio") == "") {update_option("EWD_US_Aspect_Ratio", "16_7");} |
| 252 |
if (get_option("EWD_US_Carousel") == "") {update_option("EWD_US_Carousel", "No");} |
| 253 |
if (get_option("EWD_US_Carousel_Columns") == "") {update_option("EWD_US_Carousel_Columns", "3");} |
| 254 |
if (get_option("EWD_US_Carousel_Link_To_Full") == "") {update_option("EWD_US_Carousel_Link_To_Full", "Yes");} |
| 255 |
if (get_option("EWD_US_Carousel_Advance") == "") {update_option("EWD_US_Carousel_Advance", "Full");} |
| 256 |
if (get_option("EWD_US_Show_TinyMCE") == "") {update_option("EWD_US_Show_TinyMCE", "Yes");} |
| 257 |
if (get_option("EWD_US_Timer_Bar") == "") {update_option("EWD_US_Timer_Bar", "Top");} |
| 258 |
if (get_option("EWD_US_Slide_Indicators") == "") {update_option("EWD_US_Slide_Indicators", "Dots");} |
| 259 |
if (get_option("EWD_US_Link_Action") == "") {update_option("EWD_US_Link_Action", "Same");} |
| 260 |
if (get_option("EWD_US_Slide_Transition_Effect") == "") {update_option("EWD_US_Slide_Transition_Effect", "slide");} |
| 261 |
if (get_option("EWD_US_WC_Product_Image_Slider") == "") {update_option("EWD_US_WC_Product_Image_Slider", "No");} |
| 262 |
if (get_option("EWD_US_Mobile_Aspect_Ratio") == "") {update_option("EWD_US_Mobile_Aspect_Ratio", get_option("EWD_US_Aspect_Ratio"));} |
| 263 |
if (get_option("EWD_US_Hide_On_Mobile") == "") {update_option("EWD_US_Hide_On_Mobile", array('body', 'buttons'));} |
| 264 |
if (get_option("EWD_US_Mobile_Link_To_Full") == "") {update_option("EWD_US_Mobile_Link_To_Full", "No");} |
| 265 |
if (get_option("EWD_US_Add_Watermark") == "") {update_option("EWD_US_Add_Watermark", "No");} |
| 266 |
if (get_option("EWD_US_Title_Animate") == "") {update_option("EWD_US_Title_Animate", "None");} |
| 267 |
if (get_option("EWD_US_Lightbox") == "") {update_option("EWD_US_Lightbox", "No");} |
| 268 |
if (get_option("EWD_US_Full_Version") == "") {update_option("EWD_US_Full_Version", "No");} |
| 269 |
if (get_option("EWD_US_Install_Time") == "") {update_option("EWD_US_Install_Time", time());} |
| 270 |
if(!get_option("EWD_US_Ask_Review_Date") || get_option("EWD_US_Ask_Review_Date") == ""){update_option("EWD_US_Ask_Review_Date", get_option("EWD_US_Install_Time") + 3600*24*4);} |
| 271 |
|
| 272 |
if (get_option("EWD_us_Arrow") == "") {update_option("EWD_us_Arrow", "a");} |
| 273 |
if (get_option("EWD_us_Arrow_Background_Shape") == "") {update_option("EWD_us_Arrow_Background_Shape", "None");} |
| 274 |
if (get_option("EWD_us_Arrow_Line_Height") == "") {update_option("EWD_us_Arrow_Line_Height", "1.25");} |
| 275 |
|
| 276 |
update_option("EWD_US_Version", $EWD_US_Version); |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
|