Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/gdpr-cookie-consent/admin/class-gdpr-cookie-consent-admin.php
+++ b/gdpr-cookie-consent/admin/class-gdpr-cookie-consent-admin.php
@@ -1139,9 +1139,12 @@
<?php $consent_logs->search_box( __( 'Search Logs', 'gdpr-cookie-consent' ), 'gdpr-cookie-consent' ); ?>
</div>
</div>
+ <?php // v-pre: this table renders visitor-supplied data inside the Vue root; stop Vue compiling it as a template. ?>
+ <div v-pre>
<?php
$consent_logs->display();
?>
+ </div>
<input type="hidden" name="page" value="gdpr-cookie-consent"/>
</form>
</div>
@@ -1156,6 +1159,7 @@
'class' => array(),
'id' => array(),
'style' => array(),
+ 'v-pre' => true, // Keeps Vue from compiling the visitor-data table (template injection).
),
'h1' => array(
'class' => array(),
@@ -1570,6 +1574,17 @@
$error = true;
$message = __( "Sorry, it looks like you're a bot", 'gdpr-cookie-consent' );
}
+ $has_request_type = false;
+ foreach ( array_keys( $this->wpl_data_reqs_options() ) as $fieldname ) {
+ if ( isset( $params[ 'wpl_datarequest_' . $fieldname ] ) && 1 === intval( $params[ 'wpl_datarequest_' . $fieldname ] ) ) {
+ $has_request_type = true;
+ break;
+ }
+ }
+ if ( ! $has_request_type ) {
+ $error = true;
+ $message = __( 'Please choose at least one request type.', 'gdpr-cookie-consent' );
+ }
if ( ! isset( $params['wpl_datarequest_email'] ) || ! is_email( $params['wpl_datarequest_email'] ) ) {
$error = true;
$message = __( 'Please enter a valid email address.', 'gdpr-cookie-consent' );
@@ -1582,6 +1597,12 @@
$error = true;
$message = __( "That's a long name you got there. Please try to shorten the name.", 'gdpr-cookie-consent' );
}
+ // Curly braces are never part of a real name/email and enable template injection in the admin UI.
+ if ( ( isset( $params['wpl_datarequest_name'] ) && preg_match( '/[{}]/', $params['wpl_datarequest_name'] ) )
+ || ( isset( $params['wpl_datarequest_email'] ) && preg_match( '/[{}]/', $params['wpl_datarequest_email'] ) ) ) {
+ $error = true;
+ $message = __( 'Your name or email contains invalid characters.', 'gdpr-cookie-consent' );
+ }
if ( ! $error ) {
$email = sanitize_email( $params['wpl_datarequest_email'] );
$name = sanitize_text_field( $params['wpl_datarequest_name'] );
@@ -1612,7 +1633,8 @@
$this->wpl_send_notification_mail();
$message = __( 'Your request has been processed successfully!', 'gdpr-cookie-consent' );
} else {
- $message = __( 'Your request could not be processed. A request is already in progress for this email address or the form is not complete.', 'gdpr-cookie-consent' );
+ $error = true;
+ $message = __( 'Your request could not be processed. A request of the selected type is already in progress for this email address.', 'gdpr-cookie-consent' );
}
}
// response for ajax.
@@ -1840,9 +1862,12 @@
<?php $datarequests->search_box( __( 'Search Logs', 'gdpr-cookie-consent' ), 'gdpr-cookie-consent' ); ?>
</div>
</div>
+ <?php // v-pre: this table renders visitor-supplied data inside the Vue root; stop Vue compiling it as a template. ?>
+ <div v-pre>
<?php
$datarequests->display();
?>
+ </div>
<input type="hidden" name="page" value="gdpr-cookie-consent"/>
</form>
</div>
@@ -1858,6 +1883,7 @@
'class' => array(),
'id' => array(),
'style' => array(),
+ 'v-pre' => true, // Keeps Vue from compiling the visitor-data table (template injection).
),
'h1' => array(
'class' => array(),
@@ -2034,7 +2060,7 @@
),
array( 'ID' => intval( $_GET['id'] ) )
);
- $paged = isset( $_GET['paged'] ) ? 'paged=' . intval( $_GET['paged'] ) : '';
+ $paged = isset( $_GET['wpl_dr_paged'] ) ? 'wpl_dr_paged=' . absint( $_GET['wpl_dr_paged'] ) : '';
wp_redirect( admin_url( 'admin.php?page=gdpr-cookie-consent' . ( $paged ? '&' . $paged : '' ) . '#compliance_records#data_request' ) );
exit;
@@ -2055,7 +2081,7 @@
}
global $wpdb;
$wpdb->delete( $wpdb->prefix . 'wpl_data_req', array( 'ID' => intval( $_GET['id'] ) ) );
- $paged = isset( $_GET['paged'] ) ? 'paged=' . intval( $_GET['paged'] ) : '';
+ $paged = isset( $_GET['wpl_dr_paged'] ) ? 'wpl_dr_paged=' . absint( $_GET['wpl_dr_paged'] ) : '';
wp_redirect( admin_url( 'admin.php?page=gdpr-cookie-consent' . ( $paged ? '&' . $paged : '' ) . '#compliance_records#data_request' ) );
exit;
}
@@ -5521,6 +5547,7 @@
$the_options['button_accept_url'] = isset( $_POST['gdpr-cookie-accept-url'] ) ? sanitize_text_field( wp_unslash( $_POST['gdpr-cookie-accept-url'] ) ) : '#';
$the_options['button_accept_as_button'] = isset( $_POST['gdpr-cookie-accept-as'] ) && ( true === $_POST['gdpr-cookie-accept-as'] || 'true' === $_POST['gdpr-cookie-accept-as'] ) ? 'true' : 'false';
$the_options['button_accept_new_win'] = isset( $_POST['gdpr-cookie-url-new-window'] ) && ( true === $_POST['gdpr-cookie-url-new-window'] || 'true' === $_POST['gdpr-cookie-url-new-window'] ) ? 'true' : 'false';
+ $auto_generated_banner = isset( $_POST['auto_generated_banner'] ) ? sanitize_text_field( wp_unslash( $_POST['auto_generated_banner'] ) ) : '0'; // if($auto_generated_banner !== '1'){
if($auto_generated_banner !== '1'){
$the_options['button_accept_button_color'] = isset( $_POST['gdpr-cookie-accept-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['gdpr-cookie-accept-background-color'] ) ) : '#18a300';
$the_options['button_accept_button_border_color'] = isset( $_POST['gdpr-cookie-accept-border-color'] ) ? sanitize_text_field( wp_unslash( $_POST['gdpr-cookie-accept-border-color'] ) ) : '#18a300';
@@ -13641,7 +13668,8 @@
'is_script_dependency_on' => $the_options['is_script_dependency_on'],
'header_dependency' => $the_options['header_dependency'] ?? '',
'footer_dependency' => $the_options['footer_dependency'] ?? '',
- 'whitelist_scripts' => get_option( 'wpl_options_custom-scripts' )['whitelist_script'],
+ // The option does not exist until a whitelist entry is first saved.
+ 'whitelist_scripts' => get_option( 'wpl_options_custom-scripts' )['whitelist_script'] ?? null,
'show_language_as_options' => $show_language_as_options,
'lang_selected' => $language,
@@ -14683,6 +14711,8 @@
'notify_message_pdpl' => $new_options['notify_message_pdpl'],
'notify_message_pipeda' => $new_options['notify_message_pipeda'],
'notify_message_app' => $new_options['notify_message_app'],
+ 'notify_message_default_opt_out' => $new_options['notify_message_default_opt_out'],
+ 'notify_message_pure_opt_out' => $new_options['notify_message_pure_opt_out'],
)
),
200
--- a/gdpr-cookie-consent/admin/data-req/class-wpl-data-req-table.php
+++ b/gdpr-cookie-consent/admin/data-req/class-wpl-data-req-table.php
@@ -1,553 +1,666 @@
-<?php
-/**
- * Data Request Reports Table Class
- */
-
-// Exit if accessed directly
-if ( ! defined( 'ABSPATH' ) ) {
- exit;
-}
-
-// Load WP_List_Table if not loaded
-if ( ! class_exists( 'WP_List_Table' ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
-}
-
-class WPL_Data_Req_Table extends WP_List_Table {
-
- /**
- * Number of items per page
- *
- * @var int
- * @since 3.0.0
- */
- public $per_page = 10;
-
- /**
- * Number of results found
- *
- * @var int
- * @since 3.0.0
- */
- public $count = 0;
-
- /**
- * Total results
- *
- * @var int
- * @since 3.0.0
- */
- public $total = 0;
-
- /**
- * The arguments for the data set
- *
- * @var array
- * @since 3.0.0
- */
- public $args = array();
-
- /**
- * Get things started
- *
- * @since 3.0.0
- * @see WP_List_Table::__construct()
- */
- public function __construct() {
- global $status, $page;
-
- // Set parent defaults
- parent::__construct(
- array(
- 'singular' => __( 'User', 'gdpr-cookie-consent' ),
- 'plural' => __( 'Users', 'gdpr-cookie-consent' ),
- 'ajax' => false,
- )
- );
- }
-
- /**
- * Show the search field
- *
- * @param string $text Label for the search box
- * @param string $input_id ID of the search box
- *
- * @return void
- * @since 3.0.0
- */
- public function search_box( $text, $input_id ) {
- $input_id = $input_id . '-search-input-data-request';
-
- $order_by = isset( $_REQUEST['orderby'] ) ? sanitize_key( wp_unslash( $_REQUEST['orderby'] ) ) : '';
-
- if ( '' !== $order_by && array_key_exists( $order_by, $this->get_sortable_columns() ) ) {
- echo '<input type="hidden" name="orderby" value="' . esc_attr( $order_by ) . '" />';
- }
-
- $order = isset( $_REQUEST['order'] ) ? strtolower( sanitize_key( wp_unslash( $_REQUEST['order'] ) ) ) : '';
-
- if ( in_array( $order, array( 'asc', 'desc' ), true ) ) {
- echo '<input type="hidden" name="order" value="' . esc_attr( $order ) . '" />';
- }
- $search = $this->get_search();
- ?>
- <div class="search-and-export-container">
- <div class="search-box">
- <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
- <?php echo esc_html( $text ); ?>:
- </label>
- <input placeholder="Search Requests" type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php echo esc_attr( $search ); ?>"/>
- <img id="search-logo-data-request" v-on:click="submitDataRequestSearch" src="<?php echo esc_url( GDPR_COOKIE_CONSENT_PLUGIN_URL ) . 'admin/images/vector.png'; ?>" alt="Search Logo">
- </div>
- <?php
- submit_button(
- $text,
- 'button',
- false,
- false,
- array( 'ID' => 'search-submit-data-request' )
- );
- ?>
- </div>
- <?php
-
- $this->resolved_select();
-
- ?>
- <?php
- }
-
- /**
- * Gets the name of the primary column.
- *
- * @return string Name of the primary column.
- * @since 3.0.0
- * @access protected
- */
- protected function get_primary_column_name() {
- return 'name';
- }
-
- /**
- * This function renders most of the columns in the list table.
- *
- * @param array $item Contains all the data of the customers
- * @param string $column_name The name of the column
- *
- * @return string Column Name
- * @since 3.0.0
- */
- public function column_default( $item, $column_name ) {
- switch ( $column_name ) {
- case 'resolved':
- $value = $item['resolved'] ? __( 'Resolved', 'gdpr-cookie-consent' ) : __( 'Open', 'gdpr-cookie-consent' );
- break;
- case 'datarequest':
- // Built from the fixed request-type list, contains a link.
- $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
- break;
- default:
- $value = isset( $item[ $column_name ] ) ? esc_html( $item[ $column_name ] ) : null;
- break;
- }
- return apply_filters( 'wpl_dnsmpd_column_' . $column_name, $value, $item['ID'] );
- }
-
- /**
- * Column name
- *
- * @param array $item
- *
- * @return string
- */
- public function column_name( $item ) {
- $name = '#' . esc_html( $item['ID'] ) . ' ';
- $name .= ! empty( $item['name'] ) ? esc_html( $item['name'] ) : '<em>' . esc_html__( 'Unnamed user', 'gdpr-cookie-consent' ) . '</em>';
- return $name;
- }
-
- /**
- * Column name actions
- *
- * @param array $item
- *
- * @return string
- */
- public function column_actions_resolve_delete( $item ) {
- $actions = array();
-
- // Show Resolve action if not resolved
- if ( empty( $item['resolved'] ) || intval( $item['resolved'] ) === 0 ) {
- $resolve_url = wp_nonce_url(
- admin_url( 'admin-post.php?action=gdpr_resolve&id=' . $item['ID'] ),
- 'wpl_resolve_request'
- );
- $actions['resolve'] = '<a href="' . esc_url( $resolve_url ) . '">' .
- __( 'Resolve', 'gdpr-cookie-consent' ) .
- '</a>';
- }
- $delete_url = wp_nonce_url(
- admin_url( 'admin-post.php?action=gdpr_delete&id=' . $item['ID'] ),
- 'wpl_delete_request'
- );
- $actions['delete'] = '<a href="' . esc_url( $delete_url ) . '">' . __( 'Delete', 'gdpr-cookie-consent' ) . '</a>';
- return $this->row_actions( $actions );
- }
- /**
- * Retrieve the table columns
- *
- * @return array $columns Array of all the list table columns
- * @since 3.0.0
- */
- public function get_columns() {
- $columns = array(
- 'cb' => '<label class="screen-reader-text" for="data-req-checkbox">Data Request report Log</label><input id="data-req-checkbox" type="checkbox"/>',
- 'name' => __( 'Name', 'gdpr-cookie-consent' ),
- 'email' => __( 'Email', 'gdpr-cookie-consent' ),
- 'resolved' => __( 'Status', 'gdpr-cookie-consent' ),
- 'datarequest' => __( 'Data request', 'gdpr-cookie-consent' ),
- 'date' => __( 'Date', 'gdpr-cookie-consent' ),
- 'actions_resolve_delete' => __( 'Actions', 'gdpr-cookie-consent' ),
- );
-
- return apply_filters( 'wpl_report_customer_columns', $columns );
- }
-
- public function column_cb( $item ) {
- return sprintf(
- '<input type="checkbox" name="%1$s_id[]" value="%2$s" />',
- esc_attr( $this->_args['singular'] ),
- esc_attr( $item['ID'] )
- );
- }
-
- /**
- * Get the sortable columns
- *
- * @return array Array of all the sortable columns
- * @since 3.0.0
- */
- public function get_sortable_columns() {
- return array(
- 'request_date' => array( 'request_date', true ),
- 'name' => array( 'name', true ),
- 'region' => array( 'region', true ),
- 'email' => array( 'email', true ),
- 'resolved' => array( 'resolved', true ),
- 'date' => array( 'date', true ),
- 'datarequest' => array( 'datarequest', true ),
- 'actions_resolve_delete' => array( 'actions_resolve_delete', true ),
- );
- }
-
- /**
- * Outputs the reporting views
- *
- * @return void
- * @since 3.0.0
- */
- public function get_bulk_actions( $which = '' ) {
-
- $actions = array(
- 'delete' => __( 'Delete', 'gdpr-cookie-consent' ),
- 'reslove' => __( 'Resolve', 'gdpr-cookie-consent' ),
- );
- // echo $this->resolved_select();
- return $actions;
- }
-
- /**
- * Process bulk actions
- *
- * @access private
- * @since 3.0.0
- * @return void
- */
- public function process_bulk_action() {
-
- if ( ! current_user_can( 'manage_options' ) ) {
- wp_die( 'Unauthorized request.' );
- }
-
- $ids = isset( $_GET['user_id'] ) ? array_filter( array_map( 'absint', (array) wp_unslash( $_GET['user_id'] ) ) ) : array();
- $action = $this->current_action();
- if ( ! $action ) {
- // If no action was found, check for action2 (bottom dropdown)
- $action2 = isset( $_GET['action2'] ) ? sanitize_text_field( wp_unslash( $_GET['action2'] ) ) : '';
- $action = ( '' !== $action2 && '-1' !== $action2 ) ? $action2 : false;
- }
- if ( !$action || ! $ids ) {
- return;
- }
- check_admin_referer( 'bulk-' . $this->_args['plural'] );
-
- if ( ! is_array( $ids ) ) {
- $ids = array( $ids );
- }
-
- foreach ( $ids as $id ) {
- if ( 'delete' === $action ) {
- global $wpdb;
- $wpdb->delete( $wpdb->prefix . 'wpl_data_req', array( 'ID' => intval( $id ) ) );
- $paged = isset( $_GET['paged'] ) ? 'paged=' . intval( $_GET['paged'] ) : '';
- } elseif ( 'reslove' === $action ) {
- global $wpdb;
- $wpdb->update(
- $wpdb->prefix . 'wpl_data_req',
- array(
- 'resolved' => 1,
- ),
- array( 'ID' => intval( $id ) )
- );
- }
- }
- $paged = isset( $_GET['paged'] ) ? 'paged=' . absint( $_GET['paged'] ) : '';
- $redirect_url = admin_url( 'admin.php?page=gdpr-cookie-consent' . ( $paged ? '&' . $paged : '' ) . '#compliance_records#data_request' );
- if ( headers_sent() ) {
- echo '<script>window.location.replace(' . wp_json_encode( esc_url_raw( $redirect_url ) ) . ');</script>';
- } else {
- wp_safe_redirect( $redirect_url );
- }
- exit;
- }
-
- /**
- * Retrieve the current page number
- *
- * @return int Current page number
- * @since 3.0.0
- */
- public function get_paged() {
- return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
- }
-
- /**
- * Retrieves the search query string
- *
- * @return mixed string If search is present, false otherwise
- * @since 3.0.0
- */
- public function get_search() {
- return ! empty( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : false;
- }
-
-
- public function resolved_select() {
- // Option Select
- $options = array(
- 0 => __( 'ALL', 'gdpr-cookie-consent' ),
- 1 => __( 'Resolved', 'gdpr-cookie-consent' ),
- 2 => __( 'Unresolved', 'gdpr-cookie-consent' ),
- );
- $selected = 0;
-
- if ( isset( $_GET['wpl_resolved_select2'] ) ) {
- $selected = intval( $_GET['wpl_resolved_select2'] );
- }
- // Generate a unique identifier for the select element
- $unique_id = uniqid( 'wpl_resolved_select_' );
-
- ?>
- <!-- submit the form on change -->
- <script>
-
- document.addEventListener('DOMContentLoaded', function () {
- var resolvedSelect = document.getElementById('<?php echo esc_js( $unique_id ); ?>');
- if (resolvedSelect) {
- resolvedSelect.addEventListener('change', function () {
- document.getElementById('wpl-dnsmpd-filter-datarequest').submit();
- });
- }
- });
- </script>
-
- <?php
- // Use the unique identifier in the select element's id attribute
- echo '<select name="wpl_resolved_select2" id="' . esc_js( $unique_id ) . '" class="wpl_resolved_select_filter">';
- foreach ( $options as $value => $label ) {
- echo '<option value="' . esc_attr( $value ) . '" ' . ( $selected == $value ? 'selected' : '' ) . '>' . esc_html( $label ) . '</option>';
- }
- echo '</select>';
- }
-
- /**
- * Build all the reports data
- *
- * @return array $reports_data All the data for customer reports
- * @global object $wpdb Used to query the database using the WordPress
- * Database API
- * @since 3.0.0
- */
- public function reports_data() {
-
- $data = array();
- $paged = $this->get_paged();
- $offset = $this->per_page * ( $paged - 1 );
- $search = $this->get_search();
- $order = isset( $_GET['order'] )
- ? sanitize_text_field( wp_unslash( $_GET['order'] ) ) : 'DESC';
- $orderby = isset( $_GET['orderby'] )
- ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : 'id';
-
- $args = array(
- 'number' => $this->per_page,
- 'offset' => $offset,
- 'order' => $order,
- 'orderby' => $orderby,
- 'search' => $search,
- );
-
- if ( is_email( $search ) ) {
- $args['email'] = $search;
- } else {
- $args['name'] = $search;
- }
-
- if ( isset( $_GET['wpl_resolved_select2'] ) ) {
- $args['resolved'] = intval( $_GET['wpl_resolved_select2'] );
- }
-
- $this->args = $args;
- $requests = $this->get_requests( $args );
- if ( $requests ) {
- foreach ( $requests as $request ) {
- $datarequest = '';
-
- $options = Gdpr_Cookie_Consent_Admin::wpl_data_reqs_options();
- foreach ( $options as $fieldname => $label ) {
- if ( $request->{$fieldname} == 1 ) {
- $datarequest = '<a href="https://wplegalpages.com/' . $label['slug'] . '" target="_blank">' . $label['short'] . '</a>';
- }
- }
- $time = gmdate( get_option( 'time_format' ), $request->request_date );
- $date = $this->wpl_localize_date( $request->request_date );
-
- // Translators: Placeholder %1$s represents the date, %2$s represents the time.
- $date_time_format = __( '%1$s at %2$s', 'gdpr-cookie-consent' );
-
- $date = sprintf( $date_time_format, $date, $time );
-
- $data[] = array(
- 'ID' => $request->ID,
- 'name' => $request->name,
- 'email' => $request->email,
- 'resolved' => $request->resolved,
- 'datarequest' => $datarequest,
- 'date' => $date,
- );
- }
- }
-
- return apply_filters( 'wpl_datarequest_data', $data );
- }
-
- /**
- * Prepare items for the table
- *
- * @return void
- */
- public function prepare_items() {
- $columns = $this->get_columns();
- $hidden = array(); // No hidden columns
- $sortable = $this->get_sortable_columns();
- $this->process_bulk_action();
- $this->_column_headers = array( $columns, $hidden, $sortable );
- $this->items = $this->reports_data();
- $this->total = $this->count_requests( $this->args );
- $total_pages = $this->per_page ? ceil( (int) $this->total / (int) $this->per_page ) : 1;
- $this->set_pagination_args(
- array(
- 'total_items' => $this->total,
- 'per_page' => $this->per_page,
- 'total_pages' => $total_pages,
- )
- );
- }
-
- /**
- * Count number of users
- *
- * @param $args
- *
- * @return int
- */
- public function count_requests( $args ) {
- unset( $args['number'] );
- $users = $this->get_requests( $args );
- return count( $users );
- }
-
- /**
- * Get users
- *
- * @param array $args
- *
- * @return array
- */
- public function get_requests( $args ) {
-
- global $wpdb;
- $table_name = $wpdb->prefix . 'wpl_data_req';
-
- if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) ) ) !== $table_name ) {
- // Table doesn't exist yet, return empty result set or handle as needed
- return array();
- }
- $sql = "SELECT * from {$wpdb->prefix}wpl_data_req WHERE 1=1 ";
- if ( isset( $args['email'] ) && ! empty( $args['email'] ) && is_email( $args['email'] ) ) {
- $sql .= $wpdb->prepare( " AND email LIKE %s", '%' . $wpdb->esc_like( sanitize_email( $args['email'] ) ) . '%' );
- }
-
- if ( isset( $args['name'] ) && ! empty( $args['name'] ) ) {
- $sql .= $wpdb->prepare(" AND name LIKE %s", '%' . $wpdb->esc_like( $args['name'] ) . '%');
- }
-
- if ( isset( $args['resolved'] ) ) {
-
- if ( intval( $args['resolved'] ) == 1 ) {
-
- $sql .= ' AND resolved = ' . intval( $args['resolved'] );
-
- } elseif ( intval( $args['resolved'] ) == 2 ) {
-
- $args['resolved'] = 0;
- $sql .= ' AND resolved = ' . intval( $args['resolved'] );
- }
- }
-
- $sql .= ' ORDER BY ' . sanitize_title( $args['orderby'] ) . ' ' . sanitize_title( $args['order'] );
- if ( isset( $args['number'] ) ) {
- $sql .= ' LIMIT ' . intval( $args['number'] ) . ' OFFSET ' . intval( $args['offset'] );
- }
- // as no data is inserting into the table so no $wpdb->prepare() is needed;
- return $wpdb->get_results( $sql ); // phpcs:ignore
- }
-
- public function wpl_localize_date( $unix_time ) {
-
- $formatted_date = gmdate( get_option( 'date_format' ), $unix_time );
- $month = gmdate( 'F', $unix_time );
- $month_localized = date_i18n( 'F', $unix_time );
- $date = str_replace( $month, $month_localized, $formatted_date );
- $weekday = gmdate( 'l', $unix_time );
- $weekday_localized = date_i18n( 'l', $unix_time );
- $date = str_replace( $weekday, $weekday_localized, $date );
- return $date;
- }
-
- public function wpl_sprintf() {
-
- $args = func_get_args();
- $count = substr_count( $args[0], '%s' );
- $args_count = count( $args ) - 1;
- if ( $args_count === $count ) {
- return call_user_func_array( 'sprintf', $args );
- } else {
- $output = $args[0];
- if ( is_admin() ) {
- $output .= 'Translation error';
- }
- return $output;
- }
- }
-}
+<?php
+/**
+ * Data Request Reports Table Class
+ */
+
+// Exit if accessed directly
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+// Load WP_List_Table if not loaded
+if ( ! class_exists( 'WP_List_Table' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
+}
+
+class WPL_Data_Req_Table extends WP_List_Table {
+
+ /**
+ * Query arg holding this table's current page (kept separate from other tables on the same page).
+ *
+ * @var string
+ */
+ const PAGED_ARG = 'wpl_dr_paged';
+
+ /**
+ * Page number used instead of the query arg once it is known to be past the last page.
+ *
+ * @var int|null
+ */
+ private $clamped_paged = null;
+
+ const LIST_ID = 'data_request';
+
+ /**
+ * Whether the current request (search, paging, sorting, bulk action) targets this table.
+ *
+ * @return bool
+ */
+ private function is_current_list() {
+ return isset( $_GET['wpl_list'] ) && self::LIST_ID === $_GET['wpl_list']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ }
+
+ /**
+ * Tag this table's pagination / sort links with its LIST_ID, and keep another
+ * table's search, paging and sorting out of them.
+ *
+ * @return void
+ */
+ public function display() {
+ $uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
+ $get = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ $list_uri = $uri;
+ if ( ! $this->is_current_list() ) {
+ $list_uri = remove_query_arg( array( 's', 'paged', 'orderby', 'order' ), $uri );
+ unset( $_GET['orderby'], $_GET['order'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Drops another table's sort args only; $_GET is restored below.
+ }
+ $_SERVER['REQUEST_URI'] = add_query_arg( 'wpl_list', self::LIST_ID, $list_uri );
+ parent::display();
+ $_SERVER['REQUEST_URI'] = $uri;
+ $_GET = $get;
+ }
+
+ /**
+ * Number of items per page
+ *
+ * @var int
+ * @since 3.0.0
+ */
+ public $per_page = 10;
+
+ /**
+ * Number of results found
+ *
+ * @var int
+ * @since 3.0.0
+ */
+ public $count = 0;
+
+ /**
+ * Total results
+ *
+ * @var int
+ * @since 3.0.0
+ */
+ public $total = 0;
+
+ /**
+ * The arguments for the data set
+ *
+ * @var array
+ * @since 3.0.0
+ */
+ public $args = array();
+
+ /**
+ * Get things started
+ *
+ * @since 3.0.0
+ * @see WP_List_Table::__construct()
+ */
+ public function __construct() {
+ global $status, $page;
+
+ // Set parent defaults
+ parent::__construct(
+ array(
+ 'singular' => __( 'User', 'gdpr-cookie-consent' ),
+ 'plural' => __( 'Users', 'gdpr-cookie-consent' ),
+ 'ajax' => false,
+ )
+ );
+ }
+
+ /**
+ * Show the search field
+ *
+ * @param string $text Label for the search box
+ * @param string $input_id ID of the search box
+ *
+ * @return void
+ * @since 3.0.0
+ */
+ public function search_box( $text, $input_id ) {
+ $input_id = $input_id . '-search-input-data-request';
+ echo '<input type="hidden" name="wpl_list" value="' . esc_attr( self::LIST_ID ) . '" />';
+
+ $order_by = $this->is_current_list() && isset( $_REQUEST['orderby'] ) ? sanitize_key( wp_unslash( $_REQUEST['orderby'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+
+ if ( '' !== $order_by && array_key_exists( $order_by, $this->get_sortable_columns() ) ) {
+ echo '<input type="hidden" name="orderby" value="' . esc_attr( $order_by ) . '" />';
+ }
+
+ $order = $this->is_current_list() && isset( $_REQUEST['order'] ) ? strtolower( sanitize_key( wp_unslash( $_REQUEST['order'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+
+ if ( in_array( $order, array( 'asc', 'desc' ), true ) ) {
+ echo '<input type="hidden" name="order" value="' . esc_attr( $order ) . '" />';
+ }
+ $search = $this->get_search();
+ ?>
+ <div class="search-and-export-container">
+ <div class="search-box">
+ <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
+ <?php echo esc_html( $text ); ?>:
+ </label>
+ <input placeholder="Search Requests" type="search" id="<?php echo esc_attr( $input_id ); ?>" name="wpl_dr_s" value="<?php echo esc_attr( $search ); ?>"/>
+ <img id="search-logo-data-request" v-on:click="submitDataRequestSearch" src="<?php echo esc_url( GDPR_COOKIE_CONSENT_PLUGIN_URL ) . 'admin/images/vector.png'; ?>" alt="Search Logo">
+ </div>
+ <?php
+ submit_button(
+ $text,
+ 'button',
+ false,
+ false,
+ array( 'ID' => 'search-submit-data-request' )
+ );
+ ?>
+ </div>
+ <?php
+
+ $this->resolved_select();
+
+ ?>
+ <?php
+ }
+
+ /**
+ * Gets the name of the primary column.
+ *
+ * @return string Name of the primary column.
+ * @since 3.0.0
+ * @access protected
+ */
+ protected function get_primary_column_name() {
+ return 'name';
+ }
+
+ /**
+ * This function renders most of the columns in the list table.
+ *
+ * @param array $item Contains all the data of the customers
+ * @param string $column_name The name of the column
+ *
+ * @return string Column Name
+ * @since 3.0.0
+ */
+ public function column_default( $item, $column_name ) {
+ switch ( $column_name ) {
+ case 'resolved':
+ $value = $item['resolved'] ? __( 'Resolved', 'gdpr-cookie-consent' ) : __( 'Open', 'gdpr-cookie-consent' );
+ break;
+ case 'datarequest':
+ // Built from the fixed request-type list, contains a link.
+ $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
+ break;
+ default:
+ $value = isset( $item[ $column_name ] ) ? gdpr_cookie_consent_esc_vue( $item[ $column_name ] ) : null;
+ break;
+ }
+ return apply_filters( 'wpl_dnsmpd_column_' . $column_name, $value, $item['ID'] );
+ }
+
+ /**
+ * Column name
+ *
+ * @param array $item
+ *
+ * @return string
+ */
+ public function column_name( $item ) {
+ $name = '#' . esc_html( $item['ID'] ) . ' ';
+ $name .= ! empty( $item['name'] ) ? gdpr_cookie_consent_esc_vue( $item['name'] ) : '<em>' . esc_html__( 'Unnamed user', 'gdpr-cookie-consent' ) . '</em>';
+ return $name;
+ }
+
+ /**
+ * Column name actions
+ *
+ * @param array $item
+ *
+ * @return string
+ */
+ public function column_actions_resolve_delete( $item ) {
+ $actions = array();
+
+ // Show Resolve action if not resolved
+ if ( empty( $item['resolved'] ) || intval( $item['resolved'] ) === 0 ) {
+ $resolve_url = wp_nonce_url(
+ admin_url( 'admin-post.php?action=gdpr_resolve&id=' . $item['ID'] ),
+ 'wpl_resolve_request'
+ );
+ $actions['resolve'] = '<a href="' . esc_url( $resolve_url ) . '">' .
+ __( 'Resolve', 'gdpr-cookie-consent' ) .
+ '</a>';
+ }
+ $delete_url = wp_nonce_url(
+ admin_url( 'admin-post.php?action=gdpr_delete&id=' . $item['ID'] ),
+ 'wpl_delete_request'
+ );
+ $actions['delete'] = '<a href="' . esc_url( $delete_url ) . '">' . __( 'Delete', 'gdpr-cookie-consent' ) . '</a>';
+ return $this->row_actions( $actions );
+ }
+ /**
+ * Retrieve the table columns
+ *
+ * @return array $columns Array of all the list table columns
+ * @since 3.0.0
+ */
+ public function get_columns() {
+ $columns = array(
+ 'cb' => '<label class="screen-reader-text" for="data-req-checkbox">Data Request report Log</label><input id="data-req-checkbox" type="checkbox"/>',
+ 'name' => __( 'Name', 'gdpr-cookie-consent' ),
+ 'email' => __( 'Email', 'gdpr-cookie-consent' ),
+ 'resolved' => __( 'Status', 'gdpr-cookie-consent' ),
+ 'datarequest' => __( 'Data request', 'gdpr-cookie-consent' ),
+ 'date' => __( 'Date', 'gdpr-cookie-consent' ),
+ 'actions_resolve_delete' => __( 'Actions', 'gdpr-cookie-consent' ),
+ );
+
+ return apply_filters( 'wpl_report_customer_columns', $columns );
+ }
+
+ public function column_cb( $item ) {
+ return sprintf(
+ '<input type="checkbox" name="%1$s_id[]" value="%2$s" />',
+ esc_attr( $this->_args['singular'] ),
+ esc_attr( $item['ID'] )
+ );
+ }
+
+ /**
+ * Get the sortable columns
+ *
+ * @return array Array of all the sortable columns
+ * @since 3.0.0
+ */
+ public function get_sortable_columns() {
+ return array(
+ 'request_date' => array( 'request_date', true ),
+ 'name' => array( 'name', true ),
+ 'region' => array( 'region', true ),
+ 'email' => array( 'email', true ),
+ 'resolved' => array( 'resolved', true ),
+ 'date' => array( 'date', true ),
+ 'datarequest' => array( 'datarequest', true ),
+ 'actions_resolve_delete' => array( 'actions_resolve_delete', true ),
+ );
+ }
+
+ /**
+ * Outputs the reporting views
+ *
+ * @return void
+ * @since 3.0.0
+ */
+ public function get_bulk_actions( $which = '' ) {
+
+ $actions = array(
+ 'delete' => __( 'Delete', 'gdpr-cookie-consent' ),
+ 'reslove' => __( 'Resolve', 'gdpr-cookie-consent' ),
+ );
+ // echo $this->resolved_select();
+ return $actions;
+ }
+
+ /**
+ * Process bulk actions
+ *
+ * @access private
+ * @since 3.0.0
+ * @return void
+ */
+ public function process_bulk_action() {
+
+ if ( ! $this->is_current_list() ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_die( 'Unauthorized request.' );
+ }
+
+ $ids = isset( $_GET['user_id'] ) ? array_filter( array_map( 'absint', (array) wp_unslash( $_GET['user_id'] ) ) ) : array();
+ $action = $this->current_action();
+ if ( ! $action ) {
+ // If no action was found, check for action2 (bottom dropdown)
+ $action2 = isset( $_GET['action2'] ) ? sanitize_text_field( wp_unslash( $_GET['action2'] ) ) : '';
+ $action = ( '' !== $action2 && '-1' !== $action2 ) ? $action2 : false;
+ }
+ if ( !$action || ! $ids ) {
+ return;
+ }
+ check_admin_referer( 'bulk-' . $this->_args['plural'] );
+
+ if ( ! is_array( $ids ) ) {
+ $ids = array( $ids );
+ }
+
+ global $wpdb;
+ foreach ( $ids as $id ) {
+ if ( 'delete' === $action ) {
+ $wpdb->delete( $wpdb->prefix . 'wpl_data_req', array( 'ID' => intval( $id ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin's own table; admin action, nothing to cache.
+ } elseif ( 'reslove' === $action ) {
+ $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin's own table; admin action, nothing to cache.
+ $wpdb->prefix . 'wpl_data_req',
+ array(
+ 'resolved' => 1,
+ ),
+ array( 'ID' => intval( $id ) )
+ );
+ }
+ }
+ $paged = isset( $_GET[ self::PAGED_ARG ] ) ? self::PAGED_ARG . '=' . absint( $_GET[ self::PAGED_ARG ] ) : '';
+ $redirect_url = admin_url( 'admin.php?page=gdpr-cookie-consent&wpl_list=' . self::LIST_ID . ( $paged ? '&' . $paged : '' ) . '#compliance_records#data_request' );
+ if ( ! headers_sent() ) {
+ wp_safe_redirect( $redirect_url );
+ exit;
+ }
+ echo '<script>window.location.replace(' . wp_json_encode( esc_url_raw( $redirect_url ) ) . ');</script>';
+ exit;
+ }
+
+ /**
+ * Retrieve the current page number
+ *
+ * @return int Current page number
+ * @since 3.0.0
+ */
+ public function get_paged() {
+ if ( null !== $this->clamped_paged ) {
+ return $this->clamped_paged;
+ }
+ return isset( $_GET[ self::PAGED_ARG ] ) ? max( 1, absint( $_GET[ self::PAGED_ARG ] ) ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only pagination arg, cast with absint().
+ }
+
+ /**
+ * Current page number for WP_List_Table, read from this table's own query arg.
+ *
+ * The Data Requests table shares an admin page with other list tables, so it
+ * cannot use the core 'paged' arg without changing their page too.
+ *
+ * @return int
+ */
+ public function get_pagenum() {
+ $pagenum = $this->get_paged();
+ if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
+ $pagenum = $this->_pagination_args['total_pages'];
+ }
+ return max( 1, (int) $pagenum );
+ }
+
+ /**
+ * Store the pagination args before core validates them, so get_pagenum() can clamp an
+ * out-of-range page itself. Core would otherwise redirect using the 'paged' arg,
+ * which this table ignores, and loop.
+ *
+ * @param array $args Pagination args.
+ */
+ protected function set_pagination_args( $args ) {
+ $this->_pagination_args = $args;
+ parent::set_pagination_args( $args );
+ }
+
+ /**
+ * Render core pagination, rewritten to use this table's own page query arg.
+ *
+ * @param string $which 'top' or 'bottom'.
+ */
+ protected function pagination( $which ) {
+ // Core builds the links from REQUEST_URI; drop our arg so the first-page link really goes to page 1.
+ $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
+ $_SERVER['REQUEST_URI'] = remove_query_arg( self::PAGED_ARG, $request_uri );
+ ob_start();
+ parent::pagination( $which );
+ $html = ob_get_clean();
+ $_SERVER['REQUEST_URI'] = $request_uri;
+
+ $html = preg_replace( '/([?&;])paged=/', '$1' . self::PAGED_ARG . '=', $html );
+ echo preg_replace( '/name=(['"])paged\1/', 'name="' . self::PAGED_ARG . '"', $html ); // phpcs:ignore WordPress.Security.EscapeOutput -- markup escaped by core.
+ }
+
+ /**
+ * Retrieves the search query string
+ *
+ * @return mixed string If search is present, false otherwise
+ * @since 3.0.0
+ */
+ public function get_search() {
+ return $this->is_current_list() && ! empty( $_GET['wpl_dr_s'] ) ? sanitize_text_field( wp_unslash( $_GET['wpl_dr_s'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only search filter, sanitized; output escaped and queries prepared.
+ }
+
+
+ public function resolved_select() {
+ // Option Select
+ $options = array(
+ 0 => __( 'ALL', 'gdpr-cookie-consent' ),
+ 1 => __( 'Resolved', 'gdpr-cookie-consent' ),
+ 2 => __( 'Unresolved', 'gdpr-cookie-consent' ),
+ );
+ $selected = 0;
+
+ if ( isset( $_GET['wpl_resolved_select2'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+ $selected = intval( $_GET['wpl_resolved_select2'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+ }
+ // Generate a unique identifier for the select element
+ $unique_id = uniqid( 'wpl_resolved_select_' );
+
+ ?>
+ <!-- submit the form on change -->
+ <script>
+
+ document.addEventListener('DOMContentLoaded', function () {
+ var resolvedSelect = document.getElementById('<?php echo esc_js( $unique_id ); ?>');
+ if (resolvedSelect) {
+ resolvedSelect.addEventListener('change', function () {
+ document.getElementById('wpl-dnsmpd-filter-datarequest').submit();
+ });
+ }
+ });
+ </script>
+
+ <?php
+ // Use the unique identifier in the select element's id attribute
+ echo '<select name="wpl_resolved_select2" id="' . esc_js( $unique_id ) . '" class="wpl_resolved_select_filter">';
+ foreach ( $options as $value => $label ) {
+ echo '<option value="' . esc_attr( $value ) . '" ' . ( $selected == $value ? 'selected' : '' ) . '>' . esc_html( $label ) . '</option>';
+ }
+ echo '</select>';
+ }
+
+ /**
+ * Build all the reports data
+ *
+ * @return array $reports_data All the data for customer reports
+ * @global object $wpdb Used to query the database using the WordPress
+ * Database API
+ * @since 3.0.0
+ */
+ public function reports_data() {
+
+ $data = array();
+ $paged = $this->get_paged();
+ $offset = $this->per_page * ( $paged - 1 );
+ $search = $this->get_search();
+ $order = $this->is_current_list() && isset( $_GET['order'] ) ? sanitize_key( wp_unslash( $_GET['order'] ) ) : 'desc'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+ $orderby = $this->is_current_list() && isset( $_GET['orderby'] ) ? sanitize_key( wp_unslash( $_GET['orderby'] ) ) : 'id'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+
+ $args = array(
+ 'number' => $this->per_page,
+ 'offset' => $offset,
+ 'order' => $order,
+ 'orderby' => $orderby,
+ 'search' => $search,
+ );
+
+ if ( is_email( $search ) ) {
+ $args['email'] = $search;
+ } else {
+ $args['name'] = $search;
+ }
+
+ if ( isset( $_GET['wpl_resolved_select2'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+ $args['resolved'] = intval( $_GET['wpl_resolved_select2'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only list view arg, sanitized.
+ }
+
+ $this->args = $args;
+ $requests = $this->get_requests( $args );
+ if ( $requests ) {
+ foreach ( $requests as $request ) {
+ $datarequest = '';
+
+ $options = Gdpr_Cookie_Consent_Admin::wpl_data_reqs_options();
+ foreach ( $options as $fieldname => $label ) {
+ if ( $request->{$fieldname} == 1 ) {
+ $datarequest = '<a href="https://wplegalpages.com/' . $label['slug'] . '" target="_blank">' . $label['short'] . '</a>';
+ }
+ }
+ $time = gmdate( get_option( 'time_format' ), $request->request_date );
+ $date = $this->wpl_localize_date( $request->request_date );
+
+ // Translators: Placeholder %1$s represents the date, %2$s represents the time.
+ $date_time_format = __( '%1$s at %2$s', 'gdpr-cookie-consent' );
+
+ $date = sprintf( $date_time_format, $date, $time );
+
+ $data[] = array(
+ 'ID' => $request->ID,
+ 'name' => $request->name,
+ 'email' => $request->email,
+ 'resolved' => $request->resolved,
+ 'datarequest' => $datarequest,
+ 'date' => $date,
+ );
+ }
+ }
+
+ return apply_filters( 'wpl_datarequest_data', $data );
+ }
+
+ /**
+ * Prepare items for the table
+ *
+ * @return void
+ */
+ public function prepare_items() {
+ $columns = $this->get_columns();
+ $hidden = array(); // No hidden columns
+ $sortable = $this->get_sortable_columns();
+ $this->process_bulk_action();
+ $this->_column_headers = array( $columns, $hidden, $sortable );
+ $this->items = $this->reports_data();
+ $this->total = $this->count_requests( $this->args );
+ $total_pages = $this->per_page ? ceil( (int) $this->total / (int) $this->per_page ) : 1;
+ // An out-of-range page (e.g. a stale link after deletions) shows the last page, not an empty one.
+ if ( $total_pages > 0 && $this->get_paged() > $total_pages ) {
+ $this->clamped_paged = (int) $total_pages;
+ $this->items = $this->reports_data();
+ }
+ $this->set_pagination_args(
+ array(
+ 'total_items' => $this->total,
+ 'per_page' => $this->per_page,
+ 'total_pages' => $total_pages,
+ )
+ );
+ }
+
+ /**
+ * Count number of users
+ *
+ * @param $args
+ *
+ * @return int
+ */
+ public function count_requests( $args ) {
+ unset( $args['number'] );
+ $users = $this->get_requests( $args );
+ return count( $users );
+ }
+
+ /**
+ * Get users
+ *
+ * @param array $args
+ *
+ * @return array
+ */
+ public function get_requests( $args ) {
+
+ global $wpdb;
+ $table_name = $wpdb->prefix . 'wpl_data_req';
+
+ if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) ) ) !== $table_name ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin's own table; schema check.
+ // Table doesn't exist yet, return empty result set or handle as needed
+ return array();
+ }
+ $sql = "SELECT * from {$wpdb->prefix}wpl_data_req WHERE 1=1 ";
+ if ( isset( $args['email'] ) && ! empty( $args['email'] ) && is_email( $args['email'] ) ) {
+ $sql .= $wpdb->prepare( " AND email LIKE %s", '%' . $wpdb->esc_like( sanitize_email( $args['email'] ) ) . '%' );
+ }
+
+ if ( isset( $args['name'] ) && ! empty( $args['name'] ) ) {
+ $sql .= $wpdb->prepare(" AND name LIKE %s", '%' . $wpdb->esc_like( $args['name'] ) . '%');
+ }
+
+ if ( isset( $args['resolved'] ) ) {
+
+ if ( intval( $args['resolved'] ) == 1 ) {
+
+ $sql .= ' AND resolved = ' . intval( $args['resolved'] );
+
+ } elseif ( intval( $args['resolved'] ) == 2 ) {
+
+ $args['resolved'] = 0;
+ $sql .= ' AND resolved = ' . intval( $args['resolved'] );
+ }
+ }
+
+ // ORDER BY cannot be a placeholder, so only known columns and directions get in.
+ // Sortable columns without a database column of their own sort by date or ID.
+ $columns = array(
+ 'id' => 'ID',
+ 'name' => 'name',
+ 'email' => 'email',
+ 'resolved' => 'resolved',
+ 'request_date' => 'request_date',
+ 'date' => 'request_date',
+ );
+ $orderby = isset( $args['orderby'] ) ? strtolower( (string) $args['orderby'] ) : 'id';
+ $orderby = isset( $columns[ $orderby ] ) ? $columns[ $orderby ] : 'ID';
+ $order = ( isset( $args['order'] ) && 'asc' === strtolower( (string) $args['order'] ) ) ? 'ASC' : 'DESC';
+ $sql .= ' ORDER BY ' . $orderby . ' ' . $order;
+ if ( isset( $args['number'] ) ) {
+ $sql .= ' LIMIT ' . intval( $args['number'] ) . ' OFFSET ' . intval( $args['offset'] );
+ }
+ // as no data is inserting into the table so no $wpdb->prepare() is needed;
+ return $wpdb->get_results( $sql ); // phpcs:ignore
+ }
+
+ public function wpl_localize_date( $unix_time ) {
+
+ $formatted_date = gmdate( get_option( 'date_format' ), $unix_time );
+ $month = gmdate( 'F', $unix_time );
+ $month_localized = date_i18n( 'F', $unix_time );
+ $date = str_replace( $month, $month_localized, $formatted_date );
+ $weekday = gmdate( 'l', $unix_time );
+ $weekday_localized = date_i18n( 'l', $unix_time );
+ $date = str_replace( $weekday, $weekday_localized, $date );
+ return $date;
+ }
+
+ public function wpl_sprintf() {
+
+ $args = func_get_args();
+ $count = substr_count( $args[0], '%s' );
+ $args_count = count( $args ) - 1;
+ if ( $args_count === $count ) {
+ return call_user_func_array( 'sprintf', $args );
+ } else {
+ $output = $args[0];
+ if ( is_admin() ) {
+ $output .= 'Translation error';
+ }
+ return $output;
+ }
+ }
+}
--- a/gdpr-cookie-consent/admin/gdpr-cookie-consent-admin-settings.php
+++ b/gdpr-cookie-consent/admin/gdpr-cookie-consent-admin-settings.php
@@ -511,7 +511,7 @@
- <div class="notice-content-body" :style="{'gap': cookie_bar_spacing + 'px'}" style="width: 100%; flex-direction: <?php echo esc_attr($banner_layouts['c2']['direction'] == 'col' ? ($banner_structure['c2'][0] === 'bannerText' ? 'column' : 'column-reverse') : ($banner_structure['c2'][0] === 'bannerText' ? 'row' : 'row-reverse')); ?>;" :class="'notice-template-name-' + (template == 'default' || template == 'new_default' ? default_template_json : json_templates[template])?.name + ' template-' + (template == 'default' || template == 'new_default' ? default_template_json : json_templates[template])?.['static-settings']?.['layout']">
+ <div class="notice-content-body" :style="{'gap': cookie_bar_spacing + 'px'}" style="width: 100%; flex-direction: <?php echo esc_attr($banner_layouts['c2']['direction'] == 'col' ? ($banner_structure['c2'][0] === 'bannerText' ? 'column' : 'column-reverse') : ($banner_structure['c2'][0] === 'bannerText' ? 'row' : 'row-reverse')); ?>;<?php echo $banner_layouts['c2']['direction'] == 'row' ? ' align-items: center;' : ''; ?>" :class="'notice-template-name-' + (template == 'default' || template == 'new_default' ? default_template_json : json_templates[template])?.name + ' template-' + (template == 'default' || template == 'new_default' ? default_template_json : json_templates[template])?.['static-settings']?.['layout']">
<div style="display: flex; flex-direction: column; gap:10px;">
<p :style="{
'color': cookie_text_color,
@@ -915,14 +915,30 @@
<?php } ?>
<c-row>
- <c-col class="col-sm-4"><label><?php esc_html_e( 'Restrict Pages and/or Posts', 'gdpr-cookie-consent' ); ?> <tooltip text="<?php esc_attr_e( 'Restrict Pages and/or Posts during scanning of your website for cookies.', 'gdpr-cookie-consent' ); ?>"></tooltip></label></c-col>
+ <c-col class="col-sm-4"><label><?php esc_html_e( 'Restrict Pages and/or Posts', 'gdpr-cookie-consent' ); ?> <tooltip text="<?php esc_attr_e( 'Restrict Pages and/or Posts during scanning of your website for cookies.', 'gdpr-cookie-consent' ); ?>"></tooltip>
+ <a href="https://wplegalpages.com/pricing?utm_source=wp_cookie_consent&utm_medium=font&utm_campaign=plugin_upgrade" style="margin-left:5px;vertical-align:middle" class="probadge bg-badge">
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 640 640" fill="#f5af2f">
+ <path d="M345 151.2C354.2 143.9 360 132.6 360 120C360 97.9 342.1 80 320 80C297.9 80 280 97.9 280 120C280 132.6 285.9 143.9 295 151.2L226.6 258.8C216.6 274.5 195.3 278.4 180.4 267.2L120.9 222.7C125.4 216.3 128 208.4 128 200C128 177.9 110.1 160 88 160C65.9 160 48 177.9 87.2 240L119.8 457.5C124.5 488.8 151.4 512 183.1 512L456.9 512C488.6 512 515.5 488.8 520.2 457.5L552.8 240C574.5 239.6 592 221.8 592 200C592 177.9 574.1 160 552 160C529.9 160 512 177.9 512 200C512 208.4 514.6 216.3 519.1 222.7L459.7 267.3C444.8 278.5 423.5 274.6 413.5 258.9L345 151.2z"/>
+ <path d="M180 550H460" fill="none" stroke="#f5af2f" stroke-width="28" stroke-linecap="round"/>
+ </svg>
+ </a>
+ </label></c-col>
<c-col class="col-sm-8">
- <v-select placeholder="Select Pages and Posts" id="gdpr-cookie-consent-restrict-posts" :reduce="label => label.code" class="form-group" :options="list_of_contents" multiple v-model="restrict_array" @input="onPostsSelect"></v-select>
- <input type="hidden" name="gcc-restrict-posts" v-model="restrict_posts">
+ <?php if ( !$is_user_connected || empty($is_user_connected) || $api_user_plan === 'free' ) : ?>
+ <div class="gdpr-disabled-restrict-posts-integration">
+ <v-select placeholder="Select Pages and Posts" id="gdpr-cookie-consent-restrict-posts" :reduce="label => label.code" class="form-group" :options="list_of_contents" multiple v-model="restrict_array" disabled></v-select>
+ <input type="hidden" name="gcc-restrict-posts" v-model="restrict_posts">
+ <p class="gdpr-restrict_page-gdpr">
+ <?php esc_html_e( 'To enable this feature, connect to your pro account', 'gdpr-cookie-consent' ); ?>
+ </p>
+ </div>
+ <?php else : ?>
+ <v-select placeholder="Select Pages and Posts" id="gdpr-cookie-consent-restrict-posts" :reduce="label => label.code" class="form-group" :options="list_of_contents" multiple v-model="restrict_array" @input="onPostsSelect"></v-select>
+ <input type="hidden" name="gcc-restrict-posts" v-model="restrict_posts">
+ <?php endif; ?>
</c-col>
</c-row>
-
<c-row>
<c-col class="col-sm-4"><label><?php esc_html_e( 'Banner Initialization', 'gdpr-cookie-consent' ); ?> <tooltip text="<?php esc_attr_e( 'Control when the cookie banner should appear, immediately on page load or after user interaction.', 'gdpr-cookie-consent'); ?>"></tooltip></label></c-col>
<c-col class="col-sm-8">
@@ -1950,9 +1966,14 @@
<div class="gdpr-pro-label"><div class="gdpr-pro-label-text">Pro</div></div>
</c-col>
<c-col class="col-sm-8">
+ <div class="gdpr-disabled-font-integration">
<v-select disabled class="form-group" id="gdpr-cookie-font" :reduce="label => label.code" :options="font_options" v-model="cookie_font">
</v-select>
<input type="hidden" name="gdpr-cookie-font" v-model="cookie_font">
+ <p class="gdpr-font-message">
+ <?php esc_html_e( 'To enable this feature, upgrade to a pro plan', 'gdpr-cookie-consent' ); ?>
+ </p>
+ </div>
</c-col>
</c-row>
<?php endif ?>
@@ -1961,11 +1982,31 @@
} else {
?>
<c-row>
- <c-col class="col-sm-4"><label><?php esc_html_e( 'Font', 'gdpr-cookie-consent' ); ?></label></c-col>
+ <c-col class="col-sm-4">
+ <label>
+ <?php esc_html_e( 'Font', 'gdpr-cookie-consent' ); ?>
+ <a style="margin-left:5px;vertical-align:bottom" class="probadge bg-badge">
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 640 640" fill="#f5af2f">
+ <path d="M345 151.2C354.2 143.9 360 132.6 360 120C360 97.9 342.1 80 320 80C297.9 80 280 97.9 280 120C280 132.6 285.9 143.9 295 151.2L226.6 258.8C216.6 274.5 195.3 278.4 180.4 267.2L120.9 222.7C125.4 216.3 128 208.4 128 200C128 177.9 110.1 160 88 160C65.9 160 48 177.9 87.2 240L119.8 457.5C124.5 488.8 151.4 512 183.1 512L456.9 512C488.6 512 515.5 488.8 520.2 457.5L552.8 240C574.5 239.6 592 221.8 592 200C592 177.9 574.1 160 552 160C529.9 160 512 177.9 512 200C512 208.4 514.6 216.3 519.1 222.7L459.7 267.3C444.8 278.5 423.5 274.6 413.5 258.9L345 151.2z"/>
+ <path d="M180 550H460" fill="none" stroke="#f5af2f" stroke-width="28" stroke-linecap="round"/>
+ </svg>
+ </a>
+ </label>
+ </c-col>
<c-col class="col-sm-8">
- <v-select class="form-group" id="gdpr-cookie-font" :reduce="label => label.code" :options="font_options" v-model="cookie_font">
+ <?php if ( !$is_user_connected || empty($is_user_connected) || $api_user_plan === 'free' ) : ?>
+ <div class="gdpr-disabled-font-integration">
+ <v-select disabled class="form-group" id="gdpr-cookie-font" :reduce="label => label.code" :options="font_options" v-model="cookie_font">
</v-select>
<input type="hidden" name="gdpr-cookie-font" v-model="cookie_font">
+ <p class="gdpr-font-message">
+ <?php esc_html_e( 'To enable this feature, upgrade to a pro plan', 'gdpr-cookie-consent' ); ?>
+ </p>
+ </div>
+ <?php else : ?>
+ <v-select class="form-group" id="gdpr-cookie-font" :reduce="label => label.code" :options="font_options" v-model="cookie_font"></v-select>
+ <input type="hidden" name="gdpr-cookie-font" v-model="cookie_font">
+ <?php endif; ?>
</c-col>
</c-row>
<?php } ?>
@@ -5834,7 +5875,7 @@
></c-input>
</c-col>
<c-col class="col-sm-1">
- <c-button :disabled="!button_readmore_is_on1" class="gdpr-configure-button" :style="(button_readmore_popup2 || button_readmore_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('button_readmore_popup1')">
+ <c-button :disabled="!button_readmore_is_on1" class="gdpr-configure-button" :style="(button_readmore_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('button_readmore_popup1')">
<svg width="40" height="40" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_4634_793)"><path d="M14.1462 30.3445C11.8737 32.5765 13.7937 34.8685 10.7757 38.263C9.41368 39.7975 16.3827 39.3295 19.8342 35.9365C21.2997 34.495 20.8857 32.398 19.3152 30.853C17.7447 29.311 15.6102 28.903 14.1462 30.3445ZM39.3102 10.9885C38.1462 9.84253 25.2417 20.182 21.4017 23.9575C19.4952 25.8325 18.8592 26.8375 18.2757 27.5875C18.0207 27.916 18.3582 28.015 18.5067 28.0915C19.2627 28.4785 19.7907 28.8355 20.4732 29.506C21.1572 30.1765 21.5217 30.6955 21.9117 31.4395C21.9912 31.5865 22.0932 31.9165 22.4247 31.6675C23.1897 31.093 24.2112 30.466 26.1177 28.594C29.9592 24.82 40.4772 12.133 39.3102 10.9885Z" fill="currentColor"/></g><defs><clipPath id="clip0_4634_793"><rect width="30" height="30" fill="white" transform="translate(10 10)"/></clipPath></defs></svg>
</c-button>
@@ -5862,7 +5903,7 @@
></c-input>
</c-col>
<c-col class="col-sm-1">
- <c-button :disabled="!is_revoke_consent_on1" class="gdpr-configure-button" :style="(revoke_consent_popup2 || revoke_consent_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('revoke_consent_popup1')">
+ <c-button :disabled="!is_revoke_consent_on1" class="gdpr-configure-button" :style="(revoke_consent_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('revoke_consent_popup1')">
<svg width="40" height="40" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_4634_793)"><path d="M14.1462 30.3445C11.8737 32.5765 13.7937 34.8685 10.7757 38.263C9.41368 39.7975 16.3827 39.3295 19.8342 35.9365C21.2997 34.495 20.8857 32.398 19.3152 30.853C17.7447 29.311 15.6102 28.903 14.1462 30.3445ZM39.3102 10.9885C38.1462 9.84253 25.2417 20.182 21.4017 23.9575C19.4952 25.8325 18.8592 26.8375 18.2757 27.5875C18.0207 27.916 18.3582 28.015 18.5067 28.0915C19.2627 28.4785 19.7907 28.8355 20.4732 29.506C21.1572 30.1765 21.5217 30.6955 21.9117 31.4395C21.9912 31.5865 22.0932 31.9165 22.4247 31.6675C23.1897 31.093 24.2112 30.466 26.1177 28.594C29.9592 24.82 40.4772 12.133 39.3102 10.9885Z" fill="currentColor"/></g><defs><clipPath id="clip0_4634_793"><rect width="30" height="30" fill="white" transform="translate(10 10)"/></clipPath></defs></svg>
</c-button>
@@ -5896,7 +5937,7 @@
></c-input>
</c-col>
<c-col class="col-sm-1">
- <c-button :disabled="!cookie_accept_on1" class="gdpr-configure-button" :style="(accept_button_popup2 || accept_button_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('accept_button_popup1')">
+ <c-button :disabled="!cookie_accept_on1" class="gdpr-configure-button" :style="(accept_button_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('accept_button_popup1')">
<svg width="40" height="40" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_4634_793)"><path d="M14.1462 30.3445C11.8737 32.5765 13.7937 34.8685 10.7757 38.263C9.41368 39.7975 16.3827 39.3295 19.8342 35.9365C21.2997 34.495 20.8857 32.398 19.3152 30.853C17.7447 29.311 15.6102 28.903 14.1462 30.3445ZM39.3102 10.9885C38.1462 9.84253 25.2417 20.182 21.4017 23.9575C19.4952 25.8325 18.8592 26.8375 18.2757 27.5875C18.0207 27.916 18.3582 28.015 18.5067 28.0915C19.2627 28.4785 19.7907 28.8355 20.4732 29.506C21.1572 30.1765 21.5217 30.6955 21.9117 31.4395C21.9912 31.5865 22.0932 31.9165 22.4247 31.6675C23.1897 31.093 24.2112 30.466 26.1177 28.594C29.9592 24.82 40.4772 12.133 39.3102 10.9885Z" fill="currentColor"/></g><defs><clipPath id="clip0_4634_793"><rect width="30" height="30" fill="white" transform="translate(10 10)"/></clipPath></defs></svg>
</c-button>
@@ -5922,7 +5963,7 @@
></c-input>
</c-col>
<c-col class="col-sm-1">
- <c-button :disabled="!cookie_accept_all_on1" class="gdpr-configure-button" :style="(accept_all_button_popup2 || accept_all_button_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('accept_all_button_popup1')">
+ <c-button :disabled="!cookie_accept_all_on1" class="gdpr-configure-button" :style="(accept_all_button_popup1) ? { backgroundColor: '#EAF4FF !important', color: '#2F80ED !important' } : {}" @click="openConfigurationPanel('accept_all_button_popup1')">
<svg width="40" height="40" viewBox="0 0 50 50" fill="none" xmlns="http://www.w