/** * This tag will output a list of groups attached to the current page. * * @global wpdb $wpdb * @global array $post */ public static function groups_attached($atts) { global $wpdb, $post; //Attribute defaults $output = shortcode_atts(array('public' => 'false', 'label' => __('Groups attached to this page:', 'contexture-page-security')), $atts); //Create an array of groups that are already attached to the page $currentGroups = ''; foreach (CTXPS_Queries::get_groups_by_post($post->ID) as $curGrp) { $currentGroups .= "<li>" . $curGrp->group_title . " (id:{$curGrp->sec_access_id})</li>"; } $currentGroups = empty($currentGroups) ? '<li><em>' . __('No groups attached.', 'contexture-page-security') . '</em></li>' : $currentGroups; $return = "<div class=\"ctx-ps-groupvis\"><h3>{$output['label']}</h3><ol>{$currentGroups}</ol></div>"; if ($output['public'] === 'true') { return $return; } else { return current_user_can('edit_others_posts') ? $return : ''; } }