Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 110

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>

This example demonstrates a standard unstyled button as compared to the WordPress styled button. As you can tell, the WordPress‐styled button looks familiar and uses the proper styling, as shown in Figure 3‐11.


FIGURE 3‐11: WordPress‐styled button

Links can also take the form of a button by using the appropriate class.

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

This example shows how a standard <a href> link can be styled to look like a button, as shown in Figure 3‐12. To normal users, they would never know these are regular text links because they look just like a button.


FIGURE 3‐12: Link styled to look like a button

Professional WordPress Plugin Development

Подняться наверх