/** * Admin Page * @since 0.1 * @version 1.3.1 */ public function admin_page() { // Security if (!$this->core->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } $settings_key = 'mycred_epp_' . $_GET['page']; if (!$this->is_main_type) { $settings_key .= '_' . $this->mycred_type; } $per_page = mycred_get_user_meta($this->current_user_id, $settings_key, '', true); if ($per_page == '') { $per_page = 10; } // Prep $args = array('number' => absint($per_page)); if (isset($_GET['type']) && $_GET['type'] != '') { $args['ctype'] = sanitize_key($_GET['type']); } else { $args['ctype'] = $this->mycred_type; } if (isset($_GET['user']) && $_GET['user'] != '') { $args['user_id'] = sanitize_text_field($_GET['user']); } if (isset($_GET['s']) && $_GET['s'] != '') { $args['s'] = sanitize_text_field($_GET['s']); } if (isset($_GET['ref']) && $_GET['ref'] != '') { $args['ref'] = sanitize_text_field($_GET['ref']); } if (isset($_GET['show']) && $_GET['show'] != '') { $args['time'] = absint($_GET['show']); } if (isset($_GET['order']) && $_GET['order'] != '') { $args['order'] = sanitize_text_field($_GET['order']); } if (isset($_GET['start']) && isset($_GET['end'])) { $args['amount'] = array('start' => sanitize_text_field($_GET['start']), 'end' => sanitize_text_field($_GET['end'])); } elseif (isset($_GET['num']) && isset($_GET['compare'])) { $args['amount'] = array('num' => sanitize_text_field($_GET['num']), 'compare' => urldecode($_GET['compare'])); } elseif (isset($_GET['amount'])) { $args['amount'] = sanitize_text_field($_GET['amount']); } if (isset($_GET['data']) && $_GET['data'] != '') { $args['data'] = sanitize_text_field($_GET['data']); } if (isset($_GET['paged']) && $_GET['paged'] != '') { $args['paged'] = absint($_GET['paged']); } $log = new myCRED_Query_Log($args); $log->headers['column-actions'] = __('Actions', 'mycred'); ?> <div class="wrap" id="myCRED-wrap"> <h2><?php $this->page_title(sprintf(__('%s Log', 'mycred'), $this->core->plural())); ?> </h2> <?php // This requirement is only checked on activation. If the library is disabled // after installation we need to warn the user. Every single feature in myCRED // that requires encryption will stop working: // Points for clicking on links // Exchange Shortcode // buyCRED Add-on $extensions = get_loaded_extensions(); if (!in_array('mcrypt', $extensions) && !defined('MYCRED_DISABLE_PROTECTION')) { echo '<div id="message" class="error below-h2"><p>' . __('Warning. The required Mcrypt PHP Library is not installed on this server! Certain hooks and shortcodes will not work correctly!', 'mycred') . '</p></div>'; } // Filter by dates $log->filter_dates(admin_url('admin.php?page=' . $this->screen_id)); ?> <?php do_action('mycred_top_log_page', $this); ?> <?php $log->exporter(__('Export', 'mycred')); ?> <form method="get" action="" name="mycred-thelog-form" novalidate> <?php if (isset($_GET['type']) && $_GET['type'] != '') { echo '<input type="hidden" name="type" value="' . esc_attr($_GET['type']) . '" />'; } if (isset($_GET['user']) && $_GET['user'] != '') { echo '<input type="hidden" name="user" value="' . esc_attr($_GET['user']) . '" />'; } if (isset($_GET['s']) && $_GET['s'] != '') { echo '<input type="hidden" name="s" value="' . esc_attr($_GET['s']) . '" />'; } if (isset($_GET['ref']) && $_GET['ref'] != '') { echo '<input type="hidden" name="ref" value="' . esc_attr($_GET['ref']) . '" />'; } if (isset($_GET['show']) && $_GET['show'] != '') { echo '<input type="hidden" name="show" value="' . esc_attr($_GET['show']) . '" />'; } if (isset($_GET['order']) && $_GET['order'] != '') { echo '<input type="hidden" name="order" value="' . esc_attr($_GET['order']) . '" />'; } if (isset($_GET['data']) && $_GET['data'] != '') { echo '<input type="hidden" name="data" value="' . esc_attr($_GET['data']) . '" />'; } if (isset($_GET['paged']) && $_GET['paged'] != '') { echo '<input type="hidden" name="paged" value="' . esc_attr($_GET['paged']) . '" />'; } $log->search(); ?> <input type="hidden" name="page" value="<?php echo $this->screen_id; ?> " /> <?php do_action('mycred_above_log_table', $this); ?> <div class="tablenav top"> <?php $log->table_nav('top', false); ?> </div> <table class="mycred-table wp-list-table widefat fixed striped users" cellspacing="0" cellspacing="0"> <thead> <tr> <?php foreach ($log->headers as $col_id => $col_title) { echo '<th scope="col" id="' . str_replace('column-', '', $col_id) . '" class="manage-column ' . $col_id . '">' . $col_title . '</th>'; } ?> </tr> </thead> <tfoot> <tr> <?php foreach ($log->headers as $col_id => $col_title) { echo '<th scope="col" class="manage-column ' . $col_id . '">' . $col_title . '</th>'; } ?> </tr> </tfoot> <tbody id="the-list"> <?php if ($log->have_entries()) { $date_format = get_option('date_format') . ' ' . get_option('time_format'); $entry_data = ''; $alt = 0; foreach ($log->results as $log_entry) { $alt = $alt + 1; if ($alt % 2 == 0) { $class = ' alt'; } else { $class = ''; } echo '<tr class="myCRED-log-row' . $class . '" id="mycred-log-entry-' . $log_entry->id . '">'; // Run though columns foreach ($log->headers as $column_id => $column_name) { echo '<td class="' . $column_id . '">'; switch ($column_id) { // Username Column case 'column-username': $user = get_userdata($log_entry->user_id); if ($user === false) { $content = '<span>' . __('User Missing', 'mycred') . ' (ID: ' . $log_entry->user_id . ')</span>'; } else { $content = '<span>' . $user->display_name . '</span>'; } if ($user !== false && $this->core->can_edit_creds()) { $content .= ' <em><small>(ID: ' . $log_entry->user_id . ')</small></em>'; } echo apply_filters('mycred_log_username', $content, $log_entry->user_id, $log_entry); break; // Date & Time Column // Date & Time Column case 'column-time': echo apply_filters('mycred_log_date', date_i18n($date_format, $log_entry->time), $log_entry->time); break; // Amount Column // Amount Column case 'column-creds': $content = $this->core->format_creds($log_entry->creds); echo apply_filters('mycred_log_creds', $content, $log_entry->creds, $log_entry); break; // Log Entry Column // Log Entry Column case 'column-entry': $content = '<div style="display:none;" class="raw">' . htmlentities($log_entry->entry) . '</div>'; $content .= '<div class="entry">' . $this->core->parse_template_tags($log_entry->entry, $log_entry) . '</div>'; echo apply_filters('mycred_log_entry', $content, $log_entry->entry, $log_entry); break; // Log Action Column // Log Action Column case 'column-actions': $content = '<a href="javascript:void(0)" class="mycred-open-log-entry-editor" data-id="' . $log_entry->id . '">' . __('Edit', 'mycred') . '</a> • <span class="delete"><a href="javascript:void(0);" class="mycred-delete-row" data-id="' . $log_entry->id . '">' . __('Delete', 'mycred') . '</a></span>'; echo apply_filters('mycred_log_actions', $content, $log_entry); break; // Let others add their own columns to this particular log page // Let others add their own columns to this particular log page default: echo apply_filters('mycred_log_' . $column_id, '', $log_entry); break; } echo '</td>'; } echo '</tr>'; } } else { echo '<tr><td colspan="' . count($log->headers) . '" class="no-entries">' . $log->get_no_entries() . '</td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <?php $log->table_nav('bottom', false); ?> </div> <?php do_action('mycred_bellow_log_table', $this); ?> </form> <?php do_action('mycred_bottom_log_page', $this); ?> <div id="edit-mycred-log-entry" style="display: none;"> <div class="mycred-adjustment-form"> <p class="row inline" style="width: 40%;"><label><?php _e('User', 'mycred'); ?> :</label><span id="mycred-username"></span></p> <p class="row inline" style="width: 40%;"><label><?php _e('Time', 'mycred'); ?> :</label> <span id="mycred-time"></span></p> <p class="row inline" style="width: 20%;"><label><?php echo $this->core->plural(); ?> :</label> <span id="mycred-creds"></span></p> <div class="clear"></div> <p class="row"> <label for="mycred-update-users-balance-amount"><?php _e('Current Log Entry', 'mycred'); ?> :</label> <input type="text" name="mycred-raw-entry" id="mycred-raw-entry" value="" disabled="disabled" /><br /> <span class="description"><?php _e('The current saved log entry', 'mycred'); ?> .</span> </p> <p class="row"> <label for="mycred-update-users-balance-entry"><?php _e('Adjust Log Entry', 'mycred'); ?> :</label> <input type="text" name="mycred-new-entry" id="mycred-new-entry" value="" /><br /> <span class="description"><?php _e('The new log entry', 'mycred'); ?> .</span> </p> <p class="row"> <input type="button" id="mycred-update-log-entry" class="button button-primary button-large" value="<?php _e('Update Log Entry', 'mycred'); ?> " /> <input type="hidden" id="mycred-log-row-id" value="" /> </p> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <?php $log->reset_query(); }
/** * Admin Page * @since 0.1 * @version 1.2 */ public function admin_page() { // Security if (!$this->core->can_edit_creds()) { wp_die(__('Access Denied', 'mycred')); } $settings_key = 'mycred_epp_' . $_GET['page']; if (!$this->is_main_type) { $settings_key .= '_' . $this->mycred_type; } $per_page = mycred_get_user_meta(get_current_user_id(), $settings_key, '', true); if ($per_page == '') { $per_page = 10; } // Prep $args = array('number' => absint($per_page)); if (isset($_GET['type']) && !empty($_GET['type'])) { $args['ctype'] = $_GET['type']; } else { $args['ctype'] = $this->mycred_type; } if (isset($_GET['user_id']) && !empty($_GET['user_id'])) { $args['user_id'] = $_GET['user_id']; } if (isset($_GET['s']) && !empty($_GET['s'])) { $args['s'] = $_GET['s']; } if (isset($_GET['ref']) && !empty($_GET['ref'])) { $args['ref'] = $_GET['ref']; } if (isset($_GET['show']) && !empty($_GET['show'])) { $args['time'] = $_GET['show']; } if (isset($_GET['order']) && !empty($_GET['order'])) { $args['order'] = $_GET['order']; } if (isset($_GET['start']) && isset($_GET['end'])) { $args['amount'] = array('start' => $_GET['start'], 'end' => $_GET['end']); } elseif (isset($_GET['num']) && isset($_GET['compare'])) { $args['amount'] = array('num' => $_GET['num'], 'compare' => urldecode($_GET['compare'])); } elseif (isset($_GET['amount'])) { $args['amount'] = $_GET['amount']; } if (isset($_GET['data']) && !empty($_GET['data'])) { $args['data'] = $_GET['data']; } $log = new myCRED_Query_Log($args); $log->headers['column-actions'] = __('Actions', 'mycred'); $url = 'myCRED'; if ($args['ctype'] != 'mycred_default') { $url = 'myCRED_' . $args['ctype']; } ?> <div class="wrap" id="myCRED-wrap"> <h2><?php $this->page_title(sprintf(__('%s Log', 'mycred'), $this->core->plural())); ?> </h2> <?php $log->filter_dates(admin_url('admin.php?page=' . $url)); ?> <?php do_action('mycred_top_log_page', $this); ?> <div class="clear"></div> <?php $log->exporter(__('Export', 'mycred')); ?> <form method="get" action=""> <?php if (isset($_GET['type']) && !empty($_GET['type'])) { echo '<input type="hidden" name="type" value="' . $_GET['type'] . '" />'; } if (isset($_GET['user_id']) && !empty($_GET['user_id'])) { echo '<input type="hidden" name="user_id" value="' . $_GET['user_id'] . '" />'; } if (isset($_GET['s']) && !empty($_GET['s'])) { echo '<input type="hidden" name="s" value="' . $_GET['s'] . '" />'; } if (isset($_GET['ref']) && !empty($_GET['ref'])) { echo '<input type="hidden" name="ref" value="' . $_GET['ref'] . '" />'; } if (isset($_GET['show']) && !empty($_GET['show'])) { echo '<input type="hidden" name="show" value="' . $_GET['show'] . '" />'; } if (isset($_GET['order']) && !empty($_GET['order'])) { echo '<input type="hidden" name="order" value="' . $_GET['order'] . '" />'; } if (isset($_GET['data']) && !empty($_GET['data'])) { echo '<input type="hidden" name="data" value="' . $_GET['data'] . '" />'; } $log->search(); ?> <input type="hidden" name="page" value="myCRED" /> <?php do_action('mycred_above_log_table', $this); ?> <div class="tablenav top"> <?php $log->table_nav('top', false); ?> </div> <table class="table wp-list-table widefat mycred-table log-entries" cellspacing="0"> <thead> <tr> <?php foreach ($log->headers as $col_id => $col_title) { echo '<th scope="col" id="' . str_replace('column-', '', $col_id) . '" class="manage-column ' . $col_id . '">' . $col_title . '</th>'; } ?> </tr> </thead> <tfoot> <tr> <?php foreach ($log->headers as $col_id => $col_title) { echo '<th scope="col" class="manage-column ' . $col_id . '">' . $col_title . '</th>'; } ?> </tr> </tfoot> <tbody id="the-list"> <?php if ($log->have_entries()) { $date_format = get_option('date_format') . ' ' . get_option('time_format'); $entry_data = ''; $alt = 0; foreach ($log->results as $log_entry) { $alt = $alt + 1; if ($alt % 2 == 0) { $class = ' alt'; } else { $class = ''; } echo '<tr class="myCRED-log-row' . $class . '" id="mycred-log-entry-' . $log_entry->id . '">'; // Run though columns foreach ($log->headers as $column_id => $column_name) { echo '<td class="' . $column_id . '">'; switch ($column_id) { // Username Column case 'column-username': $user = get_userdata($log_entry->user_id); if ($user === false) { $content = '<span>' . __('User Missing', 'mycred') . ' (ID: ' . $log_entry->user_id . ')</span>'; } else { $content = '<span>' . $user->display_name . '</span>'; } if ($user !== false && $this->core->can_edit_creds()) { $content .= ' <em><small>(ID: ' . $log_entry->user_id . ')</small></em>'; } echo apply_filters('mycred_log_username', $content, $log_entry->user_id, $log_entry); break; // Date & Time Column // Date & Time Column case 'column-time': echo apply_filters('mycred_log_date', date_i18n($date_format, $log_entry->time), $log_entry->time); break; // Amount Column // Amount Column case 'column-creds': $content = $this->core->format_creds($log_entry->creds); echo apply_filters('mycred_log_creds', $content, $log_entry->creds, $log_entry); break; // Log Entry Column // Log Entry Column case 'column-entry': $content = '<div style="display:none;" class="raw">' . htmlentities($log_entry->entry) . '</div>'; $content .= '<div class="entry">' . $this->core->parse_template_tags($log_entry->entry, $log_entry) . '</div>'; echo apply_filters('mycred_log_entry', $content, $log_entry->entry, $log_entry); break; // Log Action Column // Log Action Column case 'column-actions': $content = '<a href="javascript:void(0)" class="mycred-open-log-entry-editor" data-id="' . $log_entry->id . '">' . __('Edit', 'mycred') . '</a> • <span class="delete"><a href="javascript:void(0);" class="mycred-delete-row" data-id="' . $log_entry->id . '">' . __('Delete', 'mycred') . '</a></span>'; echo apply_filters('mycred_log_actions', $content, $log_entry); break; // Let others add their own columns to this particular log page // Let others add their own columns to this particular log page default: echo apply_filters('mycred_log_' . $column_id, '', $log_entry); break; } echo '</td>'; } echo '</tr>'; } } else { echo '<tr><td colspan="' . count($log->headers) . '" class="no-entries">' . $log->get_no_entries() . '</td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <?php $log->table_nav('bottom', false); ?> </div> <?php do_action('mycred_bellow_log_table', $this); ?> </form> <?php do_action('mycred_bottom_log_page', $this); ?> <div id="edit-mycred-log-entry" style="display: none;"> <div class="mycred-adjustment-form"> <p class="row inline" style="width: 40%;"><label><?php _e('User', 'mycred'); ?> :</label><span id="mycred-username"></span></p> <p class="row inline" style="width: 40%;"><label><?php _e('Time', 'mycred'); ?> :</label> <span id="mycred-time"></span></p> <p class="row inline" style="width: 20%;"><label><?php echo $this->core->plural(); ?> :</label> <span id="mycred-creds"></span></p> <div class="clear"></div> <p class="row"> <label for="mycred-update-users-balance-amount"><?php _e('Current Log Entry', 'mycred'); ?> :</label> <input type="text" name="mycred-raw-entry" id="mycred-raw-entry" value="" disabled="disabled" /><br /> <span class="description"><?php _e('The current saved log entry', 'mycred'); ?> .</span> </p> <p class="row"> <label for="mycred-update-users-balance-entry"><?php _e('Adjust Log Entry', 'mycred'); ?> :</label> <input type="text" name="mycred-new-entry" id="mycred-new-entry" value="" /><br /> <span class="description"><?php _e('The new log entry', 'mycred'); ?> .</span> </p> <p class="row"> <input type="button" id="mycred-update-log-entry" class="button button-primary button-large" value="<?php _e('Update Log Entry', 'mycred'); ?> " /> <input type="hidden" id="mycred-log-row-id" value="" /> </p> <div class="clear"></div> </div> <div class="clear"></div> </div> </div> <?php $log->reset_query(); unset($log); }