Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
d884697d2b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
246 lines (221 sloc) 6.91 KB
<?php
/**
* Plugin Name: UC Abroad
* Description: Abroad Programs
* Version: 1.0
* Author: Josh Roy of UITS Web Dev
*/
//
// If this plugin script is called directly,
// notify the user and abort.
//
if ( ! defined( 'ABSPATH' ) || ! defined( 'WPINC' ) ){
wp_die( 'Sorry, no direct access to plugin scripts!' );
}
require_once( plugin_dir_path( __FILE__ ) . 'template-class.php' );
add_action( 'plugins_loaded', array( 'Abroad_Template_Plugin', 'get_instance' ) );
// Search for templates in plugin 'templates' dir, and load if exists
function abroad_template_include( $template ) {
if ( file_exists( untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' . basename( $template ) ) )
$template = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/' . basename( $template );
return $template;
}
add_filter( 'template_include', 'abroad_template_include', 11 );
class UC_Abroad{
//
// Create our hook for our create_post_type() method
// and hook our function to the 'init' action
//
public function __construct(){
add_action( $tag_action_hook = 'init',
$function_to_call = array( $this, 'create_post_type' ) ,
0);
}
//
// Register our new custom post type
//
public function create_post_type() {
$labels = array(
'name' => _x( 'Programs', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Program', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Programs', 'text_domain' ),
'parent_item_colon' => __( 'Parent Program:', 'text_domain' ),
'all_items' => __( 'All Programs', 'text_domain' ),
'view_item' => __( 'View Program', 'text_domain' ),
'add_new_item' => __( 'Add New Program', 'text_domain' ),
'add_new' => __( 'New Program', 'text_domain' ),
'edit_item' => __( 'Edit Program', 'text_domain' ),
'update_item' => __( 'Update Program', 'text_domain' ),
'search_items' => __( 'Search Program', 'text_domain' ),
'not_found' => __( 'No programs found', 'text_domain' ),
'not_found_in_trash' => __( 'No programs found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'program', 'text_domain' ),
'description' => __( 'Program Post Type', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'custom-fields', 'page-attributes', 'post-formats', 'categories' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => '',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'query_var' => 'program',
'capability_type' => 'page',
'taxonomies' => array('category', 'post_tag'),
'rewrite' => true
);
register_post_type( 'program', $args );
flush_rewrite_rules();
} // create_post_type
} // Class
//
// Create a new instance of UC Abroad
//
$uc_abroad = new UC_Abroad();
//===============================================================================
// Contract Archive filter - show a list of contracts on this page
//===============================================================================
/*
function get_custom_post_type_template( $archive_template ) {
if ( is_post_type_archive( 'uc_contract' ) ) {
$archive_template = dirname( __FILE__ ) . '/templates/archive.php';
}
return $archive_template;
}
add_filter( 'archive_template', 'get_custom_post_type_template' );
//===============================================================================
// Single contract filter - Not currently used.
//===============================================================================
*/
function program_page_template( $template ) {
if ( is_singular( $slug = 'program' ) ) {
//$new_template = locate_template( array( 'single.php' ) );
$new_template = dirname( __FILE__ ) . '/templates/single-program.php';
if ( $new_template != '' ) {
return $new_template ;
}
}
return $template;
}
add_filter( 'template_include', 'program_page_template', $priority = 99 );
function program_archive_page_template( $archive_template ) {
if ( is_post_type_archive( 'program' ) ) {
$archive_template = dirname( __FILE__ ) . '/templates/archive-programs.php';
}
return $archive_template;
}
add_filter( 'archive_template', 'program_archive_page_template' );
function abroad_scripts() {
wp_enqueue_script( 'abroad-js', plugin_dir_url( __FILE__ ) . '/abroad.js', array( 'jquery' ));
}
add_action( 'wp_enqueue_scripts', 'abroad_scripts' );
//===============================================================================
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_57b2138783bf4',
'title' => 'Additional Content',
'fields' => array (
array (
'key' => 'field_57b2141a96872',
'label' => 'Apply Link',
'name' => 'apply-link',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
array (
'key' => 'field_57b2147c32970',
'label' => 'Academics',
'name' => 'academics',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
),
array (
'key' => 'field_57b2148232971',
'label' => 'Experience',
'name' => 'experience',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
),
array (
'key' => 'field_57b2148e32972',
'label' => 'Finances',
'name' => 'finances',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'program',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
endif;
?>