Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2 from jmr06005/master
Committing old updates
  • Loading branch information
jmr06005 committed May 8, 2017
2 parents 1e88fad + c53f857 commit 2dcc02b
Show file tree
Hide file tree
Showing 4 changed files with 31 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
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 2dcc02b

Please sign in to comment.