PHP 클래스 WPLib, wplib

Plugin Name: WPLib Plugin URI: http://wordpress.org/plugins/wplib/ Description: A WordPress Website Foundation Library Agency and Internal Corporate Developers Version: 0.13.2 Author: The WPLib Team Author URI: http://wplib.org Text Domain: wplib License: GPLv2 or later Copyright 2015 NewClarity Consulting LLC This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
또한 보기: https://github.com/wplib/wplib/commit/8dc27c368e84f7ba6e1448753e1b1f082a60ac6d#commitcomment-11027141
파일 보기 프로젝트 열기: wplib/wplib 1 사용 예제들

공개 메소드들

메소드 설명
__callStatic ( string $method, array $args ) : mixed
_after_setup_theme ( ) Now load the theme's modules.
_after_setup_theme_11 ( ) Determine and then load the "mustload" classes They are the classes with an on_load() method.
_autoloader ( string $class_name )
_call_helper ( string $helped_class, string $helper_method, array $args, object $container = null ) : mixed | null Delegate calls to other classes.
_ensure_only_one_class ( $class_container ) Scans to ensure that only one PHP class is declared.
_find_files_autoloader ( $class_name ) Special autoloader to run only for conflicts.
_get_raw_meta_fieldname ( string $meta_name ) : string Returns the raw meta fieldname given a non-prefixed field name.
_init_9 ( ) : array Autoload all WPLib module classes to ensure they are available for 'init' hook.
_plugins_loaded_11 ( ) Load all necessary files. This finds autoloading files and loads modules.
_register_templates ( ) : array Register all templates for WPLib, an App or a module.
_set_mustload_classes ( array $autoload_files ) This will get called 4 times.
_shutdown ( ) Throw error if site failed to load because of a module failing to load.
_xmlrpc_call ( ) Capture status of DOING_XMLRPC
add_class_action ( string $action, integer $priority = 10 )
add_class_filter ( string $filter, integer $priority = 10 )
app_class ( ) : string | null Returns the one app class defined.
app_classes ( ) : array | null
assets_url ( ) : string Return the simple asset path
autoload_all_classes ( ) Force loading of all classes if needed to find all classes with a specific constant.
cache_delete ( string $key, string $group = '' )
cache_exists ( string $key, string $group = '' ) : boolean
cache_get ( string $key, string $group = '' ) : mixed
cache_set ( string $key, mixed $value, string $group = '', integer $expire )
can_call ( string $method_name, string | boolean $class_name = false ) : boolean Determines if a named method exists and is_callable a given class.
class_declares_method ( string $class_name, string $method_name ) : boolean Determines is a class actually declares a method instead of just inheriting it.
component_classes ( string $scope = 'all' ) : array Returns the list of "Component" classes. A Component is one of Lib, Site, App, Theme, Module.
current_helped_class ( ) : array Returns the class that is currently being "helped."
dashify ( string $string, boolean | true $lowercase = true ) : string
do_log_errors ( ) : boolean
do_the_methods ( string | object $view, string | object $model, string $method_name, array $args ) : mixed Do "the_" Methods - Allow classes to delegate the "the_" logic processing here.
doing_ajax ( ) : boolean
doing_autosave ( ) : boolean
doing_cron ( ) : boolean
doing_xmlrpc ( ) : boolean
emit_headers ( string | array $headers ) Emits one or more HTTP headers to the output stream
file_hash ( string $filepath ) : string Returns a file hash, but caches it in persistent cache
get_asset_url ( string $asset_path, boolean | string $class_name = false ) : string Return the asset path
get_callable ( string | object $object, string $method_name ) : callable | null Given an object/class name and method name return a callable or null if can't be called.
get_child_classes ( $base_class, $constant_name ) : string[] Returns array of class names $base_class children with positive values for $base_class::$contant_name.
get_constant ( string $constant_name, string | boolean | object $class_name = false, boolean $try_parent = true ) : mixed | null Return a class constant for the called class.
get_contents ( string $filepath ) : boolean
get_module_class ( string $module_name, string | boolean $app_class = false ) : string
get_module_classes ( string $app_class ) : string[]
get_module_dir ( WPLib_Item_Base | string | boolean $item_class = false ) : string | null
get_module_name ( string $class_name ) : mixed | null
get_real_url ( string $url ) : string Like realpath() but for URLs
get_root_dir ( string $filepath, boolean | string $class_name = false ) : string Return the root directory of the Lib/App/Site/Module/Theme class for a given class name.
get_root_url ( string $filepath, boolean | string $class_name = false ) : string Get the root URL for a given Lib/Site/App/Module/Theme.
get_template ( string $template_slug, array | string $_template_vars = [], WPLib_Item_Base | object $item = null ) : string
get_template_dir ( string $template ) : string Return the template filepath for the passed $template for the called class.
get_theme_file ( string $local_file ) : string Returns the filepath for a theme template file given its "local filename."
has_html_suffix ( string | false $suffix ) : boolean
initialize ( ) If used in a theme you have to first initialize it before WPLib_Theme_Base classes will be available to extend.
invoke_with_args ( callable $invokable, array $args ) : mixed
is_development ( ) : boolean
is_found ( string $filepath ) : boolean
is_production ( ) : boolean
is_script_debug ( ) : string If runmode is development or SCRIPT_DEBUG
is_staging ( ) : boolean
is_testing ( ) : boolean
is_wp_debug ( ) : boolean
make_new_item ( WPLib_Item_Base | WP_Post | WP_Term $item, array $args = [] ) : WPLib_Term_Base | WPLib_Post_Base
maybe_make_absolute_path ( string $filepath, boolean | string $dir = false ) : string Convert relative file paths to absolute file paths.
maybe_make_abspath_relative ( string $filepath ) : string Takes a filepath and potentially returns a relative path (prefixed with '~/'), if $filepath begins with ABSPATH.
module_classes ( ) : string[]
new_post_url ( ) : string
on_load ( )
put_contents ( string $filepath, string $contents ) : boolean Runs file_put_contents()
register_helper ( string $helper_class, string | boolean $helped_class = false ) Register a helper class to the specified class.
register_module ( string $module, integer $priority = 10 )
register_template ( string $template, string | boolean $called_class = false ) Register a template
remove_class_action ( string $action, integer $priority = 10 )
remove_class_filter ( string $filter, integer $priority = 10 )
root_dir ( ) : string Return the root directory of the Lib/App/Site/Module/Theme class.
root_url ( ) : string Return the root URL of the Lib/App/Site/Module/Theme class.
runmode ( ) : WPLib_Runmode
set_runmode ( integer | WPLib_Runmode $runmode )
set_stability ( integer | WPLib_Stability $stability )
set_theme ( WPLib_Theme_Base $theme )
short_prefix ( ) : boolean | string
site_classes ( ) : array Return the list of classes declared after WPLib first loads.
stability ( ) : WPLib_Stability
template_dir ( ) : string Return the templates directory path for the called class.
templates_subdir ( ) : string Return the subdir name for templates.
the_asset_url ( string $asset_path, boolean | string $class_name = false ) : string Echo the asset path
the_template ( string $template_slug, array | string $_template_vars = [], WPLib_Item_Base | object $item = null )
theme ( ) : WPLib_Theme_Base
trigger_error ( string $error_msg, integer $error_type = E_USER_NOTICE, boolean $echo = false ) Triggers error message unless doing AJAX, XMLRPC or Cron; then it logs the error but only if Development mode.
use_template_global_vars ( ) : boolean Return if WPLIB_TEMPLATE_GLOBAL_VARS was set to true

