WordPress Plugin Development Cookbook
eBook - ePub

WordPress Plugin Development Cookbook

Yannick Lefebvre

  1. 420 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

WordPress Plugin Development Cookbook

Yannick Lefebvre

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

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.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
WordPress Plugin Development Cookbook è disponibile online in formato PDF/ePub?
Sì, puoi accedere a WordPress Plugin Development Cookbook di Yannick Lefebvre in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatik e Programmierung in PHP. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2022
ISBN
9781801816939
Edizione
3
Argomento
Informatik

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...

Indice dei contenuti

  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
Stili delle citazioni per 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.