ReadOnly.php
28 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Admin\Notice; |
| 4 | |
| 5 | use AC\ListScreen; |
| 6 | use AC\Message; |
| 7 | use AC\Registrable; |
| 8 | |
| 9 | class ReadOnly implements Registrable { |
| 10 | |
| 11 | public function register() { |
| 12 | add_action( 'ac/settings/notice', [ $this, 'render_notice' ] ); |
| 13 | |
| 14 | } |
| 15 | |
| 16 | public function render_notice( ListScreen $list_screen ) { |
| 17 | if ( $list_screen->is_read_only() ) { |
| 18 | $message = sprintf( __( 'The columns for %s are read only and can therefore not be edited.', 'codepress-admin-columns' ), '<strong>' . esc_html( $list_screen->get_title() ?: $list_screen->get_label() ) . '</strong>' ); |
| 19 | $message = sprintf( '<p>%s</p>', apply_filters( 'ac/read_only_message', $message, $list_screen ) ); |
| 20 | |
| 21 | $notice = new Message\InlineMessage( $message ); |
| 22 | |
| 23 | echo $notice->set_type( Message::INFO ) |
| 24 | ->render(); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | } |