| 1 |
<?php |
| 2 |
/** |
| 3 |
* Manages the display of Breadcrumbs. |
| 4 |
* |
| 5 |
* @package WP_Defender\Component |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WP_Defender\Component; |
| 9 |
|
| 10 |
use WP_Defender\Component; |
| 11 |
|
| 12 |
/** |
| 13 |
* Use Breadcrumbs on different plugin pages. |
| 14 |
* |
| 15 |
* @since 5.2.0 |
| 16 |
*/ |
| 17 |
class Breadcrumbs extends Component { |
| 18 |
|
| 19 |
/** |
| 20 |
* Get the feature's slug. |
| 21 |
* |
| 22 |
* @return string |
| 23 |
*/ |
| 24 |
private function get_feature_slug(): string { |
| 25 |
return 'wd_' . \WP_Defender\Model\Setting\Session_Protection::get_module_slug() . '_breadcrumbs'; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Update the feature's meta key. |
| 30 |
* |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
public function update_meta_key(): void { |
| 34 |
update_user_meta( get_current_user_id(), $this->get_feature_slug(), 1 ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Get the feature's meta key. |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public function get_meta_key(): bool { |
| 43 |
return (bool) get_user_meta( get_current_user_id(), $this->get_feature_slug(), true ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Delete the feature's meta key. |
| 48 |
* |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
public function delete_meta_key(): void { |
| 52 |
global $wpdb; |
| 53 |
|
| 54 |
$wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $this->get_feature_slug() ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.SlowDBQuery |
| 55 |
} |
| 56 |
} |
| 57 |
|