Lesson 25 — Adding Pagination to the Auctions Table Using WP_List_Table

By Lesson 24, our Flipnzee Auctions plugin already supports:

  • Creating auctions
  • Viewing all auctions
  • Editing auctions
  • Deleting auctions
  • Displaying professional success/error notices

However, there is still one major limitation.

If your marketplace eventually contains hundreds or even thousands of auctions, displaying every auction on a single page becomes slow and difficult to use.

WordPress solves this problem with pagination, and since we’re already using WP_List_Table, adding it is surprisingly straightforward.

In this lesson, we’ll make our Auctions page production-ready by adding pagination.


Why Pagination Matters

Imagine your marketplace has:

  • 500 active auctions
  • 2,000 completed auctions
  • 15,000 historical auctions

Loading every record at once would:

  • increase page load time
  • consume unnecessary memory
  • make scrolling frustrating
  • reduce the overall admin experience

Instead, WordPress displays only a limited number of records per page.

Example:

Showing 20 auctions per page

Page 1
Page 2
Page 3
...
Page 150

This is how professional WordPress plugins behave.


How WP_List_Table Supports Pagination

The class already provides pagination support.

We only need to tell WordPress:

  • how many total items exist
  • how many items to display per page
  • which page the user is currently viewing

WordPress automatically creates:

  • Previous button
  • Next button
  • Page numbers
  • Current page indicator

Current Problem

Our current prepare_items() method probably looks similar to this:

$this->items = Flipnzee_Auction_Manager::get_all_auctions();

This loads every auction.

Instead, we should only load the current page.


Step 1 — Count Total Auctions

First, determine how many auctions exist.

Example:

$total_items =
	Flipnzee_Auction_Manager::count_auctions();

Step 2 — Decide Items Per Page

Choose how many auctions should appear on each page.

Example:

$per_page = 20;

Twenty items per page is a common default in WordPress.


Step 3 — Determine the Current Page

WordPress passes the current page automatically.

Example:

$current_page = $this->get_pagenum();

If the user clicks Page 4,

$current_page = 4

Step 4 — Calculate Database Offset

SQL needs to know where to begin.

Formula:

Offset =
(Current Page − 1)
×
Items Per Page

Example:

Page 1

Offset = 0

Page 2

Offset = 20

Page 3

Offset = 40

Only the required rows are retrieved.


Step 5 — Retrieve Only the Required Auctions

Instead of fetching everything:

SELECT *
FROM auctions

retrieve only the current page.

Example SQL:

SELECT *
FROM auctions
LIMIT 20 OFFSET 40

This loads only the records needed for the current page.


Step 6 — Configure Pagination

Finally, tell WP_List_Table how many pages exist.

Example:

$this->set_pagination_args(
	array(
		'total_items' => $total_items,
		'per_page'    => $per_page,
	)
);

WordPress calculates the number of pages automatically.


The Result

Instead of one endlessly long table:

Auction 1
Auction 2
Auction 3
...
Auction 2000

your users will see:

Auction 1
Auction 2
...
Auction 20

← Previous

1 2 3 4 5

Next →

This provides a cleaner and faster administration experience.


Why This Matters

Pagination is not just about convenience.

It also:

  • Improves performance
  • Reduces memory usage
  • Speeds up database queries
  • Makes large datasets manageable
  • Follows WordPress admin standards
  • Prepares your plugin for production use

What You’ll Learn Next

In Lesson 26, we’ll add sortable columns to the Auctions table so administrators can sort auctions by:

  • Auction ID
  • Listing ID
  • Start Price
  • Buy Now Price
  • Status
  • Creation Date

Sorting and pagination together make your auction management screen feel like a professional WordPress plugin rather than a basic prototype.

Lesson 25 Implementation Guide — Adding Pagination to the Auctions Table

Lesson 24 – Displaying Professional Admin Success and Error Notices in Your WordPress Plugin

In the previous lesson, we successfully implemented the ability to delete auctions from the Flipnzee Auctions plugin. The feature works correctly, but from a user’s perspective there is one thing missing—feedback.

Imagine clicking Delete and returning to the auction list with no indication whether the deletion actually succeeded. Users may wonder whether the auction was removed or if something went wrong.

In this lesson, we’ll improve the user experience by displaying professional WordPress admin notices after important actions such as creating, updating, and deleting auctions.


Why Admin Notices Matter

WordPress itself uses admin notices throughout the dashboard.

For example:

  • Post published.
  • Settings saved.
  • Plugin activated.
  • Theme installed.

Users have become accustomed to seeing these messages. Your plugin should follow the same design pattern.


What We’ll Build

By the end of this lesson, the plugin will display messages such as:

  • Auction created successfully.
  • Auction updated successfully.
  • Auction deleted successfully.
  • Unable to delete auction.
  • Unable to update auction.

Each message will use the standard WordPress notice styles.


Passing Messages Between Pages

After an action is completed, the user is redirected back to an admin page.

For example:

wp_safe_redirect(
	admin_url(
		'admin.php?page=flipnzee-all-auctions&message=deleted'
	)
);

Notice the query parameter:

message=deleted

This allows the next page to know what happened.


Reading the Message

Inside the destination page we retrieve the message safely.

$message = isset( $_GET['message'] )
	? sanitize_text_field(
		wp_unslash( $_GET['message'] )
	)
	: '';

This ensures that only sanitized input is used.


Displaying a Success Notice

If the message equals deleted, we display a success notice.

if ( 'deleted' === $message ) :
?>

<div class="notice notice-success is-dismissible">
	<p>Auction deleted successfully.</p>
</div>

<?php endif; ?>

The classes are provided by WordPress.

  • notice
  • notice-success
  • is-dismissible

No custom CSS is required.


Displaying an Error Notice

If something goes wrong, we display an error.

<?php if ( 'error' === $message ) : ?>

