Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Committing old updates
  • Loading branch information
jmr06005 committed May 8, 2017
1 parent 1e88fad commit 9ba5dad
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 38 deletions.
36 changes: 6 additions & 30 deletions template-class.php
Expand Up @@ -77,12 +77,8 @@ class Purchasing_Template_Plugin {

// Grab the translations for the plugin
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );

// Add a filter to the page attributes metabox to inject our template into the page template cache.
add_filter('page_attributes_dropdown_pages_args', array( $this, 'register_project_templates' ) );

// Add a filter to the save post in order to inject out template into the page cache
add_filter('wp_insert_post_data', array( $this, 'register_project_templates' ) );

add_filter('theme_page_templates', array( $this, 'add_page_templates'));

// Add a filter to the template include in order to determine if the page has our template assigned and return it's path
add_filter('template_include', array( $this, 'view_project_template') );
Expand Down Expand Up @@ -127,31 +123,11 @@ class Purchasing_Template_Plugin {
* @verison 1.0.0
* @since 1.0.0
*/
public function register_project_templates( $atts ) {

// Create the key used for the themes cache
$cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );

// Retrieve the cache list. If it doesn't exist, or it's empty prepare an array
$templates = wp_cache_get( $cache_key, 'themes' );
if ( empty( $templates ) ) {
$templates = array();
} // end if

// Since we've updated the cache, we need to delete the old cache
wp_cache_delete( $cache_key , 'themes');

// Now add our template to the list of templates by merging our templates
// with the existing templates array from the cache.

public function add_page_templates($templates){
$templates = array_merge( $templates, $this->templates );

// Add the modified cache to allow WordPress to pick it up for listing
// available templates
wp_cache_add( $cache_key, $templates, 'themes', 1800 );

return $atts;

} // end register_project_templates
return $templates;
}

/**
* Checks if the template is assigned to the page
Expand Down
6 changes: 0 additions & 6 deletions templates/_notes/dwsync.xml

This file was deleted.

1 change: 0 additions & 1 deletion templates/page-purchasing.php
Expand Up @@ -101,7 +101,6 @@ get_header(); ?>
<tbody>

<?php

//
// we pass 'CCV_PLUS' on the URL ( "+" is reserved )
// so let's convert, as CCV+ is what's stored in the database -
Expand Down
37 changes: 37 additions & 0 deletions templates/single.php
@@ -0,0 +1,37 @@
<?php
/**
* The Template for displaying all single posts.
*
* @package uc-purchasing
*/

get_header(); ?>
<div id="page-single">
<div class="row">
<div class="col-md-9">

<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">

<?php while ( have_posts() ) : the_post(); ?>

<?php get_template_part( 'content', 'single' ); ?>

<?php cs_post_nav(); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>

<?php endwhile; // end of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
26 changes: 25 additions & 1 deletion uc-purchasing.php
Expand Up @@ -176,7 +176,31 @@ class UC_Purchasing{
//

$uc_purchasing = new UC_Purchasing();

function add_uc_contract_columns($columns) {
return array(
'cb' => '<input type="checkbox" />',
'title' => __('Title'),
'contract_number' => __('Contract Number'),
'contract_vendor_name' => __('Vendor Name'),
'author' => __('Author'),
'date' => __('Date')
);
//return array_merge($columns,
// array('contract_number' => __('Contract Number')));
}
add_filter('manage_uc_contract_posts_columns' , 'add_uc_contract_columns');

function uc_contract_columns( $column, $post_id ) {
switch ( $column ) {
case 'contract_number':
echo get_field( "contract_number", $post_id );
break;
case 'contract_vendor_name':
echo get_field( "contract_vendor_name", $post_id );
break;
}
}
add_action( 'manage_uc_contract_posts_custom_column' , 'uc_contract_columns', 10, 2 );
//===============================================================================
// Contract Archive filter - show a list of contracts on this page
//===============================================================================
Expand Down

0 comments on commit 9ba5dad

Please sign in to comment.