Example #1
0
 /**
  * Sets up each column's output.
  *
  * @since 1.0.0
  *
  * @param array  $item        The current row item.
  * @param string $column_name The name of the column.
  * @return mixed|string The shortcode column output.
  */
 public function column_default($item, $column_name)
 {
     global $render_sc_table_disabled;
     $render_sc_table_disabled = (array) $render_sc_table_disabled;
     $categories = render_get_shortcode_categories();
     switch ($column_name) {
         case 'code':
         case 'source':
         case 'description':
             return $item[$column_name];
             break;
         case 'category':
             if (isset($categories[$item[$column_name]])) {
                 return $categories[$item[$column_name]]['label'];
             } else {
                 return $item[$column_name];
             }
             break;
         case 'attributes':
             if (!empty($item[$column_name])) {
                 $atts = array();
                 foreach ($item[$column_name] as $att) {
                     if (isset($att['label'])) {
                         $atts[] = $att['label'];
                     }
                 }
                 $output = implode(', ', $atts);
             } else {
                 $output = 'None';
             }
             return $output;
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
Example #2
0
/**
 * Returns all shortcode categories currently in use.
 *
 * @since 1.0.0
 *
 * @return array Categories in use.
 */
function render_get_shortcode_used_categories()
{
    global $Render;
    $used_categories = array_values(array_unique(wp_list_pluck($Render->shortcodes, 'category')));
    return array_merge(array('all' => array('label' => __('All', 'Render'), 'icon' => 'dashicons-tagcloud')), array_intersect_key(render_get_shortcode_categories(), array_flip($used_categories)));
}