<?php
if (!defined('ABSPATH')) exit;

function jc_theme_setup(){
  add_theme_support('title-tag');
  add_theme_support('post-thumbnails');
  add_theme_support('custom-logo');
  add_theme_support('html5', array('search-form','comment-form','comment-list','gallery','caption','style','script'));
  add_theme_support('align-wide');
  register_nav_menus(array('primary' => __('Primary Menu','jamescushman')));
}
add_action('after_setup_theme','jc_theme_setup');

function jc_assets(){
  wp_enqueue_style('jc-style', get_stylesheet_uri(), array(), '1.5.1');
  wp_enqueue_script('jc-theme', get_template_directory_uri().'/assets/js/theme.js', array(), '1.5.1', true);
}
add_action('wp_enqueue_scripts','jc_assets');

function jc_customizer($wp_customize){
  $wp_customize->add_section('jc_home', array('title'=>__('Homepage Content','jamescushman'),'priority'=>30));
  $fields = array(
    'jc_name' => array('James Cushman','Name'),
    'jc_role' => array('Founder | Product Architect | Software Developer','Professional Role'),
    'jc_hero_text' => array('Building smart, scalable technology that solves real-world problems.','Hero Statement'),
    'jc_email' => array('james@jamescushman.com','Email Address'),
    'jc_linkedin' => array('/in/jamescushman','LinkedIn Path'),
    'jc_resume_url' => array('#','Resume URL'),
  );
  foreach($fields as $id=>$data){
    $wp_customize->add_setting($id,array('default'=>$data[0],'sanitize_callback'=>'sanitize_text_field'));
    $wp_customize->add_control($id,array('label'=>__($data[1],'jamescushman'),'section'=>'jc_home','type'=>'text'));
  }
}
add_action('customize_register','jc_customizer');

function jc_default_menu() {
  $resume_url = get_template_directory_uri() . '/assets/documents/james-cushman-resume.pdf';

  echo '<ul>';

  $items = array(
    'Home'     => '#home',
    'Projects' => '#projects',
    'Approach' => '#approach',
    'Journey'  => '#journey'
  );

  foreach ($items as $label => $url) {
    echo '<li><a href="' . esc_url($url) . '">' . esc_html($label) . '</a></li>';
  }

  echo '<li><a href="' . esc_url($resume_url) . '" target="_blank" rel="noopener noreferrer">Resume</a></li>';
  echo '<li><a href="#contact">Contact</a></li>';
  echo '</ul>';
}

