Professional WordPress Plugin Development. Brad Williams
Чтение книги онлайн.

Читать онлайн книгу Professional WordPress Plugin Development - Brad Williams страница 29

Название: Professional WordPress Plugin Development

Автор: Brad Williams

Издательство: John Wiley & Sons Limited

Жанр: Программы

Серия:

isbn: 9781119666936

isbn:

СКАЧАТЬ 3‐10.

Screenshot of the My Plugin page displaying four different types of notices supported: error, warning, success, and information.

      Buttons

      As discussed earlier, the easiest method for adding a form submission button is using the submit_button() function. However, there's no reason you can't manually create form buttons using the preset WordPress admin stylings. When manually adding buttons to your form, you can take advantage of multiple classes. The first two you use are the button‐primary and button‐secondary classes. These classes style your buttons to match the WordPress UI.

      <p> <input type="submit" name="Save" value="Save Options"/> <input type="submit" name="Save" value="Save Options" class="button-primary"/> </p><p> <input type="submit" name="Secondary" value="Secondary Button"/> <input type="submit" name="Secondary" value="Secondary Button" class="button-secondary"/> </p>

Illustration of a WordPress-styled button using the proper admin stylings.

      <a href="#">Search</a> <a href="#" class="button-primary">Search Primary</a> <a href="#" class="button-secondary">Search Secondary</a>

Illustration depicting how a standard link can be styled to look like a button by using the appropriate class.

      Form Fields

      WordPress has a special table class just for forms called form‐table. This class is used on all WordPress Dashboard forms, including every Settings page. This is a useful class when creating any type of options in your plugin.

Screenshot of a form-table that is used on all WordPress admin dashboard forms, including every Settings page, a useful class when creating any type of options in the plugin.

      Tables

      HTML tables are a great way to display rows and columns of data in an easy‐to‐read layout. Tables can easily be styled in WordPress using the widefat class.

Illustration for styling table data where the header and footer of a table has been styled to match all other tables on the admin dashboard.

      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: