PageRenderTime 85ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/themes/responsive/core/includes/functions.php

https://github.com/mattyws/InfocorpSite
PHP | 1081 lines | 688 code | 171 blank | 222 comment | 109 complexity | a61e94654487f051d13b731d864d95af MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, LGPL-2.1
  1. <?php
  2. // Exit if accessed directly
  3. if ( !defined( 'ABSPATH' ) ) {
  4. exit;
  5. }
  6. /**
  7. * Theme's Functions and Definitions
  8. *
  9. *
  10. * @file functions.php
  11. * @package Responsive
  12. * @author Emil Uzelac
  13. * @copyright 2003 - 2014 CyberChimps
  14. * @license license.txt
  15. * @version Release: 1.2.1
  16. * @filesource wp-content/themes/responsive/includes/functions.php
  17. * @link http://codex.wordpress.org/Theme_Development#Functions_File
  18. * @since available since Release 1.0
  19. */
  20. ?>
  21. <?php
  22. /*
  23. * Globalize Theme options
  24. */
  25. $responsive_options = responsive_get_options();
  26. /**
  27. * Add plugin automation file
  28. */
  29. require_once( dirname( __FILE__ ) . '/classes/class-tgm-plugin-activation.php' );
  30. /*
  31. * Hook options
  32. */
  33. add_action( 'admin_init', 'responsive_theme_options_init' );
  34. add_action( 'admin_menu', 'responsive_theme_options_add_page' );
  35. /**
  36. * Retrieve Theme option settings
  37. */
  38. function responsive_get_options() {
  39. // Globalize the variable that holds the Theme options
  40. global $responsive_options;
  41. // Parse array of option defaults against user-configured Theme options
  42. $responsive_options = wp_parse_args( get_option( 'responsive_theme_options', array() ), responsive_get_option_defaults() );
  43. // Return parsed args array
  44. return $responsive_options;
  45. }
  46. /**
  47. * Responsive Theme option defaults
  48. */
  49. function responsive_get_option_defaults() {
  50. $defaults = array(
  51. 'breadcrumb' => false,
  52. 'cta_button' => false,
  53. 'minified_css' => false,
  54. 'front_page' => 1,
  55. 'home_headline' => null,
  56. 'home_subheadline' => null,
  57. 'home_content_area' => null,
  58. 'cta_text' => null,
  59. 'cta_url' => null,
  60. 'featured_content' => null,
  61. 'google_site_verification' => '',
  62. 'bing_site_verification' => '',
  63. 'yahoo_site_verification' => '',
  64. 'site_statistics_tracker' => '',
  65. 'twitter_uid' => '',
  66. 'facebook_uid' => '',
  67. 'linkedin_uid' => '',
  68. 'youtube_uid' => '',
  69. 'stumble_uid' => '',
  70. 'rss_uid' => '',
  71. 'google_plus_uid' => '',
  72. 'instagram_uid' => '',
  73. 'pinterest_uid' => '',
  74. 'yelp_uid' => '',
  75. 'vimeo_uid' => '',
  76. 'foursquare_uid' => '',
  77. 'responsive_inline_css' => '',
  78. 'responsive_inline_js_head' => '',
  79. 'responsive_inline_css_js_footer' => '',
  80. 'static_page_layout_default' => 'default',
  81. 'single_post_layout_default' => 'default',
  82. 'blog_posts_index_layout_default' => 'default',
  83. );
  84. return apply_filters( 'responsive_option_defaults', $defaults );
  85. }
  86. /**
  87. * Helps file locations in child themes. If the file is not being overwritten by the child theme then
  88. * return the parent theme location of the file. Great for images.
  89. *
  90. * @param $dir string directory
  91. *
  92. * @return string complete uri
  93. */
  94. function responsive_child_uri( $dir ) {
  95. if ( is_child_theme() ) {
  96. $directory = get_stylesheet_directory() . $dir;
  97. $test = is_file( $directory );
  98. if ( is_file( $directory ) ) {
  99. $file = get_stylesheet_directory_uri() . $dir;
  100. } else {
  101. $file = get_template_directory_uri() . $dir;
  102. }
  103. } else {
  104. $file = get_template_directory_uri() . $dir;
  105. }
  106. return $file;
  107. }
  108. /**
  109. * Fire up the engines boys and girls let's start theme setup.
  110. */
  111. add_action( 'after_setup_theme', 'responsive_setup' );
  112. if ( !function_exists( 'responsive_setup' ) ):
  113. function responsive_setup() {
  114. global $content_width;
  115. $template_directory = get_template_directory();
  116. /**
  117. * Global content width.
  118. */
  119. if ( !isset( $content_width ) ) {
  120. $content_width = 550;
  121. }
  122. /**
  123. * Responsive is now available for translations.
  124. * The translation files are in the /languages/ directory.
  125. * Translations are pulled from the WordPress default lanaguge folder
  126. * then from the child theme and then lastly from the parent theme.
  127. * @see http://codex.wordpress.org/Function_Reference/load_theme_textdomain
  128. */
  129. $domain = 'responsive';
  130. load_theme_textdomain( $domain, WP_LANG_DIR . '/responsive/' );
  131. load_theme_textdomain( $domain, get_stylesheet_directory() . '/languages/' );
  132. load_theme_textdomain( $domain, get_template_directory() . '/languages/' );
  133. /**
  134. * Add callback for custom TinyMCE editor stylesheets. (editor-style.css)
  135. * @see http://codex.wordpress.org/Function_Reference/add_editor_style
  136. */
  137. add_editor_style();
  138. /**
  139. * This feature enables post and comment RSS feed links to head.
  140. * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Feed_Links
  141. */
  142. add_theme_support( 'automatic-feed-links' );
  143. /**
  144. * This feature enables post-thumbnail support for a theme.
  145. * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  146. */
  147. add_theme_support( 'post-thumbnails' );
  148. /**
  149. * This feature enables woocommerce support for a theme.
  150. * @see http://www.woothemes.com/2013/02/last-call-for-testing-woocommerce-2-0-coming-march-4th/
  151. */
  152. add_theme_support( 'woocommerce' );
  153. /**
  154. * This feature enables custom-menus support for a theme.
  155. * @see http://codex.wordpress.org/Function_Reference/register_nav_menus
  156. */
  157. register_nav_menus( array(
  158. 'top-menu' => __( 'Top Menu', 'responsive' ),
  159. 'header-menu' => __( 'Header Menu', 'responsive' ),
  160. 'sub-header-menu' => __( 'Sub-Header Menu', 'responsive' ),
  161. 'footer-menu' => __( 'Footer Menu', 'responsive' )
  162. ) );
  163. add_theme_support( 'custom-background' );
  164. add_theme_support( 'custom-header', array(
  165. // Header image default
  166. 'default-image' => get_template_directory_uri() . '/core/images/default-logo.png',
  167. // Header text display default
  168. 'header-text' => false,
  169. // Header image flex width
  170. 'flex-width' => true,
  171. // Header image width (in pixels)
  172. 'width' => 300,
  173. // Header image flex height
  174. 'flex-height' => true,
  175. // Header image height (in pixels)
  176. 'height' => 100,
  177. // Admin header style callback
  178. 'admin-head-callback' => 'responsive_admin_header_style'
  179. ) );
  180. // gets included in the admin header
  181. function responsive_admin_header_style() {
  182. ?>
  183. <style type="text/css">
  184. .appearance_page_custom-header #headimg {
  185. background-repeat: no-repeat;
  186. border: none;
  187. }
  188. </style><?php
  189. }
  190. // While upgrading set theme option front page toggle not to affect old setup.
  191. $responsive_options = get_option( 'responsive_theme_options' );
  192. if ( $responsive_options && isset( $_GET['activated'] ) ) {
  193. // If front_page is not in theme option previously then set it.
  194. if ( !isset( $responsive_options['front_page'] ) ) {
  195. // Get template of page which is set as static front page
  196. $template = get_post_meta( get_option( 'page_on_front' ), '_wp_page_template', true );
  197. // If static front page template is set to default then set front page toggle of theme option to 1
  198. if ( 'page' == get_option( 'show_on_front' ) && $template == 'default' ) {
  199. $responsive_options['front_page'] = 1;
  200. } else {
  201. $responsive_options['front_page'] = 0;
  202. }
  203. update_option( 'responsive_theme_options', $responsive_options );
  204. }
  205. }
  206. }
  207. endif;
  208. /**
  209. * Set a fallback menu that will show a home link.
  210. */
  211. function responsive_fallback_menu() {
  212. $args = array(
  213. 'depth' => 0,
  214. 'sort_column' => 'menu_order, post_title',
  215. 'menu_class' => 'menu',
  216. 'include' => '',
  217. 'exclude' => '',
  218. 'echo' => false,
  219. 'show_home' => true,
  220. 'link_before' => '',
  221. 'link_after' => ''
  222. );
  223. $pages = wp_page_menu( $args );
  224. $prepend = '<div class="main-nav">';
  225. $append = '</div>';
  226. $output = $prepend . $pages . $append;
  227. echo $output;
  228. }
  229. /**
  230. * This function removes .menu class from custom menus
  231. * in widgets only and fallback's on default widget lists
  232. * and assigns new unique class called .menu-widget
  233. *
  234. * Marko Heijnen Contribution
  235. *
  236. */
  237. class responsive_widget_menu_class {
  238. public function __construct() {
  239. add_action( 'widget_display_callback', array( $this, 'menu_different_class' ), 10, 2 );
  240. }
  241. public function menu_different_class( $settings, $widget ) {
  242. if ( $widget instanceof WP_Nav_Menu_Widget ) {
  243. add_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ) );
  244. }
  245. return $settings;
  246. }
  247. public function wp_nav_menu_args( $args ) {
  248. remove_filter( 'wp_nav_menu_args', array( $this, 'wp_nav_menu_args' ) );
  249. if ( 'menu' == $args['menu_class'] ) {
  250. $args['menu_class'] = apply_filters( 'responsive_menu_widget_class', 'menu-widget' );
  251. }
  252. return $args;
  253. }
  254. }
  255. $GLOBALS['nav_menu_widget_classname'] = new responsive_widget_menu_class();
  256. /**
  257. * Removes div from wp_page_menu() and replace with ul.
  258. */
  259. function responsive_wp_page_menu( $page_markup ) {
  260. preg_match( '/^<div class=\"([a-z0-9-_]+)\">/i', $page_markup, $matches );
  261. $divclass = $matches[1];
  262. $replace = array( '<div class="' . $divclass . '">', '</div>' );
  263. $new_markup = str_replace( $replace, '', $page_markup );
  264. $new_markup = preg_replace( '/^<ul>/i', '<ul class="' . $divclass . '">', $new_markup );
  265. return $new_markup;
  266. }
  267. add_filter( 'wp_page_menu', 'responsive_wp_page_menu' );
  268. /**
  269. * wp_title() Filter for better SEO.
  270. *
  271. * Adopted from Twenty Twelve
  272. * @see http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title
  273. *
  274. */
  275. if ( !function_exists( 'responsive_wp_title' ) && !defined( 'AIOSEOP_VERSION' ) ) :
  276. function responsive_wp_title( $title, $sep ) {
  277. global $page, $paged;
  278. if ( is_feed() ) {
  279. return $title;
  280. }
  281. // Add the site name.
  282. $title .= get_bloginfo( 'name' );
  283. // Add the site description for the home/front page.
  284. $site_description = get_bloginfo( 'description', 'display' );
  285. if ( $site_description && ( is_home() || is_front_page() ) ) {
  286. $title .= " $sep $site_description";
  287. }
  288. // Add a page number if necessary.
  289. if ( $paged >= 2 || $page >= 2 ) {
  290. $title .= " $sep " . sprintf( __( 'Page %s', 'responsive' ), max( $paged, $page ) );
  291. }
  292. return $title;
  293. }
  294. add_filter( 'wp_title', 'responsive_wp_title', 10, 2 );
  295. endif;
  296. /**
  297. * Filter 'get_comments_number'
  298. *
  299. * Filter 'get_comments_number' to display correct
  300. * number of comments (count only comments, not
  301. * trackbacks/pingbacks)
  302. *
  303. * Chip Bennett Contribution
  304. */
  305. function responsive_comment_count( $count ) {
  306. if ( !is_admin() ) {
  307. global $id;
  308. $comments = get_comments( 'status=approve&post_id=' . $id );
  309. $comments_by_type = separate_comments( $comments );
  310. return count( $comments_by_type['comment'] );
  311. } else {
  312. return $count;
  313. }
  314. }
  315. add_filter( 'get_comments_number', 'responsive_comment_count', 0 );
  316. /**
  317. * wp_list_comments() Pings Callback
  318. *
  319. * wp_list_comments() Callback function for
  320. * Pings (Trackbacks/Pingbacks)
  321. */
  322. function responsive_comment_list_pings( $comment ) {
  323. $GLOBALS['comment'] = $comment;
  324. ?>
  325. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
  326. <?php
  327. }
  328. /**
  329. * Sets the post excerpt length to 40 words.
  330. * Adopted from Coraline
  331. */
  332. function responsive_excerpt_length( $length ) {
  333. return 40;
  334. }
  335. add_filter( 'excerpt_length', 'responsive_excerpt_length' );
  336. /**
  337. * Returns a "Read more" link for excerpts
  338. */
  339. function responsive_read_more() {
  340. return '<div class="read-more"><a href="' . get_permalink() . '">' . __( 'Read more &#8250;', 'responsive' ) . '</a></div><!-- end of .read-more -->';
  341. }
  342. /**
  343. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and responsive_read_more_link().
  344. */
  345. function responsive_auto_excerpt_more( $more ) {
  346. return '<span class="ellipsis">&hellip;</span>' . responsive_read_more();
  347. }
  348. add_filter( 'excerpt_more', 'responsive_auto_excerpt_more' );
  349. /**
  350. * Adds a pretty "Read more" link to custom post excerpts.
  351. */
  352. function responsive_custom_excerpt_more( $output ) {
  353. if ( has_excerpt() && !is_attachment() ) {
  354. $output .= responsive_read_more();
  355. }
  356. return $output;
  357. }
  358. add_filter( 'get_the_excerpt', 'responsive_custom_excerpt_more' );
  359. /**
  360. * This function removes inline styles set by WordPress gallery.
  361. */
  362. function responsive_remove_gallery_css( $css ) {
  363. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  364. }
  365. add_filter( 'gallery_style', 'responsive_remove_gallery_css' );
  366. /**
  367. * This function removes default styles set by WordPress recent comments widget.
  368. */
  369. function responsive_remove_recent_comments_style() {
  370. global $wp_widget_factory;
  371. if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) {
  372. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  373. }
  374. }
  375. add_action( 'widgets_init', 'responsive_remove_recent_comments_style' );
  376. /**
  377. * This function prints post meta data.
  378. *
  379. * Ulrich Pogson Contribution
  380. *
  381. */
  382. if ( !function_exists( 'responsive_post_meta_data' ) ) {
  383. function responsive_post_meta_data() {
  384. printf( __( '<span class="%1$s">Posted on </span>%2$s<span class="%3$s"> by </span>%4$s', 'responsive' ),
  385. 'meta-prep meta-prep-author posted',
  386. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="timestamp updated" datetime="%3$s">%4$s</time></a>',
  387. esc_url( get_permalink() ),
  388. esc_attr( get_the_title() ),
  389. esc_html( get_the_date('c')),
  390. esc_html( get_the_date() )
  391. ),
  392. 'byline',
  393. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  394. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  395. sprintf( esc_attr__( 'View all posts by %s', 'responsive' ), get_the_author() ),
  396. esc_attr( get_the_author() )
  397. )
  398. );
  399. }
  400. }
  401. /**
  402. * This function removes WordPress generated category and tag atributes.
  403. * For W3C validation purposes only.
  404. *
  405. */
  406. function responsive_category_rel_removal( $output ) {
  407. $output = str_replace( ' rel="category tag"', '', $output );
  408. return $output;
  409. }
  410. add_filter( 'wp_list_categories', 'responsive_category_rel_removal' );
  411. add_filter( 'the_category', 'responsive_category_rel_removal' );
  412. /**
  413. * Breadcrumb Lists
  414. * Load the plugin from the plugin that is installed.
  415. *
  416. */
  417. function get_responsive_breadcrumb_lists() {
  418. $responsive_options = get_option( 'responsive_theme_options' );
  419. $yoast_options = get_option( 'wpseo_internallinks' );
  420. if ( 1 == $responsive_options['breadcrumb'] ) {
  421. return;
  422. } elseif ( function_exists( 'bcn_display' ) ) {
  423. bcn_display();
  424. } elseif ( function_exists( 'breadcrumb_trail' ) ) {
  425. breadcrumb_trail();
  426. } elseif ( function_exists( 'yoast_breadcrumb' ) && true === $yoast_options['breadcrumbs-enable'] ) {
  427. yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
  428. } elseif ( ! is_search() ) {
  429. responsive_breadcrumb_lists();
  430. }
  431. }
  432. /**
  433. * Breadcrumb Lists
  434. * Allows visitors to quickly navigate back to a previous section or the root page.
  435. *
  436. * Adopted from Dimox
  437. *
  438. */
  439. if ( !function_exists( 'responsive_breadcrumb_lists' ) ) {
  440. function responsive_breadcrumb_lists() {
  441. /* === OPTIONS === */
  442. $text['home'] = __( 'Home', 'responsive' ); // text for the 'Home' link
  443. $text['category'] = __( 'Archive for %s', 'responsive' ); // text for a category page
  444. $text['search'] = __( 'Search results for: %s', 'responsive' ); // text for a search results page
  445. $text['tag'] = __( 'Posts tagged %s', 'responsive' ); // text for a tag page
  446. $text['author'] = __( 'View all posts by %s', 'responsive' ); // text for an author page
  447. $text['404'] = __( 'Error 404', 'responsive' ); // text for the 404 page
  448. $show['current'] = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
  449. $show['home'] = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
  450. $delimiter = ' <span class="chevron">&#8250;</span> '; // delimiter between crumbs
  451. $before = '<span class="breadcrumb-current">'; // tag before the current crumb
  452. $after = '</span>'; // tag after the current crumb
  453. /* === END OF OPTIONS === */
  454. $home_link = home_url( '/' );
  455. $before_link = '<span class="breadcrumb" typeof="v:Breadcrumb">';
  456. $after_link = '</span>';
  457. $link_att = ' rel="v:url" property="v:title"';
  458. $link = $before_link . '<a' . $link_att . ' href="%1$s">%2$s</a>' . $after_link;
  459. $post = get_queried_object();
  460. $parent_id = isset( $post->post_parent ) ? $post->post_parent : '';
  461. $html_output = '';
  462. if ( is_front_page() ) {
  463. if ( 1 == $show['home'] ) {
  464. $html_output .= '<div class="breadcrumb-list"><a href="' . $home_link . '">' . $text['home'] . '</a></div>';
  465. }
  466. } else {
  467. $html_output .= '<div class="breadcrumb-list" xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf( $link, $home_link, $text['home'] ) . $delimiter;
  468. if ( is_home() ) {
  469. if ( 1 == $show['current'] ) {
  470. $html_output .= $before . get_the_title( get_option( 'page_for_posts', true ) ) . $after;
  471. }
  472. } elseif ( is_category() ) {
  473. $this_cat = get_category( get_query_var( 'cat' ), false );
  474. if ( 0 != $this_cat->parent ) {
  475. $cats = get_category_parents( $this_cat->parent, true, $delimiter );
  476. $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats );
  477. $cats = str_replace( '</a>', '</a>' . $after_link, $cats );
  478. $html_output .= $cats;
  479. }
  480. $html_output .= $before . sprintf( $text['category'], single_cat_title( '', false ) ) . $after;
  481. } elseif ( is_search() ) {
  482. $html_output .= $before . sprintf( $text['search'], get_search_query() ) . $after;
  483. } elseif ( is_day() ) {
  484. $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter;
  485. $html_output .= sprintf( $link, get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ), get_the_time( 'F' ) ) . $delimiter;
  486. $html_output .= $before . get_the_time( 'd' ) . $after;
  487. } elseif ( is_month() ) {
  488. $html_output .= sprintf( $link, get_year_link( get_the_time( 'Y' ) ), get_the_time( 'Y' ) ) . $delimiter;
  489. $html_output .= $before . get_the_time( 'F' ) . $after;
  490. } elseif ( is_year() ) {
  491. $html_output .= $before . get_the_time( 'Y' ) . $after;
  492. } elseif ( is_single() && !is_attachment() ) {
  493. if ( 'post' != get_post_type() ) {
  494. $post_type = get_post_type_object( get_post_type() );
  495. $archive_link = get_post_type_archive_link( $post_type->name );
  496. $html_output .= sprintf( $link, $archive_link, $post_type->labels->singular_name );
  497. if ( 1 == $show['current'] ) {
  498. $html_output .= $delimiter . $before . get_the_title() . $after;
  499. }
  500. } else {
  501. $cat = get_the_category();
  502. $cat = $cat[0];
  503. $cats = get_category_parents( $cat, true, $delimiter );
  504. if ( 0 == $show['current'] ) {
  505. $cats = preg_replace( "#^(.+)$delimiter$#", "$1", $cats );
  506. }
  507. $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats );
  508. $cats = str_replace( '</a>', '</a>' . $after_link, $cats );
  509. $html_output .= $cats;
  510. if ( 1 == $show['current'] ) {
  511. $html_output .= $before . get_the_title() . $after;
  512. }
  513. }
  514. } elseif ( !is_single() && !is_page() && !is_404() && 'post' != get_post_type() ) {
  515. $post_type = get_post_type_object( get_post_type() );
  516. $html_output .= $before . $post_type->labels->singular_name . $after;
  517. } elseif ( is_attachment() ) {
  518. $parent = get_post( $parent_id );
  519. $cat = get_the_category( $parent->ID );
  520. if ( isset( $cat[0] ) ) {
  521. $cat = $cat[0];
  522. }
  523. if ( $cat ) {
  524. $cats = get_category_parents( $cat, true, $delimiter );
  525. $cats = str_replace( '<a', $before_link . '<a' . $link_att, $cats );
  526. $cats = str_replace( '</a>', '</a>' . $after_link, $cats );
  527. $html_output .= $cats;
  528. }
  529. $html_output .= sprintf( $link, get_permalink( $parent ), $parent->post_title );
  530. if ( 1 == $show['current'] ) {
  531. $html_output .= $delimiter . $before . get_the_title() . $after;
  532. }
  533. } elseif ( is_page() && !$parent_id ) {
  534. if ( 1 == $show['current'] ) {
  535. $html_output .= $before . get_the_title() . $after;
  536. }
  537. } elseif ( is_page() && $parent_id ) {
  538. $breadcrumbs = array();
  539. while ( $parent_id ) {
  540. $page_child = get_page( $parent_id );
  541. $breadcrumbs[] = sprintf( $link, get_permalink( $page_child->ID ), get_the_title( $page_child->ID ) );
  542. $parent_id = $page_child->post_parent;
  543. }
  544. $breadcrumbs = array_reverse( $breadcrumbs );
  545. for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
  546. $html_output .= $breadcrumbs[$i];
  547. if ( $i != count( $breadcrumbs ) - 1 ) {
  548. $html_output .= $delimiter;
  549. }
  550. }
  551. if ( 1 == $show['current'] ) {
  552. $html_output .= $delimiter . $before . get_the_title() . $after;
  553. }
  554. } elseif ( is_tag() ) {
  555. $html_output .= $before . sprintf( $text['tag'], single_tag_title( '', false ) ) . $after;
  556. } elseif ( is_author() ) {
  557. $user_id = get_query_var( 'author' );
  558. $userdata = get_the_author_meta( 'display_name', $user_id );
  559. $html_output .= $before . sprintf( $text['author'], $userdata ) . $after;
  560. } elseif ( is_404() ) {
  561. $html_output .= $before . $text['404'] . $after;
  562. }
  563. if ( get_query_var( 'paged' ) || get_query_var( 'page' ) ) {
  564. $page_num = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );
  565. $html_output .= $delimiter . sprintf( __( 'Page %s', 'responsive' ), $page_num );
  566. }
  567. $html_output .= '</div>';
  568. }
  569. echo $html_output;
  570. } // end responsive_breadcrumb_lists
  571. }
  572. /**
  573. * A safe way of adding stylesheets to a WordPress generated page.
  574. */
  575. if ( !function_exists( 'responsive_css' ) ) {
  576. function responsive_css() {
  577. $theme = wp_get_theme();
  578. $responsive = wp_get_theme( 'responsive' );
  579. $responsive_options = responsive_get_options();
  580. if ( 1 == $responsive_options['minified_css'] ) {
  581. wp_enqueue_style( 'responsive-style', get_template_directory_uri() . '/core/css/style.min.css', false, $responsive['Version'] );
  582. } else {
  583. wp_enqueue_style( 'responsive-style', get_template_directory_uri() . '/core/css/style.css', false, $responsive['Version'] );
  584. wp_enqueue_style( 'responsive-media-queries', get_template_directory_uri() . '/core/css/responsive.css', false, $responsive['Version'] );
  585. }
  586. if ( is_rtl() ) {
  587. wp_enqueue_style( 'responsive-rtl-style', get_template_directory_uri() . '/rtl.css', false, $responsive['Version'] );
  588. }
  589. if ( is_child_theme() ) {
  590. wp_enqueue_style( 'responsive-child-style', get_stylesheet_uri(), false, $theme['Version'] );
  591. }
  592. }
  593. }
  594. add_action( 'wp_enqueue_scripts', 'responsive_css' );
  595. /**
  596. * A safe way of adding JavaScripts to a WordPress generated page.
  597. */
  598. if ( !function_exists( 'responsive_js' ) ) {
  599. function responsive_js() {
  600. $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
  601. $directory = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'js-dev' : 'js';
  602. $template_directory_uri = get_template_directory_uri();
  603. // JS at the bottom for fast page loading.
  604. // except for Modernizr which enables HTML5 elements & feature detects.
  605. wp_enqueue_script( 'modernizr', $template_directory_uri . '/core/' . $directory . '/responsive-modernizr' . $suffix . '.js', array( 'jquery' ), '2.6.1', false );
  606. wp_enqueue_script( 'responsive-scripts', $template_directory_uri . '/core/' . $directory . '/responsive-scripts' . $suffix . '.js', array( 'jquery' ), '1.2.6', true );
  607. if ( !wp_script_is( 'tribe-placeholder' ) ) {
  608. wp_enqueue_script( 'jquery-placeholder', $template_directory_uri . '/core/' . $directory . '/jquery.placeholder' . $suffix . '.js', array( 'jquery' ), '2.0.7', true );
  609. }
  610. }
  611. }
  612. add_action( 'wp_enqueue_scripts', 'responsive_js' );
  613. /**
  614. * A comment reply.
  615. */
  616. function responsive_enqueue_comment_reply() {
  617. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  618. wp_enqueue_script( 'comment-reply' );
  619. }
  620. }
  621. add_action( 'wp_enqueue_scripts', 'responsive_enqueue_comment_reply' );
  622. /**
  623. * Theme options upgrade bar
  624. */
  625. function responsive_upgrade_bar() {
  626. ?>
  627. <div class="upgrade-callout">
  628. <p><img src="<?php echo get_template_directory_uri(); ?>/core/includes/theme-options/images/chimp.png" alt="CyberChimps"/>
  629. <?php printf( __( 'Welcome to %1$s! Upgrade to %2$s today.', 'responsive' ),
  630. 'Responsive',
  631. ' <a href="http://cyberchimps.com/store/responsivepro/" target="_blank" title="Responsive Pro">Responsive Pro</a> '
  632. ); ?>
  633. </p>
  634. <div class="social-container">
  635. <div class="social">
  636. <a href="https://twitter.com/cyberchimps" class="twitter-follow-button" data-show-count="false" data-size="small">Follow @cyberchimps</a>
  637. <script>!function (d, s, id) {
  638. var js, fjs = d.getElementsByTagName(s)[0];
  639. if (!d.getElementById(id)) {
  640. js = d.createElement(s);
  641. js.id = id;
  642. js.src = "//platform.twitter.com/widgets.js";
  643. fjs.parentNode.insertBefore(js, fjs);
  644. }
  645. }(document, "script", "twitter-wjs");</script>
  646. </div>
  647. <div class="social">
  648. <iframe
  649. src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fcyberchimps.com%2F&amp;send=false&amp;layout=button_count&amp;width=200&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21"
  650. scrolling="no" frameborder="0"
  651. style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe>
  652. </div>
  653. </div>
  654. </div>
  655. <?php
  656. }
  657. add_action( 'responsive_theme_options', 'responsive_upgrade_bar', 1 );
  658. /**
  659. * Theme Options Support and Information
  660. */
  661. function responsive_theme_support() {
  662. ?>
  663. <div id="info-box-wrapper" class="grid col-940">
  664. <div class="info-box notice">
  665. <a class="button" href="<?php echo esc_url( 'http://cyberchimps.com/guides/r-free/' ); ?>" title="<?php esc_attr_e( 'Instructions', 'responsive' ); ?>" target="_blank">
  666. <?php _e( 'Instructions', 'responsive' ); ?></a>
  667. <a class="button button-primary" href="<?php echo esc_url( 'http://cyberchimps.com/forum/free/responsive/' ); ?>" title="<?php esc_attr_e( 'Help', 'responsive' ); ?>" target="_blank">
  668. <?php _e( 'Help', 'responsive' ); ?></a>
  669. <a class="button" href="<?php echo esc_url( 'https://webtranslateit.com/en/projects/3598-Responsive-Theme' ); ?>" title="<?php esc_attr_e( 'Translate', 'responsive' ); ?>" target="_blank">
  670. <?php _e( 'Translate', 'responsive' ); ?></a>
  671. <a class="button" href="<?php echo esc_url( 'http://cyberchimps.com/showcase/' ); ?>" title="<?php esc_attr_e( 'Showcase', 'responsive' ); ?>" target="_blank">
  672. <?php _e( 'Showcase', 'responsive' ); ?></a>
  673. <a class="button" href="<?php echo esc_url( 'http://cyberchimps.com/store/' ); ?>" title="<?php esc_attr_e( 'More Themes', 'responsive' ); ?>" target="_blank">
  674. <?php _e( 'More Themes', 'responsive' ); ?></a>
  675. </div>
  676. </div>
  677. <?php
  678. }
  679. add_action( 'responsive_theme_options', 'responsive_theme_support', 2 );
  680. /**
  681. * Front Page function starts here. The Front page overides WP's show_on_front option. So when show_on_front option changes it sets the themes front_page to 0 therefore displaying the new option
  682. */
  683. function responsive_front_page_override( $new, $orig ) {
  684. global $responsive_options;
  685. if ( $orig !== $new ) {
  686. $responsive_options['front_page'] = 0;
  687. update_option( 'responsive_theme_options', $responsive_options );
  688. }
  689. return $new;
  690. }
  691. add_filter( 'pre_update_option_show_on_front', 'responsive_front_page_override', 10, 2 );
  692. /**
  693. * Funtion to add CSS class to body
  694. */
  695. function responsive_add_class( $classes ) {
  696. // Get Responsive theme option.
  697. global $responsive_options;
  698. if ( $responsive_options['front_page'] == 1 && is_front_page() ) {
  699. $classes[] = 'front-page';
  700. }
  701. return $classes;
  702. }
  703. add_filter( 'body_class', 'responsive_add_class' );
  704. function responsive_install_plugins() {
  705. $plugins = array(
  706. // This is an example of how to include a plugin pre-packaged with a theme
  707. array(
  708. 'name' => 'Responsive Add Ons', // The plugin name
  709. 'slug' => 'responsive-add-ons', // The plugin slug (typically the folder name)
  710. 'required' => false
  711. ),
  712. array(
  713. 'name' => 'Clef', // The plugin name
  714. 'slug' => 'wpclef', // The plugin slug (typically the folder name)
  715. 'required' => false
  716. ),
  717. array(
  718. 'name' => 'FooBox Image Lightbox', // The plugin name
  719. 'slug' => 'foobox-image-lightbox', // The plugin slug (typically the folder name)
  720. 'required' => false
  721. )
  722. );
  723. // Change this to your theme text domain, used for internationalising strings
  724. $theme_text_domain = 'responsive';
  725. /**
  726. * Array of configuration settings. Amend each line as needed.
  727. * If you want the default strings to be available under your own theme domain,
  728. * leave the strings uncommented.
  729. * Some of the strings are added into a sprintf, so see the comments at the
  730. * end of each line for what each argument will be.
  731. */
  732. $config = array(
  733. 'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
  734. 'default_path' => '', // Default absolute path to pre-packaged plugins
  735. 'parent_menu_slug' => 'themes.php', // Default parent menu slug
  736. 'parent_url_slug' => 'themes.php', // Default parent URL slug
  737. 'menu' => 'install-responsive-addons', // Menu slug
  738. 'has_notices' => true, // Show admin notices or not
  739. 'is_automatic' => true, // Automatically activate plugins after installation or not
  740. 'message' => '', // Message to output right before the plugins table
  741. 'strings' => array(
  742. 'page_title' => __( 'Responsive Add Features', 'responsive' ),
  743. 'menu_title' => __( 'Activate Add Ons', 'responsive' ),
  744. 'installing' => __( 'Installing Plugin: %s', 'responsive' ), // %1$s = plugin name
  745. 'oops' => __( 'Something went wrong with the plugin API.', 'responsive' ),
  746. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'responsive' ), // %1$s = plugin name(s)
  747. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'responsive' ), // %1$s = plugin name(s)
  748. 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'responsive' ), // %1$s = plugin name(s)
  749. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'responsive' ), // %1$s = plugin name(s)
  750. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'responsive' ), // %1$s = plugin name(s)
  751. 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'responsive' ), // %1$s = plugin name(s)
  752. 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'responsive' ), // %1$s = plugin name(s)
  753. 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'responsive' ), // %1$s = plugin name(s)
  754. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'responsive' ),
  755. 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'responsive' ),
  756. 'return' => __( 'Return to Required Plugins Installer', 'responsive' ),
  757. 'plugin_activated' => __( 'Plugin activated successfully.', 'responsive' ),
  758. 'complete' => __( 'All plugins installed and activated successfully. %s', 'responsive' ) // %1$s = dashboard link
  759. )
  760. );
  761. global $pagenow;
  762. // Add plugin notification only if the current user is admin and on theme.php
  763. if ( current_user_can( 'manage_options' ) && 'themes.php' == $pagenow ) {
  764. tgmpa( $plugins, $config );
  765. }
  766. }
  767. add_action( 'tgmpa_register', 'responsive_install_plugins' );
  768. /*
  769. * Add notification to Reading Settings page to notify if Custom Front Page is enabled.
  770. *
  771. * @since 1.9.4.0
  772. */
  773. function responsive_front_page_reading_notice() {
  774. $screen = get_current_screen();
  775. $responsive_options = responsive_get_options();
  776. if ( 'options-reading' == $screen->id ) {
  777. $html = '<div class="updated">';
  778. if ( 1 == $responsive_options['front_page'] ) {
  779. $html .= '<p>' . sprintf( __( 'The Custom Front Page is enabled. You can disable it in the <a href="%1$s">theme settings</a>.', 'responsive' ), admin_url( 'themes.php?page=theme_options' ) ) . '</p>';
  780. } else {
  781. $html .= '<p>' . sprintf( __( 'The Custom Front Page is disabled. You can enable it in the <a href="%1$s">theme settings</a>.', 'responsive' ), admin_url( 'themes.php?page=theme_options' ) ) . '</p>';
  782. }
  783. $html .= '</div>';
  784. echo $html;
  785. }
  786. }
  787. add_action( 'admin_notices', 'responsive_front_page_reading_notice' );
  788. /**
  789. * Use shortcode_atts_gallery filter to add new defaults to the WordPress gallery shortcode.
  790. * Allows user input in the post gallery shortcode.
  791. *
  792. */
  793. function responsive_gallery_atts( $out, $pairs, $atts ) {
  794. $full_width = is_page_template( 'full-width-page.php' ) || is_page_template( 'landing-page.php' );
  795. // Check if the size attribute has been set, if so use it and skip the responsive sizes
  796. if ( array_key_exists( 'size', $atts ) ) {
  797. $size = $atts['size'];
  798. } else {
  799. if ( $full_width ) {
  800. switch ( $out['columns'] ) {
  801. case 1:
  802. $size = 'responsive-900'; //900
  803. break;
  804. case 2:
  805. $size = 'responsive-450'; //450
  806. break;
  807. case 3:
  808. $size = 'responsive-300'; //300
  809. break;
  810. case 4:
  811. $size = 'responsive-200'; //225
  812. break;
  813. case 5:
  814. $size = 'responsive-200'; //180
  815. break;
  816. case 6:
  817. $size = 'responsive-150'; //150
  818. break;
  819. case 7:
  820. $size = 'responsive-150'; //125
  821. break;
  822. case 8:
  823. $size = 'responsive-150'; //112
  824. break;
  825. case 9:
  826. $size = 'responsive-100'; //100
  827. break;
  828. }
  829. } else {
  830. switch ( $out['columns'] ) {
  831. case 1:
  832. $size = 'responsive-600'; //600
  833. break;
  834. case 2:
  835. $size = 'responsive-300'; //300
  836. break;
  837. case 3:
  838. $size = 'responsive-200'; //200
  839. break;
  840. case 4:
  841. $size = 'responsive-150'; //150
  842. break;
  843. case 5:
  844. $size = 'responsive-150'; //120
  845. break;
  846. case 6:
  847. $size = 'responsive-100'; //100
  848. break;
  849. case 7:
  850. $size = 'responsive-100'; //85
  851. break;
  852. case 8:
  853. $size = 'responsive-100'; //75
  854. break;
  855. case 9:
  856. $size = 'responsive-100'; //66
  857. break;
  858. }
  859. }
  860. }
  861. $atts = shortcode_atts(
  862. array(
  863. 'size' => $size,
  864. ),
  865. $atts
  866. );
  867. $out['size'] = $atts['size'];
  868. return $out;
  869. }
  870. add_filter( 'shortcode_atts_gallery', 'responsive_gallery_atts', 10, 3 );
  871. /*
  872. * Create image sizes for the galley
  873. */
  874. add_image_size( 'responsive-100', 100, 9999 );
  875. add_image_size( 'responsive-150', 150, 9999 );
  876. add_image_size( 'responsive-200', 200, 9999 );
  877. add_image_size( 'responsive-300', 300, 9999 );
  878. add_image_size( 'responsive-450', 450, 9999 );
  879. add_image_size( 'responsive-600', 600, 9999 );
  880. add_image_size( 'responsive-900', 900, 9999 );
  881. /*
  882. * Get social icons.
  883. *
  884. * @since 1.9.4.9
  885. */
  886. function responsive_get_social_icons() {
  887. $responsive_options = responsive_get_options();
  888. $sites = array (
  889. 'twitter' => __( 'Twitter', 'responsive' ),
  890. 'facebook' => __( 'Facebook', 'responsive' ),
  891. 'linkedin' => __( 'LinkedIn', 'responsive' ),
  892. 'youtube' => __( 'YouTube', 'responsive' ),
  893. 'stumbleupon' => __( 'StumbleUpon', 'responsive' ),
  894. 'rss' => __( 'RSS Feed', 'responsive' ),
  895. 'googleplus' => __( 'Google+', 'responsive' ),
  896. 'instagram' => __( 'Instagram', 'responsive' ),
  897. 'pinterest' => __( 'Pinterest', 'responsive' ),
  898. 'yelp' => __( 'Yelp!', 'responsive' ),
  899. 'vimeo' => __( 'Vimeo', 'responsive' ),
  900. 'foursquare' => __( 'foursquare', 'responsive' ),
  901. );
  902. $html = '<ul class="social-icons">';
  903. foreach( $sites as $key => $value ) {
  904. if ( !empty( $responsive_options[$key . '_uid'] ) ) {
  905. $html .= '<li class="' . esc_attr( $key ) . '-icon"><a href="' . $responsive_options[$key . '_uid'] . '">' . '<img src="' . responsive_child_uri( '/core/icons/' . esc_attr( $key ) . '-icon.png' ) . '" width="24" height="24" alt="' . esc_html( $value ) . '">' . '</a></li>';
  906. }
  907. }
  908. $html .= '</ul><!-- .social-icons -->';
  909. return $html;
  910. }