Tag Archives: tips

Ways to Use Google Apps Script to Fetch Databases to a Google Spreadsheet

How to Use Google Apps Script to Fetch Databases to a Google Spreadsheet_YWF

It is pretty common to export information from a WordPress database to an Excel sheet or in a CSV format. However, you may realize that there is a problem with exporting and importing files. One of the most common ones is that the process is sometimes not too intuitive and all files need to be updated at regular intervals.

However, now you can forget those old days, as today, you can solve the problem by using Google Apps Script to link your WordPress database to a Google spreadsheet which automates the workflow. As a web developer, you surely want to know how a Google Apps Script can be used to fetch database values from WordPress through the Google Apps Script Spreadsheet Service. So, here is some information about it that you need to know.

What is Google Apps Script?

Through Google Apps Script, you can automate tasks across Google products and third party services and build web applications. In many cases, Google Apps Script is also known as a JavaScript cloud scripting.

This is why you can do a lot of new things with Google Apps like Docs, Sheets, and Forms through the Google App Script. Other benefits that you can get from the Google App Scripts are:

  • Add custom menus, dialogs, and sidebars to Google Docs, Sheets, and Forms.
  • Write custom functions for Google Sheets
  • Publish web apps – either standalone or embedded in Google Sites
  • Interact with other Google services, including AdSense, Analytics, Calendar, Drive, Gmail, and Maps.

Furthermore, with the Google Apps Script Spreadsheet service, you can create access and modify Google Sheets files.

Creating a Google Apps Script with Spreadsheet

If you want to create a Google Apps Scripts with Spreadsheet, the steps will be as follows:

  • Create a New Spreasheet
  • Click on “Tools ->Script Editor”
  • The editor window will appear in a new tab
  • When writing the script, there are several Classes and methods that you can choose. Some of them are as follows:
  1. Classes
  • BorderStyle
  • DataValidation
  • ContainerInfo
  • Range
  1. Methods
  • getChartType()
  • getRanges()
  • setColours()


Below is the Sample app script example that will store the spreadsheet data into the log:

