if (!defined('THEME_FRAMEWORK')) exit('No direct script access allowed'); /** * General methods to be used in custom post types class * * @author Bob Ulusoy * @copyright Artbees LTD (c) * @link http://artbees.net * @since Version 1.0 * @package artbees */ class Mk_Post_Type_Helpers { /** * Beautifies a string. Capitalize words and remove underscores * * @param string $string * @return string * * @author Bob Ulusoy * @since 1.0 * */ static function beautify($string) { $letters = array( '-', '_' ); return apply_filters('abb_beautify', ucwords(str_replace($letters, ' ', $string))); } /** * Uglifies a string. replace dash to underline and removes strange keyworks * * @param string $string * @return string * * @author Bob Ulusoy * @since 1.0 * */ static function uglify($string) { return apply_filters('abb_uglify', sanitize_title($string)); } /** * Converts first char of the string to upper letter * * @param string $string * @return string * * @author Maki * @since 1.0 * */ static function upper_first($string) { return strtoupper($string[1]); } /** * Turns a hyphen-separated strings into CamelCase * * @param string $string * @return string * * @author Maki * @since 1.0 * */ static function camel_case($str) { if (version_compare(phpversion() , '5.3', '>=')) { return preg_replace_callback('/-(.?)/', function ($string) { return strtoupper($string[1]); } , $str); } else { return preg_replace("/\-(.)/e", "strtoupper('\\1')", $str); } } /** * Makes a word plural * * @param string $string * @return string * * @author Bob Ulusoy * @since 1.0 * */ static function pluralize($string) { $plural = array( array( '/(quiz)$/i', "$1zes" ) , array( '/^(ox)$/i', "$1en" ) , array( '/([m|l])ouse$/i', "$1ice" ) , array( '/(matr|vert|ind)ix|ex$/i', "$1ices" ) , array( '/(x|ch|ss|sh)$/i', "$1es" ) , array( '/([^aeiouy]|qu)y$/i', "$1ies" ) , array( '/([^aeiouy]|qu)ies$/i', "$1y" ) , array( '/(hive)$/i', "$1s" ) , array( '/(?:([^f])fe|([lr])f)$/i', "$1$2ves" ) , array( '/sis$/i', "ses" ) , array( '/([ti])um$/i', "$1a" ) , array( '/(buffal|tomat)o$/i', "$1oes" ) , array( '/(bu)s$/i', "$1ses" ) , array( '/(alias|status)$/i', "$1es" ) , array( '/(octop|vir)us$/i', "$1i" ) , array( '/(ax|test)is$/i', "$1es" ) , array( '/s$/i', "s" ) , array( '/$/', "s" ) ); $irregular = array( array( 'move', 'moves' ) , array( 'sex', 'sexes' ) , array( 'child', 'children' ) , array( 'man', 'men' ) , array( 'person', 'people' ) ); $uncountable = array( 'sheep', 'fish', 'series', 'species', 'money', 'rice', 'information', 'equipment' ); // Save time if string in uncountable if (in_array(strtolower($string) , $uncountable)) return apply_filters('abb_pluralize', $string); // Check for irregular words foreach ($irregular as $noun) { if (strtolower($string) == $noun[0]) return apply_filters('abb_pluralize', $noun[1]); } // Check for plural forms foreach ($plural as $pattern) { if (preg_match($pattern[0], $string)) return apply_filters('abb_pluralize', preg_replace($pattern[0], $pattern[1], $string)); } // Return if noting found return apply_filters('abb_pluralize', $string); } /** * Returns Current Page URL * * */ static function current_page_url() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"])) { if ($_SERVER["HTTPS"] == "on") { $pageURL.= "s"; } } $pageURL.= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL.= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL.= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } } if (!defined('THEME_FRAMEWORK')) exit('No direct script access allowed'); /** * Class to register custom post type * * @author Bob Ulusoy * @copyright Artbees LTD (c) * @link http://artbees.net * @since Version 1.0 * @package artbees */ class Mk_Register_Post_Type { var $title; var $name; var $plural; var $labels; var $args; var $supports; /** * Construct a new custom post type * @param string|array $name * @param array $args * @param array $labels * * @author Bob Ulusoy * @since 1.0 * */ function __construct($name, $supports = array() , $args = array() , $singular = false, $labels = array()) { if (!empty($name)) { // Checks if $name is array, first value will be name, second plural name if (is_array($name)) { $this->name = Mk_Post_Type_Helpers::uglify($name[0]); $this->title = Mk_Post_Type_Helpers::beautify($name[0]); $this->plural = Mk_Post_Type_Helpers::beautify($name[1]); } else { $this->name = Mk_Post_Type_Helpers::uglify($name); $this->title = Mk_Post_Type_Helpers::beautify($name); $this->plural = Mk_Post_Type_Helpers::pluralize(Mk_Post_Type_Helpers::beautify($name)); } $this->args = isset($args) ? $args : ''; $this->labels = isset($labels) ? $labels : ''; $this->supports = isset($supports) ? $supports : ''; // If post type does not exists, we will pass to register the post type if (!post_type_exists($this->name)) { $this->register_post_type(); if ($singular) { } } } } /** * * Register the post type * * @author Bob Ulusoy * @since 1.0 */ function register_post_type() { $options = get_option(THEME_OPTIONS); $toggle = isset($options[$this->name . '-post-type']) ? $options[$this->name . '-post-type'] : false; $post_type_toggle = isset($toggle) ? $toggle : 'true'; if ($post_type_toggle == 'false') return false; // Set labels $labels = array_merge(array( 'name' => sprintf(_x('%s', 'post type general name', 'mk_framework') , $this->plural) , 'singular_name' => sprintf(_x('%s', 'post type singular title', 'mk_framework') , $this->title) , 'menu_name' => sprintf(__('%s', 'artbees') , $this->plural) , 'all_items' => sprintf(__('All %s', 'mk_framework') , $this->plural) , 'add_new' => sprintf(_x('Add New', '%s', 'mk_framework') , $this->title) , 'add_new_item' => sprintf(__('Add New %s', 'mk_framework') , $this->title) , 'edit_item' => sprintf(__('Edit %s', 'mk_framework') , $this->title) , 'new_item' => sprintf(__('New %s', 'mk_framework') , $this->title) , 'view_item' => sprintf(__('View %s', 'mk_framework') , $this->title) , 'items_archive' => sprintf(__('%s Archive', 'mk_framework') , $this->title) , 'search_items' => sprintf(__('Search %s', 'mk_framework') , $this->plural) , 'not_found' => sprintf(__('No %s found', 'mk_framework') , $this->plural) , 'not_found_in_trash' => sprintf(__('No %s found in trash', 'mk_framework') , $this->plural) , 'parent_item_colon' => sprintf(__('%s Parent', 'mk_framework') , $this->title) , ) , $this->labels); // Post type arguments $args = array_merge(array( 'label' => sprintf(__('%s', 'mk_framework') , $this->plural) , 'labels' => $labels, 'public' => true, 'menu_position' => 100, 'supports' => $this->supports, ) , $this->args); // Register Post type using WP register_post_type action. register_post_type($this->name, $args); } /** * * Register Taxonomy for $this post type * * @param string|array $name * @param array $args * @param array $labels * @return object Abb_Custom_Post_Type * * */ function register_taxonomy($name, $args = array() , $labels = array()) { $post_type_name = $this->name; $taxonomy = new Mk_Register_Taxonomy($name, $post_type_name, $args, $labels); return $this; // To chain methods } /** * * Add specific supports for this post type * * @param string|array $features * @return object Abb_Custom_Post_Type * * */ function add_post_support($features) { $post_type_name = $this->name; add_post_type_support($post_type_name, $features); return $this; } /** * * Remove specific supports for this post type * * @param string|array $features * @return object Abb_Custom_Post_Type * * */ function remove_post_type_supports($features) { $post_type_name = $this->name; foreach ((array)$features as $feature) { remove_post_type_support($post_type_name, $feature); } } /** * * Removes singular pages from this post type. * * */ function set_as_none_singular_posts() { if (get_query_var('post_type') == $this->name) { global $wp_query; $wp_query->is_home = false; $wp_query->is_404 = true; $wp_query->is_single = false; $wp_query->is_singular = false; } } } /** * Registers a Post Type * * @param string|array $name * @param array $args * @param array $labels * @return object Abb_Register_Post_Type * * */ function Mk_Register_Custom_Post_Type($name, $supports = array(), $args = array(), $singular = false, $labels = array()) { $post_type = new Mk_Register_Post_Type($name, $supports, $args, $singular = false, $labels); return $post_type; } if (!defined('THEME_FRAMEWORK')) exit('No direct script access allowed'); /** * Class to register Taxonomy * * @author Bob Ulusoy * @copyright Artbees LTD (c) * @link http://artbees.net * @since Version 1.0 * @package artbees */ class Mk_Register_Taxonomy { var $title; var $name; var $labels; var $post_type; var $plural; var $args; public $extra_fields = 'false'; /** * Constructs the class with important vars and method calls * If the taxonomy exists, it will be attached to the post type * * @param string $name * @param string $post_type * @param array $args * @param array $labels * * @author Bob Ulusoy * @since 1.0 * */ function __construct($name, $post_type = null, $args = array() , $labels = array()) { if (!empty($name)) { $this->post_type = (array)$post_type; if (is_array($name)) { $this->name = Mk_Post_Type_Helpers::uglify($name[0]); $this->title = Mk_Post_Type_Helpers::beautify($name[0]); $this->plural = Mk_Post_Type_Helpers::beautify($name[1]); } else { $this->name = Mk_Post_Type_Helpers::uglify($name); $this->title = Mk_Post_Type_Helpers::beautify($name); $this->plural = Mk_Post_Type_Helpers::pluralize(Mk_Post_Type_Helpers::beautify($name)); } $this->labels = $labels; $this->args = $args; if (!taxonomy_exists($this->name)) { $this->register_taxonomy(); } else { $this->register_taxonomy_for_object_type(); } } } /** * Register csutom taxonomy * * * @author Bob Ulusoy * @since 1.0 * */ function register_taxonomy() { // Default labels, overwrite them with the given labels. $labels = array_merge(array( 'name' => sprintf(_x('%s', 'taxonomy general name', 'mk_framework') , $this->plural) , 'singular_name' => sprintf(_x('%s', 'taxonomy singular name', 'mk_framework') , $this->title) , 'search_items' => sprintf(__('Search %s', 'mk_framework') , $this->plural) , 'all_items' => sprintf(__('All %s', 'mk_framework') , $this->plural) , 'parent_item' => sprintf(__('Parent %s', 'mk_framework') , $this->title) , 'parent_item_colon' => sprintf(__('Parent %s:', 'mk_framework') , $this->title) , 'edit_item' => sprintf(__('Edit %s', 'mk_framework') , $this->title) , 'update_item' => sprintf(__('Update %s', 'mk_framework') , $this->title) , 'add_new_item' => sprintf(__('Add New %s', 'mk_framework') , $this->title) , 'new_item_name' => sprintf(__('New %s Name', 'mk_framework') , $this->title) , 'menu_name' => sprintf(__('%s', 'mk_framework') , $this->plural) ) , $this->labels); // Default arguments, overwitten with the given arguments $args = array_merge(array( 'label' => sprintf(__('%s', 'mk_framework') , $this->plural) , 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false, 'show_admin_column' => false ) , $this->args); register_taxonomy($this->name, $this->post_type, $args); } /** * Used to attach the existing taxonomy to the post type * * @author Bob Ulusoy * @since 1.0 * */ function register_taxonomy_for_object_type() { register_taxonomy_for_object_type($this->name, $this->post_type); } } /** * Registers a Taxonomy for a Post Type * * @param string $name * @param string $post_type * @param array $args * @param array $labels * @return object Abb_Register_Taxonomy * * @author Bob Ulusoy * @since 1.0 * */ function mk_register_custom_taxonomy($name, $post_type, $args = array(), $labels = array()) { $taxonomy = new Mk_Register_Taxonomy($name, $post_type, $args, $labels); return $taxonomy; } if (!defined('THEME_FRAMEWORK')) exit('No direct script access allowed'); $mk_options = get_option(THEME_OPTIONS); /*-----------------------------------------------------------------------------------*/ /* Register Clients Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('clients', $supports = array( 'title', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-businessman', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true); function mk_edit_clients_columns($columns) { $columns = array( "cb" => "", 'title' => __('Client Name', 'mk_framework') , "thumbnail" => __('Thumbnail', 'mk_framework') , "date" => 'Date', ); return $columns; } add_filter('manage_edit-clients_columns', 'mk_edit_clients_columns'); function mk_manage_clients_columns($column) { global $post; if ($post->post_type == "clients") { switch ($column) { case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_clients_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Animated Columns Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('animated-columns', $supports = array( 'title', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-align-center', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true); function mk_edit_animated_columns($columns) { $columns = array( "cb" => "", 'title' => __('Client Name', 'mk_framework') , "icon_type" => __('Icon Type', 'mk_framework') , "column_title" => __('Column Title', 'mk_framework') , "column_desc" => __('Column Description', 'mk_framework') , "date" => 'Date', ); return $columns; } add_filter('manage_edit-animated-columns_columns', 'mk_edit_animated_columns'); function mk_manage_animated_columns($column) { global $post; if ($post->post_type == "animated-columns") { switch ($column) { case "icon_type": echo get_post_meta($post->ID, '_icon_type', true); break; case "column_title": echo get_post_meta($post->ID, '_title', true); break; case "column_desc": echo get_post_meta($post->ID, '_desc', true); break; } } } add_action('manage_posts_custom_column', 'mk_manage_animated_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Banner Builder Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('banner_builder', $supports = array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-format-image', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true); function mk_edit_banner_builder_columns($columns) { $columns = array( "cb" => "", "title" => __('Slider Item Title', 'mk_framework') , "thumbnail" => 'Thumbnail', "date" => 'Date', ); return $columns; } add_filter('manage_edit-banner_builder_columns', 'mk_edit_banner_builder_columns'); function mk_manage_banner_builder_columns($column) { global $post; if ($post->post_type == "banner_builder") { switch ($column) { case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_banner_builder_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Edge Slider Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('edge', $supports = array( 'title', 'page-attributes', 'editor', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-image-flip-horizontal', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true, array( 'name' => sprintf(_x('%s', 'post type general name', 'mk_framework') , 'Edge Slider') , 'singular_name' => sprintf(_x('%s', 'post type singular title', 'mk_framework') , 'Edge Slider') , 'menu_name' => sprintf(__('%s', 'artbees') , 'Edge Slider') , 'all_items' => sprintf(__('All %s', 'mk_framework') , 'Slides') , 'add_new' => sprintf(_x('Add New', '%s', 'mk_framework') , 'Edge Slide') , 'add_new_item' => sprintf(__('Add New %s', 'mk_framework') , 'Edge Slide') , 'edit_item' => sprintf(__('Edit %s', 'mk_framework') , 'Edge Slide') , 'new_item' => sprintf(__('New %s', 'mk_framework') , 'Edge Slide') , 'view_item' => sprintf(__('View %s', 'mk_framework') , 'Edge Slide') , 'items_archive' => sprintf(__('%s Archive', 'mk_framework') , 'Edge Slider') , 'search_items' => sprintf(__('Search %s', 'mk_framework') , 'Edge Slides') , 'not_found' => sprintf(__('No %s found', 'mk_framework') , 'Edge Slides') , 'not_found_in_trash' => sprintf(__('No %s found in trash', 'mk_framework') , 'Edge Slides') , 'parent_item_colon' => sprintf(__('%s Parent', 'mk_framework') , 'Edge Slide') , )); function mk_edit_edge_slider_columns($columns) { $columns = array( "cb" => "", "title" => __('Title', 'mk_framework') , "caption_title" => 'Caption Title', "caption_desc" => 'Caption Description', "slider_type" => 'Slider Type', "thumbnail" => 'Thumbnail', "date" => 'Date', ); return $columns; } add_filter('manage_edit-edge_columns', 'mk_edit_edge_slider_columns'); function mk_get_image_id_by_url($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url)); if (isset($attachment[0])) return $attachment[0]; } function mk_manage_edge_columns($column) { global $post; if ($post->post_type == "edge") { $slider_type = get_post_meta($post->ID, '_edge_type', true); switch ($column) { case "slider_type": echo ucwords($slider_type); break; case "caption_title": echo get_post_meta($post->ID, '_title', true); break; case "caption_desc": echo get_post_meta($post->ID, '_description', true); break; case 'thumbnail': if ($slider_type == 'image') { $url = get_post_meta($post->ID, '_slide_image', true); } else { $url = get_post_meta($post->ID, '_video_preview', true); } if (!empty($url)) { $image_id = mk_get_image_id_by_url($url); if (!empty($image_id)) { $image = wp_get_attachment_image_src($image_id, 'thumbnail'); if (!empty($image[0])) { echo ''; } } } break; } } } add_action('manage_posts_custom_column', 'mk_manage_edge_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Employee Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('employees', $supports = array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-groups', 'has_archive' => true, 'rewrite' => array( 'slug' => _x('team', 'URL slug', 'mk_framework') , 'with_front' => FALSE ) , ), $singular = false); Mk_Register_custom_taxonomy('employees_category', 'employees', array( 'rewrite' => array( 'slug' => _x('employees_category', 'URL slug', 'mk_framework') , 'with_front' => FALSE ) )); function mk_edit_employees_columns($columns) { $columns = array( "cb" => "", 'title' => __('Employee Name', 'mk_framework') , "position" => __('Position', 'mk_framework') , "desc" => __('Description', 'mk_framework') , "thumbnail" => __('Thumbnail', 'mk_framework') , ); return $columns; } add_filter('manage_edit-employees_columns', 'mk_edit_employees_columns'); function mk_manage_employees_columns($column) { global $post; if ($post->post_type == "employees") { switch ($column) { case "position": echo get_post_meta($post->ID, '_position', true); break; case "desc": echo get_post_meta($post->ID, '_desc', true); break; case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_employees_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register FAQ Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('faq', $supports = array( 'title', 'editor', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-editor-help', 'has_archive' => true, 'rewrite' => array( 'slug' => 'faq' ) , ) , $singular = true); /** * Registers Faq taxonomy */ Mk_Register_custom_taxonomy('faq_category', 'faq'); /*-----------------------------------------------------------------------------------*/ /* Register News Custom Post type */ /*-----------------------------------------------------------------------------------*/ $news_slug = isset($mk_options['news_slug']) ? $mk_options['news_slug'] : 'news-posts'; Mk_Register_Custom_Post_Type('news', $supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-welcome-widgets-menus', 'has_archive' => true, 'rewrite' => array( 'slug' => _x($news_slug, 'URL slug', 'mk_framework') , 'with_front' => FALSE ) , ) , $singular = true); /** * Registers News taxonomy */ Mk_Register_custom_taxonomy('news_category', 'news'); function mk_edit_news_columns($columns) { $columns = array( "cb" => "", "title" => _x('news Name', 'column name', 'mk_framework') , "news_categories" => __('Categories', 'mk_framework') , "description" => __('Description', 'mk_framework') , "thumbnail" => __('Thumbnail', 'mk_framework') , "date" => 'Date', ); return $columns; } add_filter('manage_edit-news_columns', 'mk_edit_news_columns'); function mk_manage_news_columns($column) { global $post; if ($post->post_type == "news") { switch ($column) { case "description": the_excerpt(); break; case "news_categories": $terms = get_the_terms($post->ID, 'news_category'); if (!empty($terms)) { foreach ($terms as $t) $output[] = " " . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'news_tag', 'display')) . ""; $output = implode(', ', $output); } else { $t = get_taxonomy('news_category'); $output = "No $t->label"; } echo $output; break; case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_news_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Portfolio Custom Post type */ /*-----------------------------------------------------------------------------------*/ $portfolio_slug = isset($mk_options['portfolio_slug']) ? $mk_options['portfolio_slug'] : 'portfolio-posts'; Mk_Register_Custom_Post_Type('portfolio', $supports = array( 'title', 'editor', 'author', 'excerpt', 'thumbnail', 'comments', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-portfolio', 'has_archive' => true, 'rewrite' => array( 'slug' => _x($portfolio_slug, 'URL slug', 'mk_framework') , 'with_front' => FALSE ) , )); /** * Registers Portfolio taxonomy */ $portfolio_cat_slug = isset($mk_options['portfolio_cat_slug']) ? $mk_options['portfolio_cat_slug'] : 'portfolio_category'; Mk_Register_custom_taxonomy('portfolio_category', 'portfolio', array( 'rewrite' => array( 'slug' => _x($portfolio_cat_slug, 'URL slug', 'mk_framework') , 'with_front' => FALSE ) )); function mk_edit_portfolio_columns($columns) { $portfolio_columns = array( "cb" => "", "title" => _x('Portfolio Name', 'column name', 'mk_framework') , "portfolio_categories" => __('Categories', 'mk_framework') , "thumbnail" => __('Thumbnail', 'mk_framework') , "date" => 'Date', ); return $portfolio_columns; } add_filter('manage_edit-portfolio_columns', 'mk_edit_portfolio_columns'); function mk_manage_portfolio_columns($column) { global $post; if ($post->post_type == "portfolio") { switch ($column) { case "portfolio_categories": $terms = get_the_terms($post->ID, 'portfolio_category'); if (!empty($terms)) { foreach ($terms as $t) $output[] = " " . esc_html(sanitize_term_field('name', $t->name, $t->term_id, 'portfolio_tag', 'display')) . ""; $output = implode(', ', $output); } else { $t = get_taxonomy('portfolio_category'); $output = "No $t->label"; } echo $output; break; case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_portfolio_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Pricing Table Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('pricing', $supports = array( 'title', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-tag', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true, array( 'name' => sprintf(_x('%s', 'post type general name', 'mk_framework') , 'Pricing Table') , 'singular_name' => sprintf(_x('%s', 'post type singular title', 'mk_framework') , 'Pricing Table') , 'menu_name' => sprintf(__('%s', 'artbees') , 'Pricing Table') , 'all_items' => sprintf(__('All %s', 'mk_framework') , 'Pricing Tables') , 'add_new' => sprintf(_x('Add New', '%s', 'mk_framework') , 'Pricing Table') , 'add_new_item' => sprintf(__('Add New %s', 'mk_framework') , 'Pricing Table') , 'edit_item' => sprintf(__('Edit %s', 'mk_framework') , 'Pricing Table') , 'new_item' => sprintf(__('New %s', 'mk_framework') , 'Pricing Table') , 'view_item' => sprintf(__('View %s', 'mk_framework') , 'Pricing Table') , 'items_archive' => sprintf(__('%s Archive', 'mk_framework') , 'Pricing Tables') , 'search_items' => sprintf(__('Search %s', 'mk_framework') , 'Pricing Tables') , 'not_found' => sprintf(__('No %s found', 'mk_framework') , 'Pricing Tables') , 'not_found_in_trash' => sprintf(__('No %s found in trash', 'mk_framework') , 'Pricing Tables') , 'parent_item_colon' => sprintf(__('%s Parent', 'mk_framework') , 'Pricing Table') , )); /*-----------------------------------------------------------------------------------*/ /* Register FlexSlider Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('slideshow', $supports = array( 'title', 'page-attributes', 'thumbnail' ) , $args = array( 'menu_icon' => 'dashicons-format-gallery', 'show_in_nav_menus' => false, 'exclude_from_search' => true, ) , $singular = true, array( 'name' => sprintf(_x('%s', 'post type general name', 'mk_framework') , 'FlexSlider') , 'singular_name' => sprintf(_x('%s', 'post type singular title', 'mk_framework') , 'FlexSlide') , 'menu_name' => sprintf(__('%s', 'artbees') , 'FlexSlider') , 'all_items' => sprintf(__('All %s', 'mk_framework') , 'FlexSliders') , 'add_new' => sprintf(_x('Add New', '%s', 'mk_framework') , 'FlexSlide') , 'add_new_item' => sprintf(__('Add New %s', 'mk_framework') , 'FlexSlide') , 'edit_item' => sprintf(__('Edit %s', 'mk_framework') , 'FlexSlider') , 'new_item' => sprintf(__('New %s', 'mk_framework') , 'FlexSlider') , 'view_item' => sprintf(__('View %s', 'mk_framework') , 'FlexSlider') , 'items_archive' => sprintf(__('%s Archive', 'mk_framework') , 'FlexSlides') , 'search_items' => sprintf(__('Search %s', 'mk_framework') , 'FlexSlides') , 'not_found' => sprintf(__('No %s found', 'mk_framework') , 'FlexSlides') , 'not_found_in_trash' => sprintf(__('No %s found in trash', 'mk_framework') , 'FlexSlides') , 'parent_item_colon' => sprintf(__('%s Parent', 'mk_framework') , 'FlexSlide') , )); function mk_edit_slideshow_columns($columns) { $columns = array( "cb" => "", "title" => __('Slider Item Title', 'mk_framework') , "thumbnail" => 'Thumbnail', "date" => 'Date', ); return $columns; } add_filter('manage_edit-slideshow_columns', 'mk_edit_slideshow_columns'); function mk_manage_slideshow_columns($column) { global $post; if ($post->post_type == "slideshow") { switch ($column) { case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_slideshow_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Tab Slider Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('tab_slider', $supports = array( 'title', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-slides', 'exclude_from_search' => true, ) , $singular = true); /*-----------------------------------------------------------------------------------*/ /* Register Timeline Custom Post type */ /*-----------------------------------------------------------------------------------*/ /*Mk_Register_Custom_Post_Type('timeline', $supports = array( 'title', 'thumbnail', 'editor', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-slides', 'exclude_from_search' => true, ) , $singular = true);*/ /*-----------------------------------------------------------------------------------*/ /* Register Testimonials Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('testimonial', $supports = array( 'title', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-exerpt-view', 'exclude_from_search' => true, ) , $singular = true); Mk_Register_custom_taxonomy('testimonial_category', 'testimonial', array( 'rewrite' => array( 'slug' => _x('testimonial_category', 'URL slug', 'mk_framework') , 'with_front' => FALSE ) )); function mk_edit_testimonial_columns($columns) { $columns = array( "cb" => "", 'title' => __('Testimonial Name', 'mk_framework') , "quote_author" => __('Author', 'mk_framework') , "desc" => __('Description', 'mk_framework') , "thumbnail" => __('Thumbnail', 'mk_framework') , ); return $columns; } add_filter('manage_edit-testimonial_columns', 'mk_edit_testimonial_columns'); function mk_manage_testimonials_columns($column) { global $post; if ($post->post_type == "testimonial") { switch ($column) { case "quote_author": echo get_post_meta($post->ID, '_author', true); break; case "desc": echo get_post_meta($post->ID, '_desc', true); break; case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_testimonials_columns', 10, 2); /*-----------------------------------------------------------------------------------*/ /* Register Gallery Custom Post type */ /*-----------------------------------------------------------------------------------*/ Mk_Register_Custom_Post_Type('photo_album', $supports = array( 'title', 'thumbnail', 'page-attributes', 'revisions' ) , $args = array( 'menu_icon' => 'dashicons-format-gallery', 'exclude_from_search' => true, 'has_archive' => true, 'rewrite' => array( 'slug' => 'albums' ) , ) , $singular = true); /** * Registers Gallery taxonomy */ Mk_Register_custom_taxonomy('photo_album_category', 'photo_album'); function mk_edit_photo_album_columns($columns) { $columns = array( "cb" => "", 'title' => __('Gallery Title', 'mk_framework') , "thumbnail" => __('Conver Photo', 'mk_framework') , "images" => __('Photos', 'mk_framework') , "date" => 'Date', ); return $columns; } add_filter('manage_edit-photo_album_columns', 'mk_edit_photo_album_columns'); function mk_manage_photo_album_columns($column) { global $post; if ($post->post_type == "photo_album") { switch ($column) { case "images": $images = explode(',', get_post_meta($post->ID, '_gallery_images', true)); foreach ($images as $image) { if($image != '') { $image_src_array = wp_get_attachment_image_src( $image, 'thumbnail', true ); echo ''; } } break; case 'thumbnail': echo the_post_thumbnail('thumbnail'); break; } } } add_action('manage_posts_custom_column', 'mk_manage_photo_album_columns', 10, 2);