tina_mvc.php
Constants
\Tina_MVC
Checks the wordpress query for a 404 and checks for a Tina MVC page controller
Methods

call_controller(string $controller, mixed $role_to_view = FALSE, string $capability_to_view = FALSE, string $custom_folder = '') : stringDirectly calls a Tina MVC controller.
This can be used from within your own app or in a template file in your theme
| Name | Type | Description |
|---|---|---|
| $controller | string | the page controller to call (you must also specify the Tina MVC page if your controller resides there) |
| $role_to_view | mixed | a (string) role, (string) comma seperated list or (array) of roles |
| $capability_to_view | string | a (string) cap, (string) comma seperated list or (array) of caps |
| $custom_folder | string | specify location of controller file |
| Type | Description |
|---|---|
| string | the page content from the controller |

do_bootstrap_funcs(integer $check_init_bootstrap = FALSE) : voidChecks if we have any bootstrap scripts to be run
Scripts live in the user_apps folder in bootstrap. Every PHP file (except index.php) in the directory (but not subdirectories), is included and a PHP function named the same as the filename is called.
This allows you to do things like use wp_enqueue_script() with shortcodes and widgets, or to use other Wordpress action hooks. The functions will be called on every page load, not just with Tina MVC pages, so use sparingly.
This feature can be disabled in tina_mvc_app_settings.php
| Name | Type | Description |
|---|---|---|
| $check_init_bootstrap | integer | set to true to check the app_init_bootstrap folder instead |

do_init_bootstrap_funcs() : voidChecks is there are init bootstrap actions to be run
- Uses
- \$this->do_bootstrap_funcs()

do_shortcode(array $attributes, string $content = '') : stringParses the Tina MVC shortcodes
Shortcodes may be self-closing or enclosing. At least the controller parameter 'c' is required:
[tina_mvc c="my-controller/my-method"]
Complete parameters: - 'c' => The controller to call - 'role' => role to view (enter '-1' for boolean FALSE to allow anyone to view) - 'cap' => capability to view
| Name | Type | Description |
|---|---|---|
| $attributes | array | the shortcode attributes. $attributes['c'] is required |
| $content | string | the content of an enclosing shortcode |
| Type | Description |
|---|---|
| string | The pre-escaped HTML to display |

get_redirect_target(string $t = '') : stringChecks permalinks and returns an appropriate redirect url
| Name | Type | Description |
|---|---|---|
| $t | string | the page name or path |
| Type | Description |
|---|---|
| string | the url after checking permalinks |

hourly_cron() : voidChecks the hourly_cron folder in a users application folder and parses files for cron functions.
If you want to use something other than hourly crons, either add a check in your cron function to check the last time the function was run or set up your own custom cron in an init_bootstrap function.

hpt_backup() : voidBackup files before plugin upgrade
Thanks to Clay Lua (http://hungred.com) for illustrating the technique
- Uses
- \tina_mvc_admin_hpt_backup()

hpt_recover() : voidRecover files after plugin upgrade
Thanks to Clay Lua (http://hungred.com) for illustrating the technique
- Uses
- \tina_mvc_admin_hpt_recover()

plugin_install(boolean $upgrading = FALSE) : voidInstalls or upgrades the plugin on activation
Takes settings from 'tina_mvc_app_settings_sample.php' or 'tina_mvc_app_settings.php' and creates Wordpress pages and options accordingly.
This function will be run whenever the plugin is upgraded AFTER any saved settings have been copied back to the tina-mvc plugin folder. Check the $tina_mvc_upgrade_backups variable in the settings file
| Name | Type | Description |
|---|---|---|
| $upgrading | boolean | set to true if function is called during plugin upgrade |
- See
- \tina_mvc_app_settings_sample.php
- Uses
- \TINA_MVC\utils\plugin_activate()

posts_filter(array $posts) : arrayPosts filter to detect a call to our controller and to pass control to it
Checks $wp_query->get('tina_mvc_request') and if set triggers a call to the Tina MVC framework. Sets the Wordpress post_title and post_content. The (object) $wp_query is previously marked tina_mvc_query_parser() to flag a call to our controller
| Name | Type | Description |
|---|---|---|
| $posts | array | A single element array of posts. This can be empty for pages like 'tina/some-page' |
| Type | Description |
|---|---|
| array | $posts |
- Uses
- \tina_mvc_check_bootstrap_funcs()

setup_shortcode(string $content) : stringWrapper function - sets up the 'tina_mvc' shortcode
Function is wrapped to prevent wp_texturize() messing with the content
| Name | Type | Description |
|---|---|---|
| $content | string | The content in an enclosing shortcode |
| Type | Description |
|---|---|
| string | The processed content |
- See
- \http://www.viper007bond.com/2009/11/22/wordpress-code-earlier-shortcodes/

tina_mvc_login() : voidForces use of the Tina MVC login framework.
Prevents a user from ever seeing a Wordpress backend.
This works by directing to a Tina MVC page. If there are no permissions to view on that page the user will not see a login form. Make sure your login page is protected to avoid this issue.
The Tina MVC setting 'logon_redirect_target' is used to direct users to a Tina MVC page. If it is empty this finds the first available page Tina MVC page (which may not make any premissions to view).
\tina_mvc_widget
- Parent(s)
- \WP_Widget
Methods

form(array $instance) : voidDisplays the widget settings controls on the widget panel.
Make use of the get_field_id() and get_field_name() function when creating your form elements. This handles the confusing stuff.
| Name | Type | Description |
|---|---|---|
| $instance | array | Arguments from the Tina MVC Widget |

update(array $new_instance, array $old_instance) : arrayUpdate the widget settings.
| Name | Type | Description |
|---|---|---|
| $new_instance | array | Arguments from the Tina MVC Widget |
| $old_instance | array |
| Type | Description |
|---|---|
| array |