The widefat
class has specific styles set for the thead
and tfoot
HTML tags. This styles the header and footer of your table to match all other tables on the Dashboard. The class can also style all table data, as shown in Figure 3‐14.
FIGURE 3‐14: Table style
Pagination
If your plugin contains a list of records, you may have a need for pagination, which is the method to break lists of data into multiple pages and have links to load each individual page. This helps reduce the load times and makes it a much cleaner user experience to navigate through the data. Would you rather view 500 records on a page or 10 pages with 50 records on each page?
WordPress has a few different classes to style your pagination. The following is an example:
<div class="tablenav"> <div class="tablenav-pages"> <span class="displaying-num">Displaying 1-20 of 69</span> <span class="page-numbers current">1</span> <a href="#" class="page-numbers">2</a> <a href="#" class="page-numbers">3</a> <a href="#" class="page-numbers">4</a> <a href="#" class="next page-numbers">»</a> </div> </div>
First, you need to wrap your pagination links in the tablenav
and tablenav‐pages
div classes. The displaying‐num
class styles the records you view. The page‐numbers
class styles the page links in the familiar WordPress format. Adding current
or next
to the link class can add some unique styles to those elements, as shown in Figure 3‐15.
FIGURE 3‐15: Pagination style
Keeping your plugin design consistent with the WordPress user interface can reduce your plugins' learning curve because users will feel comfortable with the design and styles used. This can also make your plugins' design future‐proof. If the WordPress core styles change down the road, your plugins' design will also change to match the new user interface, and you won't need to edit a single line of code!
SUMMARY
This chapter covered many different methods for integrating your plugin in WordPress. You certainly won't use every method discussed in every plugin you develop, but it's essential to understand what's available for use in your plugin.
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.