Base class for the SD series of Wordpress plugins. More...
Public Member Functions | |
| __construct ($filename) | |
| activate () | |
| deactivate () | |
| deactivate_me () | |
| admin_init () | |
| admin_uninstall () | |
| load_language ($domain= '') | |
| _ ($string) | |
| uninstall () | |
| query ($query, $wpdb=null) | |
| query_single ($query) | |
| query_insert_id ($query) | |
| sql_encode ($object) | |
| sql_decode ($string) | |
| sql_table_exists ($table_name) | |
| get_user_role () | |
| roles_as_options () | |
| role_at_least ($role) | |
| user_id () | |
| delete_option ($option) | |
| delete_local_option ($option) | |
| delete_site_option ($option) | |
| fix_option_name ($option) | |
| deregister_options () | |
| get_option ($option) | |
| get_local_option ($option, $default=false) | |
| get_site_option ($option, $default=false) | |
| register_options () | |
| update_option ($option, $value) | |
| update_local_option ($option, $value) | |
| update_site_option ($option, $value) | |
| display_message ($type, $string) | |
| message ($string) | |
| message_ ($string, $args= '') | |
| Convenience function to translate and then create a message from a string and optional sprintf arguments. | |
| error ($string) | |
| error_ ($string, $args= '') | |
| Convenience function to translate and then create an error message from a string and optional sprintf arguments. | |
| array_insert ($array, $position, $new_array) | |
| Insert an array into another. | |
| array_sort_subarrays ($array, $key) | |
| Sort an array of arrays using a specific key in the subarray as the sort key. | |
| array_rekey ($array, $key) | |
| array_to_object ($array, $object=null) | |
| ago ($time_string, $time=null) | |
| check_plain ($text) | |
| display_form_table ($inputs, $options=array()) | |
| display_form_table_row ($input, $form=null) | |
| download ($filepath, $options=array()) | |
| Output a file to the browser for downloading. | |
| filters ($filter_name) | |
| form ($options=array()) | |
| hash ($string, $type= 'sha512') | |
| implode_html ($prefix, $suffix, $array) | |
| Implode an array in an HTML-friendly way. | |
| minmax ($number, $min, $max) | |
| mime_type ($filename) | |
| now () | |
| object_to_array ($object) | |
| p ($string, $args= '') | |
| wpautop's a string, using sprintf to replace arguments. | |
| p_ ($string, $args= '') | |
| wpautop's a translated string, using sprintf to replace arguments. | |
| rmdir ($directory) | |
| send_mail ($mail_data) | |
| slug ($string) | |
| strip_post_slashes ($post=null) | |
| strtolower ($string) | |
| strtoupper ($string) | |
| tab_slug ($string) | |
| tabs ($options) | |
| time () | |
| wrap ($title, $text) | |
| Outputs the text in Wordpress admin's panel format. | |
Public Attributes | |
| $paths = array() | |
Protected Attributes | |
| $is_network | |
| $site_options = array() | |
| $local_options = array() | |
| $options = array() | |
| $language_domain = '' | |
| $wpdb | |
| $roles | |
Base class for the SD series of Wordpress plugins.
Provides a simple framework with common Wordpress functions.
| SD_Meeting_Tool_Base::__construct | ( | $filename | ) |
Construct the class.
| $filename | The full path of the parent class. |
| SD_Meeting_Tool_Base::_ | ( | $string | ) |
Translate a string, if possible.
Like Wordpress' internal _() method except this one automatically uses the plugin's domain.
Can function like sprintf, if any s are specified.
| $string | String to translate. s will require extra arguments to the method. |
| SD_Meeting_Tool_Base::activate | ( | ) |
Overridable activation function.
It's here in case plugins need a common activation method in the future.
Reimplemented in SD_Meeting_Tool, SD_Meeting_Tool_elections, SD_Meeting_Tool_Speakers, SD_Meeting_Tool_Displays, SD_Meeting_Tool_Agendas, SD_Meeting_Tool_Lists, SD_Meeting_Tool_Printing, SD_Meeting_Tool_Participants, SD_Meeting_Tool_Display_Formats, SD_Meeting_Tool_Actions, SD_Meeting_Tool_List_Sorts, and SD_Meeting_Tool_Registrations.
| SD_Meeting_Tool_Base::admin_init | ( | ) |
Filter for admin_init.
Reimplemented in SD_Meeting_Tool_Printing.
| SD_Meeting_Tool_Base::admin_uninstall | ( | ) |
Shows the uninstall form.
Form is currently only available in English.
| SD_Meeting_Tool_Base::ago | ( | $time_string, | |
$time = null |
|||
| ) |
Display the time ago as human-readable string.
| $time_string | "2010-04-12 15:19" |
| $time | An optional timestamp to base time difference on, if not now. |
| SD_Meeting_Tool_Base::array_insert | ( | $array, | |
| $position, | |||
| $new_array | |||
| ) |
Insert an array into another.
Like array_splice but better, because it even inserts the new key.
| $array | Array into which to insert the new array. |
| $position | Position into which to insert the new array. |
| $new_array | The new array which is to be inserted. |
| SD_Meeting_Tool_Base::array_rekey | ( | $array, | |
| $key | |||
| ) |
Make a value a key.
Given an array of arrays, take the key from the subarray and makes it the key of the main array.
| $array | Array to rearrange. |
| $key | Which if the subarray keys to make the key in the main array. |
| SD_Meeting_Tool_Base::array_sort_subarrays | ( | $array, | |
| $key | |||
| ) |
Sort an array of arrays using a specific key in the subarray as the sort key.
| $array | An array of arrays. |
| $key | Key in subarray to use as sort key. |
| SD_Meeting_Tool_Base::array_to_object | ( | $array, | |
$object = null |
|||
| ) |
Convert an array to stdClass, or appends the $array to an existing $object.
| $array | Array to convert. |
| $object | Existing object, if any, to append data to. |
| SD_Meeting_Tool_Base::check_plain | ( | $text | ) |
| SD_Meeting_Tool_Base::deactivate | ( | ) |
Overridable method to deactive the plugin.
| SD_Meeting_Tool_Base::deactivate_me | ( | ) |
Deactivates the plugin.
| SD_Meeting_Tool_Base::delete_local_option | ( | $option | ) |
Deletes a local option.
| $option | Name of option to delete. |
| SD_Meeting_Tool_Base::delete_option | ( | $option | ) |
Deletes a site option.
If this is a network, the site option is preferred.
| $option | Name of option to delete. |
| SD_Meeting_Tool_Base::delete_site_option | ( | $option | ) |
Deletes a site option.
| $option | Name of option to delete. |
| SD_Meeting_Tool_Base::deregister_options | ( | ) |
Removes all the options this plugin uses.
| SD_Meeting_Tool_Base::display_form_table | ( | $inputs, | |
$options = array() |
|||
| ) |
| SD_Meeting_Tool_Base::display_form_table_row | ( | $input, | |
$form = null |
|||
| ) |
| SD_Meeting_Tool_Base::display_message | ( | $type, | |
| $string | |||
| ) |
Displays a message.
Autodetects HTML / text.
| $type | Type of message: error, warning, whatever. Free content. |
| $string | The message to display. |
| SD_Meeting_Tool_Base::download | ( | $filepath, | |
$options = array() |
|||
| ) |
Output a file to the browser for downloading.
| $file | Path to file on disk. |
| $name | Downloaded file's name. |
| $mime_type | Optional mime_type. |
if ( isset($_SERVER['HTTP_RANGE']) ) { if ( ! function_exists( 'download_416' ) ) function download_416( $filesize ) { header('HTTP/1.1 416 Requested Range Not Satisfiable'); header('Content-Range: bytes *\/' . $o->filesize); // Required in 416. *\/ *\/ *\/ }
if (!preg_match('^bytes=*-*(,*-*)*$', $_SERVER['HTTP_RANGE'])) { { download_416( $o->filesize ); return; }
$ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6) ); foreach ( $ranges as $range ) { $parts = explode('-', $range); $start = $parts[0]; // If this is empty, this should be 0. $end = $parts[1]; // If this is empty or greater than than filelength - 1, this should be filelength - 1.
if ($start > $end) { download_416( $o->filesize ); return; } } } else
| SD_Meeting_Tool_Base::error | ( | $string | ) |
Displays an error message.
The only thing that makes it an error message is that the div has the class "error".
| $string | String to display. |
| SD_Meeting_Tool_Base::error_ | ( | $string, | |
$args = '' |
|||
| ) |
Convenience function to translate and then create an error message from a string and optional sprintf arguments.
| $string | String to translate and create into an error message. |
| SD_Meeting_Tool_Base::filters | ( | $filter_name | ) |
| SD_Meeting_Tool_Base::fix_option_name | ( | $option | ) |
Normalizes the name of an option.
Will prepend the class name in front, to make the options easily findable in the table.
| $option | Option name to fix. |
| SD_Meeting_Tool_Base::form | ( | $options = array() | ) |
Creates a new SD_Form.
| $options | Default options to send to the SD form constructor. |
| SD_Meeting_Tool_Base::get_local_option | ( | $option, | |
$default = false |
|||
| ) |
Gets the value of a local option.
| $option | Name of option to get. |
| $default | The default value if the option === false |
| SD_Meeting_Tool_Base::get_option | ( | $option | ) |
Get a site option.
If this is a network, the site option is preferred.
| $option | Name of option to get. |
| SD_Meeting_Tool_Base::get_site_option | ( | $option, | |
$default = false |
|||
| ) |
Gets the value of a site option.
| $option | Name of option to get. |
| $default | The default value if the option === false |
| SD_Meeting_Tool_Base::get_user_role | ( | ) |
Returns the user's role as a string.
| SD_Meeting_Tool_Base::hash | ( | $string, | |
$type = 'sha512' |
|||
| ) |
Returns a hash value of a string. The standard hash type is sha512 (64 chars).
| $string | String to hash. |
| $type | Hash to use. Default is sha512. |
| SD_Meeting_Tool_Base::implode_html | ( | $prefix, | |
| $suffix, | |||
| $array | |||
| ) |
Implode an array in an HTML-friendly way.
Used to implode arrays using HTML tags before, between and after the array. Good for lists.
| $prefix | li |
| $suffix | /li |
| $array | The array of strings to implode. |
| SD_Meeting_Tool_Base::load_language | ( | $domain = '' | ) |
Loads this plugin's language files.
Reads the language data from the class's name domain as default.
| $domain | Optional domain. |
| SD_Meeting_Tool_Base::message | ( | $string | ) |
Displays an informational message.
| $string | String to display. |
| SD_Meeting_Tool_Base::message_ | ( | $string, | |
$args = '' |
|||
| ) |
Convenience function to translate and then create a message from a string and optional sprintf arguments.
| $string | String to translate and create into a message. |
| SD_Meeting_Tool_Base::mime_type | ( | $filename | ) |
| SD_Meeting_Tool_Base::minmax | ( | $number, | |
| $min, | |||
| $max | |||
| ) |
Returns the number corrected into the min and max values.
| SD_Meeting_Tool_Base::now | ( | ) |
Returns WP's current timestamp (corrected for UTC)
| SD_Meeting_Tool_Base::object_to_array | ( | $object | ) |
Convert an object to an array.
| $object | Object or array of objects to convert to a simple array. |
| SD_Meeting_Tool_Base::p | ( | $string, | |
$args = '' |
|||
| ) |
wpautop's a string, using sprintf to replace arguments.
| $string | String to wpautop. |
| $args | Optional arguments to sprintf. |
| SD_Meeting_Tool_Base::p_ | ( | $string, | |
$args = '' |
|||
| ) |
wpautop's a translated string, using sprintf to replace arguments.
| $string | String to translate and then wpautop. |
| $args | Optional arguments to _() / sprintf. |
| SD_Meeting_Tool_Base::query | ( | $query, | |
$wpdb = null |
|||
| ) |
Sends a query to wpdb and return the results.
| $query | The SQL query. |
| $wpdb | An optional, other WPDB if the standard $wpdb isn't good enough for you. |
| SD_Meeting_Tool_Base::query_insert_id | ( | $query | ) |
Fire an SQL query and return the row ID of the inserted row.
| $query | The SQL query. |
| SD_Meeting_Tool_Base::query_single | ( | $query | ) |
Fire an SQL query and return the results only if there is one row result.
| $query | The SQL query. |
| SD_Meeting_Tool_Base::register_options | ( | ) |
Registers all the options this plugin uses.
| SD_Meeting_Tool_Base::rmdir | ( | $directory | ) |
Recursively removes a directory.
Assumes that all files in the directory, and the dir itself, are writeable.
| $directory | Directory to remove. |
| SD_Meeting_Tool_Base::role_at_least | ( | $role | ) |
Checks whether the user's role is at least $role.
| $role | Role as string. |
| SD_Meeting_Tool_Base::roles_as_options | ( | ) |
Returns the user roles as a select options array.
| SD_Meeting_Tool_Base::send_mail | ( | $mail_data | ) |
Sends mail via SMTP.
| $mail_data | Mail data. |
| SD_Meeting_Tool_Base::slug | ( | $string | ) |
Sanitizes a string.
| $string | String to sanitize. |
| SD_Meeting_Tool_Base::sql_decode | ( | $string | ) |
Converts a base64 encoded, serialized string back into an object.
| $string | Serialized, base64-encoded string. |
| SD_Meeting_Tool_Base::sql_encode | ( | $object | ) |
Converts an object to a base64 encoded, serialized string, ready to be inserted into sql.
| $object | An object. |
| SD_Meeting_Tool_Base::sql_table_exists | ( | $table_name | ) |
Returns whether a table exists.
| $table_name | Table name to check for. |
| SD_Meeting_Tool_Base::strip_post_slashes | ( | $post = null | ) |
| SD_Meeting_Tool_Base::strtolower | ( | $string | ) |
Multibyte strtolower.
| $string | String to lowercase. |
| SD_Meeting_Tool_Base::strtoupper | ( | $string | ) |
Multibyte strtoupper.
| $string | String to uppercase. |
| SD_Meeting_Tool_Base::tab_slug | ( | $string | ) |
Sanitizes the name of a tab.
| $string | String to sanitize. |
| SD_Meeting_Tool_Base::tabs | ( | $options | ) |
Displays Wordpress tabs.
| $options | See options. |
| SD_Meeting_Tool_Base::time | ( | ) |
Returns the current time(), corrected for UTC and DST.
| SD_Meeting_Tool_Base::uninstall | ( | ) |
Overridable uninstall method.
Reimplemented in SD_Meeting_Tool_Speakers, SD_Meeting_Tool_elections, SD_Meeting_Tool_Agendas, SD_Meeting_Tool_Displays, SD_Meeting_Tool_Lists, SD_Meeting_Tool_Printing, SD_Meeting_Tool_Actions, SD_Meeting_Tool_Participants, SD_Meeting_Tool_Display_Formats, SD_Meeting_Tool_List_Sorts, and SD_Meeting_Tool_Registrations.
| SD_Meeting_Tool_Base::update_local_option | ( | $option, | |
| $value | |||
| ) |
Updates a local option.
| option | Name of option to update. |
| $value | New value |
| SD_Meeting_Tool_Base::update_option | ( | $option, | |
| $value | |||
| ) |
Updates a site option.
If this is a network, the site option is preferred.
| $option | Name of option to update. |
| $value | New value |
| SD_Meeting_Tool_Base::update_site_option | ( | $option, | |
| $value | |||
| ) |
Updates a site option.
| $option | Name of option to update. |
| $value | New value |
| SD_Meeting_Tool_Base::user_id | ( | ) |
Return the user_id of the current user.
| SD_Meeting_Tool_Base::wrap | ( | $title, | |
| $text | |||
| ) |
Outputs the text in Wordpress admin's panel format.
| $title | H2 title to display. |
| $text | Text to display. |
|
protected |
Stores whether this blog is a network blog.
|
protected |
Text domain of .PO translation.
If left unset will be set to the base filename minus the .php
|
protected |
Array of options => default_values that this plugin stores locally.
|
protected |
Array of options => default_values that this plugin stores locally or globally.
| SD_Meeting_Tool_Base::$paths = array() |
Contains the paths to the plugin and other places of interest.
The keys in the array are:
name
filename
filename_from_plugin_directory
path_from_plugin_directory
path_from_base_directory
url
|
protected |
The list of the standard user roles in Wordpress.
First an array of role_name => array
And then each role is an array of name => role_name and current_user_can => capability.
|
protected |
Array of options => default_values that this plugin stores sitewide.
|
protected |
Links to Wordpress' database object.
1.8.1.2