register(); ( new GettingStarted() )->register(); } public function menu(): void { add_menu_page( __( 'Receipts', 'action-receipts' ), __( 'Receipts', 'action-receipts' ), Installer::CAP, self::PAGE, array( $this, 'render_page' ), 'dashicons-tickets-alt', 26 ); add_submenu_page( self::PAGE, __( 'All receipts', 'action-receipts' ), __( 'All receipts', 'action-receipts' ), Installer::CAP, self::PAGE, array( $this, 'render_page' ) ); } public function assets( $hook ): void { if ( false === strpos( (string) $hook, self::PAGE ) ) { return; } wp_enqueue_style( 'actr-admin', ACTR_URL . 'assets/css/admin.css', array(), ACTR_VERSION ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only tab check. $tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : ''; if ( false !== strpos( (string) $hook, SettingsPage::PAGE ) && StatusesTab::TAB === $tab ) { wp_enqueue_script( 'actr-admin-statuses', ACTR_URL . 'assets/js/admin-statuses.js', array(), ACTR_VERSION, true ); } } public function action_links( $links ) { $links[] = '' . esc_html__( 'Settings', 'action-receipts' ) . ''; return $links; } /** * Adds a "Donate" link to the plugin's row on the Plugins screen (next to "View details"). * Only there: the plugin never asks for donations anywhere else in wp-admin. * * @param string[] $links Row meta links. * @param string $file Plugin basename of the row. */ public function row_meta( $links, $file ) { if ( plugin_basename( ACTR_FILE ) === $file ) { $links[] = '' . esc_html__( 'Donate', 'action-receipts' ) . ''; } return $links; } public function render_page(): void { if ( ! current_user_can( Installer::CAP ) ) { wp_die( esc_html__( 'You do not have permission to view receipts.', 'action-receipts' ) ); } // phpcs:ignore WordPress.Security.NonceVerification.Recommended $id = isset( $_GET['receipt'] ) ? absint( $_GET['receipt'] ) : 0; if ( $id ) { $this->render_single( $id ); return; } $table = new ReceiptsListTable(); $table->prepare_items(); echo '
' . esc_html__( 'Install and activate Contact Form 7 or WPForms to start creating receipts.', 'action-receipts' ) . '