Internationalizing a plugin After setting up the text domain in your plugin metadata we need to load the translated files to use them. For plugins we use the load\plugin\textdomainhttps://developer.wordpress.org/reference/functions/loadplugintextdomain/ function; it takes 4 parameters: 1. The name of text domain 2. This parameter is deprecated so always use FALSE 3. The path to the directory where your plugin's translations are stored Then add an action for the pluginsloaded hook and call the function we just created. php { return { 'Hello World', 'myguten' } ; }, save: => { return { 'Hello World', 'myguten' } ; }, } ; This...
According to GALA Globalization and Localization Alliancehttps://www.gala-global.org/language-industry/intro-language-industry/what-internationalization: > Internationalization is a design process that ensures a product usually a software application can be adapted to various languages and regions without requiring engineering changes to the source code. Think of internationalization as readiness for localization... Some practical examples of how internationalization is critical to multilingual products include: > > - Independence from a specific language/character set encoding > - Independence from specific cultural conventions > - Removal of hard-coded text > - Minimization of concatenated text strings > - Careful use of in-line variables > - Compatibility with third-party tools >...
WordPress security is as good as you make it and you can always make it better. This post will discuss tools and techniques for making your WordPress installation more secure. Some of these are default choices in WordPress but some are not only not the defaults but you have to manually add to configuration files or .htaccess files. Some of these rules will make local development harder as we expect constant change. However, these are excellent for production sites where we don't expect major changes and we expect them to be slower in adopting new code. This post links to...
When working with APIs we should never, under any circumstance, remove elements from the endpoint. Even if you're the owner there is no real way to know who's consuming your data and how they are doing it so removing elements of the API can cause unexpected and unpleasant problems down the road. However, there is no problem with adding attributes to your custom endpoints. This post will discuss how to do it using built-in WordPress functions and coding practices. Before we jump into adding attributes we need to ask ourselves if we need a new attribute or if we can...
One of the things I've always liked about WordPress is its flexibility. We can extend WordPress and create pretty much any type of content that we need for specific projects. We can choose whether to build it inside a theme or a plugin. For the most part I would recommend building it in a plugin so that we will retain the capability even if we switch themes. Like all plugins we first declare a preamble that looks like this. This is the block that makes it a plugin that we can load and use. php The actual meat of the...
In the last posts we created a CRUD system for authenticated WordPress requests but it's not complete. It currently only deals with the post content, it doesn't provide an easy way to paginate content, and it doesn't provide for how to access other parts of a WordPress site or app. This post will discuss solutions to these problems. Embedding content related to the post When we load the data from the posts REST endpoint we get references to the post assets like featured image, author, and comments. This is good when we're exploring the API but it becomes troublesome when...
So far we've installed JWT in our WordPress instancehttps://publishing-project.rivendellweb.net/adding-jwt-to-wordpress/ and created a basic infrastructure for the app. This post will take care of the rest of the CRUD system, we'll create/save a post, update it and delete it. All the functions we'll discuss in this post require the user to be authenticated and will not work if there is no authentication token stored in a cookie on the user's machine. A later iteration of this code may do better error handling. Create Creating a new post means, essentially, saving the content of a form into the database. The code completes...
The whole idea of the WordPress REST API is to allow developers to use whatever tools they choose to create front-ends for WordPress systems. We're no longer limited to PHP and the Gutenberg editor and the possibilities are endless. This post will cover authentication using JWT, listing pages of posts, viewing individual posts, and the basic CRUD operations: create, update, and delete. We covered setting up JWT authentication in WordPress in Adding JWT to WordPresshttps://publishing-project.rivendellweb.net/adding-jwt-to-wordpress/ We will write this using ES Modules, so we'll have to build a quick WebPack build system to convert it into something that works in...
One of the things I've struggled with when working with headless WordPress is getting stuff that I need to be authenticated to accomplish; for example, I can get a list of posts and get an individual post but I can't create, update and delete posts from a remote client. While reviewing a Udemy Course on the subject Zach Gordon's Headless WordPress REST API Authenticationhttps://www.udemy.com/course/headless-wordpress-rest-api-authentication-course/l I discovered that the reason this happens is that WordPress doesn't provide third-party clients authentication by default. SO if you want to authenticate you have to set up your authentication infrastructure in WordPress. This post will...
In previous posts this one from 2015https://publishing-project.rivendellweb.net/open-type-features/, this one from 2017https://publishing-project.rivendellweb.net/opentype-features-in-css/ I did brief writeups about OpenType features and what they were. In Open Type Features in CSShttps://publishing-project.rivendellweb.net/open-type-features-in-css/ from 2019, I wrote about OpenType features in the context of variations or what makes variable fonts and briefly touched on other features. In this post, I will dive deeper into other features available on OpenType fonts, how to implement them directly in CSS and how to implement them with CSS custom properties Getting started The first thing we need to do to enable OpenType features is to figure out what features...