$data ) { $slug = dirname( $file ); if ( '.' === $slug ) { $slug = basename( $file, '.php' ); } if ( 'robotstxt-manager' === $slug ) { return is_plugin_active( $file ); } } return false; } /** * Enqueue the inline dismissal script on the plugins list screen. * * @return void */ public function enqueue_scripts() { if ( ! $this->should_show_notice() ) { return; } wp_enqueue_script( 'common' ); $script = '(function () { document.addEventListener( \'click\', function ( event ) { var notice = document.getElementById( \'robotstxt-telemetry-manager-notice\' ); if ( ! notice || ! event.target.closest( \'#robotstxt-telemetry-manager-notice .notice-dismiss\' ) ) { return; } var data = new FormData(); data.append( \'action\', \'robotstxt_telemetry_dismiss_manager_notice\' ); data.append( \'nonce\', \'' . esc_js( wp_create_nonce( 'robotstxt_telemetry_manager_notice' ) ) . '\' ); fetch( window.ajaxurl, { method: \'POST\', credentials: \'same-origin\', body: data } ); } ); })();'; if ( function_exists( 'wp_add_inline_script' ) ) { wp_add_inline_script( 'common', $script, 'after' ); return; } // WordPress 4.0 - 4.4 fallback. echo ''; // phpcs:ignore WordPress.Security.EscapeOutput -- Static script with an escaped nonce. } /** * Render the dismissible notice on the plugins list screen. * * @return void */ public function render_plugins_page_notice() { if ( ! $this->should_show_notice() ) { return; } $this->render_notice( 'notice-warning is-dismissible', 'robotstxt-telemetry-manager-notice' ); } /** * Render a permanent notice for the settings screen. * * @return void */ public function render_settings_notice() { $this->render_notice( 'notice-info', '' ); } /** * Render the Manager (by ROBOTSTXT) notice markup. * * @param string $classes Extra CSS classes. * @param string $id Optional DOM id for the notice container. * @return void */ private function render_notice( $classes, $id ) { if ( self::is_manager_active() ) { return; } printf( '
%s