Main.php
| 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.0.18 |
| 11 | */ |
| 12 | |
| 13 | global $ewd_us_message; |
| 14 | global $US_Full_Version; |
| 15 | global $EWD_US_Version; |
| 16 | |
| 17 | $EWD_US_Version = '1.0.3'; |
| 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 | |
| 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_Admin_Options() { |
| 32 | wp_enqueue_style( 'ewd-us-admin', plugins_url("ultimate-slider/css/Admin.css")); |
| 33 | wp_enqueue_style( 'spectrum', plugins_url("ultimate-slider/css/spectrum.css")); |
| 34 | } |
| 35 | |
| 36 | function EWD_US_Enable_Sub_Menu() { |
| 37 | add_submenu_page('edit.php?post_type=ultimate_slider', 'Slider Options', 'Settings', 'edit_posts', 'us-options', 'EWD_US_Output_Options_Page'); |
| 38 | } |
| 39 | add_action('admin_menu' , 'EWD_US_Enable_Sub_Menu'); |
| 40 | |
| 41 | |
| 42 | function EWD_US_Make_Posts_Sortable($hook) { |
| 43 | global $post; |
| 44 | if (is_object($post)) {$post_type = $post->post_type; } |
| 45 | else { $post_type = ""; } |
| 46 | if ($hook == 'edit.php' or $hook == 'post-new.php' or $hook == 'post.php' or $hook == 'ultimate_slider_page_us-options' or $hook == 'widgets.php') { |
| 47 | if ($post_type == 'ultimate_slider' or $hook == 'ultimate_slider_page_us-options' or $hook == 'widgets.php') { |
| 48 | wp_enqueue_script( 'jquery-ui-core' ); |
| 49 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 50 | wp_enqueue_script( 'ultimate-slider-admin', plugins_url('ultimate-slider/js/ultimate-slider-admin.js'), array('jquery', 'jquery-ui-core', 'jquery-ui-sortable'), true); |
| 51 | wp_enqueue_script( 'spectrum', plugins_url('ultimate-slider/js/spectrum.js'), array('jquery'), true); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | add_action( 'admin_enqueue_scripts', 'EWD_US_Make_Posts_Sortable', 10, 1 ); |
| 56 | |
| 57 | add_action( 'wp_enqueue_scripts', 'EWD_US_Add_Stylesheet' ); |
| 58 | function EWD_US_Add_Stylesheet() { |
| 59 | wp_enqueue_style( 'ewd-us-main', plugins_url("ultimate-slider/css/ewd-us-main.css")); |
| 60 | wp_enqueue_style( 'ewd-ulb-main', plugins_url("ultimate-slider/css/ewd-ulb-main.css")); |
| 61 | } |
| 62 | |
| 63 | // Add settings link on plugin page |
| 64 | function EWD_US_plugin_settings_link($links) { |
| 65 | $settings_link = '<a href="edit.php?post_type=ultimate_slider">Settings</a>'; |
| 66 | array_unshift($links, $settings_link); |
| 67 | return $links; |
| 68 | } |
| 69 | $plugin = plugin_basename(__FILE__); |
| 70 | add_filter("plugin_action_links_$plugin", 'EWD_US_plugin_settings_link' ); |
| 71 | |
| 72 | add_action( 'wp_enqueue_scripts', 'Add_EWD_US_FrontEnd_Scripts' ); |
| 73 | function Add_EWD_US_FrontEnd_Scripts() { |
| 74 | wp_register_script( 'ultimate-slider', plugins_url('ultimate-slider/js/ultimate-slider.js'), array('jquery'), true); |
| 75 | |
| 76 | $Autoplay_Slideshow = get_option('EWD_US_Autoplay_Slideshow'); |
| 77 | $Autoplay_Delay = get_option('EWD_US_Autoplay_Delay'); |
| 78 | $Autoplay_Interval = get_option("EWD_US_Autoplay_Interval"); |
| 79 | $Slide_Transition_Effect = get_option("EWD_US_Slide_Transition_Effect"); |
| 80 | $Transition_Time = get_option("EWD_US_Transition_Time"); |
| 81 | $Aspect_Ratio = get_option("EWD_US_Aspect_Ratio"); |
| 82 | $Mobile_Aspect_Ratio = get_option("EWD_US_Mobile_Aspect_Ratio"); |
| 83 | $Carousel = get_option("EWD_US_Carousel"); |
| 84 | $Carousel_Columns = get_option("EWD_US_Carousel_Columns"); |
| 85 | $Carousel_Link_To_Full = get_option("EWD_US_Carousel_Link_To_Full"); |
| 86 | $Carousel_Advance = get_option("EWD_US_Carousel_Advance"); |
| 87 | $Title_Animate = get_option("EWD_US_Title_Animate"); |
| 88 | $Lightbox = get_option("EWD_US_Lightbox"); |
| 89 | $Timer_Bar = get_option("EWD_US_Timer_Bar"); |
| 90 | |
| 91 | $Aspect_Fraction = EWD_US_Get_Aspect_Fraction($Aspect_Ratio); |
| 92 | $Mobile_Aspect_Fraction = EWD_US_Get_Aspect_Fraction($Mobile_Aspect_Ratio); |
| 93 | |
| 94 | $Data_Array = array( 'autoplay_slideshow' => $Autoplay_Slideshow, |
| 95 | 'autoplay_delay' => $Autoplay_Delay, |
| 96 | 'autoplay_interval' => $Autoplay_Interval, |
| 97 | 'slide_transition_effect' => $Slide_Transition_Effect, |
| 98 | 'transition_time' => $Transition_Time, |
| 99 | 'aspect_ratio' => $Aspect_Fraction, |
| 100 | 'mobile_aspect_ratio' => $Mobile_Aspect_Fraction, |
| 101 | 'slider_carousel' => $Carousel, |
| 102 | 'carousel_columns' => $Carousel_Columns, |
| 103 | 'carousel_link_to_full' => $Carousel_Link_To_Full, |
| 104 | 'carousel_advance' => $Carousel_Advance, |
| 105 | 'title_animate' => $Title_Animate, |
| 106 | 'lightbox' => $Lightbox, |
| 107 | 'timer_bar' => $Timer_Bar |
| 108 | ); |
| 109 | wp_localize_script( 'ultimate-slider', 'ewd_us_php_data', $Data_Array ); |
| 110 | |
| 111 | wp_enqueue_script('ultimate-slider'); |
| 112 | |
| 113 | wp_enqueue_script( 'iframe-clicks', plugins_url('ultimate-slider/js/jquery.iframetracker.js'), array('jquery'), true); |
| 114 | if ($Lightbox == "Yes") { |
| 115 | wp_enqueue_script( 'ultimate-lightbox', plugins_url('ultimate-slider/js/ultimate-lightbox.js'), array('jquery'), true); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | function EWD_US_Get_Aspect_Fraction($Aspect_Ratio) { |
| 120 | if ($Aspect_Ratio == "3_1") {$Aspect_Fraction = .333333333;} |
| 121 | if ($Aspect_Ratio == "16_7") {$Aspect_Fraction = .444444444;} |
| 122 | if ($Aspect_Ratio == "2_1") {$Aspect_Fraction = .5;} |
| 123 | if ($Aspect_Ratio == "16_9") {$Aspect_Fraction = .5625;} |
| 124 | if ($Aspect_Ratio == "3_2") {$Aspect_Fraction = .666666666;} |
| 125 | if ($Aspect_Ratio == "4_3") {$Aspect_Fraction = .75;} |
| 126 | if ($Aspect_Ratio == "1_1") {$Aspect_Fraction = 1;} |
| 127 | |
| 128 | return $Aspect_Fraction; |
| 129 | } |
| 130 | |
| 131 | $US_Full_Version = get_option("EWD_US_Full_Version"); |
| 132 | |
| 133 | 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");} |
| 134 | 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");} |
| 135 | |
| 136 | if (isset($_POST['EWD_US_Upgrade_To_Full'])) { |
| 137 | add_action('admin_init', 'EWD_US_Upgrade_To_Full'); |
| 138 | } |
| 139 | |
| 140 | $Show_TinyMCE = get_option("EWD_US_Show_TinyMCE"); |
| 141 | if ($Show_TinyMCE == "Yes") { |
| 142 | add_filter( 'mce_buttons', 'EWD_US_Register_TinyMCE_Buttons' ); |
| 143 | add_filter( 'mce_external_plugins', 'EWD_US_Register_TinyMCE_Javascript' ); |
| 144 | add_action('admin_head', 'EWD_US_Output_TinyMCE_Vars'); |
| 145 | } |
| 146 | |
| 147 | function EWD_US_Register_TinyMCE_Buttons( $buttons ) { |
| 148 | array_push( $buttons, 'separator', 'US_Shortcodes' ); |
| 149 | return $buttons; |
| 150 | } |
| 151 | |
| 152 | function EWD_US_Register_TinyMCE_Javascript( $plugin_array ) { |
| 153 | $plugin_array['US_Shortcodes'] = plugins_url( '/js/tinymce-plugin.js',__FILE__ ); |
| 154 | |
| 155 | return $plugin_array; |
| 156 | } |
| 157 | |
| 158 | function EWD_US_Output_TinyMCE_Vars() { |
| 159 | global $US_Full_Version; |
| 160 | |
| 161 | $Categories = get_terms('ultimate_slider_categories', array('hide_empty' => false)); |
| 162 | if ($Categories) { |
| 163 | foreach ($Categories as $Category) { |
| 164 | $Category_Array_Item['Category_Name'] = $Category->name; |
| 165 | $Category_Array_Item['Category_Slug'] = $Category->slug; |
| 166 | |
| 167 | $Categories_Array[] = $Category_Array_Item; |
| 168 | } |
| 169 | } |
| 170 | $WC_Categories = get_terms('product_cat', array('hide_empty' => false)); |
| 171 | if ($WC_Categories) { |
| 172 | foreach ($WC_Categories as $Category) { |
| 173 | $Category_Array_Item['Category_Name'] = $Category->name; |
| 174 | $Category_Array_Item['Category_Slug'] = $Category->slug; |
| 175 | |
| 176 | $WC_Categories_Array[] = $Category_Array_Item; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | echo "<script type='text/javascript'>"; |
| 181 | echo "var us_premium = '" . $US_Full_Version . "';\n"; |
| 182 | echo "var slider_categories = " . json_encode($Categories_Array) . ";\n"; |
| 183 | echo "var woocommerce_categories = " . json_encode($WC_Categories_Array) . ";\n"; |
| 184 | echo "</script>"; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | include "Functions/EWD_US_Add_Meta_Boxes.php"; |
| 189 | include "Functions/EWD_US_Add_Order_Column.php"; |
| 190 | include "Functions/EWD_US_Error_Notices.php"; |
| 191 | include "Functions/EWD_US_Full_Upgrade.php"; |
| 192 | include "Functions/EWD_US_Output_Options_Page.php"; |
| 193 | include "Functions/EWD_US_Process_Ajax.php"; |
| 194 | include "Functions/EWD_US_Register_Custom_Posttype.php"; |
| 195 | include "Functions/EWD_US_Upgrade_Box.php"; |
| 196 | include "Functions/EWD_US_Version_Reversion.php"; |
| 197 | include "Functions/EWD_US_Widgets.php"; |
| 198 | include "Functions/EWD_US_WooCommerce.php"; |
| 199 | include "Functions/Update_EWD_US_Admin_Databases.php"; |
| 200 | include "Functions/Update_EWD_US_Content.php"; |
| 201 | include "Functions/EWD_US_Styling.php"; |
| 202 | include "Functions/EWD_US_Add_Views_Column.php"; |
| 203 | |
| 204 | include "Shortcodes/Display_Slider.php"; |
| 205 | |
| 206 | if (get_option('EWD_US_Version') != $EWD_US_Version) { |
| 207 | Set_EWD_US_Options(); |
| 208 | } |
| 209 | |
| 210 | function Set_EWD_US_Options() { |
| 211 | global $US_Full_Version; |
| 212 | global $EWD_US_Version; |
| 213 | |
| 214 | if (get_option("EWD_US_Autoplay_Slideshow") == "") {update_option("EWD_US_Autoplay_Slideshow", "Yes");} |
| 215 | if (get_option("EWD_US_Autoplay_Delay") == "") {update_option("EWD_US_Autoplay_Delay", 6);} |
| 216 | if (get_option("EWD_US_Autoplay_Interval") == "") {update_option("EWD_US_Autoplay_Interval", 4);} |
| 217 | if (get_option("EWD_US_Transition_Time") == "") {update_option("EWD_US_Transition_Time", 1);} |
| 218 | if (get_option("EWD_US_Aspect_Ratio") == "") {update_option("EWD_US_Aspect_Ratio", "16_7");} |
| 219 | if (get_option("EWD_US_Carousel") == "") {update_option("EWD_US_Carousel", "No");} |
| 220 | if (get_option("EWD_US_Carousel_Columns") == "") {update_option("EWD_US_Carousel_Columns", "3");} |
| 221 | if (get_option("EWD_US_Carousel_Link_To_Full") == "") {update_option("EWD_US_Carousel_Link_To_Full", "Yes");} |
| 222 | if (get_option("EWD_US_Carousel_Advance") == "") {update_option("EWD_US_Carousel_Advance", "Full");} |
| 223 | if (get_option("EWD_US_Show_TinyMCE") == "") {update_option("EWD_US_Show_TinyMCE", "Yes");} |
| 224 | if (get_option("EWD_US_Timer_Bar") == "") {update_option("EWD_US_Timer_Bar", "Top");} |
| 225 | if (get_option("EWD_US_Slide_Indicators") == "") {update_option("EWD_US_Slide_Indicators", "Dots");} |
| 226 | if (get_option("EWD_US_Link_Action") == "") {update_option("EWD_US_Link_Action", "Same");} |
| 227 | if (get_option("EWD_US_Slide_Transition_Effect") == "") {update_option("EWD_US_Slide_Transition_Effect", "slide");} |
| 228 | if (get_option("EWD_US_WC_Product_Image_Slider") == "") {update_option("EWD_US_WC_Product_Image_Slider", "No");} |
| 229 | if (get_option("EWD_US_Mobile_Aspect_Ratio") == "") {update_option("EWD_US_Mobile_Aspect_Ratio", get_option("EWD_US_Aspect_Ratio"));} |
| 230 | if (get_option("EWD_US_Hide_On_Mobile") == "") {update_option("EWD_US_Hide_On_Mobile", array('body', 'buttons'));} |
| 231 | if (get_option("EWD_US_Mobile_Link_To_Full") == "") {update_option("EWD_US_Mobile_Link_To_Full", "No");} |
| 232 | if (get_option("EWD_US_Add_Watermark") == "") {update_option("EWD_US_Add_Watermark", "No");} |
| 233 | if (get_option("EWD_US_Title_Animate") == "") {update_option("EWD_US_Title_Animate", "None");} |
| 234 | if (get_option("EWD_US_Lightbox") == "") {update_option("EWD_US_Lightbox", "No");} |
| 235 | if (get_option("EWD_US_Full_Version") == "") {update_option("EWD_US_Full_Version", "No");} |
| 236 | |
| 237 | if (get_option("EWD_us_Arrow") == "") {update_option("EWD_us_Arrow", "a");} |
| 238 | if (get_option("EWD_us_Arrow_Background_Shape") == "") {update_option("EWD_us_Arrow_Background_Shape", "None");} |
| 239 | if (get_option("EWD_us_Arrow_Line_Height") == "") {update_option("EWD_us_Arrow_Line_Height", "1.25");} |
| 240 | |
| 241 | update_option("EWD_US_Version", $EWD_US_Version); |
| 242 | } |
| 243 | |
| 244 | |
| 245 |