1
0
mirror of https://github.com/ascribe/wp-theme synced 2024-12-31 09:07:47 +01:00

Adding base controllers

This commit is contained in:
Sarah Etter 2015-09-17 18:13:03 -06:00
parent 59c91103c6
commit d026427f90
5 changed files with 227 additions and 11 deletions

View File

@ -0,0 +1,40 @@
<?php
/**
* Created by PhpStorm.
* User: sarahetter
* Date: 15-09-17
* Time: 4:47 PM
*/
class Subtemplate {
public function loopSubtemplates() {
global $post;
$id = $post->ID;
$result = '';
$subtemplates = get_field('subtemplate', $id);
$result = '';
if( $subtemplates ) {
foreach ( $subtemplates as $subtemplate ) {
$subtemplateType = $subtemplate['subtemplate_type'];
$subtemplateTitle = $subtemplate['section_title'];
switch ($subtemplateType) {
case 'content':
$result .= $this->content($subtemplate,$subtemplateTitle);
break;
}
}
return $result;
}
return $result;
}
}

View File

@ -0,0 +1,19 @@
<?php
/**
* Created by PhpStorm.
* User: sarahetter
*/
class Controller {
public function __construct() {
spl_autoload_register(function ($class) {
require_once 'classes/' . $class . '.php';
});
}
public function loopSubtemplates() {
$controller = new Subtemplate();
return $controller->loopSubtemplates();
}
}

55
controller/header.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/**
* Created by PhpStorm.
* User: sarahetter
* Date: 15-09-17
* Time: 4:48 PM
*/
//<editor-fold desc="Init">
global $passInTitle;
$description = '';
$image = '';
$title = '';
$url = get_bloginfo('wpurl');
//</editor-fold>
//<editor-fold desc="Get Title">
if(isset($passInTitle)) {
$title = $passInTitle;
}
else {
$title = get_the_title();
}
if (strpos($title, 'Home') !== false)
{
$title = '';
}
else {
$title .= ' | ';
}
$title .= get_bloginfo();
//</editor-fold>
//<editor-fold desc="Get Description">
$description = get_the_excerpt();
if (empty($description)) {
$content = get_field('subtemplate')[0]['content'];
if (!empty($content)) {
$description = substr(strip_tags($content),0,140)."...";
}
}
if (empty($description)) {
$description = get_bloginfo('description');
}
//</editor-fold>
//<editor-fold desc="Get Image">
$image = get_field('header_image')['url'];
if (empty($image)) {
$image = WPTHEME_TEMPLATE_URL.'/images/ico/apple-touch-icon-152x152.png';
}
//</editor-fold>

View File

@ -13,6 +13,9 @@
* @since 0.1.0
*/
require "controller/controller.inc.php";
// Useful global constants
define( 'WPTHEME_VERSION', '0.1.0' );
define( 'WPTHEME_URL', get_stylesheet_directory_uri() );
@ -23,7 +26,29 @@ define( 'WPTHEME_INC', WPTHEME_PATH . 'includes/' );
// Include compartmentalized functions
require_once WPTHEME_INC . 'functions/core.php';
// Include lib classes
// Run the setup functions
TenUp\ascribe\Core\setup();
TenUp\ascribe\Core\setup();
// REMOVE WIDTH AND HEIGHT ATTRIBUTES ON THUMBNAILS
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );
//ACF Collapser temp fix
add_filter('acf/compatibility/field_wrapper_class', '__return_true');
// TURN ON ACF SETTINGS PAGE
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
//add excerpt to page
function wpcodex_add_excerpt_support_for_pages() {
add_post_type_support( 'page', 'excerpt' );
}
add_action( 'init', 'wpcodex_add_excerpt_support_for_pages' );

View File

@ -5,11 +5,88 @@
* @package ascribe
* @since 0.1.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php wp_head(); ?>
</head>
<body>
require 'controller/header.php';
$controller = new Controller();
?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en" itemscope itemtype="https://schema.org/Organization"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en" itemscope itemtype="https://schema.org/Organization"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en" itemscope itemtype="https://schema.org/Organization"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js " lang="en" itemscope itemtype="https://schema.org/Organization" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php echo $title ?></title>
<base href="<?php echo $url; ?>">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0">
<meta name="description" content="<?php echo $description ?>">
<meta property="og:title" content="<?php echo $title; ?>" />
<meta property="og:type" content="website" />
<meta property="og:url" content="<?php echo $url; ?>" />
<meta property="og:image" content="<?php echo $image; ?>" />
<meta property="og:site_name" content="<?php echo get_bloginfo(); ?>" />
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="<?php echo $title; ?>">
<meta name="twitter:description" content="<?php echo $description ?>">
<meta name="twitter:image:src" content="<?php echo $image; ?>">
<meta name="twitter:domain" content="<?php echo $url; ?>">
<meta itemprop="name" content="<?php echo $title; ?>">
<meta itemprop="description" content="<?php echo $description ?>">
<meta itemprop="image" content="<?php echo $image; ?>">
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/manifest.json">
<meta name="msapplication-TileColor" content="#00a300">
<meta name="msapplication-TileImage" content="<?php echo WPTHEME_TEMPLATE_URL; ?>/images/ico/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">
<script src='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.2/mapbox.css' rel='stylesheet' />
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,600' rel='stylesheet' type='text/css'>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div class="wrapper">
<div class="scrollpos"></div>
<?php
$headerClass = '';
$indexHeadContent = '';
$indexHead = '';
$headerImageMarkup = '';
if (is_front_page()) {
$headerClass = 'index';
$indexHeadContent = $controller->indexHeader();
$indexMobileBg = get_field('mobile_video_replacement_image')['url'];
$indexHead = "<section class='indexHead' style='background-image:url({$indexMobileBg})'>{$indexHeadContent}</section>";
}
?>
<header class="<?php echo $headerClass; ?>">
<div class="centered">
<?php echo $logo; ?>
<span class="icon-menu mobile-only"></span>
<nav>
<?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container' => false ) ); ?>
</nav>
</div>
</header>
<?php echo $indexHead; ?>