PageRenderTime 55ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-ui/wp-ui.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 1150 lines | 704 code | 241 blank | 205 comment | 201 complexity | 84cf4e15ce72570b31fb0a26e1c0db00 MD5 | raw file
  1. <?php
  2. /*
  3. Plugin Name: WP UI - Tabs, accordions and more.
  4. Plugin URI: http://kav.in/wp-ui-for-wordpress
  5. Description: Easily add Tabs, Accordion, Collapsibles to your posts. With 14 fresh Unique CSS3 styles and multiple jQuery UI custom themes.
  6. Author: Kavin
  7. Version: 0.8.5
  8. Author URI: http://kav.in
  9. Copyright (c) 2011 Kavin ( http://kav.in/contact )
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. /*
  23. Script: WP UI for Wordpress
  24. About: Version
  25. 0.8.5
  26. About: License
  27. The PHP files are licensed under GPLv2. Javascript files as specified in their file header ( Or their *.dev.js ). Included scripts come under their respective licenses.
  28. About: Wordpress versions supported.
  29. This version is supported from WordPress 3.1 through 3.4.1.
  30. About: Download
  31. Download the plugin from wordpress Extend, http://wordpress.org/extend/plugins/wp-ui
  32. About: Support
  33. Support
  34. About: Copyright
  35. Copyright 2012 - Kavin
  36. */
  37. define( 'WPUI_VER', '0.8.5' );
  38. // $opts = get_option( 'wpUI_options');
  39. // echo '<pre>';
  40. // print_r( $opts );
  41. // echo '</pre>';
  42. global $wp_ui, $wpui_bleeding;
  43. $wp_ui = new wpUI;
  44. class wpUI {
  45. private $plugin_details,
  46. $options,
  47. $wpuiPosts;
  48. public function __construct() {
  49. $this->wpUI();
  50. } // END fn __construct.
  51. public function wpUI() {
  52. // Register the default options on activation.
  53. register_activation_hook( __FILE__ , array(&$this, 'set_defaults'));
  54. // Get the options.
  55. $this->options = get_option('wpUI_options', array());
  56. // Bleeding edge - Experimental
  57. global $wpui_bleeding;
  58. $wpui_bleeding = ( isset( $this->options[ 'bleeding_edge' ] ) &&
  59. $this->options[ 'bleeding_edge' ] == 'on' ) ?
  60. true : false;
  61. $this->bleeding = $wpui_bleeding;
  62. // Translation.
  63. add_action('init', array(&$this, 'load_plugin_loc'));
  64. // Custom CSS query.
  65. add_filter( 'query_vars', array( &$this, 'wpui_add_query') );
  66. add_action( 'template_redirect', array( &$this, 'wpui_add_queries') );
  67. // Shortcodes.
  68. add_shortcode('wptabs', array(&$this, 'sc_wptabs'));
  69. add_shortcode('wptabposts', array(&$this, 'sc_wptabposts'));
  70. add_shortcode( 'wptabtitle', array(&$this, 'sc_wptabtitle'));
  71. add_shortcode( 'wptabcontent', array(&$this, 'sc_wptabcontent'));
  72. add_shortcode( 'wpspoiler', array(&$this, 'sc_wpspoiler'));
  73. add_shortcode( 'wpdialog', array(&$this, 'sc_wpdialog'));
  74. add_shortcode( 'wploop', array(&$this, 'sc_wpui_loop'));
  75. add_shortcode( 'wpuifeeds', array(&$this, 'sc_wpuifeeds'));
  76. add_shortcode( 'wpuicomp', array( &$this, 'sc_wpuicomp' ) );
  77. add_shortcode( 'wpui_related_posts', array( $this->wpuiPosts, 'insert_related_posts' ) );
  78. // Feeds support.
  79. include_once( ABSPATH . WPINC . '/feed.php' );
  80. // Helpers
  81. include_once( 'inc/wpui-helpers.php' );
  82. /**
  83. * Load scripts and styles.
  84. */
  85. if ( ! is_admin() ) {
  86. add_action('wp_enqueue_scripts', array(&$this, 'plugin_viewer_scripts'), 999);
  87. add_action('wp_print_styles', array(&$this, 'plugin_viewer_styles'), 999 );
  88. }
  89. /**
  90. * Insert the editor buttons and help panels.
  91. */
  92. if ( is_admin() ) include_once( 'inc/wpuimce/wpui_mce.php' );
  93. if ( function_exists( 'gd_info' ) )
  94. include_once( 'inc/class-imager.php' );
  95. /**
  96. * Posts module.
  97. * @todo move into modules dir.
  98. */
  99. include_once( 'inc/class-wpui-posts.php' );
  100. $this->wpuiPosts = new wpuiPosts();
  101. /**
  102. * WP UI options module and the page.
  103. */
  104. if ( is_admin() ) require_once( wpui_dir( 'admin/wpUI-options.php' ));
  105. if ( ! is_admin() ) include_once( wpui_dir( 'inc/wpui-buttons.php' ));
  106. $this->plugin_dir = plugin_dir_path( __FILE__ );
  107. if ( isset( $this->options[ 'enable_widgets' ] ) && $this->options[ 'enable_widgets' ] == 'on' ) {
  108. /* $widVer = ( floatval( get_bloginfo( 'version' ) ) >= 3.3 ) ? '-3.3' : '';*/
  109. include_once( $this->plugin_dir . 'inc/widgets.php' );
  110. }
  111. /**
  112. * Scan and load modules.
  113. */
  114. $this->load_modules();
  115. } //END method wpUI
  116. /**
  117. * Test stuff.
  118. */
  119. public function test_ground() {}
  120. /**
  121. * Load the wpUI text domain.
  122. */
  123. public function load_plugin_loc() {
  124. load_plugin_textdomain( 'wp-ui', false, '/wp-ui/languages/' );
  125. }
  126. public function plugin_viewer_scripts() {
  127. if ( ! $this->get_conditionals() ) return;
  128. $plugin_url = wpui_url();
  129. $js_dir = $plugin_url . '/js/';
  130. if ( ! is_admin()
  131. && ( isset( $this->options['jquery_disabled'] ) ||
  132. $this->options['jquery_disabled'] == 'off' ) ) {
  133. /**
  134. * In case of conflicts, alternate between the below jQuery
  135. * includes and work one out.
  136. */
  137. // wp_deregister_script( 'jquery' );
  138. // // These are local jQuery and jQuery UI, from the plugin dir.
  139. // wp_enqueue_script( 'jquery', $js_dir . 'jquery.min.js' );
  140. // wp_enqueue_script( 'jquery-ui', $js_dir . 'jquery-ui.min.js' );
  141. // // Load from Google CDN.
  142. // wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1');
  143. // wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', false, '1.4.2');
  144. // Let's use Wordpress bundled jQuery.
  145. // wp_enqueue_script( 'jquery' );
  146. // if ( isset( $this->options[ 'jquery_disabled' ] ) ) {
  147. // Will be gradually moved to wordpress bundled UI ( >= 3.3)
  148. wp_deregister_script( 'jquery-ui' );
  149. wp_register_script('jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js', array( 'jquery' ), '1.8.21' );
  150. wp_register_script('jquery-easing', $plugin_url . '/js/jquery.easing.1.3.js', array( 'jquery', 'jquery-ui') );
  151. // }
  152. }
  153. /**
  154. * On demand loading. New feature, use with caution.
  155. */
  156. if ( isset( $this->options[ 'load_scripts_on_demand' ] ) &&
  157. $this->options[ 'load_scripts_on_demand' ] == 'on' ) {
  158. wp_enqueue_script( 'wp-ui-async', wpui_url( 'js/async.js' ), array( 'jquery', 'jquery-ui' ), WPUI_VER );
  159. wp_localize_script( 'wp-ui-async', 'wpUIOpts', $this->get_script_options());
  160. return;
  161. }
  162. if ( $this->bleeding ) {
  163. wp_enqueue_script( 'wp-ui-min', $plugin_url . 'js/wp-ui-old.js', array( 'jquery', 'jquery-ui'), WPUI_VER );
  164. } else {
  165. wp_enqueue_script( 'wp-ui-min', $plugin_url . 'js/wp-ui.js', array( 'jquery', 'jquery-ui'), WPUI_VER );
  166. }
  167. wp_localize_script( 'wp-ui-min', 'wpUIOpts', $this->get_script_options());
  168. }
  169. /**
  170. * Check if scripts/styles can be loaded.
  171. *
  172. * @uses eval
  173. * @return boolean
  174. */
  175. private function get_conditionals() {
  176. $script_needed = true;
  177. if ( isset( $this->options ) &&
  178. ! empty( $this->options[ 'script_conditionals' ] ) ) {
  179. $scrcon = $this->options[ 'script_conditionals' ];
  180. $script_needed = ( stripos( $scrcon , 'return') !== FALSE ) ?
  181. $scrcon :
  182. eval( 'return ' . $scrcon . ';');
  183. }
  184. return $script_needed;
  185. }
  186. /**
  187. * Script options
  188. *
  189. * @todo remove.
  190. * @return array options for javascript
  191. */
  192. public function get_script_options() {
  193. $wpui_opts = array(
  194. 'wpUrl' => get_bloginfo('url'),
  195. 'pluginUrl' => plugins_url('/wp-ui/'),
  196. 'enableTabs' => isset($this->options['enable_tabs']) ? $this->options['enable_tabs'] : '',
  197. 'enableAccordion' => isset($this->options['enable_accordion']) ? $this->options['enable_accordion'] : '',
  198. 'enableSpoilers' => isset($this->options['enable_spoilers']) ? $this->options['enable_spoilers'] : '' ,
  199. 'enableDialogs' => isset($this->options['enable_dialogs']) ? $this->options['enable_dialogs'] : '' ,
  200. // 'enablePagination' => isset($this->options['enable_pagination']) ? $this->options['enable_pagination'] : '' ,
  201. 'tabsEffect' => isset($this->options['tabsfx']) ? $this->options['tabsfx'] : '',
  202. 'effectSpeed' => isset($this->options['fx_speed']) ? $this->options['fx_speed'] : '',
  203. 'accordEffect' => isset($this->options['tabsfx']) ? $this->options['tabsfx'] : '',
  204. 'alwaysRotate' => isset($this->options['tabs_rotate']) ? $this->options['tabs_rotate'] : '',
  205. 'tabsEvent' => isset($this->options['tabs_event']) ? $this->options['tabs_event'] : '',
  206. 'collapsibleTabs' => isset($this->options['collapsible_tabs']) ? $this->options['collapsible_tabs'] : '',
  207. 'accordEvent' => isset($this->options['accord_event']) ? $this->options['accord_event'] : '',
  208. 'topNav' => isset($this->options['topnav']) ? $this->options['topnav'] : '',
  209. 'accordAutoHeight'=> isset($this->options['accord_autoheight']) ? $this->options['accord_autoheight'] : '',
  210. 'accordCollapsible'=> isset($this->options['accord_collapsible']) ? $this->options['accord_collapsible'] : '',
  211. 'accordEasing' => isset( $this->options['accord_easing'] ) ? $this->options['accord_easing'] : '',
  212. 'mouseWheelTabs' => isset( $this->options['mouse_wheel_tabs'] ) ? $this->options['mouse_wheel_tabs'] : '',
  213. 'bottomNav' => isset($this->options['bottomnav']) ? $this->options['bottomnav'] : '',
  214. 'tabPrevText' => isset($this->options['tab_nav_prev_text']) ? $this->options['tab_nav_prev_text'] : '',
  215. 'tabNextText' => isset($this->options['tab_nav_next_text']) ? $this->options['tab_nav_next_text'] : '',
  216. 'spoilerShowText' => isset($this->options['spoiler_show_text']) ? $this->options['spoiler_show_text'] : '',
  217. 'spoilerHideText' => isset($this->options['spoiler_hide_text']) ? $this->options['spoiler_hide_text'] : '',
  218. "cookies" => isset( $this->options['use_cookies'] ) ? $this->options['use_cookies'] : '',
  219. "hashChange" => isset( $this->options['linking_history'] ) ? $this->options['linking_history'] : '',
  220. "docWriteFix" => isset( $this->options['docwrite_fix'] ) ? $this->options['docwrite_fix'] : '',
  221. 'bleeding' => isset( $this->options[ 'bleeding_edge' ] ) ? $this->options[ 'bleeding_edge' ] : 'off',
  222. 'linking_history' => isset( $this->options[ 'linking_history' ] ) ? $this->options[ 'linking_history' ] : 'off',
  223. 'misc_options' => isset( $this->options[ 'misc_options' ] ) ? $this->options[ 'misc_options' ] : 'hello=world'
  224. );
  225. return $wpui_opts;
  226. }
  227. /**
  228. * Output the plugin styles.
  229. */
  230. public function plugin_viewer_styles() {
  231. if ( ! $this->get_conditionals() ) return;
  232. global $is_IE;
  233. $plugin_url = plugins_url('/wp-ui/');
  234. $wpuiCss3List = wpui_get_css3_styles_list();
  235. $jqui_c = wpui_get_custom_themes_list();
  236. $jqui_cs = wpui_get_custom_themes_list( true );
  237. /**
  238. * Look if it's a css3 style, or try to load a jQuery theme.
  239. */
  240. if ( in_array( $this->options[ 'tab_scheme' ] , $wpuiCss3List ) ) {
  241. wp_enqueue_style('wp-ui', $plugin_url . 'wp-ui.css');
  242. wp_enqueue_style($this->options['tab_scheme'], $plugin_url . 'css/' . $this->options['tab_scheme'] . '.css');
  243. } elseif( $jqui_c && in_array( $this->options[ 'tab_scheme' ] , $jqui_c ) ) {
  244. wp_enqueue_style( 'jquery-ui-wp-fix', $plugin_url . 'css/jquery-ui-wp-fix.css' );
  245. wp_enqueue_style( $this->options[ 'tab_scheme' ], $jqui_cs[ $this->options[ 'tab_scheme' ] ] );
  246. } else {
  247. // Sets the standard font size for jQuery UI themes,
  248. // to ensure compat with variety of wordpress themes.
  249. wp_enqueue_style( 'jquery-ui-wp-fix', $plugin_url . 'css/jquery-ui-wp-fix.css' );
  250. // Load the jQuery UI theme from the Google CDN.
  251. wp_enqueue_style( 'jquery-ui-css-' . $this->options['tab_scheme'], 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/' . $this->options['tab_scheme'] . '/jquery.ui.all.css');
  252. // wp_enqueue_style( 'jquery-ui-css-' . $this->options['tab_scheme'], 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/' . $this->options['tab_scheme'] . '/jquery-ui.css' );
  253. }
  254. /**
  255. * Load multiple styles - once that are selected on admin.
  256. */
  257. if ( isset( $this->options[ 'load_all_styles' ] ) &&
  258. isset( $this->options[ 'selected_styles' ] ) &&
  259. $this->options[ 'load_all_styles'] == 'on' ) {
  260. if ( $this->options['selected_styles' ] != '' ) {
  261. $selStylesArr = json_decode( $this->options[ 'selected_styles' ], true );
  262. if ( is_array( $selStylesArr ) ) {
  263. $selQuery = implode( "|" , $selStylesArr );
  264. wp_enqueue_style( 'wpui-multiple' , $plugin_url . 'css/css.php?styles=' . $selQuery );
  265. }
  266. } else {
  267. wp_enqueue_style( 'wp-ui-all' , $plugin_url . 'css/wpui-all.css');
  268. }
  269. }
  270. // if ( $is_IE && $this->options['enable_ie_grad'] )
  271. // wp_enqueue_style( 'wp-tabs-css-bundled-all-IE' , $plugin_url . 'css/wpui-all-ie.css');
  272. /**
  273. * Load jQuery UI custom themes.
  274. */
  275. if ( isset( $this->options['jqui_custom_themes'] ) && $this->options['jqui_custom_themes'] != '' ) {
  276. $jquithms = json_decode( $this->options[ 'jqui_custom_themes'] , true );
  277. foreach( $jquithms as $key=>$val ) {
  278. if ( $key !== $this->options[ 'tab_scheme' ] )
  279. wp_enqueue_style( $key, $val );
  280. }
  281. }
  282. // Try a jQuery UI theme.
  283. // wp_enqueue_style( 'jquery-ui-css-flick' , 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/flick/jquery.ui.all.css');
  284. /**
  285. * Load the additional CSS, if any has been input on the options page.
  286. */
  287. if ( $this->options['custom_css'] != '' )
  288. wp_enqueue_style( 'wpui-custom-css', get_bloginfo( 'url' ) . '/?wpui-css=css');
  289. } // END method plugin_viewer_styles()
  290. /**
  291. * Set the defaults on plugin activation.
  292. */
  293. function set_defaults() {
  294. // First install.
  295. if ( ! $this->options ) {
  296. $defaults = get_wpui_default_options();
  297. update_option( 'wpUI_options', $defaults );
  298. } else {
  299. // Append the new options.
  300. $oldopts = get_option( 'wpUI_options' );
  301. $newdefs = get_wpui_default_options();
  302. foreach ( $newdefs as $def=>$val ) {
  303. // Options not set.
  304. if ( ! isset( $oldopts[ $def ] ) ) {
  305. if ( is_array( $newdefs[ $def ] ) )
  306. $oldopts[ $def ] = array();
  307. $oldopts[ $def ] = $newdefs[ $def ];
  308. }
  309. }
  310. /* $oldopts = array_merge( $oldopts, $newdefs );*/
  311. update_option( 'wpUI_options', $oldopts );
  312. } // End if ( !this->options )
  313. } // END set defaults.
  314. /**
  315. *
  316. * Add the shortcodes.
  317. *
  318. */
  319. /**
  320. * [wptabs] shortcode.
  321. */
  322. function sc_wptabs( $atts, $content = null) {
  323. extract(shortcode_atts(array(
  324. "type" => 'tabs',
  325. 'style' => $this->options['tab_scheme'],
  326. 'effect' => $this->options['tabsfx'],
  327. 'speed' => '600',
  328. // Tabs only options below
  329. 'rotate' => '',
  330. 'position' => 'top',
  331. 'cat' => '',
  332. 'category_name' => '',
  333. 'mode' => 'horizontal',
  334. 'listwidth' => '',
  335. // Accordion only options below
  336. 'active' => false,
  337. 'background' => 'true',
  338. 'engine' => 'ui',
  339. 'autoheight' => 'off',
  340. 'sortable' => 'false'
  341. ), $atts));
  342. $output = '';
  343. $scheme = $style;
  344. static $wpui_tabs_id = 0;
  345. $wpui_tabs_id++;
  346. $jqui_cust = isset( $this->options[ 'jqui_custom_themes' ] ) ? json_decode( $this->options[ 'jqui_custom_themes' ] , true ) : array();
  347. if ( stristr( $style, 'wpui-' ) && ! isset( $jqui_cust[ $scheme ] ) ) {
  348. $style .= ' wpui-styles';
  349. } else {
  350. $style .= ' jqui-styles';
  351. }
  352. if ( $mode == 'vertical' ) {
  353. $style .= ' wpui-tabs-vertical';
  354. }
  355. if ( $listwidth != '' )
  356. $style .= ' listwidth-' . $listwidth;
  357. if ( $background == 'false' )
  358. $style .= ' wpui-no-background';
  359. if ( $autoheight == 'true' )
  360. $style .= ' wpui-autoheight';
  361. if ( $sortable == 'true' )
  362. $style .= ' wpui-sortable';
  363. // Default : tabs. Change type for accordion.
  364. // $class = ($type == 'accordion') ? 'wp-accordion' : 'wp-tabs';
  365. if ( $type == 'accordion' ) {
  366. $class = 'wp-accordion';
  367. if ( $active && $active > 0 ) {
  368. $class .= ' acc-active-' . ( $active - 1 );
  369. }
  370. } else {
  371. $class = ( $this->bleeding && $engine == 'wp-ui' ) ? 'ktabs' : 'wp-tabs';
  372. }
  373. $class .= ' ' . $style;
  374. $class .= ( $rotate == '' ) ? '' : ' tab-rotate-' . $rotate;
  375. $class .= ( $position == 'bottom' ) ? ' tabs-bottom' : '';
  376. $id = ( ( $type == 'accordion' ) ? 'wp-accordion-' : 'wp-tabs-' ) . $wpui_tabs_id;
  377. $output .= '<div id="' . $id . '" class="' . $class . '">' . do_shortcode($content) . '</div><!-- end div.wp-tabs -->';
  378. if ( $engine == 'wp-ui' ) {
  379. $output .= '<script type="text/javascript">';
  380. $output .= 'thisisIT' . $wpui_tabs_id . ' = setInterval( function() { ';
  381. $output .= "if ( typeof(jQuery.fn.ktabs) == 'function' ) {";
  382. $output .= 'jQuery( "#wp-tabs-' . $wpui_tabs_id . '" ).ktabs({ elements : { header : ".wp-tab-title", content : ".wp-tab-content"}, animateSelect : false, mode : "' . $mode . '" ';
  383. $output .= ( $mode == 'vertical' ) ? ', buffer : { height : 40 } ' : '';
  384. $output .= ' });';
  385. $output .= 'clearInterval( thisisIT' . $wpui_tabs_id . ' ); }';
  386. $output .= '}, 300 );';
  387. $output .= '</script>';
  388. }
  389. return $output;
  390. } // END function sc_wptabs.
  391. /**
  392. * Get posts with a custom loop.
  393. */
  394. function sc_wpui_loop( $atts, $content=null )
  395. {
  396. extract( shortcode_atts( array(
  397. 'get' => '',
  398. 'cat' => '',
  399. 'category_name' => '',
  400. 'tag' => '',
  401. 'number' => '4',
  402. 'exclude' => '',
  403. 'elength' => $this->options['excerpt_length'],
  404. 'before_post' => '',
  405. 'after_post' => '',
  406. 'num_per_page' => FALSE,
  407. 'template' => '1'
  408. ), $atts ));
  409. if ( ( ! $cat || $cat == '' ) && ( ! $tag || $tag == '' ) && ( ! $get || $get == '' ) )
  410. return;
  411. if ( $cat != '' ) $tag = '';
  412. // $wquery . '&number=' . $number . '&length=' . $elength
  413. $custom_loop = $this->wpuiPosts->wpui_get_posts( array(
  414. 'cat' => $cat,
  415. 'tag' => $tag,
  416. 'get' => $get,
  417. 'number' => $number,
  418. 'exclude' => $exclude,
  419. 'length' => $elength
  420. ));
  421. $output = '';
  422. if ( ! $custom_loop ) {
  423. return "Please verify <code>[<span>wploop</span>]</code> arguments.";
  424. }
  425. if ( $num_per_page ) {
  426. $output .= '<div class="wpui-pages-holder" />';
  427. $output .= '<div class="wpui-page wpui-page-1">';
  428. $num_page = 1;
  429. }
  430. $ptempl = ( isset( $this->options[ 'post_template_' . $template ] ) ) ?
  431. $this->options[ 'post_template_' . $template ] :
  432. $this->options[ 'post_template_1' ];
  433. $wpui_total_posts = count( $custom_loop );
  434. foreach( $custom_loop as $index=>$item ) {
  435. $posts_passed = $index + 1;
  436. $tmpl = $this->wpuiPosts->replace_tags( $ptempl, $item );
  437. $output .= $before_post . $tmpl . $after_post;
  438. if( $num_per_page
  439. && ( ( $posts_passed % $num_per_page ) == 0 )
  440. && ( $posts_passed != ( $wpui_total_posts ) )
  441. ) {
  442. $num_page++;
  443. $output .= '</div><!-- end div.wpui-page -->';
  444. $output .= '<div class="wpui-page wpui-page-' . $num_page . '">';
  445. }
  446. } // END foreach.
  447. if ( $num_per_page ) {
  448. $output .= '</div><!-- end wpui-page -->';
  449. $output .= '</div><!-- end wpui-pages-holder -->';
  450. }
  451. return $output;
  452. } // END function sc_wpui_loop
  453. /**
  454. * Output tab sets of posts.
  455. * [wptabposts]
  456. *
  457. * @since 0.7
  458. * @param $atts, $content
  459. * @return shortcode handler.
  460. */
  461. function sc_wptabposts( $atts, $content = null )
  462. {
  463. extract( shortcode_atts( array(
  464. 'style' => $this->options[ 'tab_scheme' ],
  465. 'type' => 'tabs',
  466. 'mode' => '',
  467. 'listwidth' => '',
  468. 'tab_names' => 'title',
  469. 'effect' => $this->options['tabsfx'],
  470. 'speed' => '600',
  471. 'get' => '',
  472. 'cat' => '',
  473. 'category_name' => '',
  474. 'tag' => '',
  475. 'post_type' => '',
  476. 'post_status' => 'publish',
  477. 'number' => '4',
  478. 'page' => '',
  479. 'exclude' => '',
  480. 'rotate' => '',
  481. 'elength' => $this->options['excerpt_length'],
  482. 'before_post' => '',
  483. 'after_post' => '',
  484. 'template' => '1'
  485. ), $atts ));
  486. if ( ( ! $cat || $cat == '' ) && ( ! $tag || $tag == '' ) && ( ! $get || $get == '' ) && ( $post_type == '' ))
  487. return;
  488. if ( $cat != '' ) $tag = '';
  489. $my_posts = $this->wpuiPosts->wpui_get_posts( array(
  490. 'cat' => $cat,
  491. 'tag' => $tag,
  492. 'get' => $get,
  493. 'post_type' => $post_type,
  494. 'post_status' => $post_status,
  495. 'number' => $number,
  496. 'exclude' => $exclude,
  497. 'length' => $elength
  498. ));
  499. $tab_names_arr = preg_split( '/\s?,\s?/i', $tab_names );
  500. $output = '';
  501. $each_tabs = '';
  502. if ( ! $my_posts ) {
  503. return "Please verify <code>[<span>wptabposts</span>]</code> arguments.";
  504. }
  505. $ptempl = ( isset( $this->options[ 'post_template_' . $template ] ) ) ?
  506. $this->options[ 'post_template_' . $template ] :
  507. $this->options[ 'post_template_1' ];
  508. foreach( $my_posts as $index=>$item ) {
  509. $tabs_count = $index + 1;
  510. if ( $tab_names == 'title' ) {
  511. $tab_name = $item[ 'title' ];
  512. } elseif ( isset( $tab_names_arr ) && ( count( $tab_names_arr ) > 1 ) ) {
  513. $tab_name = $tab_names_arr[ $index ];
  514. } else {
  515. $tab_name = $tabs_count;
  516. }
  517. $tmpl = $this->wpuiPosts->replace_tags( $ptempl , $item );
  518. $tab_content = $before_post . $tmpl . $after_post;
  519. if ( $item[ 'thumbnail' ] )
  520. $tab_title_args = ' icon="' . htmlspecialchars( $item[ 'thumbnail' ] ) . '"';
  521. $each_tabs .= do_shortcode( '[wptabtitle ' . $tab_title_args . '] ' . $tab_name . ' [/wptabtitle] [wptabcontent] ' . $tab_content . ' [/wptabcontent]' . "\n" );
  522. } // END foreach.
  523. $wptabsargs = '';
  524. if ( $type != '' )
  525. $wptabsargs .= ' type="' . $type . '"';
  526. if ( $mode != '' )
  527. $wptabsargs .= ' mode="' . $mode . '"';
  528. if ( $listwidth != '' )
  529. $style .= ' listwidth-' . $listwidth;
  530. $wptabsargs .= ' style="' . $style . '"';
  531. if ( $rotate && $rotate != '' )
  532. $wptabsargs .= ' rotate="' . $rotate . '"';
  533. if ( $listwidth != '' )
  534. $wptabsargs .= ' listwidth-' . $listwidth;
  535. $output .= do_shortcode( '[wptabs' . $wptabsargs . '] ' . $each_tabs . ' [/wptabs]' );
  536. return $output;
  537. } // END function wptabposts
  538. /**
  539. * [wptabtitle]
  540. */
  541. function sc_wptabtitle( $atts, $content = null ) {
  542. extract(shortcode_atts(array(
  543. 'header' => 'h3',
  544. 'hclass' => 'wp-tab-title',
  545. 'label' => 'text',
  546. 'image_size'=> '24,24',
  547. 'load' => '',
  548. 'post' => '',
  549. 'page' => '',
  550. 'cat' => '',
  551. 'category_name' => '',
  552. 'tag' => '',
  553. 'tag_name' => '',
  554. 'number' => '4',
  555. 'exclude' => '',
  556. 'tag' => '',
  557. 'feed' => '',
  558. 'hide' => "false",
  559. 'elength' => $this->options['excerpt_length'],
  560. 'before_post' => '',
  561. 'after_post' => '',
  562. 'template' => '1',
  563. 'title_template'=> false,
  564. 'icon' => false
  565. ), $atts));
  566. $tmpl = ( isset( $this->options[ 'post_template_' . $template ] ) ) ?
  567. $this->options[ 'post_template_' . $template ] :
  568. $this->options[ 'post_template_1' ];
  569. if ( ! $title_template ) {
  570. $title_template = ( isset( $this->options[ 'title_template' ] ) && $this->options[ 'title_template' ] != '' ) ? $this->options[ 'title_template' ] : '<' . $header . ' class="' . $hclass . '">{$title}</' . $header . '>';
  571. }
  572. if ( $hide == "true" ) $hclass .= ' wpui-hidden-tab';
  573. $data = false;
  574. // Get the post contents.
  575. if ( $post != '' ) {
  576. $data = $this->wpuiPosts->wpui_get_post( $post, $elength );
  577. } elseif ( $page != '' ) {
  578. $data = $this->wpuiPosts->wpui_get_post( $page, $elength );
  579. } elseif ( $feed != '' ) {
  580. $data = $this->wpuiPosts->wpui_get_feeds( array(
  581. 'url' => $feed,
  582. 'number' => $number
  583. ));
  584. } elseif ( $cat != '' || $category_name != '' || $tag != '' || $tag_name != '' ) {
  585. $data = $this->wpuiPosts->wpui_get_posts( array(
  586. 'cat' => $cat,
  587. 'category_name' => $category_name,
  588. 'tag' => $tag,
  589. 'tag_name' => $tag_name,
  590. 'number' => $number,
  591. 'exclude' => $exclude,
  592. 'length' => $elength
  593. ));
  594. }
  595. if ( $load != '' ) {
  596. $content = '<a class="wp-tab-load" href="' . $load . '">' . $content . '</a>';
  597. }
  598. $title_str = str_ireplace( '{$title}', $content, $title_template );
  599. if ( $icon && $icon != '' ) {
  600. $title_str = str_replace( '{$thumbnail}', htmlspecialchars_decode( $icon ), $title_str );
  601. }
  602. if ( is_array( $data ) ) {
  603. if ( isset( $data[ 'title' ] ) ) {
  604. $title_str = $this->wpuiPosts->replace_tags( $title_template, $data );
  605. $data = $before_post . $this->wpuiPosts->replace_tags( $tmpl, $data ) . $after_post;
  606. } else {
  607. $scra = '';
  608. foreach( $data as $index=>$values ) {
  609. $scra .= $this->wpuiPosts->replace_tags( $tmpl, $values );
  610. }
  611. $data = $before_post . $scra . $after_post;
  612. }
  613. }
  614. $title_str = preg_replace( '/\{.*\}/', '', $title_str );
  615. $output = $title_str;
  616. if ( $data ) {
  617. $output .= do_shortcode( "[wptabcontent]" . $data . "[/wptabcontent]" );
  618. }
  619. return $output;
  620. } // END function sc_wptabtitle
  621. /**
  622. * [wptabcontent]
  623. */
  624. function sc_wptabcontent( $atts, $content = null ) {
  625. extract( shortcode_atts( array(
  626. 'class' => ''
  627. ), $atts));
  628. return '<div class="wp-tab-content"><div class="wp-tab-content-wrapper">' . do_shortcode($content) . '</div></div><!-- end div.wp-tab-content -->';
  629. } // END function sc_wptabcontent
  630. /**
  631. * Spoilers/Collapsibles/Sliders.
  632. *
  633. * [wpspoiler name="NAME"]
  634. */
  635. function sc_wpspoiler( $atts, $content = null ) {
  636. extract( shortcode_atts( array(
  637. 'name' => 'Show Content',
  638. 'style' => $this->options['tab_scheme'],
  639. 'fade' => 'true',
  640. 'slide' => 'true',
  641. 'speed' => false,
  642. 'closebtn' => false,
  643. 'showtext' => false,
  644. 'hidetext' => false,
  645. 'open' => 'false',
  646. 'post' => '',
  647. 'page' => '',
  648. 'elength' => $this->options['excerpt_length'],
  649. 'before_post' => '',
  650. 'after_post' => '',
  651. 'template' => '2',
  652. 'background'=> 'true'
  653. ), $atts));
  654. static $wpui_spoiler_id = 0;
  655. $wpui_spoiler_id++;
  656. $scheme = $style;
  657. $style = ( $background != 'true' ) ? $background : $style;
  658. $h3class = '';
  659. $h3class .= ( $fade == 'true' ) ? ' fade-true' : ' fade-false';
  660. $h3class .= ( $slide == 'true' ) ? ' slide-true' : ' slide-false';
  661. $h3class .= ( $open == 'true' ) ? ' open-true' : ' open-false';
  662. $jqui_cust = isset( $this->options[ 'jqui_custom_themes' ] ) ? @json_decode( $this->options[ 'jqui_custom_themes' ] , true ) : array();
  663. if ( stristr( $style, 'wpui-' ) && ! isset( $jqui_cust[ $scheme ] ) ) {
  664. $style .= ' wpui-styles';
  665. } else {
  666. $style .= ' jqui-styles';
  667. }
  668. $h3class .= ( $speed ) ? ' speed-' . $speed : '';
  669. if ( $post != '' || $page != '' ) {
  670. $typew = ( $page != '' ) ? 'page' : 'post';
  671. $piod = ( $page != '' ) ? $page : $post;
  672. $content = '';
  673. $post_content = $this->wpuiPosts->wpui_get_post( $piod, $elength, $typew );
  674. $tmpl = ( isset($this->options[ 'post_template_' . $template ]) ) ?
  675. $this->options[ 'post_template_' . $template ] :
  676. $this->options[ 'post_template_2' ];
  677. $content = $before_post . $this->wpuiPosts->replace_tags( $tmpl, $post_content ) . $after_post;
  678. $name = $post_content[ 'title' ];
  679. }
  680. $out_content = do_shortcode( $content );
  681. if ( $closebtn )
  682. $out_content .= '<a class="close-spoiler ui-button ui-corner-all" href="#">' . $closebtn . '</a>';
  683. $textdata = '';
  684. if ( $showtext )
  685. $textdata .= ' data-showtext="' . $showtext . '"';
  686. if ( $hidetext )
  687. $textdata .= ' data-hidetext="' . $hidetext . '"';
  688. /* return '<div class="wp-spoiler ' . $style . '"><h3 class="ui-collapsible-header' . $h3class . '">' .$name . '</h3><div class="ui-collapsible-content"><div class="ui-collapsible-wrapper">' . $out_content . '</div></div></div><!-- end div.wp-spoiler -->'; */
  689. return '<div id="wp-spoiler-' . $wpui_spoiler_id . '" class="wp-spoiler wpui-hashable ' . $style . '"> <h3 id="' . wpui_get_id( $name ) . '" class="wp-spoiler-title wpui-hashable' . $h3class . '"' . $textdata . '>' .$name . '</h3><div class="wp-spoiler-content">' . $out_content . '</div> </div><!-- end div.wp-spoiler -->';
  690. } // END function sc_wptabcontent
  691. /**
  692. * Dialogs
  693. *
  694. * [wpdialog]Stuff you wanna say[/wpdialog]
  695. */
  696. function sc_wpdialog( $atts, $content = null ) {
  697. extract( shortcode_atts( array(
  698. 'style' => $this->options['tab_scheme'],
  699. 'auto_open' => "true",
  700. 'openlabel' => "Show Information",
  701. 'opener' => 'button',
  702. 'title' => 'Information',
  703. 'height' => 'auto',
  704. 'width' => $this->options[ 'dialog_width' ],
  705. 'show' => 'slide',
  706. 'hide' => 'fade',
  707. 'modal' => 'false',
  708. 'closeOnEscape' => 'true',
  709. 'resizable' => 'true',
  710. 'draggable' => 'true',
  711. 'position' => 'center',
  712. 'zIndex' => false,
  713. 'button' => false,
  714. 'post' => '',
  715. 'elength' => 'more',
  716. 'before_post' => '',
  717. 'after_post' => '',
  718. 'template' => '2'
  719. ), $atts ) );
  720. static $dia_inst = 0;
  721. $dia_inst++;
  722. // $args = '';
  723. $args = array();
  724. $scheme = $style;
  725. $sel_post = $post;
  726. unset( $post );
  727. global $post;
  728. $args[ 'dialogClass' ] = $style;
  729. $args[ 'width' ] = $width;
  730. $args[ 'height' ] = $height;
  731. $args[ 'autoOpen' ] = ($auto_open == 'true' ) ? true : false;
  732. $args[ 'show' ] = $show;
  733. $args[ 'hide' ] = $hide;
  734. $args[ 'modal' ] = ($modal == 'true' ) ? true : false;
  735. $args[ 'resizable' ] = ($resizable == 'true' ) ? true : false;
  736. $args[ 'draggable' ] = ($draggable == 'true' ) ? true : false;
  737. $args[ 'closeOnEscape' ] = ($closeOnEscape == 'true' ) ? true : false;
  738. $args[ 'position' ] = explode( ' ', $position );
  739. if ( $zIndex ) $args[ 'zIndex' ] = $zIndex;
  740. $buttonz = get_post_meta( $post->ID, 'wpui_dialog_' . $dia_inst . '_button', true );
  741. $tmpl = ( isset($this->options[ 'post_template_' . $template ]) ) ?
  742. $this->options[ 'post_template_' . $template ] :
  743. $this->options[ 'post_template_1' ];
  744. if ( $sel_post != '' ) {
  745. $get_post = $this->wpuiPosts->wpui_get_post( $sel_post , $elength );
  746. $title = $get_post[ 'title' ];
  747. $out_content = $before_post . $this->wpuiPosts->replace_tags( $tmpl, $get_post ) . $after_post;
  748. } else {
  749. $out_content = $content;
  750. }
  751. $output = '';
  752. if ( $auto_open == "false" ) {
  753. if ( $opener == 'button' ) {
  754. $output .= do_shortcode( '[wpui_button class="wpui-open-dialog" primary="ui-icon-newwin" url="#" rel="wp-dialog-' . $dia_inst . '" label="' . $openlabel . '"]' );
  755. } else {
  756. $output .= '<a href="#" class="wpui-open-dialog dialog-opener-' . $dia_inst . '" rel="wp-dialog-' . $dia_inst . '">' . $openlabel . '</a>';
  757. }
  758. }
  759. $output .= '<div id="wp-dialog-' . $dia_inst . '" class="wp-dialog wp-dialog-' . $dia_inst . ' ' . $style . '" title="' . $title . '">';
  760. $output .= do_shortcode( $out_content ) . '</div><!-- end .wp-dialog -->';
  761. $output .= '<script type="text/javascript">' . "\n";
  762. $output .= 'thiArgs' . $dia_inst . ' = JSON.parse(\'' . json_encode( $args ) . '\');' . "\n";
  763. if ( $buttonz ) {
  764. $output .= 'thiArgs' . $dia_inst . '.buttons = [' . $buttonz . '];';
  765. }
  766. $output .= 'jQuery(function() {' . "\n";
  767. $output .= 'jQuery( "#wp-dialog-' . $dia_inst . '" ).dialog( thiArgs' . $dia_inst . ' ); });' . "\n";
  768. $output .= 'jQuery(".wpui-open-dialog" ).live( "click", function() {' . "\n";
  769. $output .= 'var tisRel = jQuery( this ).attr( "rel" );' . "\n";
  770. $output .= 'jQuery( "#" + tisRel ).dialog( "open" );' . "\n";
  771. $output .= 'return false;'. "\n";
  772. $output .= '});' . "\n";
  773. $output .= '</script>';
  774. return $output;
  775. } // END method sc_wpdialog
  776. /**
  777. * WP UI Feeds - Parse a feed articles into tabs/accordions.
  778. *
  779. * @return void
  780. * @author Kavin
  781. **/
  782. function sc_wpuifeeds( $atts, $content = null ) {
  783. extract( shortcode_atts( array(
  784. 'url' => '',
  785. 'number' => 3,
  786. 'style' => $this->options[ 'tab_scheme' ],
  787. 'type' => 'tabs',
  788. 'mode' => '',
  789. 'listwidth' => '',
  790. 'tab_names' => 'title',
  791. 'effect' => $this->options['tabsfx'],
  792. 'speed' => '600',
  793. 'number' => '4',
  794. 'rotate' => '',
  795. 'elength' => $this->options['excerpt_length'],
  796. 'before_post' => '',
  797. 'after_post' => '',
  798. 'template' => '1'
  799. ), $atts));
  800. if ( ! $url )
  801. return __( 'WP-UI feeds shortcodes needs a valid RSS URL to work.' , 'wp-ui' );
  802. $results = $this->wpuiPosts->wpui_get_feeds( array(
  803. 'url' => $url,
  804. 'elength' => $elength,
  805. 'number' => $number
  806. ));
  807. if ( ! $results ) return false;
  808. $tab_names_arr = preg_split( '/\s?,\s?/i', $tab_names );
  809. $output = '';
  810. $output_s = '';
  811. $tmpl = ( isset( $this->options[ 'post_template_' . $template ] ) ) ?
  812. $this->options[ 'post_template_' . $template ] :
  813. $this->options[ 'post_template_1' ];
  814. foreach( $results as $index=>$item ) {
  815. $tab_num = $index+ 1;
  816. if ( $tab_names == 'title' ) {
  817. $tab_name = $item[ 'title' ];
  818. } elseif ( isset( $tab_names_arr ) && count( $tab_names_arr ) > 1 ) {
  819. $tab_name = $tab_names_arr[ $index ];
  820. } else {
  821. $tab_name = $tab_num;
  822. }
  823. $tabs_content = $this->wpuiPosts->replace_tags( $tmpl , $item );
  824. $output_s .= do_shortcode( '[wptabtitle]' . $tab_name. '[/wptabtitle] [wptabcontent] ' . $tabs_content . ' [/wptabcontent]' );
  825. }
  826. $wptabsargs = '';
  827. if ( $type != '' )
  828. $wptabsargs .= ' type="' . $type . '"';
  829. if ( $mode != '' )
  830. $wptabsargs .= ' mode="' . $mode . '"';
  831. if ( $listwidth != '' )
  832. $style .= ' listwidth-' . $listwidth;
  833. $wptabsargs .= ' style="' . $style . '"';
  834. if ( $rotate && $rotate != '' )
  835. $wptabsargs .= ' rotate="' . $rotate . '"';
  836. if ( $listwidth != '' )
  837. $style .= ' listwidth-' . $listwidth;
  838. $output .= do_shortcode( '[wptabs' . $wptabsargs . '] ' . $output_s . ' [/wptabs]' );
  839. return $output;
  840. } // END function sc_wptabcontent
  841. /**
  842. * Add the wpui-query GET var
  843. */
  844. function wpui_add_query( $query_vars )
  845. {
  846. $query_vars[] = 'wpui-css';
  847. $query_vars[] = 'wpui-image';
  848. $query_vars[] = 'wpui-tour';
  849. return $query_vars;
  850. } // END function wpui_add_query
  851. /**
  852. * Queue the custom css.
  853. *
  854. * @since 0.5
  855. * @uses get_query_var
  856. */
  857. function wpui_add_queries()
  858. {
  859. $query = get_query_var( 'wpui-css' );
  860. if ( 'css' == $query ) {
  861. // include_once( 'css/css.php');
  862. header( 'Content-type: text/css' );
  863. header( 'Cache-Control: must-revalidate' );
  864. $offset = 72000;
  865. header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 72000) . " GMT");
  866. $opts = get_option( 'wpUi_options' );
  867. echo $opts['custom_css'];
  868. exit; // Dont remove.
  869. }
  870. } // END function wpui_add_queries
  871. /**
  872. * Can the user edit?
  873. */
  874. private function do_edit() {
  875. $cond = false;
  876. if (
  877. ( in_array( basename( $_SERVER['PHP_SELF'] ), array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' ) ) ) &&
  878. ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) )
  879. ) $cond = true;
  880. return $cond;
  881. }
  882. private function load_modules() {
  883. if ( ! is_dir ( wpui_dir( 'modules' ) ) ) return false;
  884. if ( $mod_dir = opendir( wpui_dir( 'modules' ) ) ) {
  885. while ( false != ( $module = readdir( $mod_dir ) ) ) {
  886. if ( 'php' == substr( $module, -3 ) ) {
  887. @include_once( wpui_dir( 'modules/' . $module ) );
  888. }
  889. } // end while.
  890. } // end if mod_dir.
  891. }
  892. } // end class WP_UI
  893. if ( function_exists( 'shortcode_unautop' ) ) {
  894. add_filter( 'the_editor_content', 'shortcode_unautop' );
  895. add_filter( 'the_content', 'shortcode_unautop' );
  896. }
  897. add_filter( 'widget_text', 'do_shortcode');
  898. ?>