PageRenderTime 51ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/simple-catch/functions/simplecatch_functions.php

https://github.com/Bochet/festival_lgbt
PHP | 943 lines | 558 code | 153 blank | 232 comment | 137 complexity | a3902fd96ae80abf67ef460f01ba6726 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Register jquery scripts
  4. *
  5. * @register jquery cycle and custom-script
  6. * hooks action wp_enqueue_scripts
  7. */
  8. function simplecatch_scripts_method() {
  9. //Register JQuery circle all and JQuery set up as dependent on Jquery-cycle
  10. wp_register_script( 'jquery-cycle', get_template_directory_uri() . '/js/jquery.cycle.all.min.js', array( 'jquery' ), '2.9999.5', true );
  11. //Enqueue Slider Script only in Front Page
  12. if ( is_home() || is_front_page() ) {
  13. wp_enqueue_script( 'simplecatch_slider', get_template_directory_uri() . '/js/simplecatch_slider.js', array( 'jquery-cycle' ), '1.0', true );
  14. }
  15. //Enqueue Search Script
  16. wp_enqueue_script ( 'simplecatch_search', get_template_directory_uri() . '/js/simplecatch_search.js', array( 'jquery' ), '1.0', true );
  17. //Browser Specific Enqueue Script i.e. for IE 1-6
  18. $simplecatch_ua = strtolower($_SERVER['HTTP_USER_AGENT']);
  19. if(preg_match('/(?i)msie [1-6]/',$simplecatch_ua)) {
  20. wp_enqueue_script( 'pngfix', get_template_directory_uri() . '/js/pngfix.min.js' );
  21. }
  22. if(preg_match('/(?i)msie [1-8]/',$simplecatch_ua)) {
  23. wp_enqueue_style( 'iebelow8', get_template_directory_uri() . '/css/ie.css', true );
  24. }
  25. } // simplecatch_scripts_method
  26. add_action( 'wp_enqueue_scripts', 'simplecatch_scripts_method' );
  27. /**
  28. * Register Google Font Style
  29. *
  30. * @uses wp_register_style and wp_enqueue_style
  31. * @action wp_enqueue_scripts
  32. */
  33. function simplecatch_load_google_fonts() {
  34. wp_register_style('google-fonts', 'http://fonts.googleapis.com/css?family=Lobster');
  35. wp_enqueue_style( 'google-fonts');
  36. }
  37. add_action('wp_enqueue_scripts', 'simplecatch_load_google_fonts');
  38. /**
  39. * Register script for admin section
  40. *
  41. * No scripts should be enqueued within this function.
  42. * jquery cookie used for remembering admin tabs, and potential future features... so let's register it early
  43. * @uses wp_register_script
  44. * @action admin_enqueue_scripts
  45. */
  46. function simplecatch_register_js() {
  47. //jQuery Cookie
  48. wp_register_script( 'jquery-cookie', get_template_directory_uri() . '/js/jquery.cookie.min.js', array( 'jquery' ), '1.0', true );
  49. }
  50. add_action( 'admin_enqueue_scripts', 'simplecatch_register_js' );
  51. /**
  52. * Enqueue Comment Reply Script
  53. *
  54. * We add some JavaScript to pages with the comment form
  55. * to support sites with threaded comments (when in use).
  56. * @used comment_form_before action hook
  57. */
  58. function simplecatch_enqueue_comment_reply_script() {
  59. if ( comments_open() && get_option( 'thread_comments' ) ) {
  60. wp_enqueue_script( 'comment-reply' );
  61. }
  62. }
  63. add_action( 'comment_form_before', 'simplecatch_enqueue_comment_reply_script' );
  64. /**
  65. * Creates a nicely formatted and more specific title element text
  66. * for output in head of document, based on current view.
  67. *
  68. * @param string $title Default title text for current view.
  69. * @param string $sep Optional separator.
  70. * @return string Filtered title.
  71. */
  72. function simplecatch_wp_title( $title, $sep ) {
  73. global $paged, $page;
  74. if ( is_feed() )
  75. return $title;
  76. // Add the site name.
  77. $title .= get_bloginfo( 'name' );
  78. // Add the site description for the home/front page.
  79. $site_description = get_bloginfo( 'description', 'display' );
  80. if ( $site_description && ( is_home() || is_front_page() ) )
  81. $title = "$title $sep $site_description";
  82. // Add a page number if necessary.
  83. if ( $paged >= 2 || $page >= 2 )
  84. $title = "$title $sep " . sprintf( __( 'Page %s', 'simplecatch' ), max( $paged, $page ) );
  85. return $title;
  86. }
  87. add_filter( 'wp_title', 'simplecatch_wp_title', 10, 2 );
  88. /**
  89. * Sets the post excerpt length to 30 words.
  90. *
  91. * function tied to the excerpt_length filter hook.
  92. * @uses filter excerpt_length
  93. */
  94. function simplecatch_excerpt_length( $length ) {
  95. global $simplecatch_options_settings;
  96. $options = $simplecatch_options_settings;
  97. return $options[ 'excerpt_length' ];
  98. }
  99. add_filter( 'excerpt_length', 'simplecatch_excerpt_length' );
  100. /**
  101. * Returns a "Continue Reading" link for excerpts
  102. */
  103. function simplecatch_continue_reading() {
  104. global $simplecatch_options_settings;
  105. $options = $simplecatch_options_settings;
  106. $more_tag_text = $options[ 'more_tag_text' ];
  107. return ' <a class="readmore" href="'. esc_url( get_permalink() ) . '">' . sprintf( __( '%s', 'simplecatch' ), esc_attr( $more_tag_text ) ) . '</a>';
  108. }
  109. /**
  110. * Replaces "[...]" (appended to automatically generated excerpts) with simplecatch_continue_reading().
  111. *
  112. */
  113. function simplecatch_excerpt_more( $more ) {
  114. return ' &hellip;' . simplecatch_continue_reading();
  115. }
  116. add_filter( 'excerpt_more', 'simplecatch_excerpt_more' );
  117. /**
  118. * Adds Continue Reading link to post excerpts.
  119. *
  120. * function tied to the get_the_excerpt filter hook.
  121. */
  122. function simplecatch_custom_excerpt( $output ) {
  123. if ( has_excerpt() && ! is_attachment() ) {
  124. $output .= simplecatch_continue_reading();
  125. }
  126. return $output;
  127. }
  128. add_filter( 'get_the_excerpt', 'simplecatch_custom_excerpt' );
  129. /**
  130. * Allows post queries to sort the results by the order specified in the post__in parameter.
  131. * Just set the orderby parameter to post__in
  132. *
  133. * uses action filter posts_orderby
  134. */
  135. if ( !function_exists('simplecatch_sort_query_by_post_in') ) : //simple WordPress 3.0+ version, now across VIP
  136. add_filter('posts_orderby', 'simplecatch_sort_query_by_post_in', 10, 2);
  137. function simplecatch_sort_query_by_post_in($sortby, $thequery) {
  138. if ( isset($thequery->query['post__in']) && !empty($thequery->query['post__in']) && isset($thequery->query['orderby']) && $thequery->query['orderby'] == 'post__in' )
  139. $sortby = "find_in_set(ID, '" . implode( ',', $thequery->query['post__in'] ) . "')";
  140. return $sortby;
  141. }
  142. endif;
  143. /**
  144. * Get the header logo Image from theme options
  145. *
  146. * @uses header logo
  147. * @get the data value of image from theme options
  148. * @display Header Image logo
  149. *
  150. * @uses default logo if logo field on theme options is empty
  151. *
  152. * @uses set_transient and delete_transient
  153. */
  154. function simplecatch_headerdetails() {
  155. //delete_transient( 'simplecatch_headerdetails' );
  156. global $simplecatch_options_settings;
  157. $options = $simplecatch_options_settings;
  158. if ( ( !$simplecatch_headerdetails = get_transient( 'simplecatch_headerdetails' ) ) && ( empty( $options[ 'remove_header_logo' ] ) || empty( $options[ 'remove_site_title' ] ) || empty( $options[ 'remove_site_description' ] ) ) ) {
  159. echo '<!-- refreshing cache -->';
  160. $simplecatch_headerdetails = '<div class="logo-wrap">';
  161. if( empty( $options[ 'remove_header_logo' ] ) || empty( $options[ 'remove_site_title' ] ) ) {
  162. $simplecatch_headerdetails .= '<h1 id="site-title">'.'<a href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'">';
  163. if( empty( $options[ 'remove_header_logo' ] ) ) {
  164. if ( !empty( $options[ 'featured_logo_header' ] ) ):
  165. $simplecatch_headerdetails .= '<img src="'.esc_url( $options['featured_logo_header'] ).'" alt="'.get_bloginfo( 'name' ).'" />';
  166. else:
  167. // if empty featured_logo_header on theme options, display default logo
  168. $simplecatch_headerdetails .='<img src="'. get_template_directory_uri().'/images/logo.png" alt="logo" />';
  169. endif;
  170. }
  171. if ( empty( $options[ 'remove_site_title' ] ) ) {
  172. $simplecatch_headerdetails .= '<span>'.esc_attr( get_bloginfo( 'name', 'display' ) ).'</span>';
  173. }
  174. $simplecatch_headerdetails .= '</a></h1>';
  175. }
  176. if( empty( $options[ 'remove_site_description' ] ) ) {
  177. $simplecatch_headerdetails .= '<h2 id="site-description">'.esc_attr( get_bloginfo( 'description' ) ).'</h2>';
  178. }
  179. $simplecatch_headerdetails .= '</div><!-- .logo-wrap -->';
  180. set_transient( 'simplecatch_headerdetails', $simplecatch_headerdetails, 86940 );
  181. }
  182. echo $simplecatch_headerdetails;
  183. } // simplecatch_headerdetails
  184. /**
  185. * Get the footer logo Image from theme options
  186. *
  187. * @uses footer logo
  188. * @get the data value of image from theme options
  189. * @display footer Image logo
  190. *
  191. * @uses default logo if logo field on theme options is empty
  192. *
  193. * @uses set_transient and delete_transient
  194. */
  195. function simplecatch_footerlogo() {
  196. //delete_transient('simplecatch_footerlogo');
  197. if ( !$simplecatch_footerlogo = get_transient( 'simplecatch_footerlogo' ) ) {
  198. global $simplecatch_options_settings;
  199. $options = $simplecatch_options_settings;
  200. echo '<!-- refreshing cache -->';
  201. if ( $options[ 'remove_footer_logo' ] == "0" ) :
  202. // if not empty featured_logo_footer on theme options
  203. if ( !empty( $options[ 'featured_logo_footer' ] ) ) :
  204. $simplecatch_footerlogo =
  205. '<img src="'.esc_url( $options[ 'featured_logo_footer' ] ).'" alt="'.get_bloginfo( 'name' ).'" />';
  206. else:
  207. // if empty featured_logo_footer on theme options, display default fav icon
  208. $simplecatch_footerlogo ='
  209. <img src="'. get_template_directory_uri().'/images/logo-foot.png" alt="footerlogo" />';
  210. endif;
  211. endif;
  212. set_transient( 'simplecatch_footerlogo', $simplecatch_footerlogo, 86940 );
  213. }
  214. echo $simplecatch_footerlogo;
  215. } // simplecatch_footerlogo
  216. /**
  217. * Get the favicon Image from theme options
  218. *
  219. * @uses favicon
  220. * @get the data value of image from theme options
  221. * @display favicon
  222. *
  223. * @uses default favicon if favicon field on theme options is empty
  224. *
  225. * @uses set_transient and delete_transient
  226. */
  227. function simplecatch_favicon() {
  228. //delete_transient( 'simplecatch_favicon' );
  229. if( ( !$simplecatch_favicon = get_transient( 'simplecatch_favicon' ) ) ) {
  230. global $simplecatch_options_settings;
  231. $options = $simplecatch_options_settings;
  232. echo '<!-- refreshing cache -->';
  233. if ( $options[ 'remove_favicon' ] == "0" ) :
  234. // if not empty fav_icon on theme options
  235. if ( !empty( $options[ 'fav_icon' ] ) ) :
  236. $simplecatch_favicon = '<link rel="shortcut icon" href="'.esc_url( $options[ 'fav_icon' ] ).'" type="image/x-icon" />';
  237. else:
  238. // if empty fav_icon on theme options, display default fav icon
  239. $simplecatch_favicon = '<link rel="shortcut icon" href="'. get_template_directory_uri() .'/images/favicon.ico" type="image/x-icon" />';
  240. endif;
  241. endif;
  242. set_transient( 'simplecatch_favicon', $simplecatch_favicon, 86940 );
  243. }
  244. echo $simplecatch_favicon ;
  245. } // simplecatch_favicon
  246. //Load Favicon in Header Section
  247. add_action('wp_head', 'simplecatch_favicon');
  248. //Load Favicon in Admin Section
  249. add_action( 'admin_head', 'simplecatch_favicon' );
  250. /**
  251. * This function to display featured posts on homepage header
  252. *
  253. * @get the data value from theme options
  254. * @displays on the homepage header
  255. *
  256. * @useage Featured Image, Title and Content of Post
  257. *
  258. * @uses set_transient and delete_transient
  259. */
  260. function simplecatch_sliders() {
  261. global $post;
  262. //delete_transient( 'simplecatch_sliders' );
  263. global $simplecatch_options_settings;
  264. $options = $simplecatch_options_settings;
  265. $postperpage = $options[ 'slider_qty' ];
  266. if( ( !$simplecatch_sliders = get_transient( 'simplecatch_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) {
  267. echo '<!-- refreshing cache -->';
  268. $simplecatch_sliders = '
  269. <div class="featured-slider">';
  270. $get_featured_posts = new WP_Query( array(
  271. 'posts_per_page' => $postperpage,
  272. 'post__in' => $options[ 'featured_slider' ],
  273. 'orderby' => 'post__in',
  274. 'ignore_sticky_posts' => 1 // ignore sticky posts
  275. ));
  276. $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  277. $title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
  278. $excerpt = get_the_excerpt();
  279. if ( $i == 1 ) { $classes = "slides displayblock"; } else { $classes = "slides displaynone"; }
  280. $simplecatch_sliders .= '
  281. <div class="'.$classes.'">
  282. <div class="featured">
  283. <div class="slide-image">';
  284. if( has_post_thumbnail() ) {
  285. $simplecatch_sliders .= '<a href="' . get_permalink() . '" title="Permalink to '.the_title('','',false).'">';
  286. if( $options[ 'remove_noise_effect' ] == "0" ) {
  287. $simplecatch_sliders .= '<span class="img-effect pngfix"></span>';
  288. }
  289. $simplecatch_sliders .= get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).'</a>';
  290. }
  291. else {
  292. $simplecatch_sliders .= '<span class="img-effect pngfix"></span>';
  293. }
  294. $simplecatch_sliders .= '
  295. </div> <!-- .slide-image -->
  296. </div> <!-- .featured -->
  297. <div class="featured-text">';
  298. if( $excerpt !='') {
  299. $simplecatch_sliders .= the_title( '<span>','</span>', false ).': '.$excerpt;
  300. }
  301. $simplecatch_sliders .= '
  302. </div><!-- .featured-text -->
  303. </div> <!-- .slides -->';
  304. endwhile; wp_reset_query();
  305. $simplecatch_sliders .= '
  306. </div> <!-- .featured-slider -->
  307. <div id="controllers">
  308. </div><!-- #controllers -->';
  309. set_transient( 'simplecatch_sliders', $simplecatch_sliders, 86940 );
  310. }
  311. echo $simplecatch_sliders;
  312. } // simplecatch_sliders
  313. /**
  314. * Display slider or breadcrumb on header
  315. *
  316. * If the page is home or front page, slider is displayed.
  317. * In other pages, breadcrumb will display if exist bread
  318. */
  319. function simplecatch_sliderbreadcrumb() {
  320. // If the page is home or front page
  321. if ( is_home() || is_front_page() ) :
  322. // display featured slider
  323. if ( function_exists( 'simplecatch_sliders' ) ):
  324. simplecatch_sliders();
  325. endif;
  326. else :
  327. // if breadcrumb is not empty, display breadcrumb
  328. if ( function_exists( 'bcn_display_list' ) ):
  329. echo '<div class="breadcrumb">
  330. <ul>';
  331. bcn_display_list();
  332. echo '</ul>
  333. <div class="row-end"></div>
  334. </div> <!-- .breadcrumb -->';
  335. endif;
  336. endif;
  337. } // simplecatch_sliderbreadcrumb
  338. /**
  339. * This function for social links display on header
  340. *
  341. * @fetch links through Theme Options
  342. * @use in widget
  343. * @social links, Facebook, Twitter and RSS
  344. */
  345. function simplecatch_headersocialnetworks() {
  346. //delete_transient( 'simplecatch_headersocialnetworks' );
  347. global $simplecatch_options_settings;
  348. $options = $simplecatch_options_settings;
  349. if ( ( !$simplecatch_headersocialnetworks = get_transient( 'simplecatch_headersocialnetworks' ) ) && ( !empty( $options[ 'social_facebook' ] ) || !empty( $options[ 'social_twitter' ] ) || !empty( $options[ 'social_googleplus' ] ) || !empty( $options[ 'social_pinterest' ] ) || !empty( $options[ 'social_youtube' ] ) || !empty( $options[ 'social_linkedin' ] ) || !empty( $options[ 'social_slideshare' ] ) || !empty( $options[ 'social_foursquare' ] ) || !empty( $options[ 'social_rss' ] ) || !empty( $options[ 'social_vimeo' ] ) || !empty( $options[ 'social_flickr' ] ) || !empty( $options[ 'social_tumblr' ] ) || !empty( $options[ 'social_deviantart' ] ) || !empty( $options[ 'social_dribbble' ] ) || !empty( $options[ 'social_myspace' ] ) || !empty( $options[ 'social_wordpress' ] ) || !empty( $options[ 'social_delicious' ] ) || !empty( $options[ 'social_lastfm' ] ) ) ) {
  350. echo '<!-- refreshing cache -->';
  351. $simplecatch_headersocialnetworks .='
  352. <ul class="social-profile">';
  353. //facebook
  354. if ( !empty( $options[ 'social_facebook' ] ) ) {
  355. $simplecatch_headersocialnetworks .=
  356. '<li class="facebook"><a href="'.esc_url( $options[ 'social_facebook' ] ).'" title="'.sprintf( esc_attr__( '%s in Facebook', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Facebook </a></li>';
  357. }
  358. //Twitter
  359. if ( !empty( $options[ 'social_twitter' ] ) ) {
  360. $simplecatch_headersocialnetworks .=
  361. '<li class="twitter"><a href="'.esc_url( $options[ 'social_twitter' ] ).'" title="'.sprintf( esc_attr__( '%s in Twitter', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Twitter </a></li>';
  362. }
  363. //Google+
  364. if ( !empty( $options[ 'social_googleplus' ] ) ) {
  365. $simplecatch_headersocialnetworks .=
  366. '<li class="google-plus"><a href="'.esc_url( $options[ 'social_googleplus' ] ).'" title="'.sprintf( esc_attr__( '%s in Google+', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Google+ </a></li>';
  367. }
  368. //Linkedin
  369. if ( !empty( $options[ 'social_linkedin' ] ) ) {
  370. $simplecatch_headersocialnetworks .=
  371. '<li class="linkedin"><a href="'.esc_url( $options[ 'social_linkedin' ] ).'" title="'.sprintf( esc_attr__( '%s in Linkedin', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Linkedin </a></li>';
  372. }
  373. //Pinterest
  374. if ( !empty( $options[ 'social_pinterest' ] ) ) {
  375. $simplecatch_headersocialnetworks .=
  376. '<li class="pinterest"><a href="'.esc_url( $options[ 'social_pinterest' ] ).'" title="'.sprintf( esc_attr__( '%s in Pinterest', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Twitter </a></li>';
  377. }
  378. //Youtube
  379. if ( !empty( $options[ 'social_youtube' ] ) ) {
  380. $simplecatch_headersocialnetworks .=
  381. '<li class="you-tube"><a href="'.esc_url( $options[ 'social_youtube' ] ).'" title="'.sprintf( esc_attr__( '%s in YouTube', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' YouTube </a></li>';
  382. }
  383. //Vimeo
  384. if ( !empty( $options[ 'social_vimeo' ] ) ) {
  385. $simplecatch_headersocialnetworks .=
  386. '<li class="viemo"><a href="'.esc_url( $options[ 'social_vimeo' ] ).'" title="'.sprintf( esc_attr__( '%s in Vimeo', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Vimeo </a></li>';
  387. }
  388. //Slideshare
  389. if ( !empty( $options[ 'social_slideshare' ] ) ) {
  390. $simplecatch_headersocialnetworks .=
  391. '<li class="slideshare"><a href="'.esc_url( $options[ 'social_slideshare' ] ).'" title="'.sprintf( esc_attr__( '%s in Slideshare', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Slideshare </a></li>';
  392. }
  393. //Foursquare
  394. if ( !empty( $options[ 'social_foursquare' ] ) ) {
  395. $simplecatch_headersocialnetworks .=
  396. '<li class="foursquare"><a href="'.esc_url( $options[ 'social_foursquare' ] ).'" title="'.sprintf( esc_attr__( '%s in Foursquare', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' foursquare </a></li>';
  397. }
  398. //Flickr
  399. if ( !empty( $options[ 'social_flickr' ] ) ) {
  400. $simplecatch_headersocialnetworks .=
  401. '<li class="flickr"><a href="'.esc_url( $options[ 'social_flickr' ] ).'" title="'.sprintf( esc_attr__( '%s in Flickr', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Flickr </a></li>';
  402. }
  403. //Tumblr
  404. if ( !empty( $options[ 'social_tumblr' ] ) ) {
  405. $simplecatch_headersocialnetworks .=
  406. '<li class="tumblr"><a href="'.esc_url( $options[ 'social_tumblr' ] ).'" title="'.sprintf( esc_attr__( '%s in Tumblr', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' Tumblr </a></li>';
  407. }
  408. //deviantART
  409. if ( !empty( $options[ 'social_deviantart' ] ) ) {
  410. $simplecatch_headersocialnetworks .=
  411. '<li class="deviantart"><a href="'.esc_url( $options[ 'social_deviantart' ] ).'" title="'.sprintf( esc_attr__( '%s in deviantART', 'simplecatch' ),get_bloginfo( 'name' ) ).'" target="_blank">'.get_bloginfo( 'name' ).' deviantART </a></li>';
  412. }
  413. //Dribbble
  414. if ( !empty( $options[ 'social_dribbble' ] ) ) {
  415. $simplecatch_headersocialnetworks .=
  416. '<li class="dribbble"><a href="'.esc_url( $options[ 'social_dribbble' ] ).'" title="'.sprintf( esc_attr__( '%s in Dribbble', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' Dribbble </a></li>';
  417. }
  418. //MySpace
  419. if ( !empty( $options[ 'social_myspace' ] ) ) {
  420. $simplecatch_headersocialnetworks .=
  421. '<li class="myspace"><a href="'.esc_url( $options[ 'social_myspace' ] ).'" title="'.sprintf( esc_attr__( '%s in MySpace', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' MySpace </a></li>';
  422. }
  423. //WordPress
  424. if ( !empty( $options[ 'social_wordpress' ] ) ) {
  425. $simplecatch_headersocialnetworks .=
  426. '<li class="wordpress"><a href="'.esc_url( $options[ 'social_wordpress' ] ).'" title="'.sprintf( esc_attr__( '%s in WordPress', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' WordPress </a></li>';
  427. }
  428. //RSS
  429. if ( !empty( $options[ 'social_rss' ] ) ) {
  430. $simplecatch_headersocialnetworks .=
  431. '<li class="rss"><a href="'.esc_url( $options[ 'social_rss' ] ).'" title="'.sprintf( esc_attr__( '%s in RSS', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' RSS </a></li>';
  432. }
  433. //Delicious
  434. if ( !empty( $options[ 'social_delicious' ] ) ) {
  435. $simplecatch_headersocialnetworks .=
  436. '<li class="delicious"><a href="'.esc_url( $options[ 'social_delicious' ] ).'" title="'.sprintf( esc_attr__( '%s in Delicious', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' Delicious </a></li>';
  437. }
  438. //Last.fm
  439. if ( !empty( $options[ 'social_lastfm' ] ) ) {
  440. $simplecatch_headersocialnetworks .=
  441. '<li class="lastfm"><a href="'.esc_url( $options[ 'social_lastfm' ] ).'" title="'.sprintf( esc_attr__( '%s in Last.fm', 'simplecatch' ),get_bloginfo('name') ).'" target="_blank">'.get_bloginfo( 'name' ).' Last.fm </a></li>';
  442. }
  443. $simplecatch_headersocialnetworks .='
  444. </ul>
  445. <div class="row-end"></div>';
  446. set_transient( 'simplecatch_headersocialnetworks', $simplecatch_headersocialnetworks, 86940 );
  447. }
  448. echo $simplecatch_headersocialnetworks;
  449. } // simplecatch_headersocialnetworks
  450. /**
  451. * Site Verification and Webmaster Tools
  452. *
  453. * If user sets the code we're going to display meta verification
  454. * @get the data value from theme options
  455. * @uses wp_head action to add the code in the header
  456. * @uses set_transient and delete_transient API for cache
  457. */
  458. function simplecatch_site_verification() {
  459. //delete_transient( 'simplecatch_site_verification' );
  460. if ( ( !$simplecatch_site_verification = get_transient( 'simplecatch_site_verification' ) ) ) {
  461. global $simplecatch_options_settings;
  462. $options = $simplecatch_options_settings;
  463. echo '<!-- refreshing cache -->';
  464. $simplecatch_site_verification = '';
  465. //google
  466. if ( !empty( $options['google_verification'] ) ) {
  467. $simplecatch_site_verification .= '<meta name="google-site-verification" content="' . $options['google_verification'] . '" />' . "\n";
  468. }
  469. //bing
  470. if ( !empty( $options['bing_verification'] ) ) {
  471. $simplecatch_site_verification .= '<meta name="msvalidate.01" content="' . $options['bing_verification'] . '" />' . "\n";
  472. }
  473. //yahoo
  474. if ( !empty( $options['yahoo_verification'] ) ) {
  475. $simplecatch_site_verification .= '<meta name="y_key" content="' . $options['yahoo_verification'] . '" />' . "\n";
  476. }
  477. //site stats, analytics header code
  478. if ( !empty( $options['analytic_header'] ) ) {
  479. $simplecatch_site_verification .= $options[ 'analytic_header' ] ;
  480. }
  481. set_transient( 'simplecatch_site_verification', $simplecatch_site_verification, 86940 );
  482. }
  483. echo $simplecatch_site_verification;
  484. }
  485. add_action('wp_head', 'simplecatch_site_verification');
  486. /**
  487. * This function loads the Footer Code such as Add this code from the Theme Option
  488. *
  489. * @get the data value from theme options
  490. * @load on the footer ONLY
  491. * @uses wp_footer action to add the code in the footer
  492. * @uses set_transient and delete_transient
  493. */
  494. function simplecatch_footercode() {
  495. //delete_transient( 'simplecatch_footercode' );
  496. if ( ( !$simplecatch_footercode = get_transient( 'simplecatch_footercode' ) ) ) {
  497. global $simplecatch_options_settings;
  498. $options = $simplecatch_options_settings;
  499. echo '<!-- refreshing cache -->';
  500. //site stats, analytics header code
  501. if ( !empty( $options['analytic_footer'] ) ) {
  502. $simplecatch_footercode = $options[ 'analytic_footer' ] ;
  503. }
  504. set_transient( 'simplecatch_footercode', $simplecatch_footercode, 86940 );
  505. }
  506. echo $simplecatch_footercode;
  507. }
  508. add_action('wp_footer', 'simplecatch_footercode');
  509. /**
  510. * Hooks the Custom Inline CSS to head section
  511. *
  512. * @since Simple Catch 1.2.3
  513. */
  514. function simplecatch_inline_css() {
  515. //delete_transient( 'simplecatch_inline_css' );
  516. if ( ( !$simplecatch_inline_css = get_transient( 'simplecatch_inline_css' ) ) ) {
  517. global $simplecatch_options_settings;
  518. $options = $simplecatch_options_settings;
  519. if( $options[ 'reset_color' ] == "0" ) {
  520. $simplecatch_inline_css = '<!-- '.get_bloginfo('name').' Custom CSS Styles -->' . "\n";
  521. $simplecatch_inline_css .= '<style type="text/css" media="screen">' . "\n";
  522. $simplecatch_inline_css .= "#main {
  523. color: ". $options[ 'text_color' ] .";
  524. }
  525. #main a {
  526. color: ". $options[ 'link_color' ] .";
  527. }
  528. #main h1 a, #main h2 a, #main h3 a, #main h4 a, #main h5 a, #main h6 a {
  529. color: ". $options[ 'heading_color' ] .";
  530. }
  531. #main #content ul.post-by li, #main #content ul.post-by li a {
  532. color: ". $options[ 'meta_color' ] .";
  533. }
  534. #sidebar h3, #sidebar h4, #sidebar h5 {
  535. color: ". $options[ 'widget_heading_color' ] .";
  536. }
  537. #sidebar, #sidebar p, #sidebar a, #sidebar ul li a, #sidebar ol li a {
  538. color: ". $options[ 'widget_text_color' ] .";
  539. }". "\n";
  540. $simplecatch_inline_css .= '</style>' . "\n";
  541. }
  542. echo '<!-- refreshing cache -->' . "\n";
  543. if( !empty( $options[ 'custom_css' ] ) ) {
  544. $simplecatch_inline_css .= '<!-- '.get_bloginfo('name').' Custom Content Color CSS Styles -->' . "\n";
  545. $simplecatch_inline_css .= '<style type="text/css" media="screen">' . "\n";
  546. $simplecatch_inline_css .= $options['custom_css'] . "\n";
  547. $simplecatch_inline_css .= '</style>' . "\n";
  548. }
  549. set_transient( 'simplecatch_inline_css', $simplecatch_inline_css, 86940 );
  550. }
  551. echo $simplecatch_inline_css;
  552. }
  553. add_action('wp_head', 'simplecatch_inline_css');
  554. /*
  555. * Function for showing custom tag cloud
  556. */
  557. function simplecatch_custom_tag_cloud() {
  558. ?>
  559. <div class="custom-tagcloud"><?php wp_tag_cloud('smallest=12&largest=12px&unit=px'); ?></div>
  560. <?php
  561. }
  562. /**
  563. * shows footer credits
  564. */
  565. function simplecatch_footer() {
  566. ?>
  567. <div class="col5 powered-by">
  568. <?php _e( 'Powered By:', 'simplecatch');?> <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'simplecatch' ) ); ?>" target="_blank" title="<?php esc_attr_e( 'Powered By WordPress', 'simplecatch' ); ?>"><?php _e( 'WordPress', 'simplecatch' ); ?></a> | <?php _e( 'Theme:', 'simplecatch');?> <a href="<?php echo esc_url( __( 'http://catchthemes.com/', 'simplecatch' ) ); ?>" target="_blank" title="<?php esc_attr_e( 'Simple Catch', 'simplecatch' ); ?>"><?php _e( 'Simple Catch', 'simplecatch' ); ?></a>
  569. </div><!--.col5 powered-by-->
  570. <?php
  571. }
  572. add_filter( 'simplecatch_credits', 'simplecatch_footer' );
  573. /**
  574. * Function to pass the slider value
  575. */
  576. function simplecatch_pass_slider_value() {
  577. global $simplecatch_options_settings;
  578. $options = $simplecatch_options_settings;
  579. $transition_effect = $options[ 'transition_effect' ];
  580. $transition_delay = $options[ 'transition_delay' ] * 1000;
  581. $transition_duration = $options[ 'transition_duration' ] * 1000;
  582. wp_localize_script(
  583. 'simplecatch_slider',
  584. 'js_value',
  585. array(
  586. 'transition_effect' => $transition_effect,
  587. 'transition_delay' => $transition_delay,
  588. 'transition_duration' => $transition_duration
  589. )
  590. );
  591. }// simplecatch_pass_slider_value
  592. /**
  593. * Alter the query for the main loop in home page
  594. * @uses pre_get_posts hook
  595. */
  596. function simple_catch_alter_home( $query ){
  597. global $simplecatch_options_settings;
  598. $options = $simplecatch_options_settings;
  599. if ( $options[ 'exclude_slider_post'] != "0" && !empty( $options[ 'featured_slider' ] ) ) {
  600. if( $query->is_main_query() && $query->is_home() ) {
  601. $query->query_vars['post__not_in'] = $options[ 'featured_slider' ];
  602. }
  603. }
  604. if ( !empty( $options[ 'front_page_category' ] ) ) {
  605. if( $query->is_main_query() && $query->is_home() ) {
  606. $query->query_vars['category__in'] = $options[ 'front_page_category' ];
  607. }
  608. }
  609. }
  610. add_action( 'pre_get_posts','simple_catch_alter_home' );
  611. /**
  612. * Add specific CSS class by filter
  613. * @uses body_class filter hook
  614. * @since Simple Catch 1.3.2
  615. */
  616. function simplecatch_class_names($classes) {
  617. global $post;
  618. if( $post ) {
  619. if ( is_attachment() ) {
  620. $parent = $post->post_parent;
  621. $layout = get_post_meta( $parent,'simplecatch-sidebarlayout', true );
  622. } else {
  623. $layout = get_post_meta( $post->ID,'simplecatch-sidebarlayout', true );
  624. }
  625. }
  626. if( empty( $layout ) || ( !is_page() && !is_single() ) ) {
  627. $layout='default';
  628. }
  629. global $simplecatch_options_settings;
  630. $options = $simplecatch_options_settings;
  631. $themeoption_layout = $options['sidebar_layout'];
  632. if( ( $layout == 'no-sidebar' || ( $layout=='default' && $themeoption_layout == 'no-sidebar') ) ){
  633. $classes[] = 'no-sidebar';
  634. }
  635. return $classes;
  636. }
  637. add_filter('body_class','simplecatch_class_names');
  638. /**
  639. * Display the page/post content
  640. * @since Simple Catch 1.3.2
  641. */
  642. function simplecatch_content() {
  643. global $post;
  644. $layout = get_post_meta( $post->ID,'simplecatch-sidebarlayout', true );
  645. if( empty( $layout ) )
  646. $layout='default';
  647. get_header();
  648. if( $layout=='default') {
  649. global $simplecatch_options_settings;
  650. $options = $simplecatch_options_settings;
  651. $themeoption_layout = $options['sidebar_layout'];
  652. if( $themeoption_layout == 'left-sidebar' ) {
  653. get_template_part( 'content-sidebar','left' );
  654. }
  655. elseif( $themeoption_layout == 'right-sidebar' ) {
  656. get_template_part( 'content-sidebar','right' );
  657. }
  658. else {
  659. get_template_part( 'content-sidebar','no' );
  660. }
  661. }
  662. elseif( $layout=='left-sidebar' ) {
  663. get_template_part( 'content-sidebar','left' );
  664. }
  665. elseif( $layout=='right-sidebar' ) {
  666. get_template_part( 'content-sidebar','right' );
  667. }
  668. else{
  669. get_template_part( 'content-sidebar','no' );
  670. }
  671. get_footer();
  672. }
  673. /**
  674. * Display the page/post loop part
  675. * @since Simple Catch 1.3.2
  676. */
  677. function simplecatch_loop() {
  678. if( is_page() ): ?>
  679. <div <?php post_class(); ?> >
  680. <h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
  681. <?php the_content();
  682. // copy this <!--nextpage--> and paste at the post content where you want to break the page
  683. wp_link_pages(array(
  684. 'before' => '<div class="pagination">Pages: ',
  685. 'after' => '</div>',
  686. 'link_before' => '<span>',
  687. 'link_after' => '</span>',
  688. 'pagelink' => '%',
  689. 'echo' => 1
  690. ) ); ?>
  691. </div><!-- .post -->
  692. <?php elseif( is_single() ): ?>
  693. <div <?php post_class(); ?>>
  694. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>"><?php the_title(); ?></a></h2>
  695. <ul class="post-by">
  696. <li class="no-padding-left"><a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"
  697. title="<?php echo esc_attr( get_the_author_meta( 'display_name' ) ); ?>"><?php _e( 'By', 'simplecatch' ); ?>&nbsp;<?php the_author_meta( 'display_name' );?></a></li>
  698. <li><?php $simplecatch_date_format = get_option( 'date_format' ); the_time( $simplecatch_date_format ); ?></li>
  699. <li><?php comments_popup_link( __( 'No Comments', 'simplecatch' ), __( '1 Comment', 'simplecatch' ), __( '% Comments', 'simplecatch' ) ); ?></li>
  700. </ul>
  701. <?php the_content();
  702. // copy this <!--nextpage--> and paste at the post content where you want to break the page
  703. wp_link_pages(array(
  704. 'before' => '<div class="pagination">Pages: ',
  705. 'after' => '</div>',
  706. 'link_before' => '<span>',
  707. 'link_after' => '</span>',
  708. 'pagelink' => '%',
  709. 'echo' => 1
  710. ) );
  711. $tag = get_the_tags();
  712. if (! $tag ) { ?>
  713. <div class='tags'><?php _e( 'Categories: ', 'simplecatch' ); ?> <?php the_category(', '); ?> </div>
  714. <?php } else {
  715. the_tags( '<div class="tags"> Tags: ', ', ', '</div>');
  716. } ?>
  717. </div> <!-- .post -->
  718. <?php endif;
  719. }
  720. /**
  721. * Display the header div
  722. * @since Simple Catch 1.3.2
  723. */
  724. function simplecatch_display_div() {
  725. echo '<div id="main" class="layout-978">';
  726. global $simplecatch_options_settings;
  727. $options = $simplecatch_options_settings;
  728. $themeoption_layout = $options['sidebar_layout'];
  729. if( $themeoption_layout == 'left-sidebar' ) {
  730. get_sidebar();
  731. echo '<div id="content" class="col8">';
  732. }
  733. elseif( $themeoption_layout == 'right-sidebar' ) {
  734. echo '<div id="content" class="col8 no-margin-left">';
  735. }
  736. else {
  737. echo '<div id="content" class="col8">';
  738. }
  739. return $themeoption_layout;
  740. }
  741. /**
  742. * Redirect WordPress Feeds To FeedBurner
  743. */
  744. function simplecatch_rss_redirect() {
  745. global $simplecatch_options_settings;
  746. $options = $simplecatch_options_settings;
  747. if ($options['feed_url']) {
  748. $url = 'Location: '.$options['feed_url'];
  749. if ( is_feed() && !preg_match('/feedburner|feedvalidator/i', $_SERVER['HTTP_USER_AGENT']))
  750. {
  751. header($url);
  752. header('HTTP/1.1 302 Temporary Redirect');
  753. }
  754. }
  755. }
  756. add_action('template_redirect', 'simplecatch_rss_redirect');
  757. /**
  758. * function that displays info bar in Theme Options
  759. */
  760. function simplecatch_infobar() {
  761. ?>
  762. <div id="info-support">
  763. <div class="upgrade">
  764. <a class="upgrade button" href="<?php echo esc_url(__('http://catchthemes.com/themes/simple-catch-pro','simplecatch')); ?>" title="<?php esc_attr_e('Upgrade to Simple Catch Pro', 'simplecatch'); ?>" target="_blank"><?php printf(__('Upgrade to Simple Catch Pro','simplecatch')); ?></a>
  765. </div>
  766. <div class="theme-social">
  767. <div class="widget-fb">
  768. <div data-show-faces="false" data-width="80" data-layout="button_count" data-send="false" data-href="<?php echo esc_url(__('http://facebook.com/catchthemes','simplecatch')); ?>" class="fb-like"></div>
  769. </div>
  770. <div class="widget-tw">
  771. <a data-dnt="true" data-show-screen-name="true" data-show-count="true" class="twitter-follow-button" href="<?php echo esc_url(__('https://twitter.com/catchthemes','simplecatch')); ?>">Follow @catchthemes</a>
  772. </div>
  773. </div>
  774. <div class="clear"></div>
  775. </div>
  776. <?php
  777. }
  778. /**
  779. * Altering Comment Form Fields
  780. * @uses comment_form_default_fields filter
  781. */
  782. function simplecatch_comment_form_fields( $fields ) {
  783. $req = get_option( 'require_name_email' );
  784. $aria_req = ( $req ? " aria-required='true'" : '' );
  785. $fields['author'] = '<label for="author">' . __('Name','simplecatch') . '</label><input type="text" class="text" placeholder="'.esc_attr__( 'Name', 'simplecatch' ) .'&nbsp;'. ( $req ? esc_attr__( '( required )', 'simplecatch' ) : '' ) .'" name="author"'. $aria_req .' />';
  786. $fields['email'] = '<label for="email">' . __('Email','simplecatch') . '</label><input type="text" class="text" placeholder="'.esc_attr__( 'Email', 'simplecatch' ) .'&nbsp;'. ( $req ? esc_attr__( '( required )', 'simplecatch' ) : '' ) .'" name="email"'. $aria_req .' />';
  787. $fields['url'] = '<label for="url">' . __('Website','simplecatch') . '</label><input type="text" class="text" placeholder="'.esc_attr__( 'Website', 'simplecatch' ) .'" name="url"'. $aria_req .' />';
  788. return $fields;
  789. }
  790. add_filter( 'comment_form_default_fields', 'simplecatch_comment_form_fields' );