WordPress Plugin Development Cookbook
eBook - ePub

WordPress Plugin Development Cookbook

Yannick Lefebvre

  1. 420 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

WordPress Plugin Development Cookbook

Yannick Lefebvre

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Create plugins for WordPress through detailed recipes that cover the creation of shortcodes, custom post types, and custom blocks, integrate data from external sources, and do much more with this recipe-based guideKey Features‱ Create plugins that change and extend WordPress to perform virtually any task‱ Extend the WordPress Block Editor (Gutenberg) and other components with the help of detailed examples and explanations‱ Customize WordPress to meet your project's needs and create plugins that benefit the entire communityBook DescriptionWordPress is one of the most widely used, powerful, and open content management systems (CMSs). Whether you're a site owner trying to find the right extension, a developer who wants to contribute to the community, or a website developer working to fulfill a client's needs, learning how to extend WordPress' capabilities will help you to unleash its full potential. This book will help you become familiar with API functions to create secure plugins with easy-to-use administration interfaces.This third edition contains new recipes and up-to-date code samples, including new chapters on creating custom blocks for the block editor and integrating data from external sources. From one chapter to the next, you'll learn how to create plugins of varying complexity, ranging from a few lines of code to complex extensions that provide intricate new capabilities. You'll start by using the basic mechanisms provided in WordPress to create plugins, followed by recipes covering how to design administration panels, enhance the post editor with custom fields, store custom data, and even create custom blocks. You'll safely incorporate dynamic elements into web pages using scripting languages, learn how to integrate data from external sources, and build new widgets that users will be able to add to WordPress sidebars and widget areas.By the end of this book, you will be able to create WordPress plugins to perform any task you can imagine.What you will learn‱ Discover action and filter hooks, which form the basis of plugin creation‱ Explore the creation of administration pages and add new content management sections through custom post types and custom fields‱ Add new components to the block editor library‱ Fetch, cache, and regularly update data from external sources‱ Bring in external data sources to enhance your content‱ Make your pages dynamic by using JavaScript, jQuery, and AJAX and adding new widgets to the platform‱ Add support for plugin translation and distributing your work to the WordPress communityWho this book is forThis book is for WordPress users, developers, and site integrators interested in creating new plugins to address their personal needs, fulfill client requirements, and bring new capabilities to the WordPress community. Basic knowledge of PHP and WordPress is expected.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que WordPress Plugin Development Cookbook est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  WordPress Plugin Development Cookbook par Yannick Lefebvre en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et Programmierung in PHP. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2022
ISBN
9781801816939
Édition
3

Chapter 1: Preparing a Local Development Environment

Before you start writing your first WordPress plugin, it is important to have a good set of tools in place that will allow you to work locally on your computer and be more efficient in your work. While it is possible to perform some development tasks with the built-in tools that are provided with the operating system, creating a solid local development environment will help you develop plugins quickly and have full control over your server settings to be able to test different configurations.
This chapter proposes a set of free tools that can easily be installed on your computer, regardless of your preferred operating system, to facilitate the development of your future WordPress plugins. These tools include a local web server to speed up page access and avoid sending files constantly to a remote server, a version control system to keep incremental backups of your work, and a code editor to enhance your editing capabilities.
We will cover the following recipes in this chapter:
  • Installing a local web server on your computer
  • Creating a local version control repository
  • Installing a dedicated code editor/text editor

Technical requirements

You can find complete code examples on GitHub under the following repository: https://github.com/PacktPublishing/WordPress-Plugin-Development-Cookbook-Third-Edition.

Installing a local web server on your computer

The first step to preparing a local development environment is to install a local web server on your computer. This will transform your computer into a system capable of running the core WordPress code and performing all tasks related to rendering a WordPress website locally.
Having a local web server has many benefits:
  • It provides a quick response to the frequent page refreshes that are made as plugin code is written, tested, and refined, since all information is processed locally.
  • It removes the need to constantly upload new plugin file versions to a remote web server to validate code changes.
  • It allows development to take place when no internet connection is available (for example, when traveling on an airplane). This is only possible if your plugin code does not interact with external servers.
  • It offers a worry-free programming environment where you cannot bring down a live website with a programming error or an infinite loop.
