/**
  * Generates a "lock" symbol for the "Protected" column, if the current content
  * is protected. See WP's template.php -> display_page_row() for  more.
  *
  * @param type $column_name The name of the column to affect ('protected')
  * @param type $term_id The id of the page to check.
  */
 public static function render_term_protection_column($test, $column_name, $term_id)
 {
     //Only do this if we've got the right column
     if ($column_name === 'protected') {
         //If page is protected, return lock icon
         if (CTXPS_Queries::check_protection($term_id, 'term')) {
             CTX_Helper::img(array('alt' => __('Protected', 'contexture-page-security'), 'title' => __('Protected', 'contexture-page-security'), 'src' => CTXPSURL . 'images/protected-inline-2x.png', 'class' => "prot-icon prot-inline"));
         } else {
             if (CTXPS_Queries::check_term_protection($term_id, $_REQUEST['taxonomy'])) {
                 CTX_Helper::img(array('alt' => __('Protected (inherited)', 'contexture-page-security'), 'title' => __('Inheriting protection', 'contexture-page-security'), 'src' => CTXPSURL . 'images/protected-inline-descendant-2x.png', 'class' => "prot-icon prot-inline-descendant"));
             }
         }
     }
 }
        /**
         * JS is injected into post.php when action=edit in order to add an asterisk
         * to protected terms. This is very, very, very bad form, but there aren't the
         * necessary hooks to do this server side (well, there is, but its obviously
         * never been used for anything since it's very buggy), so it's either this or
         * nothing. In this case, I side with usability over good coding practices.
         *
         * @param type $term_name
         */
        public static function tag_protected_terms_heirarchal()
        {
            global $current_screen;
            if ($current_screen->base === 'post' && isset($_REQUEST['post'])) {
                ?>
<script type="text/javascript">jQuery(function(){<?php 
                //Get taxonomies for this post
                $taxonomies = get_post_taxonomies($_REQUEST['post']);
                //For each taxonomy, get a list of term ids used for this post
                foreach ($taxonomies as $tax) {
                    //Initialize vars
                    $terms = get_terms($tax);
                    $termlist = array();
                    //Build an array out of the term ids...
                    foreach ($terms as $term) {
                        //...but only if it's protected
                        if (CTXPS_Queries::check_term_protection($term->term_id, $tax)) {
                            $termlist[] = $term->term_id;
                        }
                    }
                    //Join the array into a CSV
                    $termlist = join(',', $termlist);
                    //Generate javascript to add asterisk to protected terms
                    if (!empty($termlist)) {
                        $tarray = "{$tax}_protect";
                        ?>
                        var <?php 
                        echo $tarray;
                        ?>
 = [<?php 
                        echo $termlist;
                        ?>
];
                        for(x in <?php 
                        echo $tarray;
                        ?>
){
                            jQuery('#<?php 
                        echo $tax;
                        ?>
div input[value="'+<?php 
                        echo $tarray;
                        ?>
[x]+'"]').parent().append('*');
                            jQuery('#<?php 
                        echo $tax;
                        ?>
div option[value="'+<?php 
                        echo $tarray;
                        ?>
[x]+'"]').append('*');
                        }
                    <?php 
                    }
                    //So there's no accidental carryovers
                    unset($terms, $termlist);
                }
                ?>
});</script><?php 
            }
            //Nothing to do
            return false;
        }