/inc/catchresponsive-core.php

  1. <?php 
  2. /** 
  3. * Core functions and definitions 
  4. * 
  5. * Sets up the theme 
  6. * 
  7. * The first function, catchresponsive_initial_setup(), sets up the theme by registering support 
  8. * for various features in WordPress, such as theme support, post thumbnails, navigation menu, and the like. 
  9. * 
  10. * Catchresponsive functions and definitions 
  11. * 
  12. * @package Catch Themes 
  13. * @subpackage Catch Responsive 
  14. * @since Catch Responsive 1.0 
  15. */ 
  16.  
  17. if ( ! defined( 'CATCHRESPONSIVE_THEME_VERSION' ) ) { 
  18. header( 'Status: 403 Forbidden' ); 
  19. header( 'HTTP/1.1 403 Forbidden' ); 
  20. exit(); 
  21.  
  22.  
  23. if ( ! function_exists( 'catchresponsive_content_width' ) ) : 
  24. /** 
  25. * Set the content width in pixels, based on the theme's design and stylesheet. 
  26. * 
  27. * Priority 0 to make it available to lower priority callbacks. 
  28. * 
  29. * @global int $content_width 
  30. */ 
  31. function catchresponsive_content_width() { 
  32. $content_width = 780; /** pixels */ 
  33.  
  34. $GLOBALS['content_width'] = apply_filters( 'catchresponsive_content_width', $content_width ); 
  35. endif; 
  36. add_action( 'after_setup_theme', 'catchresponsive_content_width', 0 ); 
  37.  
  38.  
  39. if ( ! function_exists( 'catchresponsive_setup' ) ) : 
  40. /** 
  41. * Sets up theme defaults and registers support for various WordPress features. 
  42. * 
  43. * Note that this function is hooked into the after_setup_theme hook, which runs 
  44. * before the init hook. The init hook is too late for some features, such as indicating 
  45. * support post thumbnails. 
  46. */ 
  47. function catchresponsive_setup() { 
  48. /** 
  49. * Get Theme Options Values 
  50. */ 
  51. $options = catchresponsive_get_theme_options(); 
  52.  
  53. /** 
  54. * Make theme available for translation 
  55. * Translations can be filed in the /languages/ directory 
  56. * If you're building a theme based on catchresponsive, use a find and replace 
  57. * to change 'catch-responsive' to the name of your theme in all the template files 
  58. */ 
  59. load_theme_textdomain( 'catch-responsive', get_template_directory() . '/languages' ); 
  60.  
  61. /** 
  62. * Add default posts and comments RSS feed links to head 
  63. */ 
  64. add_theme_support( 'automatic-feed-links' ); 
  65.  
  66. /** 
  67. * Enable support for Post Thumbnails on posts and pages 
  68. * 
  69. * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails 
  70. */ 
  71. add_theme_support( 'post-thumbnails' ); 
  72.  
  73. // Add Catch Responsive's custom image sizes 
  74. add_image_size( 'catchresponsive-slider', 1200, 514, true ); // Used for Featured slider Ratio 21:9 
  75.  
  76. add_image_size( 'catchresponsive-featured-content', 350, 197, true ); // used in Featured Content Options Ratio 16:9 
  77.  
  78. //Archive Images 
  79. add_image_size( 'catchresponsive-featured', 860, 484, true); // used in Archive Top Ratio 16:9 
  80. add_image_size( 'catchresponsive-square', 200, 200, true ); // used in Archive Left/Right Ratio 1:1 
  81.  
  82. /** 
  83. * This theme uses wp_nav_menu() in one location. 
  84. */ 
  85. register_nav_menus( array( 
  86. 'primary' => __( 'Primary Menu', 'catch-responsive' ),  
  87. 'secondary' => __( 'Secondary Menu', 'catch-responsive' ),  
  88. ) ); 
  89.  
  90. /** 
  91. * Enable support for Post Formats 
  92. */ 
  93. add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) ); 
  94.  
  95. /** 
  96. * Setup the WordPress core custom background feature. 
  97. */ 
  98. if ( 'light' == $options['color_scheme'] ) { 
  99. $default_bg_color = catchresponsive_get_default_theme_options(); 
  100. $default_bg_color = $default_bg_color['background_color']; 
  101. $default_bg_image = 'body-bg.jpg'; 
  102. elseif ( 'dark' == $options['color_scheme'] ) { 
  103. $default_bg_color = catchresponsive_default_dark_color_options(); 
  104. $default_bg_color = $default_bg_color['background_color']; 
  105. $default_bg_image = 'body-bg-dark.jpg'; 
  106.  
  107. add_theme_support( 'custom-background', apply_filters( 'catchresponsive_custom_background_args', array( 
  108. 'default-color' => $default_bg_color,  
  109. 'default-image' => get_template_directory_uri() . '/images/' . $default_bg_image,  
  110. ) ) ); 
  111.  
  112. /** 
  113. * This theme styles the visual editor to resemble the theme style,  
  114. * specifically font, colors, icons, and column width. 
  115. */ 
  116. add_editor_style( array( 'css/editor-style.css', catchresponsive_fonts_url() ) ); 
  117.  
  118. /** 
  119. * Setup title support for theme 
  120. * Supported from WordPress version 4.1 onwards 
  121. * More Info: https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ 
  122. */ 
  123. add_theme_support( 'title-tag' ); 
  124.  
  125. //@remove Remove check when WordPress 4.8 is released 
  126. if ( function_exists( 'has_custom_logo' ) ) { 
  127. /** 
  128. * Setup Custom Logo Support for theme 
  129. * Supported from WordPress version 4.5 onwards 
  130. * More Info: https://make.wordpress.org/core/2016/03/10/custom-logo/ 
  131. */ 
  132. add_theme_support( 'custom-logo' ); 
  133.  
  134. /** 
  135. * Setup Infinite Scroll using JetPack if navigation type is set 
  136. */ 
  137. $pagination_type = $options['pagination_type']; 
  138.  
  139. if ( 'infinite-scroll-click' == $pagination_type ) { 
  140. add_theme_support( 'infinite-scroll', array( 
  141. 'type' => 'click',  
  142. 'container' => 'main',  
  143. 'footer' => 'page' 
  144. ) ); 
  145. elseif ( 'infinite-scroll-scroll' == $pagination_type ) { 
  146. //Override infinite scroll disable scroll option 
  147. update_option('infinite_scroll', true); 
  148.  
  149. add_theme_support( 'infinite-scroll', array( 
  150. 'type' => 'scroll',  
  151. 'container' => 'main',  
  152. 'footer' => 'page' 
  153. ) ); 
  154. endif; // catchresponsive_setup 
  155. add_action( 'after_setup_theme', 'catchresponsive_setup' ); 
  156.  
  157.  
  158. /** 
  159. * Return the Google font stylesheet URL, if available. 
  160. * 
  161. * The use of Open Sans and Droid Sans by default is localized. For languages 
  162. * that use characters not supported by the font, the font can be disabled. 
  163. * 
  164. * @since Catch Responsive 1.0 
  165. * 
  166. * @return string Font stylesheet or empty string if disabled. 
  167. */ 
  168. function catchresponsive_fonts_url() { 
  169. $fonts_url = ''; 
  170.  
  171. /** Translators: If there are characters in your language that are not 
  172. * supported by Open Sans, translate this to 'off'. Do not translate 
  173. * into your own language. 
  174. */ 
  175. $open_sans = _x( 'on', 'Open Sans font: on or off', 'catch-responsive' ); 
  176.  
  177. /** Translators: If there are characters in your language that are not 
  178. * supported by Droid Sans, translate this to 'off'. Do not translate into your 
  179. * own language. 
  180. */ 
  181. $droid_sans = _x( 'on', 'Droid Sans font: on or off', 'catch-responsive' ); 
  182.  
  183. if ( 'off' !== $open_sans || 'off' !== $droid_sans ) { 
  184. $font_families = array(); 
  185.  
  186. if ( 'off' !== $open_sans ) 
  187. $font_families[] = 'Open Sans:300, 400, 700, 300italic, 400italic, 700italic'; 
  188.  
  189. if ( 'off' !== $droid_sans ) 
  190. $font_families[] = 'Droid Sans:400, 700'; 
  191.  
  192. $query_args = array( 
  193. 'family' => urlencode( implode( '|', $font_families ) ),  
  194. 'subset' => urlencode( 'latin, latin-ext' ),  
  195. ); 
  196. $fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" ); 
  197.  
  198. return $fonts_url; 
  199.  
  200.  
  201. /** 
  202. * Enqueue scripts and styles 
  203. * 
  204. * @uses wp_register_script, wp_enqueue_script, wp_register_style, wp_enqueue_style, wp_localize_script 
  205. * @action wp_enqueue_scripts 
  206. * 
  207. * @since Catch Responsive 1.0 
  208. */ 
  209. function catchresponsive_scripts() { 
  210. $options = catchresponsive_get_theme_options(); 
  211.  
  212. // Add Source Sans Pro and Bitter fonts, used in the main stylesheet. 
  213. wp_enqueue_style( 'catchresponsive-fonts', catchresponsive_fonts_url(), array(), null ); 
  214.  
  215. wp_enqueue_style( 'catchresponsive-style', get_stylesheet_uri() ); 
  216.  
  217. wp_enqueue_script( 'catchresponsive-navigation', get_template_directory_uri() . '/js/navigation.min.js', array(), '20120206', true ); 
  218.  
  219. // Load the html5 shiv. 
  220. wp_enqueue_script( 'catchresponsive-html5', get_template_directory_uri() . '/js/html5.min.js', array(), '3.7.3' ); 
  221. wp_script_add_data( 'catchresponsive-html5', 'conditional', 'lt IE 9' ); 
  222.  
  223. wp_enqueue_script( 'catchresponsive-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.min.js', array(), '20130115', true ); 
  224.  
  225. /** 
  226. * Adds JavaScript to pages with the comment form to support 
  227. * sites with threaded comments (when in use). 
  228. */ 
  229. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 
  230. wp_enqueue_script( 'comment-reply' ); 
  231.  
  232. //For genericons 
  233. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/css/genericons/genericons.css', false, '3.4.1' ); 
  234.  
  235. /** 
  236. * Enqueue the styles for the current color scheme for catchresponsive. 
  237. */ 
  238. if ( $options['color_scheme'] != 'light' ) { 
  239. wp_enqueue_style( 'catchresponsive-dark', get_template_directory_uri() . '/css/colors/dark.css', array(), null ); 
  240.  
  241. /** 
  242. * Loads up Responsive Menu 
  243. */ 
  244. wp_enqueue_script( 'jquery-sidr', get_template_directory_uri() . '/js/jquery.sidr.min.js', array('jquery'), '2.2.1.1', false ); 
  245.  
  246. /** 
  247. * Loads default sidr color scheme styles(Does not require handle prefix) 
  248. */ 
  249. if ( 'dark' == $options['mobile_menu_color_scheme'] ) { 
  250. wp_enqueue_style( 'jquery-sidr', get_template_directory_uri() . '/css/jquery.sidr.dark.min.css', false, '2.1.0' ); 
  251. else { 
  252. wp_enqueue_style( 'jquery-sidr', get_template_directory_uri() . '/css/jquery.sidr.light.min.css', false, '2.1.0' ); 
  253.  
  254. wp_enqueue_script( 'jquery-fitvids', get_template_directory_uri() . '/js/fitvids.min.js', array( 'jquery' ), '1.1', true ); 
  255.  
  256.  
  257. /** 
  258. * Loads up Cycle JS 
  259. */ 
  260. if ( $options['featured_slider_option'] != 'disabled' ) { 
  261. wp_register_script( 'jquery.cycle2', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.min.js', array( 'jquery' ), '2.1.5', true ); 
  262.  
  263. /** 
  264. * Condition checks for additional slider transition plugins 
  265. */ 
  266. // Scroll Vertical transition plugin addition 
  267. if ( 'scrollVert' == $options['featured_slide_transition_effect'] ) { 
  268. wp_enqueue_script( 'jquery.cycle2.scrollVert', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.scrollVert.min.js', array( 'jquery.cycle2' ), '20140128', true ); 
  269. // Flip transition plugin addition 
  270. elseif ( 'flipHorz' == $options['featured_slide_transition_effect'] || 'flipVert' == $options['featured_slide_transition_effect'] ) { 
  271. wp_enqueue_script( 'jquery.cycle2.flip', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.flip.min.js', array( 'jquery.cycle2' ), '20140128', true ); 
  272. // Shuffle transition plugin addition 
  273. elseif ( 'tileSlide' == $options['featured_slide_transition_effect'] || 'tileBlind' == $options['featured_slide_transition_effect'] ) { 
  274. wp_enqueue_script( 'jquery.cycle2.tile', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.tile.min.js', array( 'jquery.cycle2' ), '20140128', true ); 
  275. // Shuffle transition plugin addition 
  276. elseif ( 'shuffle' == $options['featured_slide_transition_effect'] ) { 
  277. wp_enqueue_script( 'jquery.cycle2.shuffle', get_template_directory_uri() . '/js/jquery.cycle/jquery.cycle2.shuffle.min.js', array( 'jquery.cycle2' ), '20140128 ', true ); 
  278. else { 
  279. wp_enqueue_script( 'jquery.cycle2' ); 
  280.  
  281. /** 
  282. * Loads up Scroll Up script 
  283. */ 
  284. if ( ! $options['disable_scrollup'] ) { 
  285. wp_enqueue_script( 'catchresponsive-scrollup', get_template_directory_uri() . '/js/catchresponsive-scrollup.min.js', array( 'jquery' ), '20072014', true ); 
  286.  
  287. /** 
  288. * Enqueue custom script for catchresponsive. 
  289. */ 
  290. wp_enqueue_script( 'catchresponsive-custom-scripts', get_template_directory_uri() . '/js/catchresponsive-custom-scripts.min.js', array( 'jquery' ), null ); 
  291. add_action( 'wp_enqueue_scripts', 'catchresponsive_scripts' ); 
  292.  
  293.  
  294. /** 
  295. * Enqueue scripts and styles for Metaboxes 
  296. * @uses wp_register_script, wp_enqueue_script, and wp_enqueue_style 
  297. * 
  298. * @action admin_print_scripts-post-new, admin_print_scripts-post, admin_print_scripts-page-new, admin_print_scripts-page 
  299. * 
  300. * @since Catch Responsive 1.0 
  301. */ 
  302. function catchresponsive_enqueue_metabox_scripts() { 
  303. //Scripts 
  304. wp_enqueue_script( 'catchresponsive-metabox', get_template_directory_uri() . '/js/catchresponsive-metabox.min.js', array( 'jquery', 'jquery-ui-tabs' ), '2013-10-05' ); 
  305.  
  306. //CSS Styles 
  307. wp_enqueue_style( 'catchresponsive-metabox-tabs', get_template_directory_uri() . '/css/catchresponsive-metabox-tabs.css' ); 
  308. add_action( 'admin_print_scripts-post-new.php', 'catchresponsive_enqueue_metabox_scripts', 11 ); 
  309. add_action( 'admin_print_scripts-post.php', 'catchresponsive_enqueue_metabox_scripts', 11 ); 
  310. add_action( 'admin_print_scripts-page-new.php', 'catchresponsive_enqueue_metabox_scripts', 11 ); 
  311. add_action( 'admin_print_scripts-page.php', 'catchresponsive_enqueue_metabox_scripts', 11 ); 
  312.  
  313.  
  314. /** 
  315. * Default Options. 
  316. */ 
  317. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-default-options.php'; 
  318.  
  319. /** 
  320. * Custom Header. 
  321. */ 
  322. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-custom-header.php'; 
  323.  
  324.  
  325. /** 
  326. * Structure for catchresponsive 
  327. */ 
  328. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-structure.php'; 
  329.  
  330.  
  331. /** 
  332. * Customizer additions. 
  333. */ 
  334. require trailingslashit( get_template_directory() ) . 'inc/customizer-includes/catchresponsive-customizer.php'; 
  335.  
  336.  
  337. /** 
  338. * Custom Menus 
  339. */ 
  340. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-menus.php'; 
  341.  
  342.  
  343. /** 
  344. * Load Slider file. 
  345. */ 
  346. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-featured-slider.php'; 
  347.  
  348.  
  349. /** 
  350. * Load Featured Content. 
  351. */ 
  352. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-featured-content.php'; 
  353.  
  354.  
  355. /** 
  356. * Load Breadcrumb file. 
  357. */ 
  358. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-breadcrumb.php'; 
  359.  
  360.  
  361. /** 
  362. * Load Widgets and Sidebars 
  363. */ 
  364. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-widgets.php'; 
  365.  
  366.  
  367. /** 
  368. * Load Social Icons 
  369. */ 
  370. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-social-icons.php'; 
  371.  
  372.  
  373. /** 
  374. * Load Metaboxes 
  375. */ 
  376. require trailingslashit( get_template_directory() ) . 'inc/catchresponsive-metabox.php'; 
  377.  
  378.  
  379. /** 
  380. * Returns the options array for catchresponsive. 
  381. * @uses get_theme_mod 
  382. * 
  383. * @since Catch Responsive 1.0 
  384. */ 
  385. function catchresponsive_get_theme_options() { 
  386. $catchresponsive_default_options = catchresponsive_get_default_theme_options(); 
  387.  
  388. return array_merge( $catchresponsive_default_options , get_theme_mod( 'catchresponsive_theme_options', $catchresponsive_default_options ) ) ; 
  389.  
  390.  
  391. /** 
  392. * Flush out all transients 
  393. * 
  394. * @uses delete_transient 
  395. * 
  396. * @action customize_save, catchresponsive_customize_preview (see catchresponsive_customizer function: catchresponsive_customize_preview) 
  397. * 
  398. * @since Catch Responsive 1.0 
  399. */ 
  400. function catchresponsive_flush_transients() { 
  401. delete_transient( 'catchresponsive_featured_content' ); 
  402.  
  403. delete_transient( 'catchresponsive_featured_slider' ); 
  404.  
  405. //@remove Remove version check when WordPress 4.8 is released 
  406. delete_transient( 'catchresponsive_favicon' ); 
  407.  
  408. //@remove Remove version check when WordPress 4.8 is released 
  409. delete_transient( 'catchresponsive_webclip' ); 
  410.  
  411. delete_transient( 'catchresponsive_custom_css' ); 
  412.  
  413. delete_transient( 'catchresponsive_footer_content' ); 
  414.  
  415. delete_transient( 'catchresponsive_promotion_headline' ); 
  416.  
  417. delete_transient( 'catchresponsive_featured_image' ); 
  418.  
  419. delete_transient( 'catchresponsive_social_icons' ); 
  420.  
  421. delete_transient( 'catchresponsive_scrollup' ); 
  422.  
  423. delete_transient( 'all_the_cool_cats' ); 
  424.  
  425. //Add Catchresponsive default themes if there is no values 
  426. if ( !get_theme_mod('catchresponsive_theme_options') ) { 
  427. set_theme_mod( 'catchresponsive_theme_options', catchresponsive_get_default_theme_options() ); 
  428. add_action( 'customize_save', 'catchresponsive_flush_transients' ); 
  429.  
  430. /** 
  431. * Flush out category transients 
  432. * 
  433. * @uses delete_transient 
  434. * 
  435. * @action edit_category 
  436. * 
  437. * @since Catch Responsive 1.0 
  438. */ 
  439. function catchresponsive_flush_category_transients() { 
  440. delete_transient( 'all_the_cool_cats' ); 
  441. add_action( 'edit_category', 'catchresponsive_flush_category_transients' ); 
  442.  
  443.  
  444. /** 
  445. * Flush out post related transients 
  446. * 
  447. * @uses delete_transient 
  448. * 
  449. * @action save_post 
  450. * 
  451. * @since Catch Responsive 1.0 
  452. */ 
  453. function catchresponsive_flush_post_transients() { 
  454. delete_transient( 'catchresponsive_featured_content' ); 
  455.  
  456. delete_transient( 'catchresponsive_featured_slider' ); 
  457.  
  458. delete_transient( 'catchresponsive_featured_image' ); 
  459.  
  460. delete_transient( 'all_the_cool_cats' ); 
  461. add_action( 'save_post', 'catchresponsive_flush_post_transients' ); 
  462.  
  463.  
  464. if ( ! function_exists( 'catchresponsive_favicon' ) ) : 
  465. /** 
  466. * Get the favicon Image options 
  467. * 
  468. * @uses favicon 
  469. * @get the data value of image from options 
  470. * @display favicon 
  471. * 
  472. * @uses set_transient 
  473. * 
  474. * @action wp_head, admin_head 
  475. * 
  476. * @since Catch Responsive 1.0 
  477. * 
  478. * @remove Remove version check when WordPress 4.8 is released 
  479. */ 
  480. function catchresponsive_favicon() { 
  481. if ( ( !$catchresponsive_favicon = get_transient( 'catchresponsive_favicon' ) ) ) { 
  482. $options = catchresponsive_get_theme_options(); 
  483.  
  484. echo '<!-- refreshing cache -->'; 
  485.  
  486. if ( isset( $options[ 'favicon' ] ) && $options[ 'favicon' ] != '' && !empty( $options[ 'favicon' ] ) ) { 
  487. // if not empty fav_icon on options 
  488. $catchresponsive_favicon = '<link rel="shortcut icon" href="'.esc_url( $options[ 'favicon' ] ).'" type="image/x-icon" />'; 
  489.  
  490. set_transient( 'catchresponsive_favicon', $catchresponsive_favicon, 86940 ); 
  491. echo $catchresponsive_favicon ; 
  492. endif; //catchresponsive_favicon 
  493. //Load Favicon in Header Section 
  494. add_action( 'wp_head', 'catchresponsive_favicon' ); 
  495. //Load Favicon in Admin Section 
  496. add_action( 'admin_head', 'catchresponsive_favicon' ); 
  497.  
  498.  
  499. if ( ! function_exists( 'catchresponsive_web_clip' ) ) : 
  500. /** 
  501. * Get the Web Clip Icon Image from options 
  502. * 
  503. * @uses web_clip and remove_web_clip 
  504. * @get the data value of image from theme options 
  505. * @display web clip 
  506. * 
  507. * @uses default Web Click Icon if web_clip field on theme options is empty 
  508. * 
  509. * @uses set_transient and delete_transient 
  510. * 
  511. * @action wp_head 
  512. * 
  513. * @since Catch Responsive 1.0 
  514. * 
  515. * @remove Remove version check when WordPress 4.8 is released 
  516. */ 
  517. function catchresponsive_web_clip() { 
  518. if ( ( !$catchresponsive_web_clip = get_transient( 'catchresponsive_web_clip' ) ) ) { 
  519. $options = catchresponsive_get_theme_options(); 
  520.  
  521. echo '<!-- refreshing cache -->'; 
  522.  
  523. if ( isset( $options[ 'web_clip' ] ) && $options[ 'web_clip' ] != '' && !empty( $options[ 'web_clip' ] ) ) { 
  524. $catchresponsive_web_clip = '<link rel="apple-touch-icon-precomposed" href="'.esc_url( $options[ 'web_clip' ] ).'" />'; 
  525.  
  526. set_transient( 'catchresponsive_web_clip', $catchresponsive_web_clip, 86940 ); 
  527. echo $catchresponsive_web_clip ; 
  528. } // catchresponsive_web_clips 
  529. endif; //catchresponsive_web_clip 
  530. //Load Catchresponsive Icon in Header Section 
  531. add_action('wp_head', 'catchresponsive_web_clip'); 
  532.  
  533. if ( ! function_exists( 'catchresponsive_custom_css' ) ) : 
  534. /** 
  535. * Enqueue Custon CSS 
  536. * 
  537. * @uses set_transient, wp_head, wp_enqueue_style 
  538. * 
  539. * @action wp_enqueue_scripts 
  540. * 
  541. * @since Catch Responsive 1.0 
  542. */ 
  543. function catchresponsive_custom_css() { 
  544. //catchresponsive_flush_transients(); 
  545. $options = catchresponsive_get_theme_options(); 
  546.  
  547. $defaults = catchresponsive_get_default_theme_options(); 
  548.  
  549. if ( ( !$catchresponsive_custom_css = get_transient( 'catchresponsive_custom_css' ) ) ) { 
  550. $catchresponsive_custom_css =''; 
  551.  
  552. // Has the text been hidden? 
  553. if ( ! display_header_text() ) { 
  554. $catchresponsive_custom_css .= ".site-title a, .site-description { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px); }". "\n"; 
  555.  
  556. //Custom CSS Option 
  557. if ( !empty( $options[ 'custom_css' ] ) ) { 
  558. $catchresponsive_custom_css .= $options['custom_css'] . "\n"; 
  559.  
  560. if ( '' != $catchresponsive_custom_css ) { 
  561. echo '<!-- refreshing cache -->' . "\n"; 
  562.  
  563. $catchresponsive_custom_css = '<!-- '.get_bloginfo('name').' inline CSS Styles -->' . "\n" . '<style type="text/css" media="screen">' . "\n" . $catchresponsive_custom_css; 
  564.  
  565. $catchresponsive_custom_css .= '</style>' . "\n"; 
  566.  
  567.  
  568. set_transient( 'catchresponsive_custom_css', htmlspecialchars_decode( $catchresponsive_custom_css ), 86940 ); 
  569.  
  570. echo $catchresponsive_custom_css; 
  571. endif; //catchresponsive_custom_css 
  572. add_action( 'wp_head', 'catchresponsive_custom_css', 101 ); 
  573.  
  574.  
  575. if ( ! function_exists( 'catchresponsive_content_nav' ) ) : 
  576. /** 
  577. * Display navigation to next/previous pages when applicable 
  578. * 
  579. * @since Catch Responsive 1.0 
  580. */ 
  581. function catchresponsive_content_nav( $nav_id ) { 
  582. global $wp_query, $post; 
  583.  
  584. // Don't print empty markup on single pages if there's nowhere to navigate. 
  585. if ( is_single() ) { 
  586. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); 
  587. $next = get_adjacent_post( false, '', false ); 
  588.  
  589. if ( ! $next && ! $previous ) 
  590. return; 
  591.  
  592. // Don't print empty markup in archives if there's only one page. 
  593. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) { 
  594. return; 
  595.  
  596. $options = catchresponsive_get_theme_options(); 
  597.  
  598. $pagination_type = $options['pagination_type']; 
  599.  
  600. $nav_class = ( is_single() ) ? 'site-navigation post-navigation' : 'site-navigation paging-navigation'; 
  601.  
  602. /** 
  603. * Check if navigation type is Jetpack Infinite Scroll and if it is enabled, else goto default pagination 
  604. * if it's active then disable pagination 
  605. */ 
  606. if ( ( 'infinite-scroll-click' == $pagination_type || 'infinite-scroll-scroll' == $pagination_type ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'infinite-scroll' ) ) { 
  607. return false; 
  608.  
  609. ?> 
  610. <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>"> 
  611. <h3 class="screen-reader-text"><?php _e( 'Post navigation', 'catch-responsive' ); ?></h3> 
  612. <?php 
  613. /** 
  614. * Check if navigation type is numeric and if Wp-PageNavi Plugin is enabled 
  615. */ 
  616. if ( 'numeric' == $pagination_type && function_exists( 'wp_pagenavi' ) ) { 
  617. wp_pagenavi(); 
  618. else { ?> 
  619. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'catch-responsive' ) ); ?></div> 
  620. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'catch-responsive' ) ); ?></div> 
  621. <?php 
  622. } ?> 
  623. </nav><!-- #nav --> 
  624. <?php 
  625. endif; // catchresponsive_content_nav 
  626.  
  627.  
  628. if ( ! function_exists( 'catchresponsive_comment' ) ) : 
  629. /** 
  630. * Template for comments and pingbacks. 
  631. * 
  632. * Used as a callback by wp_list_comments() for displaying the comments. 
  633. * 
  634. * @since Catch Responsive 1.0 
  635. */ 
  636. function catchresponsive_comment( $comment, $args, $depth ) { 
  637. $GLOBALS['comment'] = $comment; 
  638.  
  639. if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?> 
  640.  
  641. <li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>> 
  642. <div class="comment-body"> 
  643. <?php _e( 'Pingback:', 'catch-responsive' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit', 'catch-responsive' ), '<span class="edit-link">', '</span>' ); ?> 
  644. </div> 
  645.  
  646. <?php else : ?> 
  647.  
  648. <li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>> 
  649. <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> 
  650. <footer class="comment-meta"> 
  651. <div class="comment-author vcard"> 
  652. <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> 
  653. <?php printf( __( '%s <span class="says">says:</span>', 'catch-responsive' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?> 
  654. </div><!-- .comment-author --> 
  655.  
  656. <div class="comment-metadata"> 
  657. <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> 
  658. <time datetime="<?php comment_time( 'c' ); ?>"> 
  659. <?php printf( _x( '%1$s at %2$s', '1: date, 2: time', 'catch-responsive' ), get_comment_date(), get_comment_time() ); ?> 
  660. </time> 
  661. </a> 
  662. <?php edit_comment_link( __( 'Edit', 'catch-responsive' ), '<span class="edit-link">', '</span>' ); ?> 
  663. </div><!-- .comment-metadata --> 
  664.  
  665. <?php if ( '0' == $comment->comment_approved ) : ?> 
  666. <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'catch-responsive' ); ?></p> 
  667. <?php endif; ?> 
  668. </footer><!-- .comment-meta --> 
  669.  
  670. <div class="comment-content"> 
  671. <?php comment_text(); ?> 
  672. </div><!-- .comment-content --> 
  673.  
  674. <?php 
  675. comment_reply_link( array_merge( $args, array( 
  676. 'add_below' => 'div-comment',  
  677. 'depth' => $depth,  
  678. 'max_depth' => $args['max_depth'],  
  679. 'before' => '<div class="reply">',  
  680. 'after' => '</div>',  
  681. ) ) ); 
  682. ?> 
  683. </article><!-- .comment-body --> 
  684.  
  685. <?php 
  686. endif; 
  687. endif; // catchresponsive_comment() 
  688.  
  689.  
  690. if ( ! function_exists( 'catchresponsive_the_attached_image' ) ) : 
  691. /** 
  692. * Prints the attached image with a link to the next attached image. 
  693. * 
  694. * @since Catch Responsive 1.0 
  695. */ 
  696. function catchresponsive_the_attached_image() { 
  697. $post = get_post(); 
  698. $attachment_size = apply_filters( 'catchresponsive_attachment_size', array( 1200, 1200 ) ); 
  699. $next_attachment_url = wp_get_attachment_url(); 
  700.  
  701. /** 
  702. * Grab the IDs of all the image attachments in a gallery so we can get the 
  703. * URL of the next adjacent image in a gallery, or the first image (if 
  704. * we're looking at the last image in a gallery), or, in a gallery of one,  
  705. * just the link to that image file. 
  706. */ 
  707. $attachment_ids = get_posts( array( 
  708. 'post_parent' => $post->post_parent,  
  709. 'fields' => 'ids',  
  710. 'numberposts' => 1,  
  711. 'post_status' => 'inherit',  
  712. 'post_type' => 'attachment',  
  713. 'post_mime_type' => 'image',  
  714. 'order' => 'ASC',  
  715. 'orderby' => 'menu_order ID' 
  716. ) ); 
  717.  
  718. // If there is more than 1 attachment in a gallery... 
  719. if ( count( $attachment_ids ) > 1 ) { 
  720. foreach ( $attachment_ids as $attachment_id ) { 
  721. if ( $attachment_id == $post->ID ) { 
  722. $next_id = current( $attachment_ids ); 
  723. break; 
  724.  
  725. // get the URL of the next image attachment... 
  726. if ( $next_id ) 
  727. $next_attachment_url = get_attachment_link( $next_id ); 
  728.  
  729. // or get the URL of the first image attachment. 
  730. else 
  731. $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); 
  732.  
  733. printf( '<a href="%1$s" title="%2$s" rel="attachment">%3$s</a>',  
  734. esc_url( $next_attachment_url ),  
  735. the_title_attribute( array( 'echo' => false ) ),  
  736. wp_get_attachment_image( $post->ID, $attachment_size ) 
  737. ); 
  738. endif; //catchresponsive_the_attached_image 
  739.  
  740.  
  741. if ( ! function_exists( 'catchresponsive_entry_meta' ) ) : 
  742. /** 
  743. * Prints HTML with meta information for the current post-date/time and author. 
  744. * 
  745. * @since Catch Responsive 1.0 
  746. */ 
  747. function catchresponsive_entry_meta() { 
  748. echo '<p class="entry-meta">'; 
  749.  
  750. $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; 
  751.  
  752. if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { 
  753. $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; 
  754.  
  755. $time_string = sprintf( $time_string,  
  756. esc_attr( get_the_date( 'c' ) ),  
  757. esc_html( get_the_date() ),  
  758. esc_attr( get_the_modified_date( 'c' ) ),  
  759. esc_html( get_the_modified_date() ) 
  760. ); 
  761.  
  762. printf( '<span class="posted-on">%1$s<a href="%2$s" rel="bookmark">%3$s</a></span>',  
  763. sprintf( __( '<span class="screen-reader-text">Posted on</span>', 'catch-responsive' ) ),  
  764. esc_url( get_permalink() ),  
  765. $time_string 
  766. ); 
  767.  
  768. if ( is_singular() || is_multi_author() ) { 
  769. printf( '<span class="byline"><span class="author vcard">%1$s<a class="url fn n" href="%2$s">%3$s</a></span></span>',  
  770. sprintf( __( '<span class="screen-reader-text">Author</span>', 'catch-responsive' ) ),  
  771. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),  
  772. esc_html( get_the_author() ) 
  773. ); 
  774.  
  775. if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) { 
  776. echo '<span class="comments-link">'; 
  777. comments_popup_link( esc_html__( 'Leave a comment', 'catch-responsive' ), esc_html__( '1 Comment', 'catch-responsive' ), esc_html__( '% Comments', 'catch-responsive' ) ); 
  778. echo '</span>'; 
  779.  
  780. edit_post_link( esc_html__( 'Edit', 'catch-responsive' ), '<span class="edit-link">', '</span>' ); 
  781.  
  782. echo '</p><!-- .entry-meta -->'; 
  783. endif; //catchresponsive_entry_meta 
  784.  
  785.  
  786. if ( ! function_exists( 'catchresponsive_tag_category' ) ) : 
  787. /** 
  788. * Prints HTML with meta information for the categories, tags. 
  789. * 
  790. * @since Catch Responsive 1.0 
  791. */ 
  792. function catchresponsive_tag_category() { 
  793. echo '<p class="entry-meta">'; 
  794.  
  795. if ( 'post' == get_post_type() ) { 
  796. $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'catch-responsive' ) ); 
  797. if ( $categories_list && catchresponsive_categorized_blog() ) { 
  798. printf( '<span class="cat-links">%1$s%2$s</span>',  
  799. sprintf( _x( '<span class="screen-reader-text">Categories</span>', 'Used before category names.', 'catch-responsive' ) ),  
  800. $categories_list 
  801. ); 
  802.  
  803. $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'catch-responsive' ) ); 
  804. if ( $tags_list ) { 
  805. printf( '<span class="tags-links">%1$s%2$s</span>',  
  806. sprintf( _x( '<span class="screen-reader-text">Tags</span>', 'Used before tag names.', 'catch-responsive' ) ),  
  807. $tags_list 
  808. ); 
  809.  
  810. echo '</p><!-- .entry-meta -->'; 
  811. endif; //catchresponsive_tag_category 
  812.  
  813.  
  814. if ( ! function_exists( 'catchresponsive_categorized_blog' ) ) : 
  815. /** 
  816. * Returns true if a blog has more than 1 category 
  817. * 
  818. * @since Catch Responsive 1.0 
  819. */ 
  820. function catchresponsive_categorized_blog() { 
  821. if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) { 
  822. // Create an array of all the categories that are attached to posts 
  823. $all_the_cool_cats = get_categories( array( 
  824. 'hide_empty' => 1,  
  825. ) ); 
  826.  
  827. // Count the number of categories that are attached to the posts 
  828. $all_the_cool_cats = count( $all_the_cool_cats ); 
  829.  
  830. set_transient( 'all_the_cool_cats', $all_the_cool_cats ); 
  831.  
  832. if ( '1' != $all_the_cool_cats ) { 
  833. // This blog has more than 1 category so catchresponsive_categorized_blog should return true 
  834. return true; 
  835. } else { 
  836. // This blog has only 1 category so catchresponsive_categorized_blog should return false 
  837. return false; 
  838. endif; //catchresponsive_categorized_blog 
  839.  
  840.  
  841. /** 
  842. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. 
  843. * 
  844. * @since Catch Responsive 1.0 
  845. */ 
  846. function catchresponsive_page_menu_args( $args ) { 
  847. $args['show_home'] = true; 
  848. return $args; 
  849. add_filter( 'wp_page_menu_args', 'catchresponsive_page_menu_args' ); 
  850.  
  851.  
  852. /** 
  853. * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages 
  854. * 
  855. * @since Catch Responsive 1.0 
  856. */ 
  857. function catchresponsive_enhanced_image_navigation( $url, $id ) { 
  858. if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) 
  859. return $url; 
  860.  
  861. $image = get_post( $id ); 
  862. if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) 
  863. $url .= '#main'; 
  864.  
  865. return $url; 
  866. add_filter( 'attachment_link', 'catchresponsive_enhanced_image_navigation', 10, 2 ); 
  867.  
  868.  
  869. /** 
  870. * Count the number of footer sidebars to enable dynamic classes for the footer 
  871. * 
  872. * @since Catch Responsive 1.0 
  873. */ 
  874. function catchresponsive_footer_sidebar_class() { 
  875. $count = 0; 
  876.  
  877. if ( is_active_sidebar( 'footer-1' ) ) 
  878. $count++; 
  879.  
  880. if ( is_active_sidebar( 'footer-2' ) ) 
  881. $count++; 
  882.  
  883. if ( is_active_sidebar( 'footer-3' ) ) 
  884. $count++; 
  885.  
  886. if ( is_active_sidebar( 'footer-4' ) ) 
  887. $count++; 
  888.  
  889. $class = ''; 
  890.  
  891. switch ( $count ) { 
  892. case '1': 
  893. $class = 'one'; 
  894. break; 
  895. case '2': 
  896. $class = 'two'; 
  897. break; 
  898. case '3': 
  899. $class = 'three'; 
  900. break; 
  901. case '4': 
  902. $class = 'four'; 
  903. break; 
  904.  
  905. if ( $class ) 
  906. echo 'class="' . $class . '"'; 
  907.  
  908.  
  909. if ( ! function_exists( 'catchresponsive_excerpt_length' ) ) : 
  910. /** 
  911. * Sets the post excerpt length to n words. 
  912. * 
  913. * function tied to the excerpt_length filter hook. 
  914. * @uses filter excerpt_length 
  915. * 
  916. * @since Catch Responsive 1.0 
  917. */ 
  918. function catchresponsive_excerpt_length( $length ) { 
  919. // Getting data from Customizer Options 
  920. $options = catchresponsive_get_theme_options(); 
  921. $length = $options['excerpt_length']; 
  922. return $length; 
  923. endif; //catchresponsive_excerpt_length 
  924. add_filter( 'excerpt_length', 'catchresponsive_excerpt_length' ); 
  925.  
  926.  
  927. if ( ! function_exists( 'catchresponsive_continue_reading' ) ) : 
  928. /** 
  929. * Returns a "Custom Continue Reading" link for excerpts 
  930. * 
  931. * @since Catch Responsive 1.0 
  932. */ 
  933. function catchresponsive_continue_reading() { 
  934. // Getting data from Customizer Options 
  935. $options = catchresponsive_get_theme_options(); 
  936. $more_tag_text = $options['excerpt_more_text']; 
  937.  
  938. return ' <a class="more-link" href="'. esc_url( get_permalink() ) . '">' . sprintf( __( '%s', 'catch-responsive' ) , $more_tag_text ) . '</a>'; 
  939. endif; //catchresponsive_continue_reading 
  940. add_filter( 'excerpt_more', 'catchresponsive_continue_reading' ); 
  941.  
  942.  
  943. if ( ! function_exists( 'catchresponsive_excerpt_more' ) ) : 
  944. /** 
  945. * Replaces "[...]" (appended to automatically generated excerpts) with catchresponsive_continue_reading(). 
  946. * 
  947. * @since Catch Responsive 1.0 
  948. */ 
  949. function catchresponsive_excerpt_more( $more ) { 
  950. return catchresponsive_continue_reading(); 
  951. endif; //catchresponsive_excerpt_more 
  952. add_filter( 'excerpt_more', 'catchresponsive_excerpt_more' ); 
  953.  
  954.  
  955. if ( ! function_exists( 'catchresponsive_custom_excerpt' ) ) : 
  956. /** 
  957. * Adds Continue Reading link to more tag excerpts. 
  958. * 
  959. * function tied to the get_the_excerpt filter hook. 
  960. * 
  961. * @since Catch Responsive 1.0 
  962. */ 
  963. function catchresponsive_custom_excerpt( $output ) { 
  964. if ( has_excerpt() && ! is_attachment() ) { 
  965. $output .= catchresponsive_continue_reading(); 
  966. return $output; 
  967. endif; //catchresponsive_custom_excerpt 
  968. add_filter( 'get_the_excerpt', 'catchresponsive_custom_excerpt' ); 
  969.  
  970.  
  971. if ( ! function_exists( 'catchresponsive_more_link' ) ) : 
  972. /** 
  973. * Replacing Continue Reading link to the_content more. 
  974. * 
  975. * function tied to the the_content_more_link filter hook. 
  976. * 
  977. * @since Catch Responsive 1.0 
  978. */ 
  979. function catchresponsive_more_link( $more_link, $more_link_text ) { 
  980. $options = catchresponsive_get_theme_options(); 
  981. $more_tag_text = $options['excerpt_more_text']; 
  982.  
  983. return str_replace( $more_link_text, $more_tag_text, $more_link ); 
  984. endif; //catchresponsive_more_link 
  985. add_filter( 'the_content_more_link', 'catchresponsive_more_link', 10, 2 ); 
  986.  
  987.  
  988. if ( ! function_exists( 'catchresponsive_body_classes' ) ) : 
  989. /** 
  990. * Adds Catchresponsive layout classes to the array of body classes. 
  991. * 
  992. * @since Catch Responsive 1.0 
  993. */ 
  994. function catchresponsive_body_classes( $classes ) { 
  995. $options = catchresponsive_get_theme_options(); 
  996.  
  997. // Adds a class of group-blog to blogs with more than 1 published author 
  998. if ( is_multi_author() ) { 
  999. $classes[] = 'group-blog'; 
  1000.  
  1001. $layout = catchresponsive_get_theme_layout(); 
  1002.  
  1003. switch ( $layout ) { 
  1004. case 'left-sidebar': 
  1005. $classes[] = 'two-columns content-right'; 
  1006. break; 
  1007.  
  1008. case 'right-sidebar': 
  1009. $classes[] = 'two-columns content-left'; 
  1010. break; 
  1011.  
  1012. case 'no-sidebar': 
  1013. $classes[] = 'no-sidebar content-width'; 
  1014. break; 
  1015.  
  1016. case 'no-sidebar-one-column': 
  1017. $classes[] = 'no-sidebar one-column'; 
  1018. break; 
  1019.  
  1020. case 'no-sidebar-full-width': 
  1021. $classes[] = 'no-sidebar full-width'; 
  1022. break; 
  1023.  
  1024. if ( "" != $options['content_layout'] ) { 
  1025. $classes[] = $options['content_layout']; 
  1026.  
  1027. //Count number of menus avaliable and set class accordingly 
  1028. $mobile_menu_count = 1; // For primary menu 
  1029.  
  1030. if ( has_nav_menu( 'secondary' ) ) { 
  1031. $mobile_menu_count++; 
  1032.  
  1033. if ( has_nav_menu( 'header-right' ) ) { 
  1034. $mobile_menu_count++; 
  1035.  
  1036. switch ( $mobile_menu_count ) { 
  1037. case 1: 
  1038. $classes[] = 'mobile-menu-one'; 
  1039. break; 
  1040.  
  1041. case 2: 
  1042. $classes[] = 'mobile-menu-two'; 
  1043. break; 
  1044.  
  1045. case 3: 
  1046. $classes[] = 'mobile-menu-three'; 
  1047. break; 
  1048.  
  1049. $classes = apply_filters( 'catchresponsive_body_classes', $classes ); 
  1050.  
  1051. return $classes; 
  1052. endif; //catchresponsive_body_classes 
  1053. add_filter( 'body_class', 'catchresponsive_body_classes' ); 
  1054.  
  1055.  
  1056. if ( ! function_exists( 'catchresponsive_get_theme_layout' ) ) : 
  1057. /** 
  1058. * Returns Theme Layout prioritizing the meta box layouts 
  1059. * 
  1060. * @uses get_theme_mod 
  1061. * 
  1062. * @action wp_head 
  1063. * 
  1064. * @since Catch Responsive 3.8.1 
  1065. */ 
  1066. function catchresponsive_get_theme_layout() { 
  1067. $id = ''; 
  1068.  
  1069. global $post, $wp_query; 
  1070.  
  1071. // Front page displays in Reading Settings 
  1072. $page_on_front = get_option('page_on_front') ; 
  1073. $page_for_posts = get_option('page_for_posts'); 
  1074.  
  1075. // Get Page ID outside Loop 
  1076. $page_id = $wp_query->get_queried_object_id(); 
  1077.  
  1078. // Blog Page or Front Page setting in Reading Settings 
  1079. if ( $page_id == $page_for_posts || $page_id == $page_on_front ) { 
  1080. $id = $page_id; 
  1081. elseif ( is_singular() ) { 
  1082. if ( is_attachment() ) { 
  1083. $id = $post->post_parent; 
  1084. else { 
  1085. $id = $post->ID; 
  1086.  
  1087. //Get appropriate metabox value of layout 
  1088. if ( '' != $id ) { 
  1089. $layout = get_post_meta( $id, 'catchresponsive-layout-option', true ); 
  1090. else { 
  1091. $layout = 'default'; 
  1092.  
  1093. //Load options data 
  1094. $options = catchresponsive_get_theme_options(); 
  1095.  
  1096. //check empty and load default 
  1097. if ( empty( $layout ) || 'default' == $layout ) { 
  1098. $layout = $options['theme_layout']; 
  1099.  
  1100. return $layout; 
  1101. endif; //catchresponsive_get_theme_layout 
  1102.  
  1103.  
  1104. if ( ! function_exists( 'catchresponsive_archive_content_image' ) ) : 
  1105. /** 
  1106. * Template for Featured Image in Archive Content 
  1107. * 
  1108. * To override this in a child theme 
  1109. * simply create your own catchresponsive_archive_content_image(), and that function will be used instead. 
  1110. * 
  1111. * @since Catch Responsive 1.0 
  1112. */ 
  1113. function catchresponsive_archive_content_image() { 
  1114. $options = catchresponsive_get_theme_options(); 
  1115.  
  1116. $featured_image = $options['content_layout']; 
  1117.  
  1118. if ( has_post_thumbnail() && 'excerpt-image-left' == $featured_image ) { 
  1119. ?> 
  1120. <figure class="featured-image"> 
  1121. <a rel="bookmark" href="<?php the_permalink(); ?>"> 
  1122. <?php 
  1123. the_post_thumbnail( 'catchresponsive-square' ); 
  1124. ?> 
  1125. </a> 
  1126. </figure> 
  1127. <?php 
  1128. endif; //catchresponsive_archive_content_image 
  1129. add_action( 'catchresponsive_before_entry_container', 'catchresponsive_archive_content_image', 10 ); 
  1130.  
  1131.  
  1132. if ( ! function_exists( 'catchresponsive_single_content_image' ) ) : 
  1133. /** 
  1134. * Template for Featured Image in Single Post 
  1135. * 
  1136. * To override this in a child theme 
  1137. * simply create your own catchresponsive_single_content_image(), and that function will be used instead. 
  1138. * 
  1139. * @since Catch Responsive 1.0 
  1140. */ 
  1141. function catchresponsive_single_content_image() { 
  1142. global $post, $wp_query; 
  1143.  
  1144. // Getting data from Theme Options 
  1145. $options = catchresponsive_get_theme_options(); 
  1146.  
  1147. $featured_image = $options['single_post_image_layout']; 
  1148.  
  1149. // Get Page ID outside Loop 
  1150. $page_id = $wp_query->get_queried_object_id(); 
  1151.  
  1152. if ( $post ) { 
  1153. if ( is_attachment() ) { 
  1154. $parent = $post->post_parent; 
  1155. $individual_featured_image = get_post_meta( $parent, 'catchresponsive-featured-image', true ); 
  1156. } else { 
  1157. $individual_featured_image = get_post_meta( $page_id, 'catchresponsive-featured-image', true ); 
  1158.  
  1159. if ( empty( $individual_featured_image ) || ( !is_page() && !is_single() ) ) { 
  1160. $individual_featured_image = 'default'; 
  1161.  
  1162. if ( ( 'disable' == $individual_featured_image || '' == get_the_post_thumbnail() || ( $individual_featured_image=='default' && 'disabled' == $featured_image) ) ) { 
  1163. echo '<!-- Page/Post Single Image Disabled or No Image set in Post Thumbnail -->'; 
  1164. return false; 
  1165. else { 
  1166. $class = ''; 
  1167.  
  1168. if ( 'default' == $individual_featured_image ) { 
  1169. $class = $featured_image; 
  1170. else { 
  1171. $class = 'from-metabox ' . $individual_featured_image; 
  1172.  
  1173. ?> 
  1174. <figure class="featured-image <?php echo $class; ?>"> 
  1175. <?php 
  1176. if ( 'featured' == $individual_featured_image || ( $individual_featured_image=='default' && 'featured' == $featured_image ) ) { 
  1177. the_post_thumbnail( 'catchresponsive-featured' ); 
  1178. else { 
  1179. the_post_thumbnail( 'full' ); 
  1180. } ?> 
  1181. </figure> 
  1182. <?php 
  1183. endif; //catchresponsive_single_content_image 
  1184. add_action( 'catchresponsive_before_post_container', 'catchresponsive_single_content_image', 10 ); 
  1185. add_action( 'catchresponsive_before_page_container', 'catchresponsive_single_content_image', 10 ); 
  1186.  
  1187.  
  1188. if ( ! function_exists( 'catchresponsive_get_comment_section' ) ) : 
  1189. /** 
  1190. * Comment Section 
  1191. * 
  1192. * @display comments_template 
  1193. * @action catchresponsive_comment_section 
  1194. * 
  1195. * @since Catch Responsive 1.0 
  1196. */ 
  1197. function catchresponsive_get_comment_section() { 
  1198. if ( comments_open() || '0' != get_comments_number() ) 
  1199. comments_template(); 
  1200. endif; 
  1201. add_action( 'catchresponsive_comment_section', 'catchresponsive_get_comment_section', 10 ); 
  1202.  
  1203.  
  1204. if ( ! function_exists( 'catchresponsive_promotion_headline' ) ) : 
  1205. /** 
  1206. * Template for Promotion Headline 
  1207. * 
  1208. * To override this in a child theme 
  1209. * simply create your own catchresponsive_promotion_headline(), and that function will be used instead. 
  1210. * 
  1211. * @uses catchresponsive_before_main action to add it in the header 
  1212. * @since Catch Responsive 1.0 
  1213. */ 
  1214. function catchresponsive_promotion_headline() { 
  1215. //delete_transient( 'catchresponsive_promotion_headline' ); 
  1216.  
  1217. global $post, $wp_query; 
  1218. $options = catchresponsive_get_theme_options(); 
  1219.  
  1220. $promotion_headline = $options['promotion_headline']; 
  1221. $promotion_subheadline = $options['promotion_subheadline']; 
  1222. $promotion_headline_button = $options['promotion_headline_button']; 
  1223. $promotion_headline_target = $options['promotion_headline_target']; 
  1224. $enablepromotion = $options['promotion_headline_option']; 
  1225.  
  1226. //support qTranslate plugin 
  1227. if ( function_exists( 'qtrans_convertURL' ) ) { 
  1228. $promotion_headline_url = qtrans_convertURL($options[ 'promotion_headline_url' ]); 
  1229. else { 
  1230. $promotion_headline_url = $options[ 'promotion_headline_url' ]; 
  1231.  
  1232. // Front page displays in Reading Settings 
  1233. $page_on_front = get_option( 'page_on_front' ) ; 
  1234. $page_for_posts = get_option('page_for_posts'); 
  1235.  
  1236. // Get Page ID outside Loop 
  1237. $page_id = $wp_query->get_queried_object_id(); 
  1238.  
  1239. if ( ( "" != $promotion_headline || "" != $promotion_subheadline || "" != $promotion_headline_url ) && ( 'entire-site' == $enablepromotion || ( ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) && 'homepage' == $enablepromotion ) ) ) { 
  1240.  
  1241. if ( !$catchresponsive_promotion_headline = get_transient( 'catchresponsive_promotion_headline' ) ) { 
  1242.  
  1243. echo '<!-- refreshing cache -->'; 
  1244.  
  1245. $catchresponsive_promotion_headline = ' 
  1246. <div id="promotion-message"> 
  1247. <div class="wrapper"> 
  1248. <div class="section left">'; 
  1249.  
  1250. if ( "" != $promotion_headline ) { 
  1251. $catchresponsive_promotion_headline .= '<h2>' . $promotion_headline . '</h2>'; 
  1252.  
  1253. if ( "" != $promotion_subheadline ) { 
  1254. $catchresponsive_promotion_headline .= '<p>' . $promotion_subheadline . '</p>'; 
  1255.  
  1256. $catchresponsive_promotion_headline .= ' 
  1257. </div><!-- .section.left -->'; 
  1258.  
  1259. if ( "" != $promotion_headline_url ) { 
  1260. if ( "1" == $promotion_headline_target ) { 
  1261. $headlinetarget = '_blank'; 
  1262. else { 
  1263. $headlinetarget = '_self'; 
  1264.  
  1265. $catchresponsive_promotion_headline .= ' 
  1266. <div class="section right"> 
  1267. <a class="promotion-button" href="' . esc_url( $promotion_headline_url ) . '" target="' . $headlinetarget . '">' . esc_attr( $promotion_headline_button ) . ' 
  1268. </a> 
  1269. </div><!-- .section.right -->'; 
  1270.  
  1271. $catchresponsive_promotion_headline .= ' 
  1272. </div><!-- .wrapper --> 
  1273. </div><!-- #promotion-message -->'; 
  1274.  
  1275. set_transient( 'catchresponsive_promotion_headline', $catchresponsive_promotion_headline, 86940 ); 
  1276. echo $catchresponsive_promotion_headline; 
  1277. endif; // catchresponsive_promotion_featured_content 
  1278. add_action( 'catchresponsive_before_content', 'catchresponsive_promotion_headline', 30 ); 
  1279.  
  1280.  
  1281. /** 
  1282. * Footer Text 
  1283. * 
  1284. * @get footer text from theme options and display them accordingly 
  1285. * @display footer_text 
  1286. * @action catchresponsive_footer 
  1287. * 
  1288. * @since Catch Responsive 1.0 
  1289. */ 
  1290. function catchresponsive_footer_content() { 
  1291. //catchresponsive_flush_transients(); 
  1292. if ( ( !$catchresponsive_footer_content = get_transient( 'catchresponsive_footer_content' ) ) ) { 
  1293. echo '<!-- refreshing cache -->'; 
  1294.  
  1295. $catchresponsive_content = catchresponsive_get_content(); 
  1296.  
  1297. $catchresponsive_footer_content = ' 
  1298. <div id="site-generator"> 
  1299. <div class="wrapper"> 
  1300. <div id="footer-content" class="copyright">' 
  1301. . $catchresponsive_content['left'] . ' | ' . $catchresponsive_content['right'] . 
  1302. '</div> 
  1303. </div><!-- .wrapper --> 
  1304. </div><!-- #site-generator -->'; 
  1305.  
  1306. set_transient( 'catchresponsive_footer_content', $catchresponsive_footer_content, 86940 ); 
  1307.  
  1308. echo $catchresponsive_footer_content; 
  1309. add_action( 'catchresponsive_footer', 'catchresponsive_footer_content', 100 ); 
  1310.  
  1311.  
  1312. /** 
  1313. * Return the first image in a post. Works inside a loop. 
  1314. * @param [integer] $post_id [Post or page id] 
  1315. * @param [string/array] $size Image size. Either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32, 32). 
  1316. * @param [string/array] $attr Query string or array of attributes. 
  1317. * @return [string] image html 
  1318. * 
  1319. * @since Catch Responsive 1.0 
  1320. */ 
  1321.  
  1322. function catchresponsive_get_first_image( $postID, $size, $attr ) { 
  1323. ob_start(); 
  1324.  
  1325. ob_end_clean(); 
  1326.  
  1327. $image = ''; 
  1328.  
  1329. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_post_field('post_content', $postID ) , $matches); 
  1330.  
  1331. if ( isset( $matches [1] [0] ) ) { 
  1332. //Get first image 
  1333. $first_img = $matches [1] [0]; 
  1334.  
  1335. return '<img class="pngfix wp-post-image" src="'. esc_url( $first_img ) .'">'; 
  1336. else { 
  1337. return false; 
  1338.  
  1339.  
  1340. if ( ! function_exists( 'catchresponsive_scrollup' ) ) { 
  1341. /** 
  1342. * This function loads Scroll Up Navigation 
  1343. * 
  1344. * @action catchresponsive_footer action 
  1345. * @uses set_transient and delete_transient 
  1346. */ 
  1347. function catchresponsive_scrollup() { 
  1348. //catchresponsive_flush_transients(); 
  1349. if ( !$catchresponsive_scrollup = get_transient( 'catchresponsive_scrollup' ) ) { 
  1350.  
  1351. // get the data value from theme options 
  1352. $options = catchresponsive_get_theme_options(); 
  1353. echo '<!-- refreshing cache -->'; 
  1354.  
  1355. //site stats, analytics header code 
  1356. if ( ! $options['disable_scrollup'] ) { 
  1357. $catchresponsive_scrollup = '<a href="#masthead" id="scrollup" class="genericon"><span class="screen-reader-text">' . __( 'Scroll Up', 'catch-responsive' ) . '</span></a>' ; 
  1358.  
  1359. set_transient( 'catchresponsive_scrollup', $catchresponsive_scrollup, 86940 ); 
  1360. echo $catchresponsive_scrollup; 
  1361. add_action( 'catchresponsive_after', 'catchresponsive_scrollup', 10 ); 
  1362.  
  1363.  
  1364. if ( ! function_exists( 'catchresponsive_page_post_meta' ) ) : 
  1365. /** 
  1366. * Post/Page Meta for Google Structure Data 
  1367. */ 
  1368. function catchresponsive_page_post_meta() { 
  1369. $catchresponsive_author_url = esc_url( get_author_posts_url( get_the_author_meta( "ID" ) ) ); 
  1370.  
  1371. $catchresponsive_page_post_meta = '<span class="post-time">' . __( 'Posted on', 'catch-responsive' ) . ' <time class="entry-date updated" datetime="' . esc_attr( get_the_date( 'c' ) ) . '" pubdate>' . esc_html( get_the_date() ) . '</time></span>'; 
  1372. $catchresponsive_page_post_meta .= '<span class="post-author">' . __( 'By', 'catch-responsive' ) . ' <span class="author vcard"><a class="url fn n" href="' . $catchresponsive_author_url . '" title="View all posts by ' . get_the_author() . '" rel="author">' .get_the_author() . '</a></span>'; 
  1373.  
  1374. return $catchresponsive_page_post_meta; 
  1375. endif; //catchresponsive_page_post_meta 
  1376.  
  1377.  
  1378. if ( ! function_exists( 'catchresponsive_alter_home' ) ) : 
  1379. /** 
  1380. * Alter the query for the main loop in homepage 
  1381. * 
  1382. * @action pre_get_posts action 
  1383. */ 
  1384. function catchresponsive_alter_home( $query ) { 
  1385. $options = catchresponsive_get_theme_options(); 
  1386.  
  1387. $cats = $options[ 'front_page_category' ]; 
  1388.  
  1389. if ( is_array( $cats ) && !in_array( '0', $cats ) ) { 
  1390. if ( $query->is_main_query() && $query->is_home() ) { 
  1391. $query->query_vars['category__in'] = $options[ 'front_page_category' ]; 
  1392. endif; //catchresponsive_alter_home 
  1393. add_action( 'pre_get_posts', 'catchresponsive_alter_home' ); 
  1394.  
  1395.  
  1396. if ( ! function_exists( 'catchresponsive_post_navigation' ) ) : 
  1397. /** 
  1398. * Displays Single post Navigation 
  1399. * 
  1400. * @uses the_post_navigation 
  1401. * 
  1402. * @action catchresponsive_after_post 
  1403. * 
  1404. * @since Catch Responsive 1.6 
  1405. */ 
  1406. function catchresponsive_post_navigation() { 
  1407. // Previous/next post navigation. 
  1408. if ( function_exists( 'the_post_navigation' ) ) { 
  1409. the_post_navigation( array( 
  1410. 'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next →', 'catch-responsive' ) . '</span> ' . 
  1411. '<span class="screen-reader-text">' . __( 'Next post:', 'catch-responsive' ) . '</span> ' . 
  1412. '<span class="post-title">%title</span>',  
  1413. 'prev_text' => '<span class="meta-nav" aria-hidden="true">' . __( '← Previous', 'catch-responsive' ) . '</span> ' . 
  1414. '<span class="screen-reader-text">' . __( 'Previous post:', 'catch-responsive' ) . '</span> ' . 
  1415. '<span class="post-title">%title</span>',  
  1416. ) ); 
  1417. else { 
  1418. // Don't print empty markup if there's nowhere to navigate. 
  1419. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); 
  1420. $next = get_adjacent_post( false, '', false ); 
  1421.  
  1422. if ( ! $next && ! $previous ) { 
  1423. return; 
  1424. ?> 
  1425. <nav class="navigation post-navigation" role="navigation"> 
  1426. <h2 class="screen-reader-text"><?php esc_html_e( 'Post navigation', 'catch-responsive' ); ?></h2> 
  1427. <div class="nav-links"> 
  1428. <?php 
  1429. previous_post_link( '<div class="nav-previous">%link</div>', '%title' ); 
  1430. next_post_link( '<div class="nav-next">%link</div>', '%title' ); 
  1431. ?> 
  1432. </div><!-- .nav-links --> 
  1433. </nav><!-- .navigation --> 
  1434. <?php 
  1435. endif; //catchresponsive_post_navigation 
  1436. add_action( 'catchresponsive_after_post', 'catchresponsive_post_navigation', 10 ); 
  1437.  
  1438.  
  1439. /** 
  1440. * Migrate Logo to New WordPress core Custom Logo 
  1441. * 
  1442. * 
  1443. * Runs if version number saved in theme_mod "logo_version" doesn't match current theme version. 
  1444. */ 
  1445. function catchresponsive_logo_migrate() { 
  1446. $ver = get_theme_mod( 'logo_version', false ); 
  1447.  
  1448. // Return if update has already been run 
  1449. if ( version_compare( $ver, '2.8' ) >= 0 ) { 
  1450. return; 
  1451.  
  1452. /** 
  1453. * Get Theme Options Values 
  1454. */ 
  1455. $options = catchresponsive_get_theme_options(); 
  1456.  
  1457. // If a logo has been set previously, update to use logo feature introduced in WordPress 4.5 
  1458. if ( function_exists( 'the_custom_logo' ) ) { 
  1459. if ( isset( $options['logo'] ) && '' != $options['logo'] ) { 
  1460. // Since previous logo was stored a URL, convert it to an attachment ID 
  1461. $logo = attachment_url_to_postid( $options['logo'] ); 
  1462.  
  1463. if ( is_int( $logo ) ) { 
  1464. set_theme_mod( 'custom_logo', $logo ); 
  1465.  
  1466. // Update to match logo_version so that script is not executed continously 
  1467. set_theme_mod( 'logo_version', '2.8' ); 
  1468.  
  1469. add_action( 'after_setup_theme', 'catchresponsive_logo_migrate' ); 
  1470.  
  1471.  
  1472. /** 
  1473. * Migrate Custom Favicon to WordPress core Site Icon 
  1474. * 
  1475. * Runs if version number saved in theme_mod "site_icon_version" doesn't match current theme version. 
  1476. */ 
  1477. function catchresponsive_site_icon_migrate() { 
  1478. $ver = get_theme_mod( 'site_icon_version', false ); 
  1479.  
  1480. // Return if update has already been run 
  1481. if ( version_compare( $ver, '2.8' ) >= 0 ) { 
  1482. return; 
  1483.  
  1484. /** 
  1485. * Get Theme Options Values 
  1486. */ 
  1487. $options = catchresponsive_get_theme_options(); 
  1488.  
  1489. // If a logo has been set previously, update to use logo feature introduced in WordPress 4.5 
  1490. if ( function_exists( 'has_site_icon' ) ) { 
  1491. if ( isset( $options['favicon'] ) && '' != $options['favicon'] ) { 
  1492. // Since previous logo was stored a URL, convert it to an attachment ID 
  1493. $site_icon = attachment_url_to_postid( $options['favicon'] ); 
  1494.  
  1495. if ( is_int( $site_icon ) ) { 
  1496. update_option( 'site_icon', $site_icon ); 
  1497.  
  1498. // Update to match site_icon_version so that script is not executed continously 
  1499. set_theme_mod( 'site_icon_version', '2.8' ); 
  1500. add_action( 'after_setup_theme', 'catchresponsive_site_icon_migrate' ); 
  1501.  
  1502.  
  1503. /** 
  1504. * Migrate Custom CSS to WordPress core Custom CSS 
  1505. * 
  1506. * Runs if version number saved in theme_mod "custom_css_version" doesn't match current theme version. 
  1507. */ 
  1508. function catchresponsive_custom_css_migrate() { 
  1509. $ver = get_theme_mod( 'custom_css_version', false ); 
  1510.  
  1511. // Return if update has already been run 
  1512. if ( version_compare( $ver, '4.7' ) >= 0 ) { 
  1513. return; 
  1514.  
  1515. if ( function_exists( 'wp_update_custom_css_post' ) ) { 
  1516. // Migrate any existing theme CSS to the core option added in WordPress 4.7. 
  1517.  
  1518. /** 
  1519. * Get Theme Options Values 
  1520. */ 
  1521. $options = catchresponsive_get_theme_options(); 
  1522.  
  1523. if ( '' != $options['custom_css'] ) { 
  1524. $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option. 
  1525. $return = wp_update_custom_css_post( $core_css . $options['custom_css'] ); 
  1526. if ( ! is_wp_error( $return ) ) { 
  1527. // Remove the old theme_mod, so that the CSS is stored in only one place moving forward. 
  1528. unset( $options['custom_css'] ); 
  1529. set_theme_mod( 'catchresponsive_theme_options', $options ); 
  1530.  
  1531. // Update to match custom_css_version so that script is not executed continously 
  1532. set_theme_mod( 'custom_css_version', '4.7' ); 
  1533. add_action( 'after_setup_theme', 'catchresponsive_custom_css_migrate' ); 
.