Пример #1
0
 /**
  * Load all of our data
  *
  * @access      public
  * @since       1.0
  * @return      void
  */
 function prepare_items()
 {
     /**
      * First, lets decide how many records per page to show
      */
     $per_page = 20;
     $paged = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
     $columns = $this->get_columns();
     $hidden = array();
     // no hidden columns
     $this->_column_headers = array($columns, $hidden, array());
     $this->process_bulk_action();
     $meta_query = array();
     if (isset($_GET['user'])) {
         $meta_query[] = array('key' => '_wp_log_user_id', 'value' => absint($_GET['user']));
     }
     $this->items = WP_Logging::get_connected_logs(array('log_type' => 'gateway_error', 'paged' => $paged, 'posts_per_page' => $per_page, 'meta_query' => $meta_query));
     $current_page = $this->get_pagenum();
     $total_items = WP_Logging::get_log_count(0, 'gateway_error', $meta_query);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
    function log_page()
    {
        $page = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
        $this->current_log_type = empty($_GET['log']) ? 'ctct_' . self::$methods[0] : $_GET['log'];
        // trying to acces a log type that's not enabled.
        if (!in_array(str_replace('ctct_', '', $this->current_log_type), self::$methods)) {
            return;
        }
        $args = array('posts_per_page' => $this->logs_per_page, 'paged' => $page, 'log_type' => $this->current_log_type);
        $logs = WP_Logging::get_connected_logs($args);
        ?>
		<div class="wrap">

			<h2><?php 
        esc_html_e('Constant Contact Log', 'ctct');
        ?>
</h2>

			<?php 
        $this->print_pagination($page);
        $this->print_navigation();
        ?>
			 <table class="ctct_table widefat">
				<thead>
				<tr>
					<th class="title"><?php 
        esc_html_e('Title', 'kwslog');
        ?>
</th>
					<th class="" style="width: 30%"><?php 
        esc_html_e('Content', 'kwslog');
        ?>
</th>
					<th class="column column-post_date"><?php 
        esc_html_e('Date', 'kwslog');
        ?>
</th>
				</tr>
				</thead>
					<tbody>
					<?php 
        if ($logs) {
            foreach ($logs as $log) {
                ?>
								<tr>
									<td><?php 
                echo get_the_title($log);
                ?>
</td>
									<td><?php 
                $content = $log->post_content;
                $message = get_post_meta($log->ID, '_wp_log_message', true);
                $data = get_post_meta($log->ID, '_wp_log_data', true);
                foreach (array($content, $message, $data) as $key => $item) {
                    if (empty($item)) {
                        continue;
                    }
                    $item = maybe_unserialize($item);
                    echo '<pre>';
                    ob_start();
                    print_r($item);
                    $item_output = ob_get_clean();
                    echo esc_html($item_output);
                    echo '</pre>';
                }
                ?>
</td>
									<td><?php 
                echo esc_html($log->post_date);
                ?>
</td>
								</tr>
							<?php 
            }
        } else {
            ?>
					<tr>
						<td colspan="3" style="text-align:center;">
						<h4><?php 
            esc_html_e('No activity has been logged.');
            ?>
</h4>
						</td>
					</tr>
					<?php 
        }
        ?>
				</tbody>
			</table>

			<?php 
        $this->print_pagination($page);
        ?>

		</div>
	<?php 
    }