functions.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <?php
  2. /**
  3. * Theme Functions
  4. *
  5. * Please do not edit this file. This file is part of the Cyber Chimps Framework and all modifications
  6. * should be made in a child theme.
  7. *
  8. * @category CyberChimps Framework
  9. * @package Framework
  10. * @since 1.0
  11. * @author CyberChimps
  12. * @license http://www.opensource.org/licenses/gpl-license.php GPL v3.0 (or later)
  13. * @link http://www.cyberchimps.com/
  14. */
  15. function cyberchimps_text_domain() {
  16. load_theme_textdomain( 'business-lite', get_template_directory() . '/inc/languages' );
  17. }
  18. add_action( 'after_setup_theme', 'cyberchimps_text_domain' );
  19. // Load Core
  20. require_once( get_template_directory() . '/cyberchimps/init.php' );
  21. // Set the content width based on the theme's design and stylesheet.
  22. if( !isset( $content_width ) ) {
  23. $content_width = 640;
  24. } /* pixels */
  25. function cyberchimps_add_site_info() {
  26. ?>
  27. <p>&copy; Company Name</p>
  28. <?php
  29. }
  30. add_action( 'cyberchimps_site_info', 'cyberchimps_add_site_info' );
  31. if( !function_exists( 'cyberchimps_comment' ) ) :
  32. // Template for comments and pingbacks.
  33. // Used as a callback by wp_list_comments() for displaying the comments.
  34. function cyberchimps_comment( $comment, $args, $depth ) {
  35. $GLOBALS['comment'] = $comment;
  36. switch( $comment->comment_type ) :
  37. case 'pingback' :
  38. case 'trackback' :
  39. ?>
  40. <li class="post pingback">
  41. <p><?php _e( 'Pingback:', 'business-lite' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'business-lite' ), ' ' ); ?></p>
  42. <?php
  43. break;
  44. default :
  45. ?>
  46. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  47. <article id="comment-<?php comment_ID(); ?>" class="comment hreview">
  48. <footer>
  49. <div class="comment-author reviewer vcard">
  50. <?php echo get_avatar( $comment, 40 ); ?>
  51. <?php printf( '%s <span class="says">' . __( 'says:', 'business-lite' ) . '</span>', sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  52. </div>
  53. <!-- .comment-author .vcard -->
  54. <?php if( $comment->comment_approved == '0' ) : ?>
  55. <em><?php _e( 'Your comment is awaiting moderation.', 'business-lite' ); ?></em>
  56. <br/>
  57. <?php endif; ?>
  58. <div class="comment-meta commentmetadata">
  59. <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>" class="dtreviewed">
  60. <time pubdate datetime="<?php comment_time( 'c' ); ?>">
  61. <?php
  62. /* translators: 1: date, 2: time */
  63. printf( __( '%1$s', 'business-lite' ), get_comment_date( 'm / d / y' ) ); ?>
  64. </time>
  65. </a>
  66. <?php edit_comment_link( __( '(Edit)', 'business-lite' ), ' ' );
  67. ?>
  68. </div>
  69. <!-- .comment-meta .commentmetadata -->
  70. </footer>
  71. <div class="comment-content"><?php comment_text(); ?></div>
  72. <div class="reply">
  73. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  74. </div>
  75. <!-- .reply -->
  76. </article><!-- #comment-## -->
  77. <?php
  78. break;
  79. endswitch;
  80. }
  81. endif; // ends check for cyberchimps_comment()
  82. // set up next and previous post links for lite themes only
  83. function cyberchimps_next_previous_posts() {
  84. if( get_next_posts_link() || get_previous_posts_link() ): ?>
  85. <div class="more-content">
  86. <div class="row-fluid">
  87. <div class="span6 previous-post">
  88. <?php previous_posts_link(); ?>
  89. </div>
  90. <div class="span6 next-post">
  91. <?php next_posts_link(); ?>
  92. </div>
  93. </div>
  94. </div>
  95. <?php
  96. endif;
  97. }
  98. add_action( 'cyberchimps_after_content', 'cyberchimps_next_previous_posts' );
  99. // core options customization Names and URL's
  100. //Pro or Free
  101. function cyberchimps_theme_check() {
  102. $level = 'free';
  103. return $level;
  104. }
  105. //Theme Name
  106. function cyberchimps_options_theme_name() {
  107. $text = 'Business Lite';
  108. return $text;
  109. }
  110. //Pro version name
  111. function cyberchimps_upgrade_bar_pro_title() {
  112. $text = 'Business Pro';
  113. return $text;
  114. }
  115. //Pro version link
  116. function cyberchimps_options_pro_link() {
  117. $url = 'http://cyberchimps.com/store/business-pro/';
  118. return $url;
  119. }
  120. //Doc's URL
  121. function cyberchimps_options_documentation_url() {
  122. $url = 'http://cyberchimps.com/guides/';
  123. return $url;
  124. }
  125. // Support Forum URL
  126. function cyberchimps_options_support_forum() {
  127. $url = 'http://cyberchimps.com/forum/free/business/';
  128. return $url;
  129. }
  130. // Slider Options Help URL
  131. function cyberchimps_options_slider_options_help() {
  132. $url = 'http://cyberchimps.com/faq/how-to-use-the-ifeature-pro-slider/';
  133. return $url;
  134. }
  135. add_filter( 'cyberchimps_current_theme_name', 'cyberchimps_options_theme_name', 1 );
  136. add_filter( 'cyberchimps_upgrade_pro_title', 'cyberchimps_upgrade_bar_pro_title' );
  137. add_filter( 'cyberchimps_upgrade_link', 'cyberchimps_options_pro_link' );
  138. add_filter( 'cyberchimps_documentation', 'cyberchimps_options_documentation_url' );
  139. add_filter( 'cyberchimps_support_forum', 'cyberchimps_options_support_forum' );
  140. add_filter( 'cyberchimps_slider_options_help', 'cyberchimps_options_slider_options_help' );
  141. // Help Section
  142. function cyberchimps_options_help_header() {
  143. $text = 'Business Lite';
  144. return $text;
  145. }
  146. function cyberchimps_options_help_sub_header() {
  147. $text = __( 'Professional Business Theme', 'business-lite' );
  148. return $text;
  149. }
  150. add_filter( 'cyberchimps_help_heading', 'cyberchimps_options_help_header' );
  151. add_filter( 'cyberchimps_help_sub_heading', 'cyberchimps_options_help_sub_header' );
  152. // Branding images and defaults
  153. // Slider Defaults
  154. function cyberchimps_default_slider2() {
  155. $image = '/images/branding/slide2.jpg';
  156. return $image;
  157. }
  158. function cyberchimps_default_slider3() {
  159. $image = '/images/branding/slide3.jpg';
  160. return $image;
  161. }
  162. add_filter( 'cyberchimps_slider_lite_img2', 'cyberchimps_default_slider2' );
  163. add_filter( 'cyberchimps_slider_lite_img3', 'cyberchimps_default_slider3' );
  164. //theme specific skin options in array. Must always include option default
  165. //todo clean up function
  166. function cyberchimps_skin_color_options( $options ) {
  167. // Get path of image
  168. $imagepath = get_template_directory_uri() . '/inc/css/skins/images/';
  169. $options = array(
  170. 'default' => $imagepath . 'default.png'
  171. );
  172. return $options;
  173. }
  174. add_filter( 'cyberchimps_skin_color', 'cyberchimps_skin_color_options', 1 );
  175. // theme specific background images
  176. function cyberchimps_background_image( $options ) {
  177. $imagepath = get_template_directory_uri() . '/cyberchimps/lib/images/';
  178. $options = array(
  179. 'none' => $imagepath . 'backgrounds/thumbs/none.png',
  180. 'noise' => $imagepath . 'backgrounds/thumbs/noise.png',
  181. 'blue' => $imagepath . 'backgrounds/thumbs/blue.png',
  182. 'dark' => $imagepath . 'backgrounds/thumbs/dark.png',
  183. 'space' => $imagepath . 'backgrounds/thumbs/space.png'
  184. );
  185. return $options;
  186. }
  187. add_filter( 'cyberchimps_background_image', 'cyberchimps_background_image' );
  188. // theme specific typography options
  189. function cyberchimps_typography_sizes( $sizes ) {
  190. $sizes = array( '8', '9', '10', '12', '14', '16', '20' );
  191. return $sizes;
  192. }
  193. function cyberchimps_typography_faces( $faces ) {
  194. $faces = array(
  195. 'Arial, Helvetica, sans-serif' => 'Arial',
  196. 'Arial Black, Gadget, sans-serif' => 'Arial Black',
  197. 'Comic Sans MS, cursive' => 'Comic Sans MS',
  198. 'Courier New, monospace' => 'Courier New',
  199. 'Georgia, serif' => 'Georgia',
  200. 'Impact, Charcoal, sans-serif' => 'Impact',
  201. 'Lucida Console, Monaco, monospace' => 'Lucida Console',
  202. 'Lucida Sans Unicode, Lucida Grande, sans-serif' => 'Lucida Sans Unicode',
  203. 'Palatino Linotype, Book Antiqua, Palatino, serif' => 'Palatino Linotype',
  204. 'Tahoma, Geneva, sans-serif' => 'Tahoma',
  205. 'Times New Roman, Times, serif' => 'Times New Roman',
  206. 'Trebuchet MS, sans-serif' => 'Trebuchet MS',
  207. 'Verdana, Geneva, sans-serif' => 'Verdana',
  208. 'Symbol' => 'Symbol',
  209. 'Webdings' => 'Webdings',
  210. 'Wingdings, Zapf Dingbats' => 'Wingdings',
  211. 'MS Sans Serif, Geneva, sans-serif' => 'MS Sans Serif',
  212. 'MS Serif, New York, serif' => 'MS Serif',
  213. );
  214. return $faces;
  215. }
  216. function cyberchimps_typography_styles( $styles ) {
  217. $styles = array( 'normal' => 'Normal', 'bold' => 'Bold' );
  218. return $styles;
  219. }
  220. add_filter( 'cyberchimps_typography_sizes', 'cyberchimps_typography_sizes' );
  221. add_filter( 'cyberchimps_typography_faces', 'cyberchimps_typography_faces' );
  222. add_filter( 'cyberchimps_typography_styles', 'cyberchimps_typography_styles' );
  223. //image size for the blog page
  224. add_image_size( 'blog-page', 1500, 200, true ); //830 pixels wide and 180 pixels tall
  225. //change cyberchimps featured image to use this new image size
  226. function cyberchimps_featured_image_size() {
  227. return 'blog-page';
  228. }
  229. add_filter( 'cyberchimps_post_thumbnail_size', 'cyberchimps_featured_image_size' );
  230. //Register Secondary Menu
  231. function cyberchimps_secondary_menu() {
  232. register_nav_menu( 'secondary', __( 'Secondary Menu', 'business-lite' ) );
  233. }
  234. add_action( 'init', 'cyberchimps_secondary_menu' );
  235. /******************************************
  236. ************** Custom meta data **********
  237. ******************************************/
  238. //Get the meta date
  239. function cyberchimps_posted_on() {
  240. if( is_single() ) {
  241. $show_date = ( cyberchimps_get_option( 'single_post_byline_date', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_date', 1 ) : false;
  242. }
  243. elseif( is_archive() ) {
  244. $show_date = ( cyberchimps_get_option( 'archive_post_byline_date', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_date', 1 ) : false;
  245. }
  246. else {
  247. $show_date = ( cyberchimps_get_option( 'post_byline_date', 1 ) ) ? cyberchimps_get_option( 'post_byline_date', 1 ) : false;
  248. }
  249. $posted_on = sprintf( '<span class="meta-date"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date updated" datetime="%3$s">%4$s</time></a></span>',
  250. esc_url( get_permalink() ),
  251. esc_attr( get_the_time() ),
  252. esc_attr( get_the_date( 'c' ) ),
  253. ( $show_date ) ? esc_html( get_the_date() ) : ''
  254. );
  255. if( $show_date ) {
  256. apply_filters( 'cyberchimps_posted_on', $posted_on );
  257. echo $posted_on;
  258. }
  259. }
  260. //Get the meta author
  261. function cyberchimps_posted_by() {
  262. if( is_single() ) {
  263. $show_author = ( cyberchimps_get_option( 'single_post_byline_author', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_author', 1 ) : false;
  264. }
  265. elseif( is_archive() ) {
  266. $show_author = ( cyberchimps_get_option( 'archive_post_byline_author', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_author', 1 ) : false;
  267. }
  268. else {
  269. $show_author = ( cyberchimps_get_option( 'post_byline_author', 1 ) ) ? cyberchimps_get_option( 'post_byline_author', 1 ) : false;
  270. }
  271. $posted_by = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
  272. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  273. esc_attr( sprintf( __( 'View all posts by %s', 'cyberchimps_core' ), get_the_author() ) ),
  274. ( $show_author ) ? esc_html( get_the_author() ) : ''
  275. );
  276. if( $show_author ) {
  277. apply_filters( 'cyberchimps_posted_by', $posted_by );
  278. echo $posted_by;
  279. }
  280. }
  281. //categories
  282. function cyberchimps_posted_in() {
  283. global $post;
  284. if( is_single() ) {
  285. $show = ( cyberchimps_get_option( 'single_post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_categories', 1 ) : false;
  286. }
  287. elseif( is_archive() ) {
  288. $show = ( cyberchimps_get_option( 'archive_post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_categories', 1 ) : false;
  289. }
  290. else {
  291. $show = ( cyberchimps_get_option( 'post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'post_byline_categories', 1 ) : false;
  292. }
  293. if( $show ):
  294. $categories_list = get_the_category_list( ', ' );
  295. if( $categories_list ) :
  296. $cats = $categories_list;
  297. ?>
  298. <span class="cat-links">
  299. <?php echo apply_filters( 'cyberchimps_post_categories', $cats ); ?>
  300. </span>
  301. <?php endif;
  302. endif;
  303. }
  304. //Post coments
  305. function cyberchimps_post_comments() {
  306. global $post;
  307. if( is_single() ) {
  308. $show = ( cyberchimps_get_option( 'single_post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_comments', 1 ) : false;
  309. }
  310. elseif( is_archive() ) {
  311. $show = ( cyberchimps_get_option( 'archive_post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_comments', 1 ) : false;
  312. }
  313. else {
  314. $show = ( cyberchimps_get_option( 'post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'post_byline_comments', 1 ) : false;
  315. }
  316. $leave_comment = ( is_single() || is_page() ) ? '' : __( 'Leave a comment', 'cyberchimps_core' );
  317. if( $show ):
  318. if( !post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
  319. <span class="comments-link"><?php comments_popup_link( $leave_comment, __( '1 Comment', 'cyberchimps_core' ), '% ' . __( 'Comments', 'cyberchimps_core' ) ); ?></span>
  320. <?php endif;
  321. endif;
  322. }
  323. /******************************************
  324. ********** End Custom meta data **********
  325. ******************************************/
  326. //Create secondary menu page title
  327. function cyberchimps_secondary_menu_title() {
  328. if( is_home() || is_single() ) {
  329. $title = __( 'Our Blog', 'business-lite' );
  330. }
  331. elseif( is_page() && get_post_meta( get_the_ID(), 'cyberchimps_page_title_toggle', true ) == 1 ) {
  332. $title = esc_html( get_the_title() );
  333. }
  334. elseif( is_category() ) {
  335. $title = sprintf( __( 'Category Archives: %s', 'business-lite' ), '<span>' . single_cat_title( '', false ) . '</span>' );
  336. }
  337. elseif( is_tag() ) {
  338. $title = sprintf( __( 'Tag Archives: %s', 'business-lite' ), '<span>' . single_tag_title( '', false ) . '</span>' );
  339. }
  340. elseif( is_author() ) {
  341. /* Queue the first post, that way we know
  342. * what author we're dealing with (if that is the case).
  343. */
  344. the_post();
  345. $title = sprintf( __( 'Author Archives: %s', 'business-lite' ), '<span>' . get_the_author() . '</span>' );
  346. /* Since we called the_post() above, we need to
  347. * rewind the loop back to the beginning that way
  348. * we can run the loop properly, in full.
  349. */
  350. rewind_posts();
  351. }
  352. elseif( is_day() ) {
  353. $title = sprintf( __( 'Daily Archives: %s', 'business-lite' ), '<span>' . get_the_date() . '</span>' );
  354. }
  355. elseif( is_month() ) {
  356. $title = sprintf( __( 'Monthly Archives: %s', 'business-lite' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );
  357. }
  358. elseif( is_year() ) {
  359. $title = sprintf( __( 'Yearly Archives: %s', 'business-lite' ), '<span>' . get_the_date( 'Y' ) . '</span>' );
  360. }
  361. elseif( is_search() ) {
  362. $title = sprintf( __( 'Search Results for: %s', 'business-lite' ), '<span>' . get_search_query() . '</span>' );
  363. }
  364. else {
  365. $title = '';
  366. }
  367. return $title;
  368. }
  369. // header drag and drop default
  370. function cyberchimps_business_lite_header_drag_and_drop_default() {
  371. $option = array( 'cyberchimps_logo' => __( 'Logo', 'cyberchimps_elements' )
  372. );
  373. return $option;
  374. }
  375. add_filter( 'header_drag_and_drop_default', 'cyberchimps_business_lite_header_drag_and_drop_default', 20 );
  376. //add header drag and drop options
  377. function cyberchimps_business_lite_header_drag_and_drop_options() {
  378. $options = array(
  379. 'cyberchimps_sitename_register' => __( 'Logo + Login', 'cyberchimps_elements' ),
  380. 'cyberchimps_logo_search' => __( 'Logo + Search', 'cyberchimps_elements' ),
  381. 'cyberchimps_logo' => __( 'Logo', 'cyberchimps_elements' )
  382. );
  383. return $options;
  384. }
  385. add_filter( 'header_drag_and_drop_options', 'cyberchimps_business_lite_header_drag_and_drop_options', 15 );
  386. //Create header drag and drop display on frontend
  387. function cyberchimps_header_display() {
  388. //get selected header elements
  389. $selected = cyberchimps_get_option( 'header_section_order' );
  390. //loop through results and display
  391. if( is_array( $selected ) ) {
  392. foreach( $selected as $value ) {
  393. switch( $value ) {
  394. case 'cyberchimps_logo_search':
  395. ?>
  396. <div class="header-search">
  397. <?php get_search_form( true ); ?>
  398. </div>
  399. <?php
  400. break;
  401. case 'cyberchimps_sitename_contact':
  402. cyberchimps_contact_info();
  403. break;
  404. case 'cyberchimps_sitename_register':
  405. ?>
  406. <div class="register">
  407. <?php
  408. if( !is_user_logged_in() ) :
  409. wp_loginout(); ?> <?php wp_meta(); ?> | <?php wp_register( '', '', true );
  410. else :?>
  411. Welcome back <strong><?php global $current_user;
  412. get_currentuserinfo();
  413. echo( $current_user->user_login ); ?></strong> | <?php wp_loginout(); ?>
  414. <?php endif; ?>
  415. </div>
  416. <?php
  417. break;
  418. default:
  419. break;
  420. }
  421. }
  422. }
  423. }
  424. add_action( 'cyberchimps_header_display', 'cyberchimps_header_display' );
  425. // Places icons in footer if there are any
  426. function cyberchimps_footer_social() {
  427. $twitter_display = cyberchimps_get_option( 'social_twitter', 'checked' );
  428. $facebook_display = cyberchimps_get_option( 'social_facebook', 'checked' );
  429. $google_display = cyberchimps_get_option( 'social_google', 'checked' );
  430. $flickr_display = cyberchimps_get_option( 'social_flickr' );
  431. $pinterest_display = cyberchimps_get_option( 'social_pinterest' );
  432. $linkedin_display = cyberchimps_get_option( 'social_linkedin' );
  433. $youtube_display = cyberchimps_get_option( 'social_youtube' );
  434. $googlemaps_display = cyberchimps_get_option( 'social_googlemaps' );
  435. $email_display = cyberchimps_get_option( 'social_email' );
  436. $rss_display = cyberchimps_get_option( 'social_rss' );
  437. if( !empty( $twitter_display ) || !empty( $facebook_display ) || !empty( $google_display ) || !empty( $flickr_display ) || !empty( $pinterest_display ) || !empty( $linkedin_display ) || !empty( $youtube_display ) || !empty( $googlemaps_display ) || !empty( $email_display ) || !empty( $rss_display ) ): ?>
  438. <div class="container-full-width" id="footer_social_icons">
  439. <div class="container">
  440. <div class="container-fluid">
  441. <div class="row-fluid">
  442. <?php cyberchimps_header_social_icons(); ?>
  443. </div>
  444. </div>
  445. </div>
  446. </div>
  447. <?php endif;
  448. }
  449. add_action( 'cyberchimps_before_footer_container', 'cyberchimps_footer_social' );
  450. ?>