PluginProbe
Parse.ly / 3.2.1
Parse.ly v3.2.1
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / UI / class-admin-warning.php

class-admin-warning.php in Parse.ly 3.2.1, at src/UI/class-admin-warning.php

83 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Parsely wp-admin warning
4 *
5 * @package Parsely
6 * @since 3.0.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\UI;
12
13 use Parsely\Parsely;
14
15 /**
16 * Conditionally render a warning message on wp-admin
17 *
18 * @since 3.0.0
19 */
20 final class Admin_Warning {
21 /**
22 * Instance of Parsely class.
23 *
24 * @var Parsely
25 */
26 private $parsely;
27
28 /**
29 * Constructor.
30 *
31 * @param Parsely $parsely Instance of Parsely class.
32 */
33 public function __construct( Parsely $parsely ) {
34 $this->parsely = $parsely;
35 }
36
37 /**
38 * Register admin warning.
39 *
40 * @since 3.0.0
41 *
42 * @return void
43 */
44 public function run(): void {
45 add_action( 'admin_notices', array( $this, 'display_admin_warning' ) );
46 }
47
48 /**
49 * Display the admin warning if needed.
50 *
51 * @return void
52 */
53 public function display_admin_warning(): void {
54 if ( ! $this->should_display_admin_warning() ) {
55 return;
56 }
57
58 $message = sprintf(
59 /* translators: %s: Plugin settings page URL */
60 __( '<strong>The Parse.ly plugin is not active.</strong> You need to <a href="%s">provide your Parse.ly Dash Site ID</a> before things get cooking.', 'wp-parsely' ),
61 esc_url( Parsely::get_settings_url() )
62 );
63 ?>
64 <div id="wp-parsely-apikey-error-notice" class="notice notice-error"><p><?php echo wp_kses_post( $message ); ?></p></div>
65 <?php
66 }
67
68 /**
69 * Decide whether the admin display warning should be displayed
70 *
71 * @since 2.6.0
72 *
73 * @return bool True if the admin warning should be displayed
74 */
75 private function should_display_admin_warning(): bool {
76 if ( is_network_admin() ) {
77 return false;
78 }
79
80 return $this->parsely->api_key_is_missing();
81 }
82 }
83