*/ class Ang_Timeline_Post_Type { public $post_type_name; /** * public constructor function. * * @since 1.3.0 */ public function __construct() { $this->post_type_name = 'timeline'; } /** * Register Timeline custom post type * * @since 1.3.0 */ public function register_timeline_post_type() { $labels = array( 'name' => _x( 'Timelines', 'Post Type General Name', 'ang-timeline' ), 'singular_name' => _x( 'Timeline', 'Post Type Singular Name', 'ang-timeline' ), 'menu_name' => __( 'Timeline', 'ang-timeline' ), 'name_admin_bar' => __( 'Timeline', 'ang-timeline' ), 'parent_item_colon' => __( 'Parent Timeline:', 'ang-timeline' ), 'all_items' => __( 'All Timelines', 'ang-timeline' ), 'add_new_item' => __( 'Add New Timeline', 'ang-timeline' ), 'add_new' => __( 'Add New', 'ang-timeline' ), 'new_item' => __( 'Timeline', 'ang-timeline' ), 'edit_item' => __( 'Edit Timeline', 'ang-timeline' ), 'update_item' => __( 'Update Timeline', 'ang-timeline' ), 'view_item' => __( 'View Timeline', 'ang-timeline' ), 'search_items' => __( 'Search Timeline', 'ang-timeline' ), 'not_found' => __( 'Timeline Not found', 'ang-timeline' ), 'not_found_in_trash' => __( 'Timeline Not found in Trash', 'ang-timeline' ), 'items_list' => __( 'Timelines list', 'ang-timeline' ), 'items_list_navigation' => __( 'Timelines list navigation', 'ang-timeline' ), 'filter_items_list' => __( 'Filter Timelines list', 'ang-timeline' ), ); $args = array( 'label' => __( 'Timeline', 'ang-timeline' ), 'description' => __( 'Custom Timeline', 'ang-timeline' ), 'labels' => apply_filters( 'ang_timeline_labels', $labels), 'supports' => apply_filters( 'ang_timeline_supports', array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments' ) ), 'taxonomies' => array( 'event' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 12, 'menu_icon' => 'dashicons-chart-line', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', ); register_post_type( $this->post_type_name, apply_filters( 'register_ang_timeline_arguments', $args) ); } /** * Register Timeline Event custom taxonomy * * @since 1.3.0 */ public function register_timeline_event_taxonomy() { $labels = array( 'name' => _x( 'Events', 'Taxonomy General Name', 'ang-timeline' ), 'singular_name' => _x( 'Event', 'Taxonomy Singular Name', 'ang-timeline' ), 'menu_name' => __( 'Events', 'ang-timeline' ), 'all_items' => __( 'All Events', 'ang-timeline' ), 'parent_item' => __( 'Parent Event', 'ang-timeline' ), 'parent_item_colon' => __( 'Parent Event:', 'ang-timeline' ), 'new_item_name' => __( 'New Event Name', 'ang-timeline' ), 'add_new_item' => __( 'Add New Event', 'ang-timeline' ), 'edit_item' => __( 'Edit Event', 'ang-timeline' ), 'update_item' => __( 'Update Event', 'ang-timeline' ), 'view_item' => __( 'View Event', 'ang-timeline' ), 'separate_items_with_commas' => __( 'Separate Events with commas', 'ang-timeline' ), 'add_or_remove_items' => __( 'Add or remove Events ', 'ang-timeline' ), 'choose_from_most_used' => __( 'Choose from the most used', 'ang-timeline' ), 'popular_items' => __( 'Popular Events', 'ang-timeline' ), 'search_items' => __( 'Search Events', 'ang-timeline' ), 'not_found' => __( 'Not Found', 'ang-timeline' ), 'items_list' => __( 'Events list', 'ang-timeline' ), 'items_list_navigation' => __( 'Events list navigation', 'ang-timeline' ), ); $args = array( 'labels' => apply_filters( 'ang_timeline_event_labels', $labels ), 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, ); register_taxonomy( 'event', array( $this->post_type_name ), apply_filters( 'register_ang_timeline_event_arguments', $args ) ); } /** * Add custom column headings for timeline image * Add theme support post thumbnails in timeline listing for admin * * @param array $defaults * @since 1.3.0 * @return array $defaults */ public function register_custom_column_headings($default1) { $default1['post_thumbnails'] = __('Image ', 'ang-timeline' ); return $default1; } // sortable columns public function register_custom_sortable_column_headings($sortable_columns){ $sortable_columns['post_thumbnails'] = __('Image ', 'ang-timeline' ); return $sortable_columns; } /** * Register custom column for image. * * @access public * @param string $column_name * @since 1.3.0 * @return void */ //image size public function register_custom_column($row_label) { if ($row_label === 'post_thumbnails') : print the_post_thumbnail(array(85,85)); endif; } /** * Add meta box to collect timeline meta information * * @access public * @since 1.3.0 * @return void */ public function add_timeline_meta_box () { add_meta_box( 'timeline', __( 'Timeline', 'ang-timeline' ), array( $this, 'generate_meta_box' ), $this->post_type_name, 'normal', 'high' ); } /** * Generate meta box markup on admin side * * @access public * @since 1.3.0 * @return void */ public function generate_meta_box () { global $post_id; $fields = get_post_custom( $post_id ); $field_data = $this->get_timeline_fields_settings(); $html = ''; $html .= ''; if ( 0 < count( $field_data ) ) { $html .= '
| ' . "\n";
$html .= ' ' . $v['description'] . ' ' . "\n"; $html .= ' | |