<div class="notice notice-error is-dismissible">
	<p>Unable to delete auction.</p>
</div>

<?php endif; ?>

WordPress automatically styles it using the familiar red error notice.


Why Redirect Instead of Printing Messages?

Suppose we deleted the record and immediately echoed:

Auction deleted.

The user would remain on the processing page.

Instead, WordPress plugins usually:

  1. Perform the action.
  2. Redirect.
  3. Display a message.

This pattern avoids duplicate submissions when the browser is refreshed.


Benefits of This Approach

Our plugin now provides:

  • Clear feedback to administrators.
  • Consistent WordPress user experience.
  • Cleaner navigation.
  • Better security through redirects.
  • Professional appearance.

Best Practices Learned

Throughout this lesson we reinforced several WordPress development practices:

  • Use wp_safe_redirect() after processing forms.
  • Pass status information using query parameters.
  • Sanitize all incoming data.
  • Use WordPress admin notice classes.
  • Keep users informed after every important action.

What We’ve Achieved So Far

At this point, the Flipnzee Auctions plugin supports:

  • Plugin activation
  • Database creation
  • Admin dashboard
  • Add Auction
  • View Auctions
  • Edit Auction
  • Delete Auction
  • Admin notices
  • Secure nonces
  • CRUD operations

The plugin is beginning to feel like a real production-ready WordPress application rather than a simple demonstration project.


Coming Up Next

In Lesson 25, we’ll make the auction management screen even more powerful by adding Bulk Actions, allowing administrators to delete multiple auctions at once, just like the built-in WordPress Posts and Pages screens.

Lesson 23: Adding Secure Auction Deletion to Your WordPress Plugin


Deleting data is one of the most sensitive operations in any application. A single mistake can accidentally remove valuable records or create a serious security vulnerability.

In this lesson, we’ll build a secure Delete Auction feature for the Flipnzee Auctions plugin using WordPress best practices.

Why a Delete Feature Matters

As administrators manage auctions over time, some records become unnecessary:

  • Test auctions
  • Duplicate auctions
  • Expired drafts
  • Incorrect listings

Instead of manually deleting records from phpMyAdmin, administrators should be able to remove auctions directly from the WordPress dashboard.


Step 1 — Add a Delete Link

Inside our custom WP_List_Table, we added a new row action.

'delete' => sprintf(
    '<a href="%s" onclick="return confirm(\'Are you sure you want to delete this auction?\');">Delete</a>',
    wp_nonce_url(
        admin_url(
            'admin-post.php?action=flipnzee_delete_auction&auction_id=' . absint( $item->id )
        ),
        'flipnzee_delete_auction'
    )
),

This generates a secure URL for every auction.


Step 2 — Protect the Request with a Nonce

Deleting records should never rely only on an auction ID.

Instead, WordPress adds a nonce to the URL.

A nonce helps verify that:

  • the request originated from your website
  • the current administrator intentionally clicked Delete
  • attackers cannot easily forge deletion requests

Step 3 — Display a Confirmation Dialog

Before the browser follows the Delete link, JavaScript displays:

Are you sure you want to delete this auction?

This gives administrators one final chance to cancel.

It is a simple but important safeguard.


Step 4 — Register the Delete Action

WordPress routes admin form submissions and custom actions through the admin_post hook.

We registered:

add_action(
    'admin_post_flipnzee_delete_auction',
    array( $this, 'handle_delete_auction' )
);

Now WordPress knows exactly which method should process the deletion request.


Step 5 — Verify the Nonce

Inside our handler we verify the request.

check_admin_referer(
    'flipnzee_delete_auction'
);

If the nonce is invalid, WordPress immediately stops execution.

This protects the plugin from Cross-Site Request Forgery (CSRF) attacks.


Step 6 — Delete the Database Record

The Auction Manager performs the actual deletion.

Flipnzee_Auction_Manager::delete_auction(
    $auction_id
);

Keeping database operations inside the manager class keeps the code organized and easier to maintain.


Step 7 — Redirect Back

After deletion, the administrator is redirected back to the auction list.

wp_safe_redirect(
    admin_url(
        'admin.php?page=flipnzee-all-auctions'
    )
);

This prevents accidental duplicate requests if the page is refreshed.


What We Learned

In this lesson we learned how to:

  • Add custom row actions to WP_List_Table
  • Generate secure admin URLs
  • Protect delete operations using WordPress nonces
  • Display JavaScript confirmation dialogs
  • Handle custom admin_post actions
  • Remove database records safely
  • Redirect users after completing an action

Why This Matters

Delete functionality may seem simple, but implementing it securely is an important milestone in WordPress plugin development.

By following WordPress coding standards—using nonces, confirmation dialogs, dedicated manager classes, and proper redirects—you create a plugin that is both user-friendly and resistant to common security risks.

In the next lesson, we’ll continue enhancing the Flipnzee Auctions plugin by adding more professional management features to make auction administration even more powerful.

Lesson 22: Deleting Auctions Securely with Confirmation in WordPress

In the previous lessons, we successfully built the ability to create, view, and edit auctions from the WordPress admin panel. The final piece of the basic CRUD (Create, Read, Update, Delete) functionality is allowing administrators to safely delete auctions.

Deleting records is a destructive operation, so it must be implemented carefully. A poorly designed delete feature could allow accidental deletions or even expose your plugin to security vulnerabilities. In this lesson, we’ll build a secure delete system using WordPress best practices.


Why Deleting Requires Special Attention

Unlike creating or editing records, deleting permanently removes data from the database. This means we should always:

  • Verify the user’s permissions.
  • Protect against CSRF attacks using WordPress nonces.
  • Ask the administrator for confirmation.
  • Delete only the intended auction.
  • Redirect back with a success or error message.

Fortunately, WordPress provides built-in tools that make implementing secure deletion straightforward.


What We’ll Build

By the end of this lesson, every auction listed in the All Auctions page will include a Delete link.

The workflow will look like this:

  1. Administrator clicks Delete.
  2. A confirmation dialog appears.
  3. Clicking Cancel stops the process.
  4. Clicking OK sends a secure request.
  5. The selected auction is removed from the database.
  6. The administrator is redirected back to the auction list with a success message.

Step 1 — Create a Delete Method in the Auction Manager

Inside:

includes/class-auction-manager.php

we’ll add a new method named:

delete_auction( $auction_id )

This method will use WordPress’s $wpdb->delete() function to remove a single auction based on its ID.

Keeping database operations inside the Auction Manager keeps our plugin organized and follows the same architecture we’ve used for creating and updating auctions.


Step 2 — Handle Delete Requests

Next, we’ll open:

admin/class-admin-posts.php

and register another admin action.

Instead of processing form submissions, this action will process delete requests coming from the auction list.

The handler will:

  • verify the nonce
  • validate the auction ID
  • call delete_auction()
  • redirect back to the auction list

Separating request handling from database logic keeps the code easier to maintain.


Step 3 — Add Delete Links to the Auction Table

Our WP_List_Table currently displays an Edit action for every auction.

We’ll modify the Actions column so that every row displays:

Edit | Delete

The Delete link will include:

  • auction ID
  • WordPress nonce
  • delete action

This allows WordPress to verify that the request genuinely originated from an authorized administrator.


Step 4 — Display a Confirmation Dialog

Even administrators sometimes click the wrong link.

To prevent accidental deletions, we’ll attach a simple JavaScript confirmation dialog.

When the administrator clicks Delete, WordPress will ask:

Are you sure you want to delete this auction?

Selecting Cancel aborts the request.

Selecting OK continues with the deletion.

This small addition greatly improves the user experience while reducing accidental mistakes.


Why WordPress Uses Nonces for Delete Operations

Imagine an administrator is logged into WordPress and unknowingly visits a malicious website.

Without nonce protection, that website could secretly trigger requests that delete auctions from your plugin.

A WordPress nonce ensures that delete requests originate from your own plugin and are intentionally initiated by the administrator.

Although nonces are not passwords or encryption keys, they provide an important layer of protection against Cross-Site Request Forgery (CSRF) attacks.


Expected Result

Once this lesson is complete, the All Auctions page will look similar to this:

Auction IDListingStatusActions
1222DraftEdit | Delete
255ActiveEdit | Delete
3108ClosedEdit | Delete

Clicking Delete will display a confirmation dialog before permanently removing the auction.


What You’ll Learn

By completing this lesson, you’ll understand:

  • How to delete database records using $wpdb->delete()
  • How WordPress processes admin actions
  • Why delete operations require nonces
  • How to generate secure action links
  • How to redirect after completing an operation
  • How to improve usability with confirmation dialogs

Coming Up Next

In Lesson 23, we’ll make the auction management screen much more powerful by adding search, sorting, filtering, and pagination to our custom WP_List_Table. These features become essential as the number of auctions grows, helping administrators quickly locate and manage specific records.


Conclusion

With the addition of secure deletion, our auction plugin will support the complete set of CRUD operations—Create, Read, Update, and Delete. More importantly, we’ll implement this functionality using WordPress coding standards and security best practices, laying the foundation for a robust and production-ready auction management system.

Lesson 21: Updating Auctions in the Database

In the previous lesson, we transformed our Edit Auction page into a fully editable form. Administrators can now modify auction values such as the listing ID, prices, and status.

However, clicking Save Changes currently results in a blank page because our plugin does not yet know how to process the submitted form.

In this lesson, we’ll complete the editing workflow by processing the form submission, updating the database, and redirecting the administrator back to the Edit Auction page with a success message.


Learning Objectives

By the end of this lesson you will be able to:

  • Register a new WordPress admin_post action.
  • Process an Edit Auction form securely.
  • Verify nonces before updating the database.
  • Sanitize user input.
  • Update an existing database record using $wpdb->update().
  • Redirect back to the Edit page with a success message.

Current Workflow

At the moment our workflow looks like this:

Edit Auction
      ↓
Modify Fields
      ↓
Click Save Changes
      ↓
Blank Screen

After this lesson it will become:

Edit Auction
      ↓
Modify Fields
      ↓
Click Save Changes
      ↓
Update Database
      ↓
Redirect Back
      ↓
Success Message

Step 1 – Register a New Admin Action

Open:

admin/class-admin-posts.php

Inside the constructor, add another action:

add_action(
	'admin_post_flipnzee_update_auction',
	array( $this, 'handle_update_auction' )
);

Your constructor should now contain both actions:

public function __construct() {

	add_action(
		'admin_post_flipnzee_create_auction',
		array( $this, 'handle_create_auction' )
	);

	add_action(
		'admin_post_flipnzee_update_auction',
		array( $this, 'handle_update_auction' )
	);
}

Step 2 – Create the Update Handler

Inside the same class, add:

public function handle_update_auction() {

	check_admin_referer(
		'flipnzee_update_auction',
		'flipnzee_nonce'
	);

	$auction_id = absint( $_POST['auction_id'] );

	$listing_id = absint( $_POST['listing_id'] );

	$start_price = floatval( $_POST['start_price'] );

	$reserve_price = floatval( $_POST['reserve_price'] );

	$buy_now_price = floatval( $_POST['buy_now_price'] );

	$status = sanitize_text_field(
		wp_unslash( $_POST['status'] )
	);

	$updated = Flipnzee_Auction_Manager::update_auction(
		$auction_id,
		$listing_id,
		$start_price,
		$reserve_price,
		$buy_now_price,
		$status
	);

	$message = $updated
		? 'updated'
		: 'error';

	wp_safe_redirect(

		admin_url(

			'admin.php?page=flipnzee-edit-auction&auction_id=' .
			$auction_id .
			'&message=' .
			$message
		)

	);

	exit;
}

