Series of learning videos Programming weather forecast plugin (TP Weather)

One of the questions I get a lot from readers at TechtipsNReview.com is how to program a plugin in WordPress yourself, both those who have programming experience and those who don’t know how to program. Everyone knows that WordPress is an open source CMS written in the PHP language, so if you want to touch the core part (also known as the core part of the source code), you must have a solid grasp of PHP knowledge, including programming. theme or plugin programming.

If you have no knowledge of PHP, I recommend you learn PHP basics to understand what we’re doing. And if you already have PHP knowledge but have no experience in plugin programming, this video series will help you with that.

About the author

This set of plugin programming learning videos was not filmed by me, but by a PHP lecturer at QHOnline.Info named An Vu who participated in teaching at my invitation, but anyway it is a learning series for readers. at TechtipsNReview.com like other series I did.

Overview of the series’ content

In this series, although we will be writing a plugin with one function of getting weather forecast information of provinces, with that example you will know better how to deploy a plugin and how to write a plugin according to the model. Professional code image, convenient for later upgrade.

More specifically, with the app that gets the weather forecast information through a free API, you’ll learn how to apply JSON-style data processing, AJAX applications to get that information out to the widget, and especially use transient to save Object Cache to reduce the load on the server.

See more:  8 Best Starter Themes that support self-designing themes

As for how to go deeper, you will discover for yourself when watching the video.

Resources

Before starting to follow the video, please download the source file available here, it’s just a template with HTML and CSS so you don’t have to waste time rebuilding the template.

Download the prepared source file

Series of videos to learn Programming weather forecast plugin (TP Weather) 15

And if you have a need to refer to the code, please download the completed source code file below.

Download completed source code

List of lessons

  1. [Lập trình plugin TP Weather] – Part 1 – Action & Filter hook overview
  2. [Lập trình plugin TP Weather] – Part 2 – Plugin creation and API overview
  3. [Lập trình plugin TP Weather] – Part 3 – Creating an API interaction library
  4. [Lập trình plugin TP Weather] – Part 4 – Building weather widgets
  5. [Lập trình plugin TP Weather] – Part 5 – Weather widget and Settings
  6. [Lập trình plugin TP Weather] – Part 6 – Finish building Settings
  7. [Lập trình plugin TP Weather] – Part 7 – Finished building the Weather Widget
  8. [Lập trình plugin TP Weather] – Last part – Cache weather data

Playlist on Youtube: https://www.youtube.com/playlist?list=PLl4nkmb3a8w2mZDbIzTb5mLI9tcjXxV7M

Replace the file_get_contents() function

When watching the Video, you also see the inadequacy from the function file_get_contents() then is it true? Sometimes, this function has an error that causes the data to be loaded incorrectly.

Series of videos to learn Programming weather forecast plugin (TP Weather) 15

So to be able to limit this, WordPress has also provided us with some specialized functions to do this. You can replace the following code in the library TP_Weather_API that we created earlier by replacing the functions with the corresponding code as follows:

See more:  Instructions to install Wordfence Security for WordPress

Find:

@$fget = file_get_contents($url);
if ($fget) {
return self::get_JSON($fget);
}

Series of videos to learn Programming weather forecast plugin (TP Weather) 15

Change to

@$fget = wp_remote_get($url);
if ($fget) {
return self::get_JSON($fget[‘body’]);
} else {
return false;
}

And similar to the request method in the API library to :

Series of videos to learn Programming weather forecast plugin (TP Weather) 15

@$fget = wp_remote_get($url);
if ($fget) {
$return[] = self::get_JSON($fget[‘body’]);
}

Good luck!

Rate this content


Source: Series of learning videos Programming weather forecast plugin (TP Weather)
– TechtipsnReview

, , , , , ,

Leave a Reply

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