PageRenderTime 63ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/pinboard/functions.php

https://bitbucket.org/mshmsh5000/wp-demo
PHP | 1301 lines | 1073 code | 43 blank | 185 comment | 291 complexity | eb80cd083a735cf9ddad44d2bc0605b0 MD5 | raw file
Possible License(s): Apache-2.0, AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Load the theme options page if in admin mode
  4. */
  5. if ( is_admin() && is_readable( get_template_directory() . '/includes/theme-options.php' ) )
  6. require_once( get_template_directory() . '/includes/theme-options.php' );
  7. if ( ! function_exists( 'pinboard_theme_setup' ) ) :
  8. /*
  9. * Set up theme specific settings
  10. *
  11. * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  12. * @uses register_nav_menus() To add support for navigation menus.
  13. * @uses add_editor_style() To style the visual editor.
  14. * @uses load_theme_textdomain() For translation/localization support.
  15. * @uses add_image_size() To set custom image sizes.
  16. *
  17. * @since Pinboard 1.0
  18. */
  19. function pinboard_theme_setup() {
  20. // Set default content width based on the theme's layout. This affects the width of post images and embedded media.
  21. global $content_width;
  22. if( ! isset( $content_width ) ) $content_width = 660;
  23. // Automatically add feed links to document head
  24. add_theme_support( 'automatic-feed-links' );
  25. // Register Primary Navigation Menu
  26. register_nav_menus(
  27. array(
  28. 'primary_nav' => 'Primary Menu', // You can add more menus here
  29. )
  30. );
  31. // Add support for Post Formats
  32. add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
  33. // Add support for post thumbnails and custom image sizes specific to theme locations
  34. add_theme_support( 'post-thumbnails', array( 'post' ) );
  35. add_image_size( 'slider-thumb', 1140, 395, 1 );
  36. add_image_size( 'blog-thumb', 700, ( pinboard_get_option( 'crop_thumbnails' ) ? 300 : 9999 ), ( pinboard_get_option( 'crop_thumbnails' ) ? 1 : 0 ) );
  37. add_image_size( 'teaser-thumb', 332, ( pinboard_get_option( 'crop_thumbnails' ) ? 205 : 9999 ), ( pinboard_get_option( 'crop_thumbnails' ) ? 1 : 0 ) );
  38. add_image_size( 'gallery-1-thumb', 432, 432, 1 );
  39. add_image_size( 'gallery-2-thumb', 268, 268, 1 );
  40. add_image_size( 'gallery-3-thumb', 268, 164, 1 );
  41. add_image_size( 'image-thumb', 700, 9999 );
  42. add_image_size( 'video-thumb', 700, 393, 1 );
  43. // Allows users to set a custom header image
  44. add_theme_support( 'custom-header', array(
  45. 'width' => ( pinboard_get_option( 'retina_header' ) ? 392 : 196 ),
  46. 'height' => ( pinboard_get_option( 'retina_header' ) ? 96 : 48 ),
  47. 'default-text-color' => '333',
  48. 'flex-width' => true,
  49. 'wp-head-callback' => 'pinboard_header_style',
  50. 'admin-head-callback' => 'pinboard_admin_header_style',
  51. 'admin-preview-callback' => 'pinboard_admin_header_image'
  52. ) );
  53. // Allows users to set a custom background
  54. add_theme_support( 'custom-background', array(
  55. 'default-image' => get_template_directory_uri() . '/images/bg.jpg',
  56. ) );
  57. // Styles the post editor
  58. add_editor_style();
  59. // Makes theme translation ready
  60. load_theme_textdomain( 'pinboard', get_template_directory() . '/languages' );
  61. }
  62. endif;
  63. add_action( 'after_setup_theme', 'pinboard_theme_setup' );
  64. if ( ! function_exists( 'pinboard_widgets_init' ) ) :
  65. /**
  66. * Registers theme widget areas
  67. *
  68. * @uses register_sidebar()
  69. *
  70. * @since Pinboard 1.0
  71. */
  72. function pinboard_widgets_init() {
  73. $title_tag = pinboard_get_option( 'widget_title_tag' );
  74. register_sidebar(
  75. array(
  76. 'name' => 'Header',
  77. 'description' => 'Displays in the header. Intended exclusively for displaying ads of standard dimentions.',
  78. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  79. 'after_widget' => '</aside><!-- .widget -->',
  80. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  81. 'after_title' => '</' . $title_tag . '>'
  82. )
  83. );
  84. register_sidebar(
  85. array(
  86. 'name' => 'Sidebar Top',
  87. 'description' => 'Displays in in the main sidebar stacked at the top.',
  88. 'before_widget' => '<div class="column onecol"><aside id="%1$s" class="widget %2$s">',
  89. 'after_widget' => '</aside><!-- .widget --></div>',
  90. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  91. 'after_title' => '</' . $title_tag . '>'
  92. )
  93. );
  94. register_sidebar(
  95. array(
  96. 'name' => 'Sidebar Left',
  97. 'description' => 'Displays in in the main sidebar floated to the left.',
  98. 'before_widget' => '<div class="column onecol"><aside id="%1$s" class="widget %2$s">',
  99. 'after_widget' => '</aside><!-- .widget --></div>',
  100. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  101. 'after_title' => '</' . $title_tag . '>'
  102. )
  103. );
  104. register_sidebar(
  105. array(
  106. 'name' => 'Sidebar Right',
  107. 'description' => 'Displays in in the main sidebar floated to the right.',
  108. 'before_widget' => '<div class="column onecol"><aside id="%1$s" class="widget %2$s">',
  109. 'after_widget' => '</aside><!-- .widget --></div>',
  110. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  111. 'after_title' => '</' . $title_tag . '>'
  112. )
  113. );
  114. register_sidebar(
  115. array(
  116. 'name' => 'Sidebar Bottom',
  117. 'description' => 'Displays in in the main sidebar stacked at the bottom.',
  118. 'before_widget' => '<div class="column onecol"><aside id="%1$s" class="widget %2$s">',
  119. 'after_widget' => '</aside><!-- .widget --></div>',
  120. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  121. 'after_title' => '</' . $title_tag . '>'
  122. )
  123. );
  124. $columns = pinboard_get_option( 'footer_columns' );
  125. if( 1 == $columns )
  126. $grid_class = 'onecol';
  127. elseif( 2 == $columns )
  128. $grid_class = 'twocol';
  129. elseif( 3 == $columns )
  130. $grid_class = 'threecol';
  131. elseif( 4 == $columns )
  132. $grid_class = 'fourcol';
  133. register_sidebar(
  134. array(
  135. 'name' => 'Footer',
  136. 'description' => 'Displays in in the footer area.',
  137. 'before_widget' => '<div class="column ' . $grid_class . '"><aside id="%1$s" class="widget %2$s">',
  138. 'after_widget' => '</aside><!-- .widget --></div>',
  139. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  140. 'after_title' => '</' . $title_tag . '>'
  141. )
  142. );
  143. register_sidebar(
  144. array(
  145. 'name' => '404 Page',
  146. 'description' => 'Displays on 404 Pages in the content area.',
  147. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  148. 'after_widget' => '</aside><!-- .widget -->',
  149. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  150. 'after_title' => '</' . $title_tag . '>'
  151. )
  152. );
  153. register_sidebar(
  154. array(
  155. 'name' => 'Wide',
  156. 'description' => 'Displays on the front page and spans full width.',
  157. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  158. 'after_widget' => '</aside><!-- .widget -->',
  159. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  160. 'after_title' => '</' . $title_tag . '>'
  161. )
  162. );
  163. $columns = pinboard_get_option( 'boxes_columns' );
  164. if( 1 == $columns )
  165. $grid_class = 'onecol';
  166. elseif( 2 == $columns )
  167. $grid_class = 'twocol';
  168. elseif( 3 == $columns )
  169. $grid_class = 'threecol';
  170. elseif( 4 == $columns )
  171. $grid_class = 'fourcol';
  172. register_sidebar(
  173. array(
  174. 'name' => 'Boxes',
  175. 'before_widget' => '<div class="column ' . $grid_class . '"><aside id="%1$s" class="widget %2$s">',
  176. 'after_widget' => '</aside><!-- .widget --></div>',
  177. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  178. 'after_title' => '</' . $title_tag . '>'
  179. )
  180. );
  181. register_sidebar(
  182. array(
  183. 'name' => 'Footer Wide',
  184. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  185. 'after_widget' => '</aside><!-- .widget -->',
  186. 'before_title' => '<' . $title_tag . ' class="widget-title">',
  187. 'after_title' => '</' . $title_tag . '>'
  188. )
  189. );
  190. }
  191. endif;
  192. add_action( 'widgets_init', 'pinboard_widgets_init' );
  193. if ( ! function_exists( 'pinboard_header_style' ) ) :
  194. /**
  195. * Styles the header image displayed on the Appearance > Header admin panel.
  196. *
  197. * @since Pinboard 1.0
  198. */
  199. function pinboard_header_style() { ?>
  200. <style type="text/css">
  201. <?php if ( 'blank' == get_header_textcolor() ) : ?>
  202. #site-title .home,
  203. #site-description {
  204. position:absolute !important;
  205. clip:rect(1px, 1px, 1px, 1px);
  206. }
  207. <?php else : ?>
  208. #site-title a,
  209. #site-description {
  210. color:#<?php header_textcolor(); ?>;
  211. }
  212. <?php endif; ?>
  213. </style>
  214. <?php
  215. }
  216. endif;
  217. if ( ! function_exists( 'pinboard_admin_header_style' ) ) :
  218. /**
  219. * Shows the header image preview in the admin panel.
  220. *
  221. * @since Pinboard 1.0
  222. */
  223. function pinboard_admin_header_style() {
  224. $header_image = get_header_image(); ?>
  225. <style type="text/css">
  226. @import url("<?php echo ( is_ssl() ? 'https' : 'http' ); ?>://fonts.googleapis.com/css?family=Oswald:300|Open+Sans:normal&subset=latin");
  227. .appearance_page_custom-header #headimg {
  228. max-width:1132px;
  229. width:100%;
  230. border:none;
  231. }
  232. #headimg {
  233. padding:0 20px;
  234. background:#F8F8F8;
  235. }
  236. #headimg h1 {
  237. float:left;
  238. margin:0;
  239. font-family:"Oswald", sans-serif;
  240. font-size:32px;
  241. font-weight:bold;
  242. line-height:120px;
  243. }
  244. #headimg h1 a {
  245. text-decoration:none;
  246. }
  247. #desc {
  248. float:left;
  249. margin-left:20px;
  250. font-family:"Open Sans", sans-serif;
  251. font-size:12px;
  252. font-weight:normal;
  253. line-height:120px;
  254. }
  255. #headimg img {
  256. max-width: 100%;
  257. vertical-align:middle;
  258. }
  259. #headimg h1 a,
  260. #desc {
  261. color:#<?php header_textcolor() ?>;
  262. }
  263. </style>
  264. <?php
  265. }
  266. endif;
  267. if ( ! function_exists( 'pinboard_admin_header_image' ) ) :
  268. /**
  269. * Custom header image markup displayed on the Appearance > Header admin panel.
  270. *
  271. * @since Pinboard 1.0
  272. */
  273. function pinboard_admin_header_image() {
  274. if ( 'blank' == get_header_textcolor() || '' == get_header_textcolor() )
  275. $style = ' style="display:none;"';
  276. else
  277. $style = ' style="color:#' . get_header_textcolor() . ';"';
  278. $header_image = get_header_image(); ?>
  279. <div id="headimg">
  280. <h1>
  281. <?php if ( ! empty( $header_image ) ) : ?>
  282. <a id="name" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>">
  283. <img src="<?php header_image(); ?>" alt="<?php bloginfo( 'name' ); ?>" width="<?php echo ( pinboard_get_option( 'retina_header' ) ? absint( get_custom_header()->width / 2 ) : get_custom_header()->width ); ?>" height="<?php echo ( pinboard_get_option( 'retina_header' ) ? absint( get_custom_header()->height / 2 ) : get_custom_header()->height ); ?>" />
  284. </a>
  285. <?php endif; ?>
  286. <a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a>
  287. </h1>
  288. <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
  289. <div class="clear"></div>
  290. </div>
  291. <?php
  292. }
  293. endif;
  294. if ( ! function_exists( 'pinboard_default_options' ) ) :
  295. /**
  296. * Returns an array of theme default options.
  297. *
  298. * @since Pinboard 1.0
  299. */
  300. function pinboard_default_options() {
  301. $options = array(
  302. 'home_page_excerpts' => 2,
  303. 'slider' => true,
  304. 'location' => true,
  305. 'retina_header' => false,
  306. 'crop_thumbnails' => false,
  307. 'lightbox' => true,
  308. 'facebook_link' => '',
  309. 'twitter_link' => '',
  310. 'pinterest_link' => '',
  311. 'flickr_link' => '',
  312. 'youtube_link' => '',
  313. 'vimeo_link' => '',
  314. 'googleplus_link' => '',
  315. 'dribble_link' => '',
  316. 'linkedin_link' => '',
  317. 'portfolio_cat' => -1,
  318. 'portfolio_filter' => true,
  319. 'portfolio_excerpts' => 0,
  320. 'portfolio_archive_excerpts' => 0,
  321. 'portfolio_columns' => 3,
  322. 'portfolio_meta' => true,
  323. 'blog_exclude_portfolio' => true,
  324. 'location' => true,
  325. 'archive_excerpts' => 0,
  326. 'posts_nav' => 'infinite',
  327. 'posts_nav_labels' => 'older/newer',
  328. 'fancy_dropdowns' => true,
  329. 'facebook' => true,
  330. 'twitter' => true,
  331. 'google' => true,
  332. 'pinterest' => true,
  333. 'author_box' => false,
  334. 'copyright_notice' => '&copy; %year% %blogname%',
  335. 'theme_credit_link' => true,
  336. 'author_credit_link' => false,
  337. 'wordpress_credit_link' => true,
  338. 'page_background' => '#f8f8f8',
  339. 'menu_background' => '#111',
  340. 'menu_item_hover_background' => '#555',
  341. 'sidebar_wide_background' => '#eee',
  342. 'content_background' => '#fff',
  343. 'post_meta_background' => '#fcfcfc',
  344. 'footer_area_background' => '#222',
  345. 'footer_background' => '#111',
  346. 'layout' => 'content-sidebar',
  347. 'layout_columns' => 3,
  348. 'boxes_columns' => 3,
  349. 'footer_columns' => 3,
  350. 'hide_sidebar' => false,
  351. 'hide_footer_area' => false,
  352. 'user_css' => '',
  353. 'body_font' => 'open-sans',
  354. 'headings_font' => 'oswald',
  355. 'content_font' => 'open-sans',
  356. 'body_font_size' => '13',
  357. 'body_font_size_unit' => 'px',
  358. 'body_line_height' => '1.62',
  359. 'body_line_height_unit' => 'em',
  360. 'h1_font_size' => '36',
  361. 'h1_font_size_unit' => 'px',
  362. 'h2_font_size' => '32',
  363. 'h2_font_size_unit' => 'px',
  364. 'h3_font_size' => '24',
  365. 'h3_font_size_unit' => 'px',
  366. 'h4_font_size' => '18',
  367. 'h4_font_size_unit' => 'px',
  368. 'headings_line_height' => '1.62',
  369. 'headings_line_height_unit' => 'em',
  370. 'content_font_size' => '15',
  371. 'content_font_size_unit' => 'px',
  372. 'content_line_height' => '1.62',
  373. 'content_line_height_unit' => 'em',
  374. 'mobile_font_size' => '17',
  375. 'mobile_font_size_unit' => 'px',
  376. 'mobile_line_height' => '1.62',
  377. 'mobile_line_height_unit' => 'em',
  378. 'body_color' => '#333',
  379. 'headings_color' => '#333',
  380. 'content_color' => '#333',
  381. 'links_color' => '#21759b',
  382. 'links_hover_color' => '#d54e21',
  383. 'menu_color' => '#f0f0f0',
  384. 'menu_hover_color' => '#fff',
  385. 'sidebar_color' => '#ccc',
  386. 'sidebar_title_color' => '#ccc',
  387. 'sidebar_links_color' => '#7597B9',
  388. 'footer_color' => '#ccc',
  389. 'footer_title_color' => '#e0e0e0',
  390. 'copyright_color' => '#ccc',
  391. 'copyright_links_color' => '#7597B9',
  392. 'home_site_title_tag' => 'h1',
  393. 'home_desc_title_tag' => 'div',
  394. 'home_post_title_tag' => 'h2',
  395. 'archive_site_title_tag' => 'div',
  396. 'archive_desc_title_tag' => 'div',
  397. 'archive_location_title_tag' => 'h1',
  398. 'archive_post_title_tag' => 'h2',
  399. 'single_site_title_tag' => 'div',
  400. 'single_desc_title_tag' => 'div',
  401. 'single_post_title_tag' => 'h1',
  402. 'single_comments_title_tag' => 'h2',
  403. 'single_respond_title_tag' => 'h2',
  404. 'widget_title_tag' => 'h3',
  405. );
  406. return $options;
  407. }
  408. endif;
  409. if ( ! function_exists( 'pinboard_get_option' ) ) :
  410. /**
  411. * Used to output theme options is an elegant way
  412. *
  413. * @uses get_option() To retrieve the options array
  414. *
  415. * @since Pinboard 1.0
  416. */
  417. function pinboard_get_option( $option ) {
  418. global $pinboard_options;
  419. if( ! isset( $pinboard_options ) )
  420. $pinboard_options = get_option( 'pinboard_theme_options', pinboard_default_options() );
  421. return $pinboard_options[ $option ];
  422. }
  423. endif;
  424. if ( ! function_exists( 'pinboard_available_fonts' ) ) :
  425. /**
  426. * Returns an array of fonts available to the theme.
  427. *
  428. * @since Pinboard 1.0
  429. */
  430. function pinboard_available_fonts() {
  431. return array(
  432. 'helvetica' => '"Helvetica Neue", "Nimbus Sans L", sans-serif',
  433. 'verdana' => 'Geneva, Verdana, "DejaVu Sans", sans-serif',
  434. 'tahoma' => 'Tahoma, "DejaVu Sans", sans-serif',
  435. 'trebuchet' => '"Trebuchet MS", "Bitstream Vera Sans", sans-serif',
  436. 'lucida-grande' => '"Lucida Grande", "Lucida Sans Unicode", "Bitstream Vera Sans", sans-serif',
  437. 'droid-sans' => '"Droid Sans", sans-serif',
  438. 'lato' => '"Lato", sans-serif',
  439. 'pt-sans' => '"PT Sans", sans-serif',
  440. 'cantarell' => '"Cantarell", sans-serif',
  441. 'open-sans' => '"Open Sans", sans-serif',
  442. 'oswald' => '"Oswald", sans-serif',
  443. 'yanone-kaffeesatz' => '"Yanone Kaffeesatz", sans-serif',
  444. 'quattrocento-sans' => '"Quattrocento Sans", sans-serif',
  445. 'georgia' => 'Georgia, "URW Bookman L", serif',
  446. 'times' => 'Times, "Times New Roman", "Century Schoolbook L", serif',
  447. 'palatino' => 'Palatino, "Palatino Linotype", "URW Palladio L", serif',
  448. 'droid-serif' => '"Droid Serif", serif',
  449. 'lora' => '"Lora", serif',
  450. 'pt-serif' => '"PT Serif", serif',
  451. 'courier' => 'Courier, "Courier New", "Nimbus Mono L", monospace',
  452. 'monaco' => 'Monaco, Consolas, "Lucida Console", "Bitstream Vera Sans Mono", monospace',
  453. );
  454. }
  455. endif;
  456. if ( ! function_exists( 'pinboard_filter_query' ) ) :
  457. /**
  458. * Filter the main loop
  459. *
  460. * Allows overriding of query parameters
  461. * for the main loop without performing
  462. * additional database queries
  463. *
  464. * @since Pinboard 1.0
  465. */
  466. function pinboard_filter_query( $query ) {
  467. global $wp_the_query;
  468. if( $wp_the_query === $query ) {
  469. if( $query->is_home() && pinboard_get_option( 'slider' ) )
  470. $query->set( 'ignore_sticky_posts', 1 );
  471. if( $query->is_home() && pinboard_get_option( 'blog_exclude_portfolio' ) )
  472. $query->set( 'cat', '-' . pinboard_get_option( 'portfolio_cat' ) );
  473. }
  474. }
  475. endif;
  476. add_action( 'pre_get_posts', 'pinboard_filter_query' );
  477. if ( ! function_exists( 'pinboard_register_styles' ) ) :
  478. /**
  479. * Register theme styles
  480. *
  481. * Registers stylesheets used by the theme.
  482. * Also offers integration with Google Web Fonts Directory
  483. * @uses wp_register_style() To register styles
  484. *
  485. * @since Pinboard 1.0.
  486. */
  487. function pinboard_register_styles() {
  488. $web_fonts = array(
  489. 'droid-sans' => 'Droid+Sans',
  490. 'lato' => 'Lato',
  491. 'pt-sans' => 'PT+Sans',
  492. 'cantarell' => 'Cantarell',
  493. 'open-sans' => 'Open+Sans',
  494. 'oswald' => 'Oswald',
  495. 'yanone-kaffeesatz' => 'Yanone+Kaffeesatz',
  496. 'quattrocento-sans' => 'Quattrocento+Sans',
  497. 'droid-serif' => 'Droid+Serif',
  498. 'lora' => 'Lora',
  499. 'pt-serif' => 'PT+Serif'
  500. );
  501. if( array_key_exists( pinboard_get_option( 'body_font' ), $web_fonts ) || in_array( pinboard_get_option( 'headings_font' ), $web_fonts )|| in_array( pinboard_get_option( 'content_font' ), $web_fonts ) ) {
  502. $web_fonts_stylesheet = 'http' . ( is_ssl() ? 's' : '' ) . '://fonts.googleapis.com/css?family=';
  503. if( array_key_exists( pinboard_get_option( 'body_font' ), $web_fonts ) ) {
  504. $web_fonts_stylesheet .= $web_fonts[pinboard_get_option( 'body_font' )] . ':300,300italic,regular,italic,600,600italic';
  505. }
  506. if( ( pinboard_get_option( 'headings_font' ) != pinboard_get_option( 'body_font' ) ) && array_key_exists( pinboard_get_option( 'headings_font' ), $web_fonts ) ) {
  507. $web_fonts_stylesheet .= '|' . $web_fonts[pinboard_get_option( 'headings_font' )] . ':300,300italic,regular,italic,600,600italic';
  508. }
  509. if( ( pinboard_get_option( 'content_font' ) != pinboard_get_option( 'body_font' ) ) && ( pinboard_get_option( 'content_font' ) != pinboard_get_option( 'headings_font' ) ) && array_key_exists( pinboard_get_option( 'content_font' ), $web_fonts ) ) {
  510. $web_fonts_stylesheet .= '|' . $web_fonts[pinboard_get_option( 'content_font' )] . ':300,300italic,regular,italic,600,600italic';
  511. }
  512. $web_fonts_stylesheet .= '&subset=latin';
  513. } else
  514. $web_fonts_stylesheet = false;
  515. if( false !== $web_fonts_stylesheet ) {
  516. wp_register_style( 'pinboard-web-font', $web_fonts_stylesheet, false, null );
  517. $pinboard_deps = array( 'pinboard-web-font' );
  518. } else
  519. $pinboard_deps = false;
  520. wp_register_style( 'pinboard', get_stylesheet_uri(), $pinboard_deps, null );
  521. wp_register_style( 'colorbox', get_template_directory_uri() . '/styles/colorbox.css', false, null );
  522. wp_register_style( 'mediaelementplayer', get_template_directory_uri() . '/styles/mediaelementplayer.css', false, null );
  523. }
  524. endif;
  525. add_action( 'init', 'pinboard_register_styles' );
  526. if ( ! function_exists( 'pinboard_enqueue_styles' ) ) :
  527. /**
  528. * Enqueue theme styles
  529. *
  530. * @uses wp_enqueue_style() To enqueue styles
  531. *
  532. * @since Pinboard 1.0
  533. */
  534. function pinboard_enqueue_styles() {
  535. //wp_enqueue_style( 'pinboard-web-font' );
  536. wp_enqueue_style( 'pinboard' );
  537. if( pinboard_get_option( 'lightbox' ) )
  538. wp_enqueue_style( 'colorbox' );
  539. wp_enqueue_style( 'mediaelementplayer' );
  540. }
  541. endif;
  542. add_action( 'wp_enqueue_scripts', 'pinboard_enqueue_styles' );
  543. if ( ! function_exists( 'pinboard_register_scripts' ) ) :
  544. /**
  545. * Register theme scripts
  546. *
  547. * @uses wp_register_scripts() To register scripts
  548. *
  549. * @since Pinboard 1.0
  550. */
  551. function pinboard_register_scripts() {
  552. wp_register_script( 'ios-orientationchange-fix', get_template_directory_uri() . '/scripts/ios-orientationchange-fix.js', false, null );
  553. wp_register_script( 'flexslider', get_template_directory_uri() . '/scripts/jquery.flexslider-min.js', array( 'jquery' ), null );
  554. wp_register_script( 'masonry', get_template_directory_uri() . '/scripts/jquery.masonry.min.js', array( 'jquery' ), null );
  555. wp_register_script( 'colorbox', get_template_directory_uri() . '/scripts/colorbox.js', array( 'jquery' ), null );
  556. wp_register_script( 'fitvids', get_template_directory_uri() . '/scripts/fitvids.js', array( 'jquery' ), null );
  557. wp_register_script( 'mediaelement', get_template_directory_uri() . '/scripts/mediaelement.js', array( 'jquery' ), null );
  558. wp_register_script( 'mediaelementplayer', get_template_directory_uri() . '/scripts/mediaelementplayer.js', array( 'mediaelement' ), null );
  559. wp_register_script( 'infinitescroll', get_template_directory_uri() . '/scripts/jquery.infinitescroll.js', array( 'jquery' ), null );
  560. }
  561. endif;
  562. add_action( 'init', 'pinboard_register_scripts' );
  563. if ( ! function_exists( 'pinboard_enqueue_scripts' ) ) :
  564. /**
  565. * Enqueue theme scripts
  566. *
  567. * @uses wp_enqueue_scripts() To enqueue scripts
  568. *
  569. * @since Pinboard 1.0
  570. */
  571. function pinboard_enqueue_scripts() {
  572. wp_enqueue_script( 'ios-orientationchange-fix' );
  573. wp_enqueue_script( 'jquery' );
  574. wp_enqueue_script( 'flexslider' );
  575. wp_enqueue_script( 'fitvids' );
  576. wp_enqueue_script( 'mediaelementplayer' );
  577. if( 'infinite' == pinboard_get_option( 'posts_nav' ) && ! is_singular() && ! is_paged() || ( is_page_template( 'template-blog.php' ) || is_page_template( 'template-blog-full-width.php' ) || is_page_template( 'template-blog-four-col.php' ) || is_page_template( 'template-blog-left-sidebar.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-portfolio.php' ) || is_page_template( 'template-portfolio-right-sidebar.php' ) || is_page_template( 'template-portfolio-four-col.php' ) || is_page_template( 'template-portfolio-left-sidebar.php' ) || is_page_template( 'template-portfolio-no-sidebars.php' ) && ! is_paged() ) )
  578. wp_enqueue_script( 'infinitescroll' );
  579. if( ! is_singular() || is_page_template( 'template-blog.php' ) || is_page_template( 'template-blog-full-width.php' ) || is_page_template( 'template-blog-four-col.php' ) || is_page_template( 'template-blog-left-sidebar.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-portfolio.php' ) || is_page_template( 'template-portfolio-right-sidebar.php' ) || is_page_template( 'template-portfolio-four-col.php' ) || is_page_template( 'template-portfolio-left-sidebar.php' ) || is_page_template( 'template-portfolio-no-sidebars.php' ) )
  580. wp_enqueue_script( 'masonry' );
  581. if( pinboard_get_option( 'lightbox' ) )
  582. wp_enqueue_script( 'colorbox' );
  583. if ( is_singular() && get_option( 'thread_comments' ) )
  584. wp_enqueue_script( 'comment-reply' );
  585. }
  586. endif;
  587. add_action( 'wp_enqueue_scripts', 'pinboard_enqueue_scripts' );
  588. if ( ! function_exists( 'pinboard_html5_shiv' ) ) :
  589. /**
  590. * Outputs the html5.js script with IE conditionals
  591. *
  592. * @since Pinboard 1.0
  593. */
  594. function pinboard_html5_shiv() { ?>
  595. <!--[if lt IE 9]>
  596. <script src="<?php echo get_template_directory_uri(); ?>/scripts/html5.js" type="text/javascript"></script>
  597. <![endif]-->
  598. <?php
  599. }
  600. endif;
  601. add_action( 'wp_print_scripts', 'pinboard_html5_shiv' );
  602. if ( ! function_exists( 'pinboard_call_scripts' ) ) :
  603. /**
  604. * Call script functions in document head
  605. *
  606. * @since Pinboard 1.0
  607. */
  608. function pinboard_call_scripts() { ?>
  609. <script>
  610. /* <![CDATA[ */
  611. jQuery(document).ready(function($) {
  612. $('#access .menu > li > a').each(function() {
  613. var title = $(this).attr('title');
  614. if(typeof title !== 'undefined' && title !== false) {
  615. $(this).append('<br /> <span>'+title+'</span>');
  616. $(this).removeAttr('title');
  617. }
  618. });
  619. function pinboard_move_elements(container) {
  620. if( container.hasClass('onecol') ) {
  621. var thumb = $('.entry-thumbnail', container);
  622. if('undefined' !== typeof thumb)
  623. $('.entry-container', container).before(thumb);
  624. var video = $('.entry-attachment', container);
  625. if('undefined' !== typeof video)
  626. $('.entry-container', container).before(video);
  627. var gallery = $('.post-gallery', container);
  628. if('undefined' !== typeof gallery)
  629. $('.entry-container', container).before(gallery);
  630. var meta = $('.entry-meta', container);
  631. if('undefined' !== typeof meta)
  632. $('.entry-container', container).after(meta);
  633. }
  634. }
  635. function pinboard_restore_elements(container) {
  636. if( container.hasClass('onecol') ) {
  637. var thumb = $('.entry-thumbnail', container);
  638. if('undefined' !== typeof thumb)
  639. $('.entry-header', container).after(thumb);
  640. var video = $('.entry-attachment', container);
  641. if('undefined' !== typeof video)
  642. $('.entry-header', container).after(video);
  643. var gallery = $('.post-gallery', container);
  644. if('undefined' !== typeof gallery)
  645. $('.entry-header', container).after(gallery);
  646. var meta = $('.entry-meta', container);
  647. if('undefined' !== typeof meta)
  648. $('.entry-header', container).append(meta);
  649. else
  650. $('.entry-header', container).html(meta.html());
  651. }
  652. }
  653. if( ($(window).width() > 960) || ($(document).width() > 960) ) {
  654. // Viewport is greater than tablet: portrait
  655. } else {
  656. $('#content .post').each(function() {
  657. pinboard_move_elements($(this));
  658. });
  659. }
  660. $(window).resize(function() {
  661. if( ($(window).width() > 960) || ($(document).width() > 960) ) {
  662. <?php if( is_category( pinboard_get_option( 'portfolio_cat' ) ) || ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) : ?>
  663. $('#content .post').each(function() {
  664. pinboard_restore_elements($(this));
  665. });
  666. <?php else : ?>
  667. $('.page-template-template-full-width-php #content .post, .page-template-template-blog-full-width-php #content .post, .page-template-template-blog-four-col-php #content .post').each(function() {
  668. pinboard_restore_elements($(this));
  669. });
  670. <?php endif; ?>
  671. } else {
  672. $('#content .post').each(function() {
  673. pinboard_move_elements($(this));
  674. });
  675. }
  676. if( ($(window).width() > 760) || ($(document).width() > 760) ) {
  677. var maxh = 0;
  678. $('#access .menu > li > a').each(function() {
  679. if(parseInt($(this).css('height'))>maxh) {
  680. maxh = parseInt($(this).css('height'));
  681. }
  682. });
  683. $('#access .menu > li > a').css('height', maxh);
  684. } else {
  685. $('#access .menu > li > a').css('height', 'auto');
  686. }
  687. });
  688. if( ($(window).width() > 760) || ($(document).width() > 760) ) {
  689. var maxh = 0;
  690. $('#access .menu > li > a').each(function() {
  691. var title = $(this).attr('title');
  692. if(typeof title !== 'undefined' && title !== false) {
  693. $(this).append('<br /> <span>'+title+'</span>');
  694. $(this).removeAttr('title');
  695. }
  696. if(parseInt($(this).css('height'))>maxh) {
  697. maxh = parseInt($(this).css('height'));
  698. }
  699. });
  700. $('#access .menu > li > a').css('height', maxh);
  701. <?php if( pinboard_get_option( 'fancy_dropdowns' ) ) : ?>
  702. $('#access li').mouseenter(function() {
  703. $(this).children('ul').css('display', 'none').stop(true, true).fadeIn(250).css('display', 'block').children('ul').css('display', 'none');
  704. });
  705. $('#access li').mouseleave(function() {
  706. $(this).children('ul').stop(true, true).fadeOut(250).css('display', 'block');
  707. });
  708. <?php endif; ?>
  709. } else {
  710. $('#access li').each(function() {
  711. if($(this).children('ul').length)
  712. $(this).append('<span class="drop-down-toggle"><span class="drop-down-arrow"></span></span>');
  713. });
  714. $('.drop-down-toggle').click(function() {
  715. $(this).parent().children('ul').slideToggle(250);
  716. });
  717. }
  718. <?php if( ( is_home() && ! is_paged() ) || ( is_front_page() && ! is_home() ) || is_page_template( 'template-landing-page.php' ) ) : ?>
  719. $('#slider').flexslider({
  720. selector: '.slides > li',
  721. video: true,
  722. prevText: '&larr;',
  723. nextText: '&rarr;',
  724. pausePlay: true,
  725. pauseText: '||',
  726. playText: '>',
  727. before: function() {
  728. $('#slider .entry-title').hide();
  729. },
  730. after: function() {
  731. $('#slider .entry-title').fadeIn();
  732. }
  733. });
  734. <?php endif; ?>
  735. <?php if( ! is_singular() || is_page_template( 'template-blog.php' ) || is_page_template( 'template-blog-full-width.php' ) || is_page_template( 'template-blog-four-col.php' ) || is_page_template( 'template-blog-left-sidebar.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-portfolio.php' ) || is_page_template( 'template-portfolio-right-sidebar.php' ) || is_page_template( 'template-portfolio-four-col.php' ) || is_page_template( 'template-portfolio-left-sidebar.php' ) || is_page_template( 'template-portfolio-no-sidebars.php' ) ) : ?>
  736. var $content = $('.entries');
  737. $content.imagesLoaded(function() {
  738. $content.masonry({
  739. itemSelector : '.post',
  740. columnWidth : function( containerWidth ) {
  741. return containerWidth / 12;
  742. },
  743. });
  744. });
  745. <?php if( ( ! is_singular() && ! is_paged() ) || ( ( is_page_template( 'template-blog.php' ) || is_page_template( 'template-blog-full-width.php' ) || is_page_template( 'template-blog-four-col.php' ) || is_page_template( 'template-blog-left-sidebar.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-blog-no-sidebars.php' ) || is_page_template( 'template-portfolio.php' ) || is_page_template( 'template-portfolio-right-sidebar.php' ) || is_page_template( 'template-portfolio-four-col.php' ) || is_page_template( 'template-portfolio-left-sidebar.php' ) || is_page_template( 'template-portfolio-no-sidebars.php' ) ) && ! is_paged() ) ) : ?>
  746. <?php if( 'ajax' == pinboard_get_option( 'posts_nav' ) ) : ?>
  747. var nav_link = $('#posts-nav .nav-all a');
  748. if(!nav_link.length)
  749. var nav_link = $('#posts-nav .nav-next a');
  750. if(nav_link.length) {
  751. nav_link.addClass('ajax-load');
  752. nav_link.html('Load more posts');
  753. nav_link.click(function() {
  754. var href = $(this).attr('href');
  755. nav_link.html('<img src="<?php echo get_template_directory_uri(); ?>/images/loading.gif" style="float: none; vertical-align: middle;" /> Loading more posts &#8230;');
  756. $.get(href, function(data) {
  757. var helper = document.createElement('div');
  758. helper = $(helper);
  759. helper.html(data);
  760. var content = $('#content .entries', helper);
  761. $('.entries').append(content.html());
  762. var nav_url = $('#posts-nav .nav-next a', helper).attr('href');
  763. if(typeof nav_url !== 'undefined') {
  764. nav_link.attr('href', nav_url);
  765. nav_link.html('Load more posts');
  766. } else {
  767. $('#posts-nav').html('<span class="ajax-load">There are no more posts to display.</span>');
  768. }
  769. });
  770. return false;
  771. });
  772. }
  773. <?php elseif( 'infinite' == pinboard_get_option( 'posts_nav' ) ) : ?>
  774. $('#content .entries').infinitescroll({
  775. debug : false,
  776. nextSelector : "#posts-nav .nav-all a, #posts-nav .nav-next a",
  777. loadingImg : ( window.devicePixelRatio > 1 ? "<?php echo get_template_directory_uri(); ?>/images/ajax-loading_2x.gif" : "<?php echo get_template_directory_uri(); ?>/images/ajax-loading.gif" ),
  778. loadingText : "Loading more posts &#8230;",
  779. donetext : "There are no more posts to display.",
  780. navSelector : "#posts-nav",
  781. contentSelector : "#content .entries",
  782. itemSelector : "#content .entries .post",
  783. }, function(entries){
  784. var $entries = $( entries ).css({ opacity: 0 });
  785. $entries.imagesLoaded(function(){
  786. $entries.animate({ opacity: 1 });
  787. $content.masonry( 'appended', $entries, true );
  788. });
  789. if( ($(window).width() > 960) || ($(document).width() > 960) ) {
  790. // Viewport is greater than tablet: portrait
  791. } else {
  792. $('#content .post').each(function() {
  793. pinboard_move_elements($(this));
  794. });
  795. }
  796. $('audio,video').mediaelementplayer({
  797. videoWidth: '100%',
  798. videoHeight: '100%',
  799. audioWidth: '100%',
  800. alwaysShowControls: true,
  801. features: ['playpause','progress','tracks','volume'],
  802. videoVolume: 'horizontal'
  803. });
  804. $(".entry-attachment, .entry-content").fitVids({ customSelector: "iframe, object, embed"});
  805. <?php if( pinboard_get_option( 'lightbox' ) ) : ?>
  806. $('.entry-content a[href$=".jpg"],.entry-content a[href$=".jpeg"],.entry-content a[href$=".png"],.entry-content a[href$=".gif"],a.colorbox').colorbox();
  807. <?php endif; ?>
  808. });
  809. <?php endif; ?>
  810. <?php endif; ?>
  811. <?php endif; ?>
  812. $('audio,video').mediaelementplayer({
  813. videoWidth: '100%',
  814. videoHeight: '100%',
  815. audioWidth: '100%',
  816. alwaysShowControls: true,
  817. features: ['playpause','progress','tracks','volume'],
  818. videoVolume: 'horizontal'
  819. });
  820. $(".entry-attachment, .entry-content").fitVids({ customSelector: "iframe, object, embed"});
  821. });
  822. jQuery(window).load(function() {
  823. <?php if( pinboard_get_option( 'lightbox' ) ) : ?>
  824. jQuery('.entry-content a[href$=".jpg"],.entry-content a[href$=".jpeg"],.entry-content a[href$=".png"],.entry-content a[href$=".gif"],a.colorbox').colorbox();
  825. <?php endif; ?>
  826. });
  827. /* ]]> */
  828. </script>
  829. <?php
  830. }
  831. endif;
  832. add_action( 'wp_head', 'pinboard_call_scripts' );
  833. if ( ! function_exists( 'pinboard_custom_styles' ) ) :
  834. /**
  835. * Custom style declarations
  836. *
  837. * Outputs CSS declarations generated by theme options
  838. * and custom user defined CSS in the document <head>
  839. *
  840. * @since Pinboard 1.0
  841. */
  842. function pinboard_custom_styles() {
  843. $default_options = pinboard_default_options();
  844. $fonts = pinboard_available_fonts(); ?>
  845. <style type="text/css">
  846. <?php if( '' == pinboard_get_option( 'facebook_link' ) && '' == pinboard_get_option( 'twitter_link' ) && '' == pinboard_get_option( 'pinterest_link' ) && '' == pinboard_get_option( 'vimeo_link' ) && '' == pinboard_get_option( 'youtube_link' ) && '' == pinboard_get_option( 'flickr_link' ) && '' == pinboard_get_option( 'googleplus_link' ) && '' == pinboard_get_option( 'dribble_link' ) && '' == pinboard_get_option( 'linkedin_link' ) ) : ?>
  847. #header input#s {
  848. width:168px;
  849. box-shadow:inset 1px 1px 5px 1px rgba(0, 0, 0, .1);
  850. text-indent: 0;
  851. }
  852. <?php endif; ?>
  853. <?php if( is_category( pinboard_get_option( 'portfolio_cat' ) ) || ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) : ?>
  854. .post.onecol .entry-header {
  855. float:left;
  856. width:27.6%;
  857. }
  858. .post.onecol .entry-summary {
  859. float:right;
  860. width:69.5%;
  861. }
  862. .post.onecol .wp-post-image,
  863. .post.onecol .entry-attachment,
  864. .post.onecol .post-gallery {
  865. float:right;
  866. max-width:69.5%;
  867. }
  868. .post.onecol .entry-attachment,
  869. .post.onecol .post-gallery {
  870. width:69.5%;
  871. }
  872. .twocol .entry-title,
  873. .threecol .entry-title,
  874. .fourcol .entry-title {
  875. margin: 0;
  876. text-align: center;
  877. }
  878. @media screen and (max-width: 960px) {
  879. .post.onecol .wp-post-image,
  880. .post.onecol .entry-attachment,
  881. .post.onecol .post-gallery {
  882. float:none;
  883. max-width:100%;
  884. margin:0;
  885. }
  886. .post.onecol .entry-attachment,
  887. .post.onecol .post-gallery {
  888. width:100%;
  889. }
  890. .post.onecol .entry-header,
  891. .post.onecol .entry-summary {
  892. float:none;
  893. width:auto;
  894. }
  895. }
  896. <?php endif; ?>
  897. <?php if( pinboard_get_option( 'hide_sidebar' ) ) : ?>
  898. @media screen and (max-width: 760px) {
  899. #sidebar {
  900. display: none;
  901. }
  902. }
  903. <?php endif; ?>
  904. <?php if( pinboard_get_option( 'hide_footer_area' ) ) : ?>
  905. @media screen and (max-width: 760px) {
  906. #footer-area {
  907. display: none;
  908. }
  909. }
  910. <?php endif; ?>
  911. <?php if( $default_options['page_background'] != pinboard_get_option( 'page_background' ) ) : ?>
  912. #wrapper {
  913. background: <?php echo esc_attr( pinboard_get_option( 'page_background' ) ); ?>;
  914. }
  915. <?php endif; ?>
  916. <?php if( $default_options['menu_background'] != pinboard_get_option( 'menu_background' ) ) : ?>
  917. #access {
  918. background: <?php echo esc_attr( pinboard_get_option( 'menu_background' ) ); ?>;
  919. }
  920. <?php endif; ?>
  921. <?php if( $default_options['menu_item_hover_background'] != pinboard_get_option( 'menu_item_hover_background' ) ) : ?>
  922. #access a:hover,
  923. #access li.current_page_item > a,
  924. #access li.current-menu-item > a {
  925. background: <?php echo esc_attr( pinboard_get_option( 'menu_item_hover_background' ) ); ?>;
  926. }
  927. <?php endif; ?>
  928. <?php if( $default_options['sidebar_wide_background'] != pinboard_get_option( 'sidebar_wide_background' ) ) : ?>
  929. #sidebar-wide,
  930. #sidebar-footer-wide,
  931. #current-location {
  932. background: <?php echo esc_attr( pinboard_get_option( 'sidebar_wide_background' ) ); ?>;
  933. }
  934. <?php endif; ?>
  935. <?php if( $default_options['content_background'] != pinboard_get_option( 'content_background' ) ) : ?>
  936. .entry,
  937. #comments,
  938. #respond {
  939. background: <?php echo esc_attr( pinboard_get_option( 'content_background' ) ); ?>;
  940. }
  941. <?php endif; ?>
  942. <?php if( $default_options['post_meta_background'] != pinboard_get_option( 'post_meta_background' ) ) : ?>
  943. .home .entry-meta,
  944. .blog .entry-meta,
  945. .archive .entry-meta,
  946. .search .entry-meta {
  947. background: <?php echo esc_attr( pinboard_get_option( 'post_meta_background' ) ); ?>;
  948. }
  949. <?php endif; ?>
  950. <?php if( $default_options['footer_area_background'] != pinboard_get_option( 'footer_area_background' ) ) : ?>
  951. #footer-area {
  952. background: <?php echo esc_attr( pinboard_get_option( 'footer_area_background' ) ); ?>;
  953. }
  954. <?php endif; ?>
  955. <?php if( $default_options['footer_background'] != pinboard_get_option( 'footer_background' ) ) : ?>
  956. #copyright {
  957. background: <?php echo esc_attr( pinboard_get_option( 'footer_background' ) ); ?>;
  958. }
  959. <?php endif; ?>
  960. <?php if( $default_options['body_font'] != pinboard_get_option( 'body_font' ) ) : ?>
  961. body,
  962. #slider .entry-title,
  963. .page-title,
  964. #sidebar-wide .widget-title,
  965. #sidebar-boxes .widget-title,
  966. #sidebar-footer-wide .widget-title {
  967. font-family:<?php echo $fonts[pinboard_get_option( 'body_font' )]; ?>;
  968. }
  969. h1, h2, h3, h4, h5, h6,
  970. #site-title,
  971. #site-description,
  972. .entry-title,
  973. #comments-title,
  974. #reply-title,
  975. .widget-title {
  976. font-family:<?php echo $fonts[pinboard_get_option( 'headings_font' )]; ?>;
  977. }
  978. .entry-content {
  979. font-family:<?php echo $fonts[pinboard_get_option( 'content_font' )]; ?>;
  980. }
  981. <?php else : ?>
  982. <?php if( $default_options['headings_font'] != pinboard_get_option( 'headings_font' ) ) : ?>
  983. h1, h2, h3, h4, h5, h6 {
  984. font-family:<?php echo $fonts[pinboard_get_option( 'headings_font' )]; ?>;
  985. }
  986. <?php endif; ?>
  987. <?php if( $default_options['content_font'] != pinboard_get_option( 'content_font' ) ) : ?>
  988. .entry-content {
  989. font-family:<?php echo $fonts[pinboard_get_option( 'content_font' )]; ?>;
  990. }
  991. <?php endif; ?>
  992. <?php endif; ?>
  993. <?php if( $default_options['body_font_size'] != pinboard_get_option( 'body_font_size' ) ) : ?>
  994. body {
  995. font-size:<?php echo pinboard_get_option( 'body_font_size' ) . pinboard_get_option( 'body_font_size_unit' ); ?>;
  996. line-height:<?php echo pinboard_get_option( 'body_line_height' ) . pinboard_get_option( 'body_line_height_unit' ); ?>;
  997. }
  998. <?php elseif( $default_options['body_line_height'] != pinboard_get_option( 'body_line_height' ) ) : ?>
  999. body {
  1000. line-height:<?php echo pinboard_get_option( 'body_line_height' ) . pinboard_get_option( 'body_line_height_unit' ); ?>;
  1001. }
  1002. <?php endif; ?>
  1003. <?php if( $default_options['h1_font_size'] != pinboard_get_option( 'h1_font_size' ) ) : ?>
  1004. h1,
  1005. .single .entry-title,
  1006. .page .entry-title,
  1007. .error404 .entry-title {
  1008. font-size:<?php echo pinboard_get_option( 'h1_font_size' ) . pinboard_get_option( 'h1_font_size_unit' ); ?>;
  1009. line-height:<?php echo pinboard_get_option( 'headings_line_height' ) . pinboard_get_option( 'headings_line_height_unit' ); ?>;
  1010. }
  1011. <?php endif; ?>
  1012. <?php if( $default_options['h2_font_size'] != pinboard_get_option( 'h2_font_size' ) ) : ?>
  1013. h2,
  1014. .entry-title {
  1015. font-size:<?php echo pinboard_get_option( 'h2_font_size' ) . pinboard_get_option( 'h2_font_size_unit' ); ?>;
  1016. line-height:<?php echo pinboard_get_option( 'headings_line_height' ) . pinboard_get_option( 'headings_line_height_unit' ); ?>;
  1017. }
  1018. <?php endif; ?>
  1019. <?php if( $default_options['h3_font_size'] != pinboard_get_option( 'h3_font_size' ) ) : ?>
  1020. h3,
  1021. .teaser .entry-title {
  1022. font-size:<?php echo pinboard_get_option( 'h3_font_size' ) . pinboard_get_option( 'h3_font_size_unit' ); ?>;
  1023. line-height:<?php echo pinboard_get_option( 'headings_line_height' ) . pinboard_get_option( 'headings_line_height_unit' ); ?>;
  1024. }
  1025. <?php endif; ?>
  1026. <?php if( $default_options['h4_font_size'] != pinboard_get_option( 'h4_font_size' ) ) : ?>
  1027. h4 {
  1028. font-size:<?php echo pinboard_get_option( 'h4_font_size' ) . pinboard_get_option( 'h4_font_size_unit' ); ?>;
  1029. line-height:<?php echo pinboard_get_option( 'headings_line_height' ) . pinboard_get_option( 'headings_line_height_unit' ); ?>;
  1030. }
  1031. <?php endif; ?>
  1032. <?php if( $default_options['headings_line_height'] != pinboard_get_option( 'headings_line_height' ) ) : ?>
  1033. h1, h2, h3, h4, h5, h6 {
  1034. line-height:<?php echo pinboard_get_option( 'headings_line_height' ) . pinboard_get_option( 'headings_line_height_unit' ); ?>;
  1035. }
  1036. <?php endif; ?>
  1037. <?php if( $default_options['content_font_size'] != pinboard_get_option( 'content_font_size' ) ) : ?>
  1038. .entry-content {
  1039. font-size:<?php echo pinboard_get_option( 'content_font_size' ) . pinboard_get_option( 'content_font_size_unit' ); ?>;
  1040. line-height:<?php echo pinboard_get_option( 'content_line_height' ) . pinboard_get_option( 'content_line_height_unit' ); ?>;
  1041. }
  1042. @media screen and (max-width: 640px) {
  1043. .entry-content {
  1044. font-size:<?php echo pinboard_get_option( 'mobile_font_size' ) . pinboard_get_option( 'content_font_size_unit' ); ?>;
  1045. line-height:<?php echo pinboard_get_option( 'mobile_line_height' ) . pinboard_get_option( 'content_line_height_unit' ); ?>;
  1046. }
  1047. }
  1048. <?php elseif( $default_options['content_line_height'] != pinboard_get_option( 'content_line_height' ) ) : ?>
  1049. .entry-content {
  1050. line-height:<?php echo pinboard_get_option( 'content_line_height' ) . pinboard_get_option( 'content_line_height' ); ?>;
  1051. }
  1052. @media screen and (max-width: 640px) {
  1053. .entry-content {
  1054. font-size:<?php echo pinboard_get_option( 'mobile_font_size' ) . pinboard_get_option( 'mobile_font_size_unit' ); ?>;
  1055. line-height:<?php echo pinboard_get_option( 'mobile_line_height' ) . pinboard_get_option( 'mobile_line_height_unit' ); ?>;
  1056. }
  1057. }
  1058. <?php elseif( $default_options['mobile_font_size'] != pinboard_get_option( 'mobile_font_size' ) ) : ?>
  1059. @media screen and (max-width: 640px) {
  1060. .entry-content {
  1061. font-size:<?php echo pinboard_get_option( 'mobile_font_size' ) . pinboard_get_option( 'mobile_font_size_unit' ); ?>;
  1062. line-height:<?php echo pinboard_get_option( 'mobile_line_height' ) . pinboard_get_option( 'mobile_line_height_unit' ); ?>;
  1063. }
  1064. }
  1065. <?php elseif( $default_options['mobile_line_height'] != pinboard_get_option( 'mobile_line_height' ) ) : ?>
  1066. @media screen and (max-width: 640px) {
  1067. .entry-content {
  1068. line-height:<?php echo pinboard_get_option( 'mobile_line_height' ) . pinboard_get_option( 'mobile_line_height_unit' ); ?>;
  1069. }
  1070. }
  1071. <?php endif; ?>
  1072. <?php if( $default_options['body_color'] != pinboard_get_option( 'body_color' ) ) : ?>
  1073. body {
  1074. color:<?php echo esc_attr( pinboard_get_option( 'body_color' ) ); ?>;
  1075. }
  1076. h1, h2, h3, h4, h5, h6,
  1077. .entry-title,
  1078. .entry-title a {
  1079. color:<?php echo esc_attr( pinboard_get_option( 'headings_color' ) ); ?>;
  1080. }
  1081. .entry-content {
  1082. color:<?php echo pinboard_get_option( 'content_color' ); ?>;
  1083. }
  1084. <?php else : ?>
  1085. <?php if( $default_options['headings_color'] != pinboard_get_option( 'headings_color' ) ) : ?>
  1086. h1, h2, h3, h4, h5, h6,
  1087. .entry-title,
  1088. .entry-title a {
  1089. color:<?php echo esc_attr( pinboard_get_option( 'headings_color' ) ); ?>;
  1090. }
  1091. <?php endif; ?>
  1092. <?php if( $default_options['content_color'] != pinboard_get_option( 'content_color' ) ) : ?>
  1093. .entry-content {
  1094. color:<?php echo esc_attr( pinboard_get_option( 'content_color' ) ); ?>;
  1095. }
  1096. <?php endif; ?>
  1097. <?php endif; ?>
  1098. <?php if( $default_options['links_color'] != pinboard_get_option( 'links_color' ) ) : ?>
  1099. a {
  1100. color:<?php echo esc_attr( pinboard_get_option( 'links_color' ) ); ?>;
  1101. }
  1102. <?php endif; ?>
  1103. <?php if( $default_options['links_hover_color'] != pinboard_get_option( 'links_hover_color' ) ) : ?>
  1104. a:hover {
  1105. color:<?php echo esc_attr( pinboard_get_option( 'links_hover_color' ) ); ?>;
  1106. }
  1107. <?php endif; ?>
  1108. <?php if( $default_options['menu_color'] != pinboard_get_option( 'menu_color' ) ) : ?>
  1109. #access a {
  1110. color:<?php echo esc_attr( pinboard_get_option( 'menu_color' ) ); ?>;
  1111. }
  1112. <?php endif; ?>
  1113. <?php if( $default_options['menu_hover_color'] != pinboard_get_option( 'menu_hover_color' ) ) : ?>
  1114. #access a:hover,
  1115. #access li.current_page_item > a {
  1116. color:<?php echo esc_attr( pinboard_get_option( 'menu_hover_color' ) ); ?>;
  1117. }
  1118. <?php endif; ?>
  1119. <?php if( $default_options['sidebar_color'] != pinboard_get_option( 'sidebar_color' ) ) : ?>
  1120. #sidebar,
  1121. #sidebar-left,
  1122. #sidebar-right {
  1123. color:<?php echo esc_attr( pinboard_get_option( 'sidebar_color' ) ); ?>;
  1124. }
  1125. <?php endif; ?>
  1126. <?php if( $default_options['sidebar_title_color'] != pinboard_get_option( 'sidebar_title_color' ) ) : ?>
  1127. .widget-title {
  1128. color:<?php echo esc_attr( pinboard_get_option( 'sidebar_title_color' ) ); ?>;
  1129. }
  1130. <?php endif; ?>
  1131. <?php if( $default_options['sidebar_links_color'] != pinboard_get_option( 'sidebar_links_color' ) ) : ?>
  1132. .widget-area a {
  1133. color:<?php echo esc_attr( pinboard_get_option( 'sidebar_links_color' ) ); ?>;
  1134. }
  1135. <?php endif; ?>
  1136. <?php if( $default_options['footer_color'] != pinboard_get_option( 'footer_color' ) ) : ?>
  1137. #footer-area {
  1138. color:<?php echo esc_attr( pinboard_get_option( 'footer_color' ) ); ?>;
  1139. }
  1140. <?php endif; ?>
  1141. <?php if( $default_options['footer_title_color'] != pinboard_get_option( 'footer_title_color' ) ) : ?>
  1142. #footer-area .widget-title {
  1143. color:<?php echo esc_attr( pinboard_get_option( 'footer_title_color' ) ); ?>;
  1144. }
  1145. <?php endif; ?>
  1146. <?php if( $default_options['copyright_color'] != pinboard_get_option( 'copyright_color' ) ) : ?>
  1147. #copyright {
  1148. color:<?php echo esc_attr( pinboard_get_option( 'copyright_color' ) ); ?>;
  1149. }
  1150. <?php endif; ?>
  1151. <?php if( $default_options['copyright_links_color'] != pinboard_get_option( 'copyright_links_color' ) ) : ?>
  1152. #copyright a {
  1153. color:<?php echo esc_attr( pinboard_get_option( 'copyright_links_color' ) ); ?>;
  1154. }
  1155. <?php endif; ?>
  1156. <?php echo esc_html( pinboard_get_option( 'user_css' ) ); ?>
  1157. </style>
  1158. <?php
  1159. }
  1160. endif;
  1161. add_action( 'wp_head', 'pinboard_custom_styles' );
  1162. if ( ! function_exists( 'pinboard_body_class' ) ) :
  1163. /**
  1164. * Adds template names to body_class filter
  1165. *
  1166. * The custom layouts are shared with the custom templates
  1167. * and use the same style declarations
  1168. * @since Pinboard 1.0
  1169. */
  1170. function pinboard_body_class( $classes ) {
  1171. if( ! is_page_template() ) {
  1172. $default_options = pinboard_default_options();
  1173. if( 'sidebar-content' == pinboard_get_option( 'layout' ) )
  1174. $classes[] = 'page-template-template-sidebar-content-php';
  1175. elseif( 'sidebar-content-sidebar' == pinboard_get_option( 'layout' ) )
  1176. $classes[] = 'page-template-template-sidebar-content-sidebar-php';
  1177. elseif( 'content-sidebar-half' == pinboard_get_option( 'layout' ) )
  1178. $classes[] = 'page-template-template-content-sidebar-half-php';
  1179. elseif( 'sidebar-content-half' == pinboard_get_option( 'layout' ) )
  1180. $classes[] = 'page-template-template-sidebar-content-half-php';
  1181. elseif( ( 'no-sidebars' == pinboard_get_option( 'layout' ) ) || ( ! is_active_sidebar( 2 ) && ! is_active_sidebar( 3 ) && ! is_active_sidebar( 4 ) && ! is_active_sidebar( 5 ) ) )
  1182. $classes[] = 'page-template-template-no-sidebars-php';
  1183. elseif( 'full-width' == pinboard_get_option( 'layout' ) )
  1184. $classes[] = 'page-template-template-full-width-php';
  1185. }
  1186. return $classes;
  1187. }
  1188. endif;
  1189. add_filter( 'body_class', 'pinboard_body_class' );
  1190. if ( ! function_exists( 'pinboard_doc_title' ) ) :
  1191. /**
  1192. * Output the <title> tag
  1193. *
  1194. * @since Pinboard 1.0
  1195. */
  1196. function pinboard_doc_title( $doc_title ) {
  1197. global $page, $paged;
  1198. $doc_title = str_replace( '&raquo;', '', $doc_title );
  1199. $site_description = get_bloginfo( 'description', 'display' );
  1200. $separator = '#124';
  1201. if ( is_singular() ) {
  1202. if( is_front_page() )
  1203. $doc_title .= get_the_title();
  1204. if ( $paged >= 2 || $page >= 2 )
  1205. $doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
  1206. } else {
  1207. if( ! is_home() )
  1208. $doc_title .= ' &' . $separator . '; ';
  1209. $doc_title .= get_bloginfo( 'name' );
  1210. if ( $paged >= 2 || $page >= 2 )
  1211. $doc_title .= ', ' . __( 'Page', 'pinboard' ) . ' ' . max( $paged, $page );
  1212. }
  1213. if ( ( is_home() ) && $site_description )
  1214. $doc_title .= ' &' . $separator . '; ' . $site_description;
  1215. return $doc_title;
  1216. }
  1217. endif;
  1218. add_filter( 'wp_title', 'pinboard_doc_title' );
  1219. if ( ! function_exists( 'pinboard_current_location' ) ) :
  1220. /**
  1221. * Highlight current location in the archive
  1222. *
  1223. * @since Pinboard 1.0
  1224. */
  1225. function pinboard_current_location() {
  1226. global $pinboard_page_template;
  1227. if ( ! ( is_home() && ! is_paged() ) && ! is_singular() || isset( $pinboard_page_template ) ) {
  1228. if( is_author() )
  1229. $archive = 'author';
  1230. elseif( is_category() || is_tag() ) {
  1231. $archive = get_queried_object()->taxonomy;
  1232. $archive = str_replace( 'post_', '', $archive );
  1233. } else
  1234. $archive = ''; ?>
  1235. <hgroup id="current-location">
  1236. <h6 class="prefix-text"><?php _e( 'Currently browsing', 'pinboard' ); ?> <?php echo $archive; ?></h6>
  1237. <<?php pinboard_title_tag( 'location' ); ?> class="page-title">
  1238. <?php if( isset( $pinboard_page_template ) ) {
  1239. echo the_title();
  1240. } elseif( is_search() ) {
  1241. __( 'Search results for', 'pinboard' ) . ': &quot;' . get_search_query() . '&quot;';
  1242. } elseif( is_author() ) {
  1243. $author = get_userdata( get_query_var( 'author' ) );
  1244. echo $author->display_name;
  1245. } elseif ( is_year() ) {
  1246. echo get_query_var( 'year' );
  1247. } elseif ( is_month() ) {
  1248. echo get_the_time( 'F Y' );
  1249. } elseif ( is_day() ) {
  1250. echo get_the_time( 'F j, Y' );
  1251. } else {
  1252. single_term_title( '' );
  1253. }
  1254. if( is_paged() ) {
  1255. global $page, $paged;
  1256. if( ! is_home() )
  1257. echo ', ';
  1258. echo sprintf( __( 'Page