Notice how every value is sanitized before being passed to the Auction Manager.


Step 3 – Add the Update Method

Open:

includes/class-auction-manager.php

Add the following method beneath create_auction():

public static function update_auction(
	$auction_id,
	$listing_id,
	$start_price,
	$reserve_price,
	$buy_now_price,
	$status
) {

	global $wpdb;

	$table = $wpdb->prefix . 'flipnzee_auctions';

	$result = $wpdb->update(

		$table,

		array(

			'listing_id'    => $listing_id,
			'start_price'   => $start_price,
			'reserve_price' => $reserve_price,
			'buy_now_price' => $buy_now_price,
			'status'        => $status,

		),

		array(
			'id' => $auction_id,
		),

		array(
			'%d',
			'%f',
			'%f',
			'%f',
			'%s',
		),

		array(
			'%d',
		)

	);

	return false !== $result;
}

This method updates only the selected auction.


Step 4 – Display a Success Message

Open:

admin/class-admin.php

Inside edit_auction_page(), immediately after the <h1> heading, add:

<?php

$message = isset( $_GET['message'] )
	? sanitize_text_field(
		wp_unslash( $_GET['message'] )
	)
	: '';

if ( 'updated' === $message ) :
?>

	<div class="notice notice-success is-dismissible">
		<p>Auction updated successfully.</p>
	</div>

<?php elseif ( 'error' === $message ) : ?>

	<div class="notice notice-error is-dismissible">
		<p>Unable to update auction.</p>
	</div>

<?php endif; ?>

Now the administrator receives immediate feedback after saving changes.


Step 5 – Test the Plugin

Create a fresh ZIP and upload the updated plugin.

Go to:

Flipnzee Auctions → All Auctions

Click Edit.

Change one or more values.

Click Save Changes.

You should now:

  • Return to the Edit page.
  • See a success message.
  • See the updated values displayed in the form.

Why Redirect Instead of Printing a Message?

Professional WordPress plugins generally follow the POST → Redirect → GET pattern.

Instead of displaying output immediately after processing a form, they redirect back to the appropriate page.

Benefits include:

  • Preventing duplicate form submissions.
  • Cleaner browser history.
  • Easier refresh behaviour.
  • Better user experience.

Lesson Summary

In this lesson we completed the Edit Auction workflow.

The plugin now processes form submissions securely, validates the nonce, sanitizes user input, updates the database, and redirects the administrator back to the Edit Auction page with an appropriate success or error message.

This represents another major milestone because the plugin now supports both creating and updating auction records.


Key Takeaways

  • Register a dedicated admin_post action for each form.
  • Always verify nonces before processing requests.
  • Sanitize every submitted value.
  • Use $wpdb->update() to modify existing database rows.
  • Redirect after processing forms.

Common Mistakes

  • Forgetting to register the new admin_post action.
  • Omitting nonce verification.
  • Forgetting to sanitize submitted values.
  • Redirecting before calling exit.
  • Returning output instead of redirecting.

Git Commands Used

git add .

git commit -m "Lesson 21: Update auctions"

git push

Testing Checklist

Before moving to the next lesson, verify that:

  • ✅ Edit page opens correctly.
  • ✅ Auction values can be modified.
  • ✅ Clicking Save Changes updates the database.
  • ✅ Success message appears.
  • ✅ Refreshing the page does not resubmit the form.
  • ✅ No PHP warnings or notices appear.

Project Status

✅ Dashboard

✅ Add Auction

✅ Save Auction

✅ View Auctions

✅ WP_List_Table

✅ Row Actions

✅ Edit Auction Form

✅ Update Auction

⬜ Delete Auction

⬜ Auction Scheduling

⬜ Bid Engine

⬜ Escrow Workflow

Developer’s Notebook

WordPress encourages developers to separate the user interface from business logic. In this lesson, the form is responsible only for collecting user input, while the admin_post handler processes and validates the request before delegating the database update to the Auction Manager. This separation of responsibilities makes the plugin easier to test, maintain, and extend in future lessons.

Lesson 20: Building the Edit Auction Form

In the previous lesson, we successfully created an Edit Auction page and retrieved the selected auction from the database. When an administrator clicked the Edit link, the plugin displayed the auction’s current information.

Although this proved that our retrieval logic worked correctly, the page was still read-only. In this lesson, we’ll replace the information table with a fully editable form whose fields are automatically populated with the auction’s existing values.

This approach mirrors how WordPress edits posts, pages, users, and many other objects. Administrators see the current values, make changes, and then save them.


Learning Objectives

By the end of this lesson you will be able to:

  • Build an editable administration form.
  • Pre-populate form fields with database values.
  • Display existing auction information inside HTML inputs.
  • Create the foundation for updating auctions in the next lesson.

Current Workflow

Our current workflow is:

All Auctions
      ↓
Click Edit
      ↓
Retrieve Auction
      ↓
Display Read-only Table

After today’s lesson it becomes:

All Auctions
      ↓
Click Edit
      ↓
Retrieve Auction
      ↓
Editable Form
      ↓
Save Changes (Next Lesson)

Step 1 – Locate the Edit Auction Page

Open:

admin/class-admin.php

Locate the method:

public function edit_auction_page()

Inside the method you’ll find a table displaying the auction details.


Step 2 – Replace the Table with a Form

Replace the existing table with the following form:

