tina_mvc/helpers/tina_mvc_functions.php
- Author
- Francis Crossen
- Package
- Tina-MVC
- Subpackage
- Core
Constants
Functions
app_folder() : string
Find the path to the application folder
In multisite, this is in tina-mvc/user_apps/multisite/example or tina-mvc/user_apps/default, in non multisite, in tina-mvc/user_apps/default.
This is an internal helper function. You don't generally need to call it.
Type | Description |
---|---|
string | the path to your app folder (no trailing slash) |
- Uses
- \TINA_MVC\tina_mvc_find_plugin_folder()
error(string $msg = '', boolean $suppress_esc = FALSE) : void
A basic error handler
Tina calls this whenever it encounters an error. Hack/override this to help you debug your applications
Name | Type | Description |
---|---|---|
$msg | string | The error message |
$suppress_esc | boolean | Suppress escaping of the message |
esc_html_recursive(mixed $data = FALSE) : mixed
Escape a data structure for rendering in a browser
Recurses into arrays and objects
Name | Type | Description |
---|---|---|
$data | mixed | An array or object containing data to be escaped |
Type | Description |
---|---|
mixed | The $escaped $data |
- Uses
- to escape non-XML entities
find_app_file(string $filename = '', string $tina_mvc_page = '', string $called_from = 'PAGE_FILTER', array $find_app_file_error) : mixed
Searches for a file in the standard Tina MVC application folders
In case of error the locations we looked in are stored in $find_app_file_error for use in an error message later.
Name | Type | Description |
---|---|---|
$filename | string | |
$tina_mvc_page | string | the page the controller is accessed through |
$called_from | string | PAGE_FILTER, WIDGET, SHORTCODE, CALLABLE_CONTROLLER |
$find_app_file_error | array | contains a list of places searched (for use in case of error) |
Type | Description |
---|---|
mixed | FALSE or the full path and filename to the file to be included |
get_abs_controller_link(string $controller = '', string $link_text = FALSE, string $extra_attribs = '') : string
Makes an HTML link a Tina MVC controller.
Makes links to arbitrary Tina MVC controllers. You should use this function in your widget and shortcode page controllers when there is no active Tina MVC page.
Name | Type | Description |
---|---|---|
$controller | string | The 'tina-page/controller/method/data' we want to call |
$link_text | string | The link text to display in the element (default $controller) |
$extra_attribs | string | Attributes to put in the tag. e.g. style or script attributes |
Type | Description |
---|---|
string | An <a> element ready for browser output |
- Uses
- \TINA_MVC\get_controller_url()
get_controller_link(string $controller = '', string $link_text = FALSE, string $extra_attribs = '') : string
Gets a HTML link a Tina MVC controller
Uses the current active Tina MVC front end page controller.
Name | Type | Description |
---|---|---|
$controller | string | The 'controller/action/data' we want to call |
$link_text | string | The link text to display in the element (default $controller) |
$extra_attribs | string | Attributes to put in the tag. e.g. style or script attributes |
Type | Description |
---|---|
string | An <a> element ready for browser output |
- Uses
- \TINA_MVC\get_controller_url()
get_controller_url(string $controller = '', boolean $absolute_controller_path = false) : string
Gets a url to a Tina MVC controller
For example, you want to call 'my-app/my-action' and your controller is accessed through the Tina MVC page 'tina-mvc', this function will return http://example.com/tina-mvc/my-app/my-action. This will fail when used from shortcodes and widgets (because they are not accessed through a Tina MVC page). In that case you can specify the absolute path to your controller by setting $absolute_controller_path to 'true'
This function can be called directly from with your controllers (for example if you want to do a browser header redirect) but is typically used in view files (templates) with get_controller_link() and get_abs_controller_link() functions
Name | Type | Description |
---|---|---|
$controller | string | The 'controller/action/data' we want to call |
$absolute_controller_path | boolean | set to |
Type | Description |
---|---|
string | an absolute URL to the controller |
- See
- and get_abs_controller_link()
get_get(string $var = NULL) : mixed
Gets a value from $_GET
Name | Type | Description |
---|---|---|
$var | string | The variable name to retrieve |
Type | Description |
---|---|
mixed | The $_GET var |
- See
- in get_post()
get_getpost(string $var) : mixed
Gets a value from $_GET and if not set look in $_POST
Name | Type | Description |
---|---|---|
$var | string | The variable name to retrieve |
Type | Description |
---|---|
mixed | The $_GET/$_POST var |
- See
- in tina_mvc_get_post()
- Uses
- and tina_mvc_get_Post()
get_mailer_from_address() : string
Gets an email address for use by the Tina MVC mailer function.
Emails are sent from this address
Type | Description |
---|---|
string |
get_multisite_blog_name() : \TINA_MVC\strng
Gets the blog name in a Wordpress Multisite installation
Type | Description |
---|---|
\TINA_MVC\strng | the blog name |
get_post(string $var = NULL) : mixed
Gets a value from $_POST
Wordpress has some funky ways of treating global $_POST and $_GET variables. Look at wp-settings.php (line 624 for v2.9.1):
// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep($_GET );
$_POST = stripslashes_deep($_POST );
$_COOKIE = stripslashes_deep($_COOKIE);
}
// Escape with wpdb.
$_GET = add_magic_quotes($_GET );
$_POST = add_magic_quotes($_POST );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);
Tina assumes that you want to deal with unescaped data. If you want to store it in a DB then do your own escaping or use the $wpdb class (recommended)
Name | Type | Description |
---|---|---|
$var | string | Variable name to retrieve |
Type | Description |
---|---|
mixed | The $_POST var |
get_tina_mvc_folder_url() : string
Gets the url to the Tina MVC plugin folder
Handy for adding js or css files using wp_enqueue_* functions
Type | Description |
---|---|
string |
get_tina_mvc_setting(string $option_name = '') : mixed
Gets a Tina MVC setting
This is stored in the Wordpress option table as 'tina_mvc_settings'
Name | Type | Description |
---|---|---|
$option_name | string |
Type | Description |
---|---|
mixed | default FALSE |
helpers_folder() : string
Returns the path to the tina_mvc/helpers folder
Type | Description |
---|---|
string |
include_helper(string $h = '') : object
Locates and loads a helper.
Returns an instantiated object.
Name | Type | Description |
---|---|---|
$h | string | the helper to include (for, table, pagination, etc) |
Type | Description |
---|---|
object |
log(string $msg = '') : void
Display a message as a PHP E_USER_NOTICE Error
Handy for quick debugging when you can't use tmpr() or tmprd() but can view your PHP error logs instead
Name | Type | Description |
---|---|---|
$msg | string | The message to log |
- Uses
- \TINA_MVC\trigger_error()
plugin_folder() : string
Returns the path to the main Tina MVC plugin folder
Type | Description |
---|---|
string |
pr(mixed $a = NULL, string $l = 'Variable Dump') : string
Alias to tina_mvc_print_r()
Name | Type | Description |
---|---|---|
$a | mixed | Stuff to dump to screen... |
$l | string | An optional label to output e.g. the variable name... |
Type | Description |
---|---|
string |
- See
- \TINA_MVC\tina_mvc_print_r
prd(mixed $a = NULL, string $l = 'Variable Dump') : string
Alias to tina_mvc_print_r() and die();
Name | Type | Description |
---|---|---|
$a | mixed | Stuff to dump to screen... |
$l | string | An optional label to output e.g. the variable name... |
Type | Description |
---|---|
string |
- See
- \TINA_MVC\tina_mvc_print_r
tina_mvc_print_r(mixed $arg = NULL, string $label = 'Variable Dump') : string
Wrapper for print_r()
A convenient way of examining variables during development. $arg is passed by reference, so you cannot use a function return. To avoid this limitation use the following construct:
tina_mvc_print_r( ( $_a = some_function() ) )
Name | Type | Description |
---|---|---|
$arg | mixed | Stuff to dump to screen... |
$label | string | An optional label to output e.g. the variable name... |
Type | Description |
---|---|
string |
- See
- \TINA_MVC\pr()
- See
- \TINA_MVC\prd()
user_has_capability(array | string $cap_to_check = array()) : \TINA_MVC\bolean
Check if a user has been assigned a capability
Name | Type | Description |
---|---|---|
$cap_to_check | array | string | a list capabilities to check (array or comma separated string) |
Type | Description |
---|---|
\TINA_MVC\bolean |
user_has_role(array | string $roles_to_check = array()) : \TINA_MVC\bolean
Check if a user has been assigned to a role
This is safe to use when users can have multiple roles
Name | Type | Description |
---|---|---|
$roles_to_check | array | string | a list roles to check (array or comma separated string) |
Type | Description |
---|---|
\TINA_MVC\bolean |