ok, here is the updated code. I left some comments in it for testing purpose. Ready to be tested…
<?php
/**
* @package Content Aware Sidebars
* @author Joachim Jensen <[email protected]>
*/
/**
*
* Pods Module
*
* Detects if current content is:
* a) any or specific pods pages
*
*/
class CASModule_pods extends CASModule {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
$this->id = 'pods';
$this->name = __('Pods Pages',ContentAwareSidebars::DOMAIN);
}
/**
* Get pods pages
* @return array
*/
protected function _get_content() {
if ( function_exists( 'pods_api' ) ) {
// Get PodsAPI
$api = pods_api();
// Get Pod Pages
$pod_pages = $api->load_pages();
$pod_page_list = array();
foreach ( $pod_pages as $pod_page ) {
$pod_page_list[$pod_page[ 'slug' ]] = $pod_page[ 'name' ];
}
}
return $pod_page_list;
}
/**
* Determine if content is relevant
* @return boolean
*/
public function is_content() {
return is_pod_page();
}
/**
* Where query
* @return string
*/
public function db_where() {
//$pods_name = pods_url_variable('first', uri);
//return "(pods.meta_value IS NULL OR pods.meta_value = '".$pods_name."')";
return is_pod_page($pod_page[ 'slug' ]);
}
/**
* Meta box content
* @global object $post
* @return void
*/
public function meta_box_content() {
global $post;
echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'. "\n";
$meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX . $this->id, false);
$current = $meta != '' ? $meta : array();
echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'. "\n";
foreach ($this->_get_content() as $id => $name) {
echo '<li><label><input type="checkbox" name="' . $this->id . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
}
echo '</ul>'. "\n";
echo '</div>'. "\n";
}
}