Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
yscik committed Jul 22, 2024
1 parent ea40602 commit 72f6d73
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/class-wp-job-manager-usage-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function track_job_approval( $post_id, $properties = [] ) {
* @return self
*/
public static function get_instance() {
return self::get_instance_for_subclass( get_class() );
return self::get_instance_for_subclass( static::class );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Usage_Tracking_Test_Subclass extends WP_Job_Manager_Usage_Tracking_Base {
const TRACKING_ENABLED_OPTION_NAME = 'testing-usage-tracking-enabled';

public static function get_instance() {
return self::get_instance_for_subclass( get_class() );
return self::get_instance_for_subclass( static::class );
}

public function get_prefix() {
Expand Down
1 change: 1 addition & 0 deletions lib/usage-tracking/tests/test-class-usage-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class WP_Job_Manager_Usage_Tracking_Test extends WP_UnitTestCase {
private $event_counts = array();
private $track_http_request = array();
private $usage_tracking;

public function setUp(): void {
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'includes/admin/class-wp-job-manager-cpt.php';

class WP_Test_WP_Job_Manager_CPT extends WPJM_BaseTest {
protected WP_Job_Manager_CPT $job_manager_cpt;

public function setUp(): void {
parent::setUp();

Expand Down
9 changes: 5 additions & 4 deletions wp-job-manager-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,18 @@ function job_manager_construct_secondary_conditions( $search_term, $is_excluding
// Only selected meta keys.
if ( $searchable_meta_keys ) {
$meta_keys = implode( "','", array_map( 'esc_sql', $searchable_meta_keys ) );
//phpcs:disabled WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ( '${meta_keys}' ) AND meta_value LIKE %s )", $meta_value );
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ( '{$meta_keys}' ) AND meta_value LIKE %s )", $meta_value );
} else {
// No meta keys defined, search all post meta value.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE %s )", $meta_value );
//phpcs:enabled WordPress.DB.PreparedSQL.InterpolatedNotPrepared
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
}

// Search taxonomy.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID ${not_string}IN ( SELECT object_id FROM {$wpdb->term_relationships} AS tr LEFT JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE t.name LIKE %s )", $meta_value );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT object_id FROM {$wpdb->term_relationships} AS tr LEFT JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE t.name LIKE %s )", $meta_value );

return $conditions;
}
Expand Down

0 comments on commit 72f6d73

Please sign in to comment.