<form method="post">

	<table class="form-table">

		<tr>

			<th scope="row">
				<label for="listing_id">Listing ID</label>
			</th>

			<td>
				<input
					type="number"
					id="listing_id"
					name="listing_id"
					value="<?php echo esc_attr( $auction->listing_id ); ?>"
					required
					class="regular-text"
				>
			</td>

		</tr>

		<tr>

			<th scope="row">
				<label for="start_price">Start Price</label>
			</th>

			<td>
				<input
					type="number"
					step="0.01"
					id="start_price"
					name="start_price"
					value="<?php echo esc_attr( $auction->start_price ); ?>"
					class="regular-text"
				>
			</td>

		</tr>

		<tr>

			<th scope="row">
				<label for="reserve_price">Reserve Price</label>
			</th>

			<td>
				<input
					type="number"
					step="0.01"
					id="reserve_price"
					name="reserve_price"
					value="<?php echo esc_attr( $auction->reserve_price ); ?>"
					class="regular-text"
				>
			</td>

		</tr>

		<tr>

			<th scope="row">
				<label for="buy_now_price">Buy Now Price</label>
			</th>

			<td>
				<input
					type="number"
					step="0.01"
					id="buy_now_price"
					name="buy_now_price"
					value="<?php echo esc_attr( $auction->buy_now_price ); ?>"
					class="regular-text"
				>
			</td>

		</tr>

		<tr>

			<th scope="row">
				<label for="status">Status</label>
			</th>

			<td>

				<select
					name="status"
					id="status"
				>

					<option value="draft" <?php selected( $auction->status, 'draft' ); ?>>
						Draft
					</option>

					<option value="active" <?php selected( $auction->status, 'active' ); ?>>
						Active
					</option>

					<option value="closed" <?php selected( $auction->status, 'closed' ); ?>>
						Closed
					</option>

				</select>

			</td>

		</tr>

	</table>

	<?php submit_button( 'Save Changes' ); ?>

</form>

Notice that every input field uses the current auction value. This allows administrators to modify existing information instead of re-entering everything.


Step 3 – Test the Plugin

Create a fresh ZIP and upload the updated plugin.

Navigate to:

Flipnzee Auctions → All Auctions

Click Edit.

Instead of a read-only table you should now see an editable form containing:

  • Listing ID
  • Start Price
  • Reserve Price
  • Buy Now Price
  • Status

The Save Changes button will appear but won’t update the database yet. We’ll implement that functionality in the next lesson.


Why Build the Form First?

Professional software development often separates the user interface from the data processing logic.

Today’s lesson focuses entirely on presenting editable fields.

The next lesson will focus on validating user input and updating the database.

Separating these concerns makes the code easier to understand, test, and maintain.


Lesson Summary

In this lesson we transformed the Edit Auction page from a read-only display into an editable administration form.

Each input field is automatically populated using data retrieved from the database, allowing administrators to modify auction information without retyping existing values.

Although the Save Changes button is now visible, it does not yet perform any updates. That functionality will be implemented in the next lesson.


Key Takeaways

  • Editable forms improve administrator usability.
  • Existing values should always be pre-populated.
  • esc_attr() safely outputs values inside HTML attributes.
  • Building the interface before processing simplifies development.

Common Mistakes

  • Forgetting to pre-populate form values.
  • Using echo without esc_attr() inside HTML attributes.
  • Omitting the Status dropdown.
  • Trying to update the database before the form is complete.

Git Commands Used

git add .

git commit -m "Lesson 20: Build Edit Auction form"

git push

Testing Checklist

Before moving to the next lesson, verify that:

  • ✅ The plugin activates successfully.
  • ✅ The Edit page opens correctly.
  • ✅ All fields contain the current auction values.
  • ✅ Status is selected correctly.
  • ✅ The Save Changes button appears.
  • ✅ No PHP errors occur.

Project Status

✅ Dashboard

✅ Add Auction

✅ Save Auction

✅ View Auctions

✅ WP_List_Table

✅ Row Actions

✅ Edit Auction Page

✅ Edit Auction Form

⬜ Update Auction

⬜ Delete Auction

⬜ Bid Engine

⬜ Escrow Workflow

Developer’s Notebook

Creating the editing interface before implementing database updates follows a common development pattern. It allows you to verify that data retrieval and presentation work correctly before adding validation and persistence logic. This incremental approach also makes debugging significantly easier because each lesson introduces only one major concept.

Lesson 19: Creating the Edit Auction Page

Introduction

In the previous lesson, we enhanced our auction list by adding View, Edit, and Delete row actions beneath each Auction ID. Although these links improved the user interface, they were only placeholders.

In this lesson, we’ll make the Edit action functional by creating a dedicated Edit Auction page inside the WordPress administration area. Initially, this page will retrieve an auction from the database and display its existing information in a form. We’ll save the changes in the next lesson.

Breaking the workflow into two lessons makes it easier to understand and follows the same incremental approach we’ve used throughout this series.


Learning Objectives

By the end of this lesson, you’ll be able to:

  • Build an Edit Auction administration page.
  • Pass an auction ID through a URL.
  • Retrieve a single auction from the database.
  • Populate a form with existing values.
  • Understand how editing workflows begin in WordPress plugins.

How the Workflow Changes

Our administration flow now becomes:

All Auctions
      ↓
Click Edit
      ↓
Edit Auction Page
      ↓
Retrieve Auction
      ↓
Display Existing Values

Notice that we’re still not saving changes yet. Today’s goal is to display the current data.


Step 1 – Update the Edit Row Action

Open:

admin/class-auctions-table.php

Locate the column_id() method.

Replace the Edit action with:

'edit' => sprintf(
	'<a href="%s">Edit</a>',
	admin_url(
		'admin.php?page=flipnzee-edit-auction&auction_id=' . absint( $item->id )
	)
),

Now every Edit link will open the correct auction.


Step 2 – Register a New Submenu

Open:

admin/class-admin.php

Inside register_menu(), add another submenu:

add_submenu_page(
	'flipnzee-auctions',
	'Edit Auction',
	'Edit Auction',
	'manage_options',
	'flipnzee-edit-auction',
	array( $this, 'edit_auction_page' )
);