There are many free packages available online that contain all of the web server components necessary to run a WordPress installation.

How to do it


Follow these steps to easily install the aptly named Local application from Flywheel:
  1. Visit the Local website (https://www.localwp.com/) and download the appropriate package for your computer.
    Note
    Local is free and available for Windows, macOS, and Linux platforms. The screenshots and instructions in this recipe are based on Local version 6.1.5 running on Windows 11. The installation steps and exact dialog content may vary based on your choice of platform.
  2. Launch the Local installer.
  3. On Windows, select whether the application should be available only to the user performing the application or to all users (requires administrator privileges), and then leave all the other options at their default values.
  4. Also on Windows, make sure that the Run Local checkbox is checked at the end of the installation process and click on Finish to exit the installer and start Local.
Figure 1.1 – Last page of the Local installation program on Windows
Figure 1.1 – Last page of the Local installation program on Windows
  1. On macOS, open the installation package and drag the Local program to the Applications folder. Once this is done, search for Local and run it.
  2. When Local first starts, you will need to accept the application's Terms of Service and will also be given the option to activate Error Reporting to automatically report problems back to the Local team. You can activate the error reporting feature at your discretion.
  3. On the next screen, you will be prompted to create a free Local account. This is optional and can be bypassed by closing the account creation screen, bringing you to the main Local interface.
Figure 1.2 – Main Local interface
Figure 1.2 – Main Local interface
  1. Click on + CREATE A NEW SITE to start the site creation process.
  2. Name your new site Plugin Development Site and click on CONTINUE.
  3. Select the Preferred option to create a site running the latest versions of PHP and MySQL, along with the nginx web server, and then click on CONTINUE.
  4. Specify a username, password, and email to create an account on your development WordPress site and then click on ADD SITE. The Local application will download and install the required components and start all of the required applications to have a working local WordPress installation. On Windows, you may need to allow multiple applications through the computer's firewall.
Figure 1.3 – Newly created local development site
Figure 1.3 – Newly created local development site
  1. Visit your local development site by clicking on the OPEN SITE button in the top-right corner of the Local interface. The default address of your site is http://plugin-development-site.local/.
  2. Back in the Local interface, click on the ADMIN button to visit your site's login page and connect using the credentials you provided during the site creation process.
  3. Make sure that the active theme is Twenty Twenty-Two. If not, install it and activate it.
  4. Still in the Local interface, click on the arrow next to the site path under the site name to access the site's local files on your computer. The WordPress software files will be found under the app\public directory within the site directory.

How i...

Table des matiĂšres

  1. WordPress Plugin Development Cookbook
  2. Third Edition
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
  7. Chapter 1: Preparing a Local Development Environment
  8. Chapter 2: Plugin Framework Basics
  9. Chapter 3: User Settings and Administration Pages
  10. Chapter 4: The Power of Custom Post Types
  11. Chapter 5: Customizing Post and Page Editors
  12. Chapter 6: Extending the Block Editor
  13. Chapter 7: Accepting User Content Submissions
  14. Chapter 8: Customizing User Data
  15. Chapter 9: Leveraging JavaScript, jQuery, and AJAX Scripts
  16. Chapter 10: Adding New Widgets to the WordPress Library
  17. Chapter 11: Fetching, Caching, and Regularly Updating External Site Data
  18. Chapter 12: Enabling Plugin Internationalization
  19. Chapter 13: Distributing Your Plugin on WordPress.org
  20. Other Books You May Enjoy
Normes de citation pour WordPress Plugin Development Cookbook

APA 6 Citation

Lefebvre, Y. (2022). WordPress Plugin Development Cookbook (3rd ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/3448792 (Original work published 2022)

Chicago Citation

Lefebvre, Yannick. (2022) 2022. WordPress Plugin Development Cookbook. 3rd ed. Packt Publishing. https://www.perlego.com/book/3448792.

Harvard Citation

Lefebvre, Y. (2022) WordPress Plugin Development Cookbook. 3rd edn. Packt Publishing. Available at: https://www.perlego.com/book/3448792 (Accessed: 24 June 2024).

MLA 7 Citation

Lefebvre, Yannick. WordPress Plugin Development Cookbook. 3rd ed. Packt Publishing, 2022. Web. 24 June 2024.