Learn PHP for WordPress and Essential Resources

If you already love the WordPress source code and want to go deeper into it, specifically programming features in WordPress, writing plugins or making themes, then you have to master a lot of knowledge. The knowledge needed to make a web, I did not say, but one of the most important knowledge to be able to program features in the WordPress source code is the PHP programming language. Because WordPress is written in PHP language to interact with the database using the MySQL management system, if you want to “communicate” with the code in WordPress, you must know PHP.

Actually, I have finished writing a series of Learning PHP for the needs of working in WordPress, but the irony is that when I finished writing it, I found it too bananas to read and sometimes it would be even more difficult for you to understand PHP. So I decided not to post that series but will write a guide, this one to guide you step by step to learn PHP to be able to work with WordPress.

What is PHP and how does it work?

PHP is an application programming language designed to serve the needs of writing web-based applications. That means we only use PHP in website programming, and the PHP data will be output as HTML for the browser to display.

PHP cannot work unilaterally so it will need an interpreter (PHP interpreter) is understood as a web server module (eg Apache’s mod_php module to execute PHP code) or through a CGI program to execute PHP code. Ready here I say drive through a little is always the localhost that you use to install on your computer to run the PHP source code is a webserver application that has mod_php installed so you can run the PHP code there.

Learn PHP for WordPress and Essential Resources 15

What is the mission of PHP?

In a website, PHP’s job will be to build scripts in the website’s source code so that it executes to do things that you don’t have to do manually. For example, it can display the current time on the webserver or a predefined time zone in PHP to the website, for example:

<?php echo ‘Năm nay là ‘ . date(‘Y’); ?>

Although you may not understand PHP by now, you can imagine it has to do with displaying time. But PHP not only works with that much, but if I mention it, I don’t know when it’s all over.

See more:  24 great code snippets for Woocommerce

In addition, another important task of PHP to be able to form dynamic web pages is to connect to a server containing a database for manipulation such as entering, deleting, editing and retrieving data about the website. This job is like you go to a website, PHP understands what data you need to see, and then it tells the database that it needs to get this, get that to show you. Or a more obvious example in WordPress, when you post a Post, that post will be saved in the database.

PHP in WordPress

Now you want to know what PHP does in WordPress then see the source code of the Twenty Fifteen theme, open the content.php template and see. In it is a structure of an article, you can easily see that it is nested in HTML tags for external display, for example you can see this paragraph:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
Learn PHP for WordPress and Essential Resources 15

It will use special WordPress functions like the_ID() or post_class() to display the corresponding information inside this HTML tag. Now it will display the HTML content outside the browser like this:

[html]

[/html]

Or it applies the if else clause in the PHP language to display the element in an article like this:


if ( is_single() ) :
        the_title( ‘<h1 class="entry-title">’, ‘</h1>’ );
else :
        the_title( sprintf( ‘<h2 class="entry-title"><a href="https://TechtipsNReview.com/wordpress/wordpress-development/%s" rel="bookmark">’, esc_url( get_permalink() ) ), ‘</a></h2>’ );
endif;

PHP knowledge for programming in WordPress

When you learn PHP, you will learn a lot of techniques related to website programming but not all of them are used in WordPress, but if you have a lot of knowledge about PHP, it’s fine for you.

Learn PHP for WordPress and Essential Resources 15

Primary knowledge

Basic knowledge of PHP in particular or a programming language in general such as data types, variables, arrays, loops, if else (if) branching clauses statement) are mandatory knowledge you need to know. These things should be known of course, but I tell you that it is very important so please master it.

See more:  [Woocommerce] How to use YITH WooCommerce Color and Label Variations

Knowledge of functions

The technique of constructing functions is very important when you are programming in WordPress. In this source code it has many built-in functions that if you do not know, it is difficult to work in WordPress. Actually the concept of a function is also very simple, if you have not learned through PHP, I would like to say first that a function means a set of PHP scripts and it will be executed when the function is called.

Proficient in Arrays

Arrays are very important data types in any project, including WordPress. Imagine an array as a variable with many values, in WordPress it often uses arrays for two things, that is to set parameters when using a function or a certain class, and the other is to process the data returned when using a function in WordPress. So, only if you are fluent in array manipulation, you can not have to worry when learning advanced WordPress.

Class and Object (Class & Object)

Its class is like an array, a collection of PHP scripts but will be at a higher level. And in the class it can contain variables (called properties) and functions inside the class (called methods). And when the class is recreated then it will return data objects. This when learning PHP you can practice as much as possible, and when you come here, you are considered to have learned object-oriented programming (OOP).

Learn PHP for WordPress and Essential Resources 15

The reason I ask you to learn this part is because in addition to functions, WordPress also has a number of classes that you use very often, the most common are the WP_Query class (to create queries) and the WP_Widget class (to create widgets). Also, when you get the post’s data, you’ll be working with the object a lot (namely the $post object).

PHP Learning Resources

English (recommended)

CodeAcademy
Learn PHP basics for free at CodeAcademy

Learn PHP basics for free at CodeAcademy

If you can read English but want to learn PHP less boring, you should try this basic PHP course. The reason why I like to study at CodeAcademy is because you learn and practice at the same time, that is, you will learn new knowledge through solving exercises from their suggestions, doing it once is remembering for a long time.

See more:  Instructions for creating Widgets yourself
200 videos to learn PHP by TheNewBoston
Learn PHP from basic to advanced for free through video

Learn PHP from basic to advanced for free through video

TheNewBoston is a very famous coding channel on Youtube, and if you want to learn PHP, don’t know this channel yet, try their set of PHP lessons from basic to advanced. With 200 extremely detailed, easy-to-listen tutorials, you can master PHP knowledge because not only learn but this series also has very intuitive tutorials.

PHP the right way

phptherightwayIf you’ve ever learned programming, have mastered a few languages ​​and want to get started with PHP, you should start here. The name says it all, this is a handbook to guide you to learn PHP in the right way, updated with the latest knowledge base because there are many outdated PHP tutorials online. If you follow this manual, I think your knowledge of PHP will not be bad.

Learn PHP for WordPress and Essential Resources 15

Vietnamese

QHOnline
Learn PHP through video at QHOnline

Learn PHP through video at QHOnline

A few years ago, this is where I learned basic PHP and then advanced PHP. With an easy-to-understand teaching method through videos, with accompanying practice exercises, I believe you can understand PHP in the simplest way without having to cram too many complicated definitions.

PHP Resources in WordPress

Here are useful links so you can look up the WordPress source code when needed.

PHP Coding Standard

To avoid your code being hard to read, WordPress has compiled a coding standard in WordPress to make it more readable, in sync with the source code so if possible, check out their PHP writing rules for writing. better code.

WordPress Code Reference

If while learning advanced WordPress or coding in WordPress, you encounter a function that is difficult to understand or want to find a function, you can use this page to look it up. There you can get to know the details of the code snippets in WordPress, as well as how to use it, which you will use most of the time.

Learn PHP for WordPress and Essential Resources 15

WordPress Plugin Handbook

Don’t know the necessary knowledge in WordPress to be able to program plugins? Take a look at this handbook, which details the sequence of knowledge required to be able to write plugins in WordPress.

Epilogue

Although I have not posted a series of learning PHP in WordPress, hopefully with the resources and tips above, you can have a clearer plan to learn PHP, know what you learn for and how to learn to. can work in WordPress.

Wish you soon master WordPress programming!


Source: Learn PHP for WordPress and Essential Resources
– TechtipsnReview

, , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *