Advertisement
Guest User

slider.php

a guest
Sep 30th, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.19 KB | None | 0 0
  1. <?php /** @version $Id: thethe-image-slider.php 1055 2011-10-14 14:56:43Z lexx-ua $ */?>
  2. <?php
  3. /*
  4. Plugin Name: TheThe Image Slider
  5. Plugin URI: http://thethefly.com/wp-plugins/thethe-image-slider/
  6. Description: TheThe Image Slider is a WordPress plug-in that provides you with one of the most powerful, the most creative and the most versatile of image sliders built using jQuery.
  7. Version: 1.1.8
  8. Author: TheThe Fly
  9. Author URI: http://thethefly.com
  10. License: GNU GPL v2
  11. */
  12. $TheTheIS = array(
  13. 'wp_plugin_dir' => dirname(__FILE__),
  14. 'wp_plugin_dir_url' => WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)),
  15. 'wp_plugin_base_name' => plugin_basename(__FILE__),
  16. 'wp_plugin_name' => 'TheThe Image Slider',
  17. 'wp_plugin_version' => '1.1.8'
  18. );
  19.  
  20. if (is_admin()) {
  21. include('inc/inc.functions.php');
  22. include('inc/inc.boxes.php');
  23. require_once('thethe-actions.php');
  24. require_once $TheTheIS['wp_plugin_dir'] . '/thethe-admin.php';
  25. add_filter('admin_menu','TheTheIS_Menu');
  26. }else{
  27. include('inc/inc.boxes.php');
  28. }
  29.  
  30. add_action('init', 'thethe_image_slider_init');
  31.  
  32. define('THETHE_IMAGE_SLIDER_URL', plugin_dir_url(__FILE__));
  33.  
  34. function thethe_image_slider_head_scripts(){
  35. wp_deregister_script( 'jquery' );
  36. wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', false, '1.6.4');
  37. wp_enqueue_script( 'jquery' );
  38.  
  39. wp_enqueue_script('slider-ui', THETHE_IMAGE_SLIDER_URL.'style/js/thethe-image-slider.js', array('jquery'));
  40. }
  41.  
  42. function thethe_image_slider_init(){
  43. if(is_admin()){
  44. post_type_slider();
  45.  
  46. $bUpdate = false;
  47. if(isset($_POST['submit'])){
  48. switch ($_POST['action']) {
  49. case 'savecustomcss':
  50. $bUpdate = _thethe_image_slider_save_customcss();
  51. break;
  52. case 'editslider':
  53. $bUpdate = _thethe_image_slider_edit();
  54. $_GET['_view'] = 'editslider';
  55. $_GET['id'] = $_POST['id'];
  56. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  57. $_GET['_view'] = 'addnewslide';
  58. } else if (isset($_POST['submit']['save_and_exit'])) {
  59. $_GET['_view'] = 'sliders';
  60. }
  61. break;
  62. case 'editslide':
  63. $bUpdate = _thethe_image_slider_slide_edit();
  64. $_GET['_view'] = 'editslide';
  65. $_GET['sid'] = $_POST['sid'];
  66. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  67. $_GET['_view'] = 'addnewslide';
  68. } else if (isset($_POST['submit']['save_and_exit'])) {
  69. $_GET['_view'] = 'sliders';
  70. $_POST['id'] = '';
  71. $_POST['sid'] = '';
  72. }
  73. break;
  74. case 'reorderslides':
  75. $bUpdate = _thethe_image_slider_reorder();
  76. if (isset($_POST['ajax'])){
  77. die();
  78. }
  79. break;
  80. case 'createslider':
  81. if (_thethe_image_slider_isExists($_POST['_slider_name'])) {
  82. global $_thethe_image_slider_error_msg;
  83. $_thethe_image_slider_error_msg = 'Slider name ['.$_POST['_slider_name'].'] already exists!';
  84. } else {
  85. $post_id = _thethe_image_slider_add();
  86. if ($post_id){
  87. $_GET['_view'] = 'editslider';
  88.  
  89. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  90. $_GET['_view'] = 'addnewslide';
  91. $_GET['id'] = $post_id;
  92. $_GET['added'] = true;
  93. $bUpdate = true;
  94. } else if (isset($_POST['submit']['save_and_exit'])) {
  95. $_GET['_view'] = 'sliders';
  96. } else {
  97. $_GET['id'] = $post_id;
  98. $_GET['added'] = true;
  99. $bUpdate = true;
  100. }
  101. }
  102. }
  103. break;
  104. case 'addnewslide':
  105. $slide_id = _thethe_image_slider_slide_add();
  106. if ($slide_id !== false){
  107. $_GET['_view'] = 'editslide';
  108. $_GET['sid'] = $slide_id;
  109. $_GET['added'] = true;
  110. $bUpdate = true;
  111. }
  112. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  113. $_GET['_view'] = 'addnewslide';
  114. $_GET['id'] = $_REQUEST['id'];
  115. } else if (isset($_POST['submit']['save_and_exit'])) {
  116. $_GET['_view'] = 'sliders';
  117. }
  118. break;
  119. }
  120. }elseif (isset($_POST['reset'])){
  121. switch ($_POST['action']) {
  122. case 'editslider':
  123. $bUpdate = _thethe_image_slider_edit(true);
  124. $_GET['_view'] = 'editslider';
  125. $_GET['id'] = $_POST['id'];
  126. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  127. $_GET['_view'] = 'addnewslide';
  128. } else if (isset($_POST['submit']['save_and_exit'])) {
  129. $_GET['_view'] = 'sliders';
  130. }
  131. break;
  132. case 'editslide':
  133. $bUpdate = _thethe_image_slider_slide_edit(true);
  134. $_GET['_view'] = 'editslide';
  135. $_GET['sid'] = $_POST['sid'];
  136. if (isset($_POST['submit']['save_and_add_new_slide'])) {
  137. $_GET['_view'] = 'addnewslide';
  138. } else if (isset($_POST['submit']['save_and_exit'])) {
  139. $_GET['_view'] = 'sliders';
  140. }
  141. break;
  142. case 'savecustomcss':
  143. $bUpdate = _thethe_image_slider_save_customcss(true);
  144. break;
  145. }
  146. }else{
  147. if (isset($_GET['view']) && ($_GET['view'] == 'deleteslider')){
  148. $bUpdate = _thethe_image_slider_delete();
  149. }
  150. if (isset($_POST['action']) && $_POST['action'] == 'meta-box-order' && isset($_POST['page']) && $_POST['page'] == 'thethe-image-slider'){
  151. _thethe_image_slider_slides_order();
  152. }
  153. }
  154. $_GET['update'] = $bUpdate;
  155.  
  156. }else{
  157. add_action('wp_print_scripts', "thethe_image_slider_head_scripts");
  158.  
  159. wp_enqueue_style('slider-ui', THETHE_IMAGE_SLIDER_URL.'style/css/thethe-image-slider.css', false, false, 'screen');
  160. add_filter( 'wp_head', '_thethe_image_slider_add_customcss');
  161. }
  162. }
  163.  
  164. function _thethe_image_slider_add_customcss(){
  165. if(get_option('thethe-image-slider-enable-customcss') && get_option('thethe-image-slider-customcss')) {
  166. echo '<!-- TheThe Image Slider v.' . $TheTheIS['wp_plugin_version'] . ' Custom CSS begin //-->' . chr(10);
  167. echo '<style type="text/css" media="screen">' . chr(10);
  168. echo stripslashes_deep(get_option('thethe-image-slider-customcss')) . chr(10);
  169. echo '</style>' . chr(10);
  170. echo '<!-- TheThe Image Slider Custom CSS end //-->' . chr(10);
  171. }
  172. }
  173.  
  174. function post_type_slider() {
  175. register_post_type( 'thethe-slider',
  176. array(
  177. 'labels' => array(
  178. 'name' => _x('TheThe Sliders', 'post type general name'),
  179. 'singular_name' => _x('TheThe Slider', 'post type singular name'),
  180. 'add_new' => _x('Add New TheThe Slider', 'book'),
  181. 'add_new_item' => __('Add New TheThe Slider'),
  182. 'edit_item' => __('Edit TheThe Slider'),
  183. 'new_item' => __('New TheThe Slider'),
  184. 'view_item' => __('View TheThe Slider'),
  185. 'search_items' => __('Search TheThe Sliders'),
  186. 'not_found' => __('No TheThe Sliders Found'),
  187. 'not_found_in_trash' => __('No TheThe Sliders found in Trash'),
  188. 'parent_item_colon' => '',
  189. 'menu_name' => 'Sliders'
  190. ),
  191. 'public' => true,
  192. 'show_ui' => false,
  193. 'register_meta_box_cb' => 'init_metaboxes_thethe_slider',
  194. '_builtin' => false, // It's a custom post type, not built in!
  195. '_edit_link' => 'post.php?post=%d',
  196. 'capability_type' => 'post',
  197. 'hierarchical' => false,
  198. 'rewrite' => array("slug" => "thethe-slider"), // Permalinks format
  199. 'supports' => array('')
  200. )
  201. );
  202. register_taxonomy_for_object_type('thethe-slider', 'thethe-slider');
  203. }
  204.  
  205. add_shortcode('thethe-image-slider', 'thethe_image_slider_shortcode');
  206. function thethe_image_slider_shortcode($atts, $content = null)
  207. {
  208. extract(shortcode_atts(array(
  209. 'name' => 'thethe-image-slider'
  210. ), $atts));
  211. return get_thethe_image_slider($name);
  212. }
  213. add_shortcode('thethe_image_slider', 'thethe_image_slider_shortcode2');
  214. function thethe_image_slider_shortcode2($atts, $content = null)
  215. {
  216. extract(shortcode_atts(array(
  217. 'name' => 'thethe_image_slider'
  218. ), $atts));
  219. return get_thethe_image_slider($name);
  220. }
  221. function thethe_get_image_path($src) {
  222. //Call the WordPress Network blog Id Numeral
  223. global $blog_id;
  224.  
  225. // if it's there and greater than 0
  226. if($blog_id && $blog_id > 0) {
  227.  
  228. // Take the presented source file and break apart the query string to get the specific file name
  229. $imageParts = explode('/files/' , $src);
  230. if($imageParts[1]) {
  231.  
  232. // Assemble the new query string using a Network-Friendly format
  233. $src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
  234. }
  235. }
  236. return $src;
  237. }
  238.  
  239. function get_thethe_image_slider($name){
  240. global $g_arrBoxes;
  241. $nPostID = 0;
  242. $second_query = new WP_Query( 'name=' . sanitize_title($name) .'&post_type=thethe-slider');
  243. // The Loop
  244. while( $second_query->have_posts() ){
  245. $second_query->the_post();
  246. $nPostID = get_the_ID();
  247. }
  248. wp_reset_postdata();
  249. if (empty($nPostID)){
  250. return false;
  251. }
  252. $oPost = get_post($nPostID);
  253. $arrOptions = array();
  254. foreach ( $g_arrBoxes as $box ) {
  255. if ($box['type'] == 'select' && !isset($box['keyvalue'])){
  256. if ($box['name'] != '_slider_paginator_type' && $box['name'] != '_slider_paginator_position'){
  257. $arrOptions[$box['name']] = $box['values'][get_post_meta($oPost->ID, $box['name'], true)];
  258. }else{
  259. $arrOptions[$box['name']] = get_post_meta($oPost->ID, $box['name'], true);
  260. }
  261. }else{
  262. $arrOptions[$box['name']] = get_post_meta($oPost->ID, $box['name'], true);
  263. }
  264. }
  265. $strSlides = get_post_meta($oPost->ID, 'slides', true);
  266. $arrSlides = (is_array($arrSlides = @unserialize($strSlides))) ? $arrSlides : array();
  267. $output = '';
  268.  
  269. $output .= '<div class="thethe_image_slider '.$arrOptions['_slider_style'].'" id="thethe_image_slider'.$oPost->ID.'" style="width:'.$arrOptions['_slider_width'].'px;">';
  270.  
  271. $output .= '<div class="thethe_image_slider_inner" style="width:'.$arrOptions['_slider_width'].'px; height:'.$arrOptions['_slider_height'].'px;">';
  272. $output .= '<div class="thethe-image-slider-settings">';
  273. $output .= '<span class="width">'.$arrOptions['_slider_width'].'</span>';
  274. $slider_loop = $arrOptions['_slider_loop']?'true':'false';
  275. $output .= '<span class="loop">'.$slider_loop.'</span>
  276. <span class="pagginator_type">'.$arrOptions['_slider_paginator_type'].'</span>
  277. <span class="pagginator_position">'.$arrOptions['_slider_paginator_position'].'</span>
  278. <span class="height">'.$arrOptions['_slider_height'].'</span>';
  279. $slider_autoplay = $arrOptions['_slider_autoplay']?'true':'false';
  280. $slider_autoresize = $arrOptions['_slider_autoresize']?'true':'false';
  281. $output .= '<span class="autoplay">'.$slider_autoplay.'</span>
  282. <span class="autoresize">'.$slider_autoresize.'</span>
  283. <span class="trans-time">'.$arrOptions['_slider_trans_time'].'</span>';
  284. $slider_style = ($arrOptions['_slider_style'] == 'none') ? 'none' : THETHE_IMAGE_SLIDER_URL.'style/skins/'.$arrOptions['_slider_style'];
  285. $output .= '<span class="skin">'.$slider_style.'</span>
  286. </div>
  287. <div class="thethe-image-slider-loader"><div class="thethe-image-slider-progress"></div></div>';
  288.  
  289. $output .= '<ul class="thethe-image-slider-slides">';
  290. foreach ($arrSlides as $i => $slide){
  291. $output .='<li>';
  292. $slide_caption = $slide['slide_caption']?'true':'false';
  293. $output .=' <div class="thethe-image-slider-slide-settings">
  294. <span class="time">'.$slide['delay'].'</span>
  295. <span class="transition">'.$slide['transition'].'</span>
  296. <span class="slide_caption">'.$slide_caption.'</span>
  297. <span class="caption-size">'.$slide['caption_size'].'</span>
  298. <span class="caption-position">'.$slide['caption_position'].'</span>
  299. <span class="caption_opacity">'.$slide['caption_opacity'].'</span>
  300. <span class="link">'.$slide['url'].'</span>
  301. </div>';
  302. if ($arrOptions['_slider_autoresize']){
  303. $image_src = $slide['image'] ? thethe_get_image_path( $slide['image'] ) : THETHE_IMAGE_SLIDER_URL.'style/images/blank.gif';
  304. $output .='<img src="'.THETHE_IMAGE_SLIDER_URL . 'timthumb.php?w='.$arrOptions['_slider_width'].'&amp;h='.$arrOptions['_slider_height'].'&amp;zc=1&amp;src='.urlencode($image_src).'" alt="'.$slide['title'].'" class="thethe-image-slider-image"/>';
  305. }else{
  306. $image_src = $slide['image'] ? $slide['image'] : THETHE_IMAGE_SLIDER_URL.'style/images/blank.gif';
  307.  
  308. $output .='<img src="'.$image_src.'" alt="'.$slide['title'].'" class="thethe-image-slider-image"/>';
  309. }
  310. $url = str_ireplace(array('http://','https://'), '', $slide['url']);
  311. $output .= $url ? '<a class="slide-link" href="http://'.$url.'" title="'.$slide['title'].'">&nbsp;</a>' : '';
  312. if ($slide['slide_caption']){
  313. $slideCaptionBgColor = $slide['caption_bg_color'] ? 'style="background:'.$slide['caption_bg_color'].';"' : '';
  314. $slideCaptionTextColor = $slide['caption_text_color'] ? 'style="color:'.$slide['caption_text_color'].';"' : '';
  315. $output .='
  316. <div class="thethe-image-slider-caption thethe-image-slider-caption-'.$slide['caption_position'].' thethe-image-slider-caption-bg thethe-image-slider-caption-'.$slide['caption_style'].'" '.$slideCaptionBgColor.'></div>
  317. <div class="thethe-image-slider-caption front thethe-image-slider-caption-'.$slide['caption_position'].' thethe-image-slider-caption-'.$slide['caption_style'].'">
  318.  
  319. <div class="thethe-image-slider-caption-inner" '.$slideCaptionTextColor.'>
  320. <div class="thethe-image-slider-caption-text">';
  321. $output .= $slide['text'];
  322. $output .='</div>
  323. </div>
  324. </div>';
  325. }
  326. $output .='</li>';
  327. }
  328. $output .= '</ul>';
  329. if ($arrOptions['_slider_controls']){
  330. $output .= '<div class="thethe-image-slider-controls-prev thethe-previous thethe-image-slider-controls" id="thethe_image_slider'.$oPost->ID.'-previous"></div>
  331. <div class="thethe-image-slider-controls-pause thethe-image-slider-controls thethe-';
  332. $output .=$arrOptions['_slider_autoplay'] ? 'pause' : 'play';
  333. $output .='" id="thethe_image_slider'.$oPost->ID.'-pause"></div>
  334. <div class="thethe-image-slider-controls-next thethe-image-slider-controls thethe-next" id="thethe_image_slider'.$oPost->ID.'-next"></div>';
  335. }
  336. $output .= '</div>';
  337. if ($arrOptions['_slider_paginator']){
  338. $output .= '<div class="thethe-image-slider-thumbnails thethe-image-slider-thumbnails-'.$arrOptions['_slider_paginator_type'].' thethe-image-slider-thumbnails'.$arrOptions['_slider_paginator_position'].'">';
  339. foreach ($arrSlides as $i => $slide){
  340. $output .= '<div class="thethe-image-slider-thumbnails-thumb">';
  341. if ($arrOptions['_slider_paginator_type'] == 'thumbnails'){
  342. $image_src = thethe_get_image_path( $slide['image'] );
  343. $output .= '<div class="thumbnail-img" style="background-image:url('.THETHE_IMAGE_SLIDER_URL. 'timthumb.php?w=227&amp;h=137&amp;zc=1&amp;src='.urlencode($image_src).')" >&nbsp;</div>';
  344. }elseif ($arrOptions['_slider_paginator_type'] == 'numbers'){
  345. $output .= $i+1;
  346. }elseif ($arrOptions['_slider_paginator_type'] == 'slidenames'){
  347. $output .= $slide['title'];
  348. }elseif ($arrOptions['_slider_paginator_type'] == 'dots'){
  349. }
  350. $output .='</div>';
  351. }
  352. $output .= '</div>';
  353. }
  354. if ($arrOptions['_slider_backlink']){
  355. $output .= '<a class="thethe-backlink" href="http://thethefly.com/wp-plugins/thethe-image-slider/" title="Powered by TheThe Image Slider WordPress Plugin" target="_blank">?</a>';
  356. }
  357. $output .='</div>';
  358. return $output;
  359. }
  360.  
  361.  
  362. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement