David Stockdale's Scrapcode

My Plugins

As I continued with my volunteer work I found myself working on a few useful pieces of code. I was encouraged to work on transforming several into plugins that could be released for public use.

These plugins may not all be up to current industry standards depending on how far along I am in the process of creating them (and if I happen to know those standards exist).

David Scroller

A plugin designed to make it as easy as possible to display a number contained by a cell within a Google Spreadsheet as a scrolling number.

Version: 1.0.1 (Needs more documentation and comments?)

Version: 1.0.5 (Testing settings, still needs more documentation and comments?)

Credits:

  •  WordPress-Plugin-Boilerplate A boilerplate plugin used as a starting point (as at this point I knew nothing about the requirements of such a plugin).
  •  NumScroller A JQuery Plugin incorporated as part of the plugin.

Instructions:

The plugin is fairly simple, as long as you have your API Keys and SpreadSheet IDs stored in your Options Database Table you need only use the shortcode (examples below) in your post/page for the plugin to function.

Remember to make your Google SpreadSheet sharable by link (as the spreadsheet cannot be accessed if it is hidden away).

Adding/Updating API Keys and SpreadSheet IDs:

/**
 * Stores/updates the array of Api Keys within the options database table.
 */
update_option( 'api_key_array', array(1 => "XXX_XXX"), true );

To get the API Key goto the “Google Developers Console” and create a key in the “Credentials” section.

/**
 * Stores/updates the array of SpreadSheet IDs within the options database table.
 */
update_option( 'spreadsheet_id_array', array(1 => "XXX-XXX-XXX",
											 2 =>"XXX-XXX"), true );

To get the SpreadSheet ID simply look in the “Sharable Link” (broken down here):

https://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=sheetId

Shortcode Examples:

Required Parameters:
Location, Key and ID:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2]

OR

Location (using “Named Range”), Key and ID:
[david_scroller location="NamedRange1" api_key=1 spreadsheet_id=2]

Optional Parameters:
Delay:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2 delay=10]
Increment:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2 increment=1]
Minimum:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2 min=4]
Default:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2 default=999]
Using All Parameters At Once:
[david_scroller location="'Summary Page'!C3" api_key=1 spreadsheet_id=2 delay=10 increment=1 min=4 default=999]

Leave a Reply