function logProductInfo() {

var sheet = SpreadsheetApp.getActiveSheet();

var data = sheet.getDataRange().getValues();

for (var i = 0; i < data.length; i++) {

Logger.log(‘Product name: ‘ + data[i][0]);

Logger.log(‘Product number: ‘ + data[i][1]);



  • Don’t forget to debug the script after writing the script. You can debug the icon easily by clicking on debug icon and if debugging is successful with no error then you can “Run” the script by clicking on run icon.
  • Click on “View->Logs” to view the Log.

 Google Apps Script and WordPress

You can also use Google Apps Script with WordPress in many ways. For example, you can connect with the WordPress database. Via JDBC service, Google Apps Script can access many relational databases. It is actually a wrapper around the standard Java Database Connectivity standard. In Google Apps Script, the JDBC service supports the Google Cloud SQL, MySQL, Microsoft SQL Server, and Oracle databases.

You can read the following example that will demonstrate the database connection:

function myFunction() {// make the connectionvar connection = Jdbc.getConnection(“jdbc:mysql://db IP or host name:port number/DB name”, “User name”, “password”);// perform the queryvar SQLstatement = connection.createStatement();var result = SQLstatement.executeQuery(“SELECT * FROM DB_NAME”);// choose a range in sheetvar ss = SpreadsheetApp.getActiveSpreadsheet();var cell = ss.getRange(‘A2’);// loop through result object, setting cell values to database datavar row = 0;while(result.next()) {for(var i=0; i<4; i++) { // four fields per recordcell.offset(row, i).setValue(result.getString(i+1));}row++;}// tidy upresult.close();SQLstatement.close();connection.close();}

By running this code, you will get the values from the database and add the fetched values into the currently active spreadsheet. You can also add values into the database, in which those values can be used in WordPress. For instance, it is possible to register all of the users’ data in a spreadsheet in one go through the Google Apps Script.


In order to easily map your WordPress database to a Google Spreadsheet, you can use the Google Apps Script. Another advantage that you can get by applying this method is that you can simply run this script to update your spreadsheet as per your database. Furthermore, you don’t need to constantly import and merge files in order to keep your online and offline databases in sync. This makes this application highly useful, especially for developers who want to use Google APIs for many purposes.

How to Create a Design that Satisfies


Believe it or not, working as a designer or web designer will require you to know your users and motivate them. You might think that designers sound like phycology, but this is actually important for designers to acknowledge a little knowledge of phycology, especially about motivation and how to apply a good motivation in their design, since by utilizing good motivation on your design, you will provide strong reasons for users to take an action for buying your product. Take a look further on how motivation can really affect your design, such as follows.

What is Motivation?

Motivation is famously known as something that can encourage people. It gives motives, needs or wants that drive behavior and explain why people do something. In design, motivation is also needed; it could help designers see the direct way to make the product correspondent to users’ expectations and solve user’s problems. However, before your product can help users, first you have to create a product that can motivate users to try it.

There are two types of motivation that we know, extrinsic motivation and intrinsic motivation:

Extrinsic motivation

These motives come from outer sources, such as family, professional environment, competitions, contests, etc. In most cases, people who have extrinsic motivation are usually seeking of reward, such as money, prizes, diplomas, certificates, trophies, medals, praise, support, recognition, or the desire to compete with others. As a designer, we can discover users’ extrinsic motives through research for UX designers. Once we know their extrinsic motivation, we can create a design that can stimulate them.

Intrinsic motivation

Oppositely, intrinsic motivations come from inner sources, such as the need of self-improvement. This type of motivation is stronger than extrinsic motivation. If you can nail this motivation from a user, it will become a significant factor for retaining users. Therefore, it is important to get to know more about target audience at the stage of user research; in this way, designers can discover what their motives are and what kind of designs that will work for the specific users.

Knowing the types of motivation will surely help designers in creating a design that will attract and serve users best. In fact, this knowledge is necessary for UI/UX designers for several reasons, such as follows:

  • Building navigation and call-to-action elements that can truly engage to users and motivate them to take action.
  • Designing better layouts that can demonstrate key benefits or rewards.
  • Creating a process that can motivate users to try the product and test its functions.
  • Presenting aesthetic satisfaction so that users feel comfortable with your product.
  • Providing the copy that can stimulate users through describing the benefits and achievements of your product.
  • Encourage users to share their experience via various social networks; this can be a powerful extrinsic motive for other people nowadays.

Now that you know motivation is terribly important in design, by understanding users’ motivation, you can build the right design that can reach many users. So, don’t forget to analyze your users’ motivation before designing for them.


All About WordPress’ Protection: How Secure is WordPress?


As one of the most used websites in the world, WordPress has mostly been trusted by people for many purposes; however, many web developers are still wondering about whether or not WordPress is secure, since it surely has its flaws too. It is definitely not only the WordPress team’s responsibility to protect the underlying core of WordPress, but the responsibility also ultimately falls on your shoulders too.

Since WordPress is generally discussed online, consequently, the weaknesses of the platform are widely known. This is why hackers can easily target WordPress websites. Therefore, it is important to learn about how secure a WordPress is. Let’s figure out the explanation below.

What You Need to Know About the WordPress Project and Security

Below are things that you may need to know, regarding the WordPress Project and what they are doing to maintain the security of the core.

The WordPress Security Team

The WordPress security team is responsible for identifying security risks in the core. Aside from that, they are also good at reviewing potential issues with the third-party-submitted themes or plugins and then making recommendations on how they can harden their tools or patch known breaches. They also work on their own to identify and resolve issues, even though they may need some other experts in the field sometimes.

How WordPress identifies Security Risks

There are several ways that are used by the security risks to identify and resolute process work.

  • An issue can be identified by anyone. It can be someone from the security team or from outside of the team. For non-project members, you can communicate these detected issues by emailing security @wordpress.org.
  • A report is logged and the security team acknowledges receipt of it.
  • To verify that the threat is valid, team members need to work together on a walled-off and private server.
  • Then, they can track, test, and repair any security flaws detected.
  • After that, the security patch then gets added to the next minor WordPress release.
  • If you have a mild problem, WordPress will notify you within the WordPress dashboard whenever an automatic release occurs.
  • On the other hand, the release will go out immediately and WordPress.org will announce it on the News page of the website in more urgent issues.

Even though WordPress doesn’t always announce these security patches immediately, they will always take immediate action to resolve problems.

A Note about Automatic Updates

WordPress is able to push minor updates automatically to all websites, since version 3.7. In this way, the WordPress security team can get urgent patches out as timely as possible without having to wait for users to accept and make the update on each of their websites.

However, as a WordPress user, you can opt out of these automatic core updates. In fact, if this happens to you, please keep in mind that this may put your site at additional risk, especially when you don’t have time to monitor all your sites all the time for the latest and greatest update.

WordPress Plugins and Themes Security

Even though it may sound impossible to manage the  tens of thousands of plugins and themes out there, at least WordPress can keep a close eye on them to ensure nothing seriously insecure slips through the cracks.

When a security issue is detected, the WordPress Project is the team, responsible for working with developers. However, before that, there is a team of volunteers assigned to review each and every theme or plugin submitted to WordPress. This team is specially formed to work with developers and ensure that best practices are followed.

Nevertheless, there will always be security vulnerabilities found and that’s why we need security team to step in to:

  • Provide documentation for WordPress developers on plugin and theme development and security best practices.
  • Monitor plugins and themes for potential security flaws. Any issues detected will then be brought to the attention of the developer.
  • Remove harmful plugins or themes from the directory if the developers are unresponsive or uncooperative.

Later, when those security patches are available, WordPress will then notify its users via the WordPress admin.

OWASP’s Top 10

With the purpose of protecting organizations from software and programs that could potentially do harm, the Open Web Application Security Project (OWASP) Foundation was created back in 2001. What you may be surprised to learn is that the WordPress Project aims to abide by OWASP’s Top at all times.

Below are the top 10 list comprised by the OWASP of known and very serious security risks. By using the list, the WordPress security team uses those trends to define their own top 10 list of ways to defend the core. Basically, their goal is to protect the core from the following risks:

  1. User account management abuse
  2. Unauthenticated access requests to the WordPress admin
  3. Unwanted or unauthorized redirects
  4. Exposing users’ private data
  5. Requests for access to direct object reference
  6. Server misconfiguration
  7. Unauthorized code injection
  8. Cross-site scripting from unauthorized users
  9. Cross-site request forgeries whereby hackers misuse WordPress nonces
  10. Corrupted third-party plugins, themes, frameworks, libraries, etc.


Knowing that there is a dedicated team working that keeps the WordPress core secure at all times will surely let WordPress users feel at ease. Still, we have to do what we can do to secure it from every angle, since no matter how good the WordPress Project is at monitoring and securing the platform, hackers will find a way in.