This page won’t normally appear in the menu because administrators will access it through the Edit link.


Step 3 – Create the Edit Page

Inside class-admin.php, create:

public function edit_auction_page() {

	$auction_id = isset( $_GET['auction_id'] )
		? absint( $_GET['auction_id'] )
		: 0;

	$auction = Flipnzee_Auction_Manager::get_auction(
		$auction_id
	);

	if ( ! $auction ) {

		echo '<div class="notice notice-error"><p>Auction not found.</p></div>';

		return;
	}

	?>

	<div class="wrap">

		<h1>Edit Auction</h1>

		<p>The auction was loaded successfully.</p>

	</div>

	<?php
}

At this stage, we’re simply verifying that the selected auction can be retrieved.


Step 4 – Test the Plugin

Create a fresh ZIP.

Upload the plugin.

Navigate to:

Flipnzee Auctions → All Auctions

Click Edit beneath any auction.

If everything is working correctly, you’ll see:

Edit Auction

The auction was loaded successfully.

This confirms that:

  • The row action works.
  • The auction ID is passed correctly.
  • The Auction Manager retrieves the correct record.
  • The administration page loads successfully.

Why Stop Here?

Many beginners try to retrieve, display, validate, and save data in a single lesson.

Breaking the process into smaller steps makes debugging much easier.

Today we verify that the correct auction is loaded.

In the next lesson, we’ll build the complete editing form.


Lesson Summary

In this lesson, we transformed the placeholder Edit link into a working navigation path.

Administrators can now select an auction from the list, open an Edit Auction page, and retrieve the corresponding record from the database.

Although editing isn’t complete yet, we’ve successfully implemented the first half of the editing workflow.


Key Takeaways

  • ✓ Row actions can pass record IDs through URLs.
  • ✓ Retrieve individual records using the Auction Manager.
  • ✓ Separate retrieval from saving.
  • ✓ Build editing workflows incrementally.

Common Mistakes

  • Forgetting to sanitize the auction ID.
  • Accessing the database directly instead of using the Auction Manager.
  • Assuming every ID exists.
  • Trying to save changes before displaying the existing values.

Git Commands Used

git add .

git commit -m "Lesson 19: Create Edit Auction page"

git push

Testing Checklist

Before continuing:

  • ✅ Plugin activates successfully.
  • ✅ All Auctions page still loads.
  • ✅ Every Edit link opens a new page.
  • ✅ Correct auction ID is passed.
  • ✅ Auction record is retrieved successfully.
  • ✅ “Auction not found” appears only for invalid IDs.

Project Status

✅ Dashboard

✅ Add Auction

✅ Save Auctions

✅ View Auctions

✅ WP_List_Table

✅ Row Actions

✅ Edit Auction Page

⬜ Edit Auction Form

⬜ Save Edited Auction

⬜ Delete Auction

⬜ Bid Engine

⬜ Escrow Workflow

Project Evolution

With the introduction of the Edit Auction page, Flipnzee Auctions now supports navigation from a list of records to an individual record. This pattern is common in many WordPress plugins and content management systems. By retrieving a single auction before attempting to modify it, we’ve established a clean editing workflow that can be expanded safely in future lessons.


Developer’s Notebook

Professional applications rarely perform retrieval, validation, and persistence in one step. Separating these responsibilities improves readability, simplifies testing, and makes future enhancements much easier. Today’s lesson focuses entirely on retrieving the correct record, allowing the next lesson to concentrate solely on editing and saving changes.

Lesson 18: Adding Row Actions to the Auction List

Introduction

In the previous lesson, we migrated our auction list to WordPress’s WP_List_Table framework.

Although the table now uses WordPress’s native administration interface, each row is still read-only.

Professional WordPress plugins allow administrators to perform actions directly from the list table. Common actions include viewing details, editing records, deleting items, or changing their status.

In this lesson, we’ll add our first row actions to the auction list, preparing the plugin for editing and deleting auctions in the next lessons.


Learning Objectives

By the end of this lesson, you’ll be able to:

  • Understand row actions in WP_List_Table.
  • Override the column_id() method.
  • Add custom row actions.
  • Build administrator-friendly interfaces.
  • Prepare the plugin for editing and deleting auctions.

What Are Row Actions?

When you open the Posts page in WordPress, each post displays actions such as:

Edit | Quick Edit | Trash | View

These are called row actions.

Instead of placing buttons in separate columns, WordPress displays contextual links directly beneath the primary column.

We’ll adopt the same approach.


Step 1 – Choose the Primary Column

For our plugin, the Auction ID will become the primary column.

Every action related to an auction will appear beneath its ID.


Step 2 – Add a Custom Column Method

Open:

admin/class-auctions-table.php

Add the following method inside the class.

public function column_id( $item ) {

	$actions = array(

		'view' => sprintf(
			'<a href="#">View</a>'
		),

		'edit' => sprintf(
			'<a href="#">Edit</a>'
		),

		'delete' => sprintf(
			'<a href="#">Delete</a>'
		),

	);

	return sprintf(
		'%1$s %2$s',
		$item->id,
		$this->row_actions( $actions )
	);
}

Understanding row_actions()

The WordPress base class automatically formats our links into the familiar style used throughout the administration area.

Instead of manually creating HTML, we simply pass an array of actions.

WordPress handles the rest.


Step 3 – Test the Table

Create a fresh ZIP.

Upload the plugin.

Open:

Flipnzee Auctions → All Auctions

Each auction should now display:

1

View | Edit | Delete

directly beneath the Auction ID.

Although these links don’t perform any actions yet, they establish the navigation we’ll build upon in future lessons.


Why Placeholder Links?

You might wonder why the links currently point to #.

This allows us to focus on one concept at a time.

Today’s goal is to understand how row actions are rendered.

