\ BWP_Framework_V3

Copyright (c) 2015 Khang Minh <contact@betterwp.net>

Summary

Methods
Properties
Constants
__construct()
add_icon()
get_version()
get_current_php_version()
get_current_wp_version()
warn_required_versions()
show_header()
show_sidebar_right()
show_version()
build_wp_properties()
pre_init()
init()
update_options()
update_site_options()
update_some_options()
remove_some_options()
get_options_by_keys()
install()
uninstall()
upgrade_plugin()
init_upgrade_plugin()
get_admin_page_url()
safe_redirect()
plugin_action_links()
init_admin_page()
init_admin_menu()
show_option_page()
add_notice_flash()
add_error_flash()
add_container_flash()
add_notice()
show_notices()
add_error()
has_error()
show_errors()
add_url()
get_url()
get_bridge()
get_cache()
get_current_timezone()
is_option_key_valid()
is_multisite()
is_subdomain_install()
is_super_admin()
is_site_admin()
is_multisite_admin()
is_on_main_blog()
is_on_sub_blog()
can_update_site_option()
is_apache()
is_nginx()
$options
$options_default
$site_options
$current_options
$option_keys
$extra_option_keys
$option_pages
$current_option_page
$plugin_key
$plugin_full_key
$plugin_ckey
$plugin_dkey
$plugin_title
$plugin_url
$urls
$plugin_file
$plugin_folder
$plugin_wp_url
$plugin_ver
$notices
$notice_shown
$errors
$error_shown
$plugin_cap
$need_media_filters
$form_tabs
$wp_ver
$php_ver
$revision
$domain
No constants found
build_properties()
add_option_key()
add_extra_option_key()
get_dashicon()
set_version()
check_required_versions()
pre_init_actions()
init_actions()
pre_init_build_constants()
build_constants()
pre_init_build_options()
init_build_options()
build_options()
update_plugin_options()
pre_init_properties()
pre_init_load_libraries()
load_libraries()
init_shared_properties()
init_properties()
init_load_libraries()
update_plugin()
pre_init_update_plugin()
init_update_plugin()
pre_init_hooks()
init_hooks()
get_src_by_environment()
get_deps_by_environment()
register_media_file()
enqueue_media_file()
register_framework_media()
enqueue_media()
is_admin_page()
get_current_admin_page()
build_menus()
build_tabs()
build_option_page()
add_flash()
get_flash()
get_container_flash()
show_dismiss_button()
add_cap()
get_template_contents()
normalize_options()
$_menu_under_settings
$_simple_menu
$bridge
$cache
$combined_assets
N/A

Properties

$options

$options : array

Hold plugin options

This should return the most up-to-date options, even after a form submit

Type

array

$options_default

$options_default : array

Hold plugin default options

Type

array

$site_options

$site_options : array

Hold plugin site options (applied to whole site)

Type

array

$current_options

$current_options : array

Hold plugin current options

This should be used to get an option before it is modified by a form submit

Type

array

$option_keys

$option_keys : 

Hold db option keys

$extra_option_keys

$extra_option_keys : 

Hold extra option keys

$option_pages

$option_pages : 

Hold option pages

$current_option_page

$current_option_page : \BWP_Option_Page_V3

The current option page instance

Type

\BWP_Option_Page_V3

$plugin_key

$plugin_key : 

Key to identify plugin

$plugin_full_key

$plugin_full_key : 

Full key to identify plugin

$plugin_ckey

$plugin_ckey : 

Constant Key to identify plugin

$plugin_dkey

$plugin_dkey : 

Domain Key to identify plugin

$plugin_title

$plugin_title : 

Title of the plugin

$plugin_url

$plugin_url : 

Homepage of the plugin

$urls

$urls : 

Urls to various parts of homepage or other places

Expect to have a format of array('relative' => bool, 'url' => url)

$plugin_file

$plugin_file : 

Plugin file

$plugin_folder

$plugin_folder : 

Plugin folder

$plugin_wp_url

$plugin_wp_url : 

Plugin WP url

$plugin_ver

$plugin_ver : 

Version of the plugin

$notices

$notices : 

Message shown to user (Warning, Notes, etc.)

$notice_shown

$notice_shown : 

$errors

$errors : 

Error shown to user

$error_shown

$error_shown : 

$plugin_cap

$plugin_cap : 

Capabilities to manage this plugin

$need_media_filters

$need_media_filters : 

Whether or not to create filter for media paths

$form_tabs

$form_tabs : 

Form tabs to build

$wp_ver

$wp_ver : 

Version constraints

$php_ver

$php_ver : 

$revision

$revision : 

Number of framework revisions

$domain

$domain : 

Text domain

$_menu_under_settings

$_menu_under_settings : 

Other special variables

$_simple_menu

$_simple_menu : 

$bridge

$bridge : \BWP_WP_Bridge

The bridge to WP

Type

\BWP_WP_Bridge

$cache

$cache : \BWP_Cache

Cache for plugins

Type

\BWP_Cache

$combined_assets

$combined_assets : array

Combined assets used for production environment

Type

array

Methods

__construct()

__construct(array  $meta, \BWP_WP_Bridge  $bridge = null, \BWP_Cache  $cache = null) 

Construct a new plugin with appropriate meta

Parameters

array $meta
\BWP_WP_Bridge $bridge

optional, default to null

\BWP_Cache $cache

add_icon()

add_icon() 

get_version()

get_version(  $type = '') 

Parameters

$type

get_current_php_version()

get_current_php_version(string  $version = null) 

Get or check if the current WP version is greater than a specified version

Parameters

string $version

optional

get_current_wp_version()

get_current_wp_version(string  $version = null) : string|boolean

Get or check if the current WP version is greater than a specified version

Parameters

string $version

optional

Returns

string|boolean

The current WP version or true|false if a $version parameter is provided.

warn_required_versions()

warn_required_versions() 

show_header()

show_header() 

show_sidebar_right()

show_sidebar_right() 

show_version()

show_version() 

build_wp_properties()

build_wp_properties() 

pre_init()

pre_init() 

Init parts of the plugin that require certain dependencies that are available as soon as "plugins_loaded" action is fired.

init()

init() 

Init parts of the plugin that requires certain dependencies (such as authenticated user) that are available only after WordPress fires the "init" action.

update_options()

update_options(string  $option_key, array  $options) 

Update options with a specific key

This should update $options but not $current_options. If there are site options in $options, they should use the default options.

Parameters

string $option_key
array $options

all options under the option key

update_site_options()

update_site_options(string  $option_key, array  $options) 

Update site options with a specific key, when allowed to

This should pick site options found in $options and update accordingly. This should also update $options property.

Parameters

string $option_key
array $options

all options under the option key

update_some_options()

update_some_options(string  $option_key, array  $new_options) 

Update some options under a specific key

This will update per blog options and site options. This will also accept options that have not been persisted in db.

Parameters

string $option_key
array $new_options

only the new options that need updating

remove_some_options()

remove_some_options(  $option_key, array  $options_to_remove) 

Parameters

$option_key
array $options_to_remove

get_options_by_keys()

get_options_by_keys(array  $option_keys, boolean  $default = false) 

Get current options by their keys

Parameters

array $option_keys
boolean $default

Get default options or not. Default to false.

install()

install() 

uninstall()

uninstall() 

upgrade_plugin()

upgrade_plugin(  $from,   $to) 

Parameters

$from
$to

init_upgrade_plugin()

init_upgrade_plugin(  $from,   $to) 

Parameters

$from
$to

get_admin_page_url()

get_admin_page_url(  $page = '') 

Parameters

$page

safe_redirect()

safe_redirect(  $url = null) 

Redirect internally, only when headers have not been sent

Parameters

$url

plugin_action_links()

plugin_action_links(  $links,   $file) 

Parameters

$links
$file

init_admin_page()

init_admin_page() 

init_admin_menu()

init_admin_menu() 

show_option_page()

show_option_page() 

add_notice_flash()

add_notice_flash(  $message,   $append = true) 

Parameters

$message
$append

add_error_flash()

add_error_flash(  $message,   $append = true) 

Parameters

$message
$append

add_container_flash()

add_container_flash(string  $field, string  $message, boolean  $append = true) 

Add a flash message that should be put in a form container

Parameters

string $field

the field that owns the container

string $message
boolean $append

add_notice()

add_notice(  $notice) 

Parameters

$notice

show_notices()

show_notices() 

add_error()

add_error(  $error) 

Parameters

$error

has_error()

has_error() 

show_errors()

show_errors() 

add_url()

add_url(  $key,   $url,   $relative = true) 

Parameters

$key
$url
$relative

get_url()

get_url(  $key) 

Parameters

$key

get_cache()

get_cache() : \BWP_Cache

Returns

\BWP_Cache

get_current_timezone()

get_current_timezone() : \DateTimeZone

Get current timezone set by user

Returns

\DateTimeZone

is_option_key_valid()

is_option_key_valid(string  $key) : boolean

Check whether an option key is valid

Parameters

string $key

Returns

boolean

is_multisite()

is_multisite() 

is_subdomain_install()

