/wp-content/themes/artificer/functions/admin-functions.php
PHP | 3186 lines | 1944 code | 541 blank | 701 comment | 547 complexity | d69f1f7171626c6b72363513bcc3511a MD5 | raw file
Possible License(s): BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- <?php
- // File Security Check
- if ( ! defined( 'ABSPATH' ) ) exit;
- ?>
- <?php
- /*-----------------------------------------------------------------------------------
-
- TABLE OF CONTENTS
-
- - woo_image - Get Image from custom field
- - vt_resize - Resize post thumbnail
- - woo_get_youtube_video_image - Get thumbnail from YouTube
- - Add default filters to woo_embed()
- - woo_get_embed - Get Video
- - Woo Show Page Menu
- - Get the style path currently selected
- - Get page ID
- - Tidy up the image source url
- - Show image in RSS feed
- - Show analytics code footer
- - Browser detection body_class() output
- - Twitter's Blogger.js output for Twitter widgets
- - Template Detector
- - Framework Updater
- - WooFramework Update Page
- - WooFramework Update Head
- - WooFramework Version Getter
- - Woo URL shortener
- - SEO - woo_title()
- - SEO - Strip slashes from the display of the website/page title
- - SEO - woo_meta()
- - Woo Text Trimmer
- - Google Webfonts array
- - Google Fonts Stylesheet Generator
- - Enable Home link in WP Menus
- - Buy Themes page
- - Detects the Charset of String and Converts it to UTF-8
- - WP Login logo
- - WP Login logo URL
- - WP Login logo title
- - woo_pagination()
- - woo_breadcrumbs()
- -- woo_breadcrumbs_get_parents()
- -- woo_breadcrumbs_get_term_parents()
- - WordPress Admin Bar-related
- -- Disable WordPress Admin Bar
- -- Enhancements to the WordPress Admin Bar
- - woo_prepare_category_ids_from_option()
- - Move tracking code from footer to header.
- - woo_get_dynamic_values()
- - woo_get_posts_by_taxonomy()
- - If the user has specified a "posts page", load the "Blog" page template there
- - PressTrends API Integration
- - WooDojo Download Banner
- - wooframework_add_woodojo_banner()
- - wooframework_ajax_banner_close()
- - WooSEO Deprecation Banner
- - wooframework_add_wooseo_banner()
- - WooSidebars Deprecation Banner
- - wooframework_add_woosbm_banner()
- - Static Front Page Detection Banner
- - wooframework_get_theme_version_data()
- - wooframework_display_theme_version_data()
- -----------------------------------------------------------------------------------*/
-
- /*-----------------------------------------------------------------------------------*/
- /* woo_image - Get Image from custom field */
- /*-----------------------------------------------------------------------------------*/
-
- /*
- This function retrieves/resizes the image to be used with the post in this order:
-
- 1. Image passed through parameter 'src'
- 2. WP Post Thumbnail (if option activated)
- 3. Custom field
- 4. First attached image in post (if option activated)
- 5. First inline image in post (if option activated)
-
- Resize options (enabled in options panel):
- - vt_resize() is used to natively resize #2 and #4
- - Thumb.php is used to resize #1, #3, #4 (only if vt_resize is disabled) and #5
-
- Parameters:
- $key = Custom field key eg. "image"
- $width = Set width manually without using $type
- $height = Set height manually without using $type
- $class = CSS class to use on the img tag eg. "alignleft". Default is "thumbnail"
- $quality = Enter a quality between 80-100. Default is 90
- $id = Assign a custom ID, if alternative is required.
- $link = Echo with anchor ( 'src'), without anchor ( 'img') or original image URL ( 'url').
- $repeat = Auto Img Function. Adjust amount of images to return for the post attachments.
- $offset = Auto Img Function. Offset the $repeat with assigned amount of objects.
- $before = Auto Img Function. Add Syntax before image output.
- $after = Auto Img Function. Add Syntax after image output.
- $single = (true/false) Force thumbnail to link to the post instead of the image.
- $force = Force smaller images to not be effected with image width and height dimensions (proportions fix)
- $return = Return results instead of echoing out.
- $src = A parameter that accepts a img url for resizing. (No anchor)
- $meta = Add a custom meta text to the image and anchor of the image.
- $alignment = Crop alignment for thumb.php (l, r, t, b)
- $size = Custom pre-defined size for WP Thumbnail (string)
- $noheight = Don't output the height on img tag (for responsive designs)
- */
-
- if ( !function_exists('woo_image') ) {
- function woo_image($args) {
-
- /* ------------------------------------------------------------------------- */
- /* SET VARIABLES */
- /* ------------------------------------------------------------------------- */
-
- global $post;
- global $woo_options;
-
- //Defaults
- $key = 'image';
- $width = null;
- $height = null;
- $class = '';
- $quality = 90;
- $id = null;
- $link = 'src';
- $repeat = 1;
- $offset = 0;
- $before = '';
- $after = '';
- $single = false;
- $force = false;
- $return = false;
- $is_auto_image = false;
- $src = '';
- $meta = '';
- $alignment = '';
- $size = '';
- $noheight = '';
-
- $alt = '';
- $img_link = '';
-
- $attachment_id = array();
- $attachment_src = array();
-
- if ( ! is_array( $args ) )
- parse_str( $args, $args );
-
- extract( $args );
-
- // Set post ID
- if ( empty( $id ) ) {
- $id = $post->ID;
- }
-
- $thumb_id = esc_html( get_post_meta( $id, '_thumbnail_id', true ) );
-
- // Set alignment
- if ( $alignment == '' )
- $alignment = esc_html( get_post_meta( $id, '_image_alignment', true ) );
-
- // Get standard sizes
- if ( ! $width && ! $height ) {
- $width = '100';
- $height = '100';
- }
-
- // Cast $width and $height to integer
- $width = intval( $width );
- $height = intval( $height );
-
- /* ------------------------------------------------------------------------- */
- /* FIND IMAGE TO USE */
- /* ------------------------------------------------------------------------- */
-
- // When a custom image is sent through
- if ( $src != '' ) {
- $custom_field = esc_url( $src );
- $link = 'img';
-
- // WP 2.9 Post Thumbnail support
- } elseif ( get_option( 'woo_post_image_support' ) == 'true' && ! empty( $thumb_id ) ) {
-
- if ( get_option( 'woo_pis_resize' ) == 'true' ) {
-
- if ( 0 == $height ) {
- $img_data = wp_get_attachment_image_src( $thumb_id, array( intval( $width ), 9999 ) );
- $height = $img_data[2];
- }
-
- // Dynamically resize the post thumbnail
- $vt_crop = get_option( 'woo_pis_hard_crop' );
- if ($vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
- $vt_image = vt_resize( $thumb_id, '', $width, $height, $vt_crop );
-
- // Set fields for output
- $custom_field = esc_url( $vt_image['url'] );
- $width = $vt_image['width'];
- $height = $vt_image['height'];
-
- } else {
- // Use predefined size string
- if ( $size )
- $thumb_size = $size;
- else
- $thumb_size = array( $width, $height );
-
- $img_link = get_the_post_thumbnail( $id, $thumb_size, array( 'class' => 'woo-image ' . esc_attr( $class ) ) );
- }
-
- // Grab the image from custom field
- } else {
- $custom_field = esc_url( get_post_meta( $id, $key, true ) );
- }
-
- // Automatic Image Thumbs - get first image from post attachment
- if ( empty( $custom_field ) && get_option( 'woo_auto_img' ) == 'true' && empty( $img_link ) && ! ( is_singular() && in_the_loop() && $link == 'src' ) ) {
-
- if( $offset >= 1 )
- $repeat = $repeat + $offset;
-
- $attachments = get_children( array( 'post_parent' => $id,
- 'numberposts' => $repeat,
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'order' => 'DESC',
- 'orderby' => 'menu_order date')
- );
-
- // Search for and get the post attachment
- if ( ! empty( $attachments ) ) {
- $counter = -1;
- foreach ( $attachments as $att_id => $attachment ) {
- $counter++;
- if ( $counter < $offset )
- continue;
-
- if ( get_option( 'woo_post_image_support' ) == 'true' && get_option( 'woo_pis_resize' ) == 'true' ) {
- // Dynamically resize the post thumbnail
- $vt_crop = get_option( 'woo_pis_hard_crop' );
- if ( $vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
- $vt_image = vt_resize( $att_id, '', $width, $height, $vt_crop );
-
- // Set fields for output
- $custom_field = esc_url( $vt_image['url'] );
- $width = $vt_image['width'];
- $height = $vt_image['height'];
- } else {
- $src = wp_get_attachment_image_src( $att_id, 'large', true );
- $custom_field = esc_url( $src[0] );
- $attachment_id[] = $att_id;
- $src_arr[] = $custom_field;
- }
- $thumb_id = $att_id;
- $is_auto_image = true;
- }
-
- // Get the first img tag from content
- } else {
-
- $first_img = '';
- $post = get_post( $id );
- ob_start();
- ob_end_clean();
- $output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
- if ( !empty($matches[1][0]) ) {
-
- // Save Image URL
- $custom_field = esc_url( $matches[1][0] );
-
- // Search for ALT tag
- $output = preg_match_all( '/<img.+alt=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches );
- if ( !empty($matches[1][0]) ) {
- $alt = esc_attr( $matches[1][0] );
- }
- }
-
- }
-
- }
-
- // Check if there is YouTube embed
- if ( empty( $custom_field ) && empty( $img_link ) ) {
- $embed = esc_html( get_post_meta( $id, 'embed', true ) );
- if ( $embed )
- $custom_field = esc_url( woo_get_video_image( $embed ) );
- }
-
- // Return if there is no attachment or custom field set
- if ( empty( $custom_field ) && empty( $img_link ) ) {
-
- // Check if default placeholder image is uploaded
- $placeholder = get_option( 'framework_woo_default_image' );
- if ( $placeholder && !(is_singular() && in_the_loop()) ) {
- $custom_field = esc_url( $placeholder );
-
- // Resize the placeholder if
- if ( get_option( 'woo_post_image_support' ) == 'true' && get_option( 'woo_pis_resize' ) == 'true' ) {
- // Dynamically resize the post thumbnail
- $vt_crop = get_option( 'woo_pis_hard_crop' );
- if ($vt_crop == 'true' ) $vt_crop = true; else $vt_crop = false;
- $vt_image = vt_resize( '', $placeholder, $width, $height, $vt_crop );
-
- // Set fields for output
- $custom_field = esc_url( $vt_image['url'] );
- $width = $vt_image['width'];
- $height = $vt_image['height'];
- }
- } else {
- return;
- }
- }
-
- if(empty( $src_arr ) && empty( $img_link ) ) { $src_arr[] = $custom_field; }
-
- /* ------------------------------------------------------------------------- */
- /* BEGIN OUTPUT */
- /* ------------------------------------------------------------------------- */
-
- $output = '';
-
- // Set output height and width
- $set_width = ' width="' . esc_attr( $width ) . '" ';
- $set_height = '';
-
- if ( ! $noheight && 0 < $height )
- $set_height = ' height="' . esc_attr( $height ) . '" ';
-
- // Set standard class
- if ( $class ) $class = 'woo-image ' . esc_attr( $class ); else $class = 'woo-image';
-
- // Do check to verify if images are smaller then specified.
- if($force == true){ $set_width = ''; $set_height = ''; }
-
- // WP Post Thumbnail
- if( ! empty( $img_link ) ) {
-
- if( $link == 'img' ) { // Output the image without anchors
- $output .= wp_kses_post( $before );
- $output .= $img_link;
- $output .= wp_kses_post( $after );
- } elseif( $link == 'url' ) { // Output the large image
- $src = wp_get_attachment_image_src( $thumb_id, 'large', true );
- $custom_field = esc_url( $src[0] );
- $output .= $custom_field;
- } else { // Default - output with link
- if ( ( is_single() || is_page() ) && $single == false ) {
- $rel = 'rel="lightbox"';
- $href = false;
- } else {
- $href = get_permalink( $id );
- $rel = '';
- }
-
- $title = 'title="' . esc_attr( get_the_title( $id ) ) .'"';
-
- $output .= wp_kses_post( $before );
- if($href == false){
- $output .= $img_link;
- } else {
- $output .= '<a ' . $title . ' href="' . esc_url( $href ) . '" '. $rel .'>' . $img_link . '</a>';
- }
-
- $output .= wp_kses_post( $after );
- }
- }
-
- // Use thumb.php to resize. Skip if image has been natively resized with vt_resize.
- elseif ( get_option( 'woo_resize') == 'true' && empty( $vt_image['url'] ) ) {
-
- foreach( $src_arr as $key => $custom_field ) {
-
- // Clean the image URL
- $href = esc_url( $custom_field );
- $custom_field = cleanSource( $custom_field );
-
- // Check if WPMU and set correct path AND that image isn't external
- if ( function_exists( 'get_current_site') ) {
- get_current_site();
- //global $blog_id; Breaks with WP3 MS
- if ( !$blog_id ) {
- global $current_blog;
- $blog_id = $current_blog->blog_id;
- }
- if ( isset($blog_id) && $blog_id > 0 ) {
- $imageParts = explode( 'files/', $custom_field );
- if ( isset( $imageParts[1] ) )
- $custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
- }
- }
-
- //Set the ID to the Attachment's ID if it is an attachment
- if($is_auto_image == true){
- $quick_id = $attachment_id[$key];
- } else {
- $quick_id = $id;
- }
-
- //Set custom meta
- if ($meta) {
- $alt = $meta;
- $title = 'title="' . esc_attr( $meta ) . '"';
- } else {
- if ( ( $alt != '' ) || ! ( $alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) ) ) {
- $alt = esc_attr( get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) );
- } else {
- $alt = esc_attr( get_the_title( $quick_id ) );
- }
- $title = 'title="'. esc_attr( get_the_title( $quick_id ) ) .'"';
- }
-
- // Set alignment parameter
- if ( $alignment != '' )
- $alignment = '&a=' . urlencode( $alignment );
-
- $img_url = esc_url( get_template_directory_uri() . '/functions/thumb.php?src=' . $custom_field . '&w=' . $width . '&h=' . $height . '&zc=1&q=' . $quality . $alignment );
- $img_link = '<img src="' . $img_url . '" alt="' . esc_attr( $alt ) . '" class="' . esc_attr( stripslashes( $class ) ) . '" ' . $set_width . $set_height . ' />';
-
- if( $link == 'img' ) { // Just output the image
- $output .= wp_kses_post( $before );
- $output .= $img_link;
- $output .= wp_kses_post( $after );
-
- } elseif( $link == 'url' ) { // Output the image without anchors
-
- if($is_auto_image == true){
- $src = wp_get_attachment_image_src($thumb_id, 'large', true);
- $custom_field = esc_url( $src[0] );
- }
- $output .= $href;
-
- } else { // Default - output with link
-
- if ( ( is_single() || is_page() ) && $single == false ) {
- $rel = 'rel="lightbox"';
- } else {
- $href = get_permalink( $id );
- $rel = '';
- }
-
- $output .= wp_kses_post( $before );
- $output .= '<a ' . $title . ' href="' . esc_url( $href ) . '" ' . $rel . '>' . $img_link . '</a>';
- $output .= wp_kses_post( $after );
- }
- }
-
- // No dynamic resizing
- } else {
- foreach( $src_arr as $key => $custom_field ) {
-
- //Set the ID to the Attachment's ID if it is an attachment
- if( $is_auto_image == true && isset( $attachment_id[$key] ) ){
- $quick_id = $attachment_id[$key];
- } else {
- $quick_id = $id;
- }
-
- //Set custom meta
- if ($meta) {
- $alt = esc_attr( $meta );
- $title = 'title="'. esc_attr( $meta ) .'"';
- } else {
- if ($alt == '') $alt = esc_attr( get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ) );
- $title = 'title="'. esc_attr( get_the_title( $quick_id ) ) .'"';
- }
-
- $img_link = '<img src="'. esc_url( $custom_field ) . '" alt="' . esc_attr( $alt ) . '" ' . $set_width . $set_height . ' class="' . esc_attr( stripslashes( $class ) ) . '" />';
-
- if ( $link == 'img' ) { // Just output the image
- $output .= wp_kses_post( $before );
- $output .= $img_link;
- $output .= wp_kses_post( $after );
-
- } elseif( $link == 'url' ) { // Output the URL to original image
- if ( $vt_image['url'] || $is_auto_image ) {
- $src = wp_get_attachment_image_src( $thumb_id, 'full', true );
- $custom_field = esc_url( $src[0] );
- }
- $output .= $custom_field;
-
- } else { // Default - output with link
-
- if ( ( is_single() || is_page() ) && $single == false ) {
-
- // Link to the large image if single post
- if ( $vt_image['url'] || $is_auto_image ) {
- $src = wp_get_attachment_image_src( $thumb_id, 'full', true );
- $custom_field = esc_url( $src[0] );
- }
-
- $href = $custom_field;
- $rel = 'rel="lightbox"';
- } else {
- $href = get_permalink( $id );
- $rel = '';
- }
-
- $output .= wp_kses_post( $before );
- $output .= '<a href="' . esc_url( $href ) . '" ' . $rel . ' ' . $title . '>' . $img_link . '</a>';
- $output .= wp_kses_post( $after );
- }
- }
- }
-
- // Remove no height attribute - IE fix when no height is set
- $output = str_replace( 'height=""', '', $output );
- $output = str_replace( 'height="0"', '', $output );
-
- // Return or echo the output
- if ( $return == TRUE )
- return $output;
- else
- echo $output; // Done
-
- }
- }
-
- /* Get thumbnail from Video Embed code */
- if ( ! function_exists( 'woo_get_video_image' ) ) {
- function woo_get_video_image( $embed ) {
- $video_thumb = '';
-
- // YouTube - get the video code if this is an embed code (old embed)
- preg_match( '/youtube\.com\/v\/([\w\-]+)/', $embed, $match );
-
- // YouTube - if old embed returned an empty ID, try capuring the ID from the new iframe embed
- if( ! isset( $match[1] ) )
- preg_match( '/youtube\.com\/embed\/([\w\-]+)/', $embed, $match );
-
- // YouTube - if it is not an embed code, get the video code from the youtube URL
- if( ! isset( $match[1] ) )
- preg_match( '/v\=(.+)&/', $embed, $match );
-
- // YouTube - get the corresponding thumbnail images
- if( isset( $match[1] ) )
- $video_thumb = "http://img.youtube.com/vi/" . urlencode( $match[1] ) . "/0.jpg";
-
- // return whichever thumbnail image you would like to retrieve
- return $video_thumb;
- } // End woo_get_video_image()
- }
-
-
- /*-----------------------------------------------------------------------------------*/
- /* vt_resize - Resize images dynamically using wp built in functions
- /*-----------------------------------------------------------------------------------*/
- /*
- * Resize images dynamically using wp built in functions
- * Victor Teixeira
- *
- * php 5.2+
- *
- * Exemplo de uso:
- *
- * <?php
- * $thumb = get_post_thumbnail_id();
- * $image = vt_resize( $thumb, '', 140, 110, true );
- * ?>
- * <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" />
- *
- * @param int $attach_id
- * @param string $img_url
- * @param int $width
- * @param int $height
- * @param bool $crop
- * @return array
- */
- if ( ! function_exists( 'vt_resize' ) ) {
- function vt_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
-
- // Cast $width and $height to integer
- $width = intval( $width );
- $height = intval( $height );
-
- // this is an attachment, so we have the ID
- if ( $attach_id ) {
- $image_src = wp_get_attachment_image_src( $attach_id, 'full' );
- $file_path = get_attached_file( $attach_id );
- // this is not an attachment, let's use the image url
- } else if ( $img_url ) {
- $file_path = parse_url( esc_url( $img_url ) );
- $file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
-
- //$file_path = ltrim( $file_path['path'], '/' );
- //$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
-
- $orig_size = getimagesize( $file_path );
-
- $image_src[0] = $img_url;
- $image_src[1] = $orig_size[0];
- $image_src[2] = $orig_size[1];
- }
-
- $file_info = pathinfo( $file_path );
-
- // check if file exists
- if ( !isset( $file_info['dirname'] ) && !isset( $file_info['filename'] ) && !isset( $file_info['extension'] ) )
- return;
-
- $base_file = $file_info['dirname'].'/'.$file_info['filename'].'.'.$file_info['extension'];
- if ( !file_exists($base_file) )
- return;
-
- $extension = '.'. $file_info['extension'];
-
- // the image path without the extension
- $no_ext_path = $file_info['dirname'].'/'.$file_info['filename'];
-
- $cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
-
- // checking if the file size is larger than the target size
- // if it is smaller or the same size, stop right here and return
- if ( $image_src[1] > $width ) {
- // 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)
- if ( file_exists( $cropped_img_path ) ) {
- $cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
-
- $vt_image = array (
- 'url' => $cropped_img_url,
- 'width' => $width,
- 'height' => $height
- );
- return $vt_image;
- }
-
- // $crop = false or no height set
- if ( $crop == false OR !$height ) {
- // calculate the size proportionaly
- $proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
- $resized_img_path = $no_ext_path.'-'.$proportional_size[0].'x'.$proportional_size[1].$extension;
-
- // checking if the file already exists
- if ( file_exists( $resized_img_path ) ) {
- $resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
-
- $vt_image = array (
- 'url' => $resized_img_url,
- 'width' => $proportional_size[0],
- 'height' => $proportional_size[1]
- );
- return $vt_image;
- }
- }
-
- // check if image width is smaller than set width
- $img_size = getimagesize( $file_path );
- if ( $img_size[0] <= $width ) $width = $img_size[0];
-
- // Check if GD Library installed
- if ( ! function_exists ( 'imagecreatetruecolor' ) ) {
- echo 'GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library';
- return;
- }
-
- // no cache files - let's finally resize it
- if ( function_exists( 'wp_get_image_editor' ) ) {
- $image = wp_get_image_editor( $file_path );
- if ( ! is_wp_error( $image ) ) {
- $image->resize( $width, $height, $crop );
- $save_data = $image->save();
- if ( isset( $save_data['path'] ) ) $new_img_path = $save_data['path'];
- }
- } else {
- $new_img_path = image_resize( $file_path, $width, $height, $crop );
- }
-
- $new_img_size = getimagesize( $new_img_path );
- $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
-
- // resized output
- $vt_image = array (
- 'url' => $new_img,
- 'width' => $new_img_size[0],
- 'height' => $new_img_size[1]
- );
-
- return $vt_image;
- }
-
- // default output - without resizing
- $vt_image = array (
- 'url' => $image_src[0],
- 'width' => $width,
- 'height' => $height
- );
-
- return $vt_image;
- }
- }
-
- /*-----------------------------------------------------------------------------------*/
- /* Depreciated - woo_get_image - Get Image from custom field */
- /*-----------------------------------------------------------------------------------*/
-
- // Depreciated
- 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) {
- // Run new function
- 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 );
- return;
- } // End woo_get_image()
-
- /*-----------------------------------------------------------------------------------*/
- /* woo_embed - Get Video embed code from custom field */
- /*-----------------------------------------------------------------------------------*/
-
- /*
- Get Video
- This function gets the embed code from the custom field
- Parameters:
- $key = Custom field key eg. "embed"
- $width = Set width manually without using $type
- $height = Set height manually without using $type
- $class = Custom class to apply to wrapping div
- $id = ID from post to pull custom field from
- */
-
- if ( ! function_exists( 'woo_embed' ) ) {
- function woo_embed($args) {
- //Defaults
- $key = 'embed';
- $width = null;
- $height = null;
- $class = 'video';
- $id = null;
-
- if ( ! is_array( $args ) )
- parse_str( $args, $args );
-
- extract( $args );
-
- if( empty( $id ) ) {
- global $post;
- $id = $post->ID;
- }
-
- // Cast $width and $height to integer
- $width = intval( $width );
- $height = intval( $height );
-
- $custom_field = esc_textarea( get_post_meta( $id, $key, true ) );
-
- if ($custom_field) :
- $custom_field = html_entity_decode( $custom_field ); // Decode HTML entities.
-
- $org_width = $width;
- $org_height = $height;
- $calculated_height = '';
- $embed_width = '';
- $embed_height = '';
-
- // Get custom width and height
- $custom_width = esc_html( get_post_meta( $id, 'width', true ) );
- $custom_height = esc_html( get_post_meta( $id, 'height', true ) );
-
- //Dynamic Height Calculation
- if ($org_height == '' && $org_width != '') {
- $raw_values = explode( ' ', $custom_field);
-
- foreach ( $raw_values as $raw ) {
- $embed_params = explode( '=', $raw );
- if ( $embed_params[0] == 'width' ) {
- $embed_width = preg_replace( '/[^0-9]/', '', $embed_params[1]);
- }
- elseif ( $embed_params[0] == 'height' ) {
- $embed_height = preg_replace( '/[^0-9]/', '', $embed_params[1]);
- }
- }
-
- $float_width = floatval( $embed_width );
- $float_height = floatval( $embed_height );
- @$float_ratio = $float_height / $float_width;
- $calculated_height = intval( $float_ratio * $width );
- }
-
- // Set values: width="XXX", height="XXX"
- if ( ! $custom_width ) $width = 'width="' . esc_attr( $width ) . '"'; else $width = 'width="' . esc_attr( $custom_width ) . '"';
- if ( $height == '' ) { $height = 'height="' . esc_attr( $calculated_height ) . '"'; } else { if ( ! $custom_height ) { $height = 'height="' . esc_attr( $height ) . '"'; } else { $height = 'height="' . esc_attr( $custom_height ) . '"'; } }
- $custom_field = stripslashes($custom_field);
- $custom_field = preg_replace( '/width="([0-9]*)"/' , $width , $custom_field );
- $custom_field = preg_replace( '/height="([0-9]*)"/' , $height, $custom_field );
-
- // Set values: width:XXXpx, height:XXXpx
- if ( ! $custom_width ) $width = 'width:' . esc_attr( $org_width ) . 'px'; else $width = 'width:' . esc_attr( $custom_width ) . 'px';
- 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'; } }
- $custom_field = stripslashes($custom_field);
- $custom_field = preg_replace( '/width:([0-9]*)px/' , $width , $custom_field );
- $custom_field = preg_replace( '/height:([0-9]*)px/' , $height, $custom_field );
-
- // Suckerfish menu hack
- $custom_field = str_replace( '<embed ', '<param name="wmode" value="transparent"></param><embed wmode="transparent" ', $custom_field );
- $custom_field = str_replace( '<iframe ', '<iframe wmode="transparent" ', $custom_field );
- $custom_field = str_replace( '" frameborder="', '?wmode=transparent" frameborder="', $custom_field );
-
- // Find and sanitize video URL. Add "wmode=transparent" to URL.
- $video_url = preg_match( '/src=["\']?([^"\' ]*)["\' ]/is', $custom_field, $matches );
- if ( isset( $matches[1] ) ) {
- $custom_field = str_replace( $matches[0], 'src="' . esc_url( add_query_arg( 'wmode', 'transparent', $matches[1] ) ) . '"', $custom_field );
- }
-
- $output = '';
- $output .= '<div class="'. esc_attr( $class ) .'">' . $custom_field . '</div>';
-
- return apply_filters( 'woo_embed', $output );
- else :
- return false;
- endif;
- }
- }
-
- /*-----------------------------------------------------------------------------------*/
- /* Add default filters to woo_embed() */
- /*-----------------------------------------------------------------------------------*/
-
- add_filter( 'woo_embed', 'do_shortcode' );
-
- /*-----------------------------------------------------------------------------------*/
- /* Depreciated - woo_get_embed - Get Video embed code from custom field */
- /*-----------------------------------------------------------------------------------*/
- // Depreciated
- function woo_get_embed($key = 'embed', $width, $height, $class = 'video', $id = null) {
- // Run new function
- return woo_embed( 'key='.$key.'&width='.$width.'&height='.$height.'&class='.$class.'&id='.$id );
-
- }
-
- /*-----------------------------------------------------------------------------------*/
- /* Woo Show Page Menu */
- /*-----------------------------------------------------------------------------------*/
- // Show menu in header.php
- // Exlude the pages from the slider
- function woo_show_pagemenu( $exclude = '' ) {
- // Split the featured pages from the options, and put in an array
- if ( get_option( 'woo_ex_featpages') ) {
- $menupages = get_option( 'woo_featpages' );
- $exclude = $menupages . ',' . $exclude;
- }
-
- $pages = wp_list_pages( 'sort_column=menu_order&title_li=&echo=0&depth=1&exclude=' . $exclude );
- $pages = preg_replace( '%<a ([^>]+)>%U','<a $1><span>', $pages );
- $pages = str_replace( '</a>','</span></a>', $pages );
- echo $pages;
- } // End woo_show_pagemenu()
-
- /*-----------------------------------------------------------------------------------*/
- /* Get the style path currently selected */
- /*-----------------------------------------------------------------------------------*/
- function woo_style_path() {
- $return = '';
-
- $style = $_REQUEST['style'];
-
- // Sanitize request input.
- $style = esc_attr( strtolower( trim( strip_tags( $style ) ) ) );
-
- if ( $style != '' ) {
- $style_path = $style;
- } else {
- $stylesheet = esc_attr( get_option( 'woo_alt_stylesheet' ) );
-
- // Prevent against an empty return to $stylesheet.
- if ( $stylesheet == '' ) {
- $stylesheet = 'default.css';
- }
-
- $style_path = str_replace( '.css', '', $stylesheet );
- }
-
- if ( $style_path == 'default' ) {
- $return = 'images';
- } else {
- $return = 'styles/' . $style_path;
- }
-
- echo esc_html( $return );
- } // End woo_style_path()
-
-
- /*-----------------------------------------------------------------------------------*/
- /* Get page ID */
- /*-----------------------------------------------------------------------------------*/
- function get_page_id( $page_slug ) {
- $page_id = get_page_by_path( $page_slug );
- if ($page_id) {
- return $page_id->ID;
- } else {
- return null;
- }
- } // End get_page_id()
-
- /*-----------------------------------------------------------------------------------*/
- /* Tidy up the image source url */
- /*-----------------------------------------------------------------------------------*/
- function cleanSource( $src ) {
- // remove slash from start of string
- if(strpos($src, "/") == 0) {
- $src = substr($src, -(strlen($src) - 1));
- }
-
- // Check if same domain so it doesn't strip external sites
- $host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
- if ( ! strpos( $src, $host ) )
- return $src;
-
-
- $regex = "/^((ht|f)tp(s|):\/\/)(www\.|)" . $host . "/i";
- $src = preg_replace ( $regex, '', $src );
- $src = htmlentities ( $src );
-
- // remove slash from start of string
- if ( strpos( $src, '/' ) === 0 ) {
- $src = substr ( $src, -( strlen( $src ) - 1 ) );
- }
-
- return $src;
- } // End cleanSource()
-
- /*-----------------------------------------------------------------------------------*/
- /* Show image in RSS feed */
- /* Original code by Justin Tadlock http://justintadlock.com */
- /*-----------------------------------------------------------------------------------*/
- if ( get_option( 'woo_rss_thumb' ) == 'true' ) {
- if ( get_option( 'rss_use_excerpt' ) )
- add_filter( 'the_excerpt_rss', 'add_image_RSS' );
- else
- add_filter( 'the_content', 'add_image_RSS' );
- }
-
- function add_image_RSS( $content ) {
-
- global $post, $id;
- $blog_key = substr( md5( home_url( '/' ) ), 0, 16 );
- if ( ! is_feed() ) return $content;
-
- // Get the "image" from custom field
- //$image = get_post_meta($post->ID, 'image', $single = true);
- $image = woo_image( 'return=true&link=url' );
- $image_width = '240';
-
- // If there's an image, display the image with the content
- if( $image != '' ) {
- $content = '<p style="float:right; margin:0 0 10px 15px; width:' . esc_attr( $image_width ) . 'px;">
- <img src="' . esc_url( $image ) . '" width="' . esc_attr( $image_width ) . '" />
- </p>' . $content;
- return $content;
- } else {
- // If there's not an image, just display the content
- $content = $content;
- return $content;
- }
- } // End add_image_RSS()
-
-
-
- /*-----------------------------------------------------------------------------------*/
- /* Show analytics code in footer */
- /*-----------------------------------------------------------------------------------*/
- function woo_analytics(){
- $output = get_option( 'woo_google_analytics' );
- if ( $output != '' )
- echo stripslashes( $output ) . "\n";
- } // End woo_analytics()
- add_action( 'wp_footer','woo_analytics' );
-
-
-
- /*-----------------------------------------------------------------------------------*/
- /* Browser detection body_class() output */
- /*-----------------------------------------------------------------------------------*/
- add_filter( 'body_class','browser_body_class' );
- function browser_body_class( $classes ) {
- global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
-
- if($is_lynx) $classes[] = 'lynx';
- elseif($is_gecko) $classes[] = 'gecko';
- elseif($is_opera) $classes[] = 'opera';
- elseif($is_NS4) $classes[] = 'ns4';
- elseif($is_safari) $classes[] = 'safari';
- elseif($is_chrome) $classes[] = 'chrome';
- elseif($is_IE) {
- $browser = $_SERVER['HTTP_USER_AGENT'];
- $browser = substr( "$browser", 25, 8);
- if ($browser == "MSIE 7.0" ) {
- $classes[] = 'ie7';
- $classes[] = 'ie';
- } elseif ($browser == "MSIE 6.0" ) {
- $classes[] = 'ie6';
- $classes[] = 'ie';
- } elseif ($browser == "MSIE 8.0" ) {
- $classes[] = 'ie8';
- $classes[] = 'ie';
- } elseif ($browser == "MSIE 9.0" ) {
- $classes[] = 'ie9';
- $classes[] = 'ie';
- } else {
- $classes[] = 'ie';
- }
- }
- else $classes[] = 'unknown';
-
- if( $is_iphone ) $classes[] = 'iphone';
-
- // Alternative style body class.
- $style = get_option( 'woo_alt_stylesheet', 'default' );
- $style = str_replace( '.css', '', $style );
- if ( '' != $style ) {
- $classes[] = 'alt-style-' . esc_attr( $style );
- }
- return $classes;
- } // End browser_body_class()
-
- /*-----------------------------------------------------------------------------------*/
- /* Twitter's Blogger.js output for Twitter widgets */
- /*-----------------------------------------------------------------------------------*/
-
- if ( ! function_exists( 'woo_twitter_script' ) ) {
- function woo_twitter_script($unique_id,$username,$limit) {
- ?>
- <script type="text/javascript">
- <!--//--><![CDATA[//><!--
-
- function twitterCallback2(twitters) {
-
- var statusHTML = [];
- for (var i=0; i<twitters.length; i++){
- var username = twitters[i].user.screen_name;
- var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
- return '<a href="'+url+'">'+url+'</a>';
- }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
- return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
- });
- 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>' );
- }
- document.getElementById( 'twitter_update_list_<?php echo esc_attr( $unique_id ); ?>').innerHTML = statusHTML.join( '' );
- }
-
- function relative_time(time_value) {
- var values = time_value.split( " " );
- time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
- var parsed_date = Date.parse(time_value);
- var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
- var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
- delta = delta + (relative_to.getTimezoneOffset() * 60);
-
- if (delta < 60) {
- return '<?php esc_attr_e( 'less than a minute ago', 'woothemes' ); ?>';
- } else if(delta < 120) {
- return '<?php esc_attr_e( 'about a minute ago', 'woothemes' ); ?>';
- } else if(delta < (60*60)) {
- return (parseInt(delta / 60)).toString() + ' <?php esc_attr_e( 'minutes ago', 'woothemes' ); ?>';
- } else if(delta < (120*60)) {
- return 'about an hour ago';
- } else if(delta < (24*60*60)) {
- return 'about ' + (parseInt(delta / 3600)).toString() + ' <?php esc_attr_e( 'hours ago', 'woothemes' ); ?>';
- } else if(delta < (48*60*60)) {
- return '1 day ago';
- } else {
- return (parseInt(delta / 86400)).toString() + ' <?php esc_attr_e( 'days ago', 'woothemes' ); ?>';
- }
- }
- //-->!]]>
- </script>
- <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&count=<?php echo esc_attr( $limit ); ?>&include_rts=t"></script>
- <?php
- } // End woo_twitter_script()
- }
-
- /*-----------------------------------------------------------------------------------*/
- /* Deprecated: Template Detector */
- /*-----------------------------------------------------------------------------------*/
- function woo_active_template( $filename = null ) {
-
- 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' ) );
- return false; // No $filename argument was set
-
- } // End woo_active_template()
-
- /*-----------------------------------------------------------------------------------*/
- /* WooFramework Update Page */
- /*-----------------------------------------------------------------------------------*/
-
- function woothemes_framework_update_page() {
-
- // Clear transients.
- delete_transient( 'woo_framework_critical_update' );
- delete_transient( 'woo_framework_critical_update_data' );
- delete_transient( 'wooframework_version_data' );
-
- $method = get_filesystem_method();
-
- $to = ABSPATH . 'wp-content/themes/' . get_option( 'template' ) . '/functions/';
- if(isset($_POST['password'])){
-
- $cred = $_POST;
- $filesystem = WP_Filesystem($cred);
-
- }
- elseif(isset($_POST['woo_ftp_cred'])){
-
- $cred = unserialize(base64_decode($_POST['woo_ftp_cred']));
- $filesystem = WP_Filesystem($cred);
-
- } else {
-
- $filesystem = WP_Filesystem();
-
- };
- $url = admin_url( 'admin.php?page=woothemes_framework_update' );
- ?>
- <div class="wrap themes-page">
- <?php
- if($filesystem == false){
-
- request_filesystem_credentials ( $url );
-
- } else {
-
- // Clear the transient to force a fresh update.
- delete_transient( 'wooframework_version_data' );
-
- $localversion = esc_html( get_option( 'woo_framework_version' ) );
- $remoteversion = woo_get_fw_version();
-
- // Test if new version
- $upd = false;
- $loc = explode( '.',$localversion);
- $rem = explode( '.',$remoteversion['version']);
-
- if( $loc[0] < $rem[0] )
- $upd = true;
- elseif ( $loc[1] < $rem[1] )
- $upd = true;
- elseif( $loc[2] < $rem[2] )
- $upd = true;
-
- ?>
- <?php screen_icon( 'tools' ); ?>
- <h2>Framework Update</h2>
- <span style="display:none"><?php echo $method; ?></span>
- <form method="post" enctype="multipart/form-data" id="wooform" action="<?php /* echo $url; */ ?>">
-
- <?php if( $upd ) { ?>
- <?php wp_nonce_field( 'update-options' ); ?>
- <h3>A new version of WooFramework is available.</h3>
- <p>This updater will download and extract the latest WooFramework files to your current theme's functions folder. </p>
- <p>We recommend backing up your theme files and updating WordPress to latest version before proceeding.</p>
- <p>→ <strong>Your version:</strong> <?php echo $localversion; ?></p>
-
- <p>→ <strong>Current Version:</strong> <?php echo $remoteversion['version']; ?></p>
-
- <input type="submit" class="button" value="Update Framework" />
- <?php } else { ?>
- <h3>You have the latest version of WooFramework</h3>
- <p>→ <strong>Your version:</strong> <?php echo $localversion; ?></p>
- <?php } ?>
- <input type="hidden" name="woo_update_save" value="save" />
- <input type="hidden" name="woo_ftp_cred" value="<?php echo esc_attr( base64_encode(serialize($_POST))); ?>" />
-
- </form>
- <?php } ?>
- </div>
- <?php
- };
-
- /*-----------------------------------------------------------------------------------*/
- /* WooFramework Update Head */
- /*-----------------------------------------------------------------------------------*/
-
- function woothemes_framework_update_head() {
- if( isset( $_REQUEST['page'] ) ) {
- // Sanitize page being requested.
- $_page = esc_attr( $_REQUEST['page'] );
-
- if( $_page == 'woothemes_framework_update' ) {
- //Setup Filesystem
- $method = get_filesystem_method();
-
- if( isset( $_POST['woo_ftp_cred'] ) ) {
- $cred = unserialize( base64_decode( $_POST['woo_ftp_cred'] ) );
- $filesystem = WP_Filesystem($cred);
- } else {
- $filesystem = WP_Filesystem();
- }
-
- if( $filesystem == false && $_POST['upgrade'] != 'Proceed' ) {
-
- function woothemes_framework_update_filesystem_warning() {
- $method = get_filesystem_method();
- echo "<div id='filesystem-warning' class='updated fade'><p>Failed: Filesystem preventing downloads. ( ". $method .")</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_filesystem_warning' );
- return;
- }
- if(isset($_REQUEST['woo_update_save'])){
-
- // Sanitize action being requested.
- $_action = esc_attr( $_REQUEST['woo_update_save'] );
-
- if( $_action == 'save' ) {
-
- $temp_file_addr = download_url( esc_url( 'http://www.woothemes.com/updates/framework.zip' ) );
-
- if ( is_wp_error($temp_file_addr) ) {
-
- $error = esc_html( $temp_file_addr->get_error_code() );
-
- if( $error == 'http_no_url' ) {
- //The source file was not found or is invalid
- function woothemes_framework_update_missing_source_warning() {
- echo "<div id='source-warning' class='updated fade'><p>Failed: Invalid URL Provided</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_missing_source_warning' );
- } else {
- function woothemes_framework_update_other_upload_warning() {
- echo "<div id='source-warning' class='updated fade'><p>Failed: Upload - $error</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_other_upload_warning' );
-
- }
-
- return;
-
- }
- //Unzip it
- global $wp_filesystem;
- $to = $wp_filesystem->wp_content_dir() . "/themes/" . get_option( 'template' ) . "/functions/";
-
- $dounzip = unzip_file($temp_file_addr, $to);
-
- unlink($temp_file_addr); // Delete Temp File
-
- if ( is_wp_error($dounzip) ) {
-
- //DEBUG
- $error = esc_html( $dounzip->get_error_code() );
- $data = $dounzip->get_error_data($error);
- //echo $error. ' - ';
- //print_r($data);
-
- if($error == 'incompatible_archive') {
- //The source file was not found or is invalid
- function woothemes_framework_update_no_archive_warning() {
- echo "<div id='woo-no-archive-warning' class='updated fade'><p>Failed: Incompatible archive</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_no_archive_warning' );
- }
- if($error == 'empty_archive') {
- function woothemes_framework_update_empty_archive_warning() {
- echo "<div id='woo-empty-archive-warning' class='updated fade'><p>Failed: Empty Archive</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_empty_archive_warning' );
- }
- if($error == 'mkdir_failed') {
- function woothemes_framework_update_mkdir_warning() {
- echo "<div id='woo-mkdir-warning' class='updated fade'><p>Failed: mkdir Failure</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_mkdir_warning' );
- }
- if($error == 'copy_failed') {
- function woothemes_framework_update_copy_fail_warning() {
- echo "<div id='woo-copy-fail-warning' class='updated fade'><p>Failed: Copy Failed</p></div>";
- }
- add_action( 'admin_notices', 'woothemes_framework_update_copy_fail_warning' );
- }
-
- return;
-
- }
-
- function woothemes_framework_updated_success() {
- echo "<div id='framework-upgraded' class='updated fade'><p>New framework successfully downloaded, extracted and updated.</p></div>";
- }
-
- add_action( 'admin_notices', 'woothemes_framework_updated_success' );
-
- }
- }
- } //End user input save part of the update
- }
- }
-
- add_action( 'admin_head', 'woothemes_framework_update_head' );
-
- /*-----------------------------------------------------------------------------------*/
- /* WooFramework Version Getter */
- /*-----------------------------------------------------------------------------------*/
-
- function woo_get_fw_version( $url = '', $check_if_critical = false ) {
-
- if( ! empty( $url ) ) {
- $fw_url = $url;
- } else {
- $fw_url = 'http://www.woothemes.com/updates/functions-changelog.txt';
- }
-
- $output = array( 'version' => '', 'is_critical' => false );
-
- $version_data = get_transient( 'wooframework_version_data' );
-
- if ( $version_data != '' && $check_if_critical == false ) { return $version_data; }
-
- $temp_file_addr = download_url( $fw_url );
- if( ! is_wp_error( $temp_file_addr ) && $file_contents = file( $temp_file_addr ) ) {
- foreach ( $file_contents as $line_num => $line ) {
- $current_line = $line;
-
- if( $line_num > 1 ) { // Not the first or second... dodgy :P
-
- if ( preg_match( '/^[0-9]/', $line ) ) {
-
- // Do critical update check.
- if ( $check_if_critical && ( strtolower( trim( substr( $line, -10 ) ) ) == 'critical' ) ) {
- $output['is_critical'] = true;
- }
-
- $current_line = stristr( $current_line, 'version' );
- $current_line = preg_replace( '~[^0-9,.]~','',$current_line );
- $output['version'] = $current_line;
- break;
- }
- }
- }
- unlink( $temp_file_addr );
- } else {
- $output['version'] = get_option( 'woo_framework_version' );
- }
-
- // Set the transient containing the latest version number.
- set_transient( 'wooframework_version_data', $output , 60*60*24 );
-
- return $output;
- } // End woo_get_fw_version()
-
-
- /*-----------------------------------------------------------------------------------*/
- /* WooFramework Version Checker */
- /*-----------------------------------------------------------------------------------*/
-
- function woo_framework_version_checker( $local_version, $check_if_critical = false ) {
- $data = array( 'is_update' => false, 'version' => '1.0.0', 'status' => 'none' );
-
- if ( ! $local_version ) { return $data; }
-
- $version_data = woo_get_fw_version( '', $check_if_critical );
-
- $check = version_compare( $version_data['version'], $local_version ); // Returns 1 if there is an update available.
-
- if ( $check == 1 ) {
- $data['is_update'] = true;
- $data['version'] = $version_data['version'];
- $data['is_critical'] = $version_data['is_critical'];
- }
-
- return $data;
- } // End woo_framework_version_checker()
-
- /*-----------------------------------------------------------------------------------*/
- /* Woo URL shortener */
- /*-----------------------------------------------------------------------------------*/
-
- function woo_short_url($url) {
- $service = get_option( 'woo_url_shorten' );
- $bitlyapilogin = get_option( 'woo_bitly_api_login' );;
- $bitlyapikey = get_option( 'woo_bitly_api_key' );;
- if (isset($service)) {
- switch ($service)
- {
- case 'TinyURL':
- $shorturl = getTinyUrl($url);
- break;
- case 'Bit.ly':
- if (isset($bitlyapilogin) && isset($bitlyapikey) && ($bitlyapilogin != '') && ($bitlyapikey != '')) {
- $shorturl = make_bitly_url($url,$bitlyapilogin,$bitlyapikey,'json' );
- }
- else {
- $shorturl = getTinyUrl($url);
- }
- break;
- case 'Off':
- $shorturl = $url;
- break;
- default:
- $shorturl = $url;
- break;
- }
- }
- else {
- $shorturl = $url;
- }
- return $shorturl;
- }
-
- //TinyURL
- function getTinyUrl($url) {
- $tinyurl = file_get_contents_curl( "http…
Large files files are truncated, but you can click here to view the full file