In the next lessons, we’ll replace each placeholder with working functionality.


Lesson Summary

In this lesson, we enhanced the auction list by introducing row actions through the column_id() method.

The auction table now follows the same interaction model used throughout the WordPress administration area, giving users familiar controls while preparing the plugin for more advanced features.


Key Takeaways

  • ✓ Row actions belong beneath the primary column.
  • ✓ Override column_id() to customize the first column.
  • ✓ Use row_actions() instead of manually building links.
  • ✓ Keep one lesson focused on one new concept.

Common Mistakes

  • Forgetting to create the column_id() method.
  • Returning only the ID without row actions.
  • Placing action links inside separate columns.
  • Trying to implement edit and delete functionality before creating the row actions.

Git Commands Used

git add .

git commit -m "Lesson 18: Add row actions to auction list"

git push

Testing Checklist

Before moving to the next lesson, verify:

  • ✅ Plugin activates successfully.
  • ✅ Dashboard still loads.
  • ✅ Add Auction still works.
  • ✅ All Auctions page loads correctly.
  • ✅ Every auction displays its ID.
  • ✅ View, Edit, and Delete appear beneath each Auction ID.
  • ✅ No PHP warnings or fatal errors.

Project Status

✅ Dashboard

✅ Add Auction

✅ Save Auctions

✅ View Auctions

✅ WP_List_Table

✅ Row Actions

⬜ View Auction

⬜ Edit Auction

⬜ Delete Auction

⬜ Bid Engine

⬜ Escrow Workflow

Project Evolution

Our administration interface is becoming increasingly similar to native WordPress screens. Instead of treating auctions as static records, administrators can now see contextual actions associated with each auction. While the actions are placeholders today, the underlying structure is now in place. Future lessons will simply connect these links to real functionality without redesigning the interface.


Developer’s Notebook

One of the strengths of WP_List_Table is that it encourages consistency across the WordPress administration area. By adopting row actions rather than adding separate action columns, our plugin immediately feels more familiar to WordPress users. This small architectural decision improves usability while reducing unnecessary visual clutter.


Looking Ahead

In Lesson 19, we’ll replace the placeholder Edit link with a fully functional auction editing page. Administrators will be able to modify auction details directly from the dashboard, making Flipnzee Auctions feel even more like a native WordPress application.

Lesson 16: Building a Professional Auction List with WP_List_Table

Introduction

In the previous lesson, we displayed all auctions inside a simple HTML table. While this approach works well for learning, professional WordPress plugins usually rely on a built-in class called WP_List_Table.

WP_List_Table powers many of the tables you already use every day in WordPress, including Posts, Pages, Comments, Plugins, Themes, and Users.

In this lesson, we’ll replace our simple table with a WP_List_Table implementation, giving our plugin a more professional and scalable administration interface.


Learning Objectives

By the end of this lesson, you’ll be able to:

  • Understand the purpose of WP_List_Table.
  • Create your first custom table class.
  • Display auction records using WordPress’s native table layout.
  • Prepare the plugin for pagination, searching, sorting, and bulk actions.
  • Build a more professional administration interface.

Why Replace Our HTML Table?

Our current table works:

Database

↓

Auction Manager

↓

HTML Table

However, WordPress already provides a reusable table framework.

Using WP_List_Table, our architecture becomes:

Database

↓

Auction Manager

↓

WP_List_Table

↓

WordPress Admin

This gives us a consistent look and makes future enhancements much easier.


What Is WP_List_Table?

WP_List_Table is an internal WordPress class responsible for rendering tables in the administration area.

It provides support for:

  • Pagination
  • Sorting columns
  • Bulk actions
  • Row actions
  • Search boxes
  • Screen options

Many popular plugins extend this class to create professional management screens.


Step 1 – Create a New File

Create:

admin/class-auctions-table.php

This class will extend WP_List_Table.


Step 2 – Load the WordPress Class

At the top of the file, add:

if ( ! class_exists( 'WP_List_Table' ) ) {
	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}

This ensures the base class is available.


Step 3 – Create the Table Class

Begin with:

class Flipnzee_Auctions_Table extends WP_List_Table {

}

Every custom list table extends the WordPress base class.


Step 4 – Define the Columns

Our first version will display:

ColumnDescription
IDAuction ID
ListingListing ID
Start PriceOpening bid
Reserve PriceMinimum acceptable price
Buy NowImmediate purchase price
StatusCurrent auction status

Additional columns will be introduced in later lessons.


Step 5 – Populate the Table

Instead of writing SQL inside the table class, retrieve data using:

Flipnzee_Auction_Manager::get_all_auctions();

The Auction Manager continues to own all database operations.


Step 6 – Replace the Manual Table

The All Auctions page will eventually become as simple as:

$table = new Flipnzee_Auctions_Table();

$table->prepare_items();

$table->display();

Notice how much cleaner the administration page becomes.


Why This Architecture Matters

Rather than mixing HTML, SQL, and business logic together, each layer performs one task.

Database

↓

Auction Manager

↓

WP_List_Table

↓

Admin Page

↓

Administrator

As our plugin grows, this separation will make new features much easier to implement.


Lesson Summary

In this lesson, we introduced the WP_List_Table class, the same framework WordPress uses throughout its administration area.

Although our implementation is still simple, this architectural improvement prepares Flipnzee Auctions for advanced capabilities such as searching, sorting, pagination, row actions, and bulk operations.


Key Takeaways

  • ✓ WP_List_Table is WordPress’s standard table framework.
  • ✓ Keep SQL inside the Auction Manager.
  • ✓ Separate presentation from business logic.
  • ✓ Build interfaces using WordPress conventions.
  • ✓ Prepare early for future scalability.

Common Mistakes

  • Writing SQL inside the table class.
  • Duplicating business logic.
  • Mixing HTML with database queries.
  • Ignoring WordPress’s existing UI framework.

