%1$d', (int) $pending ) : '';
add_menu_page(
__( 'PAYGRAB', 'paygrab' ),
__( 'PAYGRAB', 'paygrab' ) . $badge,
'manage_options',
self::SLUG,
array( 'Paygrab_Admin_Dashboard', 'render' ),
'dashicons-download',
56
);
add_submenu_page( self::SLUG, __( 'PAYGRAB dashboard', 'paygrab' ), __( 'Dashboard', 'paygrab' ), 'manage_options', self::SLUG, array( 'Paygrab_Admin_Dashboard', 'render' ) );
add_submenu_page( self::SLUG, __( 'Orders', 'paygrab' ), __( 'Orders', 'paygrab' ) . $badge, 'manage_options', self::ORDERS, array( 'Paygrab_Admin_Orders', 'render' ) );
// "Products" and "Add new product" are added by Paygrab_Admin_Products at priority 10,
// "Settings" by Paygrab_Settings_Page at priority 20.
}
/**
* Links made before the orders screen moved (admin.php?page=paygrab&order=…, e.g. in
* emails already sent) still open the order.
*
* @return void
*/
public static function redirect_old_order_links() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended -- navigation only.
if ( ! isset( $_GET['order'] ) && ! isset( $_GET['status'] ) && ! isset( $_GET['s'] ) ) {
return;
}
$args = array();
foreach ( array( 'order', 'status', 's', 'paged', 'user', 'paygrab_done', 'n', 'f' ) as $key ) {
if ( isset( $_GET[ $key ] ) ) {
$args[ $key ] = sanitize_text_field( wp_unslash( $_GET[ $key ] ) );
}
}
// phpcs:enable
wp_safe_redirect( add_query_arg( $args, admin_url( 'admin.php?page=' . self::ORDERS ) ) );
exit;
}
/**
* Admin styles for PAYGRAB screens.
*
* @param string $hook Screen hook.
* @return void
*/
public static function assets( $hook ) {
$screen = get_current_screen();
$ours = str_contains( (string) $hook, self::SLUG ) || ( $screen && Paygrab_Product::TYPE === $screen->post_type );
if ( ! $ours ) {
return;
}
wp_enqueue_style( 'paygrab-admin', PAYGRAB_URL . 'assets/css/admin.css', array(), PAYGRAB_VERSION );
}
/**
* "Settings" link on the plugins screen.
*
* @param array $links Links.
* @return array
*/
public static function action_links( $links ) {
array_unshift( $links, '' . esc_html__( 'Settings', 'paygrab' ) . '' );
return $links;
}
}