| Current Path : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/classes/ |
| Current File : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/classes/class-media.php |
<?php
class Genesis_Club_Media extends Genesis_Club_Module {
const OPTION_NAME = 'media';
const FEATURED_IMAGE_KEY = '_genesis_club_featured_image';
const FEATURED_IMAGE_ALT_KEY = '_genesis_club_featured_image_alt';
const FEATURED_THUMBS_KEY = '_genesis_club_featured_thumbs';
const FITVIDS_DISABLE_METAKEY = '_genesis_club_fitvids_disable';
const THUMBNAIL_QUALITY = 90;
protected $defaults = array(
'favicon_url' => '',
'header_image' => '',
'thumbnails' => false,
'thumbnail_quality' => self::THUMBNAIL_QUALITY,
'regenerate_thumbnails' => false,
'home_big_image' => '',
'peelback' => array( 'enabled' => false,'image' => '', 'target' => '', 'tracking' => ''),
'fitvids' => array('setting' => 'none', 'home' => false)
);
function get_defaults() { return $this->defaults; }
function get_options_name() { return self::OPTION_NAME; }
protected $fitvids_include = false;
function init() {
if (is_admin()) {
add_filter('genesis_pre_load_favicon', array($this,'favicon_url'));
add_action('admin_head', 'genesis_load_favicon');
} else {
add_action('wp',array($this,'prepare'));
}
}
function prepare() {
add_filter('genesis_pre_load_favicon', array($this,'favicon_url'));
if ($this->get_option('header_image')
&& ($header_support = get_theme_support( 'custom-header'))) {
if (array_key_exists('header-selector', $header_support)) unset ($header_support['header-selector']);
remove_theme_support( 'custom-header');
add_theme_support( 'custom-header', $header_support );
add_filter('theme_mod_header_image', array($this,'header_image'));
}
if (is_front_page() && ($image = $this->get_option('home_big_image'))) {
add_filter('minimum_get_featured_image', array($this, 'home_featured_image'));
add_filter('home_featured_image', array($this, 'home_featured_image_url'));
add_filter('home_featured_peelback', array($this, 'home_featured_peelback'));
}
if ($this->get_option('thumbnails')) { //generate local thumbnails from remote images
require_once(dirname(__FILE__).'/class-media-thumbnails.php');
$thumbnail_generator = new Genesis_Club_Thumbnails($this->get_option('thumbnail_quality'));
add_filter('genesis_pre_get_image', array($thumbnail_generator, 'get_featured_thumbnail'), 10, 3);
if ($this->utils->is_seo_framework_installed() )
add_filter('the_seo_framework_og_image_after_featured', array($thumbnail_generator, 'get_facebook_image'), 10, 3);
}
$this->check_fitvids();
}
function home_featured_peelback($content) {
if ($peelback = $this->get_option('peelback'))
return array_merge($content, $peelback);
else
return $content;
}
function home_featured_image($content) {
if ($image = $this->get_option('home_big_image'))
return sprintf('<img src="%1$s" alt="Featured Image" />',$image);
else
return $content;
}
function home_featured_image_url($content) {
if ($image = $this->get_option('home_big_image'))
return $image;
else
return $content;
}
function header_image($content) {
return $this->get_option('header_image');
}
function favicon_url($content) {
if ($favicon = $this->get_option('favicon_url'))
return $favicon;
else
return $content;
}
function get_default_favicon() {
$favicon = '';
$dir = get_stylesheet_directory().'/images/';
$url = get_stylesheet_directory_uri().'/images/';
if ( file_exists( $dir . 'favicon.ico' ) )
$favicon = $url . 'favicon.ico';
elseif ( file_exists( $dir . 'favicon.gif' ) )
$favicon = $url . 'favicon.gif';
elseif ( file_exists( $dir . 'favicon.png' ) )
$favicon = $url . 'favicon.png';
elseif ( file_exists( $dir . 'favicon.jpg' ) )
$favicon = $url . 'favicon.jpg';
elseif (file_exists( get_template_directory() . '/images/favicon.ico' ))
$favicon = get_template_directory_uri() . '/images/favicon.ico';
else
$favicon = site_url('favicon.ico') ;
return $favicon;
}
function check_fitvids() {
if ($fitvids=$this->get_option('fitvids')) {
if (is_front_page()) {
if ($fitvids['home']) $this->set_include_fitvids();
} else {
switch ($fitvids['setting']) {
case 'none': return; break;
case 'all': $this->set_include_fitvids(); break;
case 'on_demand' : //check for disabling on individual pages
if (is_singular() && ($pm = get_post_meta(get_queried_object_id(), self::FITVIDS_DISABLE_METAKEY,true)))
return;
default:
add_filter('the_content', array($this, 'check_fitvids_content'),10);
}
}
add_action('wp_footer', array($this, 'maybe_include_fitvids'));
}
}
function check_fitvids_content($content) {
if (preg_match('/youtube/i',$content) || preg_match('/vimeo/i',$content) ||preg_match('/<object/i',$content))
$this->set_include_fitvids(); //enable if video in content
return $content; //pass content through unchanged
}
function set_include_fitvids() {
$this->fitvids_include = true; //enable fitvids
}
function get_include_fitvids() {
return $this->fitvids_include;
}
function maybe_include_fitvids() {
if ($this->get_include_fitvids()) {
wp_enqueue_script('jquery-fitvids', plugins_url('scripts/jquery.fitvids.js',dirname(__FILE__)), array('jquery'), '1.0', true);
add_action('wp_print_footer_scripts', array($this, 'start_fitvids'),10);
}
}
function start_fitvids() {
print <<< FITVIDS
<!-- RESPONSIVE VIDEO FITVIDS BEGIN-->
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
$("iframe").not('.ls-wp-container iframe').not('.fv-responsive iframe').wrap('<div class="fv-responsive" />');
$("object").not('.ls-wp-container object').not('.fv-responsive object').wrap('<div class="fv-responsive" />');
$(".fv-responsive").fitVids();
});
//]]>
</script>
<!-- RESPONSIVE VIDEO FITVIDS END -->
FITVIDS;
}
}