dvadf
File manager - Edit - /home/centroca/public_html/Logger.zip
Back
PK �D0]�~v� � Repository.phpnu �[��� <?php // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @noinspection PhpIllegalPsrClassPathInspection */ namespace WPForms\Logger; use WPForms\Helpers\DB; /** * Class Repository. * * @since 1.6.3 */ class Repository { /** * Cache key name for total logs. * * @since 1.6.3 */ const CACHE_TOTAL_KEY = 'wpforms_logs_total'; /** * Records query. * * @since 1.6.3 * * @var RecordQuery */ private $records_query; /** * Records. * * @since 1.6.3 * * @var Records */ private $records; /** * Get a not-limited total query. * * @since 1.6.4.1 * * @var int */ private $full_total; /** * Log constructor. * * @since 1.6.3 * @since 1.9.0 Removed the argument. */ public function __construct() { $this->full_total = false; $this->records_query = new RecordQuery(); $this->records = new Records(); } /** * Get log table name. * * @since 1.6.3 * * @return string */ public static function get_table_name(): string { global $wpdb; return $wpdb->prefix . 'wpforms_logs'; } /** * Create table in the database. * * @since 1.6.3 */ public function create_table() { global $wpdb; $table = self::get_table_name(); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table ( id BIGINT(20) NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL, message LONGTEXT NOT NULL, types VARCHAR(255) NOT NULL, create_at DATETIME NOT NULL, form_id BIGINT(20), entry_id BIGINT(20), user_id BIGINT(20), PRIMARY KEY (id) ) $charset_collate;"; dbDelta( $sql ); } /** * Create new record. * * @since 1.6.3 * * @param string $title Record title. * @param string $message Record message. * @param array|string $types Array, string, or string separated by comma types. * @param int $form_id Record form ID. * @param int $entry_id Record entry ID. * @param int $user_id Record user ID. */ public function add( $title, $message, $types, $form_id, $entry_id, $user_id ) { $this->records->push( Record::create( $title, $message, $types, $form_id, $entry_id, $user_id ) ); } /** * Get records. * * @since 1.6.3 * * @param int $limit Query limit of records. * @param int $offset Offset of records. * @param string $search Search. * @param string $type Type of records. * * @return Records */ public function records( $limit, $offset = 0, $search = '', $type = '' ) { $data = $this->records_query->get( $limit, $offset, $search, $type ); $this->full_total = true; $records = new Records(); // As we got raw data, we need to convert to Record. foreach ( $data as $row ) { $records->push( $this->prepare_record( $row ) ); } return $records; } /** * Get record. * * @since 1.6.3 * * @param int $id Record ID. * * @return Record|null */ public function record( $id ) { global $wpdb; //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $item = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . self::get_table_name() . ' WHERE id = %d', //phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared absint( $id ) ) ); if ( $item ) { $item = $this->prepare_record( $item ); } return $item; } /** * Create record from DB row. * * @since 1.6.3 * * @param object $row Row from DB. * * @return Record */ private function prepare_record( $row ) { return new Record( absint( $row->id ), $row->title, $row->message, $row->types, $row->create_at, absint( $row->form_id ), absint( $row->entry_id ), absint( $row->user_id ) ); } /** * Save records to the database. * * @since 1.6.3 */ public function save() { global $wpdb; // We can't use the empty function because it doesn't work with a Countable object. if ( ! count( $this->records ) ) { return; } $sql = 'INSERT INTO ' . self::get_table_name() . ' ( `id`, `title`, `message`, `types`, `create_at`, `form_id`, `entry_id`, `user_id` ) VALUES '; foreach ( $this->records as $record ) { $sql .= $wpdb->prepare( '( NULL, %s, %s, %s, %s, %d, %d, %d ),', $record->get_title(), $record->get_message(), implode( ',', $record->get_types() ), $record->get_date( 'sql' ), $record->get_form_id(), $record->get_entry_id(), $record->get_user_id() ); } $sql = rtrim( $sql, ',' ); //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared $wpdb->query( $sql ); //phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared wp_cache_delete( self::CACHE_TOTAL_KEY ); } /** * Check if the database table exists. * * @since 1.6.4 * * @return bool */ public function table_exists() { return DB::table_exists( self::get_table_name() ); } /** * Get total count of logs. * * @since 1.6.3 * * @return int */ public function get_total() { global $wpdb; $total = wp_cache_get( self::CACHE_TOTAL_KEY ); if ( ! $total ) { //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared $total = $this->full_total ? $wpdb->get_var( 'SELECT FOUND_ROWS()' ) : $wpdb->get_var( 'SELECT COUNT( ID ) FROM ' . self::get_table_name() ); //phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared wp_cache_set( self::CACHE_TOTAL_KEY, $total, 'wpforms', DAY_IN_SECONDS ); } return absint( $total ); } /** * Clear all records in the Database. * * @since 1.6.3 */ public function clear_all() { global $wpdb; //phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared $wpdb->query( 'TRUNCATE TABLE ' . self::get_table_name() ); } } PK �D0]��, Record.phpnu �[��� <?php namespace WPForms\Logger; /** * Class Record. * * @since 1.6.3 */ class Record { /** * Record ID. * * @since 1.6.3 * * @var int */ private $id; /** * Record title. * * @since 1.6.3 * * @var string */ private $title; /** * Record message. * * @since 1.6.3 * * @var string */ private $message; /** * Array, string, or string separated by commas types. * * @since 1.6.3 * * @var array|string */ private $types; /** * Datetime of creating record. * * @since 1.6.3 * * @var string */ private $create_at; /** * Record form ID. * * @since 1.6.3 * * @var int */ private $form_id; /** * Record entry ID. * * @since 1.6.3 * * @var int */ private $entry_id; /** * Record user ID. * * @since 1.6.3 * * @var int */ private $user_id; /** * Record constructor. * * @since 1.6.3 * * @param int $id Record ID. * @param string $title Record title. * @param string $message Record message. * @param array|string $types Array, string, or string separated by commas types. * @param string $create_at Datetime of creating record. * @param int $form_id Record form ID. * @param int $entry_id Record entry ID. * @param int $user_id Record user ID. */ public function __construct( $id, $title, $message, $types, $create_at, $form_id = 0, $entry_id = 0, $user_id = 0 ) { $this->id = $id; $this->title = $title; $this->message = $message; $this->types = $types; $this->create_at = strtotime( $create_at ); $this->form_id = $form_id; $this->entry_id = $entry_id; $this->user_id = $user_id; } /** * Get record ID. * * @since 1.6.3 * * @return int */ public function get_id() { return $this->id; } /** * Get record title. * * @since 1.6.3 * * @return string */ public function get_title() { return $this->title; } /** * Get record message. * * @since 1.6.3 * * @return string */ public function get_message() { return $this->message; } /** * Get record types. * * @since 1.6.3 * * @param string $view Keys or labels. * * @return array */ public function get_types( $view = 'key' ) { $this->types = is_array( $this->types ) ? $this->types : explode( ',', $this->types ); if ( $view === 'label' ) { return array_intersect_key( Log::get_log_types(), array_flip( $this->types ) ); } return $this->types; } /** * Get date of creating record. * * @since 1.6.3 * * @param string $format Date format full|short|default sql format. * * @return string */ public function get_date( $format = 'short' ) { switch ( $format ) { case 'short': $date = wpforms_date_format( $this->create_at, '', true ); break; case 'full': $date = wpforms_datetime_format( $this->create_at, '', true ); break; case 'sql': $date = wpforms_datetime_format( $this->create_at, 'Y-m-d H:i:s' ); break; case 'sql-local': $date = wpforms_datetime_format( $this->create_at, 'Y-m-d H:i:s', true ); break; default: $date = ''; break; } return $date; } /** * Get form ID. * * @since 1.6.3 * * @return int */ public function get_form_id() { return $this->form_id; } /** * Get entry ID. * * @since 1.6.3 * * @return int */ public function get_entry_id() { return $this->entry_id; } /** * Get user ID. * * @since 1.6.3 * * @return int */ public function get_user_id() { return $this->user_id; } /** * Create new record. * * @since 1.6.3 * * @param string $title Record title. * @param string $message Record message. * @param array|string $types Array, string, or string separated by commas types. * @param int $form_id Record form ID. * @param int $entry_id Record entry ID. * @param int $user_id Record user ID. * * @return Record */ public static function create( $title, $message, $types, $form_id = 0, $entry_id = 0, $user_id = 0 ) { return new Record( 0, sanitize_text_field( $title ), wp_kses( $message, [ 'pre' => [] ] ), $types, gmdate( 'Y-m-d H:i:s' ), absint( $form_id ), absint( $entry_id ), absint( $user_id ) ); } } PK �D0]%ǧ�� � Records.phpnu �[��� <?php namespace WPForms\Logger; use Iterator; use Countable; /** * Class Records. * * @since 1.6.3 */ class Records implements Countable, Iterator { /** * Iterator position. * * @since 1.6.3 * * @var int */ private $iterator_position = 0; /** * List of log records. * * @since 1.6.3 * * @var array */ private $list = []; /** * Return the current element. * * @since 1.6.3 * * @return \WPForms\Logger\Record|null Return null when no items in collection. */ #[\ReturnTypeWillChange] public function current() { return $this->valid() ? $this->list[ $this->iterator_position ] : null; } /** * Move forward to next element. * * @since 1.6.3 */ #[\ReturnTypeWillChange] public function next() { ++ $this->iterator_position; } /** * Return the key of the current element. * * @since 1.6.3 * * @return int */ #[\ReturnTypeWillChange] public function key() { return $this->iterator_position; } /** * Checks if current position is valid. * * @since 1.6.3 * * @return bool */ #[\ReturnTypeWillChange] public function valid() { return isset( $this->list[ $this->iterator_position ] ); } /** * Rewind the Iterator to the first element. * * @since 1.6.3 */ #[\ReturnTypeWillChange] public function rewind() { $this->iterator_position = 0; } /** * Count number of Record in a Queue. * * @since 1.6.3 * * @return int */ #[\ReturnTypeWillChange] public function count() { return count( $this->list ); } /** * Push record to list. * * @since 1.6.3 * * @param \WPForms\Logger\Record $record Record. */ #[\ReturnTypeWillChange] public function push( $record ) { if ( ! is_a( $record, '\WPForms\Logger\Record' ) ) { return; } $this->list[] = $record; } /** * Clear collection. * * @since 1.6.3 */ #[\ReturnTypeWillChange] public function clear() { $this->list = []; $this->iterator_position = 0; } } PK �D0]�4L� Log.phpnu �[��� <?php // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @noinspection PhpIllegalPsrClassPathInspection */ namespace WPForms\Logger; /** * Class Log. * * @since 1.6.3 */ class Log { /** * Repository. * * @since 1.6.3 * * @var Repository */ private $repository; /** * List table. * * @since 1.6.3 * * @var ListTable */ private $list_table; /** * Register log hooks. * * @since 1.6.3 */ public function hooks() { $this->repository = new Repository(); add_action( 'shutdown', [ $this->repository, 'save' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); add_action( 'wp_ajax_wpforms_get_log_record', [ $this, 'get_record' ] ); } /** * Enqueue styles. * * @since 1.6.3 */ public function enqueue_styles() { if ( ! $this->is_logger_page() ) { return; } $min = wpforms_get_min_suffix(); wp_enqueue_style( 'wpforms-tools-logger', WPFORMS_PLUGIN_URL . "assets/css/logger{$min}.css", [], WPFORMS_VERSION ); } /** * Enqueue styles. * * @since 1.6.3 */ public function enqueue_scripts() { if ( ! $this->is_logger_page() ) { return; } $min = wpforms_get_min_suffix(); wp_enqueue_script( 'wpforms-tools-logger', WPFORMS_PLUGIN_URL . "assets/js/admin/logger/logger{$min}.js", [ 'jquery', 'jquery-confirm', 'wp-util' ], WPFORMS_VERSION, true ); } /** * Get log types. * * @since 1.6.3 * * @return array */ public static function get_log_types() { return [ 'conditional_logic' => esc_html__( 'Conditional Logic', 'wpforms-lite' ), 'entry' => esc_html__( 'Entries', 'wpforms-lite' ), 'error' => esc_html__( 'Errors', 'wpforms-lite' ), 'log' => esc_html__( 'Log', 'wpforms-lite' ), 'payment' => esc_html__( 'Payment', 'wpforms-lite' ), 'provider' => esc_html__( 'Providers', 'wpforms-lite' ), 'security' => esc_html__( 'Security', 'wpforms-lite' ), 'spam' => esc_html__( 'Spam', 'wpforms-lite' ), 'translation' => esc_html__( 'Translation', 'wpforms-lite' ), ]; } /** * Determine if it is a Logs page. * * @since 1.6.3 * * @return bool */ private function is_logger_page() { return wpforms_is_admin_page( 'tools', 'logs' ); } /** * Create new record. * * @since 1.6.3 * * @param string $title Record title. * @param string $message Record message. * @param array|string $types Array, string, or string separated by comma types. * @param int $form_id Record form ID. * @param int $entry_id Record entry ID. * @param int $user_id Record user ID. */ public function add( $title, $message, $types, $form_id = 0, $entry_id = 0, $user_id = 0 ) { $this->repository->add( $title, $message, $types, $form_id, $entry_id, $user_id ); } /** * Check if the database table exists. * Used in \WPForms_Install::maybe_create_tables() during plugin installation. * * @since 1.8.7 * * @return bool */ public function table_exists(): bool { // phpcs:ignore WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement return $this->repository->table_exists(); } /** * Create table for logs. * * @since 1.6.3 */ public function create_table() { if ( $this->table_exists() ) { return; } $this->repository->create_table(); } /** * Get ListView. * * @since 1.6.3 * * @return ListTable */ public function get_list_table() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks if ( ! $this->list_table ) { $this->list_table = new ListTable( $this->repository ); add_action( 'admin_print_scripts', [ $this->list_table, 'popup_template' ] ); } return $this->list_table; } /** * Json config for detail information about log record. * * @since 1.6.3 */ public function get_record() { if ( ! check_ajax_referer( 'wpforms-admin', 'nonce', false ) || ! wpforms_current_user_can() ) { wp_send_json_error( esc_html__( 'You do not have permission.', 'wpforms-lite' ) ); } $id = filter_input( INPUT_GET, 'recordId', FILTER_VALIDATE_INT ); if ( ! $id ) { wp_send_json_error( esc_html__( 'Record ID not found', 'wpforms-lite' ), 404 ); } $item = $this->repository->record( $id ); if ( $item === null ) { wp_send_json_error( esc_html__( 'No such record.', 'wpforms-lite' ), 404 ); } wp_send_json_success( [ 'ID' => absint( $item->get_id() ), 'title' => esc_html( $item->get_title() ), 'message' => wp_kses( $item->get_message(), [ 'pre' => [] ] ), 'types' => esc_html( implode( ', ', $item->get_types( 'label' ) ) ), 'create_at' => esc_html( $item->get_date( 'full' ) ), 'form_id' => absint( $item->get_form_id() ), 'entry_id' => absint( $item->get_entry_id() ), 'user_id' => absint( $item->get_user_id() ), 'form_url' => admin_url( sprintf( 'admin.php?page=wpforms-builder&view=fields&form_id=%d', absint( $item->get_form_id() ) ) ), 'entry_url' => admin_url( sprintf( 'admin.php?page=wpforms-entries&view=details&entry_id=%d', absint( $item->get_entry_id() ) ) ), 'user_url' => esc_url( get_edit_user_link( $item->get_user_id() ) ), ] ); } } PK �D0]ϗ��G G RecordQuery.phpnu �[��� <?php // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @noinspection PhpIllegalPsrClassPathInspection */ namespace WPForms\Logger; /** * Class RecordQuery. * * @since 1.6.3 */ class RecordQuery { /** * Build query. * * @since 1.6.3 * * @param int $limit Query limit of records. * @param int $offset Offset of records. * @param string $search Search. * @param string $type Type of records. * * @return array */ public function get( $limit, $offset = 0, $search = '', $type = '' ) { global $wpdb; //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared return (array) $wpdb->get_results( $this->build_query( $limit, $offset, $search, $type ) ); //phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared } /** * Build query. * * @since 1.6.3 * * @param int $limit Query limit of records. * @param int $offset Offset of records. * @param string $search Search. * @param string $type Type of records. * * @return string */ private function build_query( $limit, $offset = 0, $search = '', $type = '' ) { global $wpdb; $sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM ' . Repository::get_table_name(); $where = []; if ( ! empty( $search ) ) { $where[] = $wpdb->prepare( '`title` REGEXP %s OR `message` REGEXP %s', $search, $search ); } if ( ! empty( $type ) ) { $where[] = $wpdb->prepare( '`types` REGEXP %s', $type ); } if ( $where ) { $sql .= ' WHERE ' . implode( ' AND ', $where ); } $sql .= ' ORDER BY `create_at` DESC, `id` DESC'; $sql .= $wpdb->prepare( ' LIMIT %d, %d', absint( $offset ), absint( $limit ) ); return $sql; } } PK �D0]�i�1 �1 ListTable.phpnu �[��� <?php namespace WPForms\Logger; if ( ! defined( 'ABSPATH' ) ) { exit; } use WP_List_Table; if ( ! class_exists( 'WP_List_Table' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } /** * Class ListTable. * * @since 1.6.3 */ class ListTable extends WP_List_Table { /** * Record Query. * * @since 1.6.3 * * @var Repository */ private $repository; /** * ListTable constructor. * * @since 1.6.3 * * @param Repository $repository Repository. */ public function __construct( $repository ) { $this->repository = $repository; parent::__construct( [ 'plural' => esc_html__( 'Logs', 'wpforms-lite' ), 'singular' => esc_html__( 'Log', 'wpforms-lite' ), ] ); $this->hooks(); add_screen_option( 'per_page', [ 'default' => $this->get_items_per_page( $this->get_per_page_option_name() ) ] ); set_screen_options(); } /** * Hooks. * * @since 1.7.5 */ private function hooks() { add_filter( 'set_screen_option_' . $this->get_per_page_option_name(), [ $this, 'set_items_per_page_option' ], 10, 3 ); } /** * Handles setting the items_per_page option for this screen. * * @since 1.7.5 * * @param mixed $status Default false (to skip saving the current option). * @param string $option Screen option name. * @param int $value Screen option value. * * @return int * @noinspection PhpUnusedParameterInspection */ public function set_items_per_page_option( $status, $option, $value ) { return $value; } /** * Whether the table has items to display or not. * * @since 1.6.3 * * @return bool */ public function has_items() { // We can't use the empty function because it doesn't work with the Countable object. return (bool) count( $this->items ); } /** * Prepares the list of items for displaying. * * @since 1.6.3 */ public function prepare_items() { $offset = $this->get_items_offset(); $search = $this->get_request_search_query(); $types = $this->get_items_type(); $per_page = $this->get_items_per_page( $this->get_per_page_option_name() ); $this->items = $this->repository->records( $per_page, $offset, $search, $types ); $total_items = $this->get_total(); $this->set_pagination_args( [ 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => (int) ceil( $total_items / $per_page ), ] ); } /** * Return the type of records. * * @since 1.6.3 * * @return string */ private function get_items_type() { return filter_input( INPUT_GET, 'log_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); } /** * Return the number of items to offset/skip for this current view. * * @since 1.6.3 * * @return int */ private function get_items_offset() { return $this->get_items_per_page( $this->get_per_page_option_name() ) * ( $this->get_pagenum() - 1 ); } /** * Return the search filter for this request, if any. * * @since 1.6.3 * * @return string */ private function get_request_search_query() { return filter_input( INPUT_GET, 's', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); } /** * Column title. * * @since 1.6.3 * * @param Record $item List table item. * * @return string * @noinspection PhpUnused */ public function column_log_title( $item ) { return sprintf( '<a href="#" class="js-single-log-target" data-log-id="%1$d"><strong>%2$s</strong></a>', absint( $item->get_id() ), esc_html( $item->get_title() ) ); } /** * Column message. * * @since 1.6.3 * * @param Record $item List table item. * * @return string * @noinspection PhpUnused */ public function column_message( $item ) { $message = $item->get_message(); if ( preg_match( '/\[body].+{"error":"(.+)"}/i', $message, $m ) ) { $message = $m[1]; } if ( preg_match( '/\[error] => (.+)/i', $message, $m ) ) { $message = $m[1]; } return esc_html( $this->crop_message( $message ) ); } /** * Column form ID. * * @since 1.6.3 * * @param Record $item List table item. * * @return int * @noinspection PhpUnused */ public function column_form_id( $item ) { return absint( $item->get_form_id() ); } /** * Column types. * * @since 1.6.3 * * @param Record $item List table item. * * @return string * @noinspection PhpUnused */ public function column_types( $item ) { return esc_html( implode( ', ', $item->get_types( 'label' ) ) ); } /** * Column date. * * @since 1.6.3 * * @param Record $item List table item. * * @return string * @noinspection PhpUnused */ public function column_date( $item ) { return esc_html( $item->get_date( 'sql-local' ) ); } /** * Crop message for preview on list table. * * @since 1.6.3 * * @param string $message Message. * * @return string */ private function crop_message( $message ) { return wp_html_excerpt( $message, 97, '...' ); } /** * Prepares the _column_headers property which is used by WP_Table_List at rendering. * It merges the columns and the sortable columns. * * @since 1.6.3 */ private function prepare_column_headers() { $this->_column_headers = [ $this->get_columns(), get_hidden_columns( $this->screen ), [], ]; } /** * Return the columns' names for rendering. * * @since 1.6.3 * * @return array */ public function get_columns() { return [ 'log_title' => __( 'Log Title', 'wpforms-lite' ), 'message' => __( 'Message', 'wpforms-lite' ), 'form_id' => __( 'Form ID', 'wpforms-lite' ), 'types' => __( 'Types', 'wpforms-lite' ), 'date' => __( 'Date', 'wpforms-lite' ), ]; } /** * Header before log table. * * @since 1.6.3 */ private function header() { ?> <div class="wpforms-admin-content-header"> <h4 class="wp-heading-inline"><?php esc_html_e( 'View Logs', 'wpforms-lite' ); ?> <?php if ( $this->get_request_search_query() ) { ?> <span class="subtitle"> <?php printf( /* translators: %s - search query. */ esc_html__( 'Search results for "%s"', 'wpforms-lite' ), esc_html( $this->get_request_search_query() ) ); ?> </span> <?php } ?> </h4> <?php $this->hidden_fields(); $this->search_box( esc_html__( 'Search Logs', 'wpforms-lite' ), 'plugin' ); ?> </div> <?php } /** * Generate the table navigation above or below the table. * * @since 1.6.3 * * @param string $which Which position. */ protected function display_tablenav( $which ) { ?> <div class="tablenav <?php echo esc_attr( $which ); ?>"> <?php if ( $which === 'top' ) { $this->extra_tablenav( $which ); } $this->pagination( $which ); ?> <br class="clear" /> </div> <?php } /** * Table list actions. * * @since 1.6.3 * * @param string $which Position of navigation (top or bottom). */ protected function extra_tablenav( $which ) { if ( ! $this->get_total() ) { return; } $this->log_type_select(); $this->clear_all(); } /** * Clear all log records. * * @since 1.6.3 */ private function clear_all() { ?> <button name="clear-all" type="submit" class="button" value="1"><?php esc_html_e( 'Delete All Logs', 'wpforms-lite' ); ?></button> <?php } /** * Update URL when table showing. * _wp_http_referer is used only on bulk actions, we remove it to keep the $_GET shorter. * * @since 1.6.3 */ public function process_admin_ui() { $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; if ( ! wp_verify_nonce( $nonce, 'wpforms-table-' . $this->_args['plural'] ) ) { return; } if ( empty( $_REQUEST['_wp_http_referer'] ) && empty( $_REQUEST['clear-all'] ) ) { return; } if ( ! empty( $_REQUEST['clear-all'] ) ) { $this->repository->clear_all(); } $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; wp_safe_redirect( remove_query_arg( [ '_wp_http_referer', '_wpnonce', 'clear-all' ], $uri ) ); exit; } /** * Message to be displayed when there are no items. * * @since 1.6.3 */ public function no_items() { esc_html_e( 'No logs found.', 'wpforms-lite' ); } /** * Print all hidden fields. * * @since 1.6.3 */ private function hidden_fields() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended foreach ( $_GET as $key => $value ) { if ( $key[0] === '_' || $key === 'paged' || $key === 'ID' ) { continue; } echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" />'; } } /** * Select for choose a log type. * * @since 1.6.3 */ private function log_type_select() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $current_type = ! empty( $_GET['log_type'] ) ? sanitize_text_field( wp_unslash( $_GET['log_type'] ) ) : ''; ?> <select name="log_type"> <option value=""><?php esc_html_e( 'All Logs', 'wpforms-lite' ); ?></option> <?php foreach ( Log::get_log_types() as $type_slug => $type ) { ?> <option value="<?php echo esc_attr( $type_slug ); ?>" <?php selected( $type_slug, $current_type ); ?>> <?php echo esc_html( $type ); ?> </option> <?php } ?> </select> <input type="submit" class="button" value="<?php esc_attr_e( 'Apply', 'wpforms-lite' ); ?>"> <?php } /** * Popup view. * * @since 1.6.3 */ public function popup_template() { ?> <script type="text/html" id="tmpl-wpforms-log-record"> <div class="wpforms-log-popup"> <div class="wpforms-log-popup-block"> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Log Title', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-title">{{{ data.title }}}</div> </div> <div class="wpforms-log-popup-block"> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Message', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-message">{{{ data.message }}}</div> </div> <div class="wpforms-log-popup-flex wpforms-log-popup-flex-column-2"> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Date', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-create-at">{{ data.create_at }}</div> </div> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Types', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-types">{{ data.types }}</div> </div> </div> <div class="wpforms-log-popup-flex wpforms-log-popup-flex-column-4"> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Log ID', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-id">{{ data.ID }}</div> </div> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Form ID', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-form-id"> <# if ( data.form_id ) { #> <a href="{{ data.form_url }}"> <# } #> {{ data.form_id }} <# if ( data.form_id ) { #> </a> <# } #> </div> </div> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'Entry ID', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-entry-id"> <# if ( data.entry_id ) { #> <a href="{{ data.entry_url }}"> <# } #> {{ data.entry_id }} <# if ( data.entry_id ) { #> </a> <# } #> </div> </div> <div> <div class="wpforms-log-popup-label"><?php esc_html_e( 'User ID', 'wpforms-lite' ); ?></div> <div class="wpforms-log-popup-user-id"> <# if ( data.user_id ) { #> <a href="{{ data.user_url }}"> <# } #> {{ data.user_id }} <# if ( data.user_id ) { #> </a> <# } #> </div> </div> </div> </div> </script> <?php } /** * Display list table page. * * @since 1.6.3 */ public function display_page() { $this->prepare_column_headers(); $this->prepare_items(); $slug = $this->_args['plural']; echo '<div class="wpforms-list-table wpforms-list-table--logs">'; echo '<form id="' . esc_attr( $slug ) . '-filter" method="get">'; wp_nonce_field( 'wpforms-table-' . $slug ); $this->header(); $this->display(); echo '</form>'; echo '</div>'; } /** * Get total logs. * * @since 1.6.3 * * @return int */ public function get_total() { return $this->repository->get_total(); } /** * Gets the screen per_page option name. * * @since 1.7.5 * * @return string */ private function get_per_page_option_name() { return str_replace( '-', '_', $this->screen->id ) . '_per_page'; } } PK �D0]�~v� � Repository.phpnu �[��� PK �D0]��, Record.phpnu �[��� PK �D0]%ǧ�� � c) Records.phpnu �[��� PK �D0]�4L� `1 Log.phpnu �[��� PK �D0]ϗ��G G �F RecordQuery.phpnu �[��� PK �D0]�i�1 �1 7N ListTable.phpnu �[��� PK � M�
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 8.2.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings