tina_mvc.php

Show: PublicProtectedPrivateinherited
Table of Contents

Constants

>VConstant  TINA_MVC_VERSION = '1.0010'
>VConstant  TINA_MVC_PLUGIN_DIR = dirname(__FILE__)
>VConstant  TINA_MVC_PAGE_CONTROLLER_ID = $q->query_vars['page_id']
>VConstant  TINA_MVC_PAGE_CONTROLLER_NAME = $this_controller_name
>VConstant  TINA_MVC_PAGE_CONTROLLER_NAME = $this_controller_name

\Tina_MVC

Package: Tina-MVC\Core
The main plugin class

Checks the wordpress query for a 404 and checks for a Tina MVC page controller

Methods

methodpublic__construct() : void

Sets up the WP hooks

methodpubliccall_controller(string $controller, mixed $role_to_view = FALSE, string $capability_to_view = FALSE, string $custom_folder = '') : string
static

Directly calls a Tina MVC controller.

This can be used from within your own app or in a template file in your theme

Parameters
NameTypeDescription
$controllerstring

the page controller to call (you must also specify the Tina MVC page if your controller resides there)

$role_to_viewmixed

a (string) role, (string) comma seperated list or (array) of roles

$capability_to_viewstring

a (string) cap, (string) comma seperated list or (array) of caps

$custom_folderstring

specify location of controller file

Returns
TypeDescription
stringthe page content from the controller
methodpublicdo_bootstrap_funcs(integer $check_init_bootstrap = FALSE) : void

Checks 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

Parameters
NameTypeDescription
$check_init_bootstrapinteger

set to true to check the app_init_bootstrap folder instead

methodpublicdo_init_bootstrap_funcs() : void

Checks is there are init bootstrap actions to be run

Details
Uses
\$this->do_bootstrap_funcs()  
methodpublicdo_shortcode(array $attributes, string $content = '') : string

Parses 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

Parameters
NameTypeDescription
$attributesarray

the shortcode attributes. $attributes['c'] is required

$contentstring

the content of an enclosing shortcode

Returns
TypeDescription
stringThe pre-escaped HTML to display
methodprivateget_redirect_target(string $t = '') : string

Checks permalinks and returns an appropriate redirect url

Parameters
NameTypeDescription
$tstring

the page name or path

Returns
TypeDescription
stringthe url after checking permalinks
methodpublichourly_cron() : void

Checks 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.

methodpublichpt_backup() : void

Backup files before plugin upgrade

Thanks to Clay Lua (http://hungred.com) for illustrating the technique

Details
Uses
\tina_mvc_admin_hpt_backup()  
methodpublichpt_recover() : void

Recover files after plugin upgrade

Thanks to Clay Lua (http://hungred.com) for illustrating the technique

Details
Uses
\tina_mvc_admin_hpt_recover()  
methodpublicplugin_install(boolean $upgrading = FALSE) : void

Installs 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

Parameters
NameTypeDescription
$upgradingboolean

set to true if function is called during plugin upgrade

Details
See
\tina_mvc_app_settings_sample.php  
Uses
\TINA_MVC\utils\plugin_activate()  
methodpublicplugin_remove() : void

Removes the plugin on deactivation

Details
Uses
\TINA_MVC\utils\plugin_remove()  
methodpublicposts_filter(array $posts) : array

Posts 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

Parameters
NameTypeDescription
$postsarray

A single element array of posts. This can be empty for pages like 'tina/some-page'

Returns
TypeDescription
array$posts
Details
Uses
\tina_mvc_check_bootstrap_funcs()  
methodpublicredirect_logout() : void

Redirect on logout

methodpublicsetup_shortcode(string $content) : string

Wrapper function - sets up the 'tina_mvc' shortcode

Function is wrapped to prevent wp_texturize() messing with the content

Parameters
NameTypeDescription
$contentstring

The content in an enclosing shortcode

Returns
TypeDescription
stringThe processed content
Details
See
\http://www.viper007bond.com/2009/11/22/wordpress-code-earlier-shortcodes/  
methodpublicsetup_widget() : void

Sets up the Tina MVC widget

methodpublictina_mvc_login() : void

Forces 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).

methodpublicwp_query_checker(object $q) : object

Checks the $wp_query object for a call to a Tina MVC page controller

Parameters
NameTypeDescription
$qobject

wp_query object

Returns
TypeDescription
objectwp_query

\tina_mvc_widget

Package: Tina-MVC\Core
The Tina MVC Widget
Parent(s)
\WP_Widget

Methods

methodpublic__construct() : void

Widget setup.

methodpublicform(array $instance) : void

Displays 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.

Parameters
NameTypeDescription
$instancearray

Arguments from the Tina MVC Widget

methodpublicupdate(array $new_instance, array $old_instance) : array

Update the widget settings.

Parameters
NameTypeDescription
$new_instancearray

Arguments from the Tina MVC Widget

$old_instancearray
Returns
TypeDescription
array
methodpublicwidget(array $args, array $instance) : void

Displays the widget on the screen.

Parameters
NameTypeDescription
$argsarray

Wordpress widget arguments

$instancearray

Arguments from the Tina MVC Widget

Documentation was generated by phpDocumentor 2.0.0a12.