비공개 메소드들

메소드 설명
_current_helped_classes ( ) : array
_filter_group ( $group ) : string
_find_autoload_files ( ) Scan registered autoload files, by priority
_flatten_array_dependency_order ( string $parent_class, string $child_class, array &$mustload_classes, string[] &$ordered_classes ) : array Flatten an array containing parent class names with array.
_load_modules ( ) Load all registered modules, by priority
_load_mustload_classes ( string[] $mustload_classes ) Loads the "mustload" classes on every page load.
_load_necessary_files ( ) Load all necessary files, i.e. modules and finds all autoloading files.
_ordered_mustload_classes ( ) : array Orders the Mustload classes in order of least dependency.

메소드 상세

__callStatic() 정적인 공개 메소드

static public __callStatic ( string $method, array $args ) : mixed
$method string
$args array
리턴 mixed

_after_setup_theme() 정적인 공개 메소드

Now load the theme's modules.
static public _after_setup_theme ( )

_after_setup_theme_11() 정적인 공개 메소드

Determine and then load the "mustload" classes They are the classes with an on_load() method.
static public _after_setup_theme_11 ( )

_autoloader() 정적인 공개 메소드

static public _autoloader ( string $class_name )
$class_name string

_call_helper() 정적인 공개 메소드

This allows us to document a single "API" for WPLib yet structure the code more conveniently in multiple class files.
static public _call_helper ( string $helped_class, string $helper_method, array $args, object $container = null ) : mixed | null
$helped_class string Name of class that is calling the helper
$helper_method string Name of the helper method
$args array Arguments to pass to the helper method
$container object An object containing a 'callable' property.
리턴 mixed | null

_ensure_only_one_class() 정적인 공개 메소드

This is important because we assume only one class for the autoloader.
static public _ensure_only_one_class ( $class_container )
$class_container

_find_files_autoloader() 정적인 공개 메소드

Special autoloader to run only for conflicts.
static public _find_files_autoloader ( $class_name )
$class_name

_get_raw_meta_fieldname() 정적인 공개 메소드

Adds both a leading underscore and a short prefix to the meta name.
static public _get_raw_meta_fieldname ( string $meta_name ) : string
$meta_name string
리턴 string

_init_9() 정적인 공개 메소드

Autoload all WPLib module classes to ensure they are available for 'init' hook.
static public _init_9 ( ) : array
리턴 array

_plugins_loaded_11() 정적인 공개 메소드

Load all necessary files. This finds autoloading files and loads modules.
static public _plugins_loaded_11 ( )

_register_templates() 정적인 공개 메소드

Register all templates for WPLib, an App or a module.
static public _register_templates ( ) : array
리턴 array

_set_mustload_classes() 정적인 공개 메소드

1 & 2: Finding all autoloading files from components that have been loaded by (1) plugins or (2) the theme. 3 & 4: Finding all autoloading files defined by modules specified by (1) plugins or (2) the theme. Each time it is called it will have values added to self::$_mustload_classes.
static public _set_mustload_classes ( array $autoload_files )
$autoload_files array

_shutdown() 정적인 공개 메소드

Throw error if site failed to load because of a module failing to load.
static public _shutdown ( )

_xmlrpc_call() 정적인 공개 메소드

Capture status of DOING_XMLRPC
static public _xmlrpc_call ( )

add_class_action() 정적인 공개 메소드

static public add_class_action ( string $action, integer $priority = 10 )
$action string
$priority integer

add_class_filter() 정적인 공개 메소드

static public add_class_filter ( string $filter, integer $priority = 10 )
$filter string
$priority integer

app_class() 정적인 공개 메소드

Returns the one app class defined.
static public app_class ( ) : string | null
리턴 string | null

app_classes() 정적인 공개 메소드

static public app_classes ( ) : array | null
리턴 array | null

assets_url() 정적인 공개 메소드

Return the simple asset path
static public assets_url ( ) : string
리턴 string

autoload_all_classes() 정적인 공개 메소드

Force loading of all classes if needed to find all classes with a specific constant.
static public autoload_all_classes ( )

cache_delete() 정적인 공개 메소드

static public cache_delete ( string $key, string $group = '' )
$key string
$group string

cache_exists() 정적인 공개 메소드

static public cache_exists ( string $key, string $group = '' ) : boolean
$key string
$group string
리턴 boolean

cache_get() 정적인 공개 메소드

static public cache_get ( string $key, string $group = '' ) : mixed
$key string
$group string
리턴 mixed

