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

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

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

Автор: Brad Williams

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

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

Серия:

isbn: 9781119666936

isbn:

СКАЧАТЬ these functions in detail.

      When Are Plugins Loaded?

A high-level diagram presenting the standard loading process when loading a web page in WordPress.

      The flow changes slightly when loading an admin page. The differences are minor and primarily concern what theme is loaded: admin theme versus your website theme.

      When researching available plugins, you need to know where to find WordPress plugins. You can download plugins from many places on the Internet, but this isn't always a good idea.

      WARNING As with any software, downloading plugins from an untrusted source could lead to malware‐injected and compromised plugin files. It's best to download plugins only from trusted websites and official sources such as the official Plugin Directory.

      Official Plugin Directory

      The first place to start when researching available WordPress plugins is the official Plugin Directory at WordPress.org. The Plugin Directory is located at https://wordpress.org/plugins. With more than 55,000 plugins available and millions of plugin downloads, it's easy to see the vital role plugins play in every WordPress website. All plugins available in the Plugin Directory are 100 percent GPL and free to use for personal or commercial use.

      Popular Plugin Examples

      Take a look at some of the more popular WordPress plugins available to get a sense of their diversity:

       Yoast SEO: Advanced search engine optimization functionality for WordPress. Features include custom metadata for all content, canonical URLs, custom post type support, XML sitemaps, and more!https://wordpress.org/plugins/yoast-seo

       WPForms: A powerful drag‐and‐drop form builder. Create simple contact forms and powerful subscription payment forms, all without writing a single line of code.https://wordpress.org/plugins/wpforms-lite

       BuddyPress: A suite of components used to bring common social networking features to your website. Features for online communities include member profiles, activity streams, user groups, messaging, and more!https://wordpress.org/plugins/buddypress

       WooCommerce: Advanced eCommerce solution built on WordPress. This is an extremely powerful plugin allowing anyone to sell physical and digital goods online.https://wordpress.org/plugins/woocommerce

       Custom Post Type UI: Easy‐to‐use interface for registering and managing custom post types and taxonomies in WordPress.https://wordpress.org/plugins/custom-post-type-ui

      Popular Plugin Tags

      Now you will look at some popular tags for plugins. Plugin tags are just like blog post tags, simple keywords that describe a plugin in the Plugin Directory. This makes it easy to search for existing plugins by tag. The following are popular examples:

       Twitter: Everyone loves Twitter for micro‐blogging and sharing links. You can find an abundance of Twitter‐related plugins for WordPress.https://wordpress.org/plugins/tags/twitter

       Google: With so many different services and APIs, Google is a popular plugin tag. Everything from Google ads to Google maps have been integrated into a WordPress plugin.https://wordpress.org/plugins/tags/google

       Blocks: Most plugins that include block editor integration also use the blocks tag. This is great for viewing the many different types of blocks available for WordPress.https://wordpress.org/plugins/tags/blocks

      Viewing popular plugin tags can provide inspiration when developing new plugins for WordPress.

      WordPress offers many advantages when using plugins. It's important to understand the advantages of building plugins to truly understand why you should spend time building them. This can also help when determining the need for a specific plugin in WordPress.

      Not Modifying Core

      One of the main advantages to plugins is the ability to modify the behavior of WordPress without modifying any core files. Core files refer to any file that is part of the default WordPress installation.

      Hacking core files can make it difficult to update WordPress when a new version is released. If you made any modifications to a core file, that modification would be overwritten when the update occurs. Keeping WordPress up‐to‐date with the latest version is essential in keeping your website secure.

      Modifying core files can also lead to an unstable website. Different areas of WordPress rely on other areas to function as expected. If you modify a core file and it no longer works as expected, it can cause instability and quite possibly break a completely unrelated feature in WordPress.

      Why Reinvent the Wheel?

      <?php if ( current_user_can( 'manage_options' ) ) { //any code entered here will only be executed IF //user is an administrator } ?>

      As you can see, it's easy to verify that a user has proper permissions prior to executing any code in your plugin. You will learn about user accounts and roles in Chapter 9, “Users and User Data.”

      As another example, look at sending an email in WordPress. Sure, you could create a new function in your plugin to send СКАЧАТЬ