jimboobrien
5/17/2016 - 6:34 PM

staff-plugin-code.php

<? 
	
	/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~PROPER WAY OF ADDING CHILD THEME CSS FILE ~~~~
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
	function theme_enqueue_styles() {
		wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
		
		$options = get_option('wpdc_options');
			
		//echo "<hr><pre>";  var_dump($options); echo "</pre>";
		
		if( $options["wpdc_chk_staff_list"] == 1 && $options["wpdc_chk_staff_list_left"] == 1 ) {
			wp_enqueue_style( 'staff-list-left-style', get_stylesheet_directory_uri() . '/inc/css/staff-list-left-style.css',  array(), null );
		}else{		
			if( $options["wpdc_chk_staff_list"] == 1 ) {
				wp_enqueue_style( 'octane-staff-list-style', get_stylesheet_directory_uri() . '/inc/css/staff-list-style.css',  array(), null );
			}
		}//end else
		
		if( $options["wpdc_chk_staff_list"] == 0 && $options["wpdc_chk_staff_list_left"] == 0) {
			wp_enqueue_style( 'staff-grid-octane', get_stylesheet_directory_uri() . '/inc/css/staff-grid-octane.css',  array(), null );
		}
		
		
	}








	/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		Divi Child Functions - This came from someones divi remake allowing me to enable page builder on custom post types 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


	if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
		
	// plugin version, used to add version for scripts and styles
	define( 'WPDC_VER', '1.0' );
	define( 'WPDC_THEME_NAME', 'Divi Child Theme' );
		
	// includes
	include( 'inc/admin/settings.php' );
	include( 'inc/customizer/customizer.php' );

	// include builder integration
	if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
		
		include( 'inc/builder/class-divi-builder-integration-admin.php' );
		add_action( 'after_setup_theme', array( 'Divi_Builder_Integration_Admin', 'get_instance' ) );

	}

	add_action( 'wp_head', 'wpdc_remove_space_before_footer');

	function wpdc_remove_space_before_footer() { 
		
		if ( ! is_single() ) return;
		//if ( $is_page_builder_used ) return;
		if ( comments_open() && 'false' != et_get_option( 'divi_show_postcomments', 'on' ) ) return;
		?>
		<style>
		/* BODY */
		<?php echo '.single .post {padding-bottom: 0px;}'; ?>
		</style>
		<?php
	}


	/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~OCTANE CUSTOM STUFF~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	add_action( 'init', 'octane_cpt_init' );
	function octane_cpt_init() {
		register_post_type(  'staff',
			array(
			  'labels' => array(
				'name' => __( 'Team' ),
				'singular_name' => __( 'Staff' )
			  ),
			  'public'             => true,
			  'publicly_queryable' => true,
			  'show_ui'            => true,
			  'show_in_menu'       => true,
			  'query_var'          => true,
			  'rewrite'            => array( 'slug' => 'staff' ),
			  
			  /* this is important to make it so that page-portfolio.php will show when used */
			  'capability_type'    => 'post',
			  'hierarchical'       => true,
			  /* make sure has_archive is turned off if you plan on using page-portfolio.php */
			  'has_archive' => false,
			  
			  
			  'rewrite' => array('with_front'=>true), 
			 
			  'can_export' => true,
			  
			  'menu_position'      => null,
			  'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields','page-attributes')
			)
		);
	}

	function my_rewrite_flush() {
		flush_rewrite_rules();
	}
	add_action( 'after_switch_theme', 'my_rewrite_flush' );
	
	/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~~~~~~OCTANE CUSTOM META BOXES FOR STAFF POST TYPE ~~~~~~~~~~~~~~~ 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	/**
	 * Adds a meta box to the staff custom post type
	 */
	function prfx_custom_meta() {
		add_meta_box( 'prfx_meta', __( 'Staff Member Information', 'prfx-textdomain' ), 'prfx_meta_callback', 'staff', 'side', 'high' );
	}
	add_action( 'add_meta_boxes', 'prfx_custom_meta' );
	
	/**
	 * Outputs the content of the meta box
	 */
	function prfx_meta_callback( $post ) {
		wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
		$prfx_stored_meta = get_post_meta( $post->ID );
		?>
		<p>
			<label for="staff-position" class="prfx-row-title"><?php _e( 'Staff Position', 'prfx-textdomain' )?></label>
			<input type="text" name="staff-position" id="staff-position" value="<?php if ( isset ( $prfx_stored_meta['staff-position'] ) ) echo $prfx_stored_meta['staff-position'][0]; ?>" />
		</p>
		<?php
	}
	
	/**
	 * Saves the custom meta input
	 */
	function prfx_meta_save( $post_id ) {
	 
		// Checks save status
		$is_autosave = wp_is_post_autosave( $post_id );
		$is_revision = wp_is_post_revision( $post_id );
		$is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
	 
		// Exits script depending on save status
		if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
			return;
		}
	 
		// Checks for input and sanitizes/saves if needed
		if( isset( $_POST[ 'staff-position' ] ) ) {
			update_post_meta( $post_id, 'staff-position', sanitize_text_field( $_POST[ 'staff-position' ] ) );
		}
	 
	}
	add_action( 'save_post', 'prfx_meta_save' );
	
	
	/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~~~~~~ ~~~~~~~~~~~~~~~ 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/