Page 1 of 1

Hook system :Hook_xh

Posted: Tue Dec 29, 2015 10:10 am
by utaka
[ external image ]
I wish. That CMSimple_xh is, with a more flexible HookSystem
The wordpress is great, is equipped with a Hook system, I think flexibility is that plug-ins can be added.
Hook_xh: HookSystem for CMSimple_xh.very simple.However, it is very powerful.
Download : https://github.com/bbfriend/hook_xh

Code: Select all

global $hooks

add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 )
has_filter($tag, $function_to_check = false)
apply_filters( $tag, $value )
apply_filters_ref_array($tag, $args)
remove_filter( $tag, $function_to_remove, $priority = 10 )
remove_all_filters( $tag, $priority = false )
current_filter()
current_action()
doing_filter( $filter = null )
doing_action( $action = null )

add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
do_action($tag, $arg = '')
did_action($tag)
do_action_ref_array($tag, $args)
has_action($tag, $function_to_check = false)
remove_action( $tag, $function_to_remove, $priority = 10 )
remove_all_actions($tag, $priority = false)
_call_all_hook($args)
_filter_build_unique_id($tag, $function, $priority) 
The PHP Hooks Class is a fork of the WordPress filters hook system rolled in to a class to be ported into any php based system
This class is heavily based on the WordPress plugin API and most (if not all) of the code comes from there
Original : https://github.com/bainternet/PHP-Hooks

Re: Hook system

Posted: Thu Jan 28, 2016 3:25 pm
by utaka
V1.0.2
 Change in easy-to-use function

Example Code

Posted: Mon Aug 22, 2016 10:19 am
by utaka

Code: Select all

function xh_func($i, $x....)
{
  ..................
  $val01 = ....
  $val02 = ....

	return $return_val;
}
Change to

Code: Select all

function xh_func($i, $x....)
{
	..................
  $val01 = ....
  $val02 = ....

	return apply_filters('hook_name', $return_val, $val01,$val02);
}
Example in Plugin

Code: Select all

function my_func($atr1, $atr2){
	//$atr1 == $val01
	//$atr2 == $val02
	......
	$new_return_val = ...........

	// Further expansion(ex. my_func's Advance Plugin)
	return apply_filters('my_func_hook', $new_return_val, $atr1,$atr2);
}
add_filter('hook_name', 'my_func', 10, 2);