items = $items; $this->index = $index; } /** * Registers hooks. * * @return void */ public function register(): void { add_action( 'after_plugin_row_' . plugin_basename( YANGRA_CONDITIONAL_FILE ), array( $this, 'render' ), 10, 0 ); } /** * The warning, or '' when it doesn't apply. * * @return string */ public function text(): string { if ( is_network_admin() || ! current_user_can( 'activate_plugins' ) ) { return ''; } $sentences = array(); $count = count( $this->items->all() ); if ( $count > 0 ) { $sentences[] = sprintf( /* translators: %d: number of menu items. */ _n( '%d menu item has a visibility rule. If you deactivate Yangra Conditional, every menu item is shown to every visitor, including items your rules hide, such as Log in or Register links hidden from logged-in users.', '%d menu items have visibility rules. If you deactivate Yangra Conditional, every menu item is shown to every visitor, including items your rules hide, such as Log in or Register links hidden from logged-in users.', $count, 'yangra-conditional' ), $count ); } $posts = 0; foreach ( $this->index->live_posts() as $index ) { if ( (int) ( $index['shortcodes'] ?? 0 ) > 0 ) { ++$posts; } } if ( $posts > 0 ) { $sentences[] = sprintf( /* translators: %d: number of posts. */ _n( '%d post uses the conditional shortcode. If you deactivate Yangra Conditional, the shortcode shows as plain text, with both its content and its "else" content.', '%d posts use the conditional shortcode. If you deactivate Yangra Conditional, the shortcode shows as plain text, with both its content and its "else" content.', $posts, 'yangra-conditional' ), $posts ); } return implode( ' ', $sentences ); } /** * Prints the warning row, styled like WordPress's own update rows. * * @return void */ public function render(): void { $text = $this->text(); if ( '' === $text ) { return; } // The Plugins screen's list table; its column count, like the update rows use. global $wp_list_table; $columns = $wp_list_table instanceof \WP_List_Table ? $wp_list_table->get_column_count() : 4; printf( '
%2$s