Git Commands Used

git add .

git commit -m "Lesson 16: Introduce WP_List_Table"

git push

Project Status

✅ Development environment

✅ Plugin skeleton

✅ Plugin lifecycle

✅ Database layer

✅ Auction Manager

✅ Dashboard

✅ Add Auction

✅ Save auctions

✅ Display auctions

✅ WP_List_Table architecture

⬜ Search auctions

⬜ Sort auctions

⬜ Bulk actions

⬜ Edit auction

⬜ Delete auction

⬜ Bid engine

⬜ Escrow workflow

⬜ Version 1.0

Project Evolution

Until now, our auction list was rendered using a manually constructed HTML table. While that approach is perfectly suitable for learning, it doesn’t take advantage of WordPress’s native administration framework.

By introducing WP_List_Table, we’re aligning Flipnzee Auctions with the same patterns used throughout WordPress itself. This change not only improves consistency but also lays the groundwork for features such as pagination, searching, sorting, row actions, and bulk operations without redesigning the administration interface later.


Developer’s Notebook

One of the strengths of WordPress is that it provides reusable components for common administration tasks. Whenever possible, it’s better to build on those components rather than reinventing them. WP_List_Table is a good example: instead of maintaining our own table system, we can leverage a mature framework that’s already familiar to WordPress users and designed to scale as our plugin grows.


Looking Ahead

In Lesson 17, we’ll make our custom WP_List_Table fully functional by displaying real auction data and introducing row actions such as View, Edit, and Delete, bringing the administration interface even closer to the native WordPress experience.

Lesson 17: Migrating the Auction List to WP_List_Table

Introduction

In the previous lesson, we learned what WP_List_Table is and why professional WordPress plugins use it instead of manually building HTML tables.

In this lesson, we’ll complete the migration by creating our own WP_List_Table class, loading it into the plugin, and updating the All Auctions page to use it.

Although the table will initially display the same information as before, the underlying architecture will be much more scalable and will prepare us for pagination, sorting, searching, and row actions in future lessons.


Learning Objectives

By the end of this lesson, you’ll be able to:

  • Create a custom WP_List_Table.
  • Load the new table class into your plugin.
  • Replace a manually created HTML table.
  • Display auction records using WordPress’s native administration framework.

Step 1 – Create the Table Class

Create a new file:

admin/class-auctions-table.php

Copy the complete code from this lesson into the file.

This class extends WordPress’s WP_List_Table and is responsible for displaying auction records.


Step 2 – Load the Table Class

Open:

flipnzee-auctions.php

Immediately below the section that loads the Admin Posts Class, add:

/**
 * Load Auctions Table Class
 */
if ( file_exists( FLIPNZEE_AUCTION_PATH . 'admin/class-auctions-table.php' ) ) {
	require_once FLIPNZEE_AUCTION_PATH . 'admin/class-auctions-table.php';
}

Your loading order should now be:

  1. Loader
  2. Database
  3. Auction Manager
  4. Admin Class
  5. Admin Posts Class
  6. Auctions Table Class

Keeping related classes grouped together makes the plugin easier to maintain.


Step 3 – Update the Admin Page

Open:

admin/class-admin.php

Locate the all_auctions_page() method.

Replace the existing HTML table with:

$table = new Flipnzee_Auctions_Table();

$table->prepare_items();

$table->display();

Your page now becomes responsible only for displaying the page header and calling the table class.


Step 4 – Test the Plugin

Create a fresh ZIP.

Upload it to your WordPress website.

Activate the plugin.

Navigate to:

Flipnzee Auctions → All Auctions

If everything has been configured correctly, your auctions should now be displayed using your custom WP_List_Table.


Understanding the New Architecture

Our plugin now follows this flow:

Database
      ↓
Auction Manager
      ↓
WP_List_Table
      ↓
Admin Page
      ↓
Administrator

Notice that the Admin page no longer knows how to build the table.

Instead, it delegates that responsibility to Flipnzee_Auctions_Table.


Why This Is Better

Compared to our previous implementation:

  • The admin page contains much less code.
  • Table rendering is reusable.
  • Future enhancements become much easier.
  • The plugin follows WordPress conventions more closely.

This architecture will allow us to add pagination, searching, sorting, bulk actions, and row actions without redesigning the administration page.


Lesson Summary

In this lesson, we completed the migration from a manually constructed HTML table to WordPress’s WP_List_Table framework.

Although the interface appears familiar, the plugin now uses a more professional architecture that separates presentation from business logic and prepares the administration area for future enhancements.


Key Takeaways

  • ✓ Create a dedicated WP_List_Table class.
  • ✓ Load the class in flipnzee-auctions.php.
  • ✓ Replace the manual HTML table.
  • ✓ Keep presentation separate from business logic.
  • ✓ Build on WordPress’s native administration framework.

Common Mistakes

  • Forgetting to load class-auctions-table.php.
  • Calling $table->display() without first calling prepare_items().
  • Leaving the old HTML table in class-admin.php.
  • Writing SQL inside the table class.

Git Commands Used

git add .

git commit -m "Lesson 17: Migrate auction list to WP_List_Table"

git push

Project Status

✅ Dashboard

✅ Add Auction

✅ Save Auction

✅ View Auctions

✅ Migrate to WP_List_Table

⬜ Pagination

⬜ Search

⬜ Sorting

⬜ Row Actions

⬜ Edit Auction

⬜ Delete Auction

⬜ Bid Engine

⬜ Escrow Workflow

Developer’s Notebook

One of the advantages of building on WordPress’s native components is that your plugin becomes easier for other WordPress developers to understand. By moving table rendering into a dedicated WP_List_Table class, we’ve reduced the responsibilities of the admin page and laid the foundation for advanced features without changing the overall architecture again.