Sindbad~EG File Manager
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles');
function my_theme_enqueue_styles() {
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_filter('wp_nav_menu_items', 'search_box_function', 10, 2);
function search_box_function($nav, $args) {
if ($args->theme_location == 'navigation-menu') {
return $nav . "<li><a href='https://www.quickscrum.com/Account/Registration' class='btn btnaccess'>TRY NOW - IT'S FREE</a></li><li><a href='https://www.quickscrum.com/Account/Login' class='login-btn'>LOG IN</a></li>";
}
return $nav;
}
function custom_breadcrumbs() {
// Settings
$separator = '<img src="/wp-content/uploads/2018/10/seprator.jpg">';
$breadcrums_id = 'breadcrumbs';
$breadcrums_class = 'breadcrumbs';
$home_title = 'Home';
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
$custom_taxonomy = 'product_cat';
// Get the query & post information
global $post,$wp_query;
// Do not display on the homepage
if ( !is_front_page() ) {
// Build the breadcrums
echo '<ul id="' . $breadcrums_id . '" class="' . $breadcrums_class . '">';
// Home page
echo '<li class="item-home"><a class="bread-link bread-home" href="' . get_home_url() . '" title="' . $home_title . '">' . $home_title . '</a></li>';
echo '<li class="separator separator-home"> ' . $separator . ' </li>';
if ( is_archive() && !is_tax() && !is_category() && !is_tag() ) {
echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . post_type_archive_title($prefix, false) . '</strong></li>';
} else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
$custom_tax_name = get_queried_object()->name;
echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . $custom_tax_name . '</strong></li>';
} else if ( is_single() ) {
// If post is a custom post type
$post_type = get_post_type();
// If it is a custom post type display name and link
if($post_type != 'post') {
if ( $post_type != 'article' ) {
$post_type_object = get_post_type_object($post_type);
$post_type_archive = get_post_type_archive_link($post_type);
echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' . $post_type_object->labels->name . '">' . $post_type_object->labels->name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
} else {
$prev_page_link = $_SERVER['HTTP_REFERER'];
$get_category = get_the_terms( get_the_ID(), 'help' );
foreach ( $get_category as $cat){
if ( $cat->parent == 0 ) {
$category_link = get_category_link( $cat->term_id );
//echo $category_link;
echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $category_link . '">' . $cat->name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
}
}
}
}
// Get post category info
$category = get_the_category();
if(!empty($category)) {
// Get last category post is in
$last_category = end(array_values($category));
// Get parent any categories and create array
$get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
$cat_parents = explode(',',$get_cat_parents);
// Loop through parent categories and store in variable $cat_display
$cat_display = '';
foreach($cat_parents as $parents) {
//$cat_display .= '<li class="item-cat">'.$parents.'</li>';
//$cat_display .= '<li class="separator"> ' . $separator . ' </li>';
}
}
// If it's a custom post type within a custom taxonomy
$taxonomy_exists = taxonomy_exists($custom_taxonomy);
if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
$taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
$cat_id = $taxonomy_terms[0]->term_id;
$cat_nicename = $taxonomy_terms[0]->slug;
$cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
$cat_name = $taxonomy_terms[0]->name;
}
// Check if the post is in a category
if(!empty($last_category)) {
echo $cat_display;
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
// Else if post is in a custom taxonomy
} else if(!empty($cat_id)) {
echo '<li class="item-cat item-cat-' . $cat_id . ' item-cat-' . $cat_nicename . '"><a class="bread-cat bread-cat-' . $cat_id . ' bread-cat-' . $cat_nicename . '" href="' . $cat_link . '" title="' . $cat_name . '">' . $cat_name . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
} else {
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
}
} else if ( is_category() ) {
// Category page
echo '<li class="item-current item-cat"><strong class="bread-current bread-cat">' . single_cat_title('', false) . '</strong></li>';
} else if ( is_page() ) {
// Standard page
if( $post->post_parent ){
// If child page, get parents
$anc = get_post_ancestors( $post->ID );
// Get parents in the right order
$anc = array_reverse($anc);
// Parent page loop
if ( !isset( $parents ) ) $parents = null;
foreach ( $anc as $ancestor ) {
$parents .= '<li class="item-parent item-parent-' . $ancestor . '"><a class="bread-parent bread-parent-' . $ancestor . '" href="' . get_permalink($ancestor) . '" title="' . get_the_title($ancestor) . '">' . get_the_title($ancestor) . '</a></li>';
$parents .= '<li class="separator separator-' . $ancestor . '"> ' . $separator . ' </li>';
}
// Display parent pages
echo $parents;
// Current page
echo '<li class="item-current item-' . $post->ID . '"><strong title="' . get_the_title() . '"> ' . get_the_title() . '</strong></li>';
} else {
// Just display current page if not parents
if ( get_the_title() == 'Article Sub Category' ) {
$current_category = $_REQUEST['category'];
$get_current_category = str_replace("-"," ",$current_category);
$category = ucwords($get_current_category);
echo '<li class="item-' . $post->ID . '"><a href="'.$_SERVER['HTTP_REFERER'].'" class="bread-current bread-' . $post->ID . '"> ' . $category . '</a></li>';
echo '<li class="separator"> ' . $separator . ' </li>';
echo '<li class="item-current"> '. get_the_category_by_ID($_REQUEST['id']).' </li>';
} else {
echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '"> ' . get_the_title() . '</strong></li>';
}
}
} else if ( is_tag() ) {
// Tag page
// Get tag information
$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args = 'include=' . $term_id;
$terms = get_terms( $taxonomy, $args );
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
// Display the tag name
echo '<li class="item-current item-tag-' . $get_term_id . ' item-tag-' . $get_term_slug . '"><strong class="bread-current bread-tag-' . $get_term_id . ' bread-tag-' . $get_term_slug . '">' . $get_term_name . '</strong></li>';
} elseif ( is_day() ) {
// Day archive
// Year link
echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
// Month link
echo '<li class="item-month item-month-' . get_the_time('m') . '"><a class="bread-month bread-month-' . get_the_time('m') . '" href="' . get_month_link( get_the_time('Y'), get_the_time('m') ) . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('m') . '"> ' . $separator . ' </li>';
// Day display
echo '<li class="item-current item-' . get_the_time('j') . '"><strong class="bread-current bread-' . get_the_time('j') . '"> ' . get_the_time('jS') . ' ' . get_the_time('M') . ' Archives</strong></li>';
} else if ( is_month() ) {
// Month Archive
// Year link
echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
// Month display
echo '<li class="item-month item-month-' . get_the_time('m') . '"><strong class="bread-month bread-month-' . get_the_time('m') . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</strong></li>';
} else if ( is_year() ) {
// Display year archive
echo '<li class="item-current item-current-' . get_the_time('Y') . '"><strong class="bread-current bread-current-' . get_the_time('Y') . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</strong></li>';
} else if ( is_author() ) {
// Auhor archive
// Get the author information
global $author;
$userdata = get_userdata( $author );
// Display author name
echo '<li class="item-current item-current-' . $userdata->user_nicename . '"><strong class="bread-current bread-current-' . $userdata->user_nicename . '" title="' . $userdata->display_name . '">' . 'Author: ' . $userdata->display_name . '</strong></li>';
} else if ( get_query_var('paged') ) {
// Paginated archives
echo '<li class="item-current item-current-' . get_query_var('paged') . '"><strong class="bread-current bread-current-' . get_query_var('paged') . '" title="Page ' . get_query_var('paged') . '">'.__('Page') . ' ' . get_query_var('paged') . '</strong></li>';
} else if ( is_search() ) {
// Search results page
echo '<li class="item-current item-current-' . get_search_query() . '"><strong class="bread-current bread-current-' . get_search_query() . '" title="Search results for: ' . get_search_query() . '">Search results for: ' . get_search_query() . '</strong></li>';
} elseif ( is_404() ) {
// 404 page
echo '<li>' . 'Error 404' . '</li>';
}
echo '</ul>';
}
}
/* E- Books Start */
if ( ! function_exists( 'ebooks_register' ) ) :
add_action( 'init', 'ebooks_register' );
function ebooks_register() {
$labels = array(
'name' => __( 'E-books', 'nicethemes' ),
'singular_name' => __( 'E-book', 'nicethemes' ),
'add_new' => __( 'Add New', 'nicethemes' ),
'add_new_item' => __( 'Add New E-book', 'nicethemes' ),
'edit_item' => __( 'Edit E-book', 'nicethemes' ),
'new_item' => __( 'New E-book', 'nicethemes' ),
'view_item' => __( 'View E-book', 'nicethemes' ),
'search_items' => __( 'Search E-books', 'nicethemes' ),
'not_found' => __( 'No E-books found', 'nicethemes' ),
'not_found_in_trash' => __( 'No E-books found in Trash', 'nicethemes' ),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'ebook', 'with_front' => false ),
'capability_type' => 'page',
'hierarchical' => false,
'menu_icon' => nice_admin_menu_icon( 'btn-article.png' ),
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'comments', 'author', 'revisions' )
);
register_post_type( 'ebook', $args );
}
endif;
if ( ! function_exists( 'ebooks_taxonomies' ) ) :
add_action( 'init', 'ebooks_taxonomies', 0 );
function ebooks_taxonomies() {
$nice_category_labels = array(
'name' => __( 'Categories', 'nicethemes' ),
'singular_name' => __( 'Category', 'nicethemes' ),
'search_items' => __( 'Categories', 'nicethemes' ),
'all_items' => __( 'All Categories', 'nicethemes' ),
'parent_item' => __( 'Parent Category', 'nicethemes' ),
'parent_item_colon' => __( 'Parent Category:', 'nicethemes' ),
'edit_item' => __( 'Edit Category', 'nicethemes' ),
'update_item' => __( 'Update Category', 'nicethemes' ),
'add_new_item' => __( 'Add New Category', 'nicethemes' ),
'new_item_name' => __( 'New Category', 'nicethemes' )
);
register_taxonomy( 'ebooks', array( 'ebook' ) ,
array(
'hierarchical' => true,
'labels' => $nice_category_labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'ebooks' ),
)
);
$nice_tag_labels = array(
'name' => __( 'Tags', 'nicethemes' ),
'singular_name' => __( 'Tag', 'nicethemes' ),
'search_items' => __( 'Tags', 'nicethemes' ),
'all_items' => __( 'All Tags', 'nicethemes' ),
'parent_item' => __( 'Parent Tag', 'nicethemes' ),
'parent_item_colon' => __( 'Parent Tag:', 'nicethemes' ),
'edit_item' => __( 'Edit Tag', 'nicethemes' ),
'update_item' => __( 'Update Tag', 'nicethemes' ),
'add_new_item' => __( 'Add New Tag', 'nicethemes' ),
'new_item_name' => __( 'New Tag', 'nicethemes' )
);
register_taxonomy( 'ebooks-tag', array( 'ebook', 'faq' ) ,
array(
'hierarchical' => false,
'labels' => $nice_tag_labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'ebook-tag' ),
)
);
register_taxonomy( 'post_format', 'ebooks',
array(
'public' => true,
'hierarchical' => false,
'labels' => array(
'name' => _x( 'Format', 'post format', 'nicethemes' ),
'singular_name' => _x( 'Format', 'post format', 'nicethemes' ),
),
'query_var' => true,
'show_ui' => false,
'_builtin' => true,
'show_in_nav_menus' => current_theme_supports( 'post-formats' ),
)
);
}
endif;
if ( ! function_exists( 'ebooks_columns' ) ) :
add_filter( 'manage_edit-ebook_columns', 'ebooks_columns' ) ;
function ebooks_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'E-book', 'nicethemes' ),
'ebooks' => __( 'E-book Category', 'nicethemes' ),
'ebooks-tag' => __( 'Tags', 'nicethemes' ),
'author' => __( 'Author', 'nicethemes' ),
'date' => __( 'Date', 'nicethemes' )
);
return $columns;
}
endif;
if ( ! function_exists( 'ebooks_columns_custom' ) ) :
add_action( 'manage_ebook_posts_custom_column', 'ebooks_columns_custom', 10, 2 );
function ebooks_columns_custom( $column, $post_id ) {
global $post;
switch( $column ) {
/* If displaying the 'ebooks' column. */
case 'ebooks' :
/* Get the genres for the post. */
$terms = get_the_terms( $post_id, 'ebooks' );
/* If terms were found. */
if ( ! empty( $terms ) ) {
$out = array();
/* Loop through each term, linking to the 'edit posts' page for the specific term. */
foreach ( $terms as $term ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'ebooks' => $term->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'ebooks', 'display' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( ', ', $out );
}
/* If no terms were found, output a default message. */
else {
echo '—';
}
break;
/* If displaying the 'ebooks-tag' column. */
case 'ebooks-tag' :
/* Get the genres for the post. */
$terms = get_the_terms( $post_id, 'ebooks-tag' );
/* If terms were found. */
if ( ! empty( $terms ) ) {
$out = array();
/* Loop through each term, linking to the 'edit posts' page for the specific term. */
foreach ( $terms as $term ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'ebooks-tag' => $term->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'ebooks-tag', 'display' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( ', ', $out );
}
/* If no terms were found, output a default message. */
else {
echo '—';
}
break;
/* Just break out of the switch statement for everything else. */
default :
break;
}
}
endif;
if ( ! function_exists( 'ebooks_columns_sortable' ) ) :
add_filter( 'manage_edit-ebook_sortable_columns', 'ebooks_columns_sortable' );
function ebooks_columns_sortable( $columns ) {
$columns['ebooks'] = 'ebooks';
$columns['ebooks-tag'] = 'ebooks-tag';
$columns['author'] = 'author';
return $columns;
}
endif;
/* E- Books End */
/* File Upload In Ebooks Start */
function add_custom_meta_boxes() {
add_meta_box('wp_custom_attachment', 'Upload Attachment', 'wp_custom_attachment', 'ebook', 'normal', 'high');
}
add_action('add_meta_boxes', 'add_custom_meta_boxes');
function wp_custom_attachment() {
$filearray = get_post_meta( $_REQUEST['post'], 'wp_custom_attachment', true );
if ( is_array($filearray) ) {
$this_file = $filearray['url'];
}
wp_nonce_field(plugin_basename(__FILE__), 'wp_custom_attachment_nonce');
$html = '<p class="description">';
$html .= 'Upload your PDF here.';
$html .= '</p>';
$html .= '<input type="file" id="wp_custom_attachment" name="wp_custom_attachment" value="" size="25">';
if (is_array($filearray) && $this_file != '') {
$html .= '<p class="description">';
$html .= '<strong>Uploaded Attachement: </strong><span><a href="'.$this_file.'" target="_blank">'.$this_file.'</a></span>';
$html .= '</p>';
}
echo $html;
}
add_action('save_post', 'save_custom_meta_data');
function save_custom_meta_data($id) {
if(!empty($_FILES['wp_custom_attachment']['name'])) {
$supported_types = array('application/pdf');
$arr_file_type = wp_check_filetype(basename($_FILES['wp_custom_attachment']['name']));
$uploaded_type = $arr_file_type['type'];
if(in_array($uploaded_type, $supported_types)) {
$upload = wp_upload_bits($_FILES['wp_custom_attachment']['name'], null, file_get_contents($_FILES['wp_custom_attachment']['tmp_name']));
if(isset($upload['error']) && $upload['error'] != 0) {
wp_die('There was an error uploading your file. The error is: ' . $upload['error']);
} else {
add_post_meta($id, 'wp_custom_attachment', $upload);
update_post_meta($id, 'wp_custom_attachment', $upload);
}
}
else {
wp_die("The file type that you've uploaded is not a PDF.");
}
}
}
function update_edit_form() {
echo ' enctype="multipart/form-data"';
}
add_action('post_edit_form_tag', 'update_edit_form');
/* File Upload In Ebooks End */
/* Custom CSS Start */
add_action('admin_head', 'my_custom_css');
function my_custom_css() {
echo '<style>
#adminmenu .menu-icon-ebook div.wp-menu-image img {
display: block;
}
#adminmenu .menu-icon-ebook div.wp-menu-image:before {
content: "";
}
#adminmenu .menu-icon-ebook div.wp-menu-image:before {
content: "\f331";
}
#adminmenu .menu-icon-ebook div.wp-menu-image img {
display: none;
}
#adminmenu .menu-icon-case-study div.wp-menu-image img {
display: block;
}
#adminmenu .menu-icon-case-study div.wp-menu-image:before {
content: "";
}
#adminmenu .menu-icon-case-study div.wp-menu-image:before {
content: "\f116";
}
#adminmenu .menu-icon-case-study div.wp-menu-image img {
display: none;
}
</style>';
}
/* Custom CSS End */
/* Custom Pagination For Article Start */
function custom_pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
echo "</div>\n";
}
}
/* Custom Pagination For Article End */
/* Case Study Start */
if ( ! function_exists( 'case_study_register' ) ) :
add_action( 'init', 'case_study_register' );
function case_study_register() {
$labels = array(
'name' => __( 'Case Studies', 'nicethemes' ),
'singular_name' => __( 'Case Study', 'nicethemes' ),
'add_new' => __( 'Add New', 'nicethemes' ),
'add_new_item' => __( 'Add New Case Study', 'nicethemes' ),
'edit_item' => __( 'Edit Case Study', 'nicethemes' ),
'new_item' => __( 'New Case Study', 'nicethemes' ),
'view_item' => __( 'View Case Study', 'nicethemes' ),
'search_items' => __( 'Search Case Studies', 'nicethemes' ),
'not_found' => __( 'No Case Studies found', 'nicethemes' ),
'not_found_in_trash' => __( 'No Case Studies found in Trash', 'nicethemes' ),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'case-study', 'with_front' => false ),
'capability_type' => 'page',
'hierarchical' => false,
'menu_icon' => nice_admin_menu_icon( 'btn-case-study.png' ),
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'comments', 'author', 'revisions' ,'excerpt' )
);
register_post_type( 'case-study', $args );
}
endif;
if ( ! function_exists( 'case_study_taxonomies' ) ) :
add_action( 'init', 'case_study_taxonomies', 0 );
function case_study_taxonomies() {
$nice_category_labels = array(
'name' => __( 'Categories', 'nicethemes' ),
'singular_name' => __( 'Category', 'nicethemes' ),
'search_items' => __( 'Categories', 'nicethemes' ),
'all_items' => __( 'All Categories', 'nicethemes' ),
'parent_item' => __( 'Parent Category', 'nicethemes' ),
'parent_item_colon' => __( 'Parent Category:', 'nicethemes' ),
'edit_item' => __( 'Edit Category', 'nicethemes' ),
'update_item' => __( 'Update Category', 'nicethemes' ),
'add_new_item' => __( 'Add New Category', 'nicethemes' ),
'new_item_name' => __( 'New Category', 'nicethemes' )
);
register_taxonomy( 'case-study-category', array( 'case-study' ) ,
array(
'hierarchical' => true,
'labels' => $nice_category_labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'case-study-category' ),
)
);
$nice_tag_labels = array(
'name' => __( 'Tags', 'nicethemes' ),
'singular_name' => __( 'Tag', 'nicethemes' ),
'search_items' => __( 'Tags', 'nicethemes' ),
'all_items' => __( 'All Tags', 'nicethemes' ),
'parent_item' => __( 'Parent Tag', 'nicethemes' ),
'parent_item_colon' => __( 'Parent Tag:', 'nicethemes' ),
'edit_item' => __( 'Edit Tag', 'nicethemes' ),
'update_item' => __( 'Update Tag', 'nicethemes' ),
'add_new_item' => __( 'Add New Tag', 'nicethemes' ),
'new_item_name' => __( 'New Tag', 'nicethemes' )
);
register_taxonomy( 'case-study-tag', array( 'case-study', 'faq' ) ,
array(
'hierarchical' => false,
'labels' => $nice_tag_labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'case-study-tag' ),
)
);
register_taxonomy( 'post_format', 'case-study',
array(
'public' => true,
'hierarchical' => false,
'labels' => array(
'name' => _x( 'Format', 'post format', 'nicethemes' ),
'singular_name' => _x( 'Format', 'post format', 'nicethemes' ),
),
'query_var' => true,
'show_ui' => false,
'_builtin' => true,
'show_in_nav_menus' => current_theme_supports( 'post-formats' ),
)
);
}
endif;
if ( ! function_exists( 'case_study_columns' ) ) :
add_filter( 'manage_edit-case-study_columns', 'case_study_columns' ) ;
function case_study_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Case Study', 'nicethemes' ),
'case-study-category' => __( 'Case Study Category', 'nicethemes' ),
'case-study-tag' => __( 'Tags', 'nicethemes' ),
'author' => __( 'Author', 'nicethemes' ),
'date' => __( 'Date', 'nicethemes' )
);
return $columns;
}
endif;
if ( ! function_exists( 'case_study_columns_custom' ) ) :
add_action( 'manage_case-study_posts_custom_column', 'case_study_columns_custom', 10, 2 );
function case_study_columns_custom( $column, $post_id ) {
global $post;
switch( $column ) {
/* If displaying the 'category' column. */
case 'case-study-category' :
/* Get the genres for the post. */
$terms = get_the_terms( $post_id, 'case-study-category' );
/* If terms were found. */
if ( ! empty( $terms ) ) {
$out = array();
/* Loop through each term, linking to the 'edit posts' page for the specific term. */
foreach ( $terms as $term ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'case-study-category' => $term->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'case-study-category', 'display' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( ', ', $out );
}
/* If no terms were found, output a default message. */
else {
echo '—';
}
break;
/* If displaying the 'taf' column. */
case 'case-study-tag' :
/* Get the genres for the post. */
$terms = get_the_terms( $post_id, 'case-study-tag' );
/* If terms were found. */
if ( ! empty( $terms ) ) {
$out = array();
/* Loop through each term, linking to the 'edit posts' page for the specific term. */
foreach ( $terms as $term ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'case-study-tag' => $term->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'case-study-tag', 'display' ) )
);
}
/* Join the terms, separating them with a comma. */
echo join( ', ', $out );
}
/* If no terms were found, output a default message. */
else {
echo '—';
}
break;
/* Just break out of the switch statement for everything else. */
default :
break;
}
}
endif;
if ( ! function_exists( 'case_study_columns_sortable' ) ) :
add_filter( 'manage_edit-case-study_sortable_columns', 'case_study_columns_sortable' );
function case_study_columns_sortable( $columns ) {
$columns['case-study-category'] = 'case-study-category';
$columns['case-study-tag'] = 'case-study-tag';
$columns['author'] = 'author';
return $columns;
}
endif;
/* Case Study End */
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists