├── .gitmodules
├── css
├── admin-post.css
├── admin-license.css
└── admin-widgets.css
├── js
├── ie-unsupported.js
├── admin-post.js
├── jquery.fitvids.js
├── responsive-embeds.js
├── maps.js
└── admin-widgets.js
├── README.md
├── includes
├── admin
│ ├── meta-boxes.php
│ ├── admin-enqueue-styles.php
│ ├── admin-enqueue-scripts.php
│ ├── admin-taxonomies.php
│ ├── activation.php
│ └── admin-widgets.php
├── body.php
├── mime-types.php
├── meta-data.php
├── posts.php
├── taxonomies.php
├── downloads.php
├── template-tags.php
├── people.php
├── locations.php
├── classes
│ ├── walker-nav-menu-description.php
│ ├── customize-controls.php
│ ├── ctfw-theme-updater-class.php
│ └── widget-galleries.php
├── page-nav.php
├── pages.php
├── background.php
├── comments.php
├── head.php
├── templates.php
├── fonts.php
├── images.php
├── sidebars.php
├── deprecated.php
├── colors.php
├── localization.php
├── maps.php
├── compatibility.php
├── conditions.php
├── embeds.php
└── customize.php
└── framework.php
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "includes/libraries/ct-meta-box"]
2 | path = includes/libraries/ct-meta-box
3 | url = https://github.com/churchthemes/ct-meta-box.git
4 | [submodule "includes/libraries/ct-recurrence"]
5 | path = includes/libraries/ct-recurrence
6 | url = https://github.com/churchthemes/ct-recurrence.git
7 |
--------------------------------------------------------------------------------
/css/admin-post.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Admin Add/Edit Post CSS
3 | */
4 |
5 | /* Gutenberg */
6 |
7 | .gutenberg #ctfw-featured-image-note:first-child {
8 | margin-top: 0;
9 | margin-bottom: 1em;
10 | }
11 |
12 | .gutenberg #ctfw-featured-image-note:last-child {
13 | margin-top: 1em;
14 | margin-bottom: 0;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/css/admin-license.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Theme License
3 | */
4 |
5 | /* Status */
6 |
7 | .ctfw-license-active {
8 | color: #1ba31b;
9 | font-weight: bold;
10 | }
11 |
12 | .ctfw-license-inactive,
13 | .ctfw-license-expired,
14 | .ctfw-license-expiring-soon {
15 | color: #d52121;
16 | font-weight: bold;
17 | }
18 |
19 | /* Buttons */
20 |
21 | .ctfw-license-button {
22 | margin-right: 10px !important;
23 | }
--------------------------------------------------------------------------------
/js/ie-unsupported.js:
--------------------------------------------------------------------------------
1 | jQuery( document ).ready( function( $ ) {
2 |
3 | // Is old version of IE used?
4 | if ( navigator.userAgent.match( new RegExp( "MSIE [5-" + ctfw_ie_unsupported.version + "]", "gi" ) ) ) {
5 |
6 | // Hide content
7 | $( 'body' )
8 | .empty() // remove content
9 | .css( 'background', 'none' ); // hide background
10 |
11 | // Tell user to upgrade to a modern browser
12 | alert( ctfw_ie_unsupported.message );
13 |
14 | // Redirect to a site with upgrade details
15 | window.location = ctfw_ie_unsupported.redirect_url;
16 |
17 | }
18 |
19 | });
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Church Theme Framework
2 | ======================
3 |
4 | A library of code from [ChurchThemes.com](https://churchthemes.com) useful for assisting with the development of church WordPress themes using the [Church Content](https://github.com/churchthemes/church-theme-content) functionality plugin.
5 |
6 | Purpose
7 | -------
8 |
9 | Church Theme Framework is a drop-in framework. In other words, it's a directory of includes containing functions, classes and other code useful to multiple, similar themes.
10 |
11 | * Faster development
12 | * Easier maintenance
13 | * Consistent features
14 |
15 | Full Details
16 | -------
17 |
18 | For full details, see the [Developer's Guide](https://churchthemes.com/guides/developer/framework/) on ChurchThemes.com.
--------------------------------------------------------------------------------
/includes/admin/meta-boxes.php:
--------------------------------------------------------------------------------
1 | ' + ctfw_post.featured_image_note + '
' );
23 | $( '#ctfw-featured-image-note' )
24 | .hide()
25 | .fadeIn( 'fast' );
26 |
27 | clearInterval( interval );
28 |
29 | }
30 |
31 | }, 1000 );
32 |
33 | }
34 |
35 | } );
36 |
--------------------------------------------------------------------------------
/includes/body.php:
--------------------------------------------------------------------------------
1 | Functions
4 | *
5 | * @package Church_Theme_Framework
6 | * @subpackage Functions
7 | * @copyright Copyright (c) 2014 - 2019, ChurchThemes.com, LLC
8 | * @link https://github.com/churchthemes/church-theme-framework
9 | * @license GPLv2 or later
10 | * @since 1.1.2
11 | */
12 |
13 | // No direct access
14 | if ( ! defined( 'ABSPATH' ) ) exit;
15 |
16 | /*******************************************
17 | * BODY CLASSES
18 | *******************************************/
19 |
20 | /**
21 | * Add various helper classes to
22 | *
23 | * Enable with add_theme_support( 'ctfw-body-classes' );
24 | *
25 | * IMPORTANT: Do not do client detection (mobile, browser, etc.) here.
26 | * Instead, do in theme's JS so works with caching plugins.
27 | *
28 | * @since 1.1.2
29 | * @param array $classes Classes currently being added to body tag
30 | * @return array Modified classes
31 | */
32 | function ctfw_add_body_classes( $classes ) {
33 |
34 | // Theme supports body helper classes?
35 | if ( current_theme_supports( 'ctfw-body-classes' ) ) {
36 |
37 | // Page has loop for multiple entries (archive, search, etc.)
38 | if ( ctfw_has_loop_multiple() ) {
39 | $classes[] = 'ctfw-has-loop-multiple';
40 | } else {
41 | $classes[] = 'ctfw-no-loop-multiple';
42 | }
43 |
44 | }
45 |
46 | return $classes;
47 |
48 | }
49 |
50 | add_filter( 'body_class', 'ctfw_add_body_classes' );
51 |
--------------------------------------------------------------------------------
/includes/mime-types.php:
--------------------------------------------------------------------------------
1 | 'Image',
37 | 'audio' => 'Audio',
38 | 'video' => 'Video',
39 | 'application/pdf' => 'PDF',
40 | );
41 | $mime_type_names = apply_filters( 'ctfw_mime_type_names', $mime_type_names );
42 |
43 | // Check for match
44 | foreach ( $mime_type_names as $mime_type_match => $mime_type_name ) {
45 |
46 | // Match the first part and keep that name (e.g. image/jpeg matches image)
47 | if ( preg_match( '/^' . preg_quote( $mime_type_match, '/' ) . '/i', $mime_type ) ) {
48 | $friendly_name = $mime_type_name;
49 | break;
50 | }
51 |
52 | }
53 |
54 | return apply_filters( 'ctfw_mime_type_name', $friendly_name , $mime_type );
55 |
56 | }
--------------------------------------------------------------------------------
/includes/meta-data.php:
--------------------------------------------------------------------------------
1 |
23 | * @return array Modified array of classes
24 | */
25 | function ctfw_add_post_classes( $classes ) {
26 |
27 | // Theme asks for this enhancement?
28 | if ( current_theme_supports( 'ctfw-post-classes' ) ) {
29 |
30 | // Has featured image?
31 | if ( has_post_thumbnail() ) {
32 | $classes[] = 'ctfw-has-image';
33 | } else {
34 | $classes[] = 'ctfw-no-image';
35 | }
36 |
37 | }
38 |
39 | return $classes;
40 |
41 | }
42 |
43 | add_filter( 'post_class', 'ctfw_add_post_classes' );
44 |
45 | /**
46 | * Get first ordered post
47 | *
48 | * Get first post according to manual order
49 | *
50 | * @since 1.0.9
51 | * @param string $post_type Post type to use
52 | * @return Array Post data
53 | */
54 | function ctfw_first_ordered_post( $post_type ) {
55 |
56 | $post = array();
57 |
58 | // Get first post
59 | $posts = get_posts( array(
60 | 'post_type' => $post_type,
61 | 'orderby' => 'menu_order', // first manually ordered
62 | 'order' => 'ASC',
63 | 'numberposts' => 1,
64 | 'suppress_filters' => false // assist multilingual
65 | ) );
66 |
67 | // Get post as array
68 | if ( isset( $posts[0] ) ) {
69 | $post = (array) $posts[0];
70 | }
71 |
72 | // Return filtered
73 | return apply_filters( 'ctfw_first_ordered_post', $post );
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/includes/admin/admin-enqueue-styles.php:
--------------------------------------------------------------------------------
1 | base ) {
35 |
36 | // CSS for add/edit post screen.
37 | wp_enqueue_style( 'ctfw-post', get_theme_file_uri( CTFW_CSS_DIR . '/admin-post.css' ), false, CTFW_THEME_VERSION ); // bust cache on update.
38 |
39 | }
40 |
41 | // Admin Widgets.
42 | if ( 'widgets' === $screen->base ) {
43 |
44 | // For color widget field type.
45 | // Improvement to enqueue only when there is a widget with color field?
46 | wp_enqueue_style( 'wp-color-picker' );
47 |
48 | // CSS for admin widgets.
49 | // Framework also enqueues this for Customizer in framework/includes/customize.php.
50 | wp_enqueue_style( 'ctfw-widgets', get_theme_file_uri( CTFW_CSS_DIR . '/admin-widgets.css' ), false, CTFW_THEME_VERSION ); // bust cache on update.
51 |
52 | }
53 |
54 | // Theme License.
55 | if ( 'appearance_page_theme-license' == $screen->base ) {
56 | wp_enqueue_style( 'ctfw-license', get_theme_file_uri( CTFW_CSS_DIR . '/admin-license.css' ), false, CTFW_THEME_VERSION ); // bust cache on update.
57 | }
58 |
59 | }
60 |
61 | add_action( 'admin_enqueue_scripts', 'ctfw_admin_enqueue_styles' );
62 |
--------------------------------------------------------------------------------
/includes/admin/admin-enqueue-scripts.php:
--------------------------------------------------------------------------------
1 | base ) { // don't enqueue unless needed
31 |
32 | wp_enqueue_script( 'ctfw-admin-post', get_theme_file_uri( CTFW_JS_DIR . '/admin-post.js' ), array( 'jquery' ), CTFW_THEME_VERSION ); // bust cache on update
33 | wp_localize_script( 'ctfw-admin-post', 'ctfw_post', array(
34 | 'featured_image_note' => ctfw_featured_image_note(), // get note to show on current post type's Featured Image (Gutenberg).
35 | ) );
36 |
37 | }
38 |
39 | // Widgets JavaScript
40 | // wp_enqueue_media() is run in classes/widget.php
41 | if ( 'widgets' === $screen->base ) { // don't enqueue unless needed
42 |
43 | // New media uploader in WP 3.5+
44 | wp_enqueue_media();
45 |
46 | // Color picker
47 | // Improvement to enqueue only when there is a widget with color field?
48 | wp_enqueue_script( 'wp-color-picker' );
49 |
50 | // Main widgets script
51 | wp_enqueue_script( 'ctfw-admin-widgets', get_theme_file_uri( CTFW_JS_DIR . '/admin-widgets.js' ), array( 'jquery' ), CTFW_THEME_VERSION ); // bust cache on update
52 | wp_localize_script( 'ctfw-admin-widgets', 'ctfw_widgets', ctfw_admin_widgets_js_data() ); // see admin-widgets.php
53 |
54 | }
55 |
56 | }
57 |
58 | add_action( 'admin_enqueue_scripts', 'ctfw_admin_enqueue_scripts' ); // admin-end only
59 |
--------------------------------------------------------------------------------
/includes/taxonomies.php:
--------------------------------------------------------------------------------
1 | show_ui ) ? true : false;
34 |
35 | // Return filterable
36 | return apply_filters( 'ctfw_ctc_taxonomy_supported', $supported, $taxonomy_name );
37 |
38 | }
39 |
40 | /**
41 | * Taxonomy term options
42 | *
43 | * Returns ID/name pairs useful for creating select options and sanitizing on front-end.
44 | *
45 | * @since 0.9
46 | * @param string $taxonomy_name Taxonomy slug
47 | * @param array $prepend Array to start with such as "All" or similar
48 | * @return array ID/name pairs
49 | */
50 | function ctfw_term_options( $taxonomy_name, $prepend = array() ) {
51 |
52 | $options = array();
53 |
54 | if ( ! preg_match( '/^ctc_/', $taxonomy_name ) || ctfw_ctc_taxonomy_supported( $taxonomy_name ) ) { // make sure CTC taxonomy support
55 |
56 | $terms = $categories = get_terms( $taxonomy_name );
57 |
58 | if ( ! empty( $prepend ) ) {
59 | $options = $prepend;
60 | }
61 |
62 | foreach ( $terms as $term ) {
63 | $options[$term->term_id] = $term->name;
64 | }
65 |
66 | }
67 |
68 | return apply_filters( 'ctfw_term_options', $options, $taxonomy_name, $prepend );
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/includes/downloads.php:
--------------------------------------------------------------------------------
1 | tags use download="download" attribute to attempt "Save As".
27 | * As of October, 2019, most browsers support (not IE11 or iOS, which doesn't save files anyway).
28 | *
29 | * Prior to framework version 2.6, this would use ctfw_force_download_url() to force downloads via headers.
30 | * Now we're relying on download attribute which is simpler, safer and not error-prone.
31 | *
32 | * @since 1.7.2
33 | * @param string $url URL for file
34 | * @return string URL modified to force Save As if local or as is if external and has extension
35 | */
36 | function ctfw_download_url( $url ) {
37 |
38 | $download_url = $url;
39 |
40 | // Dropbox URL?
41 | $is_dropbox = '';
42 | if ( preg_match( '/dropbox/', $url ) ) {
43 |
44 | $is_dropbox = true;
45 |
46 | // Force ?dl=1 since download="download" attribute won't work with remote URL in most browser.
47 | $download_url = remove_query_arg( 'dl', $download_url );
48 | $download_url = remove_query_arg( 'raw', $download_url );
49 | $download_url = add_query_arg( 'dl', '1', $download_url );
50 |
51 | }
52 |
53 | // Must have extension or be Dropbox URL to be downloadable.
54 | // It may be URL to SoundCloud, YouTube, etc.
55 | $filetype = wp_check_filetype( $download_url ); // remove any query string.
56 | if ( empty( $filetype['ext'] ) && ! $is_dropbox ) {
57 | $download_url = ''; // Return nothing, there is no file to download.
58 | }
59 |
60 | return apply_filters( 'ctfw_download_url', $download_url, $url );
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/includes/admin/admin-taxonomies.php:
--------------------------------------------------------------------------------
1 | true,
36 | 'show_ui' => true // weed out post_format
37 | ) );
38 |
39 | // Supported taxonomies (some cannot be re-ordered).
40 | $supported_taxonomies = array(
41 | 'category',
42 | 'ctc_person_group',
43 | 'ctc_sermon_speaker',
44 | 'ctc_event_category',
45 | );
46 |
47 | // Add note to each
48 | foreach ($taxonomies as $taxonomy) {
49 | if (in_array($taxonomy, $supported_taxonomies)) {
50 | add_action( 'after-' . $taxonomy . '-table', 'ctfw_taxonomy_order_note' );
51 | }
52 | }
53 |
54 | }
55 |
56 | add_action( 'admin_init', 'ctfw_taxonomy_order_notes' );
57 |
58 | /**
59 | * Show custom ordering note
60 | *
61 | * @since 0.9
62 | * @param string $taxonomy Taxonomy to affect
63 | */
64 | function ctfw_taxonomy_order_note( $taxonomy ) {
65 |
66 | // Only if theme requests this
67 | $support = get_theme_support( 'ctfw-taxonomy-order-note' );
68 | if ($support) { // returns false if feature not supported
69 |
70 | // Get URL if not using default
71 | $url = isset( $support[0] ) ? $support[0] : 'https://churchthemes.com/go/taxonomy-order';
72 |
73 | // Get taxonomy plural
74 | $taxonomy_obj = get_taxonomy( $taxonomy );
75 | $taxonomy_plural = strtolower( $taxonomy_obj->labels->name );
76 |
77 | // Show message
78 | echo '';
79 | printf(
80 | __( 'Custom Ordering: Try this plugin for custom ordering your %s.', 'church-theme-framework' ),
81 | $url,
82 | $taxonomy_plural
83 | );
84 | echo '
';
85 |
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/includes/template-tags.php:
--------------------------------------------------------------------------------
1 | false,
35 | 'today' => true, // show "Today" if post is from today
36 | 'yesterday' => true, // show "Yesterday" instead of yesterday's date
37 | 'date_format' => get_option( 'date_format' ), // from WordPress general settings
38 | 'abbreviate_date' => false, // true or pass arguments for ctfw_abbreviate_date_format()
39 | ) );
40 | $options = wp_parse_args( $options, $defaults );
41 |
42 | // Abbreviate date format
43 | // If $options['abbreviate_date'] is true, default arguments will be used (abbreviate)
44 | if ( $options['abbreviate_date'] ) {
45 |
46 | // Use the date format passed in already
47 | $abbreviate_date_args = array(
48 | 'date_format' => $options['date_format'],
49 | );
50 |
51 | // Passing arguments for abbreviating date
52 | // Default both true: abbreviate_month, remove_year
53 | if ( is_array( $options['abbreviate_date'] ) ) {
54 | $abbreviate_date_args = array_merge( $options['abbreviate_date'], $abbreviate_date_args );
55 | }
56 |
57 | $options['date_format'] = ctfw_abbreviate_date_format( $abbreviate_date_args );
58 |
59 | }
60 |
61 | // Today and yesterday in local time
62 | $today_ymd = date_i18n( 'Y-m-d' );
63 | $yesterday_ymd = date_i18n( 'Y-m-d', strtotime( $today_ymd ) - DAY_IN_SECONDS );
64 |
65 | // Post date
66 | $date_timestamp = get_the_time( 'U', $post );
67 | $date_ymd = date_i18n( 'Y-m-d', $date_timestamp );
68 |
69 | // Show "Today"
70 | if ( $options['today'] && $today_ymd == $date_ymd ) {
71 | $date_formatted = __( 'Today', 'church-theme-framework' );
72 | }
73 |
74 | // Show "Yesterday"
75 | elseif ( $options['yesterday'] && $yesterday_ymd == $date_ymd ) {
76 | $date_formatted = __( 'Yesterday', 'church-theme-framework' );
77 | }
78 |
79 | // Show date
80 | else {
81 | $date_formatted = date_i18n( $options['date_format'], $date_timestamp ); // translated date
82 | }
83 |
84 | // Date filtering
85 | $date_formatted = apply_filters( 'ctfw_post_date', $date_formatted, $options );
86 |
87 | // Output or return
88 | if ( $options['return'] ) {
89 | return $date_formatted;
90 | } else {
91 | echo $date_formatted;
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/includes/people.php:
--------------------------------------------------------------------------------
1 | is_archive && ! empty( $query->query['ctc_person_group'] ) ) {
36 | $query->set( 'orderby', 'menu_order' );
37 | $query->set( 'order', 'ASC' );
38 | }
39 |
40 | }
41 |
42 | return $query;
43 |
44 | }
45 |
46 | add_filter( 'pre_get_posts' , 'ctfw_people_group_order' );
47 |
48 | /**********************************
49 | * PEOPLE DATA
50 | **********************************/
51 |
52 | /**
53 | * Get person data
54 | *
55 | * @since 0.9
56 | * @param int $post_id Post ID to get data for; null for current post
57 | * @return array Person data
58 | */
59 | function ctfw_person_data( $post_id = null ) {
60 |
61 | // Get meta values
62 | $data = ctfw_get_meta_data( array( // without _ctc_person_ prefix
63 | 'position',
64 | 'phone',
65 | 'email',
66 | 'urls',
67 | ), $post_id );
68 |
69 | // Return filtered
70 | return apply_filters( 'ctfw_person_data', $data );
71 |
72 | }
73 |
74 | /**********************************
75 | * PEOPLE NAVIGATION
76 | **********************************/
77 |
78 | /**
79 | * Prev/next people sorting
80 | *
81 | * This makes get_previous_post() and get_next_post() sort by manual order instead of Publish Date
82 | *
83 | * @since 0.9.0
84 | */
85 | function ctfw_previous_next_person_sorting() {
86 |
87 | // Theme supports it?
88 | if ( ! current_theme_supports( 'ctfw-person-navigation' ) ) {
89 | return;
90 | }
91 |
92 | // While on single person, if theme supports People from Church Content
93 | // IMPORTANT: Without ! is_page(), is_singular() runs, somehow causing /page/#/ URL's on static front page to break
94 | if ( ! is_page() && is_singular( 'ctc_person' ) && current_theme_supports( 'ctc-people' ) ) {
95 |
96 | // SQL WHERE
97 | add_filter( 'get_previous_post_where', 'ctfw_previous_post_where' );
98 | add_filter( 'get_next_post_where', 'ctfw_next_post_where' );
99 |
100 | // SQL ORDER BY
101 | add_filter( 'get_previous_post_sort', 'ctfw_previous_post_sort' );
102 | add_filter( 'get_next_post_sort', 'ctfw_next_post_sort' );
103 |
104 | }
105 |
106 | }
107 |
108 | add_action( 'wp', 'ctfw_previous_next_person_sorting' ); // is_singular() not available until wp action (after posts_selection)
109 |
--------------------------------------------------------------------------------
/includes/locations.php:
--------------------------------------------------------------------------------
1 | publish > 1 ) {
106 | $multiple = true;
107 | }
108 |
109 | return $multiple;
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/js/jquery.fitvids.js:
--------------------------------------------------------------------------------
1 | /*global jQuery */
2 | /*jshint browser:true */
3 | /*!
4 | * FitVids 1.1
5 | *
6 | * Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
7 | * Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
8 | * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
9 | *
10 | */
11 |
12 | (function( $ ){
13 |
14 | "use strict";
15 |
16 | $.fn.fitVids = function( options ) {
17 | var settings = {
18 | customSelector: null,
19 | ignore: null
20 | };
21 |
22 | if(!document.getElementById('fit-vids-style')) {
23 | // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
24 | var head = document.head || document.getElementsByTagName('head')[0];
25 | var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
26 | var div = document.createElement('div');
27 | div.innerHTML = 'x
';
28 | head.appendChild(div.childNodes[1]);
29 | }
30 |
31 | if ( options ) {
32 | $.extend( settings, options );
33 | }
34 |
35 | return this.each(function(){
36 | var selectors = [
37 | "iframe[src*='player.vimeo.com']",
38 | "iframe[src*='youtube.com']",
39 | "iframe[src*='youtube-nocookie.com']",
40 | "iframe[src*='kickstarter.com'][src*='video.html']",
41 | "object",
42 | "embed"
43 | ];
44 |
45 | if (settings.customSelector) {
46 | selectors.push(settings.customSelector);
47 | }
48 |
49 | var ignoreList = '.fitvidsignore';
50 |
51 | if(settings.ignore) {
52 | ignoreList = ignoreList + ', ' + settings.ignore;
53 | }
54 |
55 | var $allVideos = $(this).find(selectors.join(','));
56 | $allVideos = $allVideos.not("object object"); // SwfObj conflict patch
57 | $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
58 |
59 | $allVideos.each(function(){
60 | var $this = $(this);
61 | if($this.parents(ignoreList).length > 0) {
62 | return; // Disable FitVids on this video.
63 | }
64 | if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
65 | if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
66 | {
67 | $this.attr('height', 9);
68 | $this.attr('width', 16);
69 | }
70 | var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
71 | width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
72 | aspectRatio = height / width;
73 | if(!$this.attr('id')){
74 | var videoID = 'fitvid' + Math.floor(Math.random()*999999);
75 | $this.attr('id', videoID);
76 | }
77 | $this.wrap('').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
78 | $this.removeAttr('height').removeAttr('width');
79 | });
80 | });
81 | };
82 | // Works with either jQuery or Zepto
83 | })( window.jQuery || window.Zepto );
--------------------------------------------------------------------------------
/js/responsive-embeds.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Responsive Embeds
3 | */
4 |
5 | // Use FitVids.js for responsive videos and other embeds
6 | // Note: Rdio and Spotify are correct when loading at final size ( browser resize is bad demo )
7 | ctfw_embed_fitvids_selectors = [
8 |
9 | // Default (from fitVids.js)
10 | // We redefine these here so they can be hidden prior to FitVids.js
11 | "iframe[src*='player.vimeo.com']",
12 | "iframe[src*='youtube.com']",
13 | "iframe[src*='youtube-nocookie.com']",
14 | "iframe[src*='kickstarter.com'][src*='video.html']",
15 | "object",
16 | "embed",
17 |
18 | // Custom
19 | "iframe[src*='youtu.be']",
20 | "iframe[src*='blip.tv']",
21 | "iframe[src*='hulu.com']",
22 | "iframe[src*='dailymotion.com']",
23 | "iframe[src*='revision3.com']",
24 | "iframe[src*='slideshare.net']",
25 | "iframe[src*='scribed.com']",
26 | "iframe[src*='viddler.com']",
27 | "iframe[src*='rd.io']",
28 | "iframe[src*='rdio.com']",
29 | //"iframe[src*='spotify.com']", // has issues, not needed (see https://dev.churchthemes.local/exodus/sermons/tes/)
30 | "iframe[src*='soundcloud.com']:not([width$='%'])", // Jetpack soundcloud shortcode is already responsive with %, so exclude
31 | "iframe[src*='snd.sc']",
32 | "iframe[src*='livestream.com']",
33 | "iframe[src*='soundfaith.com']",
34 | "iframe[src*='ustream.tv']",
35 | "iframe[src*='sermon.net']:not([src*='/main']):not([src*='.sermon.net/embed'])",
36 | "iframe[src*='read.amazon.com']",
37 |
38 | ];
39 | ctfw_embed_fitvids_selectors_list = ctfw_embed_fitvids_selectors.join(', ');
40 |
41 | // Other embedded media only need max-width: 100% ( height is static ) - MediaElement.js
42 | // Important: when done via stylesheet, MediaElement.js volume control flickers
43 | ctfw_embed_other_selectors_list = '.wp-video-shortcode, .wp-audio-shortcode';
44 |
45 | // Hide videos before resizing
46 | // This keeps them from showing briefly at small size before showing at full width
47 | ctfw_embed_all_selectors_list = ctfw_embed_fitvids_selectors_list + ', ' + ctfw_embed_other_selectors_list;
48 | jQuery('head').prepend('' + "\n");
49 |
50 | // Resize videos to 100% width
51 | jQuery(document).ready(function ($) {
52 |
53 | // Ignore those already being made responsive with WordPress.
54 | if (ctfw_responsive_embeds.wp_responsive_embeds) {
55 |
56 | // Loop selectors
57 | jQuery.each(ctfw_embed_fitvids_selectors, function (i, selector) {
58 |
59 | // Ignore FitVids if WP already making responsive.
60 | if (jQuery(selector).parents('.wp-has-aspect-ratio').length) {
61 |
62 | // Loop each element matching selector.
63 | jQuery.each(jQuery(selector), function (i, element) {
64 |
65 | // Not sermon media element (problem when also have media in content).
66 | if (jQuery(element).parents('[id$=-sermon-video-player]').length) {
67 | return;
68 | }
69 |
70 | jQuery(element).addClass('fitvidsignore');
71 |
72 | });
73 |
74 | }
75 |
76 | });
77 |
78 | }
79 |
80 | // Remove