コード例 #1
0
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'date':
             $created = date('Y-m-d H:i:s', strtotime($item->created));
             $date_string = sprintf('<time datetime="%s" class="relative-time record-created">%s</time>', wp_stream_get_iso_8601_extended_date(strtotime($item->created)), get_date_from_gmt($created, 'Y/m/d'));
             $out = $this->column_link($date_string, 'date', get_date_from_gmt($created, 'Y/m/d'));
             $out .= '<br />';
             $out .= get_date_from_gmt($created, 'h:i:s A');
             break;
         case 'summary':
             $out = $item->summary;
             $object_title = wp_stream_get_object_title($item);
             $view_all_text = $object_title ? sprintf(__('View all activity for "%s"', 'stream'), esc_attr($object_title)) : __('View all activity for this object', 'stream');
             if ($item->object_id) {
                 $out .= $this->column_link('<span class="dashicons dashicons-search stream-filter-object-id"></span>', array('object_id' => $item->object_id, 'context' => $item->context), null, esc_attr($view_all_text));
             }
             $out .= $this->get_action_links($item);
             break;
         case 'author':
             $author = new WP_Stream_Author((int) $item->author, (array) $item->author_meta);
             $out = sprintf('<a href="%s">%s <span>%s</span></a>%s%s%s', $author->get_records_page_url(), $author->get_avatar_img(80), $author->get_display_name(), $author->is_deleted() ? sprintf('<br /><small class="deleted">%s</small>', esc_html__('Deleted User', 'stream')) : '', $author->get_role() ? sprintf('<br /><small>%s</small>', $author->get_role()) : '', $author->get_agent() ? sprintf('<br /><small>%s</small>', WP_Stream_Author::get_agent_label($author->get_agent())) : '');
             break;
         case 'context':
             $connector_title = $this->get_term_title($item->{'connector'}, 'connector');
             $context_title = $this->get_term_title($item->{'context'}, 'context');
             $out = $this->column_link($connector_title, 'connector', $item->{'connector'});
             $out .= '<br />&#8627;&nbsp;';
             $out .= $this->column_link($context_title, array('connector' => $item->{'connector'}, 'context' => $item->{'context'}));
             break;
         case 'action':
             $out = $this->column_link($this->get_term_title($item->{$column_name}, $column_name), $column_name, $item->{$column_name});
             break;
         case 'ip':
             $out = $this->column_link($item->{$column_name}, 'ip', $item->{$column_name});
             break;
         default:
             /**
              * Registers new Columns to be inserted into the table.  The cell contents of this column is set
              * below with 'wp_stream_inster_column_default-'
              *
              * @since 1.0.0
              *
              * @return array
              */
             $inserted_columns = apply_filters('wp_stream_register_column_defaults', $new_columns = array());
             if (!empty($inserted_columns) && is_array($inserted_columns)) {
                 foreach ($inserted_columns as $column_title) {
                     /**
                      * If column title inserted via wp_stream_register_column_defaults ($column_title) exists
                      * among columns registered with get_columns ($column_name) and there is an action associated
                      * with this column, do the action
                      *
                      * Also, note that the action name must include the $column_title registered
                      * with wp_stream_register_column_defaults
                      */
                     if ($column_title == $column_name && has_filter("wp_stream_insert_column_default-{$column_title}")) {
                         /**
                          * Allows for the addition of content under a specified column.
                          *
                          * @since 2.0.4
                          *
                          * @param object $item  Contents of the row
                          *
                          * @return string
                          */
                         $out = apply_filters("wp_stream_insert_column_default-{$column_title}", $column_name, $item);
                     } else {
                         $out = $column_name;
                     }
                 }
             } else {
                 $out = $column_name;
             }
     }
     echo $out;
     // xss ok
 }
コード例 #2
0
ファイル: list-table.php プロジェクト: xwp/stream-legacy
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'date':
             $date_string = sprintf('<time datetime="%s" class="relative-time">%s</time>', $item->created, get_date_from_gmt($item->created, 'Y/m/d'));
             $out = $this->column_link($date_string, 'date', date('Y/m/d', strtotime($item->created)));
             $out .= '<br />';
             $out .= get_date_from_gmt($item->created, 'h:i:s A');
             break;
         case 'summary':
             $out = $item->summary;
             if ($item->object_id) {
                 $out .= $this->column_link('<span class="dashicons dashicons-search stream-filter-object-id"></span>', array('object_id' => $item->object_id, 'context' => $item->context), null, __('View all records for this object', 'stream'));
             }
             $out .= $this->get_action_links($item);
             break;
         case 'author':
             require_once WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
             $author_meta = wp_stream_get_meta($item->ID, 'author_meta', true);
             $author = new WP_Stream_Author((int) $item->author, $author_meta);
             $out = sprintf('<a href="%s">%s <span>%s</span></a>%s%s%s', $author->get_records_page_url(), $author->get_avatar_img(80), $author->get_display_name(), $author->is_deleted() ? sprintf('<br /><small class="deleted">%s</small>', esc_html__('Deleted User', 'stream')) : '', $author->get_role() ? sprintf('<br /><small>%s</small>', $author->get_role()) : '', $author->get_agent() ? sprintf('<br /><small>%s</small>', WP_Stream_Author::get_agent_label($author->get_agent())) : '');
             break;
         case 'connector':
         case 'context':
         case 'action':
             $out = $this->column_link($this->get_term_title($item->{$column_name}, $column_name), $column_name, $item->{$column_name});
             break;
         case 'ip':
             $out = $this->column_link($item->{$column_name}, 'ip', $item->{$column_name});
             break;
         case 'id':
             $out = absint($item->ID);
             break;
         case 'blog_id':
             $blog = $item->blog_id && is_multisite() ? get_blog_details($item->blog_id) : WP_Stream_Network::get_network_blog();
             $out = sprintf('<a href="%s"><span>%s</span></a>', add_query_arg(array('blog_id' => $blog->blog_id), network_admin_url('admin.php?page=wp_stream')), esc_html($blog->blogname));
             break;
         default:
             /**
              * Registers new Columns to be inserted into the table.  The cell contents of this column is set
              * below with 'wp_stream_inster_column_default-'
              *
              * @param array $new_columns Array of new column titles to add
              */
             $inserted_columns = apply_filters('wp_stream_register_column_defaults', $new_columns = array());
             if (!empty($inserted_columns) && is_array($inserted_columns)) {
                 foreach ($inserted_columns as $column_title) {
                     /**
                      * If column title inserted via wp_stream_register_column_defaults ($column_title) exists
                      * among columns registered with get_columns ($column_name) and there is an action associated
                      * with this column, do the action
                      *
                      * Also, note that the action name must include the $column_title registered
                      * with wp_stream_register_column_defaults
                      */
                     if ($column_title == $column_name && has_action('wp_stream_insert_column_default-' . $column_title)) {
                         /**
                          * This action allows for the addition of content under the specified column ($column_title)
                          *
                          * @param  string $column_title Title of the column (set in wp_stream_register_column_defaults)
                          * @param  obj    $item         Contents of the row
                          */
                         $out = do_action('wp_stream_insert_column_default-' . $column_title, $item);
                     } else {
                         $out = $column_name;
                     }
                 }
             } else {
                 $out = $column_name;
                 // xss ok
             }
     }
     echo $out;
     // xss ok
 }