only admin access category

owl 2015-04-27 17.32.10

Hint V2


function admin_category( $template ) {
    $allow = true;
    
    $post = get_post();
    if (!empty( $post )) {
        $adminManual = get_post_meta($post->ID, "adminManual", true);
        if ($adminManual=="1") {
            $allow = check_admin();
            return $allow ? $template : get_template_directory() . '/404.php';
        }
    }
    
  if ( ! is_main_query() ) return $template;
  $private_categories = array('%ea%b4%80%eb%a6%ac%ec%9e%90-%eb%a7%a4%eb%89%b4%ec%96%bc', '관리자 매뉴얼', 'Admin Manual'); 
  if ( is_single() ) {
    $cats = wp_get_object_terms( get_queried_object()->ID, 'category', array('fields' => 'slugs') ); 
    if ( array_intersect( $private_categories, $cats ) ) {
      $allow = check_admin();
    }
    if (is_super_admin()){ 
        //print_r($cats);
        //die();
    }
    
  } elseif ( is_category($private_categories) ) {
    $allow = check_admin();
  }
  return $allow ? $template : get_template_directory() . '/404.php';
}