Data, Maps, Usability, and Performance

API canvas d3 data geo GeoJSON html5 image JavaScript json maps mysql PHP WordPress

Results for tag: PHP

Sort WordPress Posts by Modified Date using a URL Param

List Posts by Recently Updated in WordPress

After updating a few older articles on this blog I have realized that it would be useful to provide a display where all my posts are sorted by last modified date instead of created date. I imagine it would just be a link that someone can click and it would change the WP query so that recently updated posts are displayed in descending order. Everything else stays the same. You can see it in action on my homepage and today I will cover how you can do that with two simple WordPress functions.
Read more

Managing and Displaying New Fields for WordPress Users

how to add new attributes to wordpress users

WordPress provides a lot of different hooks that allow you to expand on user management capabilities. You can easily add a new field or attribute for any user and make it editable in the user profile. You can restrict the edit mode to only Administrators and you can visualize any of these new user data points in the main Admin Users table.

So, today, I will write a quick WP Plugin that adds a new user field called credits to all users, which can be updated by Admins in the user profile. The WordPress plugin will also display that field in the Users table along with a new read only field that captures users last login date and time.
Read more

WordPress Plugin with Background Process, Queue, and Debugging

background processing sample WP plugin for async tasks

WordPress Plugins are often used to run a large process in the background like importing, exporting, bringing data from other APIs, pushing data out, and other tasks that should run asynchronously. How do you do that? TechCrunch came out with wp-async-task and WP Background Processing extended that by adding the ability to queue tasks. The author already included a good sample plugin and article but I wanted to see if I can write a more basic example. So, today, I will create a WordPress plugin that uses WP Background Process to queue and run PHP tasks in the background.
Read more

Repeatable Field Creation and Inline Edit with Fromidable Forms

Formidable Forms Repeatable Field PHP

Last year I wrote an article on Gravity Forms and now I want to follow up with something on Formidable Forms. Instead of doing a comparison between these two WordPress plugins, I will write about two problems that I have encountered with FormidableForms and explain how I have resolved them. The first one is based on the backend, PHP code that will create repeatable fields inside a form and the second one goes into the front end, JavaScript code that helps hooking into “in-place” edit.
Read more

Editing Gravity Forms Entries on The Front-End

edit gravity forms on frontend

If you are using WordPress and the Gravity Forms plugin, you might want to allow users to edit their posts or entries on the front-end. This is not supported by the plugin but there are other plugins or addons like Gravity Forms Edit Entries, Gravity Forms Sticky List, Gravity Forms: Post Updates, and GravityView that provide such functionality. But, they also come with other features that you might not want or need and installing more and more plugins can certainly impact performance. Moreover, a few of the plugins that I have tried would create and delete entries in GravityFroms causing missing Entry IDs which isn’t ideal and it is additional work on the system. Today, I will show you how to edit Gravity Forms entries on a page by simply using GF actions, hooks, and the API.
Read more

Automate SlideShare Creation with JavaScript and APIs

programmatic automation

I am a big fan of SlideShare and automation so today I want to show how you can programatically create a slideshow with JavaScript and upload it to your account with the SlideShare API. I am going to use jsPDF to generate a PDF file from images and text. When the pdf is created, I will use the upload_slideshow API call to upload the pdf into awesome slides on SlideShare. And the slides will be the actual steps to do this. Let’s start.
Read more

Save File with Ajax and PHP

Today, I am going to go over a simple example of saving content from a web page to your server. Imagine a textarea with a save button, which grabs the text from the user input and sends it to your server. There PHP grabs the data and writes it into a unique file. Our php script will respond to the Ajax request with the file name in a link so that the end user can retrieve it directly through another web request.
Read more

WordPress on VPS with Nginx and PHP APC

wordpress on nginx

It was time to pay the yearly fee for shared hosting and I decided to check out some VPS options. Performance was not really a problem as WordPress caching plugins do a good job but I wanted more control of the stack and VPS pricing is not that far off from shared hosting. DigitalOcean plans start at 5 dollars and you get 1 Core with 512MB Memory, 20GB SSD Disk, and 1TB of Transfer. You can setup a droplet in 1 minute and you can pay month to month. No wonder they are doing so well, it makes sense to just try them out. They also have great documentation, API, and an easy to use control panel. Here are some details on how I moved my WordPress blog from shared hosting to VPS and made it really fast with Nginx, PHP APC, and Super Cache.
Read more

Creating a WordPress Plugin Admin Page

Creating wp plugin options page

If you are building a WordPress plugin, there is a high chance that you want to create a backend page, perhaps a place for Admin settings or options. This post will cover how to do that and I will also build a WP Plugin which has an Admin page that interacts with the WordPress database. The plugin will render a mySQL table in a HTML table with dynamic JavaScript features like sorting, searching, etc. I will show how to include specific JavaScript and CSS files for the plugin Admin page and how to interact with WordPress mySQL tables. The cool think about a plugin admin page is that you can use it test all kinds of WordPress Database queries.
Read more

Leaflet Map Markers with API Caching

caching API calls with PHP

LeafLet Map showing Flickr and Panoraimo Photos with Caching

I was looking at my OpenLayers Flickr And Panoraimo Demo today and I realized that plotting anything on a map with data that comes from an external API should leverage the server. The most important reason for this is caching but there are other benefits. You don’t have to deal with any cross-domain policy or hope for JSONP support since the communication with the API will be server-side. Also, it’s not secure to have API keys in your JavaScript as they can easily be taken, especially with search engines like NerdyData. So, it’s good practice to have these keys on the server. Today, I am going to explore some caching options in PHP and show how to create a nice Leaflet Map with markers generated by API calls that are cached on the server.
Read more