cache_set() 정적인 공개 메소드

static public cache_set ( string $key, mixed $value, string $group = '', integer $expire )
$key string
$value mixed
$group string
$expire integer

can_call() 정적인 공개 메소드

Determines if a named method exists and is_callable a given class.
static public can_call ( string $method_name, string | boolean $class_name = false ) : boolean
$method_name string
$class_name string | boolean
리턴 boolean

class_declares_method() 정적인 공개 메소드

Determines is a class actually declares a method instead of just inheriting it.
static public class_declares_method ( string $class_name, string $method_name ) : boolean
$class_name string
$method_name string
리턴 boolean

component_classes() 정적인 공개 메소드

Returns the 'latest' or 'all' (default). This follows 'principle of least surprise'
static public component_classes ( string $scope = 'all' ) : array
$scope string 'all' or 'latest'
리턴 array

current_helped_class() 정적인 공개 메소드

The Helped class is the one to the left of '::' when the method is actually in a "helper" class: {$current_helped_class}::register_helper( $helper_class ); Which is equivalent to: WPLib::register_helper( $helper_class, $current_helped_class );
static public current_helped_class ( ) : array
리턴 array

dashify() 정적인 공개 메소드

static public dashify ( string $string, boolean | true $lowercase = true ) : string
$string string
$lowercase boolean | true
리턴 string

do_log_errors() 정적인 공개 메소드

static public do_log_errors ( ) : boolean
리턴 boolean

do_the_methods() 정적인 공개 메소드

The "the_" method can call virtual methods and/or delegate to a view or a model. The view and model can both be the same object if needed.
static public do_the_methods ( string | object $view, string | object $model, string $method_name, array $args ) : mixed
$view string | object
$model string | object
$method_name string
$args array
리턴 mixed

doing_ajax() 정적인 공개 메소드

static public doing_ajax ( ) : boolean
리턴 boolean

doing_autosave() 정적인 공개 메소드

static public doing_autosave ( ) : boolean
리턴 boolean

doing_cron() 정적인 공개 메소드

static public doing_cron ( ) : boolean
리턴 boolean

doing_xmlrpc() 정적인 공개 메소드

static public doing_xmlrpc ( ) : boolean
리턴 boolean

emit_headers() 정적인 공개 메소드

Emits one or more HTTP headers to the output stream
static public emit_headers ( string | array $headers )
$headers string | array

file_hash() 정적인 공개 메소드

Returns a file hash, but caches it in persistent cache
static public file_hash ( string $filepath ) : string
$filepath string
리턴 string

get_asset_url() 정적인 공개 메소드

Return the asset path
static public get_asset_url ( string $asset_path, boolean | string $class_name = false ) : string
$asset_path string
$class_name boolean | string Name of class to return the root dir.
리턴 string

get_callable() 정적인 공개 메소드

Given an object/class name and method name return a callable or null if can't be called.
static public get_callable ( string | object $object, string $method_name ) : callable | null
$object string | object
$method_name string
리턴 callable | null

get_child_classes() 정적인 공개 메소드

Returns array of class names $base_class children with positive values for $base_class::$contant_name.
static public get_child_classes ( $base_class, $constant_name ) : string[]
$base_class
$constant_name
리턴 string[]

get_constant() 정적인 공개 메소드

Return a class constant for the called class.
static public get_constant ( string $constant_name, string | boolean | object $class_name = false, boolean $try_parent = true ) : mixed | null
$constant_name string
$class_name string | boolean | object
$try_parent boolean
리턴 mixed | null

get_contents() 정적인 공개 메소드

static public get_contents ( string $filepath ) : boolean
$filepath string
리턴 boolean

get_module_class() 정적인 공개 메소드

static public get_module_class ( string $module_name, string | boolean $app_class = false ) : string
$module_name string
$app_class string | boolean
리턴 string

get_module_classes() 정적인 공개 메소드

static public get_module_classes ( string $app_class ) : string[]
$app_class string
리턴 string[]

get_module_dir() 정적인 공개 메소드

