/**
  * Returns singleton instance of CP_Custom_Content_Core
  *
  * @return CP_Custom_Content_Core
  */
 public static function GetInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new CP_Custom_Content_Core();
     }
     return self::$instance;
 }
 /**
  * registers the current content handler.  Child plugins should
  * register this function to fire on the 'setup_custom_content' action
  *
  * @example add_action('setup_custom_content', array($handler, 'on_setup_custom_content'));
  *
  */
 public function on_setup_custom_content()
 {
     if (strlen($this->get_content_type()) == 0) {
         trigger_error("Custom_Content_Handler must have a set content_type.  Content Type was not loaded.", E_WARNING);
         return;
     }
     CP_Custom_Content_Core::GetInstance()->register_custom_content_type($this);
 }
 /**
  * Registers the managemet pages for the custom taxonomy in wp 2.9
  *
  */
 public function register_management_page()
 {
     $post_type = array_shift($this->get_object_types());
     if ('post' == $post_type) {
         add_submenu_page('edit.php', $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name());
     } elseif ('page' == $post_type) {
         add_submenu_page('edit-pages.php', $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name());
     } else {
         add_submenu_page(str_replace('admin.php?page=', '', CP_Custom_Content_Core::GetInstance()->get_manage_custom_content_url($post_type)), $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name());
     }
 }
Example #4
0
 /**
  * Handles adding of content_types before any content is rendered.
  *
  */
 public function on_load_add_content_type_page()
 {
     if (!current_user_can('manage_content_types')) {
         wp_die("You do not have sufficient permissions to access this page");
     }
     $action = !empty($_POST['action']) ? $_POST['action'] : '';
     $nonce = !empty($_POST['_wpnonce']) ? $_POST['_wpnonce'] : '';
     switch ($action) {
         case 'add_content_type':
             if (wp_verify_nonce($nonce, 'add_content_type')) {
                 if (!empty($_POST['content_type'])) {
                     $content_type = $_POST['content_type'];
                     $content_handler = new Dynamic_Content_Handler($content_type, $_POST);
                     $content_type = $this->add_content_handler($content_handler);
                     if (!is_wp_error($content_type)) {
                         $add_url = admin_url('post-new.php?post_type=' . $content_type);
                         if (version_compare(get_wp_version(), '3.0-dev', '<')) {
                             $add_url = CP_Custom_Content_Core::GetInstance()->get_add_custom_content_url($content_type);
                         }
                         $notice = sprintf(__("The content type of '{$content_type}' has been created.  <a href=\"%s\">Add one now.</a>"), esc_attr($add_url));
                         wp_redirect($this->get_edit_content_type_url($content_type, array('notice' => $notice)));
                         exit;
                     } else {
                         $_REQUEST['notice'] = $content_type->get_error_message();
                     }
                 }
             }
             break;
     }
 }
Example #5
0
			  <tr>
					<?php 
    print_column_headers($post_type);
    ?>
	  		</tr>
	  	</thead>
		  <tfoot>
	  		<tr>
					<?php 
    print_column_headers($post_type, false);
    ?>
	  		</tr>
	  	</tfoot>
		  <tbody>
	  		<?php 
    CP_Custom_Content_Core::GetInstance()->manage_rows($post_type, $posts, $pagenum, $per_page);
    ?>
	  	</tbody>
		</table>
		<div class="tablenav">
			<?php 
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links_text}</div>";
    }
    ?>
			<div class="alignleft actions">
				<select name="action2">
					<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
Example #6
0
        return $wp_version;
    }
}
if (!version_compare(get_wp_version(), '2.9', '>=')) {
    trigger_error('CMS Press requires WP version 2.9 or higher', E_USER_NOTICE);
    return;
}
define('CP_BASE_DIR', dirname(__FILE__));
define('CP_BASE_URL', str_replace(str_replace('\\', '/', ABSPATH), site_url() . '/', str_replace('\\', '/', dirname(__FILE__))));
require_once CP_BASE_DIR . '/cp-custom-content/legacy/legacy.php';
/**
 * Core files
 */
require_once CP_BASE_DIR . '/cp-custom-content/cp-custom-content-core.php';
require_once CP_BASE_DIR . '/cp-custom-taxonomy/cp-custom-taxonomy-core.php';
CP_Custom_Content_Core::Initialize();
CP_Custom_Taxonomy_Core::Initialize();
/**
 * Add dynamic content type handler(s)
 */
require_once CP_BASE_DIR . '/child-plugins/dynamic/dynamic-content.php';
Dynamic_Content_Builder::Initialize();
require_once CP_BASE_DIR . '/child-plugins/dynamic/dynamic-taxonomies.php';
Dynamic_Taxonomy_Builder::Initialize();
function on_cmspress_activation()
{
    $role = get_role('administrator');
    if (!$role->has_cap('manage_content_types')) {
        $role->add_cap('manage_content_types');
    }
    if (!$role->has_cap('manage_taxonomies')) {