Class ToppaWPFunctions

Description

A collection of static methods facilitating common tasks for WordPress plugins.

  • author: Michael Toppa

Located in /ToppaWPFunctions.php (line 21)


	
			
Method Summary
 static mixed createTable (object an &$object, string $table)
 static void displayInput (string $input_name, array $ref_data, [string $input_value = null])
 static boolean|array parseFeed (array $feed_content, array $ref_data, [string $match_field = null], [string $match_value = null], [string $key = null])
 static array readFeed (string $feed_url, boolean $cache)
 static mixed sqlDelete (string $table, string|array $conditions)
 static mixed sqlInsert (string $table, array $fields, [array $values = null], [string $update = false])
 static mixed sqlSelect (string $table, [string|array $keywords = null], [string|array $conditions = null], [string $other = null], [string $type = 'get_row'], [string $return = ARRAY_A])
 static mixed sqlUpdate (string $table, array $fields, [string|array $conditions = null])
 static string|float|integer _sqlEscape (string|float|integer $value)
 static string _sqlPrepare (array $conditions, [string $glue = " and "], [boolean $values_only = false])
Methods
static createTable (line 33)

Creates or updates a WordPress table, based on ref_data in a passed-in object. Note that dbDelta is very picky about formatting - see http://codex.wordpress.org/Creating_Tables_with_Plugins

  • return: passes along the return value of WordPress' dbDelta()
  • access: public
  • usedby: Shashin::install()
mixed createTable (object an &$object, string $table)
  • string $table: The name of the table to create
  • object an &$object: object containing the ref_data needed for defining the table.
static displayInput (line 346)

Generates and echoes xhtml for form inputs.

Checkbox groups are currently hardcoded to a 3 column display.

void displayInput (string $input_name, array $ref_data, [string $input_value = null])
  • string $input_name: (required) the name to use for the input field
  • array $ref_data: (required) contains data about how the input field should be set up
  • string $input_value: (optional) a value to apply to the input
static parseFeed (line 444)

The function is for parsing the Picasa RSS feed. It assumes an

array of items, with keys that may have a : dividing the names of related items, and containing an array with a 'data' value and a possible 'attrs' array

boolean|array parseFeed (array $feed_content, array $ref_data, [string $match_field = null], [string $match_value = null], [string $key = null])
  • array $feed_content: should be supplied by the readFeed function
  • array $ref_data: maps your local data structure to the feed's structure; it can handle arrays nested two levels below $item
  • string $match_field: allows you to limit the results of the parse to a specific item
  • string $match_value: the value to look for in $match_field
  • string $key: allows you to use an item from the feed as the key for the returned array
static readFeed (line 424)

Reads an RSS feed. Uses the included ToppaXMLParser.

array readFeed (string $feed_url, boolean $cache)
  • string $feed_url: the feed to parse
  • boolean $cache: whether or not to cache the feed
static sqlDelete (line 267)

Creates and executes a SQL delete statement based on passed-in parameters.

If $conditions is an array, it will escape values. If it's a string, it must contain the WHERE keyword, and the values must be escaped before calling this function.

mixed sqlDelete (string $table, string|array $conditions)
  • string $table: the name of the table to query
  • string|array $conditions: array of key-values pairs, or a string containing its own WHERE clause
static sqlInsert (line 220)

Creates and executes a SQL insert statement based on passed-in parameters.

If you pass $fields and $values, they are treated as the name-value pairs to update, and are related positionally. If you pass $fields only, it assumes its actually a hash of key-value pairs. All values are escaped. Note the update option currently works only if $fields contains key- value pairs.

mixed sqlInsert (string $table, array $fields, [array $values = null], [string $update = false])
  • string $table: the name of the table to query
  • array $fields: column names or a hash of key-value pairs
  • array $values: (optional) the values to insert if $keys is only a list of columns
  • string $update: (optional) run an update instead if the insert would cause a duplicate key on a unique index (default: false)
static sqlSelect (line 95)

Creates and executes a SQL select statement based on passed-in parameters.

If $conditions is an array, it will escape values. If it's a string, it must contain the WHERE keyword, and the values must be escaped before calling this function.

mixed sqlSelect (string $table, [string|array $keywords = null], [string|array $conditions = null], [string $other = null], [string $type = 'get_row'], [string $return = ARRAY_A])
  • string $table: the name of the table to query
  • string|array $keywords: the fields to return
  • string|array $conditions: (optional) array of key-values pairs, or a string containing its own WHERE clause
  • string $other: (optional) any additional conditions for the query (GROUP BY, etc.)
  • string $type: (optional) the WP type of select query to run (default: get_row)
  • string $return: (optional) how to format the return value (default: ARRAY_A)
static sqlUpdate (line 170)

Creates and executes a SQL update statement based on passed-in parameters.

It will escape values in the $fields array. If $conditions is an array, it will escape values. If it's a string, it must contain the WHERE keyword, and the values must be escaped before calling this function.

mixed sqlUpdate (string $table, array $fields, [string|array $conditions = null])
  • string $table: the name of the table to query
  • array $fields: name-value pairs of the fields to update
  • string|array $conditions: (optional) array of key-values pairs, or a string containing its own WHERE clause
static _sqlEscape (line 330)

Escapes and quotes values for safe inserting/updating to the database

  • return: returns $value, escaped and quoted as needed
  • access: private
string|float|integer _sqlEscape (string|float|integer $value)
  • string|float|integer $value: a value to escape
static _sqlPrepare (line 306)

Builds a properly formatted partial SQL clause of key-value pairs, with values escaped.

  • return: a formatted partial SQL clause of key-value pairs
  • access: private
string _sqlPrepare (array $conditions, [string $glue = " and "], [boolean $values_only = false])
  • array $conditions: key-value pairs to use in building the query string
  • string $glue: (optional) glue for concatenating the name-value pairs (default: " and ")
  • boolean $values_only: (optional) whether to include values only in the string (default: false)

Documentation generated on Wed, 01 Jul 2009 07:48:18 -0400 by phpDocumentor 1.4.2