static public get_module_dir ( WPLib_Item_Base | string | boolean $item_class = false ) : string | null
$item_class WPLib_Item_Base | string | boolean
리턴 string | null

get_module_name() 정적인 공개 메소드

static public get_module_name ( string $class_name ) : mixed | null
$class_name string
리턴 mixed | null

get_real_url() 정적인 공개 메소드

Like realpath() but for URLs
static public get_real_url ( string $url ) : string
$url string
리턴 string

get_root_dir() 정적인 공개 메소드

Return the root directory of the Lib/App/Site/Module/Theme class for a given class name.
static public get_root_dir ( string $filepath, boolean | string $class_name = false ) : string
$filepath string Name of path to append to root dir.
$class_name boolean | string Name of class to return the source dir.
리턴 string

get_root_url() 정적인 공개 메소드

Get the root URL for a given Lib/Site/App/Module/Theme.
static public get_root_url ( string $filepath, boolean | string $class_name = false ) : string
$filepath string Name of path to append to root URL.
$class_name boolean | string Name of class to return the root dir.
리턴 string

get_template() 정적인 공개 메소드

또한 보기: self::the_template()
static public get_template ( string $template_slug, array | string $_template_vars = [], WPLib_Item_Base | object $item = null ) : string
$template_slug string
$_template_vars array | string
$item WPLib_Item_Base | object
리턴 string

get_template_dir() 정적인 공개 메소드

Return the template filepath for the passed $template for the called class.
static public get_template_dir ( string $template ) : string
$template string
리턴 string

get_theme_file() 정적인 공개 메소드

Local filename means based at the root of the theme w/o leading slash.
static public get_theme_file ( string $local_file ) : string
$local_file string
리턴 string

has_html_suffix() 정적인 공개 메소드

static public has_html_suffix ( string | false $suffix ) : boolean
$suffix string | false
리턴 boolean

initialize() 정적인 공개 메소드

If used in a theme you have to first initialize it before WPLib_Theme_Base classes will be available to extend.
static public initialize ( )

invoke_with_args() 정적인 공개 메소드

static public invoke_with_args ( callable $invokable, array $args ) : mixed
$invokable callable
$args array
리턴 mixed

is_development() 정적인 공개 메소드

static public is_development ( ) : boolean
리턴 boolean

is_found() 정적인 공개 메소드

static public is_found ( string $filepath ) : boolean
$filepath string
리턴 boolean

is_production() 정적인 공개 메소드

static public is_production ( ) : boolean
리턴 boolean

is_script_debug() 정적인 공개 메소드

If runmode is development or SCRIPT_DEBUG
또한 보기: https://github.com/wplib/wplib/commit/8dc27c368e84f7ba6e1448753e1b1f082a60ac6d#commitcomment-11026829
static public is_script_debug ( ) : string
리턴 string

is_staging() 정적인 공개 메소드

static public is_staging ( ) : boolean
리턴 boolean

is_testing() 정적인 공개 메소드

static public is_testing ( ) : boolean
리턴 boolean

is_wp_debug() 정적인 공개 메소드

static public is_wp_debug ( ) : boolean
리턴 boolean

make_new_item() 정적인 공개 메소드

static public make_new_item ( WPLib_Item_Base | WP_Post | WP_Term $item, array $args = [] ) : WPLib_Term_Base | WPLib_Post_Base
$item WPLib_Item_Base | WP_Post | WP_Term
$args array
리턴 WPLib_Term_Base | WPLib_Post_Base

maybe_make_absolute_path() 정적인 공개 메소드

Recognize a path with a leading slash as an absolute, a no leading slash or starting with '~/' as relative.
static public maybe_make_absolute_path ( string $filepath, boolean | string $dir = false ) : string
$filepath string
$dir boolean | string
리턴 string

maybe_make_abspath_relative() 정적인 공개 메소드

Takes a filepath and potentially returns a relative path (prefixed with '~/'), if $filepath begins with ABSPATH.
static public maybe_make_abspath_relative ( string $filepath ) : string
$filepath string
리턴 string

module_classes() 정적인 공개 메소드

