| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Manager |
| 5 |
* @subpackage Core Functions |
| 6 |
* @category Functions |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://oplugins.com/ |
| 10 |
* @email info@oplugins.com |
| 11 |
* |
| 12 |
* @modified 29.09.2015 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
//////////////////////////////////////////////////////////////////////////////// |
| 18 |
// Internal plugin action hooks system /////////////////////////////////// |
| 19 |
//////////////////////////////////////////////////////////////////////////////// |
| 20 |
global $wpbm_action, $wpbm_filter; |
| 21 |
|
| 22 |
|
| 23 |
function add_wpbm_filter($filter_type, $filter) { |
| 24 |
global $wpbm_filter; |
| 25 |
|
| 26 |
$args = array(); |
| 27 |
if ( is_array($filter) && 1 == count($filter) && is_object($filter[0]) ) // array(&$this) |
| 28 |
$args[] =& $filter[0]; |
| 29 |
else |
| 30 |
$args[] = $filter; |
| 31 |
for ( $a = 2; $a < func_num_args(); $a++ ) |
| 32 |
$args[] = func_get_arg($a); |
| 33 |
|
| 34 |
if ( is_array($wpbm_filter) ) |
| 35 |
|
| 36 |
if ( isset($wpbm_filter[$filter_type]) ) { |
| 37 |
if ( is_array($wpbm_filter[$filter_type]) ) |
| 38 |
$wpbm_filter[$filter_type][]= $args; |
| 39 |
else |
| 40 |
$wpbm_filter[$filter_type]= array($args); |
| 41 |
} else |
| 42 |
$wpbm_filter[$filter_type]= array($args); |
| 43 |
else |
| 44 |
$wpbm_filter = array( $filter_type => array( $args ) ) ; |
| 45 |
} |
| 46 |
|
| 47 |
function remove_wpbm_filter($filter_type, $filter) { |
| 48 |
global $wpbm_filter; |
| 49 |
|
| 50 |
if ( isset($wpbm_filter[$filter_type]) ) { |
| 51 |
for ($i = 0; $i < count($wpbm_filter[$filter_type]); $i++) { |
| 52 |
if ( $wpbm_filter[$filter_type][$i][0] == $filter ) { |
| 53 |
$wpbm_filter[$filter_type][$i] = null; |
| 54 |
return; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
function apply_wpbm_filter($filter_type) { |
| 61 |
global $wpbm_filter; |
| 62 |
|
| 63 |
|
| 64 |
$args = array(); |
| 65 |
for ( $a = 1; $a < func_num_args(); $a++ ) |
| 66 |
$args[] = func_get_arg($a); |
| 67 |
|
| 68 |
if ( count($args) > 0 ) |
| 69 |
$value = $args[0]; |
| 70 |
else |
| 71 |
$value = false; |
| 72 |
|
| 73 |
if ( is_array($wpbm_filter) ) |
| 74 |
if ( isset($wpbm_filter[$filter_type]) ) |
| 75 |
foreach ($wpbm_filter[$filter_type] as $filter) { |
| 76 |
$filter_func = array_shift($filter); |
| 77 |
$parameter = $args; |
| 78 |
$value = call_user_func_array($filter_func,$parameter ); |
| 79 |
} |
| 80 |
return $value; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
function make_wpbm_action($action_type) { |
| 85 |
global $wpbm_action; |
| 86 |
|
| 87 |
|
| 88 |
$args = array(); |
| 89 |
for ( $a = 1; $a < func_num_args(); $a++ ) |
| 90 |
$args[] = func_get_arg($a); |
| 91 |
|
| 92 |
if ( is_array($wpbm_action) ) |
| 93 |
if ( isset($wpbm_action[$action_type]) ) |
| 94 |
foreach ($wpbm_action[$action_type] as $action) { |
| 95 |
$action_func = array_shift($action); |
| 96 |
$parameter = $action; |
| 97 |
call_user_func_array($action_func,$args ); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
function add_wpbm_action($action_type, $action) { |
| 102 |
global $wpbm_action; |
| 103 |
|
| 104 |
$args = array(); |
| 105 |
if ( is_array($action) && 1 == count($action) && is_object($action[0]) ) // array(&$this) |
| 106 |
$args[] =& $action[0]; |
| 107 |
else |
| 108 |
$args[] = $action; |
| 109 |
for ( $a = 2; $a < func_num_args(); $a++ ) |
| 110 |
$args[] = func_get_arg($a); |
| 111 |
|
| 112 |
if ( is_array($wpbm_action) ) |
| 113 |
if ( isset($wpbm_action[$action_type]) ) { |
| 114 |
if ( is_array($wpbm_action[$action_type]) ) |
| 115 |
$wpbm_action[$action_type][]= $args; |
| 116 |
else |
| 117 |
$wpbm_action[$action_type]= array($args); |
| 118 |
} else |
| 119 |
$wpbm_action[$action_type]= array($args); |
| 120 |
|
| 121 |
else |
| 122 |
$wpbm_action = array( $action_type => array( $args ) ) ; |
| 123 |
} |
| 124 |
|
| 125 |
function remove_wpbm_action($action_type, $action) { |
| 126 |
global $wpbm_action; |
| 127 |
|
| 128 |
if ( isset($wpbm_action[$action_type]) ) { |
| 129 |
for ($i = 0; $i < count($wpbm_action[$action_type]); $i++) { |
| 130 |
if ( $wpbm_action[$action_type][$i][0] == $action ) { |
| 131 |
$wpbm_action[$action_type][$i] = null; |
| 132 |
return; |
| 133 |
} |
| 134 |
} |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
function get_wpbm_option( $option, $default = false ) { |
| 140 |
|
| 141 |
$u_value = apply_wpbm_filter('wpbm_get_option', 'no-values' , $option, $default ); |
| 142 |
if ( $u_value !== 'no-values' ) return $u_value; |
| 143 |
|
| 144 |
return get_option( $option, $default ); |
| 145 |
} |
| 146 |
|
| 147 |
function update_wpbm_option ( $option, $newvalue ) { |
| 148 |
|
| 149 |
$u_value = apply_wpbm_filter('wpbm_update_option', 'no-values' , $option, $newvalue ); |
| 150 |
if ( $u_value !== 'no-values' ) return $u_value; |
| 151 |
|
| 152 |
return update_option($option, $newvalue); |
| 153 |
} |
| 154 |
|
| 155 |
function delete_wpbm_option ( $option ) { |
| 156 |
|
| 157 |
$u_value = apply_wpbm_filter('wpbm_delete_option', 'no-values' , $option ); |
| 158 |
if ( $u_value !== 'no-values' ) return $u_value; |
| 159 |
|
| 160 |
return delete_option($option ); |
| 161 |
} |
| 162 |
|
| 163 |
function add_wpbm_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) { |
| 164 |
|
| 165 |
$u_value = apply_wpbm_filter('wpbm_add_option', 'no-values' , $option, $value, $deprecated, $autoload ); |
| 166 |
if ( $u_value !== 'no-values' ) return $u_value; |
| 167 |
|
| 168 |
return add_option( $option, $value , $deprecated , $autoload ); |
| 169 |
} |
| 170 |
|