is_subdomain_install() 

is_super_admin()

is_super_admin() 

is_site_admin()

is_site_admin() 

is_multisite_admin()

is_multisite_admin() 

is_on_main_blog()

is_on_main_blog() 

is_on_sub_blog()

is_on_sub_blog() 

can_update_site_option()

can_update_site_option() 

is_apache()

is_apache() 

is_nginx()

is_nginx() 

build_properties()

build_properties(  $key, array  $options,   $plugin_file = '',   $plugin_url = '',   $need_media_filters = true) 

Build base properties

Parameters

$key
array $options
$plugin_file
$plugin_url
$need_media_filters

add_option_key()

add_option_key(  $key,   $option,   $title) 

Parameters

$key
$option
$title

add_extra_option_key()

add_extra_option_key(  $key,   $option,   $title) 

Parameters

$key
$option
$title

get_dashicon()

get_dashicon(  $name,   $fallback_text = '') 

Parameters

$name
$fallback_text

set_version()

set_version(  $ver = '',   $type = '') 

Parameters

$ver
$type

check_required_versions()

check_required_versions() 

pre_init_actions()

pre_init_actions() 

init_actions()

init_actions() 

pre_init_build_constants()

pre_init_build_constants() 

build_constants()

build_constants() 

pre_init_build_options()

pre_init_build_options() 

init_build_options()

init_build_options() 

build_options()

build_options() 

update_plugin_options()

update_plugin_options(  $option_key, array  $new_options) 

Parameters

$option_key
array $new_options

pre_init_properties()

pre_init_properties() 

pre_init_load_libraries()

pre_init_load_libraries() 

load_libraries()

load_libraries() 

init_shared_properties()

init_shared_properties() 

Init properties that are shared across different plugins

init_properties()

init_properties() 

init_load_libraries()

init_load_libraries() 

update_plugin()

update_plugin(  $when = '') 

Parameters

$when

pre_init_update_plugin()

pre_init_update_plugin() 

init_update_plugin()

init_update_plugin() 

pre_init_hooks()

pre_init_hooks() 

init_hooks()

init_hooks() 

get_src_by_environment()

get_src_by_environment(string  $handle, string  $dev_src, string  $prod_src = null, string  $prod_handle = null) : mixed

Get correct media src based on environment

Parameters

string $handle

media handle

string $dev_src

the source used in development environment

string $prod_src

the source used in production environment, this will be used instead of replacing $dev_src's extension when provided

string $prod_handle

the handle used in production environment

Returns

mixed

string

get_deps_by_environment()

get_deps_by_environment(array  $deps, string  $prod_handle = null) : array

Get dependencies based on environment

Parameters

array $deps

current dependencies of the item being checked

string $prod_handle

the handle used in production environment

Returns

array

register_media_file()

register_media_file(  $handle,   $src, array  $deps = array(),   $version = false, string  $prod_src = null, string  $prod_handle = null) 

Register a BWP media file

Parameters

$handle
$src
array $deps
$version
string $prod_src

the source to use when debug is off

string $prod_handle

the handle to use when debug is off

enqueue_media_file()

enqueue_media_file(  $handle,   $src, array  $deps = array(),   $version = false, string  $prod_src = null, string  $prod_handle = null) 

Enqueue a BWP media file

Parameters

$handle
$src
array $deps
$version
string $prod_src

the source to use when debug is off

string $prod_handle

the handle to use when debug is off

register_framework_media()

register_framework_media() 

Register some framework media that plugins can depend on anytime

enqueue_media()

enqueue_media() 

is_admin_page()

is_admin_page(  $page = '') 

Parameters

$page

get_current_admin_page()

get_current_admin_page() 

build_menus()

build_menus() 

Build the Menus

build_tabs()

build_tabs() 

build_option_page()

build_option_page() 

Build the option pages

add_flash()

add_flash(string  $key, string  $message, boolean  $append = true) 

Add a flash message that is shown only once

Parameters

string $key

the key to group this message

string $message

the message to display

boolean $append

append to the group or replace

get_flash()

get_flash(  $key) : array

Get all flash messages that share a key

Parameters

$key

Returns

array

get_container_flash()

get_container_flash() 

show_dismiss_button()

show_dismiss_button() 

add_cap()

add_cap(  $cap) 

Parameters

$cap

get_template_contents()

get_template_contents(string  $template_file_path, array  $data = array()) 

Get contents from a template file, with data filled with provided $data

Parameters

string $template_file_path

path to template file, starting from plugin's src directory, a leading slash is not required.

array $data

normalize_options()

normalize_options(  $options) 

Parameters

$options