If you have loved the WordPress source code and want to go deeper into it, specifically programming features in WordPress, writing plugins or making themes, you have to master a lot of knowledge. The knowledge needed to make the web then I do not say then, but one of the most important knowledge to be able to program the features in the source code is PHP programming language. Because WordPress is written in PHP to interact with MySQL database, you need to know PHP to communicate with code in WordPress.
What is PHP and how does it work?
PHP is an application programming language designed to serve the needs of writing applications serving on a website. That means we only use PHP for website programming, and PHP data is exported as HTML for the browser to display.
PHP can not operate unilaterally so it will need a PHP interpreter to be understood as a web server module (eg Apache mod_php module for executing PHP code) or via a CGI program. To be able to execute PHP code. Now I say that the localhost that you use to install on the computer to run the PHP source code is a webserver application has been installed mod_php so you can run the PHP code it.
What is the mission of PHP?
On a web page, the task of PHP would be to build scripts in the source code of the website so that it executes to do things you do not have to do manually. For example, it can display the current time on the webserver or a certain time zone has been defined in the PHP language outside the website, such as:
Although you may not yet understand PHP, you can imagine that it involves displaying time. But PHP does not just work with that much, but if you mention it, you never know.
In addition, another important task of PHP to be able to create dynamic websites is to connect to a database server to perform operations such as importing, deleting, modifying and retrieving website data. This work is like the way you go to a website, PHP understands what you need to see, then it calls the database to get this, get the other to show you. Or a clearer example in WordPress, when you post a post, that post will be saved to the database.
PHP in WordPress
Now you want to know what PHP does in WordPress, take a look at the Twenty Fifteen source code, open the content.php template and see. In it is a structure of an article, you can easily see that it is nested in the HTML tags to show outside, for example you can see this paragraph:
It will use the special functions of WordPress such as the_ID () or post_class () to display the corresponding information inside the HTML tag. It will now display HTML content outside of this type of browser:
Or it applies the if else clause in the PHP language to display the element in an article like this:
The PHP knowledge to programmers in WordPress
When learning PHP, you will learn a lot of techniques related to website programming but not all of which are used in WordPress, but if you have a good knowledge of PHP then it is good for you.
The basic knowledge of PHP in particular or a general programming language such as data types, variables, arrays, loops, if clauses are the mandatory form you need to know. These are of course known, but I say so that you know it’s very important so keep it firmly.
Knowledge of the function (function)
Techniques for building functions are important when you program in WordPress. In this source code there are a lot of built-in functions that if you do not know, it’s hard to work in WordPress. In fact, the concept is very simple, if you have not already learned PHP, let’s say that the function is a set of PHP scripts and that it will be executed when the function is invoked.
Proficient in arrays (Array)
Arrays are a very important data type in any project, including WordPress. Imagine an array is a variable with many values, in WordPress it usually uses arrays for two things, that is, to set parameters when using a function or class, and the remaining is To handle the data returned when using a function in WordPress. So only the master of the array handling, you can not be forced to learn advanced WordPress.
Class & Object
Its class is like an array, which is a collection of PHP scripts but will be at a higher level. And in the class it can contain variables (called attributes) and functions inside the class (called methods). And when the class is recreated, it returns data objects. This is when learning PHP you can practice as much as possible, and when you learn to this is as if you have learned Object Oriented Programming (OOP) then.
In addition to the function, WordPress also has some classes that you use frequently, most commonly the WP_Query class (for creating queries) and the WP_Widget class (for creating widgets). Also, when you retrieve the article’s data, you will work with a lot of objects (specifically the $post object).
Studying at CodeAcademy is a great way for you to learn and practice, that is, you will learn new knowledge through solving exercises from their suggestions, once a long memory.
TheNewBoston is a very popular code learning channel on Youtube already, and if you want to learn PHP, do not know this channel yet, so try the basic PHP tutorial from basic to advanced. With 200 extremely detailed, easy-to-learn tutorials, you can master PHP knowledge as not only does this series have very intuitive tutorials.
If you have ever learned programming, have already mastered a few languages and want to get started with PHP then you should start here. The name says it all, this is a handbook that guides you to learn PHP in the best way, updated with the latest knowledge base, as there are now many outdated PHP tutorials available online. If you follow this manual, I think your knowledge of PHP will not be inferior.
PHP Resources in WordPress
Here are some useful links so that you can look up WordPress source code as needed.
To avoid your code being hard to read, WordPress has compiled a standard code written in WordPress so that it’s more user-friendly, in sync with the source code so if possible, take a look at their PHP writing rules to write code better.
If while learning advanced WordPress or writing code in WordPress that has a cryptic function or looking for a function, you can use this page to look up. There you can see details about the code in WordPress, as well as how to use it, you will most likely use it continuously.
Do not know the knowledge in WordPress needed to be able to programmable the plugin? Take a look at this handbook, which details the sequences of knowledge needed to be able to write plugins in WordPress.
Although I did not post the PHP series in WordPress, but hopefully with the resources and tips above, you can plan more clearly to learn PHP, know what to learn to do and how to learn to work in WordPress.
I really wish you soon mastered WordPress programming!
See more: Resource And Hook Lookup In WordPress