PageRenderTime 48ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/social-media-tabs/inc/dcwp_widget.php

https://github.com/ActivateNY/activateny.org
PHP | 850 lines | 716 code | 116 blank | 18 comment | 95 complexity | 770c25fdc4f749467042292cfe5b0115 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. class dc_jqsocialmediatabs_widget extends WP_Widget {
  3. /** constructor */
  4. function dc_jqsocialmediatabs_widget() {
  5. $name = 'Social Media Tabs';
  6. $desc = 'Sliding social media profile tabs - Facebook, Google, Twitter, YouTube & RSS Feeds';
  7. $id_base = 'dc_jqsocialmediatabs_widget';
  8. $css_class = 'dcsmt_widget';
  9. $alt_option = 'widget_dcjq_social_media_tabs';
  10. $def_tabs = 'facebook,twitter,plusone,rss,youtube,flickr,pinterest';
  11. $widget_ops = array(
  12. 'classname' => $css_class,
  13. 'description' => __( $desc, 'dcjq-social-tabs' ),
  14. );
  15. $this->WP_Widget($id_base, __($name, 'dcjqsocialtabs'), $widget_ops);
  16. $this->alt_option_name = $alt_option;
  17. add_action( 'wp_head', array(&$this, 'styles'), 10, 1 );
  18. add_action( 'wp_footer', array(&$this, 'footer'), 10, 1 );
  19. add_action('init', array(&$this, 'my_init_method'));
  20. $options = get_option('dcsmt_options');
  21. $this->defaults = array(
  22. 'method' => 'slide',
  23. 'direction' => 'horizontal',
  24. 'width' => 260,
  25. 'height' => 290,
  26. 'speedMenu' => 600,
  27. 'position' => 'right',
  28. 'offset' => 50,
  29. 'autoClose' => '1',
  30. 'start' => 0,
  31. 'facebookId' => '',
  32. 'facebook_width' => 240,
  33. 'facebook_height' => 270,
  34. 'facebook_connections' => 8,
  35. 'googleId' => '',
  36. 'nBuzz' => 5,
  37. 'rssId' => '',
  38. 'nRss' => 5,
  39. 'nPinterest' => 5,
  40. 'nFlickr' => 12,
  41. 'pinterest_follow' => '',
  42. 'youtubeId' => '',
  43. 'videoId' => '',
  44. 'pinterestId' => '',
  45. 'flickrId' => '',
  46. 'custom' => '',
  47. 'tab1' => 'facebook',
  48. 'tab2' => 'twitter',
  49. 'tab3' => 'plusone',
  50. 'tab4' => 'rss',
  51. 'tab5' => 'youtube',
  52. 'tab6' => 'none',
  53. 'tab7' => 'none',
  54. 'tab8' => 'none'
  55. );
  56. }
  57. function my_init_method(){
  58. if ( version_compare( get_bloginfo( 'version' ) , '3.0' , '<' ) && is_ssl() ) {
  59. $wp_content_url = str_replace( 'http://' , 'https://' , get_option( 'siteurl' ) );
  60. } else {
  61. $wp_content_url = get_option( 'siteurl' );
  62. }
  63. $wp_content_url .= '/wp-content';
  64. $wp_plugin_url = $wp_content_url . '/plugins';
  65. wp_register_style('dcwp_plugin_admin_dcsmt_css', $wp_plugin_url .'/social-media-tabs/css/admin.css');
  66. wp_enqueue_style('dcwp_plugin_admin_dcsmt_css');
  67. }
  68. function widget($args, $instance){
  69. extract( $args );
  70. $widget_options = wp_parse_args( $instance, $this->defaults );
  71. extract( $widget_options, EXTR_SKIP );
  72. $options = get_option('dcsmt_options');
  73. $cache = $options['cache'] != '' ? $options['cache'] * 60 : '' ;
  74. $plugin_url = dc_jqsocialmediatabs::get_plugin_directory();
  75. $icon_url = $plugin_url.'/css/images/';
  76. $check = '';
  77. $dcsmt_nav = '';
  78. $dcsmt_tabs = '';
  79. $i = 0;
  80. $deftabs = explode(',','facebook,twitter,plusone,rss,youtube,flickr,pinterest,extra,custom');
  81. foreach($deftabs as $k=>$tabv){
  82. if($tabv != ''){
  83. $k = $k+1;
  84. $tab = $widget_options['tab'.$k];
  85. if($tab != 'none' && $tab != ''){
  86. $checkTab = strlen(strstr($check,$tab)) > 0 ? 1 : 0 ;
  87. if($checkTab == 0){
  88. $class = $i == 0 ? 'first ' : '' ;
  89. $icon = $options['icon_'.$tab] == '' ? '<img src="'.$icon_url.$tab.'.png" alt="" />' : '<img src="'.$options['icon_'.$tab].'" alt="" />';
  90. $f_tab = 'dcsmt_inc_'.$tab;
  91. if($cache != '')
  92. {
  93. $x1 = implode('-',$args);
  94. $x2 = implode('-',$instance);
  95. $cache_key = $f_tab . '_' . md5($x1.$x2);
  96. $tabContent = get_transient( $cache_key );
  97. // if no cached results
  98. if ( false === ( $tabContent = get_transient( $cache_key ) ) ) {
  99. $tabContent = $this->$f_tab($args, $instance);
  100. set_transient( $cache_key, $tabContent, $cache );
  101. }
  102. }
  103. else
  104. {
  105. $tabContent = $this->$f_tab($args, $instance);
  106. }
  107. $dcsmt_nav .= '<li class="'.$class.'dcsmt-'.$tab.'"><a href="#" rel="'.$i.'">'.$icon.'</a></li>';
  108. $dcsmt_tabs .= '<li class="tab-content '.$this->id.'-tab">'.$tabContent.'</li>';
  109. $i++;
  110. $check .= ','.$tab;
  111. }
  112. }
  113. }
  114. }
  115. ?>
  116. <div id="<?php echo $this->id.'-item'; ?>">
  117. <ul class="social-tabs">
  118. <?php echo $dcsmt_nav; ?>
  119. </ul>
  120. <ul class="dcsmt <?php echo $this->id.'-slide'; ?>">
  121. <?php echo $dcsmt_tabs; ?>
  122. </ul>
  123. </div>
  124. <?php
  125. }
  126. /** @see WP_Widget::update */
  127. function update( $new_instance, $old_instance ) {
  128. $instance['method'] = $new_instance['method'];
  129. $instance['direction'] = $new_instance['direction'];
  130. $instance['width'] = (int) strip_tags( stripslashes($new_instance['width']) );
  131. $instance['height'] = (int) strip_tags( stripslashes($new_instance['height']) );
  132. $instance['speedMenu'] = (int) strip_tags( stripslashes($new_instance['speedMenu']) );
  133. $instance['position'] = $new_instance['position'];
  134. $instance['offset'] = (int) strip_tags( stripslashes($new_instance['offset']) );
  135. $instance['skin'] = $new_instance['skin'];
  136. $instance['autoClose'] = $new_instance['autoClose'];
  137. $instance['loadOpen'] = $new_instance['loadOpen'];
  138. $instance['facebookId'] = strip_tags( stripslashes($new_instance['facebookId']) );
  139. $instance['facebook_width'] = (int) strip_tags( stripslashes($new_instance['facebook_width']) );
  140. $instance['facebook_height'] = (int) strip_tags( stripslashes($new_instance['facebook_height']) );
  141. $instance['facebook_connections'] = (int) strip_tags( stripslashes($new_instance['facebook_connections']) );
  142. $instance['googleId'] = strip_tags( stripslashes($new_instance['googleId']) );
  143. $instance['nBuzz'] = (int) strip_tags( stripslashes($new_instance['nBuzz']) );
  144. $instance['rssId'] = strip_tags( stripslashes($new_instance['rssId']) );
  145. $instance['nRss'] = (int) strip_tags( stripslashes($new_instance['nRss']) );
  146. $instance['rssTitle'] = strip_tags( stripslashes($new_instance['rssTitle']) );
  147. $instance['twitterUrl'] = strip_tags( stripslashes($new_instance['twitterUrl']) );
  148. $instance['twitterWidget'] = strip_tags( stripslashes($new_instance['twitterWidget']) );
  149. $instance['youtubeId'] = strip_tags( stripslashes($new_instance['youtubeId']) );
  150. $instance['videoId'] = strip_tags( stripslashes($new_instance['videoId']) );
  151. $instance['pinterestId'] = strip_tags( stripslashes($new_instance['pinterestId']) );
  152. $instance['pinterestTitle'] = strip_tags( stripslashes($new_instance['pinterestTitle']) );
  153. $instance['nPinterest'] = strip_tags( stripslashes($new_instance['nPinterest']) );
  154. $instance['pinterest_follow'] = strip_tags( stripslashes($new_instance['pinterest_follow']) );
  155. $instance['flickrId'] = strip_tags( stripslashes($new_instance['flickrId']) );
  156. $instance['flickrTitle'] = strip_tags( stripslashes($new_instance['flickrTitle']) );
  157. $instance['nFlickr'] = strip_tags( stripslashes($new_instance['nFlickr']) );
  158. $instance['custom'] = strip_tags( stripslashes($new_instance['custom']) );
  159. $instance['customTitle'] = strip_tags( stripslashes($new_instance['customTitle']) );
  160. $deftabs = explode(',','facebook,twitter,plusone,rss,youtube,flickr,pinterest,custom');
  161. foreach($deftabs as $k=>$tabv){
  162. if($tabv != ''){
  163. $k = $k+1;
  164. $instance['tab'.$k] = strip_tags( stripslashes($new_instance['tab'.$k]) );
  165. }
  166. }
  167. $instance['start'] = strip_tags( stripslashes($new_instance['start']) );
  168. return $instance;
  169. }
  170. /** @see WP_Widget::form */
  171. function form($instance) {
  172. $widget_options = wp_parse_args( $instance, $this->defaults );
  173. extract( $widget_options, EXTR_SKIP );
  174. // Get default values
  175. settings_fields('dcsmt_options_group'); $options = get_option('dcsmt_options');
  176. $nRss = isset( $instance['nRss'] ) ? $instance['nRss'] : '5';
  177. $twitterUrl = isset( $instance['twitterUrl'] ) ? $instance['twitterUrl'] : '';
  178. $nBuzz = isset( $instance['nBuzz'] ) ? $instance['nBuzz'] : '5';
  179. $nPinterest = isset( $instance['nPinterest'] ) ? $instance['nPinterest'] : '5';
  180. $pinterest_follow = isset( $instance['pinterest_follow'] ) ? $instance['pinterest_follow'] : '';
  181. $nFlickr = isset( $instance['nFlickr'] ) ? $instance['nFlickr'] : '12';
  182. $method = isset( $instance['method'] ) ? $instance['method'] : 'static';
  183. $direction = isset( $instance['direction'] ) ? $instance['direction'] : 'horizontal';
  184. $start = isset( $instance['start'] ) ? $instance['start'] : '0';
  185. ?>
  186. <p>
  187. <label for="<?php echo $this->get_field_id('method1'); ?>"><?php _e('Tabs:') ?></label>
  188. <input type="radio" id="<?php echo $this->get_field_id('method1'); ?>" name="<?php echo $this->get_field_name('method'); ?>" value="slide"<?php checked( $method, 'slide' ); ?> class="method-slide" />
  189. <label for="<?php echo $this->get_field_id('method1'); ?>"><?php _e( 'Slide Out' , 'dcjq-social-tabs' ); ?></label>
  190. <input type="radio" id="<?php echo $this->get_field_id('method2'); ?>" name="<?php echo $this->get_field_name('method'); ?>" value="static"<?php checked( $method, 'static' ); ?> class="method-static" />
  191. <label for="<?php echo $this->get_field_id('method2'); ?>"><?php _e( 'Static' , 'dcjq-social-tabs' ); ?></label>
  192. </p>
  193. <p>
  194. <label for="<?php echo $this->get_field_id('direction1'); ?>"><?php _e('Slider:') ?></label>
  195. <input type="radio" id="<?php echo $this->get_field_id('direction1'); ?>" name="<?php echo $this->get_field_name('direction'); ?>" value="horizontal"<?php checked( $direction, 'horizontal' ); ?> />
  196. <label for="<?php echo $this->get_field_id('direction1'); ?>"><?php _e( 'Horizontal' , 'dcjq-social-tabs' ); ?></label>
  197. <input type="radio" id="<?php echo $this->get_field_id('direction2'); ?>" name="<?php echo $this->get_field_name('direction'); ?>" value="vertical"<?php checked( $direction, 'vertical' ); ?> />
  198. <label for="<?php echo $this->get_field_id('direction2'); ?>"><?php _e( 'Vertical' , 'dcjq-social-tabs' ); ?></label>
  199. </p>
  200. <p class="dcwp-row">
  201. Width:
  202. <input type="text" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $widget_options['width']; ?>" size="4" />
  203. Height:
  204. <input type="text" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" value="<?php echo $widget_options['height']; ?>" size="4" />
  205. </p>
  206. <p class="dcwp-row">
  207. <label for="<?php echo $this->get_field_id('position'); ?>"><?php _e( 'Location' , 'dcjq-social-tabs' ); ?></label>
  208. <select name="<?php echo $this->get_field_name('position'); ?>" id="<?php echo $this->get_field_id('position'); ?>" >
  209. <option value='top-left' <?php selected( $widget_options['position'], 'top-left'); ?> >Top Left</option>
  210. <option value='top-right' <?php selected( $widget_options['position'], 'top-right'); ?> >Top Right</option>
  211. <option value='bottom-left' <?php selected( $widget_options['position'], 'bottom-left'); ?> >Bottom Left</option>
  212. <option value='bottom-right' <?php selected( $widget_options['position'], 'bottom-right'); ?> >Bottom Right</option>
  213. <option value='left' <?php selected( $widget_options['position'], 'left'); ?> >Left</option>
  214. <option value='right' <?php selected( $widget_options['position'], 'right'); ?> >Right</option>
  215. </select>
  216. </p>
  217. <p class="dcwp-row">
  218. <label for="<?php echo $this->get_field_id('offset'); ?>"><?php _e( 'Offset:' , 'dcjq-social-tabs' ); ?></label>
  219. <input type="text" id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" value="<?php echo $widget_options['offset']; ?>" size="4" />
  220. </p>
  221. <p>
  222. <label for="<?php echo $this->get_field_id('speedMenu'); ?>"><?php _e('Slide Speed:') ?></label>
  223. <input type="text" id="<?php echo $this->get_field_id('speedMenu'); ?>" name="<?php echo $this->get_field_name('speedMenu'); ?>" value="<?php echo $widget_options['speedMenu']; ?>" size="5" /> (ms)
  224. </p>
  225. <p>
  226. <label for="<?php echo $this->get_field_id('autoClose'); ?>"><?php _e( 'Auto-Close' , 'dcjq-social-tabs' ); ?></label>
  227. <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('autoClose'); ?>" name="<?php echo $this->get_field_name('autoClose'); ?>"<?php checked( $widget_options['autoClose'], 'true'); ?> style="margin-right: 5px;" />
  228. <label for="<?php echo $this->get_field_id('loadOpen'); ?>"><?php _e( 'Load Open' , 'dcjq-social-tabs' ); ?></label>
  229. <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('loadOpen'); ?>" name="<?php echo $this->get_field_name('loadOpen'); ?>"<?php checked( $widget_options['loadOpen'], 'true'); ?> />
  230. </p>
  231. <p class="dcwp-row"><strong>Tabs</strong></p>
  232. <?php
  233. $deftabs = explode(',','facebook,twitter,plusone,rss,youtube,flickr,pinterest');
  234. foreach($deftabs as $k=>$tabv){
  235. if($tabv != ''){
  236. $x = $k;
  237. $k = $k+1;
  238. $tab = isset( $instance['tab'.$k] ) ? $instance['tab'.$k] : $tabv;
  239. echo $odd = $k%2 ? '<p class="dcwp-row">': '';
  240. echo $k.' '.$this->dcsmt_tab_options('tab'.$k, 'Tab '.$k, $tab);
  241. echo $odd = $k%2 ? '': '</p>';
  242. $selected = $widget_options['start'] == $x ? ' selected="selected"':'';
  243. $open .= '<option value="'.$x.'"'.$selected.'>Tab '.$k.'</option>';
  244. }
  245. }
  246. ?>
  247. <p class="dcwp-row">
  248. <label for="<?php echo $this->get_field_id('start'); ?>"><?php _e( 'Open Tab' , 'dcjq-social-tabs' ); ?></label>
  249. <select name="<?php echo $this->get_field_name('start'); ?>" id="<?php echo $this->get_field_id('start'); ?>" >
  250. <?php echo $open; ?>
  251. </select>
  252. </p>
  253. <p class="dcwp-row">
  254. <strong>Facebook</strong>
  255. </p>
  256. <p class="dcwp-row">
  257. <label for="<?php echo $this->get_field_id('facebookId'); ?>"><?php _e('ID:') ?></label>
  258. <input type="text" id="<?php echo $this->get_field_id('facebookId'); ?>" name="<?php echo $this->get_field_name('facebookId'); ?>" value="<?php echo $facebookId; ?>" />
  259. </p>
  260. <p class="dcwp-row">
  261. <label for="<?php echo $this->get_field_id('facebook_width'); ?>"><?php _e( 'Size:' , 'dcjq-social-tabs' ); ?></label>
  262. <input type="text" id="<?php echo $this->get_field_id('facebook_width'); ?>" name="<?php echo $this->get_field_name('facebook_width'); ?>" value="<?php echo $widget_options['facebook_width']; ?>" size="4" /> x
  263. <input type="text" id="<?php echo $this->get_field_id('facebook_height'); ?>" name="<?php echo $this->get_field_name('facebook_height'); ?>" value="<?php echo $widget_options['facebook_height']; ?>" size="4" />
  264. </p>
  265. <p class="dcwp-row">
  266. Connections:
  267. <input type="text" id="<?php echo $this->get_field_id('facebook_connections'); ?>" name="<?php echo $this->get_field_name('facebook_connections'); ?>" value="<?php echo $widget_options['facebook_connections']; ?>" size="4" />
  268. </p>
  269. <p class="dcwp-row">
  270. <strong>Google</strong>
  271. </p>
  272. <p class="dcwp-row">
  273. <label for="<?php echo $this->get_field_id('googleId'); ?>"><?php _e('ID:') ?></label>
  274. <input type="text" id="<?php echo $this->get_field_id('googleId'); ?>" name="<?php echo $this->get_field_name('googleId'); ?>" value="<?php echo $googleId; ?>" />
  275. </p>
  276. <p class="dcwp-row">
  277. <label for="<?php echo $this->get_field_id('nBuzz'); ?>"><?php _e( 'Results' , 'dcjq-social-tabs' ); ?></label>
  278. <input type="text" id="<?php echo $this->get_field_id('nBuzz'); ?>" name="<?php echo $this->get_field_name('nBuzz'); ?>" value="<?php echo $widget_options['nBuzz']; ?>" size="4" />
  279. </p>
  280. <p class="dcwp-row">
  281. <strong>Twitter</strong>
  282. </p>
  283. <p class="dcwp-row">
  284. <label for="<?php echo $this->get_field_id('twitterUrl'); ?>"><?php _e('Widget URL:') ?></label>
  285. <input type="text" id="<?php echo $this->get_field_id('twitterUrl'); ?>" name="<?php echo $this->get_field_name('twitterUrl'); ?>" value="<?php echo $twitterUrl; ?>" />
  286. </p>
  287. <p class="dcwp-row">
  288. <label for="<?php echo $this->get_field_id('twitterWidget'); ?>"><?php _e('Widget ID:') ?></label>
  289. <input type="text" id="<?php echo $this->get_field_id('twitterWidget'); ?>" name="<?php echo $this->get_field_name('twitterWidget'); ?>" value="<?php echo $twitterWidget; ?>" />
  290. </p>
  291. <p class="dcwp-row">
  292. <strong>RSS Feed</strong>
  293. </p>
  294. <p class="dcwp-row">
  295. <label for="<?php echo $this->get_field_id('rssId'); ?>"><?php _e('URL:') ?></label>
  296. <input type="text" id="<?php echo $this->get_field_id('rssId'); ?>" name="<?php echo $this->get_field_name('rssId'); ?>" value="<?php echo $widget_options['rssId']; ?>" />
  297. </p>
  298. <p class="dcwp-row">
  299. <label for="<?php echo $this->get_field_id('rssTitle'); ?>"><?php _e('Title:') ?></label>
  300. <input type="text" id="<?php echo $this->get_field_id('rssTitle'); ?>" name="<?php echo $this->get_field_name('rssTitle'); ?>" value="<?php echo $rssTitle; ?>" />
  301. </p>
  302. <p class="dcwp-row">
  303. <label for="<?php echo $this->get_field_id('nRss'); ?>"><?php _e( 'Results:' , 'dcjq-social-tabs' ); ?></label>
  304. <input type="text" id="<?php echo $this->get_field_id('nRss'); ?>" name="<?php echo $this->get_field_name('nRss'); ?>" value="<?php echo $nRss; ?>" size="4" />
  305. </p>
  306. <p class="dcwp-row">
  307. <strong>YouTube</strong>
  308. </p>
  309. <p class="dcwp-row">
  310. <label for="<?php echo $this->get_field_id('youtubeId'); ?>"><?php _e('Username:') ?></label>
  311. <input type="text" id="<?php echo $this->get_field_id('youtubeId'); ?>" name="<?php echo $this->get_field_name('youtubeId'); ?>" value="<?php echo $youtubeId; ?>" />
  312. </p>
  313. <p class="dcwp-row">
  314. <label for="<?php echo $this->get_field_id('videoId'); ?>"><?php _e('Video ID:') ?></label>
  315. <input type="text" id="<?php echo $this->get_field_id('videoId'); ?>" name="<?php echo $this->get_field_name('videoId'); ?>" value="<?php echo $videoId; ?>" />
  316. </p>
  317. <p class="dcwp-row">
  318. <strong>Flickr</strong>
  319. </p>
  320. <p class="dcwp-row">
  321. <label for="<?php echo $this->get_field_id('flickrId'); ?>"><?php _e('User ID:') ?></label>
  322. <input type="text" id="<?php echo $this->get_field_id('flickrId'); ?>" name="<?php echo $this->get_field_name('flickrId'); ?>" value="<?php echo $flickrId; ?>" />
  323. </p>
  324. <p class="dcwp-row">
  325. <label for="<?php echo $this->get_field_id('flickrTitle'); ?>"><?php _e('Title:') ?></label>
  326. <input type="text" id="<?php echo $this->get_field_id('flickrTitle'); ?>" name="<?php echo $this->get_field_name('flickrTitle'); ?>" value="<?php echo $flickrTitle; ?>" />
  327. </p>
  328. <p class="dcwp-row">
  329. <label for="<?php echo $this->get_field_id('nFlickr'); ?>"><?php _e( 'Results:' , 'dcjq-social-tabs' ); ?></label>
  330. <input type="text" id="<?php echo $this->get_field_id('nFlickr'); ?>" name="<?php echo $this->get_field_name('nFlickr'); ?>" value="<?php echo $nFlickr; ?>" size="4" />
  331. </p>
  332. <p class="dcwp-row">
  333. <strong>Pinterest</strong>
  334. </p>
  335. <p class="dcwp-row">
  336. <label for="<?php echo $this->get_field_id('pinterestId'); ?>"><?php _e('Username:') ?></label>
  337. <input type="text" id="<?php echo $this->get_field_id('pinterestId'); ?>" name="<?php echo $this->get_field_name('pinterestId'); ?>" value="<?php echo $pinterestId; ?>" />
  338. </p>
  339. <p class="dcwp-row">
  340. <label for="<?php echo $this->get_field_id('pinterestTitle'); ?>"><?php _e('Title:') ?></label>
  341. <input type="text" id="<?php echo $this->get_field_id('pinterestTitle'); ?>" name="<?php echo $this->get_field_name('pinterestTitle'); ?>" value="<?php echo $pinterestTitle; ?>" />
  342. </p>
  343. <p class="dcwp-row">
  344. <label for="<?php echo $this->get_field_id('nPinterest'); ?>"><?php _e( 'Results:' , 'dcjq-social-tabs' ); ?></label>
  345. <input type="text" id="<?php echo $this->get_field_id('nPinterest'); ?>" name="<?php echo $this->get_field_name('nPinterest'); ?>" value="<?php echo $nPinterest; ?>" size="4" />
  346. </p>
  347. <p>
  348. <label for="<?php echo $this->get_field_id('pinterest_follow'); ?>"><?php _e( 'Follow Button' , 'dcjq-social-tabs' ); ?></label>
  349. <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('pinterest_follow'); ?>" name="<?php echo $this->get_field_name('pinterest_follow'); ?>"<?php checked( $widget_options['pinterest_follow'], 'true'); ?> style="margin-right: 5px;" />
  350. </p>
  351. <p class="dcwp-row">
  352. <strong>Custom</strong>
  353. </p>
  354. <p class="dcwp-row">
  355. <label for="<?php echo $this->get_field_id('customTitle'); ?>"><?php _e('Title:') ?></label>
  356. <input type="text" id="<?php echo $this->get_field_id('customTitle'); ?>" name="<?php echo $this->get_field_name('customTitle'); ?>" value="<?php echo $customTitle; ?>" />
  357. </p>
  358. <p class="dcwp-row">
  359. <label for="<?php echo $this->get_field_id('custom'); ?>"><?php _e('Shortcode:') ?></label>
  360. <input type="text" id="<?php echo $this->get_field_id('custom'); ?>" name="<?php echo $this->get_field_name('custom'); ?>" value="<?php echo $custom; ?>" />
  361. </p>
  362. <div class="widget-control-actions alignright">
  363. <p><a href="http://www.designchemical.com/blog/index.php/wordpress-plugins/wordpress-plugin-social-media-tabs/"><?php esc_attr_e('Visit plugin site', 'dcjq-social-tabs'); ?></a></p>
  364. </div>
  365. <?php
  366. }
  367. /** Creates tab options. */
  368. function dcsmt_tab_options($id, $label, $value){
  369. $facebook = $value == 'facebook' ? '<option value="facebook" selected="selected">':'<option value="facebook">';
  370. $twitter = $value == 'twitter' ? '<option value="twitter" selected="selected">':'<option value="twitter">';
  371. $plusone = $value == 'plusone' ? '<option value="plusone" selected="selected">':'<option value="plusone">';
  372. $rss = $value == 'rss' ? '<option value="rss" selected="selected">':'<option value="rss">';
  373. $youtube = $value == 'youtube' ? '<option value="youtube" selected="selected">':'<option value="youtube">';
  374. $flickr = $value == 'flickr' ? '<option value="flickr" selected="selected">':'<option value="flickr">';
  375. $pinterest = $value == 'pinterest' ? '<option value="pinterest" selected="selected">':'<option value="pinterest">';
  376. $custom = $value == 'custom' ? '<option value="custom" selected="selected">':'<option value="custom">';
  377. $none = $value == 'none' ? '<option value="none" selected="selected">':'<option value="none">';
  378. $select = '<select name="'.$this->get_field_name($id).'" id="'.$this->get_field_id($id).'" class="dcsmt-select" style="margin-right: 5px;">';
  379. $select .= $facebook.'Facebook</option>';
  380. $select .= $twitter.'Twitter</option>';
  381. $select .= $plusone.'Google +1</option>';
  382. $select .= $rss.'RSS Feed</option>';
  383. $select .= $youtube.'YouTube</option>';
  384. $select .= $flickr.'Flickr</option>';
  385. $select .= $pinterest.'Pinterest</option>';
  386. $select .= $custom.'Custom</option>';
  387. $select .= $none.'None</option>';
  388. $select .= '</select>';
  389. return $select;
  390. }
  391. /** Adds ID based slick skin to the header. */
  392. function styles(){
  393. if(!is_admin()){
  394. $options = get_option('dcsmt_options');
  395. $skin = $options['skin'];
  396. if($skin != 'true'){
  397. echo "\n\t<link rel=\"stylesheet\" href=\"".dc_jqsocialmediatabs::get_plugin_directory()."/css/dcsmt.css\" type=\"text/css\" media=\"screen\" />";
  398. }
  399. }
  400. }
  401. /** Adds ID based activation script to the footer */
  402. function footer(){
  403. if(!is_admin()){
  404. $all_widgets = $this->get_settings();
  405. foreach ($all_widgets as $key => $wpdcjqsocialtabs){
  406. $widget_id = $this->id_base . '-' . $key;
  407. if(is_active_widget(false, $widget_id, $this->id_base)){
  408. $method = $wpdcjqsocialtabs['method'] == '' ? 'static' : $wpdcjqsocialtabs['method'];
  409. $direction = $wpdcjqsocialtabs['direction'] == '' ? 'horizontal' : $wpdcjqsocialtabs['direction'];
  410. $position = $wpdcjqsocialtabs['position'];
  411. if($position == 'top-left'){
  412. $location = 'top';
  413. $align = 'left';
  414. }
  415. if($position == 'top-right'){
  416. $location = 'top';
  417. $align = 'right';
  418. }
  419. if($position == 'bottom-left'){
  420. $location = 'bottom';
  421. $align = 'left';
  422. }
  423. if($position == 'bottom-right'){
  424. $location = 'bottom';
  425. $align = 'right';
  426. }
  427. if($position == 'left'){
  428. if($method == 'float'){
  429. $location = 'top';
  430. $align = 'left';
  431. } else {
  432. $location = 'left';
  433. $align = 'top';
  434. }
  435. }
  436. if($position == 'right'){
  437. if($method == 'float'){
  438. $location = 'top';
  439. $align = 'right';
  440. } else {
  441. $location = 'right';
  442. $align = 'top';
  443. }
  444. }
  445. $width = $wpdcjqsocialtabs['width'] == '' ? 260 : $wpdcjqsocialtabs['width'];
  446. $height = $wpdcjqsocialtabs['height'] == '' ? 260 : $wpdcjqsocialtabs['height'];
  447. $speedMenu = $wpdcjqsocialtabs['speedMenu'] == '' ? 600 : $wpdcjqsocialtabs['speedMenu'];
  448. $offset = $wpdcjqsocialtabs['offset'] == '' ? 0 : $wpdcjqsocialtabs['offset'];
  449. $autoClose = $wpdcjqsocialtabs['autoClose'] == '' ? 'false' : $wpdcjqsocialtabs['autoClose'];
  450. $loadOpen = $wpdcjqsocialtabs['loadOpen'] == '' ? 'false' : $wpdcjqsocialtabs['loadOpen'];
  451. $start = $wpdcjqsocialtabs['start'] == '' ? 0 : $wpdcjqsocialtabs['start'];
  452. ?>
  453. <script type="text/javascript">
  454. jQuery(document).ready(function($) {
  455. var config = {
  456. location: '<?php echo $location; ?>',
  457. align: '<?php echo $align; ?>',
  458. offset: <?php echo $offset; ?>,
  459. speed: <?php echo $speedMenu; ?>,
  460. width: <?php echo $width; ?>,
  461. height: <?php echo $height; ?>,
  462. slider: '<?php echo $widget_id.'-slide'; ?>',
  463. slides: '<?php echo $widget_id.'-tab'; ?>',
  464. tabs: 'social-tabs',
  465. slideWrap: '<?php echo $widget_id.'-wrap'; ?>',
  466. direction: '<?php echo $direction; ?>',
  467. autoClose: <?php echo $autoClose; ?>,
  468. method: '<?php echo $method; ?>',
  469. start: <?php echo $start; ?>
  470. };
  471. if(!jQuery().dcSlickTabs) {
  472. $.getScript('<?php echo dc_jqsocialmediatabs::get_plugin_directory(); ?>/js/jquery.dcsmt.1.0.js', function(){
  473. jQuery('#<?php echo $widget_id.'-item'; ?>').dcSlickTabs(config);
  474. });
  475. } else {
  476. jQuery('#<?php echo $widget_id.'-item'; ?>').dcSlickTabs(config);
  477. }
  478. <?php
  479. if($this->get_dcsmt_default('links') == 'true') {
  480. ?>
  481. $('.dc-social .tab-content a').click(function(){
  482. this.target = "_blank";
  483. });
  484. <?php } ?>
  485. });
  486. </script>
  487. <?php
  488. }
  489. }
  490. }
  491. }
  492. function get_dcsmt_default($option){
  493. $options = get_option('dcsmt_options');
  494. $default = $options[$option];
  495. return $default;
  496. }
  497. /* Twitter */
  498. function dcsmt_inc_twitter($args, $instance){
  499. extract( $args );
  500. $widget_options = wp_parse_args( $instance, $this->defaults );
  501. extract( $widget_options, EXTR_SKIP );
  502. $options = get_option('dcsmt_options');
  503. $twitterUrl = $widget_options['twitterUrl'];
  504. $icon_close = '<a href="#" class="dcsmt-close dcsmt-close-tab"></a>';
  505. $twitterWidget = $widget_options['twitterWidget'];
  506. $tab = '<div class="tab-twitter tab-inner"><a class="twitter-timeline" href="https://twitter.com/'.$twitterUrl.'" data-widget-id="'.$twitterWidget.'">Tweets by @'.$twitterUrl.'</a>
  507. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  508. </div>';
  509. return $tab;
  510. }
  511. /* Google +1 profile */
  512. function dcsmt_inc_plusone($args, $instance){
  513. $tab = '';
  514. extract( $args );
  515. $widget_options = wp_parse_args( $instance, $this->defaults );
  516. extract( $widget_options, EXTR_SKIP );
  517. $options = get_option('dcsmt_options');
  518. $id = $widget_options['googleId'];
  519. $nBuzz = $widget_options['nBuzz'];
  520. $title = $widget_options['plusoneTitle'] == '' ? '' : '<h3>'.$widget_options['plusoneTitle'].'</h3>';
  521. $tab .= '<script type="text/javascript">
  522. //<![CDATA[
  523. jQuery(document).ready(function($) {
  524. $(".google-plus-activity").googlePlusActivity({
  525. api_key : "'.$options['google_api'].'"
  526. ,user:"'.$id.'"
  527. ,image_width:50
  528. ,image_height:50
  529. ,body_height:'.($widget_options['height']-80).'
  530. });
  531. });
  532. //]]>
  533. </script>';
  534. $tab .= '<div class="tab-plusone tab-inner">'.$title;
  535. $tab .= '<div class="google-plus-activity"></div>';
  536. $tab .= '</div>';
  537. return $tab;
  538. }
  539. /* Facebook */
  540. function dcsmt_inc_facebook($args, $instance){
  541. extract( $args );
  542. $widget_options = wp_parse_args( $instance, $this->defaults );
  543. extract( $widget_options, EXTR_SKIP );
  544. $options = get_option('dcsmt_options');
  545. $facebookId = $widget_options['facebookId'];
  546. $width = $widget_options['facebook_width'];
  547. $height = $widget_options['facebook_height'];
  548. $connections = $widget_options['facebook_connections'];
  549. $tab .= '<div class="tab-facebook tab-inner"><iframe src="http://www.facebook.com/plugins/likebox.php?id='.$facebookId.'&amp;width='.$width.'&amp;connections='.$connections.'&amp;stream=false&amp;header=true&amp;height='.$height.'" scrolling="no" frameborder="0" style="border: none; background: #fff; overflow: hidden; width: '.$width.'px; height: '.$height.'px;" allowTransparency="true"></iframe></div>';
  550. return $tab;
  551. }
  552. /* RSS */
  553. function dcsmt_inc_rss($args, $instance){
  554. extract( $args );
  555. $widget_options = wp_parse_args( $instance, $this->defaults );
  556. extract( $widget_options, EXTR_SKIP );
  557. $rssId = $widget_options['rssId'];
  558. $icon_close = '<a href="#" class="dcsmt-close dcsmt-close-tab"></a>';
  559. $title = $widget_options['rssTitle'] == '' ? '' : '<h3><a href="'.$rssId.'">'.$widget_options['rssTitle'].'</a>'.$icon_close.'</h3>';
  560. $nRss = $widget_options['nRss'];
  561. $tab = '';
  562. if($rssId != ''){
  563. require_once(ABSPATH.WPINC.'/feed.php');
  564. $tab .= '<div class="tab-rss tab-inner">'.$title;
  565. $rss = fetch_feed($rssId);
  566. if (!is_wp_error( $rss ) ) :
  567. $maxitems = $rss->get_item_quantity($nRss);
  568. $rss_items = $rss->get_items(0, $maxitems);
  569. endif;
  570. $tab .= '<ul class="list-dcsmt-rss">';
  571. if ($maxitems == 0) {
  572. $tab .= '<li class="odd dcsmt-rss-item">No items.</li>';
  573. } else {
  574. $count = 1;
  575. foreach ( $rss_items as $item ) :
  576. $time = wpcom_time_since(strtotime($item->get_date()));
  577. if($odd = $count%2){
  578. $rssClass = "odd dcsmt-rss-item";
  579. } else {
  580. $rssClass = "even dcsmt-rss-item";
  581. }
  582. $tab .= '<li class="'.$rssClass.'">'.esc_html( $item->get_title() );
  583. $tab .= ' ... <a href="'.esc_url( $item->get_permalink() ).'">'.$time.'&nbsp;ago</a></li>';
  584. $count++;
  585. endforeach;
  586. }
  587. $tab .= '</ul></div>';
  588. }
  589. return $tab;
  590. }
  591. /* YouTube */
  592. function dcsmt_inc_youtube($args, $instance){
  593. extract( $args );
  594. $widget_options = wp_parse_args( $instance, $this->defaults );
  595. extract( $widget_options, EXTR_SKIP );
  596. $options = get_option('dcsmt_options');
  597. $youtubeId = $widget_options['youtubeId'];
  598. $videoId = $widget_options['videoId'];
  599. $height = $widget_options['height'];
  600. $width = $widget_options['width'];
  601. $ratio = 1.641;
  602. $maxwidth = $width - 20;
  603. $maxheight = $height - 125;
  604. $height = $maxwidth/$ratio;
  605. $width = $maxwidth;
  606. $tab = '';
  607. if($youtubeId != ''){
  608. if($height > $maxheight){
  609. $height = $maxheight;
  610. $width = $height * $ratio;
  611. }
  612. $padLeft = ($maxwidth-$width)/2;
  613. $tab .= '<div class="tab-youtube tab-inner"><iframe src="http://www.youtube.com/subscribe_widget?p='.$youtubeId.'" style="overflow: hidden; height: 105px; width: 100%; border: 0;" scrolling="no" frameBorder="0"></iframe>';
  614. if($videoId != ''){
  615. $tab .= '<div style="padding-left: '.$padLeft.'px;"><iframe title="YouTube video player" class="youtube-player" type="text/html" width="'.$width.'px" height="'.$height.'px" src="http://www.youtube.com/embed/'.$videoId.'" frameborder="0" allowFullScreen></iframe></div>';
  616. }
  617. $tab .= '</div>';
  618. }
  619. return $tab;
  620. }
  621. /* DC Flickr Images */
  622. function dcsmt_inc_flickr($args, $instance){
  623. extract( $args );
  624. $widget_options = wp_parse_args( $instance, $this->defaults );
  625. extract( $widget_options, EXTR_SKIP );
  626. $nFlickr = $widget_options['nFlickr'];
  627. $api = 'photos_public.gne?';
  628. $id = $widget_options['flickrId'];
  629. $icon_close = '<a href="#" class="dcsmt-close dcsmt-close-tab"></a>';
  630. $title = $widget_options['flickrTitle'] != '' ? '<h3>'.$widget_options['flickrTitle'].$icon_close.'</h3>' : '' ;
  631. $tag= uniqid('flickr');
  632. if($id != ''){
  633. $tab = '<script type="text/javascript">
  634. jQuery(document).ready(function($){
  635. $("#'.$tag.'").dcFlickr({
  636. limit: '.$nFlickr.',
  637. style: "thumb",
  638. q: {id: "'.$id.'",
  639. lang: "en-us",
  640. format: "json",
  641. jsoncallback: "?"}
  642. });
  643. });
  644. </script>';
  645. $tab .= '<div class="tab-flickr tab-inner">'.$title;
  646. $tab .= '<ul id="'.$tag.'"></ul>';
  647. $tab .= '</div>';
  648. }
  649. return $tab;
  650. }
  651. /* Pinterest */
  652. function dcsmt_inc_pinterest($args, $instance){
  653. extract( $args );
  654. $widget_options = wp_parse_args( $instance, $this->defaults );
  655. extract( $widget_options, EXTR_SKIP );
  656. $id = $widget_options['pinterestId'];
  657. $rssId = 'http://pinterest.com/'.$id.'/feed.rss';
  658. $icon_close = '<a href="#" class="dcsmt-close dcsmt-close-tab"></a>';
  659. $title = $widget_options['pinterestTitle'] == '' ? '' : '<h3><a href="http://pinterest.com/'.$id.'/">'.$widget_options['pinterestTitle'].'</a>'.$icon_close.'</h3>';
  660. $nPinterest = $widget_options['nPinterest'];
  661. $tab = '';
  662. if($id != ''){
  663. require_once(ABSPATH.WPINC.'/feed.php');
  664. $tab = '<script type="text/javascript">
  665. jQuery(document).ready(function($) {
  666. $(".tab-pinterest").jCarouselLitedcsmt({
  667. btnNext: ".btn-pin.next",
  668. btnPrev: ".btn-pin.prev",
  669. visible: 1,
  670. scroll: 1,
  671. speed: 800,
  672. auto: 0,
  673. width: '.($widget_options['width']-20).',
  674. height: '.($widget_options['height']-100).'
  675. });
  676. });
  677. </script>';
  678. $tab .= '<div class="tab-pinterest tab-inner" style="width: '.$widget_options['width'].';">'.$title;
  679. $rss = fetch_feed($rssId);
  680. // print_r($rss);
  681. $maxitems = $rss->get_item_quantity((int)$nPinterest);
  682. $rss_items = $rss->get_items(0,$maxitems);
  683. $tab .= '<div class="carousel" style="width: '.$widget_options['width'].';">'."\n";
  684. $tab .= '<ul class="list-dcsmt-pinterest">';
  685. $count = 1;
  686. foreach ( $rss_items as $item ) :
  687. $time = wpcom_time_since(strtotime($item->get_date()));
  688. $tab .= '<li class="dcsmt-pinterest-item carousel-slide" style="width: '.$widget_options['width'].';"><div class="pin">';
  689. $tab .= '<p><a href="'.esc_url( $item->get_permalink() ).'">'.$item->get_description().'</a></p>';
  690. $tab .= '<p class="btm">Pinned '.$time.'&nbsp;ago</p>';
  691. $tab .= '</div></li>';
  692. $count++;
  693. endforeach;
  694. }
  695. $tab .= '</ul></div>';
  696. $tab .= '<a href="#" class="btn-pin prev"></a><a href="#" class="btn-pin next"></a>';
  697. $tab .= $widget_options['pinterest_follow'] == true ? '<a href="http://pinterest.com/'.$id.'/" class="dcsmt-pin-btn"><img src="http://passets-cdn.pinterest.com/images/follow-on-pinterest-button.png" width="156" height="26" alt="Follow Me on Pinterest" /></a>' : '' ;
  698. $tab .= '</div>';
  699. return $tab;
  700. }
  701. /* Custom shortcode */
  702. function dcsmt_inc_custom($args, $instance){
  703. extract( $args );
  704. $widget_options = wp_parse_args( $instance, $this->defaults );
  705. extract( $widget_options, EXTR_SKIP );
  706. $options = get_option('dcsmt_options');
  707. $custom = $widget_options['custom'];
  708. $title = $widget_options['customTitle'] == '' ? '' : '<h3>'.$widget_options['customTitle'].$icon_close.'</h3>';
  709. $tab .= '<div class="tab-custom tab-inner">'.$title;
  710. $tab .= do_shortcode($custom);
  711. $tab .= '</div>';
  712. return $tab;
  713. }
  714. function get_string_between($string, $start, $end){
  715. $string = " ".$string;
  716. $ini = strpos($string,$start);
  717. if ($ini == 0) return "";
  718. $ini += strlen($start);
  719. $len = strpos($string,$end,$ini) - $ini;
  720. return substr($string,$ini,$len);
  721. }
  722. // Truncate text
  723. function dcwp_truncate($str, $length=10, $trailing='...'){
  724. $length-=strlen($trailing);
  725. if (strlen($str) > $length) {
  726. return substr($str,0,$length).$trailing;
  727. }
  728. else {
  729. $res = $str;
  730. }
  731. return $res;
  732. }
  733. } // class dc_jqsocialmediatabs_widget