PageRenderTime 84ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 1ms

/wp-content/themes/artificer/functions/admin-functions.php

https://bitbucket.org/nathancorbier/wastark.com
PHP | 3186 lines | 1944 code | 541 blank | 701 comment | 547 complexity | d69f1f7171626c6b72363513bcc3511a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. // File Security Check
  3. if ( ! defined( 'ABSPATH' ) ) exit;
  4. ?>
  5. <?php
  6. /*-----------------------------------------------------------------------------------
  7. TABLE OF CONTENTS
  8. - woo_image - Get Image from custom field
  9. - vt_resize - Resize post thumbnail
  10. - woo_get_youtube_video_image - Get thumbnail from YouTube
  11. - Add default filters to woo_embed()
  12. - woo_get_embed - Get Video
  13. - Woo Show Page Menu
  14. - Get the style path currently selected
  15. - Get page ID
  16. - Tidy up the image source url
  17. - Show image in RSS feed
  18. - Show analytics code footer
  19. - Browser detection body_class() output
  20. - Twitter's Blogger.js output for Twitter widgets
  21. - Template Detector
  22. - Framework Updater
  23. - WooFramework Update Page
  24. - WooFramework Update Head
  25. - WooFramework Version Getter
  26. - Woo URL shortener
  27. - SEO - woo_title()
  28. - SEO - Strip slashes from the display of the website/page title
  29. - SEO - woo_meta()
  30. - Woo Text Trimmer
  31. - Google Webfonts array
  32. - Google Fonts Stylesheet Generator
  33. - Enable Home link in WP Menus
  34. - Buy Themes page
  35. - Detects the Charset of String and Converts it to UTF-8
  36. - WP Login logo
  37. - WP Login logo URL
  38. - WP Login logo title
  39. - woo_pagination()
  40. - woo_breadcrumbs()
  41. -- woo_breadcrumbs_get_parents()
  42. -- woo_breadcrumbs_get_term_parents()
  43. - WordPress Admin Bar-related
  44. -- Disable WordPress Admin Bar
  45. -- Enhancements to the WordPress Admin Bar
  46. - woo_prepare_category_ids_from_option()
  47. - Move tracking code from footer to header.
  48. - woo_get_dynamic_values()
  49. - woo_get_posts_by_taxonomy()
  50. - If the user has specified a "posts page", load the "Blog" page template there
  51. - PressTrends API Integration
  52. - WooDojo Download Banner
  53. - wooframework_add_woodojo_banner()
  54. - wooframework_ajax_banner_close()
  55. - WooSEO Deprecation Banner
  56. - wooframework_add_wooseo_banner()
  57. - WooSidebars Deprecation Banner
  58. - wooframework_add_woosbm_banner()
  59. - Static Front Page Detection Banner
  60. - wooframework_get_theme_version_data()
  61. - wooframework_display_theme_version_data()
  62. -----------------------------------------------------------------------------------*/
  63. /*-----------------------------------------------------------------------------------*/
  64. /* woo_image - Get Image from custom field */
  65. /*-----------------------------------------------------------------------------------*/
  66. /*
  67. This function retrieves/resizes the image to be used with the post in this order:
  68. 1. Image passed through parameter 'src'
  69. 2. WP Post Thumbnail (if option activated)
  70. 3. Custom field
  71. 4. First attached image in post (if option activated)
  72. 5. First inline image in post (if option activated)
  73. Resize options (enabled in options panel):
  74. - vt_resize() is used to natively resize #2 and #4
  75. - Thumb.php is used to resize #1, #3, #4 (only if vt_resize is disabled) and #5
  76. Parameters:
  77. $key = Custom field key eg. "image"
  78. $width = Set width manually without using $type
  79. $height = Set height manually without using $type
  80. $class = CSS class to use on the img tag eg. "alignleft". Default is "thumbnail"
  81. $quality = Enter a quality between 80-100. Default is 90
  82. $id = Assign a custom ID, if alternative is required.
  83. $link = Echo with anchor ( 'src'), without anchor ( 'img') or original image URL ( 'url').
  84. $repeat = Auto Img Function. Adjust amount of images to return for the post attachments.
  85. $offset = Auto Img Function. Offset the $repeat with assigned amount of objects.
  86. $before = Auto Img Function. Add Syntax before image output.
  87. $after = Auto Img Function. Add Syntax after image output.
  88. $single = (true/false) Force thumbnail to link to the post instead of the image.
  89. $force = Force smaller images to not be effected with image width and height dimensions (proportions fix)
  90. $return = Return results instead of echoing out.
  91. $src = A parameter that accepts a img url for resizing. (No anchor)
  92. $meta = Add a custom meta text to the image and anchor of the image.
  93. $alignment = Crop alignment for thumb.php (l, r, t, b)
  94. $size = Custom pre-defined size for WP Thumbnail (string)
  95. $noheight = Don't output the height on img tag (for responsive designs)
  96. */
  97. if ( !function_exists('woo_image') ) {
  98. function woo_image($args) {
  99. /* ------------------------------------------------------------------------- */
  100. /* SET VARIABLES */
  101. /* ------------------------------------------------------------------------- */
  102. global $post;
  103. global $woo_options;
  104. //Defaults
  105. $key = 'image';
  106. $width = null;
  107. $height = null;
  108. $class = '';
  109. $quality = 90;
  110. $id = null;
  111. $link = 'src';
  112. $repeat = 1;
  113. $offset = 0;
  114. $before = '';
  115. $after = '';
  116. $single = false;
  117. $force = false;
  118. $return = false;
  119. $is_auto_image = false;
  120. $src = '';
  121. $meta = '';
  122. $alignment = '';
  123. $size = '';
  124. $noheight = '';
  125. $alt = '';
  126. $img_link = '';
  127. $attachment_id = array();
  128. $attachment_src = array();
  129. if ( ! is_array( $args ) )
  130. parse_str( $args, $args );
  131. extract( $args );
  132. // Set post ID
  133. if ( empty( $id ) ) {
  134. $id = $post->ID;
  135. }
  136. $thumb_id = esc_html( get_post_meta( $id, '_thumbnail_id', true ) );
  137. // Set alignment
  138. if ( $alignment == '' )
  139. $alignment = esc_html( get_post_meta( $id, '_image_alignment', true ) );
  140. // Get standard sizes
  141. if ( ! $width && ! $height ) {
  142. $width = '100';
  143. $height = '100';
  144. }
  145. // Cast $width and $height to integer
  146. $width = intval( $width );
  147. $height = intval( $height );
  148. /* ------------------------------------------------------------------------- */
  149. /* FIND IMAGE TO USE */
  150. /* ------------------------------------------------------------------------- */
  151. // When a custom image is sent through
  152. if ( $src != '' ) {
  153. $custom_field = esc_url( $src );
  154. $link = 'img';
  155. // WP 2.9 Post Thumbnail support
  156. } elseif ( get_option( 'woo_post_image_support' ) == 'true' && ! empty( $thumb_id ) ) {
  157. if ( get_option( 'woo_pis_resize' ) == 'true' ) {
  158. if ( 0 == $height ) {
  159. $img_data = wp_get_attachment_image_src( $thumb_id, array( intval( $width ), 9999 ) );
  160. $height = $img_data[2];
  161. }
  162. // Dynamically resize the post thumbnail
  163. $vt_crop = get_option( 'woo_pis_hard_crop' );
  164. if ($vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
  165. $vt_image = vt_resize( $thumb_id, '', $width, $height, $vt_crop );
  166. // Set fields for output
  167. $custom_field = esc_url( $vt_image['url'] );
  168. $width = $vt_image['width'];
  169. $height = $vt_image['height'];
  170. } else {
  171. // Use predefined size string
  172. if ( $size )
  173. $thumb_size = $size;
  174. else
  175. $thumb_size = array( $width, $height );
  176. $img_link = get_the_post_thumbnail( $id, $thumb_size, array( 'class' => 'woo-image ' . esc_attr( $class ) ) );
  177. }
  178. // Grab the image from custom field
  179. } else {
  180. $custom_field = esc_url( get_post_meta( $id, $key, true ) );
  181. }
  182. // Automatic Image Thumbs - get first image from post attachment
  183. if ( empty( $custom_field ) && get_option( 'woo_auto_img' ) == 'true' && empty( $img_link ) && ! ( is_singular() && in_the_loop() && $link == 'src' ) ) {
  184. if( $offset >= 1 )
  185. $repeat = $repeat + $offset;
  186. $attachments = get_children( array( 'post_parent' => $id,
  187. 'numberposts' => $repeat,
  188. 'post_type' => 'attachment',
  189. 'post_mime_type' => 'image',
  190. 'order' => 'DESC',
  191. 'orderby' => 'menu_order date')
  192. );
  193. // Search for and get the post attachment
  194. if ( ! empty( $attachments ) ) {
  195. $counter = -1;
  196. foreach ( $attachments as $att_id => $attachment ) {
  197. $counter++;
  198. if ( $counter < $offset )
  199. continue;
  200. if ( get_option( 'woo_post_image_support' ) == 'true' && get_option( 'woo_pis_resize' ) == 'true' ) {
  201. // Dynamically resize the post thumbnail
  202. $vt_crop = get_option( 'woo_pis_hard_crop' );
  203. if ( $vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
  204. $vt_image = vt_resize( $att_id, '', $width, $height, $vt_crop );
  205. // Set fields for output
  206. $custom_field = esc_url( $vt_image['url'] );
  207. $width = $vt_image['width'];
  208. $height = $vt_image['height'];
  209. } else {
  210. $src = wp_get_attachment_image_src( $att_id, 'large', true );
  211. $custom_field = esc_url( $src[0] );
  212. $attachment_id[] = $att_id;
  213. $src_arr[] = $custom_field;
  214. }
  215. $thumb_id = $att_id;
  216. $is_auto_image = true;
  217. }
  218. // Get the first img tag from content
  219. } else {
  220. $first_img = '';
  221. $post = get_post( $id );
  222. ob_start();
  223. ob_end_clean();
  224. $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
  225. if ( !empty($matches[1][0]) ) {
  226. // Save Image URL
  227. $custom_field = esc_url( $matches[1][0] );
  228. // Search for ALT tag
  229. $output = preg_match_all( '/<img.+alt=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
  230. if ( !empty($matches[1][0]) ) {
  231. $alt = esc_attr( $matches[1][0] );
  232. }
  233. }
  234. }
  235. }
  236. // Check if there is YouTube embed
  237. if ( empty( $custom_field ) && empty( $img_link ) ) {
  238. $embed = esc_html( get_post_meta( $id, 'embed', true ) );
  239. if ( $embed )
  240. $custom_field = esc_url( woo_get_video_image( $embed ) );
  241. }
  242. // Return if there is no attachment or custom field set
  243. if ( empty( $custom_field ) && empty( $img_link ) ) {
  244. // Check if default placeholder image is uploaded
  245. $placeholder = get_option( 'framework_woo_default_image' );
  246. if ( $placeholder && !(is_singular() && in_the_loop()) ) {
  247. $custom_field = esc_url( $placeholder );
  248. // Resize the placeholder if
  249. if ( get_option( 'woo_post_image_support' ) == 'true' && get_option( 'woo_pis_resize' ) == 'true' ) {
  250. // Dynamically resize the post thumbnail
  251. $vt_crop = get_option( 'woo_pis_hard_crop' );
  252. if ($vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
  253. $vt_image = vt_resize( '', $placeholder, $width, $height, $vt_crop );
  254. // Set fields for output
  255. $custom_field = esc_url( $vt_image['url'] );
  256. $width = $vt_image['width'];
  257. $height = $vt_image['height'];
  258. }
  259. } else {
  260. return;
  261. }
  262. }
  263. if(empty( $src_arr ) && empty( $img_link ) ) { $src_arr[] = $custom_field; }
  264. /* ------------------------------------------------------------------------- */
  265. /* BEGIN OUTPUT */
  266. /* ------------------------------------------------------------------------- */
  267. $output = '';
  268. // Set output height and width
  269. $set_width = ' width="' . esc_attr( $width ) . '" ';
  270. $set_height = '';
  271. if ( ! $noheight && 0 < $height )
  272. $set_height = ' height="' . esc_attr( $height ) . '" ';
  273. // Set standard class
  274. if ( $class ) $class = 'woo-image ' . esc_attr( $class ); else $class = 'woo-image';
  275. // Do check to verify if images are smaller then specified.
  276. if($force == true){ $set_width = ''; $set_height = ''; }
  277. // WP Post Thumbnail
  278. if( ! empty( $img_link ) ) {
  279. if( $link == 'img' ) { // Output the image without anchors
  280. $output .= wp_kses_post( $before );
  281. $output .= $img_link;
  282. $output .= wp_kses_post( $after );
  283. } elseif( $link == 'url' ) { // Output the large image
  284. $src = wp_get_attachment_image_src( $thumb_id, 'large', true );
  285. $custom_field = esc_url( $src[0] );
  286. $output .= $custom_field;
  287. } else { // Default - output with link
  288. if ( ( is_single() || is_page() ) && $single == false ) {
  289. $rel = 'rel="lightbox"';
  290. $href = false;
  291. } else {
  292. $href = get_permalink( $id );
  293. $rel = '';
  294. }
  295. $title = 'title="' . esc_attr( get_the_title( $id ) ) .'"';
  296. $output .= wp_kses_post( $before );
  297. if($href == false){
  298. $output .= $img_link;
  299. } else {
  300. $output .= '<a ' . $title . ' href="' . esc_url( $href ) . '" '. $rel .'>' . $img_link . '</a>';
  301. }
  302. $output .= wp_kses_post( $after );
  303. }
  304. }
  305. // Use thumb.php to resize. Skip if image has been natively resized with vt_resize.
  306. elseif ( get_option( 'woo_resize') == 'true' && empty( $vt_image['url'] ) ) {
  307. foreach( $src_arr as $key => $custom_field ) {
  308. // Clean the image URL
  309. $href = esc_url( $custom_field );
  310. $custom_field = cleanSource( $custom_field );
  311. // Check if WPMU and set correct path AND that image isn't external
  312. if ( function_exists( 'get_current_site') ) {
  313. get_current_site();
  314. //global $blog_id; Breaks with WP3 MS
  315. if ( !$blog_id ) {
  316. global $current_blog;
  317. $blog_id = $current_blog->blog_id;
  318. }
  319. if ( isset($blog_id) && $blog_id > 0 ) {
  320. $imageParts = explode( 'files/', $custom_field );
  321. if ( isset( $imageParts[1] ) )
  322. $custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
  323. }
  324. }
  325. //Set the ID to the Attachment's ID if it is an attachment
  326. if($is_auto_image == true){
  327. $quick_id = $attachment_id[$key];
  328. } else {
  329. $quick_id = $id;
  330. }
  331. //Set custom meta
  332. if ($meta) {
  333. $alt = $meta;
  334. $title = 'title="' . esc_attr( $meta ) . '"';
  335. } else {
  336. if ( ( $alt != '' ) || ! ( $alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) ) ) {
  337. $alt = esc_attr( get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) );
  338. } else {
  339. $alt = esc_attr( get_the_title( $quick_id ) );
  340. }
  341. $title = 'title="'. esc_attr( get_the_title( $quick_id ) ) .'"';
  342. }
  343. // Set alignment parameter
  344. if ( $alignment != '' )
  345. $alignment = '&amp;a=' . urlencode( $alignment );
  346. $img_url = esc_url( get_template_directory_uri() . '/functions/thumb.php?src=' . $custom_field . '&amp;w=' . $width . '&amp;h=' . $height . '&amp;zc=1&amp;q=' . $quality . $alignment );
  347. $img_link = '<img src="' . $img_url . '" alt="' . esc_attr( $alt ) . '" class="' . esc_attr( stripslashes( $class ) ) . '" ' . $set_width . $set_height . ' />';
  348. if( $link == 'img' ) { // Just output the image
  349. $output .= wp_kses_post( $before );
  350. $output .= $img_link;
  351. $output .= wp_kses_post( $after );
  352. } elseif( $link == 'url' ) { // Output the image without anchors
  353. if($is_auto_image == true){
  354. $src = wp_get_attachment_image_src($thumb_id, 'large', true);
  355. $custom_field = esc_url( $src[0] );
  356. }
  357. $output .= $href;
  358. } else { // Default - output with link
  359. if ( ( is_single() || is_page() ) && $single == false ) {
  360. $rel = 'rel="lightbox"';
  361. } else {
  362. $href = get_permalink( $id );
  363. $rel = '';
  364. }
  365. $output .= wp_kses_post( $before );
  366. $output .= '<a ' . $title . ' href="' . esc_url( $href ) . '" ' . $rel . '>' . $img_link . '</a>';
  367. $output .= wp_kses_post( $after );
  368. }
  369. }
  370. // No dynamic resizing
  371. } else {
  372. foreach( $src_arr as $key => $custom_field ) {
  373. //Set the ID to the Attachment's ID if it is an attachment
  374. if( $is_auto_image == true && isset( $attachment_id[$key] ) ){
  375. $quick_id = $attachment_id[$key];
  376. } else {
  377. $quick_id = $id;
  378. }
  379. //Set custom meta
  380. if ($meta) {
  381. $alt = esc_attr( $meta );
  382. $title = 'title="'. esc_attr( $meta ) .'"';
  383. } else {
  384. if ($alt == '') $alt = esc_attr( get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) );
  385. $title = 'title="'. esc_attr( get_the_title( $quick_id ) ) .'"';
  386. }
  387. $img_link = '<img src="'. esc_url( $custom_field ) . '" alt="' . esc_attr( $alt ) . '" ' . $set_width . $set_height . ' class="' . esc_attr( stripslashes( $class ) ) . '" />';
  388. if ( $link == 'img' ) { // Just output the image
  389. $output .= wp_kses_post( $before );
  390. $output .= $img_link;
  391. $output .= wp_kses_post( $after );
  392. } elseif( $link == 'url' ) { // Output the URL to original image
  393. if ( $vt_image['url'] || $is_auto_image ) {
  394. $src = wp_get_attachment_image_src( $thumb_id, 'full', true );
  395. $custom_field = esc_url( $src[0] );
  396. }
  397. $output .= $custom_field;
  398. } else { // Default - output with link
  399. if ( ( is_single() || is_page() ) && $single == false ) {
  400. // Link to the large image if single post
  401. if ( $vt_image['url'] || $is_auto_image ) {
  402. $src = wp_get_attachment_image_src( $thumb_id, 'full', true );
  403. $custom_field = esc_url( $src[0] );
  404. }
  405. $href = $custom_field;
  406. $rel = 'rel="lightbox"';
  407. } else {
  408. $href = get_permalink( $id );
  409. $rel = '';
  410. }
  411. $output .= wp_kses_post( $before );
  412. $output .= '<a href="' . esc_url( $href ) . '" ' . $rel . ' ' . $title . '>' . $img_link . '</a>';
  413. $output .= wp_kses_post( $after );
  414. }
  415. }
  416. }
  417. // Remove no height attribute - IE fix when no height is set
  418. $output = str_replace( 'height=""', '', $output );
  419. $output = str_replace( 'height="0"', '', $output );
  420. // Return or echo the output
  421. if ( $return == TRUE )
  422. return $output;
  423. else
  424. echo $output; // Done
  425. }
  426. }
  427. /* Get thumbnail from Video Embed code */
  428. if ( ! function_exists( 'woo_get_video_image' ) ) {
  429. function woo_get_video_image( $embed ) {
  430. $video_thumb = '';
  431. // YouTube - get the video code if this is an embed code (old embed)
  432. preg_match( '/youtube\.com\/v\/([\w\-]+)/', $embed, $match );
  433. // YouTube - if old embed returned an empty ID, try capuring the ID from the new iframe embed
  434. if( ! isset( $match[1] ) )
  435. preg_match( '/youtube\.com\/embed\/([\w\-]+)/', $embed, $match );
  436. // YouTube - if it is not an embed code, get the video code from the youtube URL
  437. if( ! isset( $match[1] ) )
  438. preg_match( '/v\=(.+)&/', $embed, $match );
  439. // YouTube - get the corresponding thumbnail images
  440. if( isset( $match[1] ) )
  441. $video_thumb = "http://img.youtube.com/vi/" . urlencode( $match[1] ) . "/0.jpg";
  442. // return whichever thumbnail image you would like to retrieve
  443. return $video_thumb;
  444. } // End woo_get_video_image()
  445. }
  446. /*-----------------------------------------------------------------------------------*/
  447. /* vt_resize - Resize images dynamically using wp built in functions
  448. /*-----------------------------------------------------------------------------------*/
  449. /*
  450. * Resize images dynamically using wp built in functions
  451. * Victor Teixeira
  452. *
  453. * php 5.2+
  454. *
  455. * Exemplo de uso:
  456. *
  457. * <?php
  458. * $thumb = get_post_thumbnail_id();
  459. * $image = vt_resize( $thumb, '', 140, 110, true );
  460. * ?>
  461. * <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" />
  462. *
  463. * @param int $attach_id
  464. * @param string $img_url
  465. * @param int $width
  466. * @param int $height
  467. * @param bool $crop
  468. * @return array
  469. */
  470. if ( ! function_exists( 'vt_resize' ) ) {
  471. function vt_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
  472. // Cast $width and $height to integer
  473. $width = intval( $width );
  474. $height = intval( $height );
  475. // this is an attachment, so we have the ID
  476. if ( $attach_id ) {
  477. $image_src = wp_get_attachment_image_src( $attach_id, 'full' );
  478. $file_path = get_attached_file( $attach_id );
  479. // this is not an attachment, let's use the image url
  480. } else if ( $img_url ) {
  481. $file_path = parse_url( esc_url( $img_url ) );
  482. $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
  483. //$file_path = ltrim( $file_path['path'], '/' );
  484. //$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
  485. $orig_size = getimagesize( $file_path );
  486. $image_src[0] = $img_url;
  487. $image_src[1] = $orig_size[0];
  488. $image_src[2] = $orig_size[1];
  489. }
  490. $file_info = pathinfo( $file_path );
  491. // check if file exists
  492. if ( !isset( $file_info['dirname'] ) && !isset( $file_info['filename'] ) && !isset( $file_info['extension'] ) )
  493. return;
  494. $base_file = $file_info['dirname'].'/'.$file_info['filename'].'.'.$file_info['extension'];
  495. if ( !file_exists($base_file) )
  496. return;
  497. $extension = '.'. $file_info['extension'];
  498. // the image path without the extension
  499. $no_ext_path = $file_info['dirname'].'/'.$file_info['filename'];
  500. $cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
  501. // checking if the file size is larger than the target size
  502. // if it is smaller or the same size, stop right here and return
  503. if ( $image_src[1] > $width ) {
  504. // the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
  505. if ( file_exists( $cropped_img_path ) ) {
  506. $cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
  507. $vt_image = array (
  508. 'url' => $cropped_img_url,
  509. 'width' => $width,
  510. 'height' => $height
  511. );
  512. return $vt_image;
  513. }
  514. // $crop = false or no height set
  515. if ( $crop == false OR !$height ) {
  516. // calculate the size proportionaly
  517. $proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
  518. $resized_img_path = $no_ext_path.'-'.$proportional_size[0].'x'.$proportional_size[1].$extension;
  519. // checking if the file already exists
  520. if ( file_exists( $resized_img_path ) ) {
  521. $resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
  522. $vt_image = array (
  523. 'url' => $resized_img_url,
  524. 'width' => $proportional_size[0],
  525. 'height' => $proportional_size[1]
  526. );
  527. return $vt_image;
  528. }
  529. }
  530. // check if image width is smaller than set width
  531. $img_size = getimagesize( $file_path );
  532. if ( $img_size[0] <= $width ) $width = $img_size[0];
  533. // Check if GD Library installed
  534. if ( ! function_exists ( 'imagecreatetruecolor' ) ) {
  535. echo 'GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library';
  536. return;
  537. }
  538. // no cache files - let's finally resize it
  539. if ( function_exists( 'wp_get_image_editor' ) ) {
  540. $image = wp_get_image_editor( $file_path );
  541. if ( ! is_wp_error( $image ) ) {
  542. $image->resize( $width, $height, $crop );
  543. $save_data = $image->save();
  544. if ( isset( $save_data['path'] ) ) $new_img_path = $save_data['path'];
  545. }
  546. } else {
  547. $new_img_path = image_resize( $file_path, $width, $height, $crop );
  548. }
  549. $new_img_size = getimagesize( $new_img_path );
  550. $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
  551. // resized output
  552. $vt_image = array (
  553. 'url' => $new_img,
  554. 'width' => $new_img_size[0],
  555. 'height' => $new_img_size[1]
  556. );
  557. return $vt_image;
  558. }
  559. // default output - without resizing
  560. $vt_image = array (
  561. 'url' => $image_src[0],
  562. 'width' => $width,
  563. 'height' => $height
  564. );
  565. return $vt_image;
  566. }
  567. }
  568. /*-----------------------------------------------------------------------------------*/
  569. /* Depreciated - woo_get_image - Get Image from custom field */
  570. /*-----------------------------------------------------------------------------------*/
  571. // Depreciated
  572. function woo_get_image($key = 'image', $width = null, $height = null, $class = "thumbnail", $quality = 90,$id = null,$link = 'src',$repeat = 1,$offset = 0,$before = '', $after = '',$single = false, $force = false, $return = false) {
  573. // Run new function
  574. woo_image( 'key='.$key.'&width='.$width.'&height='.$height.'&class='.$class.'&quality='.$quality.'&id='.$id.'&link='.$link.'&repeat='.$repeat.'&offset='.$offset.'&before='.$before.'&after='.$after.'&single='.$single.'&fore='.$force.'&return='.$return );
  575. return;
  576. } // End woo_get_image()
  577. /*-----------------------------------------------------------------------------------*/
  578. /* woo_embed - Get Video embed code from custom field */
  579. /*-----------------------------------------------------------------------------------*/
  580. /*
  581. Get Video
  582. This function gets the embed code from the custom field
  583. Parameters:
  584. $key = Custom field key eg. "embed"
  585. $width = Set width manually without using $type
  586. $height = Set height manually without using $type
  587. $class = Custom class to apply to wrapping div
  588. $id = ID from post to pull custom field from
  589. */
  590. if ( ! function_exists( 'woo_embed' ) ) {
  591. function woo_embed($args) {
  592. //Defaults
  593. $key = 'embed';
  594. $width = null;
  595. $height = null;
  596. $class = 'video';
  597. $id = null;
  598. if ( ! is_array( $args ) )
  599. parse_str( $args, $args );
  600. extract( $args );
  601. if( empty( $id ) ) {
  602. global $post;
  603. $id = $post->ID;
  604. }
  605. // Cast $width and $height to integer
  606. $width = intval( $width );
  607. $height = intval( $height );
  608. $custom_field = esc_textarea( get_post_meta( $id, $key, true ) );
  609. if ($custom_field) :
  610. $custom_field = html_entity_decode( $custom_field ); // Decode HTML entities.
  611. $org_width = $width;
  612. $org_height = $height;
  613. $calculated_height = '';
  614. $embed_width = '';
  615. $embed_height = '';
  616. // Get custom width and height
  617. $custom_width = esc_html( get_post_meta( $id, 'width', true ) );
  618. $custom_height = esc_html( get_post_meta( $id, 'height', true ) );
  619. //Dynamic Height Calculation
  620. if ($org_height == '' && $org_width != '') {
  621. $raw_values = explode( ' ', $custom_field);
  622. foreach ( $raw_values as $raw ) {
  623. $embed_params = explode( '=', $raw );
  624. if ( $embed_params[0] == 'width' ) {
  625. $embed_width = preg_replace( '/[^0-9]/', '', $embed_params[1]);
  626. }
  627. elseif ( $embed_params[0] == 'height' ) {
  628. $embed_height = preg_replace( '/[^0-9]/', '', $embed_params[1]);
  629. }
  630. }
  631. $float_width = floatval( $embed_width );
  632. $float_height = floatval( $embed_height );
  633. @$float_ratio = $float_height / $float_width;
  634. $calculated_height = intval( $float_ratio * $width );
  635. }
  636. // Set values: width="XXX", height="XXX"
  637. if ( ! $custom_width ) $width = 'width="' . esc_attr( $width ) . '"'; else $width = 'width="' . esc_attr( $custom_width ) . '"';
  638. if ( $height == '' ) { $height = 'height="' . esc_attr( $calculated_height ) . '"'; } else { if ( ! $custom_height ) { $height = 'height="' . esc_attr( $height ) . '"'; } else { $height = 'height="' . esc_attr( $custom_height ) . '"'; } }
  639. $custom_field = stripslashes($custom_field);
  640. $custom_field = preg_replace( '/width="([0-9]*)"/' , $width , $custom_field );
  641. $custom_field = preg_replace( '/height="([0-9]*)"/' , $height, $custom_field );
  642. // Set values: width:XXXpx, height:XXXpx
  643. if ( ! $custom_width ) $width = 'width:' . esc_attr( $org_width ) . 'px'; else $width = 'width:' . esc_attr( $custom_width ) . 'px';
  644. if ( $height == '' ) { $height = 'height:' . esc_attr( $calculated_height ) . 'px'; } else { if ( ! $custom_height ) { $height = 'height:' . esc_attr( $org_height ) . 'px'; } else { $height = 'height:' . esc_attr( $custom_height ) . 'px'; } }
  645. $custom_field = stripslashes($custom_field);
  646. $custom_field = preg_replace( '/width:([0-9]*)px/' , $width , $custom_field );
  647. $custom_field = preg_replace( '/height:([0-9]*)px/' , $height, $custom_field );
  648. // Suckerfish menu hack
  649. $custom_field = str_replace( '<embed ', '<param name="wmode" value="transparent"></param><embed wmode="transparent" ', $custom_field );
  650. $custom_field = str_replace( '<iframe ', '<iframe wmode="transparent" ', $custom_field );
  651. $custom_field = str_replace( '" frameborder="', '?wmode=transparent" frameborder="', $custom_field );
  652. // Find and sanitize video URL. Add "wmode=transparent" to URL.
  653. $video_url = preg_match( '/src=["\']?([^"\' ]*)["\' ]/is', $custom_field, $matches );
  654. if ( isset( $matches[1] ) ) {
  655. $custom_field = str_replace( $matches[0], 'src="' . esc_url( add_query_arg( 'wmode', 'transparent', $matches[1] ) ) . '"', $custom_field );
  656. }
  657. $output = '';
  658. $output .= '<div class="'. esc_attr( $class ) .'">' . $custom_field . '</div>';
  659. return apply_filters( 'woo_embed', $output );
  660. else :
  661. return false;
  662. endif;
  663. }
  664. }
  665. /*-----------------------------------------------------------------------------------*/
  666. /* Add default filters to woo_embed() */
  667. /*-----------------------------------------------------------------------------------*/
  668. add_filter( 'woo_embed', 'do_shortcode' );
  669. /*-----------------------------------------------------------------------------------*/
  670. /* Depreciated - woo_get_embed - Get Video embed code from custom field */
  671. /*-----------------------------------------------------------------------------------*/
  672. // Depreciated
  673. function woo_get_embed($key = 'embed', $width, $height, $class = 'video', $id = null) {
  674. // Run new function
  675. return woo_embed( 'key='.$key.'&width='.$width.'&height='.$height.'&class='.$class.'&id='.$id );
  676. }
  677. /*-----------------------------------------------------------------------------------*/
  678. /* Woo Show Page Menu */
  679. /*-----------------------------------------------------------------------------------*/
  680. // Show menu in header.php
  681. // Exlude the pages from the slider
  682. function woo_show_pagemenu( $exclude = '' ) {
  683. // Split the featured pages from the options, and put in an array
  684. if ( get_option( 'woo_ex_featpages') ) {
  685. $menupages = get_option( 'woo_featpages' );
  686. $exclude = $menupages . ',' . $exclude;
  687. }
  688. $pages = wp_list_pages( 'sort_column=menu_order&title_li=&echo=0&depth=1&exclude=' . $exclude );
  689. $pages = preg_replace( '%<a ([^>]+)>%U','<a $1><span>', $pages );
  690. $pages = str_replace( '</a>','</span></a>', $pages );
  691. echo $pages;
  692. } // End woo_show_pagemenu()
  693. /*-----------------------------------------------------------------------------------*/
  694. /* Get the style path currently selected */
  695. /*-----------------------------------------------------------------------------------*/
  696. function woo_style_path() {
  697. $return = '';
  698. $style = $_REQUEST['style'];
  699. // Sanitize request input.
  700. $style = esc_attr( strtolower( trim( strip_tags( $style ) ) ) );
  701. if ( $style != '' ) {
  702. $style_path = $style;
  703. } else {
  704. $stylesheet = esc_attr( get_option( 'woo_alt_stylesheet' ) );
  705. // Prevent against an empty return to $stylesheet.
  706. if ( $stylesheet == '' ) {
  707. $stylesheet = 'default.css';
  708. }
  709. $style_path = str_replace( '.css', '', $stylesheet );
  710. }
  711. if ( $style_path == 'default' ) {
  712. $return = 'images';
  713. } else {
  714. $return = 'styles/' . $style_path;
  715. }
  716. echo esc_html( $return );
  717. } // End woo_style_path()
  718. /*-----------------------------------------------------------------------------------*/
  719. /* Get page ID */
  720. /*-----------------------------------------------------------------------------------*/
  721. function get_page_id( $page_slug ) {
  722. $page_id = get_page_by_path( $page_slug );
  723. if ($page_id) {
  724. return $page_id->ID;
  725. } else {
  726. return null;
  727. }
  728. } // End get_page_id()
  729. /*-----------------------------------------------------------------------------------*/
  730. /* Tidy up the image source url */
  731. /*-----------------------------------------------------------------------------------*/
  732. function cleanSource( $src ) {
  733. // remove slash from start of string
  734. if(strpos($src, "/") == 0) {
  735. $src = substr($src, -(strlen($src) - 1));
  736. }
  737. // Check if same domain so it doesn't strip external sites
  738. $host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
  739. if ( ! strpos( $src, $host ) )
  740. return $src;
  741. $regex = "/^((ht|f)tp(s|):\/\/)(www\.|)" . $host . "/i";
  742. $src = preg_replace ( $regex, '', $src );
  743. $src = htmlentities ( $src );
  744. // remove slash from start of string
  745. if ( strpos( $src, '/' ) === 0 ) {
  746. $src = substr ( $src, -( strlen( $src ) - 1 ) );
  747. }
  748. return $src;
  749. } // End cleanSource()
  750. /*-----------------------------------------------------------------------------------*/
  751. /* Show image in RSS feed */
  752. /* Original code by Justin Tadlock http://justintadlock.com */
  753. /*-----------------------------------------------------------------------------------*/
  754. if ( get_option( 'woo_rss_thumb' ) == 'true' ) {
  755. if ( get_option( 'rss_use_excerpt' ) )
  756. add_filter( 'the_excerpt_rss', 'add_image_RSS' );
  757. else
  758. add_filter( 'the_content', 'add_image_RSS' );
  759. }
  760. function add_image_RSS( $content ) {
  761. global $post, $id;
  762. $blog_key = substr( md5( home_url( '/' ) ), 0, 16 );
  763. if ( ! is_feed() ) return $content;
  764. // Get the "image" from custom field
  765. //$image = get_post_meta($post->ID, 'image', $single = true);
  766. $image = woo_image( 'return=true&link=url' );
  767. $image_width = '240';
  768. // If there's an image, display the image with the content
  769. if( $image != '' ) {
  770. $content = '<p style="float:right; margin:0 0 10px 15px; width:' . esc_attr( $image_width ) . 'px;">
  771. <img src="' . esc_url( $image ) . '" width="' . esc_attr( $image_width ) . '" />
  772. </p>' . $content;
  773. return $content;
  774. } else {
  775. // If there's not an image, just display the content
  776. $content = $content;
  777. return $content;
  778. }
  779. } // End add_image_RSS()
  780. /*-----------------------------------------------------------------------------------*/
  781. /* Show analytics code in footer */
  782. /*-----------------------------------------------------------------------------------*/
  783. function woo_analytics(){
  784. $output = get_option( 'woo_google_analytics' );
  785. if ( $output != '' )
  786. echo stripslashes( $output ) . "\n";
  787. } // End woo_analytics()
  788. add_action( 'wp_footer','woo_analytics' );
  789. /*-----------------------------------------------------------------------------------*/
  790. /* Browser detection body_class() output */
  791. /*-----------------------------------------------------------------------------------*/
  792. add_filter( 'body_class','browser_body_class' );
  793. function browser_body_class( $classes ) {
  794. global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
  795. if($is_lynx) $classes[] = 'lynx';
  796. elseif($is_gecko) $classes[] = 'gecko';
  797. elseif($is_opera) $classes[] = 'opera';
  798. elseif($is_NS4) $classes[] = 'ns4';
  799. elseif($is_safari) $classes[] = 'safari';
  800. elseif($is_chrome) $classes[] = 'chrome';
  801. elseif($is_IE) {
  802. $browser = $_SERVER['HTTP_USER_AGENT'];
  803. $browser = substr( "$browser", 25, 8);
  804. if ($browser == "MSIE 7.0" ) {
  805. $classes[] = 'ie7';
  806. $classes[] = 'ie';
  807. } elseif ($browser == "MSIE 6.0" ) {
  808. $classes[] = 'ie6';
  809. $classes[] = 'ie';
  810. } elseif ($browser == "MSIE 8.0" ) {
  811. $classes[] = 'ie8';
  812. $classes[] = 'ie';
  813. } elseif ($browser == "MSIE 9.0" ) {
  814. $classes[] = 'ie9';
  815. $classes[] = 'ie';
  816. } else {
  817. $classes[] = 'ie';
  818. }
  819. }
  820. else $classes[] = 'unknown';
  821. if( $is_iphone ) $classes[] = 'iphone';
  822. // Alternative style body class.
  823. $style = get_option( 'woo_alt_stylesheet', 'default' );
  824. $style = str_replace( '.css', '', $style );
  825. if ( '' != $style ) {
  826. $classes[] = 'alt-style-' . esc_attr( $style );
  827. }
  828. return $classes;
  829. } // End browser_body_class()
  830. /*-----------------------------------------------------------------------------------*/
  831. /* Twitter's Blogger.js output for Twitter widgets */
  832. /*-----------------------------------------------------------------------------------*/
  833. if ( ! function_exists( 'woo_twitter_script' ) ) {
  834. function woo_twitter_script($unique_id,$username,$limit) {
  835. ?>
  836. <script type="text/javascript">
  837. <!--//--><![CDATA[//><!--
  838. function twitterCallback2(twitters) {
  839. var statusHTML = [];
  840. for (var i=0; i<twitters.length; i++){
  841. var username = twitters[i].user.screen_name;
  842. var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
  843. return '<a href="'+url+'">'+url+'</a>';
  844. }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
  845. return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
  846. });
  847. statusHTML.push( '<li><span class="content">'+status+'</span> <a style="font-size:85%" class="time" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+relative_time(twitters[i].created_at)+'</a></li>' );
  848. }
  849. document.getElementById( 'twitter_update_list_<?php echo esc_attr( $unique_id ); ?>').innerHTML = statusHTML.join( '' );
  850. }
  851. function relative_time(time_value) {
  852. var values = time_value.split( " " );
  853. time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  854. var parsed_date = Date.parse(time_value);
  855. var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  856. var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  857. delta = delta + (relative_to.getTimezoneOffset() * 60);
  858. if (delta < 60) {
  859. return '<?php esc_attr_e( 'less than a minute ago', 'woothemes' ); ?>';
  860. } else if(delta < 120) {
  861. return '<?php esc_attr_e( 'about a minute ago', 'woothemes' ); ?>';
  862. } else if(delta < (60*60)) {
  863. return (parseInt(delta / 60)).toString() + ' <?php esc_attr_e( 'minutes ago', 'woothemes' ); ?>';
  864. } else if(delta < (120*60)) {
  865. return 'about an hour ago';
  866. } else if(delta < (24*60*60)) {
  867. return 'about ' + (parseInt(delta / 3600)).toString() + ' <?php esc_attr_e( 'hours ago', 'woothemes' ); ?>';
  868. } else if(delta < (48*60*60)) {
  869. return '1 day ago';
  870. } else {
  871. return (parseInt(delta / 86400)).toString() + ' <?php esc_attr_e( 'days ago', 'woothemes' ); ?>';
  872. }
  873. }
  874. //-->!]]>
  875. </script>
  876. <script type="text/javascript" src="http<?php if (is_ssl()) { echo 's'; } ?>://api.twitter.com/1/statuses/user_timeline/<?php echo esc_attr( $username ); ?>.json?callback=twitterCallback2&amp;count=<?php echo esc_attr( $limit ); ?>&amp;include_rts=t"></script>
  877. <?php
  878. } // End woo_twitter_script()
  879. }
  880. /*-----------------------------------------------------------------------------------*/
  881. /* Deprecated: Template Detector */
  882. /*-----------------------------------------------------------------------------------*/
  883. function woo_active_template( $filename = null ) {
  884. trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s of the WooFramework! Please upgrade your Theme to the latest version.', 'woothemes' ), 'woo_active_template', '5.4' ) );
  885. return false; // No $filename argument was set
  886. } // End woo_active_template()
  887. /*-----------------------------------------------------------------------------------*/
  888. /* WooFramework Update Page */
  889. /*-----------------------------------------------------------------------------------*/
  890. function woothemes_framework_update_page() {
  891. // Clear transients.
  892. delete_transient( 'woo_framework_critical_update' );
  893. delete_transient( 'woo_framework_critical_update_data' );
  894. delete_transient( 'wooframework_version_data' );
  895. $method = get_filesystem_method();
  896. $to = ABSPATH . 'wp-content/themes/' . get_option( 'template' ) . '/functions/';
  897. if(isset($_POST['password'])){
  898. $cred = $_POST;
  899. $filesystem = WP_Filesystem($cred);
  900. }
  901. elseif(isset($_POST['woo_ftp_cred'])){
  902. $cred = unserialize(base64_decode($_POST['woo_ftp_cred']));
  903. $filesystem = WP_Filesystem($cred);
  904. } else {
  905. $filesystem = WP_Filesystem();
  906. };
  907. $url = admin_url( 'admin.php?page=woothemes_framework_update' );
  908. ?>
  909. <div class="wrap themes-page">
  910. <?php
  911. if($filesystem == false){
  912. request_filesystem_credentials ( $url );
  913. } else {
  914. // Clear the transient to force a fresh update.
  915. delete_transient( 'wooframework_version_data' );
  916. $localversion = esc_html( get_option( 'woo_framework_version' ) );
  917. $remoteversion = woo_get_fw_version();
  918. // Test if new version
  919. $upd = false;
  920. $loc = explode( '.',$localversion);
  921. $rem = explode( '.',$remoteversion['version']);
  922. if( $loc[0] < $rem[0] )
  923. $upd = true;
  924. elseif ( $loc[1] < $rem[1] )
  925. $upd = true;
  926. elseif( $loc[2] < $rem[2] )
  927. $upd = true;
  928. ?>
  929. <?php screen_icon( 'tools' ); ?>
  930. <h2>Framework Update</h2>
  931. <span style="display:none"><?php echo $method; ?></span>
  932. <form method="post" enctype="multipart/form-data" id="wooform" action="<?php /* echo $url; */ ?>">
  933. <?php if( $upd ) { ?>
  934. <?php wp_nonce_field( 'update-options' ); ?>
  935. <h3>A new version of WooFramework is available.</h3>
  936. <p>This updater will download and extract the latest WooFramework files to your current theme's functions folder. </p>
  937. <p>We recommend backing up your theme files and updating WordPress to latest version before proceeding.</p>
  938. <p>&rarr; <strong>Your version:</strong> <?php echo $localversion; ?></p>
  939. <p>&rarr; <strong>Current Version:</strong> <?php echo $remoteversion['version']; ?></p>
  940. <input type="submit" class="button" value="Update Framework" />
  941. <?php } else { ?>
  942. <h3>You have the latest version of WooFramework</h3>
  943. <p>&rarr; <strong>Your version:</strong> <?php echo $localversion; ?></p>
  944. <?php } ?>
  945. <input type="hidden" name="woo_update_save" value="save" />
  946. <input type="hidden" name="woo_ftp_cred" value="<?php echo esc_attr( base64_encode(serialize($_POST))); ?>" />
  947. </form>
  948. <?php } ?>
  949. </div>
  950. <?php
  951. };
  952. /*-----------------------------------------------------------------------------------*/
  953. /* WooFramework Update Head */
  954. /*-----------------------------------------------------------------------------------*/
  955. function woothemes_framework_update_head() {
  956. if( isset( $_REQUEST['page'] ) ) {
  957. // Sanitize page being requested.
  958. $_page = esc_attr( $_REQUEST['page'] );
  959. if( $_page == 'woothemes_framework_update' ) {
  960. //Setup Filesystem
  961. $method = get_filesystem_method();
  962. if( isset( $_POST['woo_ftp_cred'] ) ) {
  963. $cred = unserialize( base64_decode( $_POST['woo_ftp_cred'] ) );
  964. $filesystem = WP_Filesystem($cred);
  965. } else {
  966. $filesystem = WP_Filesystem();
  967. }
  968. if( $filesystem == false && $_POST['upgrade'] != 'Proceed' ) {
  969. function woothemes_framework_update_filesystem_warning() {
  970. $method = get_filesystem_method();
  971. echo "<div id='filesystem-warning' class='updated fade'><p>Failed: Filesystem preventing downloads. ( ". $method .")</p></div>";
  972. }
  973. add_action( 'admin_notices', 'woothemes_framework_update_filesystem_warning' );
  974. return;
  975. }
  976. if(isset($_REQUEST['woo_update_save'])){
  977. // Sanitize action being requested.
  978. $_action = esc_attr( $_REQUEST['woo_update_save'] );
  979. if( $_action == 'save' ) {
  980. $temp_file_addr = download_url( esc_url( 'http://www.woothemes.com/updates/framework.zip' ) );
  981. if ( is_wp_error($temp_file_addr) ) {
  982. $error = esc_html( $temp_file_addr->get_error_code() );
  983. if( $error == 'http_no_url' ) {
  984. //The source file was not found or is invalid
  985. function woothemes_framework_update_missing_source_warning() {
  986. echo "<div id='source-warning' class='updated fade'><p>Failed: Invalid URL Provided</p></div>";
  987. }
  988. add_action( 'admin_notices', 'woothemes_framework_update_missing_source_warning' );
  989. } else {
  990. function woothemes_framework_update_other_upload_warning() {
  991. echo "<div id='source-warning' class='updated fade'><p>Failed: Upload - $error</p></div>";
  992. }
  993. add_action( 'admin_notices', 'woothemes_framework_update_other_upload_warning' );
  994. }
  995. return;
  996. }
  997. //Unzip it
  998. global $wp_filesystem;
  999. $to = $wp_filesystem->wp_content_dir() . "/themes/" . get_option( 'template' ) . "/functions/";
  1000. $dounzip = unzip_file($temp_file_addr, $to);
  1001. unlink($temp_file_addr); // Delete Temp File
  1002. if ( is_wp_error($dounzip) ) {
  1003. //DEBUG
  1004. $error = esc_html( $dounzip->get_error_code() );
  1005. $data = $dounzip->get_error_data($error);
  1006. //echo $error. ' - ';
  1007. //print_r($data);
  1008. if($error == 'incompatible_archive') {
  1009. //The source file was not found or is invalid
  1010. function woothemes_framework_update_no_archive_warning() {
  1011. echo "<div id='woo-no-archive-warning' class='updated fade'><p>Failed: Incompatible archive</p></div>";
  1012. }
  1013. add_action( 'admin_notices', 'woothemes_framework_update_no_archive_warning' );
  1014. }
  1015. if($error == 'empty_archive') {
  1016. function woothemes_framework_update_empty_archive_warning() {
  1017. echo "<div id='woo-empty-archive-warning' class='updated fade'><p>Failed: Empty Archive</p></div>";
  1018. }
  1019. add_action( 'admin_notices', 'woothemes_framework_update_empty_archive_warning' );
  1020. }
  1021. if($error == 'mkdir_failed') {
  1022. function woothemes_framework_update_mkdir_warning() {
  1023. echo "<div id='woo-mkdir-warning' class='updated fade'><p>Failed: mkdir Failure</p></div>";
  1024. }
  1025. add_action( 'admin_notices', 'woothemes_framework_update_mkdir_warning' );
  1026. }
  1027. if($error == 'copy_failed') {
  1028. function woothemes_framework_update_copy_fail_warning() {
  1029. echo "<div id='woo-copy-fail-warning' class='updated fade'><p>Failed: Copy Failed</p></div>";
  1030. }
  1031. add_action( 'admin_notices', 'woothemes_framework_update_copy_fail_warning' );
  1032. }
  1033. return;
  1034. }
  1035. function woothemes_framework_updated_success() {
  1036. echo "<div id='framework-upgraded' class='updated fade'><p>New framework successfully downloaded, extracted and updated.</p></div>";
  1037. }
  1038. add_action( 'admin_notices', 'woothemes_framework_updated_success' );
  1039. }
  1040. }
  1041. } //End user input save part of the update
  1042. }
  1043. }
  1044. add_action( 'admin_head', 'woothemes_framework_update_head' );
  1045. /*-----------------------------------------------------------------------------------*/
  1046. /* WooFramework Version Getter */
  1047. /*-----------------------------------------------------------------------------------*/
  1048. function woo_get_fw_version( $url = '', $check_if_critical = false ) {
  1049. if( ! empty( $url ) ) {
  1050. $fw_url = $url;
  1051. } else {
  1052. $fw_url = 'http://www.woothemes.com/updates/functions-changelog.txt';
  1053. }
  1054. $output = array( 'version' => '', 'is_critical' => false );
  1055. $version_data = get_transient( 'wooframework_version_data' );
  1056. if ( $version_data != '' && $check_if_critical == false ) { return $version_data; }
  1057. $temp_file_addr = download_url( $fw_url );
  1058. if( ! is_wp_error( $temp_file_addr ) && $file_contents = file( $temp_file_addr ) ) {
  1059. foreach ( $file_contents as $line_num => $line ) {
  1060. $current_line = $line;
  1061. if( $line_num > 1 ) { // Not the first or second... dodgy :P
  1062. if ( preg_match( '/^[0-9]/', $line ) ) {
  1063. // Do critical update check.
  1064. if ( $check_if_critical && ( strtolower( trim( substr( $line, -10 ) ) ) == 'critical' ) ) {
  1065. $output['is_critical'] = true;
  1066. }
  1067. $current_line = stristr( $current_line, 'version' );
  1068. $current_line = preg_replace( '~[^0-9,.]~','',$current_line );
  1069. $output['version'] = $current_line;
  1070. break;
  1071. }
  1072. }
  1073. }
  1074. unlink( $temp_file_addr );
  1075. } else {
  1076. $output['version'] = get_option( 'woo_framework_version' );
  1077. }
  1078. // Set the transient containing the latest version number.
  1079. set_transient( 'wooframework_version_data', $output , 60*60*24 );
  1080. return $output;
  1081. } // End woo_get_fw_version()
  1082. /*-----------------------------------------------------------------------------------*/
  1083. /* WooFramework Version Checker */
  1084. /*-----------------------------------------------------------------------------------*/
  1085. function woo_framework_version_checker( $local_version, $check_if_critical = false ) {
  1086. $data = array( 'is_update' => false, 'version' => '1.0.0', 'status' => 'none' );
  1087. if ( ! $local_version ) { return $data; }
  1088. $version_data = woo_get_fw_version( '', $check_if_critical );
  1089. $check = version_compare( $version_data['version'], $local_version ); // Returns 1 if there is an update available.
  1090. if ( $check == 1 ) {
  1091. $data['is_update'] = true;
  1092. $data['version'] = $version_data['version'];
  1093. $data['is_critical'] = $version_data['is_critical'];
  1094. }
  1095. return $data;
  1096. } // End woo_framework_version_checker()
  1097. /*-----------------------------------------------------------------------------------*/
  1098. /* Woo URL shortener */
  1099. /*-----------------------------------------------------------------------------------*/
  1100. function woo_short_url($url) {
  1101. $service = get_option( 'woo_url_shorten' );
  1102. $bitlyapilogin = get_option( 'woo_bitly_api_login' );;
  1103. $bitlyapikey = get_option( 'woo_bitly_api_key' );;
  1104. if (isset($service)) {
  1105. switch ($service)
  1106. {
  1107. case 'TinyURL':
  1108. $shorturl = getTinyUrl($url);
  1109. break;
  1110. case 'Bit.ly':
  1111. if (isset($bitlyapilogin) && isset($bitlyapikey) && ($bitlyapilogin != '') && ($bitlyapikey != '')) {
  1112. $shorturl = make_bitly_url($url,$bitlyapilogin,$bitlyapikey,'json' );
  1113. }
  1114. else {
  1115. $shorturl = getTinyUrl($url);
  1116. }
  1117. break;
  1118. case 'Off':
  1119. $shorturl = $url;
  1120. break;
  1121. default:
  1122. $shorturl = $url;
  1123. break;
  1124. }
  1125. }
  1126. else {
  1127. $shorturl = $url;
  1128. }
  1129. return $shorturl;
  1130. }
  1131. //TinyURL
  1132. function getTinyUrl($url) {
  1133. $tinyurl = file_get_contents_curl( "http://tinyurl.com/api-create.php?url=".$url);
  1134. return $tinyurl;
  1135. }
  1136. //Bit.ly
  1137. function make_bitly_url($url,$login,$appkey,$format = 'xml',$version = '2.0.1')
  1138. {
  1139. //create the URL
  1140. $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
  1141. //get the url
  1142. //could also use cURL here
  1143. $response = file_get_contents_curl($bitly);
  1144. //parse depending on desired format
  1145. if(strtolower($format) == 'json')
  1146. {
  1147. $json = @json_decode($response,true);
  1148. return $json['results'][$url]['shortUrl'];
  1149. }
  1150. else //xml
  1151. {
  1152. $xml = simplexml_load_string($response);
  1153. return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
  1154. }
  1155. }
  1156. //Alternative CURL function
  1157. function file_get_contents_curl($url) {
  1158. if ( $url == '' || $url == null ) { return ''; }
  1159. $data = '';
  1160. $response = wp_remote_get( $url );
  1161. if ( is_wp_error( $response ) ) {
  1162. $data = $url;
  1163. } else {
  1164. $data = $response['body'];
  1165. }
  1166. return $data;
  1167. } // End file_get_contents_curl()
  1168. // Checks for presence of the cURL extension.
  1169. function _iscurlinstalled() {
  1170. if (in_array ( 'curl', get_loaded_extensions())) {
  1171. if (function_exists( 'curl_init')) {
  1172. return true;
  1173. } else {
  1174. return false;
  1175. }
  1176. }
  1177. else{
  1178. if (function_exists( 'curl_init')) {
  1179. return true;
  1180. } else {
  1181. return false;
  1182. }
  1183. }
  1184. }
  1185. /*-----------------------------------------------------------------------------------*/
  1186. /* woo_title() */
  1187. /*-----------------------------------------------------------------------------------*/
  1188. function woo_title () {
  1189. $sep = '|';
  1190. $raw_title = wp_title( $sep, false, 'right' );
  1191. $title = $raw_title . get_bloginfo( 'name' );
  1192. // Allow child themes/plugins to filter the title value.
  1193. $title = apply_filters( 'woo_title', $title, $sep, $raw_title );
  1194. // Display the formatted title.
  1195. echo $title;
  1196. } // End woo_title()
  1197. /*-----------------------------------------------------------------------------------*/
  1198. /* woo_meta() */
  1199. /*-----------------------------------------------------------------------------------*/
  1200. function woo_meta () {
  1201. echo '<meta http-equiv="Content-Type" content="'. esc_attr( get_bloginfo( 'html_type' ) ) . '; charset=' . esc_attr( get_bloginfo( 'charset' ) ) . '" />' . "\n";
  1202. do_action( 'woo_meta' );
  1203. } // End woo_meta()
  1204. /*-----------------------------------------------------------------------------------*/
  1205. /* Woo Text Trimmer */
  1206. /*-----------------------------------------------------------------------------------*/
  1207. if ( ! function_exists( 'woo_text_trim' ) ) {
  1208. function woo_text_trim( $text, $words = 50 ) {
  1209. $matches = preg_split( "/\s+/", $text, $words + 1);
  1210. $sz = count($matches);
  1211. if ($sz > $words)
  1212. {
  1213. unset($matches[$sz-1]);
  1214. return implode( ' ',$matches)." ...";
  1215. }
  1216. return $text;
  1217. } // End woo_text_trim()
  1218. }
  1219. /*-----------------------------------------------------------------------------------*/
  1220. /* Google Webfonts Array */
  1221. /* Documentation:
  1222. /*
  1223. /* name: The name of the Google Font.
  1224. /* variant: The Google Font API variants available for the font.
  1225. /*-----------------------------------------------------------------------------------*/
  1226. // Available Google webfont names
  1227. $google_fonts = array( array( 'name' => "Cantarell", 'variant' => ':r,b,i,bi'),
  1228. array( 'name' => "Cardo", 'variant' => ''),
  1229. array( 'name' => "Crimson Text", 'variant' => ''),
  1230. array( 'name' => "Droid Sans", 'variant' => ':r,b'),
  1231. array( 'name' => "Droid Sans Mono", 'variant' => ''),
  1232. array( 'name' => "Droid Serif", 'variant' => ':r,b,i,bi'),
  1233. array( 'name' => "IM Fell DW Pica", 'variant' => ':r,i'),
  1234. array( 'name' => "Inconsolata", 'variant' => ''),
  1235. array( 'name' => "Josefin Sans", 'variant' => ':400,400italic,700,700italic'),
  1236. array( 'name' => "Josefin Slab", 'variant' => ':r,b,i,bi'),
  1237. array( 'name' => "Lobster", 'variant' => ''),
  1238. array( 'name' => "Molengo", 'variant' => ''),
  1239. array( 'name' => "Nobile", 'variant' => ':r,b,i,bi'),
  1240. array( 'name' => "OFL Sorts Mill Goudy TT", 'variant' => ':r,i'),
  1241. array( 'name' => "Old Standard TT", 'variant' => ':r,b,i'),
  1242. array( 'name' => "Reenie Beanie", 'variant' => ''),
  1243. array( 'name' => "Tangerine", 'variant' => ':r,b'),
  1244. array( 'name' => "Vollkorn", 'variant' => ':r,b'),
  1245. array( 'name' => "Yanone Kaffeesatz", 'variant' => ':r,b'),
  1246. array( 'name' => "Cuprum", 'variant' => ''),
  1247. array( 'name' => "Neucha", 'variant' => ''),
  1248. array( 'name' => "Neuton", 'variant' => ''),
  1249. array( 'name' => "PT Sans", 'variant' => ':r,b,i,bi'),
  1250. array( 'name' => "PT Sans Caption", 'variant' => ':r,b'),
  1251. array( 'name' => "PT Sans Narrow", 'variant' => ':r,b'),
  1252. array( 'name' => "Philosopher", 'variant' => ''),
  1253. array( 'name' => "Allerta", 'variant' => ''),
  1254. array( 'name' => "Allerta Stencil", 'variant' => ''),
  1255. array( 'name' => "Arimo", 'variant' => ':r,b,i,bi'),
  1256. array( 'name' => "Arvo", 'variant' => ':r,b,i,bi'),
  1257. array( 'name' => "Bentham", 'variant' => ''),
  1258. array( 'name' => "Coda", 'variant' => ':800'),
  1259. array( 'name' => "Cousine", 'variant' => ''),
  1260. array( 'name' => "Covered By Your Grace", 'variant' => ''),
  1261. array( 'name' => "Geo", 'variant' => ''),
  1262. array( 'name' => "Just Me Again Down Here", 'variant' => ''),
  1263. array( 'name' => "Puritan", 'variant' => ':r,b,i,bi'),
  1264. array( 'name' => "Raleway", 'variant' => ':100'),
  1265. array( 'name' => "Tinos", 'variant' => ':r,b,i,bi'),
  1266. array( 'name' => "UnifrakturCook", 'variant' => ':bold'),
  1267. array( 'name' => "UnifrakturMaguntia", 'variant' => ''),
  1268. array( 'name' => "Mountains of Christmas", 'variant' => ''),
  1269. array( 'name' => "Lato", 'variant' => ':400,700,400italic'),
  1270. array( 'name' => "Orbitron", 'variant' => ':r,b,i,bi'),
  1271. array( 'name' => "Allan", 'variant' => ':bold'),
  1272. array( 'name' => "Anonymous Pro", 'variant' => ':r,b,i,bi'),
  1273. array( 'name' => "Copse", 'variant' => ''),
  1274. array( 'name' => "Kenia", 'variant' => ''),
  1275. array( 'name' => "Ubuntu", 'variant' => ':r,b,i,bi'),
  1276. array( 'name' => "Vibur", 'variant' => ''),
  1277. array( 'name' => "Sniglet", 'variant' => ':800'),
  1278. array( 'name' => "Syncopate", 'variant' => ''),
  1279. array( 'name' => "Cabin", 'variant' => ':400,400italic,700,700italic,'),
  1280. array( 'name' => "Merriweather", 'variant' => ''),
  1281. array( 'name' => "Maiden Orange", 'variant' => ''),
  1282. array( 'name' => "Just Another Hand", 'variant' => ''),
  1283. array( 'name' => "Kristi", 'variant' => ''),
  1284. array( 'name' => "Corben", 'variant' => ':b'),
  1285. array( 'name' => "Gruppo", 'variant' => ''),
  1286. array( 'name' => "Buda", 'variant' => ':light'),
  1287. array( 'name' => "Lekton", 'variant' => ''),
  1288. array( 'name' => "Luckiest Guy", 'variant' => ''),
  1289. array( 'name' => "Crushed", 'variant' => ''),
  1290. array( 'name' => "Chewy", 'variant' => ''),
  1291. array( 'name' => "Coming Soon", 'variant' => ''),
  1292. array( 'name' => "Crafty Girls", 'variant' => ''),
  1293. array( 'name' => "Fontdiner Swanky", 'variant' => ''),
  1294. array( 'name' => "Permanent Marker", 'variant' => ''),
  1295. array( 'name' => "Rock Salt", 'variant' => ''),
  1296. array( 'name' => "Sunshiney", 'variant' => ''),
  1297. array( 'name' => "Unkempt", 'variant' => ''),
  1298. array( 'name' => "Calligraffitti", 'variant' => ''),
  1299. array( 'name' => "Cherry Cream Soda", 'variant' => ''),
  1300. array( 'name' => "Homemade Apple", 'variant' => ''),
  1301. array( 'name' => "Irish Growler", 'variant' => ''),
  1302. array( 'name' => "Kranky", 'variant' => ''),
  1303. array( 'name' => "Schoolbell", 'variant' => ''),
  1304. array( 'name' => "Slackey", 'variant' => ''),
  1305. array( 'name' => "Walter Turncoat", 'variant' => ''),
  1306. array( 'name' => "Radley", 'variant' => ''),
  1307. array( 'name' => "Meddon", 'variant' => ''),
  1308. array( 'name' => "Kreon", 'variant' => ':r,b'),
  1309. array( 'name' => "Dancing Script", 'variant' => ''),
  1310. array( 'name' => "Goudy Bookletter 1911", 'variant' => ''),
  1311. array( 'name' => "PT Serif Caption", 'variant' => ':r,i'),
  1312. array( 'name' => "PT Serif", 'variant' => ':r,b,i,bi'),
  1313. array( 'name' => "Astloch", 'variant' => ':b'),
  1314. array( 'name' => "Bevan", 'variant' => ''),
  1315. array( 'name' => "Anton", 'variant' => ''),
  1316. array( 'name' => "Expletus Sans", 'variant' => ':b'),
  1317. array( 'name' => "VT323", 'variant' => ''),
  1318. array( 'name' => "Pacifico", 'variant' => ''),
  1319. array( 'name' => "Candal", 'variant' => ''),
  1320. array( 'name' => "Architects Daughter", 'variant' => ''),
  1321. array( 'name' => "Indie Flower", 'variant' => ''),
  1322. array( 'name' => "League Script", 'variant' => ''),
  1323. array( 'name' => "Quattrocento", 'variant' => ''),
  1324. array( 'name' => "Amaranth", 'variant' => ''),
  1325. array( 'name' => "Irish Grover", 'variant' => ''),
  1326. array( 'name' => "Oswald", 'variant' => ':400,300,700'),
  1327. array( 'name' => "EB Garamond", 'variant' => ''),
  1328. array( 'name' => "Nova Round", 'variant' => ''),
  1329. array( 'name' => "Nova Slim", 'variant' => ''),
  1330. array( 'name' => "Nova Script", 'variant' => ''),
  1331. array( 'name' => "Nova Cut", 'variant' => ''),
  1332. array( 'name' => "Nova Mono", 'variant' => ''),
  1333. array( 'name' => "Nova Oval", 'variant' => ''),
  1334. array( 'name' => "Nova Flat", 'variant' => ''),
  1335. array( 'name' => "Terminal Dosis Light", 'variant' => ''),
  1336. array( 'name' => "Michroma", 'variant' => ''),
  1337. array( 'name' => "Miltonian", 'variant' => ''),
  1338. array( 'name' => "Miltonian Tattoo", 'variant' => ''),
  1339. array( 'name' => "Annie Use Your Telescope", 'variant' => ''),
  1340. array( 'name' => "Dawning of a New Day", 'variant' => ''),
  1341. array( 'name' => "Sue Ellen Francisco", 'variant' => ''),
  1342. array( 'name' => "Waiting for the Sunrise", 'variant' => ''),
  1343. array( 'name' => "Special Elite", 'variant' => ''),
  1344. array( 'name' => "Quattrocento Sans", 'variant' => ''),
  1345. array( 'name' => "Smythe", 'variant' => ''),
  1346. array( 'name' => "The Girl Next Door", 'variant' => ''),
  1347. array( 'name' => "Aclonica", 'variant' => ''),
  1348. array( 'name' => "News Cycle", 'variant' => ''),
  1349. array( 'name' => "Damion", 'variant' => ''),
  1350. array( 'name' => "Wallpoet", 'variant' => ''),
  1351. array( 'name' => "Over the Rainbow", 'variant' => ''),
  1352. array( 'name' => "MedievalSharp", 'variant' => ''),
  1353. array( 'name' => "Six Caps", 'variant' => ''),
  1354. array( 'name' => "Swanky and Moo Moo", 'variant' => ''),
  1355. array( 'name' => "Bigshot One", 'variant' => ''),
  1356. array( 'name' => "Francois One", 'variant' => ''),
  1357. array( 'name' => "Sigmar One", 'variant' => ''),
  1358. array( 'name' => "Carter One", 'variant' => ''),
  1359. array( 'name' => "Holtwood One SC", 'variant' => ''),
  1360. array( 'name' => "Paytone One", 'variant' => ''),
  1361. array( 'name' => "Monofett", 'variant' => ''),
  1362. array( 'name' => "Rokkitt", 'variant' => ':400,700'),
  1363. array( 'name' => "Megrim", 'variant' => ''),
  1364. array( 'name' => "Judson", 'variant' => ':r,ri,b'),
  1365. array( 'name' => "Didact Gothic", 'variant' => ''),
  1366. array( 'name' => "Play", 'variant' => ':r,b'),
  1367. array( 'name' => "Ultra", 'variant' => ''),
  1368. array( 'name' => "Metrophobic", 'variant' => ''),
  1369. array( 'name' => "Mako", 'variant' => ''),
  1370. array( 'name' => "Shanti", 'variant' => ''),
  1371. array( 'name' => "Caudex", 'variant' => ':r,b,i,bi'),
  1372. array( 'name' => "Jura", 'variant' => ''),
  1373. array( 'name' => "Ruslan Display", 'variant' => ''),
  1374. array( 'name' => "Brawler", 'variant' => ''),
  1375. array( 'name' => "Nunito", 'variant' => ''),
  1376. array( 'name' => "Wire One", 'variant' => ''),
  1377. array( 'name' => "Podkova", 'variant' => ''),
  1378. array( 'name' => "Muli", 'variant' => ''),
  1379. array( 'name' => "Maven Pro", 'variant' => ':400,500,700'),
  1380. array( 'name' => "Tenor Sans", 'variant' => ''),
  1381. array( 'name' => "Limelight", 'variant' => ''),
  1382. array( 'name' => "Playfair Display", 'variant' => ''),
  1383. array( 'name' => "Artifika", 'variant' => ''),
  1384. array( 'name' => "Lora", 'variant' => ''),
  1385. array( 'name' => "Kameron", 'variant' => ':r,b'),
  1386. array( 'name' => "Cedarville Cursive", 'variant' => ''),
  1387. array( 'name' => "Zeyada", 'variant' => ''),
  1388. array( 'name' => "La Belle Aurore", 'variant' => ''),
  1389. array( 'name' => "Shadows Into Light", 'variant' => ''),
  1390. array( 'name' => "Lobster Two", 'variant' => ':r,b,i,bi'),
  1391. array( 'name' => "Nixie One", 'variant' => ''),
  1392. array( 'name' => "Redressed", 'variant' => ''),
  1393. array( 'name' => "Bangers", 'variant' => ''),
  1394. array( 'name' => "Open Sans Condensed", 'variant' => ':300italic,400italic,700italic,400,300,700'),
  1395. array( 'name' => "Open Sans", 'variant' => ':r,i,b,bi'),
  1396. array( 'name' => "Varela", 'variant' => ''),
  1397. array( 'name' => "Goblin One", 'variant' => ''),
  1398. array( 'name' => "Asset", 'variant' => ''),
  1399. array( 'name' => "Gravitas One", 'variant' => ''),
  1400. array( 'name' => "Hammersmith One", 'variant' => ''),
  1401. array( 'name' => "Stardos Stencil", 'variant' => ''),
  1402. array( 'name' => "Love Ya Like A Sister", 'variant' => ''),
  1403. array( 'name' => "Loved by the King", 'variant' => ''),
  1404. array( 'name' => "Bowlby One SC", 'variant' => ''),
  1405. array( 'name' => "Forum", 'variant' => ''),
  1406. array( 'name' => "Patrick Hand", 'variant' => ''),
  1407. array( 'name' => "Varela Round", 'variant' => ''),
  1408. array( 'name' => "Yeseva One", 'variant' => ''),
  1409. array( 'name' => "Give You Glory", 'variant' => ''),
  1410. array( 'name' => "Modern Antiqua", 'variant' => ''),
  1411. array( 'name' => "Bowlby One", 'variant' => ''),
  1412. array( 'name' => "Tienne", 'variant' => ''),
  1413. array( 'name' => "Istok Web", 'variant' => ':r,b,i,bi'),
  1414. array( 'name' => "Yellowtail", 'variant' => ''),
  1415. array( 'name' => "Pompiere", 'variant' => ''),
  1416. array( 'name' => "Unna", 'variant' => ''),
  1417. array( 'name' => "Rosario", 'variant' => ''),
  1418. array( 'name' => "Leckerli One", 'variant' => ''),
  1419. array( 'name' => "Snippet", 'variant' => ''),
  1420. array( 'name' => "Ovo", 'variant' => ''),
  1421. array( 'name' => "IM Fell English", 'variant' => ':r,i'),
  1422. array( 'name' => "IM Fell English SC", 'variant' => ''),
  1423. array( 'name' => "Gloria Hallelujah", 'variant' => ''),
  1424. array( 'name' => "Kelly Slab", 'variant' => ''),
  1425. array( 'name' => "Black Ops One", 'variant' => ''),
  1426. array( 'name' => "Carme", 'variant' => ''),
  1427. array( 'name' => "Aubrey", 'variant' => ''),
  1428. array( 'name' => "Federo", 'variant' => ''),
  1429. array( 'name' => "Delius", 'variant' => ''),
  1430. array( 'name' => "Rochester", 'variant' => ''),
  1431. array( 'name' => "Rationale", 'variant' => ''),
  1432. array( 'name' => "Abel", 'variant' => ''),
  1433. array( 'name' => "Marvel", 'variant' => ':r,b,i,bi'),
  1434. array( 'name' => "Actor", 'variant' => ''),
  1435. array( 'name' => "Delius Swash Caps", 'variant' => ''),
  1436. array( 'name' => "Smokum", 'variant' => ''),
  1437. array( 'name' => "Tulpen One", 'variant' => ''),
  1438. array( 'name' => "Coustard", 'variant' => ':r,b'),
  1439. array( 'name' => "Andika", 'variant' => ''),
  1440. array( 'name' => "Alice", 'variant' => ''),
  1441. array( 'name' => "Questrial", 'variant' => ''),
  1442. array( 'name' => "Comfortaa", 'variant' => ':r,b'),
  1443. array( 'name' => "Geostar", 'variant' => ''),
  1444. array( 'name' => "Geostar Fill", 'variant' => ''),
  1445. array( 'name' => "Volkhov", 'variant' => ''),
  1446. array( 'name' => "Voltaire", 'variant' => ''),
  1447. array( 'name' => "Montez", 'variant' => ''),
  1448. array( 'name' => "Short Stack", 'variant' => ''),
  1449. array( 'name' => "Vidaloka", 'variant' => ''),
  1450. array( 'name' => "Aldrich", 'variant' => ''),
  1451. array( 'name' => "Numans", 'variant' => ''),
  1452. array( 'name' => "Days One", 'variant' => ''),
  1453. array( 'name' => "Gentium Book Basic", 'variant' => ''),
  1454. array( 'name' => "Monoton", 'variant' => ''),
  1455. array( 'name' => "Alike", 'variant' => ''),
  1456. array( 'name' => "Delius Unicase", 'variant' => ''),
  1457. array( 'name' => "Abril Fatface", 'variant' => ''),
  1458. array( 'name' => "Dorsa", 'variant' => ''),
  1459. array( 'name' => "Antic", 'variant' => ''),
  1460. array( 'name' => "Passero One", 'variant' => ''),
  1461. array( 'name' => "Fanwood Text", 'variant' => ''),
  1462. array( 'name' => "Prociono", 'variant' => ''),
  1463. array( 'name' => "Merienda One", 'variant' => ''),
  1464. array( 'name' => "Changa One", 'variant' => ''),
  1465. array( 'name' => "Julee", 'variant' => ''),
  1466. array( 'name' => "Prata", 'variant' => ''),
  1467. array( 'name' => "Adamina", 'variant' => ''),
  1468. array( 'name' => "Sorts Mill Goudy", 'variant' => ''),
  1469. array( 'name' => "Terminal Dosis", 'variant' => ''),
  1470. array( 'name' => "Sansita One", 'variant' => ''),
  1471. array( 'name' => "Chivo", 'variant' => ''),
  1472. array( 'name' => "Spinnaker", 'variant' => ''),
  1473. array( 'name' => "Poller One", 'variant' => ''),
  1474. array( 'name' => "Alike Angular", 'variant' => ''),
  1475. array( 'name' => "Gochi Hand", 'variant' => ''),
  1476. array( 'name' => "Poly", 'variant' => ''),
  1477. array( 'name' => "Andada", 'variant' => ''),
  1478. array( 'name' => "Federant", 'variant' => ''),
  1479. array( 'name' => "Ubuntu Condensed", 'variant' => ''),
  1480. array( 'name' => "Ubuntu Mono", 'variant' => ''),
  1481. array( 'name' => "Sancreek", 'variant' => ''),
  1482. array( 'name' => "Coda", 'variant' => ''),
  1483. array( 'name' => "Rancho", 'variant' => ''),
  1484. array( 'name' => "Satisfy", 'variant' => ''),
  1485. array( 'name' => "Pinyon Script", 'variant' => ''),
  1486. array( 'name' => "Vast Shadow", 'variant' => ''),
  1487. array( 'name' => "Marck Script", 'variant' => ''),
  1488. array( 'name' => "Salsa", 'variant' => ''),
  1489. array( 'name' => "Amatic SC", 'variant' => ''),
  1490. array( 'name' => "Quicksand", 'variant' => ''),
  1491. array( 'name' => "Linden Hill", 'variant' => ''),
  1492. array( 'name' => "Corben", 'variant' => ''),
  1493. array( 'name' => "Creepster Caps", 'variant' => ''),
  1494. array( 'name' => "Butcherman Caps", 'variant' => ''),
  1495. array( 'name' => "Eater Caps", 'variant' => ''),
  1496. array( 'name' => "Nosifer Caps", 'variant' => ''),
  1497. array( 'name' => "Atomic Age", 'variant' => ''),
  1498. array( 'name' => "Contrail One", 'variant' => ''),
  1499. array( 'name' => "Jockey One", 'variant' => ''),
  1500. array( 'name' => "Cabin Sketch", 'variant' => ':r,b'),
  1501. array( 'name' => "Cabin Condensed", 'variant' => ':r,b'),
  1502. array( 'name' => "Fjord One", 'variant' => ''),
  1503. array( 'name' => "Rametto One", 'variant' => ''),
  1504. array( 'name' => "Mate", 'variant' => ':r,i'),
  1505. array( 'name' => "Mate SC", 'variant' => ''),
  1506. array( 'name' => "Arapey", 'variant' => ':r,i'),
  1507. array( 'name' => "Supermercado One", 'variant' => ''),
  1508. array( 'name' => "Petrona", 'variant' => ''),
  1509. array( 'name' => "Lancelot", 'variant' => ''),
  1510. array( 'name' => "Convergence", 'variant' => ''),
  1511. array( 'name' => "Cutive", 'variant' => ''),
  1512. array( 'name' => "Karla", 'variant' => ':400,400italic,700,700italic'),
  1513. array( 'name' => "Bitter", 'variant' => ':r,i,b'),
  1514. array( 'name' => "Asap", 'variant' => ':400,700,400italic,700italic'),
  1515. array( 'name' => "Bree Serif", 'variant' => '')
  1516. );
  1517. /*-----------------------------------------------------------------------------------*/
  1518. /* Google Webfonts Stylesheet Generator */
  1519. /*-----------------------------------------------------------------------------------*/
  1520. /*
  1521. INSTRUCTIONS: Needs to be loaded for the Google Fonts options to work for font options. Add this to
  1522. the specific themes includes/theme-actions.php or functions.php:
  1523. add_action( 'wp_head', 'woo_google_webfonts' );
  1524. */
  1525. if ( ! function_exists( 'woo_google_webfonts' ) ) {
  1526. function woo_google_webfonts() {
  1527. global $google_fonts;
  1528. $fonts = '';
  1529. $output = '';
  1530. // Setup Woo Options array
  1531. global $woo_options;
  1532. // Go through the options
  1533. if ( !empty($woo_options) ) {
  1534. foreach ( $woo_options as $option ) {
  1535. // Check if option has "face" in array
  1536. if ( is_array($option) && isset($option['face']) ) {
  1537. // Go through the google font array
  1538. foreach ($google_fonts as $font) {
  1539. // Check if the google font name exists in the current "face" option
  1540. if ( $option['face'] == $font['name'] AND !strstr($fonts, $font['name']) ) {
  1541. // Add google font to output
  1542. $fonts .= $font['name'].$font['variant']."|";
  1543. } // End If Statement
  1544. } // End Foreach Loop
  1545. } // End If Statement
  1546. } // End Foreach Loop
  1547. // Output google font css in header
  1548. if ( $fonts ) {
  1549. $fonts = str_replace( " ","+",$fonts);
  1550. $output .= "\n<!-- Google Webfonts -->\n";
  1551. $output .= '<link href="http'. ( is_ssl() ? 's' : '' ) .'://fonts.googleapis.com/css?family=' . $fonts .'" rel="stylesheet" type="text/css" />'."\n";
  1552. $output = str_replace( '|"','"',$output);
  1553. echo $output;
  1554. }
  1555. }
  1556. } // End woo_google_webfonts()
  1557. }
  1558. /*-----------------------------------------------------------------------------------*/
  1559. /* Enable Home link in WP Menus
  1560. /*-----------------------------------------------------------------------------------*/
  1561. if ( !function_exists( 'woo_home_page_menu_args' ) ) {
  1562. function woo_home_page_menu_args( $args ) {
  1563. $args['show_home'] = true;
  1564. return $args;
  1565. } // End woo_home_page_menu_args()
  1566. add_filter( 'wp_page_menu_args', 'woo_home_page_menu_args' );
  1567. }
  1568. /*---------------------------------------------------------------------------------*/
  1569. /* Detects the Charset of String and Converts it to UTF-8 */
  1570. /*---------------------------------------------------------------------------------*/
  1571. if ( !function_exists( 'woo_encoding_convert') ) {
  1572. function woo_encoding_convert($str_to_convert) {
  1573. if ( function_exists( 'mb_detect_encoding') ) {
  1574. $str_lang_encoding = mb_detect_encoding($str_to_convert);
  1575. //if no encoding detected, assume UTF-8
  1576. if (!$str_lang_encoding) {
  1577. //UTF-8 assumed
  1578. $str_lang_converted_utf = $str_to_convert;
  1579. } else {
  1580. //Convert to UTF-8
  1581. $str_lang_converted_utf = mb_convert_encoding($str_to_convert, 'UTF-8', $str_lang_encoding);
  1582. }
  1583. } else {
  1584. $str_lang_converted_utf = $str_to_convert;
  1585. }
  1586. return $str_lang_converted_utf;
  1587. }
  1588. }
  1589. /*---------------------------------------------------------------------------------*/
  1590. /* WP Login logo */
  1591. /*---------------------------------------------------------------------------------*/
  1592. if ( !function_exists( 'woo_custom_login_logo' ) ) {
  1593. function woo_custom_login_logo() {
  1594. $logo = get_option( 'framework_woo_custom_login_logo' );
  1595. $dimensions = @getimagesize( $logo );
  1596. $background_size = 'background-size: auto;';
  1597. if ( 0 >= $dimensions[1] ) {
  1598. $dimensions[1] = '67';
  1599. $background_size = '';
  1600. }
  1601. echo '<style type="text/css">body #login h1 a { background-image:url( ' . esc_url( $logo ) . ' ); height: ' . intval( $dimensions[1] ) . 'px; width: auto; ' . $background_size . ' }</style>';
  1602. } // End woo_custom_login_logo()
  1603. if ( '' != get_option( 'framework_woo_custom_login_logo') ) {
  1604. add_action( 'login_head', 'woo_custom_login_logo' );
  1605. }
  1606. }
  1607. /*---------------------------------------------------------------------------------*/
  1608. /* WP Login logo URL */
  1609. /*---------------------------------------------------------------------------------*/
  1610. if ( ! function_exists( 'woo_custom_login_logo_url' ) ) {
  1611. function woo_custom_login_logo_url( $text ) {
  1612. return get_option( 'framework_woo_custom_login_logo_url' ); // Escaping via esc_url() is done in wp-login.php.
  1613. } // End woo_custom_login_logo_url()
  1614. if ( '' != get_option( 'framework_woo_custom_login_logo_url' ) ) {
  1615. add_filter( 'login_headerurl', 'woo_custom_login_logo_url', 10 );
  1616. }
  1617. }
  1618. /*---------------------------------------------------------------------------------*/
  1619. /* WP Login logo title */
  1620. /*---------------------------------------------------------------------------------*/
  1621. if ( ! function_exists( 'woo_custom_login_logo_title' ) ) {
  1622. function woo_custom_login_logo_title( $text ) {
  1623. return get_option( 'framework_woo_custom_login_logo_title' ); // Escaping via esc_attr() is done in wp-login.php.
  1624. } // End woo_custom_login_logo_title()
  1625. if ( '' != get_option( 'framework_woo_custom_login_logo_title' ) ) {
  1626. add_filter( 'login_headertitle', 'woo_custom_login_logo_title', 10 );
  1627. }
  1628. }
  1629. /*-----------------------------------------------------------------------------------*/
  1630. /* woo_pagination() - Custom loop pagination function */
  1631. /*-----------------------------------------------------------------------------------*/
  1632. /*
  1633. /* Additional documentation: http://codex.wordpress.org/Function_Reference/paginate_links
  1634. /*
  1635. /* Params:
  1636. /*
  1637. /* Arguments Array:
  1638. /*
  1639. /* 'base' (optional) - The query argument on which to determine the pagination (for advanced users)
  1640. /* 'format' (optional) - The format in which the query argument is formatted in it's raw format (for advanced users)
  1641. /* 'total' (optional) - The total amount of pages
  1642. /* 'current' (optional) - The current page number
  1643. /* 'prev_next' (optional) - Whether to include the previous and next links in the list or not.
  1644. /* 'prev_text' (optional) - The previous page text. Works only if 'prev_next' argument is set to true.
  1645. /* 'next_text' (optional) - The next page text. Works only if 'prev_next' argument is set to true.
  1646. /* 'show_all' (optional) - If set to True, then it will show all of the pages instead of a short list of the pages near the current page. By default, the 'show_all' is set to false and controlled by the 'end_size' and 'mid_size' arguments.
  1647. /* 'end_size' (optional) - How many numbers on either the start and the end list edges.
  1648. /* 'mid_size' (optional) - How many numbers to either side of current page, but not including current page.
  1649. /* 'add_fragment' (optional) - An array of query args to add using add_query_arg().
  1650. /* 'type' (optional) - Controls format of the returned value. Possible values are:
  1651. 'plain' - A string with the links separated by a newline character.
  1652. 'array' - An array of the paginated link list to offer full control of display.
  1653. 'list' - Unordered HTML list.
  1654. /* 'before' (optional) - The HTML to display before the paginated links.
  1655. /* 'after' (optional) - The HTML to display after the paginated links.
  1656. /* 'echo' (optional) - Whether or not to display the paginated links (alternative is to "return").
  1657. /* 'use_search_permastruct' (optiona;) - Whether or not to use the "pretty" URL permastruct for search URLs.
  1658. /*
  1659. /* Query Parameter (optional) - Specify a custom query which you'd like to paginate.
  1660. /*
  1661. /*-----------------------------------------------------------------------------------*/
  1662. /**
  1663. * woo_pagination() is used for paginating the various archive pages created by WordPress. This is not
  1664. * to be used on single.php or other single view pages.
  1665. *
  1666. * @since 3.7.0
  1667. * @uses paginate_links() Creates a string of paginated links based on the arguments given.
  1668. * @param array $args Arguments to customize how the page links are output.
  1669. * @param object $query An optional custom query to paginate.
  1670. */
  1671. if ( ! function_exists( 'woo_pagination' ) ) {
  1672. function woo_pagination( $args = array(), $query = '' ) {
  1673. global $wp_rewrite, $wp_query;
  1674. do_action( 'woo_pagination_start' );
  1675. if ( $query ) {
  1676. $wp_query = $query;
  1677. } // End IF Statement
  1678. /* If there's not more than one page, return nothing. */
  1679. if ( 1 >= $wp_query->max_num_pages )
  1680. return;
  1681. /* Get the current page. */
  1682. $current = ( get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1 );
  1683. /* Get the max number of pages. */
  1684. $max_num_pages = intval( $wp_query->max_num_pages );
  1685. /* Set up some default arguments for the paginate_links() function. */
  1686. $defaults = array(
  1687. 'base' => add_query_arg( 'paged', '%#%' ),
  1688. 'format' => '',
  1689. 'total' => $max_num_pages,
  1690. 'current' => $current,
  1691. 'prev_next' => true,
  1692. 'prev_text' => __( '&larr; Previous', 'woothemes' ), // Translate in WordPress. This is the default.
  1693. 'next_text' => __( 'Next &rarr;', 'woothemes' ), // Translate in WordPress. This is the default.
  1694. 'show_all' => false,
  1695. 'end_size' => 1,
  1696. 'mid_size' => 1,
  1697. 'add_fragment' => '',
  1698. 'type' => 'plain',
  1699. 'before' => '<div class="pagination woo-pagination">', // Begin woo_pagination() arguments.
  1700. 'after' => '</div>',
  1701. 'echo' => true,
  1702. 'use_search_permastruct' => true
  1703. );
  1704. /* Allow themes/plugins to filter the default arguments. */
  1705. $defaults = apply_filters( 'woo_pagination_args_defaults', $defaults );
  1706. /* Add the $base argument to the array if the user is using permalinks. */
  1707. if( $wp_rewrite->using_permalinks() && ! is_search() )
  1708. $defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . 'page/%#%' );
  1709. /* Force search links to use raw permastruct for more accurate multi-word searching. */
  1710. if ( is_search() )
  1711. $defaults['use_search_permastruct'] = false;
  1712. /* If we're on a search results page, we need to change this up a bit. */
  1713. if ( is_search() ) {
  1714. /* If we're in BuddyPress, or the user has selected to do so, use the default "unpretty" URL structure. */
  1715. if ( class_exists( 'BP_Core_User' ) || $defaults['use_search_permastruct'] == false ) {
  1716. $search_query = get_query_var( 's' );
  1717. $paged = get_query_var( 'paged' );
  1718. $base = add_query_arg( 's', urlencode( $search_query ) );
  1719. $base = add_query_arg( 'paged', '%#%' );
  1720. $defaults['base'] = $base;
  1721. } else {
  1722. $search_permastruct = $wp_rewrite->get_search_permastruct();
  1723. if ( ! empty( $search_permastruct ) ) {
  1724. $base = get_search_link();
  1725. $base = add_query_arg( 'paged', '%#%', $base );
  1726. $defaults['base'] = $base;
  1727. }
  1728. }
  1729. }
  1730. /* Merge the arguments input with the defaults. */
  1731. $args = wp_parse_args( $args, $defaults );
  1732. /* Allow developers to overwrite the arguments with a filter. */
  1733. $args = apply_filters( 'woo_pagination_args', $args );
  1734. /* Don't allow the user to set this to an array. */
  1735. if ( 'array' == $args['type'] )
  1736. $args['type'] = 'plain';
  1737. /* Make sure raw querystrings are displayed at the end of the URL, if using pretty permalinks. */
  1738. $pattern = '/\?(.*?)\//i';
  1739. preg_match( $pattern, $args['base'], $raw_querystring );
  1740. if( $wp_rewrite->using_permalinks() && $raw_querystring )
  1741. $raw_querystring[0] = str_replace( '', '', $raw_querystring[0] );
  1742. @$args['base'] = str_replace( $raw_querystring[0], '', $args['base'] );
  1743. @$args['base'] .= substr( $raw_querystring[0], 0, -1 );
  1744. /* Get the paginated links. */
  1745. $page_links = paginate_links( $args );
  1746. /* Remove 'page/1' from the entire output since it's not needed. */
  1747. $page_links = str_replace( array( '&#038;paged=1\'', '/page/1\'' ), '\'', $page_links );
  1748. /* Wrap the paginated links with the $before and $after elements. */
  1749. $page_links = $args['before'] . $page_links . $args['after'];
  1750. /* Allow devs to completely overwrite the output. */
  1751. $page_links = apply_filters( 'woo_pagination', $page_links );
  1752. do_action( 'woo_pagination_end' );
  1753. /* Return the paginated links for use in themes. */
  1754. if ( $args['echo'] )
  1755. echo $page_links;
  1756. else
  1757. return $page_links;
  1758. } // End woo_pagination()
  1759. } // End IF Statement
  1760. /*-----------------------------------------------------------------------------------*/
  1761. /* woo_breadcrumbs() - Custom breadcrumb generator function */
  1762. /*
  1763. /* Params:
  1764. /*
  1765. /* Arguments Array:
  1766. /*
  1767. /* 'separator' - The character to display between the breadcrumbs.
  1768. /* 'before' - HTML to display before the breadcrumbs.
  1769. /* 'after' - HTML to display after the breadcrumbs.
  1770. /* 'front_page' - Include the front page at the beginning of the breadcrumbs.
  1771. /* 'show_home' - If $show_home is set and we're not on the front page of the site, link to the home page.
  1772. /* 'echo' - Specify whether or not to echo the breadcrumbs. Alternative is "return".
  1773. /* 'show_posts_page' - If a static front page is set and there is a posts page, toggle whether or not to display that page's tree.
  1774. /*
  1775. /*-----------------------------------------------------------------------------------*/
  1776. /**
  1777. * The code below is inspired by Justin Tadlock's Hybrid Core.
  1778. *
  1779. * woo_breadcrumbs() shows a breadcrumb for all types of pages. Themes and plugins can filter $args or input directly.
  1780. * Allow filtering of only the $args using get_the_breadcrumb_args.
  1781. *
  1782. * @since 3.7.0
  1783. * @param array $args Mixed arguments for the menu.
  1784. * @return string Output of the breadcrumb menu.
  1785. */
  1786. function woo_breadcrumbs( $args = array() ) {
  1787. global $wp_query, $wp_rewrite;
  1788. /* Create an empty variable for the breadcrumb. */
  1789. $breadcrumb = '';
  1790. /* Create an empty array for the trail. */
  1791. $trail = array();
  1792. $path = '';
  1793. /* Set up the default arguments for the breadcrumb. */
  1794. $defaults = array(
  1795. 'separator' => '&gt;',
  1796. 'before' => '<span class="breadcrumb-title">' . __( 'You are here:', 'woothemes' ) . '</span>',
  1797. 'after' => false,
  1798. 'front_page' => true,
  1799. 'show_home' => __( 'Home', 'woothemes' ),
  1800. 'echo' => true,
  1801. 'show_posts_page' => true
  1802. );
  1803. /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
  1804. if ( is_singular() )
  1805. $defaults["singular_{$wp_query->post->post_type}_taxonomy"] = false;
  1806. /* Apply filters to the arguments. */
  1807. $args = apply_filters( 'woo_breadcrumbs_args', $args );
  1808. /* Parse the arguments and extract them for easy variable naming. */
  1809. extract( wp_parse_args( $args, $defaults ) );
  1810. /* If $show_home is set and we're not on the front page of the site, link to the home page. */
  1811. if ( !is_front_page() && $show_home )
  1812. $trail[] = '<a href="' . esc_url( home_url() ) . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" rel="home" class="trail-begin">' . esc_html( $show_home ) . '</a>';
  1813. /* If viewing the front page of the site. */
  1814. if ( is_front_page() ) {
  1815. if ( !$front_page )
  1816. $trail = false;
  1817. elseif ( $show_home )
  1818. $trail['trail_end'] = "{$show_home}";
  1819. }
  1820. /* If viewing the "home"/posts page. */
  1821. elseif ( is_home() ) {
  1822. $home_page = get_page( $wp_query->get_queried_object_id() );
  1823. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( $home_page->post_parent, '' ) );
  1824. $trail['trail_end'] = get_the_title( $home_page->ID );
  1825. }
  1826. /* If viewing a singular post (page, attachment, etc.). */
  1827. elseif ( is_singular() ) {
  1828. /* Get singular post variables needed. */
  1829. $post = $wp_query->get_queried_object();
  1830. $post_id = absint( $wp_query->get_queried_object_id() );
  1831. $post_type = $post->post_type;
  1832. $parent = $post->post_parent;
  1833. /* If a custom post type, check if there are any pages in its hierarchy based on the slug. */
  1834. if ( 'page' !== $post_type && 'post' !== $post_type ) {
  1835. $post_type_object = get_post_type_object( $post_type );
  1836. /* If $front has been set, add it to the $path. */
  1837. if ( 'post' == $post_type || 'attachment' == $post_type || ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front ) )
  1838. $path .= trailingslashit( $wp_rewrite->front );
  1839. /* If there's a slug, add it to the $path. */
  1840. if ( !empty( $post_type_object->rewrite['slug'] ) )
  1841. $path .= $post_type_object->rewrite['slug'];
  1842. /* If there's a path, check for parents. */
  1843. if ( !empty( $path ) && '/' != $path )
  1844. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( '', $path ) );
  1845. /* If there's an archive page, add it to the trail. */
  1846. if ( !empty( $post_type_object->has_archive ) && function_exists( 'get_post_type_archive_link' ) )
  1847. $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';
  1848. }
  1849. /* If the post type path returns nothing and there is a parent, get its parents. */
  1850. if ( empty( $path ) && 0 !== $parent || 'attachment' == $post_type )
  1851. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( $parent, '' ) );
  1852. /* Toggle the display of the posts page on single blog posts. */
  1853. if ( 'post' == $post_type && $show_posts_page == true && 'page' == get_option( 'show_on_front' ) ) {
  1854. $posts_page = get_option( 'page_for_posts' );
  1855. if ( $posts_page != '' && is_numeric( $posts_page ) ) {
  1856. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( $posts_page, '' ) );
  1857. }
  1858. }
  1859. /* Display terms for specific post type taxonomy if requested. */
  1860. if ( isset( $args["singular_{$post_type}_taxonomy"] ) && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) )
  1861. $trail[] = $terms;
  1862. /* End with the post title. */
  1863. $post_title = get_the_title( $post_id ); // Force the post_id to make sure we get the correct page title.
  1864. if ( !empty( $post_title ) )
  1865. $trail['trail_end'] = $post_title;
  1866. }
  1867. /* If we're viewing any type of archive. */
  1868. elseif ( is_archive() ) {
  1869. /* If viewing a taxonomy term archive. */
  1870. if ( is_tax() || is_category() || is_tag() ) {
  1871. /* Get some taxonomy and term variables. */
  1872. $term = $wp_query->get_queried_object();
  1873. $taxonomy = get_taxonomy( $term->taxonomy );
  1874. /* Get the path to the term archive. Use this to determine if a page is present with it. */
  1875. if ( is_category() )
  1876. $path = get_option( 'category_base' );
  1877. elseif ( is_tag() )
  1878. $path = get_option( 'tag_base' );
  1879. else {
  1880. if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
  1881. $path = trailingslashit( $wp_rewrite->front );
  1882. $path .= $taxonomy->rewrite['slug'];
  1883. }
  1884. /* Get parent pages by path if they exist. */
  1885. if ( $path )
  1886. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( '', $path ) );
  1887. /* If the taxonomy is hierarchical, list its parent terms. */
  1888. if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
  1889. $trail = array_merge( $trail, woo_breadcrumbs_get_term_parents( $term->parent, $term->taxonomy ) );
  1890. /* Add the term name to the trail end. */
  1891. $trail['trail_end'] = $term->name;
  1892. }
  1893. /* If viewing a post type archive. */
  1894. elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
  1895. /* Get the post type object. */
  1896. $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
  1897. /* If $front has been set, add it to the $path. */
  1898. if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front )
  1899. $path .= trailingslashit( $wp_rewrite->front );
  1900. /* If there's a slug, add it to the $path. */
  1901. if ( !empty( $post_type_object->rewrite['archive'] ) )
  1902. $path .= $post_type_object->rewrite['archive'];
  1903. /* If there's a path, check for parents. */
  1904. if ( !empty( $path ) && '/' != $path )
  1905. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( '', $path ) );
  1906. /* Add the post type [plural] name to the trail end. */
  1907. $trail['trail_end'] = $post_type_object->labels->name;
  1908. }
  1909. /* If viewing an author archive. */
  1910. elseif ( is_author() ) {
  1911. /* If $front has been set, add it to $path. */
  1912. if ( !empty( $wp_rewrite->front ) )
  1913. $path .= trailingslashit( $wp_rewrite->front );
  1914. /* If an $author_base exists, add it to $path. */
  1915. if ( !empty( $wp_rewrite->author_base ) )
  1916. $path .= $wp_rewrite->author_base;
  1917. /* If $path exists, check for parent pages. */
  1918. if ( !empty( $path ) )
  1919. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( '', $path ) );
  1920. /* Add the author's display name to the trail end. */
  1921. $trail['trail_end'] = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
  1922. }
  1923. /* If viewing a time-based archive. */
  1924. elseif ( is_time() ) {
  1925. if ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
  1926. $trail['trail_end'] = get_the_time( __( 'g:i a', 'woothemes' ) );
  1927. elseif ( get_query_var( 'minute' ) )
  1928. $trail['trail_end'] = sprintf( __( 'Minute %1$s', 'woothemes' ), get_the_time( __( 'i', 'woothemes' ) ) );
  1929. elseif ( get_query_var( 'hour' ) )
  1930. $trail['trail_end'] = get_the_time( __( 'g a', 'woothemes' ) );
  1931. }
  1932. /* If viewing a date-based archive. */
  1933. elseif ( is_date() ) {
  1934. /* If $front has been set, check for parent pages. */
  1935. if ( $wp_rewrite->front )
  1936. $trail = array_merge( $trail, woo_breadcrumbs_get_parents( '', $wp_rewrite->front ) );
  1937. if ( is_day() ) {
  1938. $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', 'woothemes' ) ) . '">' . get_the_time( __( 'Y', 'woothemes' ) ) . '</a>';
  1939. $trail[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . get_the_time( esc_attr__( 'F', 'woothemes' ) ) . '">' . get_the_time( __( 'F', 'woothemes' ) ) . '</a>';
  1940. $trail['trail_end'] = get_the_time( __( 'j', 'woothemes' ) );
  1941. }
  1942. elseif ( get_query_var( 'w' ) ) {
  1943. $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', 'woothemes' ) ) . '">' . get_the_time( __( 'Y', 'woothemes' ) ) . '</a>';
  1944. $trail['trail_end'] = sprintf( __( 'Week %1$s', 'woothemes' ), get_the_time( esc_attr__( 'W', 'woothemes' ) ) );
  1945. }
  1946. elseif ( is_month() ) {
  1947. $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', 'woothemes' ) ) . '">' . get_the_time( __( 'Y', 'woothemes' ) ) . '</a>';
  1948. $trail['trail_end'] = get_the_time( __( 'F', 'woothemes' ) );
  1949. }
  1950. elseif ( is_year() ) {
  1951. $trail['trail_end'] = get_the_time( __( 'Y', 'woothemes' ) );
  1952. }
  1953. }
  1954. }
  1955. /* If viewing search results. */
  1956. elseif ( is_search() )
  1957. $trail['trail_end'] = sprintf( __( 'Search results for &quot;%1$s&quot;', 'woothemes' ), esc_attr( get_search_query() ) );
  1958. /* If viewing a 404 error page. */
  1959. elseif ( is_404() )
  1960. $trail['trail_end'] = __( '404 Not Found', 'woothemes' );
  1961. /* Allow child themes/plugins to filter the trail array. */
  1962. $trail = apply_filters( 'woo_breadcrumbs_trail', $trail, $args );
  1963. /* Connect the breadcrumb trail if there are items in the trail. */
  1964. if ( is_array( $trail ) ) {
  1965. /* Open the breadcrumb trail containers. */
  1966. $breadcrumb = '<div class="breadcrumb breadcrumbs woo-breadcrumbs"><div class="breadcrumb-trail">';
  1967. /* If $before was set, wrap it in a container. */
  1968. if ( !empty( $before ) )
  1969. $breadcrumb .= '<span class="trail-before">' . wp_kses_post( $before ) . '</span> ';
  1970. /* Wrap the $trail['trail_end'] value in a container. */
  1971. if ( !empty( $trail['trail_end'] ) )
  1972. $trail['trail_end'] = '<span class="trail-end">' . wp_kses_post( $trail['trail_end'] ) . '</span>';
  1973. /* Format the separator. */
  1974. if ( !empty( $separator ) )
  1975. $separator = '<span class="sep">' . wp_kses_post( $separator ) . '</span>';
  1976. /* Join the individual trail items into a single string. */
  1977. $breadcrumb .= join( " {$separator} ", $trail );
  1978. /* If $after was set, wrap it in a container. */
  1979. if ( !empty( $after ) )
  1980. $breadcrumb .= ' <span class="trail-after">' . wp_kses_post( $after ) . '</span>';
  1981. /* Close the breadcrumb trail containers. */
  1982. $breadcrumb .= '</div></div>';
  1983. }
  1984. /* Allow developers to filter the breadcrumb trail HTML. */
  1985. $breadcrumb = apply_filters( 'woo_breadcrumbs', $breadcrumb );
  1986. /* Output the breadcrumb. */
  1987. if ( $echo )
  1988. echo $breadcrumb;
  1989. else
  1990. return $breadcrumb;
  1991. } // End woo_breadcrumbs()
  1992. /*-----------------------------------------------------------------------------------*/
  1993. /* woo_breadcrumbs_get_parents() - Retrieve the parents of the current page/post */
  1994. /*-----------------------------------------------------------------------------------*/
  1995. /**
  1996. * Gets parent pages of any post type or taxonomy by the ID or Path. The goal of this function is to create
  1997. * a clear path back to home given what would normally be a "ghost" directory. If any page matches the given
  1998. * path, it'll be added. But, it's also just a way to check for a hierarchy with hierarchical post types.
  1999. *
  2000. * @since 3.7.0
  2001. * @param int $post_id ID of the post whose parents we want.
  2002. * @param string $path Path of a potential parent page.
  2003. * @return array $trail Array of parent page links.
  2004. */
  2005. function woo_breadcrumbs_get_parents( $post_id = '', $path = '' ) {
  2006. /* Set up an empty trail array. */
  2007. $trail = array();
  2008. /* If neither a post ID nor path set, return an empty array. */
  2009. if ( empty( $post_id ) && empty( $path ) )
  2010. return $trail;
  2011. /* If the post ID is empty, use the path to get the ID. */
  2012. if ( empty( $post_id ) ) {
  2013. /* Get parent post by the path. */
  2014. $parent_page = get_page_by_path( $path );
  2015. /* ********************************************************************
  2016. Modification: The above line won't get the parent page if
  2017. the post type slug or parent page path is not the full path as required
  2018. by get_page_by_path. By using get_page_with_title, the full parent
  2019. trail can be obtained. This may still be buggy for page names that use
  2020. characters or long concatenated names.
  2021. Author: Byron Rode
  2022. Date: 06 June 2011
  2023. ******************************************************************* */
  2024. if( empty( $parent_page ) )
  2025. // search on page name (single word)
  2026. $parent_page = get_page_by_title ( $path );
  2027. if( empty( $parent_page ) )
  2028. // search on page title (multiple words)
  2029. $parent_page = get_page_by_title ( str_replace( array('-', '_'), ' ', $path ) );
  2030. /* End Modification */
  2031. /* If a parent post is found, set the $post_id variable to it. */
  2032. if ( !empty( $parent_page ) )
  2033. $post_id = $parent_page->ID;
  2034. }
  2035. /* If a post ID and path is set, search for a post by the given path. */
  2036. if ( $post_id == 0 && !empty( $path ) ) {
  2037. /* Separate post names into separate paths by '/'. */
  2038. $path = trim( $path, '/' );
  2039. preg_match_all( "/\/.*?\z/", $path, $matches );
  2040. /* If matches are found for the path. */
  2041. if ( isset( $matches ) ) {
  2042. /* Reverse the array of matches to search for posts in the proper order. */
  2043. $matches = array_reverse( $matches );
  2044. /* Loop through each of the path matches. */
  2045. foreach ( $matches as $match ) {
  2046. /* If a match is found. */
  2047. if ( isset( $match[0] ) ) {
  2048. /* Get the parent post by the given path. */
  2049. $path = str_replace( $match[0], '', $path );
  2050. $parent_page = get_page_by_path( trim( $path, '/' ) );
  2051. /* If a parent post is found, set the $post_id and break out of the loop. */
  2052. if ( !empty( $parent_page ) && $parent_page->ID > 0 ) {
  2053. $post_id = $parent_page->ID;
  2054. break;
  2055. }
  2056. }
  2057. }
  2058. }
  2059. }
  2060. /* While there's a post ID, add the post link to the $parents array. */
  2061. while ( $post_id ) {
  2062. /* Get the post by ID. */
  2063. $page = get_page( $post_id );
  2064. /* Add the formatted post link to the array of parents. */
  2065. $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . esc_html( get_the_title( $post_id ) ) . '</a>';
  2066. /* Set the parent post's parent to the post ID. */
  2067. $post_id = $page->post_parent;
  2068. }
  2069. /* If we have parent posts, reverse the array to put them in the proper order for the trail. */
  2070. if ( isset( $parents ) )
  2071. $trail = array_reverse( $parents );
  2072. /* Return the trail of parent posts. */
  2073. return $trail;
  2074. } // End woo_breadcrumbs_get_parents()
  2075. /*-----------------------------------------------------------------------------------*/
  2076. /* woo_breadcrumbs_get_term_parents() - Retrieve the parents of the current term */
  2077. /*-----------------------------------------------------------------------------------*/
  2078. /**
  2079. * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
  2080. * function get_category_parents() but handles any type of taxonomy.
  2081. *
  2082. * @since 3.7.0
  2083. * @param int $parent_id The ID of the first parent.
  2084. * @param object|string $taxonomy The taxonomy of the term whose parents we want.
  2085. * @return array $trail Array of links to parent terms.
  2086. */
  2087. function woo_breadcrumbs_get_term_parents( $parent_id = '', $taxonomy = '' ) {
  2088. /* Set up some default arrays. */
  2089. $trail = array();
  2090. $parents = array();
  2091. /* If no term parent ID or taxonomy is given, return an empty array. */
  2092. if ( empty( $parent_id ) || empty( $taxonomy ) )
  2093. return $trail;
  2094. /* While there is a parent ID, add the parent term link to the $parents array. */
  2095. while ( $parent_id ) {
  2096. /* Get the parent term. */
  2097. $parent = get_term( $parent_id, $taxonomy );
  2098. /* Add the formatted term link to the array of parent terms. */
  2099. $parents[] = '<a href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a>';
  2100. /* Set the parent term's parent as the parent ID. */
  2101. $parent_id = $parent->parent;
  2102. }
  2103. /* If we have parent terms, reverse the array to put them in the proper order for the trail. */
  2104. if ( !empty( $parents ) )
  2105. $trail = array_reverse( $parents );
  2106. /* Return the trail of parent terms. */
  2107. return $trail;
  2108. } // End woo_breadcrumbs_get_term_parents()
  2109. /*-----------------------------------------------------------------------------------*/
  2110. /* WordPress Admin Bar-related */
  2111. /*-----------------------------------------------------------------------------------*/
  2112. /*-----------------------------------------------------------------------------------*/
  2113. /* Disable WordPress Admin Bar */
  2114. /*-----------------------------------------------------------------------------------*/
  2115. $woo_admin_bar_disable = get_option( 'framework_woo_admin_bar_disable' );
  2116. if ( $woo_admin_bar_disable == 'true' ) {
  2117. add_filter( 'show_admin_bar', '__return_false' );
  2118. add_action( 'admin_print_scripts-profile.php', 'woo_hide_admin_bar_prefs' );
  2119. function woo_hide_admin_bar_prefs () { ?>
  2120. <style type="text/css">
  2121. .show-admin-bar { display: none; }
  2122. </style>
  2123. <?php
  2124. } // End woo_hide_admin_bar_prefs()
  2125. }
  2126. /*-----------------------------------------------------------------------------------*/
  2127. /* Enhancements to the WordPress Admin Bar */
  2128. /*-----------------------------------------------------------------------------------*/
  2129. if ( $woo_admin_bar_disable != 'true' && is_user_logged_in() && current_user_can( 'manage_options' ) ) {
  2130. $woo_admin_bar_enhancements = get_option( 'framework_woo_admin_bar_enhancements' );
  2131. if ( $woo_admin_bar_enhancements == 'true' ) {
  2132. add_action( 'admin_bar_menu', 'woo_admin_bar_menu', 20 );
  2133. }
  2134. } // End IF Statement
  2135. /*-----------------------------------------------------------------------------------*/
  2136. /* woo_admin_bar_menu() - Add menu items to the admin bar. */
  2137. /*-----------------------------------------------------------------------------------*/
  2138. function woo_admin_bar_menu () {
  2139. global $wp_admin_bar, $current_user;
  2140. $current_user_id = $current_user->user_login;
  2141. $super_user = get_option( 'framework_woo_super_user' );
  2142. $theme_data = wooframework_get_theme_version_data();
  2143. $menu_label = __( 'WooThemes', 'woothemes' );
  2144. // Customise menu label to the child theme's name.
  2145. if ( is_array( $theme_data ) && array_key_exists( 'theme_name', $theme_data ) ) {
  2146. $menu_label = $theme_data['theme_name'];
  2147. }
  2148. // Main WooThemes Menu Item
  2149. $wp_admin_bar->add_menu( array( 'id' => 'woothemes', 'title' => $menu_label, 'href' => admin_url('admin.php?page=woothemes') ) );
  2150. // Theme Options
  2151. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes', 'id' => 'woothemes-theme-options', 'title' => __( 'Theme Options', 'woothemes' ), 'href' => admin_url( 'admin.php?page=woothemes' ) ) );
  2152. if ( ( $super_user == $current_user_id ) || empty( $super_user ) ) {
  2153. $wp_admin_bar->add_group( array( 'parent' => 'woothemes', 'id' => 'woothemes-super-user', 'meta' => array( 'class' => 'ab-sub-secondary' ) ) );
  2154. // Framework Settings
  2155. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes-super-user', 'id' => 'woothemes-framework-settings', 'title' => __( 'Framework Settings', 'woothemes' ), 'href' => admin_url( 'admin.php?page=woothemes_framework_settings' ) ) );
  2156. // Update Framework
  2157. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes-super-user', 'id' => 'woothemes-update-framework', 'title' => __( 'Update Framework', 'woothemes' ), 'href' => admin_url( 'admin.php?page=woothemes_framework_update' ) ) );
  2158. // Theme Version Data Display
  2159. if ( true == $theme_data['is_child'] ) {
  2160. $child_theme_name = sprintf( __( 'Child Theme: %s %s', 'woothemes' ), $theme_data['child_theme_name'], $theme_data['child_theme_version'] );
  2161. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes-super-user', 'id' => 'woothemes-child-theme-version-data', 'title' => $child_theme_name ) );
  2162. }
  2163. $theme_name = sprintf( __( 'Theme: %s %s', 'woothemes' ), $theme_data['theme_name'], $theme_data['theme_version'] );
  2164. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes-super-user', 'id' => 'woothemes-theme-version-data', 'title' => $theme_name ) );
  2165. $framework_version = sprintf( __( 'WooFramework: %s', 'woothemes' ), $theme_data['framework_version'] );
  2166. $wp_admin_bar->add_menu( array( 'parent' => 'woothemes-super-user', 'id' => 'woothemes-framework-version-data', 'title' => $framework_version ) );
  2167. } // End IF Statement
  2168. } // End woo_admin_bar_menu()
  2169. /*-----------------------------------------------------------------------------------*/
  2170. /* woo_prepare_category_ids_from_option()
  2171. *
  2172. * Setup an array of category IDs, from a given theme option.
  2173. * Attempt to transform category slugs into ID values as well.
  2174. *
  2175. * Params: String $option
  2176. * Return: Array $cats
  2177. /*-----------------------------------------------------------------------------------*/
  2178. if ( ! function_exists( 'woo_prepare_category_ids_from_option' ) ) {
  2179. function woo_prepare_category_ids_from_option ( $option ) {
  2180. $cats = array();
  2181. $stored_cats = get_option( $option );
  2182. $cats_raw = explode( ',', $stored_cats );
  2183. if ( is_array( $cats_raw ) && ( count( $cats_raw ) > 0 ) ) {
  2184. foreach ( $cats_raw as $k => $v ) {
  2185. $value = trim( $v );
  2186. if ( is_numeric( $value ) ) {
  2187. $cats_raw[$k] = $value;
  2188. } else {
  2189. $cat_obj = get_category_by_slug( $value );
  2190. if ( isset( $cat_obj->term_id ) ) {
  2191. $cats_raw[$k] = $cat_obj->term_id;
  2192. }
  2193. }
  2194. $cats = $cats_raw;
  2195. }
  2196. }
  2197. return $cats;
  2198. } // End woo_prepare_category_ids_from_option()
  2199. }
  2200. /*-----------------------------------------------------------------------------------*/
  2201. /* Move tracking code from footer to header */
  2202. /*-----------------------------------------------------------------------------------*/
  2203. add_action( 'init', 'woo_move_tracking_code', 20 );
  2204. function woo_move_tracking_code () {
  2205. $move_code = get_option( 'framework_woo_move_tracking_code' );
  2206. if ( ! is_admin() && isset( $move_code ) && ( $move_code == 'true' ) ) {
  2207. remove_action( 'wp_footer', 'woo_analytics' );
  2208. add_action( 'wp_head', 'woo_analytics', 10 );
  2209. }
  2210. } // End woo_move_tracking_code()
  2211. /*-----------------------------------------------------------------------------------*/
  2212. /* woo_get_dynamic_value() */
  2213. /* Replace values in a provided array with theme options, if available. */
  2214. /*
  2215. /* $settings array should resemble: $settings = array( 'theme_option_without_woo_' => 'default_value' );
  2216. /*
  2217. /* @since 4.4.4 */
  2218. /*-----------------------------------------------------------------------------------*/
  2219. function woo_get_dynamic_values ( $settings ) {
  2220. global $woo_options;
  2221. if ( is_array( $woo_options ) ) {
  2222. foreach ( $settings as $k => $v ) {
  2223. if ( isset( $woo_options['woo_' . $k] ) && ( $woo_options['woo_' . $k] != '' ) ) { $settings[$k] = $woo_options['woo_' . $k]; }
  2224. }
  2225. }
  2226. return $settings;
  2227. } // End woo_get_dynamic_values()
  2228. /*-----------------------------------------------------------------------------------*/
  2229. /* woo_get_posts_by_taxonomy()
  2230. /*
  2231. /* Selects posts based on specified taxonomies.
  2232. /*
  2233. /* @since 4.5.0
  2234. /* @param array $args
  2235. /* @return array $posts
  2236. /*-----------------------------------------------------------------------------------*/
  2237. function woo_get_posts_by_taxonomy ( $args = null ) {
  2238. global $wp_query;
  2239. $posts = array();
  2240. /* Parse arguments, and declare individual variables for each. */
  2241. $defaults = array(
  2242. 'limit' => 5,
  2243. 'post_type' => 'any',
  2244. 'taxonomies' => 'post_tag, category',
  2245. 'specific_terms' => '',
  2246. 'relationship' => 'OR',
  2247. 'order' => 'DESC',
  2248. 'orderby' => 'date',
  2249. 'operator' => 'IN',
  2250. 'exclude' => ''
  2251. );
  2252. $args = wp_parse_args( $args, $defaults );
  2253. extract( $args, EXTR_SKIP );
  2254. // Make sure the order value is safe.
  2255. if ( ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { $order = $defaults['order']; }
  2256. // Make sure the orderby value is safe.
  2257. if ( ! in_array( $orderby, array( 'none', 'id', 'author', 'title', 'date', 'modified', 'parent', 'rand', 'comment_count', 'menu_order' ) ) ) { $orderby = $defaults['orderby']; }
  2258. // Make sure the operator value is safe.
  2259. if ( ! in_array( $operator, array( 'IN', 'NOT IN', 'AND' ) ) ) { $orderby = $defaults['operator']; }
  2260. // Convert our post types to an array.
  2261. if ( ! is_array( $post_type ) ) { $post_type = explode( ',', $post_type ); }
  2262. // Convert our taxonomies to an array.
  2263. if ( ! is_array( $taxonomies ) ) { $taxonomies = explode( ',', $taxonomies ); }
  2264. // Convert exclude to an array.
  2265. if ( ! is_array( $exclude ) && ( $exclude != '' ) ) { $exclude = explode( ',', $exclude ); }
  2266. if ( ! count( (array)$taxonomies ) ) { return; }
  2267. // Clean up our taxonomies for use in the query.
  2268. if ( count( $taxonomies ) ) {
  2269. foreach ( $taxonomies as $k => $v ) {
  2270. $taxonomies[$k] = trim( $v );
  2271. }
  2272. }
  2273. // Determine which terms we're going to relate to this entry.
  2274. $related_terms = array();
  2275. foreach ( $taxonomies as $t ) {
  2276. $terms = get_terms( $t, 'orderby=id&hide_empty=1' );
  2277. if ( ! empty( $terms ) ) {
  2278. foreach ( $terms as $k => $v ) {
  2279. $related_terms[$t][$v->term_id] = $v->slug;
  2280. }
  2281. }
  2282. }
  2283. // If specific terms are available, use those.
  2284. if ( ! is_array( $specific_terms ) ) { $specific_terms = explode( ',', $specific_terms ); }
  2285. if ( count( $specific_terms ) ) {
  2286. foreach ( $specific_terms as $k => $v ) {
  2287. $specific_terms[$k] = trim( $v );
  2288. }
  2289. }
  2290. // Look for posts with the same terms.
  2291. // Setup query arguments.
  2292. $query_args = array();
  2293. if ( $post_type ) { $query_args['post_type'] = $post_type; }
  2294. if ( $limit ) {
  2295. $query_args['posts_per_page'] = $limit;
  2296. // $query_args['nopaging'] = true;
  2297. }
  2298. // Setup specific posts to exclude.
  2299. if ( count( $exclude ) > 0 ) {
  2300. $query_args['post__not_in'] = $exclude;
  2301. }
  2302. $query_args['order'] = $order;
  2303. $query_args['orderby'] = $orderby;
  2304. $query_args['tax_query'] = array();
  2305. // Setup for multiple taxonomies.
  2306. if ( count( $related_terms ) > 1 ) {
  2307. $query_args['tax_query']['relation'] = $args['relationship'];
  2308. }
  2309. // Add the taxonomies to the query arguments.
  2310. foreach ( (array)$related_terms as $k => $v ) {
  2311. $terms_for_search = array_values( $v );
  2312. if ( count( $specific_terms ) ) {
  2313. $specific_terms_by_tax = array();
  2314. foreach ( $specific_terms as $i => $j ) {
  2315. if ( in_array( $j, array_values( $v ) ) ) {
  2316. $specific_terms_by_tax[] = $j;
  2317. }
  2318. }
  2319. if ( count( $specific_terms_by_tax ) ) {
  2320. $terms_for_search = $specific_terms_by_tax;
  2321. }
  2322. }
  2323. $query_args['tax_query'][] = array(
  2324. 'taxonomy' => $k,
  2325. 'field' => 'slug',
  2326. 'terms' => $terms_for_search,
  2327. 'operator' => $operator
  2328. );
  2329. }
  2330. if ( empty( $query_args['tax_query'] ) ) { return; }
  2331. $query_saved = $wp_query;
  2332. $query = new WP_Query( $query_args );
  2333. if ( $query->have_posts() ) {
  2334. while( $query->have_posts() ) {
  2335. $query->the_post();
  2336. $posts[] = $query->post;
  2337. }
  2338. }
  2339. $query = $query_saved;
  2340. wp_reset_query();
  2341. return $posts;
  2342. } // End woo_get_posts_by_taxonomy()
  2343. /*-----------------------------------------------------------------------------------*/
  2344. /* If the user has specified a "posts page", load the "Blog" page template there */
  2345. /*-----------------------------------------------------------------------------------*/
  2346. add_filter( 'template_include', 'woo_load_posts_page_blog_template', 10 );
  2347. if ( ! function_exists( 'woo_load_posts_page_blog_template' ) ) {
  2348. function woo_load_posts_page_blog_template ( $template ) {
  2349. if ( 'page' == get_option( 'show_on_front' ) && ( '' != get_option( 'page_for_posts' ) ) && is_home() ) {
  2350. $tpl = locate_template( array( 'template-blog.php' ) );
  2351. if ( $tpl != '' ) { $template = $tpl; }
  2352. }
  2353. return $template;
  2354. } // End woo_load_posts_page_blog_template()
  2355. }
  2356. /*-----------------------------------------------------------------------------------*/
  2357. /* PressTrends API Integration */
  2358. /*-----------------------------------------------------------------------------------*/
  2359. /**
  2360. * woo_presstrends function.
  2361. *
  2362. * @description Send data to the PressTrends API.
  2363. * @access public
  2364. * @return void
  2365. */
  2366. if ( defined( 'WOO_PRESSTRENDS_THEMEKEY' ) ) {
  2367. if ( get_option( 'framework_woo_presstrends_enable', 'false' ) == 'true' ) {
  2368. add_action( 'admin_footer', 'woo_presstrends', 100 );
  2369. }
  2370. }
  2371. function woo_presstrends () {
  2372. if ( ! defined( 'WOO_PRESSTRENDS_THEMEKEY' ) ) { return; }
  2373. // Add your PressTrends API Keys
  2374. $api_key = 'ypvilflyjb7yyht8as1u2k0no3rxbgl2p4a9';
  2375. $auth = WOO_PRESSTRENDS_THEMEKEY;
  2376. // Check if we have cached data.
  2377. $data = get_transient( 'woo_presstrends_data' );
  2378. if ( ! $data || $data == '' ) {
  2379. global $wpdb;
  2380. // Don't edit below
  2381. $api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/';
  2382. $url = $api_base . $auth . '/api/' . $api_key . '/';
  2383. $count_posts = wp_count_posts();
  2384. $count_pages = wp_count_posts( 'page' );
  2385. $comments_count = wp_count_comments();
  2386. // Custom WooFramework way of getting theme data.
  2387. $theme_data = wooframework_get_theme_version_data();
  2388. $theme_name = $theme_data['theme_name'];
  2389. $theme_version = $theme_data['theme_version'];
  2390. $plugin_name = '&';
  2391. foreach ( get_plugins() as $plugin_info ) {
  2392. $plugin_name .= $plugin_info['Name'] . '&';
  2393. }
  2394. $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
  2395. $data = array(
  2396. 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
  2397. 'posts' => $count_posts->publish,
  2398. 'pages' => $count_pages->publish,
  2399. 'comments' => $comments_count->total_comments,
  2400. 'approved' => $comments_count->approved,
  2401. 'spam' => $comments_count->spam,
  2402. 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
  2403. 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
  2404. 'theme_version' => $theme_version,
  2405. 'theme_name' => $theme_name,
  2406. 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
  2407. 'plugins' => count( get_option( 'active_plugins' ) ),
  2408. 'plugin' => urlencode( $plugin_name ),
  2409. 'wpversion' => get_bloginfo( 'version' ),
  2410. 'api_version' => '2.4'
  2411. );
  2412. foreach ( $data as $k => $v ) {
  2413. $url .= $k . '/' . $v . '/';
  2414. }
  2415. // Perform the remote request.
  2416. $response = wp_remote_get( $url );
  2417. if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) {
  2418. // Silence is golden.
  2419. } else {
  2420. set_transient( 'woo_presstrends_data', $data, 60*60*24 );
  2421. }
  2422. }
  2423. } // End woo_presstrends()
  2424. /*-----------------------------------------------------------------------------------*/
  2425. /* THE END */
  2426. /*-----------------------------------------------------------------------------------*/
  2427. /*-----------------------------------------------------------------------------------*/
  2428. /* WooDojo Download Banner */
  2429. /*-----------------------------------------------------------------------------------*/
  2430. if ( is_admin() && current_user_can( 'install_plugins' ) && ! class_exists( 'WooDojo' ) ) {
  2431. add_action( 'wooframework_container_inside', 'wooframework_add_woodojo_banner' );
  2432. }
  2433. if ( defined( 'WOO_PRESSTRENDS_THEMEKEY' ) && is_admin() && current_user_can( 'switch_themes' ) && isset( $_GET['activated'] ) && ( $_GET['activated'] == 'true' ) ) {
  2434. add_action( 'wooframework_container_inside', 'wooframework_add_presstrends_banner' );
  2435. }
  2436. add_action( 'wp_ajax_wooframework_banner_close', 'wooframework_ajax_banner_close' );
  2437. /**
  2438. * Add a WooDojo banner on the Theme Options screen.
  2439. * @since 5.3.4
  2440. * @return void
  2441. */
  2442. function wooframework_add_woodojo_banner () {
  2443. if ( get_user_setting( 'wooframeworkhidebannerwoodojo', '0' ) == '1' ) { return; }
  2444. $close_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wooframework_banner_close&banner=woodojo' ), 'wooframework_banner_close' );
  2445. $html = '';
  2446. $html .= '<div id="woodojo-banner" class="wooframework-banner">' . "\n";
  2447. $html .= '<span class="main">' . __( 'Enhance your theme with WooDojo.', 'woothemes' ) . '</span>' . "\n";
  2448. $html .= '<span>' . __( 'WooDojo is a powerful WooThemes features suite for enhancing your website. Learn more.', 'woothemes' ) . '</span>' . "\n";
  2449. $html .= '<a class="button-primary" href="' . esc_url( 'http://woothemes.com/woodojo/' ) . '" title="' . esc_attr__( 'Get WooDojo', 'woothemes' ) . '" target="_blank">' . __( 'Get WooDojo', 'woothemes' ) . '</a>' . "\n";
  2450. $html .= '<span class="close-banner"><a href="' . $close_url . '">' . __( 'Close', 'woothemes' ) . '</a></span>' . "\n";
  2451. $html .= '</div>' . "\n";
  2452. echo $html;
  2453. } // End wooframework_add_woodojo_banner()
  2454. /**
  2455. * Add a PressTrends banner on the Theme Options screen on first activation.
  2456. * @since 5.3.4
  2457. * @return void
  2458. */
  2459. function wooframework_add_presstrends_banner () {
  2460. if ( get_user_setting( 'wooframeworkhidebannerpresstrends', '0' ) == '1' ) { return; }
  2461. $close_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wooframework_banner_close&banner=presstrends' ), 'wooframework_banner_close' );
  2462. $html = '';
  2463. $html .= '<div id="presstrends-banner" class="wooframework-banner">' . "\n";
  2464. $html .= '<span class="main">' . __( 'Enable PressTrends', 'woothemes' ) . '</span>' . "\n";
  2465. $html .= '<span class="info">' . sprintf( __( 'PressTrends is a simple usage tracker that allows us to see how our customers are using WooThemes themes - so that we can help improve them for you. %sNone%s of your personal data is sent to PressTrends.', 'woothemes' ), '<br /><strong>', '</strong>' ) . '</span>' . "\n";
  2466. $html .= '<a class="button-primary" href="' . esc_url( admin_url( 'admin.php?page=woothemes_framework_settings' ) ) . '" title="' . esc_attr__( 'Enable PressTrends', 'woothemes' ) . '">' . __( 'Enable PressTrends', 'woothemes' ) . '</a>' . "\n";
  2467. $html .= '<span class="close-banner"><a href="' . $close_url . '">' . __( 'Close', 'woothemes' ) . '</a></span>' . "\n";
  2468. $html .= '</div>' . "\n";
  2469. echo $html;
  2470. } // End wooframework_add_presstrends_banner()
  2471. /**
  2472. * wooframework_ajax_banner_close function.
  2473. *
  2474. * @access public
  2475. * @since 1.0.0
  2476. */
  2477. function wooframework_ajax_banner_close () {
  2478. if( ! current_user_can( 'install_plugins' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'woothemes' ) );
  2479. if( ! check_admin_referer( 'wooframework_banner_close' ) ) wp_die( __( 'You have taken too long. Please go back and retry.', 'woothemes' ) );
  2480. $banner = ( isset( $_GET['banner'] ) ) ? $_GET['banner'] : '';
  2481. if( ! $banner ) die;
  2482. // Run the update.
  2483. $response = set_user_setting( 'wooframeworkhidebanner' . $banner, '1' );
  2484. $sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
  2485. wp_safe_redirect( $sendback );
  2486. exit;
  2487. } // End toggle_notifications_status()
  2488. /*-----------------------------------------------------------------------------------*/
  2489. /* WooSEO Deprecation Banner */
  2490. /*-----------------------------------------------------------------------------------*/
  2491. if ( is_admin() && current_user_can( 'install_plugins' ) && isset( $_GET['page'] ) && ( $_GET['page'] == 'woothemes' || $_GET['page'] == 'woothemes_framework_settings' ) ) {
  2492. add_action( 'wooframework_container_inside', 'wooframework_add_wooseosbm_banner' );
  2493. add_action( 'wooframework_wooframeworksettings_container_inside', 'wooframework_add_wooseosbm_banner' );
  2494. }
  2495. /**
  2496. * Add a WooSEO Deprecation banner on the WooSEO Options screen.
  2497. * @since 5.4.0
  2498. * @return void
  2499. */
  2500. function wooframework_add_wooseosbm_banner () {
  2501. if ( get_user_setting( 'wooframeworkhidebannerwooseosbmremoved', '0' ) == '1' ) { return; }
  2502. $close_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wooframework_banner_close&banner=wooseosbmremoved' ), 'wooframework_banner_close' );
  2503. $html = '';
  2504. $html .= '<div id="woodeprecate-banner" class="wooframework-banner">' . "\n";
  2505. $html .= '<span class="main">' . __( 'WooSEO and Sidebar Manager have been removed from version 5.5.0 of the WooFramework.', 'woothemes' ) . '</span>' . "\n";
  2506. $html .= '<span>' . sprintf( __( 'For your SEO needs, we encourage you to use the %1$s.', 'woothemes' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/wordpress-seo/' ) . '" title="' . esc_attr__( 'Get WordPress SEO', 'woothemes' ) . '" target="_blank">' . __( 'WordPress SEO Plugin', 'woothemes' ) . '</a>' ) . '</span><span>' . __( 'If you need help moving your existing SEO data, WordPress SEO has a built-in importer to move your data over.', 'woothemes' ) . '</span>' . "\n";
  2507. $html .= '<br /><br /><span>' . sprintf( __( 'While the Sidebar Manager has been removed, we encourage you to download %1$s in our free plugin, %2$s. There is also a Sidebar Manager to WooSidebars Converter plugin, available through WooDojo.', 'woothemes' ), '<a href="' . esc_url( 'http://www.woothemes.com/woosidebars/' ) . '" title="' . esc_attr__( 'Get WooSidebars', 'woothemes' ) . '" target="_blank">' . __( 'WooSidebars', 'woothemes' ) . '</a>', '<a href="' . esc_url( 'http://www.woothemes.com/woodojo/' ) . '" title="' . esc_attr__( 'Get WooDojo', 'woothemes' ) . '" target="_blank">' . __( 'WooDojo', 'woothemes' ) . '</a>' ) . '</span>' . "\n";
  2508. $html .= '<span class="close-banner"><a href="' . $close_url . '">' . __( 'Close', 'woothemes' ) . '</a></span>' . "\n";
  2509. $html .= '</div>' . "\n";
  2510. echo $html;
  2511. } // End wooframework_add_wooseosbm_banner()
  2512. /*-----------------------------------------------------------------------------------*/
  2513. /* Timthumb Detection Banner */
  2514. /*-----------------------------------------------------------------------------------*/
  2515. if ( is_admin() && current_user_can( 'install_plugins' ) ) {
  2516. add_action( 'wooframework_wooframeworksettings_container_inside', 'wooframework_add_wootimthumb_banner' );
  2517. add_action( 'wooframework_container_inside', 'wooframework_add_wootimthumb_banner' );
  2518. }
  2519. /**
  2520. * Add a Timthumb Detection banner on all WooThemes Options screens.
  2521. * @since 5.4.0
  2522. * @return void
  2523. */
  2524. function wooframework_add_wootimthumb_banner () {
  2525. if ( get_user_setting( 'wooframeworkhidebannerwootimthumb', '0' ) == '1' ) { return; }
  2526. // Test for old timthumb scripts
  2527. $thumb_php_test = file_exists( get_template_directory() . '/thumb.php' );
  2528. $timthumb_php_test = file_exists( get_template_directory() . '/timthumb.php' );
  2529. if ( $thumb_php_test || $timthumb_php_test ) {
  2530. $theme_dir = str_replace( WP_CONTENT_DIR, '', get_template_directory() );
  2531. $close_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wooframework_banner_close&banner=wootimthumb' ), 'wooframework_banner_close' );
  2532. $html = '';
  2533. $html .= '<div id="woodeprecate-banner" class="wooframework-banner">' . "\n";
  2534. $html .= '<span class="main">' . __( 'ATTENTION: Insecure Version of Timthumb Image Resize Script Detected', 'woothemes' ) . '</span>' . "\n";
  2535. $html .= '<span>' . __( "A possible old version of the TimThumb script was detected in your theme folder. Please remove the following files from your theme as a security precaution", 'woothemes' ) . ':</span>' . "\n";
  2536. if ( $thumb_php_test ) { $html .= '<span><strong>- thumb.php</strong> ( found at ' . $theme_dir . '/thumb.php' . ' )</span>' . "\n"; }
  2537. if ( $timthumb_php_test ) { $html .= '<span><strong>- timthumb.php</strong> ( found at ' . $theme_dir . '/timthumb.php' . ' )</span>' . "\n"; }
  2538. $html .= '<span class="close-banner"><a href="' . $close_url . '">' . __( 'Close', 'woothemes' ) . '</a></span>' . "\n";
  2539. $html .= '</div>' . "\n";
  2540. echo $html;
  2541. } else {
  2542. return;
  2543. }
  2544. } // End wooframework_add_wootimthumb_banner()
  2545. /*-----------------------------------------------------------------------------------*/
  2546. /* Static Front Page Detection Banner */
  2547. /*-----------------------------------------------------------------------------------*/
  2548. if ( is_admin() && current_user_can( 'manage_options' ) && ( 0 < intval( get_option( 'page_on_front' ) ) ) ) {
  2549. add_action( 'wooframework_container_inside', 'wooframework_add_static_front_page_banner' );
  2550. }
  2551. /**
  2552. * Add a Static Front Page Detection banner on all WooThemes Options screens.
  2553. * @since 5.5.2
  2554. * @return void
  2555. */
  2556. function wooframework_add_static_front_page_banner () {
  2557. if ( get_user_setting( 'wooframeworkhidebannerstaticfrontpage', '0' ) == '1' ) { return; }
  2558. $theme_data = wooframework_get_theme_version_data();
  2559. $close_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wooframework_banner_close&banner=staticfrontpage' ), 'wooframework_banner_close' );
  2560. $html = '';
  2561. $html .= '<div id="staticfrontpage-banner" class="wooframework-banner">' . "\n";
  2562. $html .= '<span class="main">' . sprintf( __( 'You have setup a static front page in %1$sSettings > Reading%2$s. If you wish to use the %4$sHomepage%5$s theme options for %3$s, please set it to show "Your latest posts".', 'woothemes' ), '<strong><a href="' . esc_url( admin_url( 'options-reading.php' ) ) . '">', '</a></strong>', $theme_data['theme_name'], '<strong>', '</strong>' ) . '</span>' . "\n";
  2563. $html .= '<span class="close-banner"><a href="' . $close_url . '">' . __( 'Close', 'woothemes' ) . '</a></span>' . "\n";
  2564. $html .= '</div>' . "\n";
  2565. echo $html;
  2566. } // End wooframework_add_static_front_page_banner()
  2567. /**
  2568. * Get the version data for the currently active theme.
  2569. * @since 5.4.2
  2570. * @return array [theme_version, theme_name, framework_version, is_child, child_theme_version, child_theme_name]
  2571. */
  2572. if ( ! function_exists( 'wooframework_get_theme_version_data' ) ) {
  2573. function wooframework_get_theme_version_data () {
  2574. $response = array(
  2575. 'theme_version' => '',
  2576. 'theme_name' => '',
  2577. 'framework_version' => get_option( 'woo_framework_version' ),
  2578. 'is_child' => is_child_theme(),
  2579. 'child_theme_version' => '',
  2580. 'child_theme_name' => ''
  2581. );
  2582. if ( function_exists( 'wp_get_theme' ) ) {
  2583. $theme_data = wp_get_theme();
  2584. if ( true == $response['is_child'] ) {
  2585. $response['theme_version'] = $theme_data->parent()->Version;
  2586. $response['theme_name'] = $theme_data->parent()->Name;
  2587. $response['child_theme_version'] = $theme_data->Version;
  2588. $response['child_theme_name'] = $theme_data->Name;
  2589. } else {
  2590. $response['theme_version'] = $theme_data->Version;
  2591. $response['theme_name'] = $theme_data->Name;
  2592. }
  2593. } else {
  2594. $theme_data = get_theme_data( get_template_directory() . '/style.css' );
  2595. $response['theme_version'] = $theme_data['Version'];
  2596. $response['theme_name'] = $theme_data['Name'];
  2597. if ( true == $response['is_child'] ) {
  2598. $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
  2599. $response['child_theme_version'] = $theme_data['Version'];
  2600. $response['child_theme_name'] = $theme_data['Name'];
  2601. }
  2602. }
  2603. return $response;
  2604. } // End wooframework_get_theme_version_data()
  2605. }
  2606. if ( ! function_exists( 'wooframework_display_theme_version_data' ) ) {
  2607. /**
  2608. * Display the version data for the currently active theme.
  2609. * @since 5.4.2
  2610. * @return void
  2611. */
  2612. function wooframework_display_theme_version_data ( $echo = true ) {
  2613. $data = wooframework_get_theme_version_data();
  2614. $html = '';
  2615. // Theme Version
  2616. if ( true == $data['is_child'] ) {
  2617. $html .= '<span class="theme">' . esc_html( $data['child_theme_name'] . ' ' . $data['child_theme_version'] ) . '</span>' . "\n";
  2618. $html .= '<span class="parent-theme">' . esc_html( $data['theme_name'] . ' ' . $data['theme_version'] ) . '</span>' . "\n";
  2619. } else {
  2620. $html .= '<span class="theme">' . esc_html( $data['theme_name'] . ' ' . $data['theme_version'] ) . '</span>' . "\n";
  2621. }
  2622. // Framework Version
  2623. $html .= '<span class="framework">' . esc_html( sprintf( __( 'Framework %s', 'woothemes' ), $data['framework_version'] ) ) . '</span>' . "\n";
  2624. if ( true == $echo ) { echo $html; } else { return $html; }
  2625. } // End wooframework_display_theme_version_data()
  2626. }
  2627. ?>