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

/theme WP a cương/test_wp/wp-content/themes/neighborhood/functions.php

https://gitlab.com/hop23typhu/list-theme
PHP | 1227 lines | 830 code | 250 blank | 147 comment | 154 complexity | c74f7cd0f74747a0d51a5c8f6c0e62da MD5 | raw file
  1. <?php
  2. /* ==================================================
  3. Swift Framework Main Functions
  4. ================================================== */
  5. /* VARIABLE DEFINITIONS
  6. ================================================== */
  7. define('SF_TEMPLATE_PATH', get_template_directory());
  8. define('SF_INCLUDES_PATH', SF_TEMPLATE_PATH . '/includes');
  9. define('SF_FRAMEWORK_PATH', SF_INCLUDES_PATH . '/swift-framework');
  10. define('SF_WIDGETS_PATH', SF_INCLUDES_PATH . '/widgets');
  11. define('SF_LOCAL_PATH', get_template_directory_uri());
  12. /* INCLUDES
  13. ================================================== */
  14. /* Add custom post types */
  15. require_once(SF_INCLUDES_PATH . '/custom-post-types/portfolio-type.php');
  16. require_once(SF_INCLUDES_PATH . '/custom-post-types/team-type.php');
  17. require_once(SF_INCLUDES_PATH . '/custom-post-types/clients-type.php');
  18. require_once(SF_INCLUDES_PATH . '/custom-post-types/testimonials-type.php');
  19. require_once(SF_INCLUDES_PATH . '/custom-post-types/jobs-type.php');
  20. require_once(SF_INCLUDES_PATH . '/custom-post-types/faqs-type.php');
  21. /* Add image resizer */
  22. require_once(SF_INCLUDES_PATH . '/plugins/aq_resizer.php');
  23. /* Add taxonomy meta boxes */
  24. require_once(SF_INCLUDES_PATH . '/taxonomy-meta-class/Tax-meta-class.php');
  25. /* Include plugins */
  26. include(SF_INCLUDES_PATH . '/plugin-includes.php');
  27. include(SF_INCLUDES_PATH . '/plugins/slider-plugin/slider.php');
  28. include(SF_INCLUDES_PATH . '/plugins/love-it-pro/love-it-pro.php');
  29. /* Include widgets */
  30. include(SF_WIDGETS_PATH . '/widget-twitter.php');
  31. include(SF_WIDGETS_PATH . '/widget-flickr.php');
  32. include(SF_WIDGETS_PATH . '/widget-video.php');
  33. include(SF_WIDGETS_PATH . '/widget-posts.php');
  34. include(SF_WIDGETS_PATH . '/widget-portfolio.php');
  35. include(SF_WIDGETS_PATH . '/widget-portfolio-grid.php');
  36. include(SF_WIDGETS_PATH . '/widget-advertgrid.php');
  37. include(SF_WIDGETS_PATH . '/widget-infocus.php');
  38. /* SWIFT FRAMEWORK
  39. ================================================== */
  40. require_once(SF_FRAMEWORK_PATH . '/swift-framework.php');
  41. /* THEME SUPPORT
  42. ================================================== */
  43. add_theme_support( 'structured-post-formats', array(
  44. 'audio', 'gallery', 'image', 'link', 'video'
  45. ) );
  46. add_theme_support( 'post-formats', array(
  47. 'aside', 'chat', 'quote', 'status'
  48. ) );
  49. add_theme_support( 'automatic-feed-links' );
  50. add_theme_support( 'post-thumbnails' );
  51. add_theme_support( 'woocommerce' );
  52. set_post_thumbnail_size( 220, 150, true);
  53. add_image_size( 'widget-image', 94, 70, true);
  54. add_image_size( 'thumb-image', 600, 450, true);
  55. add_image_size( 'thumb-image-twocol', 900, 675, true);
  56. add_image_size( 'thumb-image-onecol', 1280, 960, true);
  57. add_image_size( 'blog-image', 1280, 9999);
  58. add_image_size( 'full-width-image', 1280, 720, true);
  59. add_image_size( 'full-width-image-gallery', 1280, 720, true);
  60. /* CONTENT WIDTH
  61. ================================================== */
  62. if ( ! isset( $content_width ) ) $content_width = 1170;
  63. /* LOAD THEME LANGUAGE
  64. ================================================== */
  65. load_theme_textdomain('swiftframework', SF_TEMPLATE_PATH.'/language');
  66. $locale = get_locale();
  67. $locale_file = SF_TEMPLATE_PATH."/language/$locale.php";
  68. if (is_readable($locale_file)) {
  69. require_once($locale_file);
  70. }
  71. /* LOAD STYLES & SCRIPTS
  72. ================================================== */
  73. function sf_enqueue_styles() {
  74. $options = get_option('sf_neighborhood_options');
  75. $enable_responsive = $options['enable_responsive'];
  76. wp_register_style('bootstrap', SF_LOCAL_PATH . '/css/bootstrap.min.css', array(), NULL, 'screen');
  77. wp_register_style('bootstrap-responsive', SF_LOCAL_PATH . '/css/bootstrap-responsive.min.css', array(), NULL, 'screen');
  78. wp_register_style('fontawesome-css', SF_LOCAL_PATH . '/css/font-awesome.min.css', array(), NULL, 'screen');
  79. wp_register_style('main-css', get_stylesheet_directory_uri() . '/style.css', array(), NULL, 'screen');
  80. wp_register_style('responsive-css', SF_LOCAL_PATH . '/css/responsive.css', array(), NULL, 'screen');
  81. wp_enqueue_style('bootstrap');
  82. wp_enqueue_style('bootstrap-responsive');
  83. wp_enqueue_style('fontawesome-css');
  84. wp_enqueue_style('main-css');
  85. if ($enable_responsive) {
  86. wp_enqueue_style('responsive-css');
  87. }
  88. }
  89. add_action('wp_enqueue_scripts', 'sf_enqueue_styles', 99);
  90. function sf_enqueue_scripts() {
  91. wp_register_script('sf-bootstrap-js', SF_LOCAL_PATH . '/js/bootstrap.min.js', 'jquery', NULL, TRUE);
  92. wp_register_script('sf-flexslider', SF_LOCAL_PATH . '/js/jquery.flexslider-min.js', 'jquery', NULL, TRUE);
  93. wp_register_script('sf-isotope', SF_LOCAL_PATH . '/js/jquery.isotope.min.js', 'jquery', NULL, TRUE);
  94. wp_register_script('sf-hoverIntent', SF_LOCAL_PATH . '/js/jquery.hoverIntent.min.js', 'jquery', NULL, TRUE);
  95. wp_register_script('sf-easing', SF_LOCAL_PATH . '/js/jquery.easing.js', 'jquery', NULL, TRUE);
  96. wp_register_script('sf-carouFredSel', SF_LOCAL_PATH . '/js/jquery.carouFredSel.min.js', 'jquery', NULL, TRUE);
  97. wp_register_script('sf-jquery-ui', SF_LOCAL_PATH . '/js/jquery-ui-1.10.2.custom.min.js', 'jquery', NULL, TRUE);
  98. wp_register_script('sf-prettyPhoto', SF_LOCAL_PATH . '/js/jquery.prettyPhoto.js', 'jquery', NULL, TRUE);
  99. wp_register_script('sf-viewjs', SF_LOCAL_PATH . '/js/view.min.js?auto', 'jquery', NULL, TRUE);
  100. wp_register_script('sf-fitvids', SF_LOCAL_PATH . '/js/jquery.fitvids.js', 'jquery', NULL , TRUE);
  101. wp_register_script('sf-maps', 'http://maps.google.com/maps/api/js?sensor=false', 'jquery', NULL, TRUE);
  102. wp_register_script('sf-respond', SF_LOCAL_PATH . '/js/respond.min.js', 'jquery', NULL, TRUE);
  103. wp_register_script('sf-elevatezoom', SF_LOCAL_PATH . '/js/jquery.elevateZoom.min.js', 'jquery', NULL, TRUE);
  104. wp_register_script('sf-parallax', SF_LOCAL_PATH . '/js/parallaxScripts.min.js', NULL, NULL, TRUE);
  105. wp_register_script('sf-superscrollorama', SF_LOCAL_PATH . '/js/jquery.superscrollorama.js', 'jquery', NULL, TRUE);
  106. wp_register_script('sf-functions', SF_LOCAL_PATH . '/js/functions.js', 'jquery', NULL, TRUE);
  107. wp_enqueue_script('jquery');
  108. wp_enqueue_script('sf-bootstrap-js');
  109. wp_enqueue_script('sf-hoverIntent');
  110. wp_enqueue_script('sf-easing');
  111. wp_enqueue_script('sf-flexslider');
  112. wp_enqueue_script('sf-prettyPhoto');
  113. wp_enqueue_script('sf-fitvids');
  114. wp_enqueue_script('sf-respond');
  115. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
  116. if (!is_account_page()) {
  117. wp_enqueue_script('sf-viewjs');
  118. }
  119. } else {
  120. wp_enqueue_script('sf-viewjs');
  121. }
  122. if (!is_admin()) {
  123. wp_enqueue_script('sf-functions');
  124. }
  125. if (is_singular()) {
  126. wp_enqueue_script('comment-reply');
  127. }
  128. }
  129. add_action('wp_enqueue_scripts', 'sf_enqueue_scripts');
  130. function sf_admin_scripts() {
  131. wp_register_script('admin-functions', get_template_directory_uri() . '/js/sf-admin.js', 'jquery', '1.0', TRUE);
  132. wp_enqueue_script('admin-functions');
  133. }
  134. add_action('admin_init', 'sf_admin_scripts');
  135. function sf_load_custom_script() {
  136. global $include_maps, $include_isotope, $include_carousel, $include_parallax;
  137. if ($include_maps) {
  138. wp_print_scripts('sf-maps');
  139. }
  140. if ($include_isotope) {
  141. wp_print_scripts('sf-isotope');
  142. }
  143. if ($include_carousel) {
  144. wp_print_scripts('sf-carouFredSel');
  145. }
  146. if ($include_parallax) {
  147. wp_print_scripts('sf-parallax');
  148. wp_print_scripts('sf-superscrollorama');
  149. }
  150. $options = get_option('sf_neighborhood_options');
  151. if (isset($options['enable_product_zoom'])) {
  152. $enable_product_zoom = $options['enable_product_zoom'];
  153. if ($enable_product_zoom) {
  154. wp_enqueue_script('sf-elevatezoom');
  155. }
  156. }
  157. }
  158. add_action('wp_footer', 'sf_load_custom_script');
  159. /* MAINTENANCE MODE
  160. ================================================== */
  161. function sf_maintenance_mode() {
  162. $options = get_option('sf_neighborhood_options');
  163. $custom_logo = $custom_logo_output = $maintenance_mode = "";
  164. if (isset($options['custom_admin_login_logo'])) {
  165. $custom_logo = $options['custom_admin_login_logo'];
  166. }
  167. if ($custom_logo) {
  168. $custom_logo_output = '<img src="'. $custom_logo .'" alt="maintenance" style="margin: 0 auto; display: block;" />';
  169. } else {
  170. $custom_logo_output = '<img src="'. get_template_directory_uri() .'/images/custom-login-logo.png" alt="maintenance" style="margin: 0 auto; display: block;" />';
  171. }
  172. if (isset($options['enable_maintenance'])) {
  173. $maintenance_mode = $options['enable_maintenance'];
  174. } else {
  175. $maintenance_mode = false;
  176. }
  177. if ($maintenance_mode) {
  178. if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
  179. wp_die($custom_logo_output . '<p style="text-align:center">We are currently in maintenance mode, please check back shortly.</p>');
  180. }
  181. }
  182. }
  183. add_action('get_header', 'sf_maintenance_mode');
  184. /* BETTER WORDPRESS MINIFY FILTER
  185. ================================================== */
  186. add_filter('bwp_minify_style_ignore', 'sf_bwm_exclude_css');
  187. function sf_bwm_exclude_css($excluded)
  188. {
  189. $excluded = array('fontawesome-css');
  190. return $excluded;
  191. }
  192. /* REVSLIDER RETURN FUNCTION
  193. ================================================== */
  194. function return_slider($revslider_shortcode) {
  195. ob_start();
  196. putRevSlider($revslider_shortcode);
  197. return ob_get_clean();
  198. }
  199. /* CUSTOM ADMIN MENU ITEMS
  200. ================================================== */
  201. if(!function_exists('sf_admin_bar_menu')) {
  202. function sf_admin_bar_menu() {
  203. global $wp_admin_bar;
  204. if ( current_user_can( 'manage_options' ) ) {
  205. $theme_options = array(
  206. 'id' => '1',
  207. 'title' => __('Theme Options', 'swiftframework'),
  208. 'href' => admin_url('/admin.php?page=sf_theme_options'),
  209. 'meta' => array('target' => 'blank')
  210. );
  211. $wp_admin_bar->add_menu($theme_options);
  212. $theme_customizer = array(
  213. 'id' => '2',
  214. 'title' => __('Color Customizer', 'swiftframework'),
  215. 'href' => admin_url('/customize.php'),
  216. 'meta' => array('target' => 'blank')
  217. );
  218. $wp_admin_bar->add_menu($theme_customizer);
  219. }
  220. }
  221. add_action('admin_bar_menu', 'sf_admin_bar_menu', 99);
  222. }
  223. /* ADMIN CUSTOM POST TYPE ICONS
  224. ================================================== */
  225. add_action( 'admin_head', 'sf_admin_css' );
  226. function sf_admin_css() {
  227. ?>
  228. <?php
  229. // Alt Background
  230. $options = get_option('sf_neighborhood_options');
  231. $section_divide_color = get_option('section_divide_color', '#e4e4e4');
  232. $alt_one_bg_color = $options['alt_one_bg_color'];
  233. $alt_one_text_color = $options['alt_one_text_color'];
  234. if (isset($options['alt_one_bg_image'])) {
  235. $alt_one_bg_image = $options['alt_one_bg_image'];
  236. }
  237. $alt_one_bg_image_size = $options['alt_one_bg_image_size'];
  238. $alt_two_bg_color = $options['alt_two_bg_color'];
  239. $alt_two_text_color = $options['alt_two_text_color'];
  240. if (isset($options['alt_two_bg_image'])) {
  241. $alt_two_bg_image = $options['alt_two_bg_image'];
  242. }
  243. $alt_two_bg_image_size = $options['alt_two_bg_image_size'];
  244. $alt_three_bg_color = $options['alt_three_bg_color'];
  245. $alt_three_text_color = $options['alt_three_text_color'];
  246. if (isset($options['alt_three_bg_image'])) {
  247. $alt_three_bg_image = $options['alt_three_bg_image'];
  248. }
  249. $alt_three_bg_image_size = $options['alt_three_bg_image_size'];
  250. $alt_four_bg_color = $options['alt_four_bg_color'];
  251. $alt_four_text_color = $options['alt_four_text_color'];
  252. if (isset($options['alt_four_bg_image'])) {
  253. $alt_four_bg_image = $options['alt_four_bg_image'];
  254. }
  255. $alt_four_bg_image_size = $options['alt_four_bg_image_size'];
  256. $alt_five_bg_color = $options['alt_five_bg_color'];
  257. $alt_five_text_color = $options['alt_five_text_color'];
  258. if (isset($options['alt_five_bg_image'])) {
  259. $alt_five_bg_image = $options['alt_five_bg_image'];
  260. }
  261. $alt_five_bg_image_size = $options['alt_five_bg_image_size'];
  262. $alt_six_bg_color = $options['alt_six_bg_color'];
  263. $alt_six_text_color = $options['alt_six_text_color'];
  264. if (isset($options['alt_six_bg_image'])) {
  265. $alt_six_bg_image = $options['alt_six_bg_image'];
  266. }
  267. $alt_six_bg_image_size = $options['alt_six_bg_image_size'];
  268. $alt_seven_bg_color = $options['alt_seven_bg_color'];
  269. $alt_seven_text_color = $options['alt_seven_text_color'];
  270. if (isset($options['alt_seven_bg_image'])) {
  271. $alt_seven_bg_image = $options['alt_seven_bg_image'];
  272. }
  273. $alt_seven_bg_image_size = $options['alt_seven_bg_image_size'];
  274. $alt_eight_bg_color = $options['alt_eight_bg_color'];
  275. $alt_eight_text_color = $options['alt_eight_text_color'];
  276. if (isset($options['alt_eight_bg_image'])) {
  277. $alt_eight_bg_image = $options['alt_eight_bg_image'];
  278. }
  279. $alt_eight_bg_image_size = $options['alt_eight_bg_image_size'];
  280. $alt_nine_bg_color = $options['alt_nine_bg_color'];
  281. $alt_nine_text_color = $options['alt_nine_text_color'];
  282. if (isset($options['alt_nine_bg_image'])) {
  283. $alt_nine_bg_image = $options['alt_nine_bg_image'];
  284. }
  285. $alt_nine_bg_image_size = $options['alt_nine_bg_image_size'];
  286. $alt_ten_bg_color = $options['alt_ten_bg_color'];
  287. $alt_ten_text_color = $options['alt_ten_text_color'];
  288. if (isset($options['alt_ten_bg_image'])) {
  289. $alt_ten_bg_image = $options['alt_ten_bg_image'];
  290. }
  291. $alt_ten_bg_image_size = $options['alt_ten_bg_image_size'];
  292. ?>
  293. <style type="text/css" media="screen">
  294. #menu-posts-portfolio .wp-menu-image {
  295. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/portfolio.png) no-repeat 6px 7px!important;
  296. background-size: 17px 15px;
  297. }
  298. #menu-posts-portfolio:hover .wp-menu-image, #menu-posts-portfolio.wp-has-current-submenu .wp-menu-image {
  299. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/portfolio_rollover.png) no-repeat 6px 7px!important;
  300. }
  301. #menu-posts-team .wp-menu-image {
  302. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/team.png) no-repeat 6px 11px!important;
  303. background-size: 18px 9px;
  304. }
  305. #menu-posts-team:hover .wp-menu-image, #menu-posts-team.wp-has-current-submenu .wp-menu-image {
  306. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/team_rollover.png) no-repeat 6px 11px!important;
  307. }
  308. #menu-posts-clients .wp-menu-image {
  309. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/clients.png) no-repeat 7px 6px!important;
  310. background-size: 15px 16px;
  311. }
  312. #menu-posts-clients:hover .wp-menu-image, #menu-posts-clients.wp-has-current-submenu .wp-menu-image {
  313. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/clients_rollover.png) no-repeat 7px 6px!important;
  314. }
  315. #menu-posts-testimonials .wp-menu-image {
  316. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/testimonials.png) no-repeat 8px 7px!important;
  317. background-size: 15px 14px;
  318. }
  319. #menu-posts-testimonials:hover .wp-menu-image, #menu-posts-testimonials.wp-has-current-submenu .wp-menu-image {
  320. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/testimonials_rollover.png) no-repeat 8px 7px!important;
  321. }
  322. #menu-posts-jobs .wp-menu-image {
  323. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/jobs.png) no-repeat 7px 8px!important;
  324. background-size: 16px 14px;
  325. }
  326. #menu-posts-jobs:hover .wp-menu-image, #menu-posts-jobs.wp-has-current-submenu .wp-menu-image {
  327. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/jobs_rollover.png) no-repeat 7px 8px!important;
  328. }
  329. #menu-posts-faqs .wp-menu-image {
  330. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/faqs.png) no-repeat 7px 7px!important;
  331. background-size: 15px 16px;
  332. }
  333. #menu-posts-faqs:hover .wp-menu-image, #menu-posts-faqs.wp-has-current-submenu .wp-menu-image {
  334. background: url(<?php echo get_template_directory_uri(); ?>/images/wp/faqs_rollover.png) no-repeat 7px 7px!important;
  335. }
  336. #menu-posts-slide .wp-menu-image img {
  337. width: 16px;
  338. }
  339. #toplevel_page_sf_theme_options .wp-menu-image img {
  340. width: 11px;
  341. margin-top: -2px;
  342. margin-left: 3px;
  343. }
  344. .toplevel_page_sf_theme_options #adminmenu li#toplevel_page_sf_theme_options.wp-has-current-submenu a.wp-has-current-submenu, .toplevel_page_sf_theme_options #adminmenu #toplevel_page_sf_theme_options .wp-menu-arrow div, .toplevel_page_sf_theme_options #adminmenu #toplevel_page_sf_theme_options .wp-menu-arrow {
  345. background: #222;
  346. border-color: #222;
  347. }
  348. #wpbody-content {
  349. min-height: 815px;
  350. }
  351. <?php
  352. echo "\n".'/*========== Asset Background Styles ==========*/'."\n";
  353. echo '.alt-bg {border-color: '.$section_divide_color.';}'. "\n";
  354. echo '.alt-one {background-color: '.$alt_one_bg_color.';}'. "\n";
  355. if (isset($options['alt_one_bg_image']) && $alt_one_bg_image != "") {
  356. if ($alt_one_bg_image_size == "cover") {
  357. echo '.alt-one {background-image: url('.$alt_one_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  358. } else {
  359. echo '.alt-one {background-image: url('.$alt_one_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  360. }
  361. }
  362. echo '.alt-one {color: '.$alt_one_text_color.';}'. "\n";
  363. echo '.alt-one.full-width-text:after {border-top-color:'.$alt_one_bg_color.';}'. "\n";
  364. echo '.alt-two {background-color: '.$alt_two_bg_color.';}'. "\n";
  365. if (isset($options['alt_two_bg_image']) && $alt_two_bg_image != "") {
  366. if ($alt_two_bg_image_size == "cover") {
  367. echo '.alt-two {background-image: url('.$alt_two_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  368. } else {
  369. echo '.alt-two {background-image: url('.$alt_two_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  370. }
  371. }
  372. echo '.alt-two {color: '.$alt_two_text_color.';}'. "\n";
  373. echo '.alt-two.full-width-text:after {border-top-color:'.$alt_two_bg_color.';}'. "\n";
  374. echo '.alt-three {background-color: '.$alt_three_bg_color.';}'. "\n";
  375. if (isset($options['alt_three_bg_image']) && $alt_three_bg_image != "") {
  376. if ($alt_three_bg_image_size == "cover") {
  377. echo '.alt-three {background-image: url('.$alt_three_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  378. } else {
  379. echo '.alt-three {background-image: url('.$alt_three_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  380. }
  381. }
  382. echo '.alt-three {color: '.$alt_three_text_color.';}'. "\n";
  383. echo '.alt-three.full-width-text:after {border-top-color:'.$alt_three_bg_color.';}'. "\n";
  384. echo '.alt-four {background-color: '.$alt_four_bg_color.';}'. "\n";
  385. if (isset($options['alt_four_bg_image']) && $alt_four_bg_image != "") {
  386. if ($alt_four_bg_image_size == "cover") {
  387. echo '.alt-four {background-image: url('.$alt_four_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  388. } else {
  389. echo '.alt-four {background-image: url('.$alt_four_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  390. }
  391. }
  392. echo '.alt-four {color: '.$alt_four_text_color.';}'. "\n";
  393. echo '.alt-four.full-width-text:after {border-top-color:'.$alt_four_bg_color.';}'. "\n";
  394. echo '.alt-five {background-color: '.$alt_five_bg_color.';}'. "\n";
  395. if (isset($options['alt_five_bg_image']) && $alt_five_bg_image != "") {
  396. if ($alt_five_bg_image_size == "cover") {
  397. echo '.alt-five {background-image: url('.$alt_five_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  398. } else {
  399. echo '.alt-five {background-image: url('.$alt_five_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  400. }
  401. }
  402. echo '.alt-five {color: '.$alt_five_text_color.';}'. "\n";
  403. echo '.alt-five.full-width-text:after {border-top-color:'.$alt_five_bg_color.';}'. "\n";
  404. echo '.alt-six {background-color: '.$alt_six_bg_color.';}'. "\n";
  405. if (isset($options['alt_six_bg_image']) && $alt_six_bg_image != "") {
  406. if ($alt_six_bg_image_size == "cover") {
  407. echo '.alt-six {background-image: url('.$alt_six_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  408. } else {
  409. echo '.alt-six {background-image: url('.$alt_six_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  410. }
  411. }
  412. echo '.alt-six {color: '.$alt_six_text_color.';}'. "\n";
  413. echo '.alt-six.full-width-text:after {border-top-color:'.$alt_six_bg_color.';}'. "\n";
  414. echo '.alt-seven {background-color: '.$alt_seven_bg_color.';}'. "\n";
  415. if (isset($options['alt_seven_bg_image']) && $alt_seven_bg_image != "") {
  416. if ($alt_seven_bg_image_size == "cover") {
  417. echo '.alt-seven {background-image: url('.$alt_seven_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  418. } else {
  419. echo '.alt-seven {background-image: url('.$alt_seven_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  420. }
  421. }
  422. echo '.alt-seven {color: '.$alt_seven_text_color.';}'. "\n";
  423. echo '.alt-seven.full-width-text:after {border-top-color:'.$alt_seven_bg_color.';}'. "\n";
  424. echo '.alt-eight {background-color: '.$alt_eight_bg_color.';}'. "\n";
  425. if (isset($options['alt_eight_bg_image']) && $alt_eight_bg_image != "") {
  426. if ($alt_eight_bg_image_size == "cover") {
  427. echo '.alt-eight {background-image: url('.$alt_eight_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  428. } else {
  429. echo '.alt-eight {background-image: url('.$alt_eight_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  430. }
  431. }
  432. echo '.alt-eight {color: '.$alt_eight_text_color.';}'. "\n";
  433. echo '.alt-eight.full-width-text:after {border-top-color:'.$alt_eight_bg_color.';}'. "\n";
  434. echo '.alt-nine {background-color: '.$alt_nine_bg_color.';}'. "\n";
  435. if (isset($options['alt_nine_bg_image']) && $alt_nine_bg_image != "") {
  436. if ($alt_nine_bg_image_size == "cover") {
  437. echo '.alt-nine {background-image: url('.$alt_nine_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  438. } else {
  439. echo '.alt-nine {background-image: url('.$alt_nine_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  440. }
  441. }
  442. echo '.alt-nine {color: '.$alt_nine_text_color.';}'. "\n";
  443. echo '.alt-nine.full-width-text:after {border-top-color:'.$alt_nine_bg_color.';}'. "\n";
  444. echo '.alt-ten {background-color: '.$alt_ten_bg_color.';}'. "\n";
  445. if (isset($options['alt_ten_bg_image']) && $alt_ten_bg_image != "") {
  446. if ($alt_ten_bg_image_size == "cover") {
  447. echo '.alt-ten {background-image: url('.$alt_ten_bg_image.'); background-repeat: no-repeat; background-position: center center; background-size:cover;}'. "\n";
  448. } else {
  449. echo '.alt-ten {background-image: url('.$alt_ten_bg_image.'); background-repeat: repeat; background-position: center center; background-size:auto;}'. "\n";
  450. }
  451. }
  452. echo '.alt-ten {color: '.$alt_nine_text_color.';}'. "\n";
  453. echo '.alt-ten.full-width-text:after {border-top-color:'.$alt_ten_bg_color.';}'. "\n";
  454. ?>
  455. </style>
  456. <?php }
  457. /* BETTER SEO PAGE TITLE
  458. ================================================== */
  459. add_filter( 'wp_title', 'filter_wp_title' );
  460. /**
  461. * Filters the page title appropriately depending on the current page
  462. *
  463. * This function is attached to the 'wp_title' fiilter hook.
  464. *
  465. * @uses get_bloginfo()
  466. * @uses is_home()
  467. * @uses is_front_page()
  468. */
  469. function filter_wp_title( $title ) {
  470. global $page, $paged;
  471. if ( is_feed() )
  472. return $title;
  473. $site_description = get_bloginfo( 'description' );
  474. $filtered_title = $title . get_bloginfo( 'name' );
  475. $filtered_title .= ( ! empty( $site_description ) && ( is_home() || is_front_page() ) ) ? ' | ' . $site_description: '';
  476. $filtered_title .= ( 2 <= $paged || 2 <= $page ) ? ' | ' . sprintf( __( 'Page %s' ), max( $paged, $page ) ) : '';
  477. return $filtered_title;
  478. }
  479. /* SET SIDEBAR GLOBAL
  480. ================================================== */
  481. function sf_set_sidebar_global($sidebar_config) {
  482. global $sidebars;
  483. if (($sidebar_config == "left-sidebar") || ($sidebar_config == "right-sidebar")) {
  484. $sidebars = 'one-sidebar';
  485. } else if ($sidebar_config == "both-sidebars") {
  486. $sidebars = 'both-sidebars';
  487. } else {
  488. $sidebars = 'no-sidebars';
  489. }
  490. }
  491. /* WORDPRESS GALLERY MODS
  492. ================================================== */
  493. add_filter( 'wp_get_attachment_link', 'sant_lightboxadd');
  494. function sant_lightboxadd($content) {
  495. $content = preg_replace("/<a/","<a class=\"view\" rel='gallery'",$content,1);
  496. return $content;
  497. }
  498. add_filter( 'gallery_style', 'custom_gallery_styling', 99 );
  499. function custom_gallery_styling() {
  500. return "<div class='gallery'>";
  501. }
  502. /* WORDPRESS TAG CLOUD WIDGET MODS
  503. ================================================== */
  504. add_filter( 'widget_tag_cloud_args', 'sf_tag_cloud_args' );
  505. function sf_tag_cloud_args( $args ) {
  506. $args['largest'] = 12;
  507. $args['smallest'] = 12;
  508. $args['unit'] = 'px';
  509. $args['format'] = 'list';
  510. return $args;
  511. }
  512. /* WORDPRESS CATEGORY WIDGET MODS
  513. ================================================== */
  514. add_filter('wp_list_categories', 'sf_category_widget_mod');
  515. function sf_category_widget_mod($output) {
  516. $output = str_replace('</a> (',' <span>(',$output);
  517. $output = str_replace(')',')</span></a> ',$output);
  518. return $output;
  519. }
  520. /* WORDPRESS ARCHIVES WIDGET MODS
  521. ================================================== */
  522. add_filter('wp_get_archives', 'sf_archives_widget_mod');
  523. function sf_archives_widget_mod($output) {
  524. $output = str_replace('</a> (',' <span>(',$output);
  525. $output = str_replace(')',')</span></a> ',$output);
  526. return $output;
  527. }
  528. /* GET CUSTOM POST TYPE TAXONOMY LIST
  529. ================================================== */
  530. function get_category_list( $category_name, $filter=0 ){
  531. if (!$filter) {
  532. $get_category = get_categories( array( 'taxonomy' => $category_name ));
  533. $category_list = array( '0' => 'All');
  534. foreach( $get_category as $category ){
  535. if (isset($category->slug)) {
  536. $category_list[] = $category->slug;
  537. }
  538. }
  539. return $category_list;
  540. } else {
  541. $get_category = get_categories( array( 'taxonomy' => $category_name ));
  542. $category_list = array( '0' => 'All');
  543. foreach( $get_category as $category ){
  544. if (isset($category->cat_name)) {
  545. $category_list[] = $category->cat_name;
  546. }
  547. }
  548. return $category_list;
  549. }
  550. }
  551. function get_category_list_key_array($category_name) {
  552. $get_category = get_categories( array( 'taxonomy' => $category_name ));
  553. $category_list = array( 'all' => 'All');
  554. foreach( $get_category as $category ){
  555. if (isset($category->slug)) {
  556. $category_list[$category->slug] = $category->cat_name;
  557. }
  558. }
  559. return $category_list;
  560. }
  561. function get_woo_product_filters_array() {
  562. global $woocommerce;
  563. $attribute_array = array();
  564. $transient_name = 'wc_attribute_taxonomies';
  565. if ( false === ( $attribute_taxonomies = get_transient( $transient_name ) ) ) {
  566. global $wpdb;
  567. $attribute_taxonomies = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies" );
  568. set_transient( $transient_name, $attribute_taxonomies );
  569. }
  570. $attribute_taxonomies = apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
  571. $attribute_array['product_cat'] = __('Product Category', 'swiftframework');
  572. $attribute_array['price'] = __('Price', 'swiftframework');
  573. if ( $attribute_taxonomies ) {
  574. foreach ( $attribute_taxonomies as $tax ) {
  575. $attribute_array[$tax->attribute_name] = $tax->attribute_name;
  576. }
  577. }
  578. return $attribute_array;
  579. }
  580. /* TWEET FUNCTIONS
  581. ================================================== */
  582. function sf_get_tweets($twitterID, $count) {
  583. $content = "";
  584. if (function_exists('getTweets')) {
  585. $tweets = getTweets($count, $twitterID);
  586. if(is_array($tweets)){
  587. foreach($tweets as $tweet){
  588. $content .= '<li>';
  589. if ($tweet['text']) {
  590. $content .= '<div class="tweet-text">';
  591. $the_tweet = $tweet['text'];
  592. /*
  593. Twitter Developer Display Requirements
  594. https://dev.twitter.com/terms/display-requirements
  595. 2.b. Tweet Entities within the Tweet text must be properly linked to their appropriate home on Twitter. For example:
  596. i. User_mentions must link to the mentioned user's profile.
  597. ii. Hashtags must link to a twitter.com search with the hashtag as the query.
  598. iii. Links in Tweet text must be displayed using the display_url
  599. field in the URL entities API response, and link to the original t.co url field.
  600. */
  601. // i. User_mentions must link to the mentioned user's profile.
  602. if(is_array($tweet['entities']['user_mentions'])){
  603. foreach($tweet['entities']['user_mentions'] as $key => $user_mention){
  604. $the_tweet = preg_replace(
  605. '/@'.$user_mention['screen_name'].'/i',
  606. '<a href="http://www.twitter.com/'.$user_mention['screen_name'].'" target="_blank">@'.$user_mention['screen_name'].'</a>',
  607. $the_tweet);
  608. }
  609. }
  610. // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
  611. if(is_array($tweet['entities']['hashtags'])){
  612. foreach($tweet['entities']['hashtags'] as $key => $hashtag){
  613. $the_tweet = preg_replace(
  614. '/#'.$hashtag['text'].'/i',
  615. '<a href="https://twitter.com/search?q=%23'.$hashtag['text'].'&amp;src=hash" target="_blank">#'.$hashtag['text'].'</a>',
  616. $the_tweet);
  617. }
  618. }
  619. // iii. Links in Tweet text must be displayed using the display_url
  620. // field in the URL entities API response, and link to the original t.co url field.
  621. if(is_array($tweet['entities']['urls'])){
  622. foreach($tweet['entities']['urls'] as $key => $link){
  623. $the_tweet = preg_replace(
  624. '`'.$link['url'].'`',
  625. '<a href="'.$link['url'].'" target="_blank">'.$link['url'].'</a>',
  626. $the_tweet);
  627. }
  628. }
  629. $content .= $the_tweet;
  630. $content .= '</div>';
  631. // 3. Tweet Actions
  632. // Reply, Retweet, and Favorite action icons must always be visible for the user to interact with the Tweet. These actions must be implemented using Web Intents or with the authenticated Twitter API.
  633. // No other social or 3rd party actions similar to Follow, Reply, Retweet and Favorite may be attached to a Tweet.
  634. // 4. Tweet Timestamp
  635. // The Tweet timestamp must always be visible and include the time and date. e.g., “3:00 PM - 31 May 12”.
  636. // 5. Tweet Permalink
  637. // The Tweet timestamp must always be linked to the Tweet permalink.
  638. $content .= '<div class="twitter_intents">'. "\n";
  639. $content .= '<a class="reply" href="https://twitter.com/intent/tweet?in_reply_to='.$tweet['id_str'].'"><i class="icon-reply"></i></a>'. "\n";
  640. $content .= '<a class="retweet" href="https://twitter.com/intent/retweet?tweet_id='.$tweet['id_str'].'"><i class="icon-retweet"></i></a>'. "\n";
  641. $content .= '<a class="favorite" href="https://twitter.com/intent/favorite?tweet_id='.$tweet['id_str'].'"><i class="icon-star"></i></a>'. "\n";
  642. $date = strtotime($tweet['created_at']); // retrives the tweets date and time in Unix Epoch terms
  643. $blogtime = current_time('U'); // retrives the current browser client date and time in Unix Epoch terms
  644. $dago = human_time_diff($date, $blogtime) . ' ' . sprintf(__('ago', 'swiftframework')); // calculates and outputs the time past in human readable format
  645. $content .= '<a class="timestamp" href="https://twitter.com/'.$twitterID.'/status/'.$tweet['id_str'].'" target="_blank">'.$dago.'</a>'. "\n";
  646. $content .= '</div>'. "\n";
  647. } else {
  648. $content .= '<a href="http://twitter.com/'.$twitterID.'" target="_blank">@'.$twitterID.'</a>';
  649. }
  650. $content .= '</li>';
  651. }
  652. }
  653. return $content;
  654. } else {
  655. return '<li><div class="tweet-text">Please install the oAuth Twitter Feed Plugin and follow the theme documentation to set it up.</div></li>';
  656. }
  657. }
  658. function sf_hyperlinks($text) {
  659. $text = preg_replace('/\b([a-zA-Z]+:\/\/[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&%#+$*!]*)\b/i',"<a href=\"$1\" class=\"twitter-link\">$1</a>", $text);
  660. $text = preg_replace('/\b(?<!:\/\/)(www\.[\w_.\-]+\.[a-zA-Z]{2,6}[\/\w\-~.?=&%#+$*!]*)\b/i',"<a href=\"http://$1\" class=\"twitter-link\">$1</a>", $text);
  661. // match name@address
  662. $text = preg_replace("/\b([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})\b/i","<a href=\"mailto://$1\" class=\"twitter-link\">$1</a>", $text);
  663. //mach #trendingtopics. Props to Michael Voigt
  664. $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)#{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a href=\"http://twitter.com/#search?q=$2\" class=\"twitter-link\">#$2</a>$3 ", $text);
  665. return $text;
  666. }
  667. function sf_twitter_users($text) {
  668. $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a href=\"http://twitter.com/$2\" class=\"twitter-user\">@$2</a>$3 ", $text);
  669. return $text;
  670. }
  671. function sf_encode_tweet($text) {
  672. $text = mb_convert_encoding( $text, "HTML-ENTITIES", "UTF-8");
  673. return $text;
  674. }
  675. /* VIDEO EMBED FUNCTIONS
  676. ================================================== */
  677. function video_embed($url, $width = 640, $height = 480) {
  678. if (strpos($url,'youtube')){
  679. return video_youtube($url, $width, $height);
  680. } else {
  681. return video_vimeo($url, $width, $height);
  682. }
  683. }
  684. function video_youtube($url, $width = 640, $height = 480){
  685. preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $video_id);
  686. return '<iframe itemprop="video" src="http://www.youtube.com/embed/'. $video_id[1] .'?wmode=transparent" width="'. $width .'" height="'. $height .'" ></iframe>';
  687. }
  688. function video_vimeo($url, $width = 640, $height = 480){
  689. preg_match('/http:\/\/vimeo.com\/(\d+)$/', $url, $video_id);
  690. return '<iframe itemprop="video" src="http://player.vimeo.com/video/'. $video_id[1] .'?title=0&amp;byline=0&amp;portrait=0?wmode=transparent" width="'. $width .'" height="'. $height .'"></iframe>';
  691. }
  692. /* MAP EMBED FUNCTIONS
  693. ================================================== */
  694. function map_embed($address) {
  695. if (!is_string($address))die("All Addresses must be passed as a string");
  696. $address = str_replace(" ", "+", $address); // replcae all the white space with "+" sign to match with google search pattern
  697. $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
  698. $response = @file_get_contents($url);
  699. if ($response === FALSE) {
  700. return "error";
  701. }
  702. $json = json_decode($response,TRUE); //generate array object from the response from the web
  703. if ($json['status'] === "OVER_QUERY_LIMIT") {
  704. return "over_limit";
  705. }
  706. if ($json['status'] === "ZERO_RESULTS") {
  707. return "unknown_address";
  708. }
  709. $_coords['lat'] = $json['results'][0]['geometry']['location']['lat'];
  710. $_coords['long'] = $json['results'][0]['geometry']['location']['lng'];
  711. return $_coords;
  712. }
  713. /* FEATURED IMAGE TITLE
  714. ================================================== */
  715. function sf_featured_img_title() {
  716. global $post;
  717. $sf_thumbnail_id = get_post_thumbnail_id($post->ID);
  718. $sf_thumbnail_image = get_posts(array('p' => $sf_thumbnail_id, 'post_type' => 'attachment', 'post_status' => 'any'));
  719. if ($sf_thumbnail_image && isset($sf_thumbnail_image[0])) {
  720. return $sf_thumbnail_image[0]->post_title;
  721. }
  722. }
  723. /* LANGUAGE FLAGS
  724. ================================================== */
  725. function language_flags() {
  726. $language_output = "";
  727. if (function_exists('icl_get_languages')) {
  728. $languages = icl_get_languages('skip_missing=0&orderby=code');
  729. if(!empty($languages)){
  730. foreach($languages as $l){
  731. $language_output .= '<li>';
  732. if($l['country_flag_url']){
  733. if(!$l['active']) {
  734. $language_output .= '<a href="'.$l['url'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /><span class="language name">'.$l['translated_name'].'</span></a>'."\n";
  735. } else {
  736. $language_output .= '<div class="current-language"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /><span class="language name">'.$l['translated_name'].'</span></div>'."\n";
  737. }
  738. }
  739. $language_output .= '</li>';
  740. }
  741. }
  742. } else {
  743. //echo '<li><div>No languages set.</div></li>';
  744. $flags_url = get_template_directory_uri() . '/images/flags';
  745. $language_output .= '<li><a href="#">DEMO - EXAMPLE PURPOSES</a><li><a href="#"><span class="language name">German</span></a></li><li><div class="current-language"><span class="language name">English</span></div></li><li><a href="#"><span class="language name">Spanish</span></a></li><li><a href="#"><span class="language name">French</span></a></li>'."\n";
  746. }
  747. return $language_output;
  748. }
  749. /* PAGINATION
  750. ================================================== */
  751. function pagination() {
  752. global $wp_query;
  753. $big = 999999999; // need an unlikely integer
  754. return paginate_links( array(
  755. 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
  756. 'format' => '?paged=%#%',
  757. 'current' => max( 1, get_query_var('paged') ),
  758. 'total' => $wp_query->max_num_pages
  759. ) );
  760. }
  761. /* LATEST TWEET FUNCTION
  762. ================================================== */
  763. function latestTweet($count, $twitterID) {
  764. global $include_twitter;
  765. $include_twitter = true;
  766. $content = "";
  767. if (function_exists('getTweets')) {
  768. $tweets = getTweets($count, $twitterID);
  769. if(is_array($tweets)){
  770. foreach($tweets as $tweet){
  771. $content .= '<li>';
  772. if($tweet['text']){
  773. $content .= '<div class="tweet-text">';
  774. $the_tweet = $tweet['text'];
  775. /*
  776. Twitter Developer Display Requirements
  777. https://dev.twitter.com/terms/display-requirements
  778. 2.b. Tweet Entities within the Tweet text must be properly linked to their appropriate home on Twitter. For example:
  779. i. User_mentions must link to the mentioned user's profile.
  780. ii. Hashtags must link to a twitter.com search with the hashtag as the query.
  781. iii. Links in Tweet text must be displayed using the display_url
  782. field in the URL entities API response, and link to the original t.co url field.
  783. */
  784. // i. User_mentions must link to the mentioned user's profile.
  785. if(is_array($tweet['entities']['user_mentions'])){
  786. foreach($tweet['entities']['user_mentions'] as $key => $user_mention){
  787. $the_tweet = preg_replace(
  788. '/@'.$user_mention['screen_name'].'/i',
  789. '<a href="http://www.twitter.com/'.$user_mention['screen_name'].'" target="_blank">@'.$user_mention['screen_name'].'</a>',
  790. $the_tweet);
  791. }
  792. }
  793. // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
  794. if(is_array($tweet['entities']['hashtags'])){
  795. foreach($tweet['entities']['hashtags'] as $key => $hashtag){
  796. $the_tweet = preg_replace(
  797. '/#'.$hashtag['text'].'/i',
  798. '<a href="https://twitter.com/search?q=%23'.$hashtag['text'].'&amp;src=hash" target="_blank">#'.$hashtag['text'].'</a>',
  799. $the_tweet);
  800. }
  801. }
  802. // iii. Links in Tweet text must be displayed using the display_url
  803. // field in the URL entities API response, and link to the original t.co url field.
  804. if(is_array($tweet['entities']['urls'])){
  805. foreach($tweet['entities']['urls'] as $key => $link){
  806. $the_tweet = preg_replace(
  807. '`'.$link['url'].'`',
  808. '<a href="'.$link['url'].'" target="_blank">'.$link['url'].'</a>',
  809. $the_tweet);
  810. }
  811. }
  812. $content .= $the_tweet;
  813. $content .= '</div>';
  814. // 3. Tweet Actions
  815. // Reply, Retweet, and Favorite action icons must always be visible for the user to interact with the Tweet. These actions must be implemented using Web Intents or with the authenticated Twitter API.
  816. // No other social or 3rd party actions similar to Follow, Reply, Retweet and Favorite may be attached to a Tweet.
  817. // 4. Tweet Timestamp
  818. // The Tweet timestamp must always be visible and include the time and date. e.g., “3:00 PM - 31 May 12”.
  819. // 5. Tweet Permalink
  820. // The Tweet timestamp must always be linked to the Tweet permalink.
  821. $content .= '<div class="twitter_intents">'. "\n";
  822. $content .= '<a class="reply" href="https://twitter.com/intent/tweet?in_reply_to='.$tweet['id_str'].'"><i class="icon-reply"></i></a>'. "\n";
  823. $content .= '<a class="retweet" href="https://twitter.com/intent/retweet?tweet_id='.$tweet['id_str'].'"><i class="icon-retweet"></i></a>'. "\n";
  824. $content .= '<a class="favorite" href="https://twitter.com/intent/favorite?tweet_id='.$tweet['id_str'].'"><i class="icon-star"></i></a>'. "\n";
  825. $date = strtotime($tweet['created_at']); // retrives the tweets date and time in Unix Epoch terms
  826. $blogtime = current_time('U'); // retrives the current browser client date and time in Unix Epoch terms
  827. $dago = human_time_diff($date, $blogtime) . ' ' . sprintf(__('ago', 'swiftframework')); // calculates and outputs the time past in human readable format
  828. $content .= '<a class="timestamp" href="https://twitter.com/'.$twitterID.'/status/'.$tweet['id_str'].'" target="_blank">'.$dago.'</a>'. "\n";
  829. $content .= '</div>'. "\n";
  830. } else {
  831. $content .= '<a href="http://twitter.com/'.$twitterID.'" target="_blank">@'.$twitterID.'</a>';
  832. }
  833. $content .= '</li>';
  834. }
  835. }
  836. return $content;
  837. } else {
  838. return '<li><div class="tweet-text">Please install the oAuth Twitter Feed Plugin and follow the theme documentation to set it up.</div></li>';
  839. }
  840. }
  841. /* CONTENT RETURN FUNCTIONS
  842. ================================================== */
  843. function get_the_content_with_formatting() {
  844. $content = get_the_content();
  845. $content = apply_filters('the_content', $content);
  846. $content = str_replace(']]>', ']]&gt;', $content);
  847. return $content;
  848. }
  849. /* SHORTCODE FIX
  850. ================================================== */
  851. function sf_shortcode_fix($content){
  852. $array = array (
  853. '<p>[' => '[',
  854. ']</p>' => ']',
  855. ']<br />' => ']'
  856. );
  857. $content = strtr($content, $array);
  858. return $content;
  859. }
  860. add_filter('the_content', 'sf_shortcode_fix');
  861. /* CATEGORY REL FIX
  862. ================================================== */
  863. function add_nofollow_cat( $text) {
  864. $strings = array('rel="category"', 'rel="category tag"', 'rel="whatever may need"');
  865. $text = str_replace('rel="category tag"', "", $text);
  866. return $text;
  867. }
  868. add_filter( 'the_category', 'add_nofollow_cat' );
  869. /* CUSTOM MENU SETUP
  870. ================================================== */
  871. add_action( 'after_setup_theme', 'setup_menus' );
  872. function setup_menus() {
  873. // This theme uses wp_nav_menu() in four locations.
  874. register_nav_menus( array(
  875. 'main_navigation' => __( 'Main Menu', "swiftframework" ),
  876. 'top_bar_menu' => __( 'Top Bar Menu', "swiftframework" )
  877. ) );
  878. }
  879. add_filter('nav_menu_css_class', 'mbudm_add_page_type_to_menu', 10, 2 );
  880. //If a menu item is a page then add the template name to it as a css class
  881. function mbudm_add_page_type_to_menu($classes, $item) {
  882. if($item->object == 'page'){
  883. $template_name = get_post_meta( $item->object_id, '_wp_page_template', true );
  884. $new_class =str_replace(".php","",$template_name);
  885. array_push($classes, $new_class);
  886. }
  887. return $classes;
  888. }
  889. /* EXCERPT
  890. ================================================== */
  891. function new_excerpt_length($length) {
  892. return 60;
  893. }
  894. add_filter('excerpt_length', 'new_excerpt_length');
  895. // Blog Widget Excerpt
  896. function excerpt($limit) {
  897. $excerpt = explode(' ', get_the_excerpt(), $limit);
  898. if (count($excerpt)>=$limit) {
  899. array_pop($excerpt);
  900. $excerpt = implode(" ",$excerpt).'...';
  901. } else {
  902. $excerpt = implode(" ",$excerpt).'';
  903. }
  904. $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
  905. return '<p>' . $excerpt . '</p>';
  906. }
  907. function content($limit) {
  908. $content = explode(' ', get_the_content(), $limit);
  909. if (count($content)>=$limit) {
  910. array_pop($content);
  911. $content = implode(" ",$content).'...';
  912. } else {
  913. $content = implode(" ",$content).'';
  914. }
  915. $content = preg_replace('/\[.+\]/','', $content);
  916. $content = apply_filters('the_content', $content);
  917. $content = str_replace(']]>', ']]&gt;', $content);
  918. return $content;
  919. }
  920. function custom_excerpt($custom_content, $limit) {
  921. $content = explode(' ', $custom_content, $limit);
  922. if (count($content)>=$limit) {
  923. array_pop($content);
  924. $content = implode(" ",$content).'...';
  925. } else {
  926. $content = implode(" ",$content).'';
  927. }
  928. $content = preg_replace('/\[.+\]/','', $content);
  929. $content = apply_filters('the_content', $content);
  930. $content = str_replace(']]>', ']]&gt;', $content);
  931. return $content;
  932. }
  933. /* REGISTER SIDEBARS
  934. ================================================== */
  935. if ( function_exists('register_sidebar')) {
  936. $options = get_option('sf_neighborhood_options');
  937. if (isset($options['footer_layout'])) {
  938. $footer_config = $options['footer_layout'];
  939. } else {
  940. $footer_config = 'footer-1';
  941. }
  942. register_sidebar(array(
  943. 'name' => 'Sidebar One',
  944. 'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
  945. 'after_widget' => '</section>',
  946. 'before_title' => '<div class="widget-heading clearfix"><h4><span>',
  947. 'after_title' => '</span></h4></div>',
  948. ));
  949. register_sidebar(array(
  950. 'name' => 'Sidebar Two',
  951. 'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
  952. 'after_widget' => '</section>',
  953. 'before_title' => '<div class="widget-heading clearfix"><h4><span>',
  954. 'after_title' => '</span></h4></div>',
  955. ));
  956. register_sidebar(array(
  957. 'name' => 'Sidebar Three',
  958. 'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
  959. 'after_widget' => '</section>',
  960. 'before_title' => '<div class="widget-heading clearfix"><h4><span>',
  961. 'after_title' => '</span></h4></div>',
  962. ));
  963. register_sidebar(array(
  964. 'name' => 'Sidebar Four',
  965. 'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
  966. 'after_widget' => '</section>',
  967. 'before_title' => '<div class="widget-heading clearfix"><h4><span>',
  968. 'after_title' => '</span></h4></div>',
  969. ));
  970. register_sidebar(array(
  971. 'name' => 'Sidebar Five',
  972. 'before_widget' => '<section id="%1$s" class="widget %2$s clearfix">',
  973. 'after_widget' => '</sectio