Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.6 More Site Information

In this lesson, I'll show you a few more methods that are available for getting information about the site.

2.6 More Site Information

Hello everyone, I am Reggie Dawson. Welcome to the Get Started with WPCOM.js course for Tuts+. I know throughout the course I mentioned the overlap with methods offered by Site. We used Site earlier to return a list of post. In this video, we'll look at some more of the method that we can use with Site. The first method you will look at is the site.get method. This method will return some information about the WordPress site. Unlike get that we use with me, this is not going to be token information. We can easily change the displayMe function in use get. First, of course, we create a reference to Site. After that, we use the reference with get. Once we do that, again, we are just logging the information. Go ahead and save and preview the project. Then click on the Display Me information with the Developer's Tools console open. Using get with site we return information such as the capabilities you have such as whether you publish or edit post. In also shows which plane you are on, quota and site options among other information. This method is useful displaying information that will important to the administrator of a WordPress site. Now the usersList method allows us to display a list of the users of the site. Again, this would be useful for the administrator of the site. We can easily replace the get method with usersList. Go ahead and save the project and preview it. Make sure the Developer's Tools are open and click on the Display Me Information button again. Now if we drill down into the array, we can see the users of the WordPress site. In addition to the log in information and email, it also has the roles of the user. In my case since I am the only user of the WordPress site, I am the administrator. Now in the last video we looked at the media methods. We can also add and delete media files using Site. Also with Site we can list all of the media objects that we have. This time we will switch usersList with mediaList. Go ahead and save the project and preview. Now when we click the button we should get a list of all of the media objects in our WordPress site. If we expand the returned object we can see all of the properties of our media. With this information, we could easily build a listing of media objects. With the additional functionality of being able to update or delete media objects, we could build an admin interface for your media. Now finally, the last part of Site that we haven't talked about yet are the stats. This allows you to view a variety of stats about your WordPress site. This information could easily be expanded upon and displayed in a custom dashboard. We can view stats for clicks, comments and more, but for now we will just grab some basic stats. Go ahead and save your project then preview. Just this basic view of stats serves to be very useful. These stats track the views and visitors over a period of time. Knowing how this data is laid out, you could easily display this in some sort of graph or chart. As you can see, the methods available from site give you most of the features you need to setup a full app using WordPress.com. In the next video, we will look at how we can make use of what we have learned about WPCOM.js.

Back to the top