| 1 |
<?php |
| 2 |
class Meow_CDEGN_Admin { |
| 3 |
|
| 4 |
public $core; |
| 5 |
|
| 6 |
/** @var Meow_CDEGN_List_Table */ |
| 7 |
public $list_table; |
| 8 |
|
| 9 |
protected $menu_slug = 'cdegn_settings'; |
| 10 |
|
| 11 |
public function __construct( $core ) { |
| 12 |
$this->core = $core; |
| 13 |
|
| 14 |
if ( is_admin() ) { |
| 15 |
add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| 16 |
add_filter( 'plugin_action_links_' . plugin_basename( CDEGN_ENTRY ), array( $this, 'plugin_action_links' ), 10, 2 ); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
public function app_menu() { |
| 21 |
// Needs to initialize the list before admin-header.php called. |
| 22 |
$this->list_table = new Meow_CDEGN_List_Table( $this->core ); |
| 23 |
|
| 24 |
add_submenu_page( 'options-general.php', 'Code Engine', 'Code Engine', 'manage_options', |
| 25 |
$this->menu_slug, array( $this, 'admin_settings' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
public function admin_settings() { |
| 29 |
$this->list_table->prepare_items(); |
| 30 |
include_once 'views/settings.php'; |
| 31 |
} |
| 32 |
|
| 33 |
public function plugin_action_links( array $actions, string $plugin_file ): array { |
| 34 |
if ( plugin_basename( CDEGN_ENTRY ) !== $plugin_file ) { |
| 35 |
return $actions; |
| 36 |
} |
| 37 |
|
| 38 |
return array_merge( |
| 39 |
[ |
| 40 |
sprintf( |
| 41 |
'<a href="%s">%s</a>', |
| 42 |
esc_url( add_query_arg( 'page', $this->menu_slug, admin_url( 'options-general.php' ) ) ), |
| 43 |
esc_html__( 'Settings', 'code-engine' ) |
| 44 |
), |
| 45 |
], |
| 46 |
$actions, |
| 47 |
); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
?> |
| 52 |
|