PluginProbe
Parse.ly / 3.4.2
Parse.ly v3.4.2
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.4.2, at src/UI/class-admin-warning.php

79 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 * UI: Parse.ly wp-admin warning class
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 renders 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 * Registers admin warning.
39 *
40 * @since 3.0.0
41 */
42 public function run(): void {
43 add_action( 'admin_notices', array( $this, 'display_admin_warning' ) );
44 }
45
46 /**
47 * Displays the admin warning if needed.
48 */
49 public function display_admin_warning(): void {
50 if ( ! $this->should_display_admin_warning() ) {
51 return;
52 }
53
54 $message = sprintf(
55 /* translators: %s: Plugin settings page URL */
56 __( '<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' ),
57 esc_url( Parsely::get_settings_url() )
58 );
59 ?>
60 <div id="wp-parsely-apikey-error-notice" class="notice notice-error"><p><?php echo wp_kses_post( $message ); ?></p></div>
61 <?php
62 }
63
64 /**
65 * Returns whether the admin display warning should be displayed.
66 *
67 * @since 2.6.0
68 *
69 * @return bool True if the admin warning should be displayed.
70 */
71 private function should_display_admin_warning(): bool {
72 if ( is_network_admin() ) {
73 return false;
74 }
75
76 return $this->parsely->api_key_is_missing();
77 }
78 }
79