-
-
Save ameeker/9b27127aec276f65de97 to your computer and use it in GitHub Desktop.
Theme functions bdsra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Theme Functions Plugin | |
Plugin URI: http://www.petersenmediagroup.com/plugins/ | |
Description: Adds a theme-dependent area to add functions that must be preserved if the theme is changed (i.e., CPTs). | |
Version: 1.0.0 | |
Author: Jesse Petersen | |
Author URI: http://www.petersenmediagroup.com | |
Copyright 2013 Jesse Petersen | |
Limit of liability: Installation and use of this plugin acknowledges the | |
understanding that this program alters WordPress and adds | |
settings to the WordPress database. The author is not responsible for any | |
damages or loss of data that might possibly be incurred through the | |
installation or use of the plugin. | |
Support: This is a free plugin, therefore support is limited to bugs that | |
affect all installations. Requests of any other nature will be at the | |
discretion of the plugin author to add or modify the code to account for | |
various installations, servers, or plugin conflicts. | |
Licenced under the GNU GPL: | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation; either version 2 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
*/ | |
// Start up the engine | |
class Theme_Functions_Plugin | |
{ | |
/** | |
* Static property to hold the singleton instance | |
* | |
* @return Theme_Functions_Plugin | |
*/ | |
static $instance = false; | |
/** | |
* If an instance exists, this returns it. If not, it creates one and | |
* returns it. | |
* | |
* @return Theme_Functions_Plugin | |
*/ | |
public static function getInstance() { | |
if ( !self::$instance ) | |
self::$instance = new self; | |
return self::$instance; | |
} | |
/** | |
* This is the constructor | |
* | |
* @return Theme_Functions_Plugin | |
*/ | |
private function __construct() { | |
/** | |
* Add theme-independent (theme agnostic) functions in this block | |
*/ | |
// Remove Post Info, Post Meta from CPT | |
function family_remove_post_info() { | |
if ('family_profiles' == get_post_type()) {//add in your CPT name | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
} | |
} | |
add_action ( 'get_header', 'family_remove_post_info' ); | |
// Remove Post Info, Post Meta from CPT | |
function centers_remove_post_info() { | |
if ('centers' == get_post_type()) {//add in your CPT name | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
} | |
} | |
add_action ( 'get_header', 'centers_remove_post_info' ); | |
/** | |
* | |
* Display a family profile using | |
* Genesis column classes and ACF. | |
* | |
* @author Angie Meeker | |
* @uses Advanced Custom Fields | |
*/ | |
add_action( 'genesis_entry_content', 'family_profiles', 12 ); | |
function family_profiles() { | |
if ( is_post_type_archive('family_profiles') ) | |
return; | |
// Store the tour data | |
$family_data = array( | |
'family_ages' => get_field('family_ages'), | |
'family_diagnosis' => get_field('family_diagnosis'), | |
'family_challenges' => get_field('family_challenges'), | |
'family_advice' => get_field('family_advice'), | |
'family_quote' => get_field('family_quote'), | |
); | |
if ($family_data['family_ages'] != '' || | |
$family_data['family_diagnosis'] != '' || | |
$family_data['family_challenges'] != '' || | |
$family_data['family_advice'] != '' || | |
$family_data['family_quote'] != '' ) { | |
echo '<div class="tour-wrap">'; | |
if ( $family_data['family_ages'] ) { | |
echo '<div class="location"><h4>How old are your family members diagnosed with Batten Disease?</h4> ' . esc_attr( $family_data['family_ages'] ) . '</div></br>'; | |
} | |
if ( $family_data['family_diagnosis'] ) { | |
echo '<div class="location"><h4>When were they first diagnosed?</h4> ' . esc_attr( $family_data['family_diagnosis'] ) . '</div></br>'; | |
} | |
if ( $family_data['family_challenges'] ) { | |
echo '<div class="location"><h4>What are the three biggest challenges you face each week?</h4> ' . esc_attr( $family_data['family_challenges'] ) . '</div></br>'; | |
} | |
if ( $family_data['family_advice'] ) { | |
echo '<div class="location"><h4>What advice would you give to a family with a newly-diagnosed family member?</h4> ' . esc_attr( $family_data['family_advice'] ) . '</div></br>'; | |
} | |
if ( $family_data['family_quote'] ) { | |
echo '<div class="location"><h4>Do you have a favorite quote or memory of your child that you’d like to share?</h4> ' . esc_attr( $family_data['family_quote'] ) . '</div>'; | |
} | |
echo '</div>'; | |
} | |
} | |
/** Family Excerpts | |
* | |
* Display an excerpt of family profiles | |
* | |
* @author Angie Meeker | |
* @uses Advanced Custom Fields | |
*/ | |
remove_action( 'genesis_entry_content', 'family_excerpt' ); | |
add_action( 'genesis_entry_content', 'family_excerpt' ); | |
function family_excerpt() { | |
// Return if CPT family | |
if ( is_post_type_archive( 'family_profiles' ) ) | |
// Store the family advice data | |
$family_excerpt_data = array( | |
'family_advice' => get_field( 'family_advice'), | |
); | |
// Only output if we have family advice profile data | |
if( $family_excerpt_data ) { | |
echo '<div class="">'; | |
if ( $family_excerpt_data['family_advice'] ) { | |
echo '<div class="location">' . esc_attr( $family_excerpt_data['family_advice'] ) . '</div>'; | |
} | |
echo '</div>'; | |
} | |
if ( '' != $family_excerpt_data ) { | |
$text = strip_shortcodes( $text ); | |
$text = apply_filters('the_excerpt', $text); | |
$text = strip_tags($text,'<p><a><em><strong><img><b><h4><br></br>'); | |
$text = str_replace(']]>', ']]>', $text); | |
$excerpt_length = 400; // 20 words | |
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); | |
} | |
return apply_filters('the_excerpt', $text); | |
} | |
add_action( 'genesis_before_loop', 'sk_full_content_testimonials_archive' ); | |
function sk_full_content_testimonials_archive() { | |
if ( is_post_type_archive( 'centers' ) ) { | |
add_filter( 'genesis_pre_get_option_content_archive', 'sk_do_full_content' ); | |
add_filter( 'genesis_pre_get_option_content_archive_limit', 'sk_no_content_limit' ); | |
} | |
} | |
// Set the content archives to full | |
function sk_do_full_content() { | |
return 'full'; | |
} | |
// Make sure the content limit isn't set | |
function sk_no_content_limit() { | |
return '0'; | |
} | |
/** | |
* | |
* Display a centers profile using | |
* Genesis column classes and ACF. | |
* | |
* @author Angie Meeker | |
* @uses Advanced Custom Fields | |
*/ | |
add_action( 'genesis_entry_content', 'centers_profiles', 12 ); | |
function centers_profiles() { | |
if ( is_post_type_archive('centers-of-excellence') ) | |
return; | |
// Store the tour data | |
$centers_data = array( | |
'centers_leader' => get_field('centers_leader'), | |
'centers_email' => get_field('centers_email'), | |
'centers_phone' => get_field('centers_phone'), | |
'centers_address' => get_field('centers_address'), | |
'centers_city_state' => get_field('centers_city_state'), | |
'centers_country' => get_field('centers_country'), | |
); | |
if ($centers_data['centers_leader'] != '' || | |
$centers_data['centers_email'] != '' || | |
$centers_data['centers_phone'] != '' || | |
$centers_data['centers_address'] != '' || | |
$centers_data['centers_city_state'] != '' || | |
$centers_data['centers_country'] != '' ) { | |
echo '<div class="tour-wrap">'; | |
if ( $centers_data['centers_leader'] ) { | |
echo '<div class="location"><strong>Medical Leader: </strong> ' . esc_attr( $centers_data['centers_leader'] ) . '</div>'; | |
} | |
if ( $centers_data['centers_email'] ) { | |
echo '<div class="location"><strong>Email: </strong> ' . esc_attr( $centers_data['centers_email'] ) . '</div>'; | |
} | |
if ( $centers_data['centers_phone'] ) { | |
echo '<div class="location"><strong>Phone: </strong> ' . esc_attr( $centers_data['centers_phone'] ) . '</div>'; | |
} | |
if ( $centers_data['centers_address'] ) { | |
echo '<div class="location"><strong>Address:</strong> ' . esc_attr( $centers_data['centers_address'] ) . '</div>'; | |
} | |
if ( $centers_data['centers_city_state'] ) { | |
echo '<div class="location">' . esc_attr( $centers_data['centers_city_state'] ) . '</div>'; | |
} | |
if ( $centers_data['centers_country'] ) { | |
echo '<div class="location">' . esc_attr( $centers_data['centers_country'] ) . '</div>'; | |
} | |
echo '</div>'; | |
} | |
} | |
/** | |
* End functions block | |
*/ | |
} | |
/// end class | |
} | |
// Instantiate the class | |
$Theme_Functions_Plugin = Theme_Functions_Plugin::getInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment