Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/wpforms-.../src/Logger
File: RecordQuery.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
[2] Fix | Delete
/** @noinspection PhpIllegalPsrClassPathInspection */
[3] Fix | Delete
[4] Fix | Delete
namespace WPForms\Logger;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class RecordQuery.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 1.6.3
[10] Fix | Delete
*/
[11] Fix | Delete
class RecordQuery {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Build query.
[15] Fix | Delete
*
[16] Fix | Delete
* @since 1.6.3
[17] Fix | Delete
*
[18] Fix | Delete
* @param int $limit Query limit of records.
[19] Fix | Delete
* @param int $offset Offset of records.
[20] Fix | Delete
* @param string $search Search.
[21] Fix | Delete
* @param string $type Type of records.
[22] Fix | Delete
*
[23] Fix | Delete
* @return array
[24] Fix | Delete
*/
[25] Fix | Delete
public function get( $limit, $offset = 0, $search = '', $type = '' ) {
[26] Fix | Delete
[27] Fix | Delete
global $wpdb;
[28] Fix | Delete
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
[29] Fix | Delete
return (array) $wpdb->get_results(
[30] Fix | Delete
$this->build_query( $limit, $offset, $search, $type )
[31] Fix | Delete
);
[32] Fix | Delete
//phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Build query.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 1.6.3
[39] Fix | Delete
*
[40] Fix | Delete
* @param int $limit Query limit of records.
[41] Fix | Delete
* @param int $offset Offset of records.
[42] Fix | Delete
* @param string $search Search.
[43] Fix | Delete
* @param string $type Type of records.
[44] Fix | Delete
*
[45] Fix | Delete
* @return string
[46] Fix | Delete
*/
[47] Fix | Delete
private function build_query( $limit, $offset = 0, $search = '', $type = '' ) {
[48] Fix | Delete
[49] Fix | Delete
global $wpdb;
[50] Fix | Delete
[51] Fix | Delete
$sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM ' . Repository::get_table_name();
[52] Fix | Delete
$where = [];
[53] Fix | Delete
[54] Fix | Delete
if ( ! empty( $search ) ) {
[55] Fix | Delete
$where[] = $wpdb->prepare(
[56] Fix | Delete
'`title` REGEXP %s OR `message` REGEXP %s',
[57] Fix | Delete
$search,
[58] Fix | Delete
$search
[59] Fix | Delete
);
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
if ( ! empty( $type ) ) {
[63] Fix | Delete
$where[] = $wpdb->prepare(
[64] Fix | Delete
'`types` REGEXP %s',
[65] Fix | Delete
$type
[66] Fix | Delete
);
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if ( $where ) {
[70] Fix | Delete
$sql .= ' WHERE ' . implode( ' AND ', $where );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
$sql .= ' ORDER BY `create_at` DESC, `id` DESC';
[74] Fix | Delete
$sql .= $wpdb->prepare( ' LIMIT %d, %d', absint( $offset ), absint( $limit ) );
[75] Fix | Delete
[76] Fix | Delete
return $sql;
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function