├── README.md ├── template-section-label.php ├── js ├── admin.js ├── display-json-feeds.js └── custom.js ├── css └── admin.css ├── 404.php ├── parts ├── featured-images.php └── headers.php ├── style.css ├── tribe-events └── default-template.php ├── includes ├── shortcode-events.php ├── plugin-color-palette.php └── plugin-headlines.php ├── spine └── site-navigation.php └── functions.php /README.md: -------------------------------------------------------------------------------- 1 | # Carson College of Business WordPress Theme -------------------------------------------------------------------------------- /template-section-label.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |
8 | 9 |
10 | 11 |
12 | 13 |
14 |

Perhaps searching can help.

15 | 16 |
17 | 18 |
19 | 20 |
21 |
22 | 23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /parts/featured-images.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 18 | -------------------------------------------------------------------------------- /js/display-json-feeds.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | if ( $('.home' ).length > 0 ) { 3 | $('.wsuwp-json-content' ).each(function(){ 4 | var container = $(this); 5 | var source_data_obj = $(this ).data('source'); 6 | var source_data = window[source_data_obj]; 7 | 8 | var json_html = ''; 13 | container.append( json_html ); 14 | }); 15 | } else { 16 | $('.wsuwp-json-content' ).each(function(){ 17 | var container = $(this); 18 | var source_data_obj = $(this ).data('source'); 19 | var source_data = window[source_data_obj]; 20 | 21 | for ( var item in source_data ) { 22 | var cob_excerpt = source_data[item ].content.split(''); 23 | container.append( '

' + source_data[item].title + '

' + cob_excerpt[0] + '
'); 24 | } 25 | }); 26 | } 27 | 28 | }(jQuery)); -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: Carson College of Business 3 | Theme URI: https://business.wsu.edu/ 4 | Description: A WSU Spine child theme for the Carson College of Business 5 | Author: WSU University Communications 6 | Author URI: https://web.wsu.edu/ 7 | Template: spine 8 | Version: 1.0.21 9 | */ 10 | 11 | .fluidbox { 12 | outline: none; 13 | } 14 | .hidden { 15 | display: none; 16 | } 17 | .fluidbox-overlay { 18 | background-color: rgba(255,255,255,.85); 19 | cursor: pointer; 20 | cursor: -webkit-zoom-out; 21 | cursor: -moz-zoom-out; 22 | opacity: 0; 23 | position: fixed; 24 | top: 0; 25 | left: 0; 26 | bottom: 0; 27 | right: 0; 28 | transition: all .25s ease-in-out; 29 | } 30 | .fluidbox-wrap { 31 | background-position: center center; 32 | background-size: cover; 33 | margin: 0 auto; 34 | position: relative; 35 | transition: all .25s ease-in-out; 36 | } 37 | .fluidbox-ghost { 38 | background-size: 100% 100%; 39 | background-position: center center; 40 | position: absolute; 41 | transition: all .25s ease-in-out; 42 | } 43 | .fluidbox-closed .fluidbox-ghost { 44 | -webkit-transition-property: top, left, opacity, -webkit-transform; 45 | -moz-transition-property: top, left, opacity, -moz-transform; 46 | -o-transition-property: top, left, opacity, -o-transform; 47 | transition-property: top, left, opacity, transform; 48 | transition-delay: 0, 0, .25s, 0; 49 | } 50 | .fluidbox-closed .fluidbox-wrap img { 51 | transition-property: opacity; 52 | transition-delay: .25s; 53 | transition-duration: 0s; 54 | } 55 | -------------------------------------------------------------------------------- /tribe-events/default-template.php: -------------------------------------------------------------------------------- 1 | 5 |
6 | 7 | 13 |
14 |
15 | 16 | ' ); ?> 17 | ' ); ?> 18 | 19 |
20 |
21 | 'cob-header', 24 | 'menu' => 'cob-header', 25 | 'container' => 'nav', 26 | 'container_class' => 'cob-headernav', 27 | 'container_id' => 'cob-headernav', 28 | 'menu_class' => null, 29 | 'menu_id' => null, 30 | 'echo' => true, 31 | 'items_wrap' => '
    %3$s
', 32 | 'depth' => 0, 33 | ); 34 | wp_nav_menu( $header_menu_args ); 35 | unset( $header_menu_args ); 36 | ?> 37 |
38 |
39 |
40 |

Calendar of Events

41 |
42 |
43 | 44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 | 52 |
53 |
54 |
55 | 56 |
57 | 7 |
8 |
9 | 10 | ' ); ?> 11 | ' ); ?> 12 | 13 |
14 |
15 | 'cob-header', 18 | 'menu' => 'cob-header', 19 | 'container' => 'nav', 20 | 'container_class' => 'cob-headernav', 21 | 'container_id' => 'cob-headernav', 22 | 'menu_class' => null, 23 | 'menu_id' => null, 24 | 'echo' => true, 25 | 'items_wrap' => '', 26 | 'depth' => 0, 27 | ); 28 | wp_nav_menu( $header_menu_args ); 29 | unset( $header_menu_args ); 30 | ?> 31 |
32 |
33 |
34 | 35 |

36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 |
48 |
49 | 50 | -------------------------------------------------------------------------------- /includes/shortcode-events.php: -------------------------------------------------------------------------------- 1 | 'full', 11 | 'headline_wrap' => 'h3', 12 | 'category' => '', 13 | 'count' => 10, 14 | ); 15 | $atts = shortcode_atts( $default_atts, $atts ); 16 | 17 | if ( ! in_array( $atts['headline_wrap'], array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ) ) ) { 18 | $atts['headline_wrap'] = 'h3'; 19 | } 20 | 21 | $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => absint( $atts['count'] ) ); 22 | 23 | if ( '' !== $atts['category'] ) { 24 | $args['tax_query'] = array( 25 | array( 26 | 'taxonomy' => 'tribe_events_cat', 27 | 'field' => 'slug', 28 | 'terms' => $atts['category'], 29 | ), 30 | ); 31 | } 32 | 33 | $events = new WP_Query( $args ); 34 | 35 | if ( 'headlines' === $atts['display'] ) { 36 | ob_start(); 37 | 38 | echo ''; 45 | 46 | $content = ob_get_contents(); 47 | ob_end_clean(); 48 | 49 | } elseif ( 'sidebar' === $atts['display'] ) { 50 | ob_start(); 51 | 52 | echo '
'; 53 | while ( $events->have_posts() ) { 54 | $events->the_post(); 55 | echo '
'; 56 | echo '<' . $atts['headline_wrap'] . '>' . get_the_title() . ''; 57 | echo tribe_events_event_schedule_details(); 58 | echo '

' . get_the_excerpt() . '

'; 59 | echo '
'; 60 | } 61 | echo '
'; 62 | 63 | $content = ob_get_contents(); 64 | ob_end_clean(); 65 | } else { 66 | ob_start(); 67 | ?> 68 |
69 | 70 | have_posts() ) : $events->the_post(); ?> 71 | 72 | 73 | 74 | 75 | 76 |
77 | 78 |
79 | 80 | 81 | 82 |
83 | 2 | path && '/dividend/' !== $nav_site->path && '/weska/' !== $nav_site->path && '/celebratecarson/' !== $nav_site->path ) { 11 | $switch_site = get_blog_details( array( 'domain' => $nav_site->domain, 'path' => '/' ) ); 12 | switch_to_blog( $switch_site->blog_id ); 13 | $output_menu_script = true; 14 | } 15 | 16 | } 17 | 18 | 19 | 20 | if ( function_exists( 'bu_navigation_display_primary' ) ) { 21 | $bu_nav_args = array( 22 | 'post_types' => array( 'page' ), // post types to display 23 | 'include_links' => true, // whether or not to include BU Navigation links with pages 24 | 'dive' => true, // whether or not to display descendants 25 | 'depth' => 4, // how many levels of descendants to display 26 | 'max_items' => 99, // how many items to display per list 27 | 'container_tag' => 'ul', // HTML tag to use for menu container 28 | 'container_id' => '', // HTML ID attribute of menu container 29 | 'container_class' => '', // HTML class attributes for menu container 30 | 'item_tag' => 'li', // HTML tag to use for individual menu items 31 | 'identify_top' => false, // If set to true, uses post name as HTML ID attribute for top level posts 32 | 'whitelist_top' => null, // optional string or array of post names to whitelist for top level 33 | 'echo' => 1 // whether to display immediately or return 34 | ); 35 | remove_filter( 'bu_navigation_filter_pages', 'bu_navigation_filter_pages_ancestors' ); 36 | bu_navigation_display_primary( $bu_nav_args ); 37 | add_filter( 'bu_navigation_filter_pages', 'bu_navigation_filter_pages_ancestors' ); 38 | } else { 39 | $spine_site_args = array( 40 | 'theme_location' => 'site', 41 | 'menu' => 'site', 42 | 'container' => false, 43 | 'container_class' => false, 44 | 'container_id' => false, 45 | 'menu_class' => null, 46 | 'menu_id' => null, 47 | 'items_wrap' => '', 48 | 'depth' => 5, 49 | ); 50 | wp_nav_menu( $spine_site_args ); 51 | } 52 | 53 | if ( ms_is_switched() ) { 54 | restore_current_blog(); 55 | } 56 | ?> 57 | 58 | 59 | 60 | 71 | array( 'name' => 'Default (Orange)', 'hex' => '#f6861f' ), 10 | 'green' => array( 'name' => 'Green', 'hex' => '#c6d02e' ), 11 | 'blue-1' => array( 'name' => 'Blue (One)', 'hex' => '#00a5bd' ), 12 | 'blue-2' => array( 'name' => 'Blue (Two)', 'hex' => '#82a9af' ), 13 | 'blue-3' => array( 'name' => 'Blue (Three)', 'hex' => '#aec7cd' ), 14 | 'yellow' => array( 'name' => 'Yellow', 'hex' => '#ffb81c' ), 15 | 'beige-1' => array( 'name' => 'Beige (One)', 'hex' => '#ccc4a2' ), 16 | 'beige-2' => array( 'name' => 'Beige (Two)', 'hex' => '#a9a387' ), 17 | 'wazzu-1' => array( 'name' => 'Wazzu (One)', 'hex' => '#8d959a' ), 18 | 'wazzu-2' => array( 'name' => 'Wazzu (Two)', 'hex' => '#5b6770' ), 19 | ); 20 | 21 | /** 22 | * @var string The meta key used to track a page's color palette. 23 | */ 24 | public $color_palette_meta_key = '_wsu_cob_color_palette'; 25 | 26 | /** 27 | * Setup hooks. 28 | */ 29 | public function __construct() { 30 | add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); 31 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); 32 | add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); 33 | add_filter( 'body_class', array( $this, 'add_body_class' ), 11 ); 34 | } 35 | 36 | /** 37 | * Configure the meta boxes to display for capturing palette. 38 | * 39 | * @param string $post_type The current post's post type. 40 | */ 41 | public function add_meta_boxes( $post_type ) { 42 | if ( 'page' === $post_type ) { 43 | add_meta_box( 'wsu_cob_color_palette', 'Select Color Palette', array( $this, 'display_color_palette_meta_box' ), null, 'normal', 'default' ); 44 | } 45 | } 46 | 47 | /** 48 | * Display the meta box to capture color palette information. 49 | * 50 | * @param WP_Post $post 51 | */ 52 | public function display_color_palette_meta_box( $post ) { 53 | $current_palette = get_post_meta( $post->ID, $this->color_palette_meta_key, true ); 54 | 55 | if ( ! array_key_exists( $current_palette, $this->color_palettes ) ) { 56 | $current_palette = 'default'; 57 | } 58 | 59 | ?> 60 | 74 | 75 | id ) { 83 | wp_enqueue_style( 'wsu-cob-palette-admin', get_stylesheet_directory_uri() . '/css/admin.css', array(), wsu_cob_script_version() ); 84 | wp_enqueue_script( 'wsu-cob-palette-admin-js', get_stylesheet_directory_uri() . '/js/admin.js', array( 'jquery' ), wsu_cob_script_version() ); 85 | } 86 | 87 | } 88 | 89 | /** 90 | * Assign the selected color palette to the page. 91 | * 92 | * @param int $post_id The ID of the post being saved. 93 | * @param WP_Post $post The full post object being saved. 94 | */ 95 | public function save_post( $post_id, $post ) { 96 | if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { 97 | return; 98 | } 99 | 100 | if ( 'page' !== $post->post_type ) { 101 | return; 102 | } 103 | 104 | if ( 'auto-draft' === $post->post_status ) { 105 | return; 106 | } 107 | 108 | if ( ! isset( $_POST['cob_wsu_palette'] ) || ! array_key_exists( $_POST['cob_wsu_palette'], $this->color_palettes ) ) { 109 | return; 110 | } 111 | 112 | $new_palette = sanitize_key( $_POST['cob_wsu_palette'] ); 113 | update_post_meta( $post_id, $this->color_palette_meta_key, $new_palette ); 114 | } 115 | 116 | /** 117 | * Assign a color palette to a page's view. 118 | * 119 | * @param array $classes List of classes to assign to this view's body element. 120 | * 121 | * @return array Modified list of classes. 122 | */ 123 | public function add_body_class( $classes ) { 124 | if ( is_singular( 'page' ) ) { 125 | $palette = get_post_meta( get_the_ID(), $this->color_palette_meta_key, true ); 126 | if ( ! array_key_exists( $palette, $this->color_palettes ) ) { 127 | $palette = 'default'; 128 | } 129 | 130 | // Only apply a master palette class to the body if no background image is present. 131 | if ( '' === spine_has_background_image() ) { 132 | $classes[] = 'cob-palette-' . $palette; 133 | } 134 | 135 | // Always apply a palette class to the body for text. 136 | $classes[] = 'cob-palette-text-' . $palette; 137 | } else { 138 | $classes[] = 'cob-palette-default'; 139 | $classes[] = 'cob-palette-text-default'; 140 | } 141 | 142 | return $classes; 143 | } 144 | 145 | public function get_color_palette( $post_id ) { 146 | return get_post_meta( $post_id, $this->color_palette_meta_key, true ); 147 | } 148 | } 149 | $wsu_cob_color_palette = new WSU_COB_Color_Palette(); 150 | 151 | function cob_get_page_color_palette( $post_id = 0 ) { 152 | global $wsu_cob_color_palette; 153 | 154 | $post_id = absint( $post_id ); 155 | 156 | if ( 0 === $post_id ) { 157 | $post_id = get_the_ID(); 158 | } 159 | 160 | return $wsu_cob_color_palette->get_color_palette( $post_id ); 161 | } -------------------------------------------------------------------------------- /js/custom.js: -------------------------------------------------------------------------------- 1 | /** MIT Licensed FontDetect - https://github.com/JenniferSimonds/FontDetect */ 2 | FontDetect=function(){function e(){if(!n){n=!0;var e=document.body,t=document.body.firstChild,i=document.createElement("div");i.id="fontdetectHelper",r=document.createElement("span"),r.innerText="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",i.appendChild(r),e.insertBefore(i,t),i.style.position="absolute",i.style.visibility="hidden",i.style.top="-200px",i.style.left="-100000px",i.style.width="100000px",i.style.height="200px",i.style.fontSize="100px"}}function t(e,t){return e instanceof Element?window.getComputedStyle(e).getPropertyValue(t):window.jQuery?$(e).css(t):""}var n=!1,i=["serif","sans-serif","monospace","cursive","fantasy"],r=null;return{onFontLoaded:function(t,i,r,o){if(t){var s=o&&o.msInterval?o.msInterval:100,a=o&&o.msTimeout?o.msTimeout:2e3;if(i||r){if(n||e(),this.isFontLoaded(t))return void(i&&i(t));var l=this,f=(new Date).getTime(),d=setInterval(function(){if(l.isFontLoaded(t))return clearInterval(d),void i(t);var e=(new Date).getTime();e-f>a&&(clearInterval(d),r&&r(t))},s)}}},isFontLoaded:function(t){var o=0,s=0;n||e();for(var a=0;a0&&o!=s)return!1;s=o}return!0},whichFont:function(e){for(var n=t(e,"font-family"),r=n.split(","),o=r.shift();o;){o=o.replace(/^\s*['"]?\s*([^'"]*)\s*['"]?\s*$/,"$1");for(var s=0;s",{"class":"fluidbox-overlay",css:{"z-index":c.stackIndex}});var f,d=this,e=a(window),g=function(){a(".fluidbox-opened").trigger("click")},h=function(a){var b=a.find("img"),d=a.find(".fluidbox-ghost"),g=a.find(".fluidbox-wrap"),h=a.data(),i=0,j=0;b.data().imgRatio=h.natWidth/h.natHeight;var k,l,m;if(f>b.data().imgRatio)i=h.natHeighth.imgRatio?e.height()*c.viewportFill/b.height():e.width()*c.viewportFill/b.width()}if(f=e.width()/e.height(),a.hasClass("fluidbox")){var b=a.find("img"),d=a.find(".fluidbox-ghost"),g=a.find(".fluidbox-wrap"),h=b.data();i(),b.load(i)}},k=function(b){if(a(this).hasClass("fluidbox")){var d=a(this),e=a(this).find("img"),f=a(this).find(".fluidbox-ghost"),g=a(this).find(".fluidbox-wrap"),i={};0!==a(this).data("fluidbox-state")&&a(this).data("fluidbox-state")?(d.data("fluidbox-state",0).removeClass("fluidbox-opened").addClass("fluidbox-closed"),i.open&&window.clearTimeout(i.open),i.close=window.setTimeout(function(){a(".fluidbox-overlay").remove(),g.css({"z-index":c.stackIndex-c.stackIndexDelta})},10),a(".fluidbox-overlay").css({opacity:0}),f.css({transform:"translate(0,0) scale(1)",opacity:0,top:e.offset().top-g.offset().top+parseInt(e.css("borderTopWidth"))+parseInt(e.css("paddingTop")),left:e.offset().left-g.offset().left+parseInt(e.css("borderLeftWidth"))+parseInt(e.css("paddingLeft"))}),e.css({opacity:1})):a("",{src:e.attr("src")}).load(function(){a("",{src:d.attr("href")}).load(function(){d.data("natWidth",a(this)[0].naturalWidth).data("natHeight",a(this)[0].naturalHeight),d.append($fbOverlay).data("fluidbox-state",1).removeClass("fluidbox-closed").addClass("fluidbox-opened"),i.close&&window.clearTimeout(i.close),i.open=window.setTimeout(function(){a(".fluidbox-overlay").css({opacity:1})},10),a(".fluidbox-wrap").css({zIndex:c.stackIndex-c.stackIndexDelta-1}),g.css({"z-index":c.stackIndex+c.stackIndexDelta}),f.css({"background-image":"url("+e.attr("src")+")",opacity:1}),e.css({opacity:0}),f.css({"background-image":"url("+d.attr("href")+")"}),h(d)})}),b.preventDefault()}};c.closeTrigger&&a.each(c.closeTrigger,function(b){var d=c.closeTrigger[b];"window"!=d.selector?"document"==d.selector?d.keyCode?a(document).on(d.event,function(a){a.keyCode==d.keyCode&&g()}):a(document).on(d.event,g):a(document).on(d.event,c.closeTrigger[b].selector,g):e.on(d.event,g)}),d.each(function(){if(a(this).is("a")&&1===a(this).children().length&&a(this).children().is("img")&&"none"!==a(this).css("display")&&"none"!==a(this).parents().css("display")){var d=a("
",{"class":"fluidbox-wrap",css:{"z-index":c.stackIndex-c.stackIndexDelta}}),e=a(this);e.addClass("fluidbox").wrapInner(d).find("img").css({opacity:1}).after('
').each(function(){var b=a(this);b.width()>0&&b.height()>0?(j(e),e.click(k)):b.load(function(){j(e),e.click(k)})})}});var l=function(){i();var b=a("a.fluidbox.fluidbox-opened");b.length>0&&h(b)};return c.debounceResize?a(window).smartresize(l):a(window).resize(l),d}}(jQuery); 6 | 7 | (function($, FontDetect, window){ 8 | 9 | var view_data = {}; 10 | 11 | var incrementor = { 12 | background: 4.5, 13 | margin: 6.25, 14 | opacity: 500, 15 | cta_opacity: 200 16 | }; 17 | 18 | var is_ios = function() { 19 | return ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false ); 20 | }; 21 | 22 | var setup_header = function() { 23 | view_data.last_position = $(window ).scrollTop(); 24 | view_data.headline_container = $('.cob-headline-container'); 25 | view_data.headline_container_height = view_data.headline_container.height(); 26 | view_data.main_header = $('.main-header'); 27 | view_data.main_header_height = view_data.main_header.height(); 28 | view_data.call_to_action = $('.page-call-to-action'); 29 | }; 30 | 31 | var setup_scroll = function() { 32 | view_data.main_header.css( { 'height' : view_data.main_header_height } ); 33 | 34 | // Main headline 35 | var page_position = $(this ).scrollTop(); 36 | 37 | var background_position = 0 + ( page_position / incrementor.background ); 38 | var margin_top = 100 + ( page_position / incrementor.margin ); 39 | var header_opacity = 1 - ( page_position / incrementor.opacity ); 40 | var cta_opacity = 1 - ( page_position / incrementor.cta_opacity ); 41 | 42 | view_data.main_header.css( { 'background-position-y' : background_position } ); 43 | view_data.headline_container.css( { 'margin-top' : margin_top, 'opacity' : header_opacity } ); 44 | view_data.call_to_action.css( { 'opacity' : cta_opacity } ); 45 | 46 | $(window).on( 'scroll', function() { 47 | var page_position = $(this).scrollTop(); 48 | 49 | if ( page_position > view_data.main_header_height ) { 50 | return; 51 | } 52 | 53 | if ( page_position > view_data.last_position ) { 54 | // scrolling down 55 | background_position = background_position + ( ( page_position - view_data.last_position ) / incrementor.background ); 56 | margin_top = margin_top + ( ( page_position - view_data.last_position ) / incrementor.margin ); 57 | header_opacity = header_opacity - ( ( page_position - view_data.last_position ) / incrementor.opacity ); 58 | cta_opacity = cta_opacity - ( ( page_position - view_data.last_position ) / incrementor.cta_opacity ); 59 | } else { 60 | // scrolling up 61 | background_position = background_position - ( ( view_data.last_position - page_position ) / incrementor.background ); 62 | margin_top = margin_top - ( ( view_data.last_position - page_position ) / incrementor.margin ); 63 | header_opacity = header_opacity + ( ( view_data.last_position - page_position ) / incrementor.opacity ); 64 | cta_opacity = cta_opacity + ( ( view_data.last_position - page_position ) / incrementor.cta_opacity ); 65 | } 66 | view_data.last_position = page_position; 67 | 68 | view_data.main_header.css( { 'background-position-y' : background_position } ); 69 | view_data.headline_container.css( { 'margin-top' : margin_top, 'opacity' : header_opacity } ); 70 | view_data.call_to_action.css( { 'opacity' : cta_opacity } ); 71 | }); 72 | }; 73 | 74 | var on_font_loaded = function() { 75 | setup_header(); 76 | setup_scroll(); 77 | }; 78 | 79 | $(document).ready(function(){ 80 | if ( ! is_ios() && 0 === $('.home' ).length && 0 !== $('.has-background-image' ).length ) { 81 | FontDetect.onFontLoaded( 'Open Sans Condensed', on_font_loaded, function() { console.log('did not load' ) }, {msTimeout: 3000}); 82 | } 83 | 84 | // Add Fluidbox to any gallery images 85 | $(".gallery-item a").fluidbox({ stackIndex: 99999 }); 86 | }); 87 | }(jQuery, FontDetect, window)); -------------------------------------------------------------------------------- /includes/plugin-headlines.php: -------------------------------------------------------------------------------- 1 | ID, $this->headline_meta_key, true ); 54 | $subtitle = get_post_meta( $post->ID, $this->subtitle_meta_key, true ); 55 | $call_to_action = get_post_meta( $post->ID, $this->call_to_action_meta_key, true ); 56 | $call_to_action_url = get_post_meta( $post->ID, $this->call_to_action_url_meta_key, true ); 57 | 58 | wp_nonce_field( 'cob-headlines-nonce', '_cob_headlines_nonce' ); 59 | ?> 60 | 61 | 62 |

Primary headline to be used for the page.

63 | 64 | 65 | 66 |

Subtitle to be used on various views throughout the theme.

67 | 68 | 69 | 70 |

Call to action text for use as a guide to this page.

71 | 72 | 73 | 74 | post_type, array( 'page', 'post' ) ) ) { 89 | return; 90 | } 91 | 92 | if ( 'auto-draft' === $post->post_status ) { 93 | return; 94 | } 95 | 96 | if ( ! isset( $_POST['_cob_headlines_nonce'] ) || false === wp_verify_nonce( $_POST['_cob_headlines_nonce'], 'cob-headlines-nonce' ) ) { 97 | return; 98 | } 99 | 100 | if ( isset( $_POST['cob_call_to_action'] ) ) { 101 | update_post_meta( $post_id, $this->call_to_action_meta_key, wp_kses_post( $_POST['cob_call_to_action'] ) ); 102 | } 103 | 104 | if ( isset( $_POST['cob_call_to_action_url'] ) && ! empty( trim( $_POST['cob_call_to_action_url'] ) ) ) { 105 | update_post_meta( $post_id, $this->call_to_action_url_meta_key, esc_url_raw( $_POST['cob_call_to_action_url'] ) ); 106 | } elseif ( ! isset( $_POST['cob_call_to_action_url'] ) || empty( trim( $_POST['cob_call_to_action_url'] ) ) ) { 107 | delete_post_meta( $post_id, $this->call_to_action_url_meta_key ); 108 | } 109 | 110 | if ( isset( $_POST['cob_subtitle'] ) ) { 111 | update_post_meta( $post_id, $this->subtitle_meta_key, wp_kses_post( $_POST['cob_subtitle'] ) ); 112 | } 113 | 114 | if ( isset( $_POST['cob_page_headline'] ) ) { 115 | update_post_meta( $post_id, $this->headline_meta_key, strip_tags( $_POST['cob_page_headline'], '
' ) ); 116 | } 117 | } 118 | 119 | /** 120 | * Display a content block, intended for the home page, that links through to the 121 | * page it represents. 122 | * 123 | * @param array $atts List of attributes to apply to the shortcode. 124 | * 125 | * @return string HTML content to display. 126 | */ 127 | public function display_home_headline( $atts ) { 128 | $atts = shortcode_atts( array( 'id' => 0, 'headline' => '', 'subtitle' => '', 'background' => '', 'palette' => '', 'link' => 'page', 'cta' => '', 'link_classes' => '' ), $atts ); 129 | 130 | if ( ! isset( $atts['id'] ) || empty( absint( $atts['id'] ) ) ) { 131 | $post = false; 132 | } else { 133 | $post = get_post( absint( $atts['id'] ) ); 134 | } 135 | 136 | if ( ! $post && empty( $atts['headline'] ) ) { 137 | $headline = ''; 138 | } elseif ( '' !== $atts['headline'] ) { 139 | $headline = $atts['headline']; 140 | } else { 141 | $headline = $this->get_headline( $post->ID ); 142 | } 143 | 144 | if ( ! $post && empty( $atts['subtitle'] ) ) { 145 | $subtitle = ''; 146 | } elseif ( '' !== $atts['subtitle'] ) { 147 | $subtitle = $atts['subtitle']; 148 | } else { 149 | $subtitle = $this->get_subtitle( $post->ID ); 150 | } 151 | 152 | if ( ! empty( $atts['background'] ) ) { 153 | $background_image = $atts['background']; 154 | } elseif ( $post && class_exists( 'MultiPostThumbnails' ) ) { 155 | $background_image = MultiPostThumbnails::get_post_thumbnail_url( $post->post_type, 'background-image', $post->ID, 'spine-xlarge_size' ); 156 | } else { 157 | $background_image = false; 158 | } 159 | 160 | if ( ! $post && empty( $atts['palette'] ) ) { 161 | $atts['palette'] = 'default'; 162 | } elseif ( '' !== $atts['palette'] ) { 163 | $palette = $atts['palette']; 164 | } else { 165 | $palette = cob_get_page_color_palette( $post->ID ); 166 | } 167 | 168 | if ( $background_image ) { 169 | $class = 'headline-has-background'; 170 | $style = 'style="background-image: url(' . esc_url( $background_image ) .');"'; 171 | } else { 172 | $class = 'cob-palette-block-' . $palette; 173 | $style = ''; 174 | } 175 | 176 | if ( $post && 'page' === $atts['link'] ) { 177 | $page_url = get_the_permalink( $post->ID ); 178 | } elseif ( 'none' === $atts['link'] || ( ! $post && 'page' === $atts['link'] ) ) { 179 | $page_url = false; 180 | } else { 181 | $page_url = $atts['link']; 182 | } 183 | 184 | if ( ! empty( $atts['cta'] ) ) { 185 | $call_to_action = '
' . sanitize_text_field( $atts['cta'] ) . '
'; 186 | } else { 187 | $call_to_action = ''; 188 | } 189 | 190 | $link_classes = ( ! empty( $atts['link_classes'] ) ) ? $atts['link_classes'] : ''; 191 | 192 | $content = ''; 193 | 194 | if ( $page_url ) { 195 | $content = ''; 196 | } 197 | 198 | $content .= '

' . strip_tags( $headline, '
' ) . '

' . strip_tags( $subtitle, '
' ) . '
' . $call_to_action . '
'; 199 | 200 | if ( $page_url ) { 201 | $content .= '
'; 202 | } 203 | 204 | return $content; 205 | } 206 | 207 | /** 208 | * Retrieve the assigned headline of a page. 209 | * 210 | * @param $post_id 211 | * 212 | * @return mixed 213 | */ 214 | public function get_headline( $post_id ) { 215 | return get_post_meta( $post_id, $this->headline_meta_key, true ); 216 | } 217 | 218 | /** 219 | * Retrieve the assigned subtitle of a page. 220 | * 221 | * @param $post_id 222 | * 223 | * @return mixed 224 | */ 225 | public function get_subtitle( $post_id ) { 226 | return get_post_meta( $post_id, $this->subtitle_meta_key, true ); 227 | } 228 | 229 | /** 230 | * Retrieve the assigned call to action of a page. 231 | * 232 | * @param $post_id 233 | * 234 | * @return mixed 235 | */ 236 | public function get_call_to_action( $post_id ) { 237 | return get_post_meta( $post_id, $this->call_to_action_meta_key, true ); 238 | } 239 | 240 | /** 241 | * Retrieve the assigned URL for the call to action of a page. 242 | * 243 | * @param $post_id 244 | * 245 | * @return mixed 246 | */ 247 | public function get_call_to_action_url( $post_id ) { 248 | return get_post_meta( $post_id, $this->call_to_action_url_meta_key, true ); 249 | } 250 | } 251 | $wsu_cob_headlines = new WSU_COB_Headlines(); 252 | 253 | /** 254 | * Wrapper to retrieve an assigned page headline. Will fallback to the current page if 255 | * a post ID is not specified. 256 | * 257 | * @param int $post_id 258 | * 259 | * @return mixed 260 | */ 261 | function cob_get_page_headline( $post_id = 0 ) { 262 | global $wsu_cob_headlines; 263 | 264 | if ( is_404() ) { 265 | return "We're sorry. We can't find the page you're looking for."; 266 | } 267 | 268 | $post_id = absint( $post_id ); 269 | 270 | if ( 0 === $post_id ) { 271 | $post_id = get_the_ID(); 272 | } 273 | 274 | return $wsu_cob_headlines->get_headline( $post_id ); 275 | } 276 | 277 | /** 278 | * Wrapper to retrieve an assigned page subtitle. Will fallback to the current page if 279 | * a post ID is not specified. 280 | * 281 | * @param int $post_id 282 | * 283 | * @return mixed 284 | */ 285 | function cob_get_page_subtitle( $post_id = 0 ) { 286 | global $wsu_cob_headlines; 287 | 288 | if ( is_404() ) { 289 | return false; 290 | } 291 | 292 | $post_id = absint( $post_id ); 293 | 294 | if ( 0 === $post_id ) { 295 | $post_id = get_the_ID(); 296 | } 297 | 298 | return $wsu_cob_headlines->get_subtitle( $post_id ); 299 | } 300 | 301 | /** 302 | * Wrapper to retrieve an assigned page call to action. Will fallback to the current page 303 | * if a post ID is not specified. 304 | * 305 | * @param int $post_id 306 | * 307 | * @return mixed 308 | */ 309 | function cob_get_page_call_to_action( $post_id = 0 ) { 310 | global $wsu_cob_headlines; 311 | 312 | if ( is_404() ) { 313 | return false; 314 | } 315 | 316 | $post_id = absint( $post_id ); 317 | 318 | if ( 0 === $post_id ) { 319 | $post_id = get_the_ID(); 320 | } 321 | 322 | return $wsu_cob_headlines->get_call_to_action( $post_id ); 323 | } 324 | 325 | /** 326 | * Wrapper to retrieve an assigned URL for a page's call to action. Will fallback to the 327 | * current page if a post ID is not specified. 328 | * 329 | * @param int $post_id 330 | * 331 | * @return mixed 332 | */ 333 | function cob_get_page_call_to_action_url( $post_id = 0 ) { 334 | global $wsu_cob_headlines; 335 | 336 | if ( is_404() ) { 337 | return false; 338 | } 339 | 340 | $post_id = absint( $post_id ); 341 | 342 | if ( 0 === $post_id ) { 343 | $post_id = get_the_ID(); 344 | } 345 | 346 | return $wsu_cob_headlines->get_call_to_action_url( $post_id ); 347 | } 348 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | tribe_is_event ) && true === $wp_query->tribe_is_event ) { 46 | if ( isset( $page->url ) && home_url( '/news-events/calendar/' ) === $page->url ) { 47 | $item_classes[] = 'active'; 48 | } 49 | 50 | if ( isset( $page->url ) && home_url( '/news-events/' ) === $page->url ) { 51 | $item_classes[] = 'active'; 52 | } 53 | } 54 | 55 | return $item_classes; 56 | } 57 | 58 | add_filter( 'wsuwp_content_syndicate_json', 'cob_content_syndication_display', 10, 2 ); 59 | /** 60 | * Add a container to the output of the JSON data. 61 | * 62 | * @param $content 63 | * @param $atts 64 | * 65 | * @return string 66 | */ 67 | function cob_content_syndication_display( $content, $atts ) { 68 | wp_enqueue_script( 'cob-display-json-feeds', get_stylesheet_directory_uri() . '/js/display-json-feeds.js', array( 'jquery' ), wsu_cob_script_version(), true ); 69 | 70 | return $content .= '
'; 71 | } 72 | 73 | add_action( 'wp_enqueue_scripts', 'cob_enqueue_scripts' ); 74 | /** 75 | * Enqueue any custom scripting provided by the child theme. 76 | */ 77 | function cob_enqueue_scripts() { 78 | if ( is_singular() ) { 79 | wp_enqueue_script( 'cob-custom-js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ), wsu_cob_script_version(), true ); 80 | } 81 | 82 | wp_enqueue_script( 'cob-remarketing', 'https://www.googleadservices.com/pagead/conversion.js', array(), false, true ); 83 | } 84 | 85 | add_filter( 'tribe_events_getLink', 'cob_modify_events_url', 10, 2 ); 86 | /** 87 | * Replace generated URLs from The Events Calendar to appear under a second level rather 88 | * than the single level forced by the plugin. 89 | * 90 | * @param string $event_url URL being output. 91 | * @param string $type Type of URL being output - home, list, month, day, single, etc... 92 | * 93 | * @return string URL to output. 94 | */ 95 | function cob_modify_events_url( $event_url, $type ) { 96 | if ( 'single' === $type ) { 97 | $event_url = str_replace( home_url( '/event/' ), home_url( '/news-events/calendar/event/' ), $event_url ); 98 | } else { 99 | $event_url = str_replace( home_url( '/events/' ), home_url( '/news-events/calendar/' ), $event_url ); 100 | } 101 | 102 | return $event_url; 103 | } 104 | 105 | add_filter( 'post_type_link', 'cob_filter_post_type_link', 10, 2 ); 106 | /** 107 | * Filter the post type link to show a single event under news-events/calendar/event/ 108 | * 109 | * @param string $post_link 110 | * @param WP_Post $post 111 | * 112 | * @return string 113 | */ 114 | function cob_filter_post_type_link( $post_link, $post ) { 115 | if ( 'tribe_events' === $post->post_type ) { 116 | $post_link = str_replace( home_url( '/event/' ), home_url( '/news-events/calendar/event/' ), $post_link ); 117 | } elseif ( 'tribe_venue' === $post->post_type ) { 118 | $post_link = str_replace( home_url( '/venue/' ), home_url( '/news-events/calendar/venue/' ), $post_link ); 119 | } elseif ( 'tribe_organizer' === $post->post_type ) { 120 | $post_link = str_replace( home_url( '/organizer/' ), home_url( '/news-events/calendar/organizer/' ), $post_link ); 121 | } 122 | 123 | return $post_link; 124 | } 125 | 126 | add_filter( 'term_link', 'cob_filter_term_link', 10 ); 127 | /** 128 | * Filter category links attached to events to match our slug. 129 | * 130 | * @param $term_link 131 | * 132 | * @return mixed 133 | */ 134 | function cob_filter_term_link( $term_link ) { 135 | $term_link = str_replace( home_url( '/events/category/' ), home_url( '/news-events/calendar/category/' ), $term_link ); 136 | 137 | return $term_link; 138 | } 139 | 140 | add_filter( 'generate_rewrite_rules', 'cob_filter_rewrite_rules', 11 ); 141 | /** 142 | * Replace rewrite rules provided by The Events Calendar with our own to support 143 | * a nested URL structure. 144 | * 145 | * @param WP_Rewrite $wp_rewrite 146 | * 147 | * @return WP_Rewrite 148 | */ 149 | function cob_filter_rewrite_rules( $wp_rewrite ) { 150 | foreach( $wp_rewrite->rules as $key => $rule ) { 151 | if ( 0 === strpos( $key, 'events/' ) ) { 152 | $new_key = str_replace( 'events/', 'news-events/calendar/', $key ); 153 | } elseif ( 0 === strpos( $key, '(.*)events/' ) ) { 154 | $new_key = str_replace( '(.*)events/', '(.*)news-events/calendar/', $key ); 155 | } elseif ( 0 === strpos( $key, 'event/' ) ) { 156 | $new_key = str_replace( 'event/', 'news-events/calendar/event/', $key ); 157 | } elseif ( 0 === strpos( $key, '(?:events)' ) ) { 158 | $new_key = str_replace( '(?:events)', '(?:news-events/calendar)', $key ); 159 | } else { 160 | $new_key = $key; 161 | } 162 | unset( $wp_rewrite->rules[ $key ] ); 163 | $wp_rewrite->rules[ $new_key ] = $rule; 164 | } 165 | return $wp_rewrite; 166 | } 167 | 168 | add_filter( 'tribe_events_register_event_type_args', 'cob_filter_event_content_type' ); 169 | /** 170 | * Alter the default arguments for the event content type to support our URL structure. 171 | * 172 | * @param $args 173 | * 174 | * @return mixed 175 | */ 176 | function cob_filter_event_content_type( $args ) { 177 | $args['rewrite']['slug'] = '/news-events/calendar/event'; 178 | $args['rewrite']['with_front'] = true; 179 | return $args; 180 | } 181 | 182 | add_filter( 'tribe_events_register_venue_type_args', 'cob_filter_venue_content_type' ); 183 | /** 184 | * Alter the default arguments for the venue content type to support our URL structure. 185 | * 186 | * @param $args 187 | * 188 | * @return mixed 189 | */ 190 | function cob_filter_venue_content_type( $args ) { 191 | $args['rewrite']['slug'] = '/news-events/calendar/venue'; 192 | $args['rewrite']['with_front'] = true; 193 | return $args; 194 | } 195 | 196 | add_filter( 'tribe_events_register_organizer_type_args', 'cob_filter_organizer_content_type' ); 197 | /** 198 | * Alter the default arguments for the organizer content type to support our URL structure. 199 | * 200 | * @param $args 201 | * 202 | * @return mixed 203 | */ 204 | function cob_filter_organizer_content_type( $args ) { 205 | $args['rewrite']['slug'] = '/news-events/calendar/organizer'; 206 | $args['rewrite']['with_front'] = true; 207 | return $args; 208 | } 209 | 210 | add_action( 'parse_query', 'cob_remove_events_from_edit', 51 ); 211 | /** 212 | * The Events Calendar makes the decision that tribe_events items should appear in every 213 | * taxonomy query via a `parse_query` action. This causes some issues on the edit screen 214 | * in WordPress, as a string is expected for the post_type data. This resets the query back 215 | * to the originally requested post type. 216 | * 217 | * @param $query 218 | */ 219 | function cob_remove_events_from_edit( $query ) { 220 | if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { 221 | return; 222 | } 223 | 224 | if ( 'edit' === get_current_screen()->base && 'tribe_events' !== get_current_screen()->post_type && $query->is_main_query() ) { 225 | $query->set( 'post_type', get_current_screen()->post_type ); 226 | } 227 | 228 | return; 229 | } 230 | 231 | add_filter( 'bu_navigation_filter_pages', 'cob_filter_page_urls', 11 ); 232 | /** 233 | * Look for pages that are intended to be section labels rather than 234 | * places where content exists. 235 | * 236 | * @param $pages 237 | * 238 | * @return array 239 | */ 240 | function cob_filter_page_urls( $pages ) { 241 | global $wpdb; 242 | 243 | $filtered = array(); 244 | 245 | if ( is_array( $pages ) && count( $pages ) > 0 ) { 246 | 247 | $ids = array_map( 'absint', array_keys( $pages ) ); 248 | $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '%s' AND post_id IN (" . implode( ',', $ids ) . ") and meta_value = '%s'", '_wp_page_template', 'template-section-label.php' ); 249 | $labels = $wpdb->get_results( $query, OBJECT_K ); 250 | 251 | if ( is_array( $labels ) && count( $labels ) > 0 ) { 252 | foreach ( $pages as $page ) { 253 | if ( array_key_exists( $page->ID, $labels ) ) { 254 | $page->url = '#'; 255 | } 256 | $filtered[ $page->ID ] = $page; 257 | } 258 | } else { 259 | $filtered = $pages; 260 | } 261 | } 262 | 263 | return $filtered; 264 | } 265 | 266 | add_filter( 'bu_navigation_filter_anchor_attrs', 'cob_bu_navigation_filter_anchor_attrs', 10, 1 ); 267 | /** 268 | * Filter anchor attributes in generate page menu to remove the title so that our default Overview 269 | * behavior remains. 270 | * 271 | * @param array $attrs List of attributes to output as part of the anchor. 272 | * 273 | * @return array 274 | */ 275 | function cob_bu_navigation_filter_anchor_attrs( $attrs ) { 276 | $attrs['title'] = ''; 277 | 278 | return $attrs; 279 | } 280 | 281 | add_action( 'after_setup_theme', 'cob_remove_feed_links' ); 282 | /** 283 | * Remove extra feeds to comments and other areas that we aren't necessarily prepared for. 284 | */ 285 | function cob_remove_feed_links() { 286 | remove_action( 'wp_head', 'feed_links_extra', 3 ); 287 | } 288 | 289 | add_filter( 'embed_oembed_html', 'embed_html', 99, 4 ); 290 | /** 291 | * Add responsive container to embeds. 292 | * 293 | * @param $html 294 | * 295 | * @return string 296 | */ 297 | function embed_html( $html ) { 298 | return '
' . $html . '
'; 299 | } 300 | 301 | add_filter( 'gform_field_validation', 'cob_validate_confirm_fields', 10, 4 ); 302 | /** 303 | * Provides a hacky method for adding a "confirmation" field immediately after a field with 304 | * a css class of "confirm-next". Very rudimentary. 305 | * 306 | * @param $result 307 | * @param $value 308 | * @param $form 309 | * @param $field 310 | * 311 | * @return mixed 312 | */ 313 | function cob_validate_confirm_fields( $result, $value, $form, $field ) { 314 | if ( isset( $field['cssClass'] ) && 'confirm-next' === $field['cssClass'] ) { 315 | $id = $field['id'] + 1; 316 | $next_value = $_POST['input_' . $id ]; 317 | 318 | if ( $value !== $next_value ) { 319 | $result['is_valid'] = false; 320 | $result['message'] = 'This field should match the value in the confirmation field below.'; 321 | } 322 | } 323 | return $result; 324 | } 325 | 326 | add_action( 'wp_footer', 'cob_remarketing_tag' ); 327 | /** 328 | * Setup variables for the enqueued remarketing script. 329 | */ 330 | function cob_remarketing_tag() { 331 | ?> 332 | 339 | 340 | 349 | 350 | 361 | 364 | 365 | 'boolean', 400 | 'default' => false, 401 | ); 402 | register_setting( 403 | 'reading', // option group "reading", default WP group 404 | 'ccb_use_local_menu', // option name 405 | $args 406 | ); 407 | 408 | // add our new setting 409 | add_settings_field( 410 | 'ccb_use_local_menu', // ID 411 | 'Use Local Menu', // Title 412 | 'ccb_add_local_menu_render', // Callback 413 | 'reading', // page 414 | 'default', // section 415 | ); 416 | 417 | } 418 | 419 | function ccb_add_local_menu_render( $args ) { 420 | 421 | $use_local = get_option('ccb_use_local_menu', false ); 422 | 423 | echo ''; 431 | 432 | } 433 | 434 | 435 | /** 436 | * Register and define the local menu settings 437 | */ 438 | add_action('admin_init', 'ccb_add_local_menu_setting'); 439 | --------------------------------------------------------------------------------