static public module_classes ( ) : string[]
리턴 string[]

new_post_url() 정적인 공개 메소드

static public new_post_url ( ) : string
리턴 string

on_load() 정적인 공개 메소드

static public on_load ( )

put_contents() 정적인 공개 메소드

Runs file_put_contents()
static public put_contents ( string $filepath, string $contents ) : boolean
$filepath string
$contents string
리턴 boolean

register_helper() 정적인 공개 메소드

Register a helper class to the specified class.
static public register_helper ( string $helper_class, string | boolean $helped_class = false )
$helper_class string The name of the helper class.
$helped_class string | boolean Name of the class adding the helper. Defaults to called class.

register_module() 정적인 공개 메소드

static public register_module ( string $module, integer $priority = 10 )
$module string
$priority integer

register_template() 정적인 공개 메소드

Register a template
static public register_template ( string $template, string | boolean $called_class = false )
$template string
$called_class string | boolean

remove_class_action() 정적인 공개 메소드

static public remove_class_action ( string $action, integer $priority = 10 )
$action string
$priority integer

remove_class_filter() 정적인 공개 메소드

static public remove_class_filter ( string $filter, integer $priority = 10 )
$filter string
$priority integer

root_dir() 정적인 공개 메소드

Return the root directory of the Lib/App/Site/Module/Theme class.
static public root_dir ( ) : string
리턴 string

root_url() 정적인 공개 메소드

Return the root URL of the Lib/App/Site/Module/Theme class.
static public root_url ( ) : string
리턴 string

runmode() 정적인 공개 메소드

static public runmode ( ) : WPLib_Runmode
리턴 WPLib_Runmode

set_runmode() 정적인 공개 메소드

static public set_runmode ( integer | WPLib_Runmode $runmode )
$runmode integer | WPLib_Runmode

set_stability() 정적인 공개 메소드

static public set_stability ( integer | WPLib_Stability $stability )
$stability integer | WPLib_Stability

set_theme() 정적인 공개 메소드

static public set_theme ( WPLib_Theme_Base $theme )
$theme WPLib_Theme_Base

short_prefix() 정적인 공개 메소드

static public short_prefix ( ) : boolean | string
리턴 boolean | string

site_classes() 정적인 공개 메소드

Return the list of classes declared after WPLib first loads.
static public site_classes ( ) : array
리턴 array

stability() 정적인 공개 메소드

static public stability ( ) : WPLib_Stability
리턴 WPLib_Stability

template_dir() 정적인 공개 메소드

Return the templates directory path for the called class.
static public template_dir ( ) : string
리턴 string

templates_subdir() 정적인 공개 메소드

Return the subdir name for templates.
static public templates_subdir ( ) : string
리턴 string

the_asset_url() 정적인 공개 메소드

Echo the asset path
static public the_asset_url ( string $asset_path, boolean | string $class_name = false ) : string
$asset_path string
$class_name boolean | string Name of class to return the root dir.
리턴 string

the_template() 정적인 공개 메소드

또한 보기: http://stackoverflow.com/a/7983863/102699
static public the_template ( string $template_slug, array | string $_template_vars = [], WPLib_Item_Base | object $item = null )
$template_slug string
$_template_vars array | string
$item WPLib_Item_Base | object

theme() 정적인 공개 메소드

static public theme ( ) : WPLib_Theme_Base
리턴 WPLib_Theme_Base

trigger_error() 정적인 공개 메소드

Triggers error message unless doing AJAX, XMLRPC or Cron; then it logs the error but only if Development mode.
static public trigger_error ( string $error_msg, integer $error_type = E_USER_NOTICE, boolean $echo = false )
$error_msg string
$error_type integer
$echo boolean If true use 'echo', if false use trigger_error().

use_template_global_vars() 정적인 공개 메소드

Setting WPLIB_TEMPLATE_GLOBAL_VARS to false will cause WPLib to extract $GLOBALS before loading the WP template which normally happens in wp-include/template-loader.php but WPLib hijacks that.
static public use_template_global_vars ( ) : boolean
리턴 boolean