process_export(); } else { if ( is_admin() ) { //Admin notice to mention about permissions required for exporting add_action( 'admin_notices', array( $this, 'export_lack_of_permission_admin_notice' ) ); } else { wp_redirect( wp_login_url() ); } } } else { return; } } /** * Admin notice to show if the user does not have access to export * * @since 1.1.0 */ public function export_lack_of_permission_admin_notice() { echo '

' . __( 'By default, admin are given access to export WPForm entries. ', 'ank-wpforms-entry' ) . '

'; } /** * Add per-page screen option to the Forms table. * * @since 1.0.0 */ public function screen_options() { $screen = get_current_screen(); if ( null === $screen || 'wpforms_page_ank-wpforms-entries' !== $screen->id ) { return; } add_screen_option( 'per_page', array( 'label' => esc_html__( 'Number of entries per page:', 'ank-wpforms-entry' ), 'option' => 'ank_entries_per_page', 'default' => apply_filters( 'ank_entries_per_page', 20 ), ) ); } /** * Form table per-page screen option value. * * @param bool $keep Whether to save or skip saving the screen option value. Default false. * @param string $option The option name. * @param int $value The number of rows to use. * * @return mixed * @since 1.0.0 * */ public function screen_options_set( $keep, $option, $value ) { if ( 'ank_entries_per_page' === $option ) { return $value; } return $keep; } /** * Enqueue assets for the entries page. * * @since 1.0.0 */ public function enqueues() { // Hook for addons. do_action( 'ank_wpforms_entries_enqueue' ); } /** * Builds the output for the entries page. * * @since 1.0.0 */ public function output() { ?>

default_form_title ) { esc_html_e( " for " . $entries_table->default_form_title ); } ?>

fields ) { $entries_table->prepare_items(); } ?>
views(); ?> display(); ?>

%1$s

', sprintf( _n( '%s entry was successfully deleted.', '%s entries were successfully deleted.', $deleted, 'ank-wpforms-entry' ), $deleted ) ); } if ( 'error' === $deleted ) { printf( '

%1$s

', sprintf( "Error in deleting entries, please open a support ticket", 'ank-wpforms-entry' ) ); } } /** * Process the bulk table actions. * * @since 1.2.0 */ public function process_bulk_actions() { $ids = isset( $_GET['entry_id'] ) ? array_map( 'absint', (array) $_GET['entry_id'] ) : array(); // phpcs:ignore WordPress.Security.NonceVerification $action = false; if ( isset( $_REQUEST['action'] ) && - 1 != $_REQUEST['action'] ) { $action = sanitize_key( $_REQUEST['action'] ); } elseif ( isset( $_REQUEST['action2'] ) && - 1 != $_REQUEST['action2'] ) { $action = sanitize_key( $_REQUEST['action2'] ); } // Checking the sortable column link. $is_orderby_link = ! empty( $_REQUEST['orderby'] ) && ! empty( $_REQUEST['order'] ); if ( empty( $ids ) || empty( $action ) || $is_orderby_link ) { return; } // Check exact action values. if ( ! in_array( $action, [ 'delete' ], true ) ) { return; } if ( empty( $_GET['_wpnonce'] ) ) { return; } // Check the nonce. (plural is set as entries) check_admin_referer( 'bulk-entries' ); // Check that we have a method for this action. if ( ! method_exists( $this, 'bulk_action_' . $action . '_entries' ) ) { return; } $processed_forms = count( $this->{'bulk_action_' . $action . '_entries'}( $ids ) ); // Unset get vars and perform redirect to avoid action reuse. wp_safe_redirect( add_query_arg( $action . 'd', $processed_forms, remove_query_arg( array( 'action', 'action2', '_wpnonce', 'form_id', 'paged', '_wp_http_referer' ) ) ) ); exit; } /** * Delete entries. * * @param array $ids entries ids to delete. * * @return array List of deleted entries. * @since 1.2.0 * */ private function bulk_action_delete_entries( $ids ) { if ( ! is_array( $ids ) ) { return []; } $deleted = []; foreach ( $ids as $id ) { $deleted[ $id ] = ank_wpforms_entry()->get_class_instance( 'entry-db' )->delete( $id ); } return array_keys( array_filter( $deleted ) ); } }