Skip to content

Commit 318cfa6

Browse files
committed
Change visibility of multiple methods from private to protected across admin classes
- Admin_Notices_API::is_notice_dismissed() - Admin_Notices::register_db_update_notice(), register_notices(), register_fulltext_index_notice(), register_missing_table_notice() - Admin::get_admin_banner_config() - Settings_Wizard::build_step_settings() - Statistics_Table::get_network_popular_searches(), get_orderby_clause() - Add static cache to Dashboard::get_data() to prevent duplicate queries - Remove inline script from Tools_Page (bsearchAdd
1 parent 78f8de0 commit 318cfa6

17 files changed

Lines changed: 100 additions & 483 deletions

includes/admin/class-admin-notices-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function handle_notice_dismissal() {
198198
* @param string $notice_id Notice ID.
199199
* @return bool Whether the notice has been dismissed.
200200
*/
201-
private function is_notice_dismissed( $notice_id ) {
201+
protected function is_notice_dismissed( $notice_id ) {
202202
$notice = $this->notices[ $notice_id ] ?? null;
203203

204204
if ( ! $notice ) {

includes/admin/class-admin-notices.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function update_db_check() {
7070
*
7171
* @since 4.2.0
7272
*/
73-
private function register_db_update_notice() {
73+
protected function register_db_update_notice() {
7474
$is_upgrader_page = isset( $_GET['page'] ) && 'bsearch-upgrader' === $_GET['page']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
7575

7676
if ( $is_upgrader_page ) {
@@ -138,7 +138,7 @@ function () use ( $message ) {
138138
*
139139
* @since 4.2.0
140140
*/
141-
private function register_notices() {
141+
protected function register_notices() {
142142
// Only register notices if the API is available.
143143
if ( ! $this->admin_notices_api ) {
144144
return;
@@ -153,7 +153,7 @@ private function register_notices() {
153153
*
154154
* @since 4.2.0
155155
*/
156-
private function register_fulltext_index_notice() {
156+
protected function register_fulltext_index_notice() {
157157
// Check if admin_notices_api is available.
158158
if ( ! $this->admin_notices_api ) {
159159
return;
@@ -187,7 +187,7 @@ function () {
187187
*
188188
* @since 4.2.0
189189
*/
190-
private function register_missing_table_notice() {
190+
protected function register_missing_table_notice() {
191191
// Check if admin_notices_api is available.
192192
if ( ! $this->admin_notices_api ) {
193193
return;

includes/admin/class-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public static function pro_upgrade_banner( $donate = true, $custom_text = '' ) {
317317
*
318318
* @return array<string, mixed>
319319
*/
320-
private function get_admin_banner_config(): array {
320+
protected function get_admin_banner_config(): array {
321321
$dashboard_url = admin_url( 'admin.php?page=bsearch_dashboard' );
322322
$popular_url = admin_url( 'admin.php?page=bsearch_popular_searches' );
323323
$settings_url = admin_url( 'admin.php?page=bsearch_options_page' );

includes/admin/class-dashboard.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,15 @@ public function get_popular_searches( $args = array() ) {
544544
$sql = "SELECT DISTINCT $fields FROM {$table_name} $join WHERE 1=1 $where $groupby $orderby $limits";
545545
}
546546

547-
$result = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
547+
static $cache = array();
548+
549+
$cache_key = md5( $sql );
550+
if ( isset( $cache[ $cache_key ] ) ) {
551+
return $cache[ $cache_key ];
552+
}
553+
554+
$result = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
555+
$cache[ $cache_key ] = $result;
548556

549557
return $result;
550558
}

includes/admin/class-settings-wizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function get_wizard_steps() {
160160
* @param array $all_settings All settings array.
161161
* @return array
162162
*/
163-
private function build_step_settings( $keys, $all_settings ) {
163+
protected function build_step_settings( $keys, $all_settings ) {
164164
$settings = array();
165165
foreach ( $keys as $key ) {
166166
if ( isset( $all_settings[ $key ] ) ) {

includes/admin/class-statistics-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function get_popular_searches( $per_page = 20, $page_number = 1, $args =
130130
* @param string $to_date To date in Y-m-d format.
131131
* @return array Array of popular search terms.
132132
*/
133-
private function get_network_popular_searches( $per_page, $page_number, $args, $from_date, $to_date ) {
133+
protected function get_network_popular_searches( $per_page, $page_number, $args, $from_date, $to_date ) {
134134
global $wpdb;
135135

136136
$overall_unions = self::get_network_table_unions( 'bsearch' );
@@ -497,7 +497,7 @@ public function process_bulk_action() {
497497
* @param array $args Array of arguments.
498498
* @return string ORDER BY clause without the ORDER BY keyword.
499499
*/
500-
private function get_orderby_clause( $args = null ) {
500+
protected function get_orderby_clause( $args = null ) {
501501
$orderby = '';
502502
if ( ! empty( $_REQUEST['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
503503
$orderby = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended

includes/admin/class-tools-page.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ public function render_page() {
218218
<?php $sql_queries = self::recreate_indices_sql(); ?>
219219
<pre id="bsearch-indices-sql"><code><?php echo implode( "\n", array_map( 'esc_html', $sql_queries ) ); ?></code></pre>
220220
</div>
221-
<script>
222-
jQuery(document).ready(function($) {
223-
bsearchAddCopyButton('bsearch-indices-sql');
224-
});
225-
</script>
226221

227222
</div>
228223
</div>

includes/admin/css/better-search-admin-rtl.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,12 @@ a.bsearch_button.bsearch_button_gold:hover {
15131513
}
15141514
}
15151515

1516+
button .spinner {
1517+
float: none;
1518+
vertical-align: middle;
1519+
margin: 0 4px 0 0;
1520+
}
1521+
15161522
/* Copy to clipboard button */
15171523
.bsearch-code-wrapper {
15181524
position: relative;

includes/admin/css/better-search-admin.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,12 @@ a.bsearch_button.bsearch_button_gold:hover {
15031503
}
15041504
}
15051505

1506+
button .spinner {
1507+
float: none;
1508+
vertical-align: middle;
1509+
margin: 0 0 0 4px;
1510+
}
1511+
15061512
/* Copy to clipboard button */
15071513
.bsearch-code-wrapper {
15081514
position: relative;

includes/admin/css/better-search-admin.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)