'unread' ) ); $bubble = $unread ? ' ' . number_format_i18n( $unread ) . '' : ''; self::$entries_hook = add_menu_page( __( 'ALPEG Forms', 'alpeg-forms' ), __( 'ALPEG Forms', 'alpeg-forms' ) . $bubble, 'manage_options', 'alpeg-forms', array( __CLASS__, 'render_entries' ), 'dashicons-feedback', 26 ); add_submenu_page( 'alpeg-forms', __( 'Submissions', 'alpeg-forms' ), __( 'Submissions', 'alpeg-forms' ), 'manage_options', 'alpeg-forms', array( __CLASS__, 'render_entries' ) ); add_submenu_page( 'alpeg-forms', __( 'Settings', 'alpeg-forms' ), __( 'Settings', 'alpeg-forms' ), 'manage_options', 'alpeg-forms-settings', array( Settings::class, 'render' ) ); // Import & export: forms from other plugins, old submissions, template files. add_submenu_page( 'alpeg-forms', __( 'Import & export', 'alpeg-forms' ), __( 'Import & export', 'alpeg-forms' ), 'manage_options', 'alpeg-forms-import', array( Importer::class, 'render' ) ); // The license page only appears once a license module (Pro add-on) is installed. if ( License::has_module() ) { add_submenu_page( 'alpeg-forms', __( 'License', 'alpeg-forms' ), __( 'License', 'alpeg-forms' ), 'manage_options', 'alpeg-forms-license', array( License::class, 'render_page' ) ); } add_action( 'load-' . self::$entries_hook, array( __CLASS__, 'load_entries' ) ); } /** * Load CSS only on our own pages. * * @param string $hook Hook suffix. */ public static function assets( $hook ) { if ( false === strpos( $hook, 'alpeg-forms' ) ) { return; } wp_enqueue_style( 'alpeg-forms-admin', ALPEG_FORMS_URL . 'assets/css/admin.css', array(), ALPEG_FORMS_VERSION ); } /** * Before output: handle bulk actions and screen options. */ public static function load_entries() { if ( ! current_user_can( 'manage_options' ) ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read only. if ( ! empty( $_GET['view'] ) ) { // A bookmarked detail URL remains read-only unless its action nonce is supplied. if ( isset( $_GET['_wpnonce'] ) ) { $id = absint( $_GET['view'] ); check_admin_referer( 'alpeg_forms_read_' . $id ); Entries::set_status( array( $id ), 'read' ); } return; } add_screen_option( 'per_page', array( 'label' => __( 'Submissions per page', 'alpeg-forms' ), 'default' => 20, 'option' => 'alpeg_forms_per_page', ) ); add_filter( 'set_screen_option_alpeg_forms_per_page', static function ( $status, $option, $value ) { return max( 1, min( 200, (int) $value ) ); }, 10, 3 ); Entries_Table::process_bulk_action(); } /** * Submissions: list or detail view. */ public static function render_entries() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read only. $view = isset( $_GET['view'] ) ? absint( $_GET['view'] ) : 0; if ( $view ) { self::render_entry( $view ); return; } $table = new Entries_Table(); $table->prepare_items(); $total = Entries::count(); $failures = Mail_Diagnostics::recent_failures(); ?>
'; if ( ! $entry ) { echo '← ' . esc_html__( 'Back to overview', 'alpeg-forms' ) . '
'; return; } $reply = $entry->email ? 'mailto:' . rawurlencode( $entry->email ) . '?subject=' . rawurlencode( 'Re: ' . $entry->form_title ) : ''; $del = wp_nonce_url( admin_url( 'admin-post.php?action=alpeg_forms_entry&do=delete&id=' . $entry->id ), 'alpeg_forms_entry_' . $entry->id ); $unr = wp_nonce_url( admin_url( 'admin-post.php?action=alpeg_forms_entry&do=unread&id=' . $entry->id ), 'alpeg_forms_entry_' . $entry->id ); ?>|
';
foreach ( $row['files'] as $i => $file ) {
$exists = (bool) Files::absolute_path( $file['path'] );
echo ' |
' . esc_html( sprintf( $messages[ $done ], $n ) ) . '
' . esc_html__( 'Do you have a question or a request? Just write to us – we will get back to you as soon as possible.', 'alpeg-forms' ) . '
' . "\n\n" . ''; } return $content; } /** * Title of the starter page. * * @param string $title Title. * @param \WP_Post $post Post. * @return string */ public static function starter_title( $title, $post ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! empty( $_GET['alpeg_forms_starter'] ) && 'page' === $post->post_type ) { return __( 'Contact', 'alpeg-forms' ); } return $title; } /** * Links in the plugin list. * * @param array $links Links. * @return array */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Submissions', 'alpeg-forms' ) . '', '' . esc_html__( 'Settings', 'alpeg-forms' ) . '' ); return $links; } }