| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/mail-manager-wpforms/admin/ |
Upload File : |
<?php
/**
* The form entries table
*
* Loads forms list with the WordPress default
* table functionlity.
*
* @since 1.0.0
* @link https://mmw.diviaccessories.com/
*
* @package mail-manager-wpforms
* @subpackage mail-manager-wpforms/table
*/
namespace MMWPF\Admin;
use MMWPF\Core\Notice;
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
/**
* The form list table
*
* Loads forms list with the WordPress default
* table functionlity.
*
* @since 1.0.0
* @package mail-manager-wpforms
* @subpackage mail-manager-wpforms/table
* @author nishanmazumder<arosh019@gmail.com>
*/
class Form_Entries_Table extends \WP_List_Table {
use \MMWPF\TRT\Trait_Manager;
/**
* Table Data
*
* @since 1.0.0
* @access private
* @var array $table_data Table data.
*/
private $table_data;
/**
* Form ID
*
* @since 1.0.0
* @access private
* @var int $form_id Form ID.
*/
private $form_id;
/**
* Notice
*
* @since 1.0.0
* @access private
* @var object $notice WP_Error object.
*/
private static $notice;
/**
* Define the entry table functionality
*
* @since 1.0.0
*/
public function __construct() {
self::mmwpf_database_int();
self::$notice = Notice::get_instance();
$this->form_id = isset( $_GET['formId'] ) ? absint( $_GET['formId'] ) : null;
parent::__construct(
array(
'singular' => __( 'Entry', 'mail-manager-wpforms' ),
'plural' => __( 'Entries', 'mail-manager-wpforms' ),
'ajax' => false,
)
);
}
/**
* Prepare the items for the table to process
*
* @since 1.0.0
* @return void
*/
public function prepare_items() {
$columns = $this->get_columns();
$sort_column = $this->get_sortable_columns();
$hidden = $this->get_hidden_columns();
$selected_columns = get_user_meta( get_current_user_id(), 'mmwpf_entries_columns_' . $this->form_id, true );
$primary = ! empty( $selected_columns ) ? array_values( $selected_columns )[0] : '';
$this->process_bulk_action();
$this->_column_headers = array( $columns, $hidden, $sort_column, $primary );
$this->table_data = $this->get_table_data();
// Sorting.
if ( is_array( $this->table_data ) ) {
usort( $this->table_data, array( $this, 'table_order' ) );
}
// Pagination.
$per_page = $this->get_items_per_page( 'entries_table_per_page_' . $this->form_id );
$current = $this->get_pagenum();
$total = count( $this->table_data );
$this->table_data = array_slice( $this->table_data, ( ( $current - 1 ) * $per_page ), $per_page );
$this->set_pagination_args(
array(
'total_items' => $total,
'per_page' => $per_page,
'total_pages' => ceil( $total / $per_page ),
)
);
// Asign data.
$this->items = $this->table_data;
}
/**
* Prepare DB data for table.
*
* @since 1.0.0
*
* @return array
*/
public function get_table_data() {
$data = array();
if ( ! self::$db_instance->entry_data ) {
return $data;
}
foreach ( self::$db_instance->entry_data as $top_level_value ) {
$item = array();
foreach ( $top_level_value as $key => $value ) {
if ( 'form_value' === $key ) {
$form_value = json_decode( $value );
foreach ( $form_value as $value ) {
$trim_key = str_replace( ' ', '_', strtolower( $value->name ) );
$item[ $trim_key ] = $value->value;
}
} else {
$item[ $key ] = $value;
}
}
$data[] = $item;
}
return $data;
}
/**
* Override the parent columns method.
*
* @since 1.0.0
* @return array
*/
public function get_columns() {
return apply_filters( 'mmwpf_add_entries_column_name', array() );
}
/**
* Define the sortable columns
*
* @since 1.0.0
* @return array
*/
public function get_sortable_columns() {
return array(
'date' => array( 'date', false ),
);
}
/**
* Define which columns are hidden
*
* @since 1.0.0
* @return array
*/
public function get_hidden_columns() {
$hide_columns = array();
$selected_columns = apply_filters( 'mmwpf_add_entries_column_name', array() );
$enable_columns = get_user_meta( get_current_user_id(), 'mmwpf_entries_columns_' . $this->form_id, true );
if ( is_array( $enable_columns ) ) {
$hide_columns = array_flip( array_diff( array_keys( $selected_columns ), $enable_columns ) );
unset(
$hide_columns['cb'],
$hide_columns['action']
);
}
if ( $hide_columns ) {
return array_keys( $hide_columns );
}
}
/**
* Order column
*
* @since 1.0.0
*
* @param array $table_list Orginal list.
* @param array $filtered_table_list Filtered list.
*
* @return array
*/
public function table_order( $table_list, $filtered_table_list ) {
$orderby = 'date';
$order = 'desc';
if ( isset( $_GET['orderby'] ) && isset( $_GET['order'] ) ) {
$orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
$order = sanitize_text_field( wp_unslash( $_GET['order'] ) );
}
$result = strcmp( $table_list[ $orderby ], $filtered_table_list[ $orderby ] );
if ( 0 !== $result ) {
return ( 'asc' === $order ) ? $result : -$result;
}
return array();
}
/**
* List checkbox
*
* @since 1.0.0
*
* @param object|array $item Item array or object.
* @return array
*/
public function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="entries[]" value="%1$s" />
<a href="#!" data-id="%1$s" class="entry-column-save %2$s">
<span class="dashicons dashicons-heart"></span>
</a>',
$item['id'],
$item['save'] ? 'active' : ''
);
}
/**
* Define what data to show on each column of the table 0e2f2530 9d4c0ed95c4ada377957517ec7adc05b
*
* @since 1.0.0
*
* @param array $item Data array.
* @param string $column_name Current column name.
* @return mixed
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'id':
case 'form_id':
case 'form_value':
return $item[ $column_name ];
case 'status':
return (int) $item['status'] ?
'<p class="' . esc_attr( 'read' ) . '">' . __( 'Read', 'mail-manager-wpforms' ) . '</p>'
: '<p class="' . esc_attr( 'unread' ) . '">' . __( 'Unread', 'mail-manager-wpforms' ) . '</p>';
case 'date':
$timestamp = strtotime( $item[ $column_name ] );
return gmdate( 'd M, y', $timestamp ) . ' 🕐 ' . gmdate( 'h:ia', $timestamp );
case 'action':
$actions = apply_filters( 'mmwpf_add_entries_action', $item );
return $this->row_actions( $actions );
default:
return $item[ $column_name ];
}
}
/**
* Bulk action.
*
* @since 1.0.0
* @return array
*/
public function get_bulk_actions() {
$actions = array(
'bulk_trashed' => __( 'Trash', 'mail-manager-wpforms' ),
'bulk_unreaded' => __( 'Unread', 'mail-manager-wpforms' ),
'bulk_saved' => __( 'Save', 'mail-manager-wpforms' ),
'bulk_deleted' => __( 'Delete', 'mail-manager-wpforms' ),
);
return $actions;
}
/**
* Generates the table navigation above or below the table
*
* @since 1.0.0
* @param string $which Position of the navigation, either top or bottom.
* @return void
*/
protected function display_tablenav( $which ) {
if ( empty( $this->table_data ) ) {
return;
}
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<?php if ( $this->has_items() ) : ?>
<div class="alignleft actions bulkactions mmwpf-bulk-action">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
endif;
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
<br class="clear" />
</div>
<?php
}
/**
* Add custom filters before the tablenav.
*
* @since 1.0.0
* @return void
*/
public function before_extra_table_nav() {
$get_filter = isset( $_GET['mmwpf_filter'] ) ? sanitize_text_field( wp_unslash( $_GET['mmwpf_filter'] ) ) : 'all';
$filters = array(
'all' => 'All',
'starred' => 'Starred',
'unread' => 'Unread',
'trashed' => 'Trash',
);
?>
<div class="alignleft actions">
<ul class="subsubsub">
<?php
foreach ( $filters as $filter_key => $filter_label ) {
$class = ( $filter_key === $get_filter ) ? ' class="current"' : '';
$count = self::$db_instance->filter->$filter_key ?? 0;
printf(
'<li%s><a href="%s">%s <span class="count">(%d)</span></a> |</li>',
esc_attr( $class ),
esc_url(
add_query_arg(
array(
'action' => 'entries',
'mmwpf_filter' => $filter_key,
),
remove_query_arg( 's' )
)
),
esc_html( $filter_label ),
absint( $count )
);
}
?>
</ul>
</div>
<div class="alignright actions">
<?php $this->search_box( 'Search', 'mail-manager-wpforms' ); ?>
</div>
<?php
}
/**
* Overridden method to add dropdown filters column type.
*
* @since 1.0.0
* @param string $which Position of the navigation, either top or bottom.
* @return void
*/
protected function extra_tablenav( $which ) {
if ( 'top' === $which ) {
$from_date = isset( $_GET['from_date'] ) ? sanitize_text_field( wp_unslash( $_GET['from_date'] ) ) : '';
$to_date = isset( $_GET['to_date'] ) ? sanitize_text_field( wp_unslash( $_GET['to_date'] ) ) : '';
?>
<div class="alignleft actions mmwpf-export-action">
<input type="date" name="from_date" value="<?php echo esc_html( $from_date ); ?>" placeholder="From Date">
<input type="date" name="to_date" value="<?php echo esc_html( $to_date ); ?>" max="<?php echo esc_html( gmdate( 'Y-m-d' ) ); ?>" placeholder="To Date">
<input type="submit" name="export_csv" id="export_csv" class="button" value="Export CSV">
</div>
<?php
}
}
}