/functions.php

  1. <?php 
  2. /** 
  3. * Bootstrap eCommerce functions and definitions. 
  4. * 
  5. * Sets up the theme and provides some helper functions, which are used 
  6. * in the theme as custom template tags. Others are attached to action and 
  7. * filter hooks in WordPress to change core functionality. 
  8. * 
  9. * When using a child theme (see http://codex.wordpress.org/Theme_Development and 
  10. * http://codex.wordpress.org/Child_Themes), you can override certain functions 
  11. * (those wrapped in a function_exists() call) by defining them first in your child theme's 
  12. * functions.php file. The child theme's functions.php file is included before the parent 
  13. * theme's file, so the child theme functions would be used. 
  14. * 
  15. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached 
  16. * to a filter or action hook. 
  17. * 
  18. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. 
  19. * Bootstrap eCommerce theme is based on Twentytwelve theme. The official WordPress theme. 
  20. * 
  21. * @package WordPress 
  22. * @subpackage Bootstrap eCommerce 
  23. * @since Bootstrap eCommerce 1.0 
  24. */ 
  25.  
  26. /** 
  27. * Sets up the content width value based on the theme's design and stylesheet. 
  28. */ 
  29. if ( ! isset( $content_width ) ) 
  30. $content_width = 870; 
  31.  
  32. /** 
  33. * Sets up theme defaults and registers the various WordPress features that 
  34. * Bootstrap eCommerce supports. 
  35. * 
  36. * @uses load_theme_textdomain() For translation/localization support. 
  37. * @uses add_editor_style() To add a Visual Editor stylesheet. 
  38. * @uses add_theme_support() To add support for post thumbnails, automatic feed links,  
  39. * custom background, and post formats. 
  40. * @uses register_nav_menu() To add support for navigation menus. 
  41. * @uses set_post_thumbnail_size() To set a custom post thumbnail size. 
  42. * 
  43. */ 
  44. function bre_setup() { 
  45. /** 
  46. * Makes Bootstrap eCommerce available for translation. 
  47. * 
  48. * Translations can be added to the /languages/ directory. 
  49. * If you're building a theme based on Bootstrap eCommerce, use a find and replace 
  50. * to change 'bre-bootstrap-ecommerce' to the name of your theme in all the template files. 
  51. */ 
  52. load_theme_textdomain( 'bre-bootstrap-ecommerce', get_template_directory() . '/languages' ); 
  53.  
  54. // This theme styles the visual editor with editor-style.css to match the theme style. 
  55. add_editor_style(); 
  56.  
  57. // Adds RSS feed links to <head> for posts and comments. 
  58. add_theme_support( 'automatic-feed-links' ); 
  59.  
  60. // This theme supports a variety of post formats. 
  61. add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) ); 
  62.  
  63. // This theme uses wp_nav_menu() in one location. 
  64. register_nav_menu( 'primary', __( 'Primary Menu', 'bre-bootstrap-ecommerce' ) ); 
  65.  
  66. // This theme uses extra menus wp_nav_menu() in one location. 
  67. register_nav_menu( 'secondary-menu', __( 'Secondary Menu', 'bre-bootstrap-ecommerce' ) ); 
  68.  
  69. /** 
  70. * This theme supports custom background color and image, and here 
  71. * we also set up the default background color. 
  72. */ 
  73. add_theme_support( 'custom-background', array( 
  74. 'default-color' => 'D7EDFB',  
  75. 'default-image' => get_template_directory_uri() . '/images/background.jpg',  
  76. ) ); 
  77.  
  78. add_theme_support( 'post-thumbnails' ); 
  79. set_post_thumbnail_size( 870, 9999 ); 
  80.  
  81. add_image_size( '150cropped', 150, 150, true ); 
  82. add_image_size( '270cropped', 270, 270, true ); 
  83.  
  84. add_image_size( 'height90', 9999, 90 ); /** 120x90 4:3 */ 
  85. add_image_size( 'height135', 9999, 135 ); /** 180x135 4:3 */ 
  86. add_image_size( 'height195', 9999, 192 ); /** 256x192 4:3 */ 
  87. add_image_size( 'height270', 9999, 270 ); /** 360x270 4:3 */ 
  88. add_image_size( 'height360', 9999, 360 ); /** 440x360 4:3 */ 
  89.  
  90. /** buddypress support */ 
  91. // This theme comes with all the BuddyPress goodies 
  92. add_theme_support( 'buddypress' ); 
  93.  
  94. // excerpt support for pages 
  95. add_post_type_support( 'page', 'excerpt' ); 
  96.  
  97. add_action( 'after_setup_theme', 'bre_setup' ); 
  98.  
  99.  
  100. /** 
  101. * Filter callback to add image sizes to Media Uploader 
  102. * 
  103. * WP 3.3 beta adds a new filter 'image_size_names_choose' to 
  104. * the list of image sizes which are displayed in the Media Uploader 
  105. * after an image has been uploaded. 
  106. * 
  107. * See image_size_input_fields() in wp-admin/includes/media.php 
  108. *  
  109. * 
  110. * @uses get_intermediate_image_sizes() 
  111. * 
  112. * @param $sizes, array of default image sizes (associative array) 
  113. * @return $new_sizes, array of all image sizes (associative array) 
  114. */ 
  115. function bre_display_image_size_names_muploader( $sizes ) { 
  116.  
  117. $new_sizes = array(); 
  118.  
  119. $added_sizes = get_intermediate_image_sizes(); 
  120.  
  121. // $added_sizes is an indexed array, therefore need to convert it 
  122. // to associative array, using $value for $key and $value 
  123. foreach( $added_sizes as $key => $value) { 
  124. $new_sizes[$value] = $value; 
  125.  
  126. // This preserves the labels in $sizes, and merges the two arrays 
  127. $new_sizes = array_merge( $new_sizes, $sizes ); 
  128.  
  129. return $new_sizes; 
  130. add_filter('image_size_names_choose', 'bre_display_image_size_names_muploader', 11, 1); 
  131.  
  132. /** 
  133. * Adds support for a custom header image. 
  134. */ 
  135. require( get_template_directory() . '/inc/custom-header.php' ); 
  136.  
  137. /** 
  138. * Enqueues scripts and styles for front-end. 
  139. * 
  140. * @since Bootstrap eCommerce 1.0 
  141. */ 
  142.  
  143. function bre_scripts_styles() { 
  144. global $wp_styles; 
  145.  
  146.  
  147. // Loads Bootstrap CSS 
  148. wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', null, null, null); 
  149. wp_enqueue_style('bootstrap'); 
  150.  
  151. // Loads TheCartPress loop CSS 
  152. wp_register_style( 'tcp-loop', get_template_directory_uri() . '/css/tcp_loop.css'); 
  153. wp_enqueue_style('tcp-loop'); 
  154.  
  155. /** 
  156. * Loads our main stylesheet. 
  157. */ 
  158. wp_enqueue_style( 'bre-style', get_stylesheet_uri() ); 
  159.  
  160. /** 
  161. * Loads the Internet Explorer specific stylesheet. 
  162. */ 
  163. wp_enqueue_style( 'bre-ie', get_template_directory_uri() . '/css/ie.css', array( 'bre-style' ), '20121010' ); 
  164. $wp_styles->add_data( 'bre-ie', 'conditional', 'lt IE 9' ); 
  165.  
  166.  
  167. /** 
  168. * Adds JavaScript to pages with the comment form to support 
  169. * sites with threaded comments (when in use). 
  170. */ 
  171. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) 
  172. wp_enqueue_script( 'comment-reply' ); 
  173.  
  174. wp_enqueue_script( 'jquery' ); 
  175.  
  176. wp_enqueue_script('respond', get_template_directory_uri() . '/js/respond.min.js', array( 'jquery' ), '1.0', true ); 
  177. wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '1.0', true ); 
  178. wp_enqueue_script('tcp-bootstrap', get_template_directory_uri() . '/js/bre-bootstrap.js', array( 'jquery' ), '1.0', true ); 
  179.  
  180. /** 
  181. * Loads our special font CSS file. 
  182. * 
  183. * The use of Open Sans by default is localized. For languages that use 
  184. * characters not supported by the font, the font can be disabled. 
  185. * 
  186. * To disable in a child theme, use wp_dequeue_style() 
  187. * function mytheme_dequeue_fonts() { 
  188. * wp_dequeue_style( 'bre-fonts' ); 
  189. * } 
  190. * add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 ); 
  191. */ 
  192.  
  193. /** translators: If there are characters in your language that are not supported 
  194. by Open Sans, translate this to 'off'. Do not translate into your own language. */ 
  195. if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'bre-bootstrap-ecommerce' ) ) { 
  196. $subsets = 'latin, latin-ext'; 
  197.  
  198. /** translators: To add an additional Open Sans character subset specific to your language, translate 
  199. this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ 
  200. $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'bre-bootstrap-ecommerce' ); 
  201.  
  202. if ( 'cyrillic' == $subset ) 
  203. $subsets .= ', cyrillic, cyrillic-ext'; 
  204. elseif ( 'greek' == $subset ) 
  205. $subsets .= ', greek, greek-ext'; 
  206. elseif ( 'vietnamese' == $subset ) 
  207. $subsets .= ', vietnamese'; 
  208.  
  209. $protocol = is_ssl() ? 'https' : 'http'; 
  210. $query_args = array( 
  211. 'family' => 'Open+Sans:400italic, 700italic, 400, 600, 700',  
  212. 'subset' => $subsets,  
  213. ); 
  214. wp_enqueue_style( 'bre-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); 
  215.  
  216.  
  217. add_action( 'wp_enqueue_scripts', 'bre_scripts_styles' ); 
  218.  
  219. function bre_wp_footer() { 
  220. $tcp_bse_sidebar_style = get_option( 'tcp_bse_sidebar_style', false ); 
  221. $tcp_bse_layout = get_option( 'tcp_bse_layout', 'content-sidebar' ); 
  222. ?> 
  223. <script> 
  224. /* Bse nav_menus in sidebar */ 
  225. <?php if ( $tcp_bse_sidebar_style ) { ?> 
  226. jQuery( '#secondary .widget_nav_menu, #secondary .taxonomytreesposttype, #secondary .flexipages_widget, #secondary .widget_categories, #secondary .widget_pages' ).addClass( 'bse_nav_menu' ); 
  227. <?php } 
  228. if ( $tcp_bse_layout == 'sidebar-content' ) { ?> 
  229. jQuery( '#secondary' ).addClass('tcp-bse-layout'); 
  230. jQuery( '#primary' ).addClass('tcp-bse-layout'); 
  231. <?php } ?> 
  232. </script> 
  233. <?php 
  234. add_action( 'wp_footer', 'bre_wp_footer' ); 
  235.  
  236. /** 
  237. * Creates a nicely formatted and more specific title element text 
  238. * for output in head of document, based on current view. 
  239. * 
  240. * @since Bootstrap eCommerce 1.0 
  241. * 
  242. * @param string $title Default title text for current view. 
  243. * @param string $sep Optional separator. 
  244. * @return string Filtered title. 
  245. */ 
  246. function bre_wp_title( $title, $sep ) { 
  247. global $paged, $page; 
  248.  
  249. if ( is_feed() ) 
  250. return $title; 
  251.  
  252. // Add the site name. 
  253. $title .= get_bloginfo( 'name' ); 
  254.  
  255. // Add the site description for the home/front page. 
  256. $site_description = get_bloginfo( 'description', 'display' ); 
  257. if ( $site_description && ( is_home() || is_front_page() ) ) 
  258. $title = "$title $sep $site_description"; 
  259.  
  260. // Add a page number if necessary. 
  261. if ( $paged >= 2 || $page >= 2 ) 
  262. $title = "$title $sep " . sprintf( __( 'Page %s', 'bre-bootstrap-ecommerce' ), max( $paged, $page ) ); 
  263.  
  264. return $title; 
  265. add_filter( 'wp_title', 'bre_wp_title', 10, 2 ); 
  266.  
  267. /** 
  268. * Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link. 
  269. * 
  270. * @since Bootstrap eCommerce 1.0 
  271. */ 
  272. function bre_page_menu_args( $args ) { 
  273. if ( ! isset( $args['show_home'] ) ) 
  274. $args['show_home'] = true; 
  275. return $args; 
  276. add_filter( 'wp_page_menu_args', 'bre_page_menu_args' ); 
  277.  
  278. /** 
  279. * Registers our main widget area and the front page widget areas. 
  280. * 
  281. * @since Bootstrap eCommerce 1.0 
  282. */ 
  283. function bre_widgets_init() { 
  284. register_sidebar( array( 
  285. 'name' => __( 'Store/Site Sidebar', 'bre-bootstrap-ecommerce' ),  
  286. 'id' => 'sidebar-1',  
  287. 'description' => __( 'Appears on Store pages', 'bre-bootstrap-ecommerce' ),  
  288. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  289. 'after_widget' => '</aside>',  
  290. 'before_title' => '<h3 class="widget-title">',  
  291. 'after_title' => '</h3>',  
  292. ) ); 
  293. register_sidebar( array( 
  294. 'name' => __( 'Blog Sidebar', 'bre-bootstrap-ecommerce' ),  
  295. 'id' => 'sidebar-blog',  
  296. 'description' => __( 'Appears in blog templates: archive, single, category and author templates', 'bre-bootstrap-ecommerce' ),  
  297. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  298. 'after_widget' => '</aside>',  
  299. 'before_title' => '<h3 class="widget-title">',  
  300. 'after_title' => '</h3>',  
  301. ) ); 
  302. register_sidebar( array( 
  303. 'name' => __( 'Site Pages Sidebar', 'bre-bootstrap-ecommerce' ),  
  304. 'id' => 'sidebar-page',  
  305. 'description' => __( 'Appears in pages', 'bre-bootstrap-ecommerce' ),  
  306. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  307. 'after_widget' => '</aside>',  
  308. 'before_title' => '<h3 class="widget-title">',  
  309. 'after_title' => '</h3>',  
  310. ) ); 
  311. register_sidebar( array( 
  312. 'name' => __( 'Shoppingcart/Checkout Pages Sidebar', 'bre-bootstrap-ecommerce' ),  
  313. 'id' => 'sidebar-shoppingcart-checkout',  
  314. 'description' => __( 'Appears in shoppingcart-checkout template', 'bre-bootstrap-ecommerce' ),  
  315. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  316. 'after_widget' => '</aside>',  
  317. 'before_title' => '<h3 class="widget-title">',  
  318. 'after_title' => '</h3>',  
  319. ) ); 
  320. register_sidebar( array( 
  321. 'name' => __( 'Author Page Sidebar', 'bre-bootstrap-ecommerce' ),  
  322. 'id' => 'sidebar-author',  
  323. 'description' => __( 'Appears in author template', 'bre-bootstrap-ecommerce' ),  
  324. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  325. 'after_widget' => '</aside>',  
  326. 'before_title' => '<h3 class="widget-title">',  
  327. 'after_title' => '</h3>',  
  328. ) ); 
  329. register_sidebar( array( 
  330. 'name' => __( 'Customer Account Pages Sidebar', 'bre-bootstrap-ecommerce' ),  
  331. 'id' => 'sidebar-account',  
  332. 'description' => __( 'Appears in Customer Account Pages templates', 'bre-bootstrap-ecommerce' ),  
  333. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  334. 'after_widget' => '</aside>',  
  335. 'before_title' => '<h3 class="widget-title">',  
  336. 'after_title' => '</h3>',  
  337. ) ); 
  338. register_sidebar( array( 
  339. 'name' => __( 'Community Sidebar', 'bre-bootstrap-ecommerce' ),  
  340. 'id' => 'sidebar-buddypress',  
  341. 'description' => __( 'Appears in Buddypress community templates', 'bre-bootstrap-ecommerce' ),  
  342. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  343. 'after_widget' => '</aside>',  
  344. 'before_title' => '<h3 class="widget-title">',  
  345. 'after_title' => '</h3>',  
  346. ) ); 
  347. register_sidebar( array( 
  348. 'name' => __( 'In TCP loop', 'bre-bootstrap-ecommerce' ),  
  349. 'id' => 'sidebar-loop-details',  
  350. 'description' => __( 'Appears in tcp loops, after excerpt', 'bre-bootstrap-ecommerce' ),  
  351. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  352. 'after_widget' => '</aside>',  
  353. 'before_title' => '<h3 class="widget-title">',  
  354. 'after_title' => '</h3>',  
  355. ) ); 
  356. register_sidebar( array( 
  357. 'name' => __( 'Below the purchase area', 'bre-bootstrap-ecommerce' ),  
  358. 'id' => 'sidebar-buying-area',  
  359. 'description' => __( 'Appears in product details page, below the purchase area', 'bre-bootstrap-ecommerce' ),  
  360. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  361. 'after_widget' => '</aside>',  
  362. 'before_title' => '<h3 class="widget-title">',  
  363. 'after_title' => '</h3>',  
  364. ) ); 
  365. register_sidebar( array( 
  366. 'name' => __( 'Product Detail Tab 1', 'bre-bootstrap-ecommerce' ),  
  367. 'id' => 'sidebar-product-tab1',  
  368. 'description' => __( 'Second tab in single product page', 'bre-bootstrap-ecommerce' ),  
  369. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  370. 'after_widget' => '</aside>',  
  371. 'before_title' => '<h3 class="widget-title">',  
  372. 'after_title' => '</h3>',  
  373. ) ); 
  374. register_sidebar( array( 
  375. 'name' => __( 'Product Detail Tab 2', 'bre-bootstrap-ecommerce' ),  
  376. 'id' => 'sidebar-product-tab2',  
  377. 'description' => __( 'Third tab in single product page', 'bre-bootstrap-ecommerce' ),  
  378. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  379. 'after_widget' => '</aside>',  
  380. 'before_title' => '<h3 class="widget-title">',  
  381. 'after_title' => '</h3>',  
  382. ) ); 
  383. register_sidebar( array( 
  384. 'name' => __( 'Product Detail Tab 3', 'bre-bootstrap-ecommerce' ),  
  385. 'id' => 'sidebar-product-tab3',  
  386. 'description' => __( 'Fourth tab in single product page', 'bre-bootstrap-ecommerce' ),  
  387. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  388. 'after_widget' => '</aside>',  
  389. 'before_title' => '<h3 class="widget-title">',  
  390. 'after_title' => '</h3>',  
  391. ) ); 
  392. register_sidebar( array( 
  393. 'name' => __( 'Cross Sales/Content Sidebar', 'bre-bootstrap-ecommerce' ),  
  394. 'id' => 'sidebar-cross',  
  395. 'description' => __( 'Appears after the content in single, category, single-product and taxonomy templates (blog and store). Cross sales and cross content !', 'bre-bootstrap-ecommerce' ),  
  396. 'before_widget' => '<aside id="%1$s" class="cross-content %2$s clearfix">',  
  397. 'after_widget' => '</aside>',  
  398. 'before_title' => '<h3 class="widget-title">',  
  399. 'after_title' => '</h3>',  
  400. ) ); 
  401. register_sidebar( array( 
  402. 'name' => __( 'Horizontal Layered Navigation support', 'bre-bootstrap-ecommerce' ),  
  403. 'id' => 'sidebar-layered',  
  404. 'description' => __( 'Add support for horizontal layered navigation. Appears before the loop in taxonomy template. ', 'bre-bootstrap-ecommerce' ),  
  405. 'before_widget' => '',  
  406. 'after_widget' => '',  
  407. 'before_title' => '',  
  408. 'after_title' => '',  
  409. ) ); 
  410. register_sidebar( array( 
  411. 'name' => __( 'First Front Page Widget Area', 'bre-bootstrap-ecommerce' ),  
  412. 'id' => 'sidebar-2',  
  413. 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'bre-bootstrap-ecommerce' ),  
  414. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  415. 'after_widget' => '</aside>',  
  416. 'before_title' => '<h3 class="widget-title">',  
  417. 'after_title' => '</h3>',  
  418. ) ); 
  419.  
  420. register_sidebar( array( 
  421. 'name' => __( 'Second Front Page Widget Area', 'bre-bootstrap-ecommerce' ),  
  422. 'id' => 'sidebar-3',  
  423. 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'bre-bootstrap-ecommerce' ),  
  424. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  425. 'after_widget' => '</aside>',  
  426. 'before_title' => '<h3 class="widget-title">',  
  427. 'after_title' => '</h3>',  
  428. ) ); 
  429. register_sidebar( array( 
  430. 'name' => __( 'First footer Widget Area', 'bre-bootstrap-ecommerce' ),  
  431. 'id' => 'sidebar-footer-1',  
  432. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  433. 'after_widget' => '</aside>',  
  434. 'before_title' => '<h3 class="widget-title">',  
  435. 'after_title' => '</h3>',  
  436. ) ); 
  437. register_sidebar( array( 
  438. 'name' => __( 'Second footer Widget Area', 'bre-bootstrap-ecommerce' ),  
  439. 'id' => 'sidebar-footer-2',  
  440. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  441. 'after_widget' => '</aside>',  
  442. 'before_title' => '<h3 class="widget-title">',  
  443. 'after_title' => '</h3>',  
  444. ) ); 
  445. register_sidebar( array( 
  446. 'name' => __( 'Third footer Widget Area', 'bre-bootstrap-ecommerce' ),  
  447. 'id' => 'sidebar-footer-3',  
  448. 'before_widget' => '<aside id="%1$s" class="widget %2$s clearfix">',  
  449. 'after_widget' => '</aside>',  
  450. 'before_title' => '<h3 class="widget-title">',  
  451. 'after_title' => '</h3>',  
  452. ) ); 
  453. add_action( 'widgets_init', 'bre_widgets_init' ); 
  454.  
  455. if ( ! function_exists( 'bre_content_nav' ) ) : 
  456. /** 
  457. * Displays navigation to next/previous pages when applicable. 
  458. * 
  459. * @since Bootstrap eCommerce 1.0 
  460. */ 
  461. function bre_content_nav( $html_id ) { 
  462. global $wp_query; 
  463.  
  464. $html_id = esc_attr( $html_id ); 
  465.  
  466. if ( $wp_query->max_num_pages > 1 ) : ?> 
  467. <nav id="<?php echo $html_id; ?>" class="navigation" role="navigation"> 
  468. <h3 class="assistive-text"><?php _e( 'Post navigation', 'bre-bootstrap-ecommerce' ); ?></h3> 
  469. <div class="nav-previous alignleft"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'bre-bootstrap-ecommerce' ) ); ?></div> 
  470. <div class="nav-next alignright"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'bre-bootstrap-ecommerce' ) ); ?></div> 
  471. </nav><!-- #<?php echo $html_id; ?> .navigation --> 
  472. <?php endif; 
  473. endif; 
  474.  
  475. if ( ! function_exists( 'bre_comment' ) ) : 
  476. /** 
  477. * Template for comments and pingbacks. 
  478. * 
  479. * To override this walker in a child theme without modifying the comments template 
  480. * simply create your own bre_comment(), and that function will be used instead. 
  481. * 
  482. * Used as a callback by wp_list_comments() for displaying the comments. 
  483. * 
  484. * @since Bootstrap eCommerce 1.0 
  485. */ 
  486. function bre_comment( $comment, $args, $depth ) { 
  487. $GLOBALS['comment'] = $comment; 
  488. switch ( $comment->comment_type ) : 
  489. case 'pingback' : 
  490. case 'trackback' : 
  491. // Display trackbacks differently than normal comments. 
  492. ?> 
  493. <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> 
  494. <p><?php _e( 'Pingback:', 'bre-bootstrap-ecommerce' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'bre-bootstrap-ecommerce' ), '<span class="edit-link">', '</span>' ); ?></p> 
  495. <?php 
  496. break; 
  497. default : 
  498. // Proceed with normal comments. 
  499. global $post; 
  500. ?> 
  501. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 
  502. <article id="comment-<?php comment_ID(); ?>" class="comment"> 
  503. <header class="comment-meta comment-author vcard"> 
  504. <?php 
  505. echo get_avatar( $comment, 44 ); 
  506. printf( '<cite class="fn">%1$s %2$s</cite>',  
  507. get_comment_author_link(),  
  508. // If current post author is also comment author, make it known visually. 
  509. ( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'bre-bootstrap-ecommerce' ) . '</span>' : '' 
  510. ); 
  511. printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',  
  512. esc_url( get_comment_link( $comment->comment_ID ) ),  
  513. get_comment_time( 'c' ),  
  514. /** translators: 1: date, 2: time */ 
  515. sprintf( __( '%1$s at %2$s', 'bre-bootstrap-ecommerce' ), get_comment_date(), get_comment_time() ) 
  516. ); 
  517. ?> 
  518. </header><!-- .comment-meta --> 
  519.  
  520. <?php if ( '0' == $comment->comment_approved ) : ?> 
  521. <p class="comment-awaiting-moderation alert alert-info"><?php _e( 'Your comment is awaiting moderation.', 'bre-bootstrap-ecommerce' ); ?></p> 
  522. <?php endif; ?> 
  523.  
  524. <section class="comment-content comment"> 
  525. <?php comment_text(); ?> 
  526. <?php edit_comment_link( __( 'Edit', 'bre-bootstrap-ecommerce' ), '<p class="edit-link btn btn-mini">', '</p>' ); ?> 
  527. </section><!-- .comment-content --> 
  528.  
  529. <div class="reply"> 
  530. <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'bre-bootstrap-ecommerce' ), 'after' => ' <span>↓</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> 
  531. </div><!-- .reply --> 
  532. </article><!-- #comment-## --> 
  533. <?php 
  534. break; 
  535. endswitch; // end comment_type check 
  536. endif; 
  537.  
  538. if ( ! function_exists( 'bre_entry_meta' ) ) : 
  539. /** 
  540. * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. 
  541. * 
  542. * Create your own bre_entry_meta() to override in a child theme. 
  543. * 
  544. * @since Bootstrap eCommerce 1.0 
  545. */ 
  546. function bre_entry_meta() { 
  547. // Translators: used between list items, there is a space after the comma. 
  548. $categories_list = get_the_category_list( __( ', ', 'bre-bootstrap-ecommerce' ) ); 
  549.  
  550. // Translators: used between list items, there is a space after the comma. 
  551. $tag_list = get_the_tag_list( '', __( ', ', 'bre-bootstrap-ecommerce' ) ); 
  552.  
  553. $date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',  
  554. esc_url( get_permalink() ),  
  555. esc_attr( get_the_time() ),  
  556. esc_attr( get_the_date( 'c' ) ),  
  557. esc_html( get_the_date() ) 
  558. ); 
  559.  
  560. $author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',  
  561. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),  
  562. esc_attr( sprintf( __( 'View all posts by %s', 'bre-bootstrap-ecommerce' ), get_the_author() ) ),  
  563. get_the_author() 
  564. ); 
  565.  
  566. // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. 
  567. if ( $tag_list ) { 
  568. $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'bre-bootstrap-ecommerce' ); 
  569. } elseif ( $categories_list ) { 
  570. $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'bre-bootstrap-ecommerce' ); 
  571. } else { 
  572. $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'bre-bootstrap-ecommerce' ); 
  573.  
  574. printf( 
  575. $utility_text,  
  576. $categories_list,  
  577. $tag_list,  
  578. $date,  
  579. $author 
  580. ); 
  581. endif; 
  582.  
  583. /** 
  584. * Extends the default WordPress body class to denote: 
  585. * 1. Using a full-width layout, when no active widgets in the sidebar 
  586. * or full-width template. 
  587. * 2. Front Page template: thumbnail in use and number of sidebars for 
  588. * widget areas. 
  589. * 3. White or empty background color to change the layout and spacing. 
  590. * 4. Custom fonts enabled. 
  591. * 5. Single or multiple authors. 
  592. * 
  593. * @since Bootstrap eCommerce 1.0 
  594. * 
  595. * @param array Existing class values. 
  596. * @return array Filtered class values. 
  597. */ 
  598. function bre_body_class( $classes ) { 
  599. $background_color = get_background_color(); 
  600.  
  601. if ( is_page_template( 'page-templates/full-width.php' ) ): 
  602. $classes[] = 'full-width'; 
  603. endif; 
  604. if ( is_page_template( 'page-templates/page-account.php' ) ): 
  605. $classes[] = 'template-page-account'; 
  606. endif; 
  607. if ( is_page_template( 'page-templates/page-blog.php' ) ): 
  608. $classes[] = 'template-page-blog'; 
  609. endif; 
  610. if ( is_page_template( 'page-templates/page-shoppingcart-checkout.php' ) ): 
  611. $classes[] = 'template-page-shoppingcart-checkout'; 
  612. endif; 
  613.  
  614.  
  615.  
  616. if ( is_page_template( 'page-templates/front-page.php' ) ) { 
  617. $classes[] = 'template-front-page'; 
  618. if ( has_post_thumbnail() ) 
  619. $classes[] = 'has-post-thumbnail'; 
  620. if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) 
  621. $classes[] = 'two-sidebars'; 
  622.  
  623. if ( is_page_template( 'page-templates/full-width-carousel.php' ) ) { 
  624. $classes[] = 'full-width-carousel'; 
  625. if ( has_post_thumbnail() ) 
  626. $classes[] = 'has-post-thumbnail'; 
  627. if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) 
  628. $classes[] = 'two-sidebars'; 
  629.  
  630.  
  631. if ( empty( $background_color ) ) 
  632. $classes[] = 'custom-background-empty'; 
  633. elseif ( in_array( $background_color, array( 'D7EDFB' ) ) ) 
  634. $classes[] = 'custom-background-default'; 
  635.  
  636. // Enable custom font class only if the font CSS is queued to load. 
  637. if ( wp_style_is( 'bre-fonts', 'queue' ) ) 
  638. $classes[] = 'custom-font-enabled'; 
  639.  
  640. if ( ! is_multi_author() ) 
  641. $classes[] = 'single-author'; 
  642.  
  643. return $classes; 
  644. add_filter( 'body_class', 'bre_body_class' ); 
  645.  
  646. /** 
  647. * Adjusts content_width value for full-width and single image attachment 
  648. * templates, and when there are no active widgets in the sidebar. 
  649. * 
  650. * @since Bootstrap eCommerce 1.0 
  651. */ 
  652. function bre_content_width() { 
  653. if ( is_page_template( 'page-templates/fullwidth-carouselheader.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) { 
  654. global $content_width; 
  655. $content_width = 870; 
  656. add_action( 'template_redirect', 'bre_content_width' ); 
  657.  
  658. /** 
  659. * Add postMessage support for site title and description for the Theme Customizer. 
  660. * 
  661. * @since Bootstrap eCommerce 1.0 
  662. * 
  663. * @param WP_Customize_Manager $wp_customize Theme Customizer object. 
  664. * @return void 
  665. */ 
  666. function bre_customize_register( $wp_customize ) { 
  667. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
  668. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; 
  669. add_action( 'customize_register', 'bre_customize_register' ); 
  670.  
  671. /** 
  672. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. 
  673. * 
  674. * @since Bootstrap eCommerce 1.0 
  675. */ 
  676. function bre_customize_preview_js() { 
  677. wp_enqueue_script( 'bre-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true ); 
  678. add_action( 'customize_preview_init', 'bre_customize_preview_js' ); 
  679.  
  680. /** Free label */ 
  681. add_filter( 'tcp_get_the_price_label', 'my_tcp_get_the_price_label', 10, 3 ); 
  682.  
  683. function my_tcp_get_the_price_label( $label, $post_id, $price ) { 
  684. if ( $price == 0 ) return '<span class="tcp_free">' . __( 'Free', 'bre-bootstrap-ecommerce' ) . '</span>'; 
  685. return $label; 
  686.  
  687. /** bootStrap shortcode support WordPress editor */ 
  688. require_once( trailingslashit( get_template_directory() ) . 'admin/bootstrap-shortcode.php' ); 
  689.  
  690. /** Theme options setup */ 
  691. require_once( trailingslashit( get_template_directory() ) . 'admin/update-version.php' ); 
  692. require_once( trailingslashit( get_template_directory() ) . 'admin/bootstrap-ecommerce-support.class.php' ); 
  693. require_once( trailingslashit( get_template_directory() ) . 'admin/bootstrap-ecommerce-setup.class.php' ); 
  694. require_once( trailingslashit( get_template_directory() ) . 'admin/boostrap-carousel.class.php' ); 
  695.  
  696. if ( function_exists( 'bp_loggedin_user_avatar' ) ) { 
  697. require_once( trailingslashit( get_template_directory() ) . 'admin/BPLoginWidget.class.php' ); 
  698. register_widget( 'BREBPLogin' ); 
  699.  
  700. /** Only show admin bar to administrators */ 
  701. if ( ! current_user_can( 'administrator' ) ) : 
  702. show_admin_bar( false ); 
  703. endif; 
  704.  
  705. /** Login Logout redirect */ 
  706. function redirect_me() { 
  707. //if the user has rights of editor then return don't do anything 
  708. //if(current_user_can('editor')) return; 
  709.  
  710. //get the reffer or you may user home_url() if the "request_to" is not set 
  711. $logout_redirect_url = $_SERVER['HTTP_REFERER']; 
  712. if( ! empty( $_REQUEST['redirect_to'] ) ) wp_safe_redirect( $_REQUEST['redirect_to'] ); 
  713. else wp_redirect( $logout_redirect_url ); 
  714. exit(); 
  715. add_filter('wp_logout', 'redirect_me'); 
  716.  
  717. //redirect user to their buddypress profile if they are trying to view their wp profile 
  718.  
  719. function bre_redirect_user_to_bp_profile() { 
  720. if ( ! defined( 'IS_PROFILE_PAGE' ) ) return false;//if this is not the profile page, do not do anything 
  721. if ( ! function_exists( 'bp_core_get_user_domain' ) ) return ; 
  722. $current_user = wp_get_current_user(); 
  723. $bp_profile_link = bp_core_get_user_domain( $current_user->ID); 
  724. bp_core_redirect( $bp_profile_link ); 
  725. add_action('admin_init', 'bre_redirect_user_to_bp_profile'); 
  726.  
  727. function bre_link_to_bp_profile( $actions, $user ) { 
  728. if ( ! function_exists( 'bp_core_get_user_domain' ) ) return $actions; 
  729. $bp_profile_link = bp_core_get_user_domain( $user->ID ); 
  730. $actions['profile'] = "<a href='".$bp_profile_link."'>Profile</a>";//hook our link 
  731. return $actions; 
  732. add_filter( 'user_row_actions', 'bre_link_to_bp_profile', 10, 2 );//hook our link to row actions 
  733.  
  734. function bre_ecommerce_upgrade() { ?> 
  735. <div style="padding:2px; background:url('<?php echo get_template_directory_uri(); ?>/images/birds.jpg') no-repeat;text-align:left;padding-left:20px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-khtml-border-radius:5px;"> 
  736.  
  737. <p style="color:white;font-weight:bold;font-size:3em;text-shadow: -1px -1px white, 1px 1px #333"><?php echo wp_get_theme(); ?></p> 
  738.  
  739. <p class="socials" style="text-align:left;"> 
  740. <span class="social twitter"> 
  741. <a href="https://twitter.com/thecartpress" class="twitter-follow-button" data-show-count="false" data-size="small">Follow @thecartpress</a> 
  742. <script>!function(d, s, id) {var js, fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)) {js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js, fjs);}}(document, "script", "twitter-wjs");</script> 
  743. </span> 
  744. <span class="social facebook"> 
  745. <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fthecartpress.com%2F&send=false&layout=button_count&width=200&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe> 
  746. </span> 
  747. </p> 
  748. </div> 
  749. <p style="text-align:center;"> 
  750. <span> 
  751. <a class="button" href="http://thecartpres.com" target="_blank" style="">TheCartPress Site</a> 
  752. </span> 
  753. <span> 
  754. <a class="button" href="http://extend.thecartpres.com" target="_blank">Extend: Plugins & Themes</a> 
  755. </span> 
  756. <span> 
  757. <a class="button" href="http://community.thecartpres.com" target="_blank">Support</a> 
  758. </span> 
  759. </p> 
  760. <?php } 
  761.  
  762. function bre_register_taxonomy_brand() { 
  763. if ( function_exists( 'tcp_exist_custom_taxonomy' ) && ! tcp_exist_custom_taxonomy( 'tcp_product_brand' ) ) { 
  764. $labels = array( 
  765. 'name' => _x( 'Brand', 'taxonomy general name', 'bre-bootstrap-ecommerce' ),  
  766. 'desc' => __( 'Brands for products', 'bre-bootstrap-ecommerce' ),  
  767. 'singular_name' => _x( 'Brand', 'taxonomy singular name', 'bre-bootstrap-ecommerce' ),  
  768. 'search_items' => __( 'Search Brands', 'bre-bootstrap-ecommerce' ),  
  769. 'all_items' => __( 'All Brands', 'bre-bootstrap-ecommerce' ),  
  770. 'parent_item' => __( 'Parent Brand', 'bre-bootstrap-ecommerce' ),  
  771. 'parent_item_colon' => __( 'Parent Brand', 'bre-bootstrap-ecommerce' ),  
  772. 'edit_item' => __( 'Edit Brand', 'bre-bootstrap-ecommerce' ),  
  773. 'update_item' => __( 'Update Brand', 'bre-bootstrap-ecommerce' ),  
  774. 'add_new_item' => __( 'Add New Brand', 'bre-bootstrap-ecommerce' ),  
  775. 'new_item_name' => __( 'New Brand Name', 'bre-bootstrap-ecommerce' ),  
  776. ); 
  777. $args = array( 
  778. 'labels' => $labels,  
  779. 'post_type' => TCP_PRODUCT_POST_TYPE,  
  780. 'hierarchical' => true,  
  781. 'query_var' => true, //'cat_prods',  
  782. 'label' => __( 'Brand', 'bre-bootstrap-ecommerce' ),  
  783. 'rewrite' => 'product_brand',  
  784. ); 
  785. register_taxonomy( 'tcp_product_brand', array( TCP_PRODUCT_POST_TYPE ), $args ); 
  786. add_action( 'init', 'bre_register_taxonomy_brand' ); 
  787.  
  788. function bre_is_active_sidebar_and_empty( $sidebar_id ) { 
  789. if ( ! is_active_sidebar( $sidebar_id ) ) return ''; 
  790. ob_start(); 
  791. dynamic_sidebar( $sidebar_id ); 
  792. $out = ob_get_clean(); 
  793. return trim( $out ); 
  794.  
  795. // 
  796. //to disable Compatibility settings 
  797. // 
  798. function bre_tcp_get_setting( $value, $setting_name, $default_value ) { 
  799. if ( 'load_bootstrap_css' == $setting_name || 'load_bootstrap_responsive_css' == $setting_name || 'load_bootstrap_js' == $setting_name ) return false; 
  800. if ( 'see_buy_button_in_content' == $setting_name || 'see_price_in_content' == $setting_name || 'see_image_in_content' == $setting_name ) return false; 
  801. if ( 'use_default_loop' == $setting_name ) return 'only_settings'; 
  802.  
  803. if ( 'load_default_buy_button_style' == $setting_name ) return true; 
  804. if ( 'load_default_shopping_cart_checkout_style' == $setting_name ) return true; 
  805. if ( 'load_default_loop_style' == $setting_name ) return false; 
  806. return $value; 
  807. add_filter( 'tcp_get_setting', 'bre_tcp_get_setting', 10, 3 ); 
  808.  
  809. function bre_tcp_theme_compatibility_settings_page( $suffix, $thecartpress ) { ?> 
  810. <script> 
  811. jQuery( '#use_default_loop_only' ).attr( 'disabled', true ); 
  812. jQuery( '#tcp_theme_compatibility_yes' ).attr( 'disabled', true ); 
  813. jQuery( '#use_default_loop_none' ).attr( 'disabled', true ); 
  814. jQuery( '#load_bootstrap_css' ).attr( 'disabled', true ); 
  815. jQuery( '#load_bootstrap_responsive_css' ).attr( 'disabled', true ); 
  816. jQuery( '#load_bootstrap_js' ).attr( 'disabled', true ); 
  817. jQuery( '#see_buy_button_in_content' ).attr( 'disabled', true ); 
  818. jQuery( '#align_buy_button_in_content' ).attr( 'disabled', true ); 
  819. jQuery( '#see_price_in_content' ).attr( 'disabled', true ); 
  820. jQuery( '#see_image_in_content' ).attr( 'disabled', false ); 
  821. jQuery( '#image_size_content' ).attr( 'disabled', false ); 
  822. jQuery( '#image_align_content' ).attr( 'disabled', false ); 
  823. jQuery( '#image_link_content' ).attr( 'disabled', false ); 
  824. jQuery( '#load_default_buy_button_style' ).attr( 'disabled', true ); 
  825. jQuery( '#load_default_shopping_cart_checkout_style' ).attr( 'disabled', true ); 
  826. jQuery( '#load_default_loop_style' ).attr( 'disabled', true ); 
  827. </script> 
  828. <?php } 
  829. add_action( 'tcp_theme_compatibility_settings_page', 'bre_tcp_theme_compatibility_settings_page', 10, 2 ); 
.