Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6705e48f
authored
2010-02-03 14:20:21 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added new wp function, Singleton class, fireEvent (maybe?)
1 parent
bc190ca2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
2 deletions
Singleton.php
fireEvent.js
tz-tools.php
wp_functions.php
Singleton.php
0 → 100644
View file @
6705e48
<?php
Interface
iSingleton
{
public
static
function
make
();
}
abstract
class
Singleton
implements
iSingleton
{
public
function
__construct
()
{
$ref
=
new
ReflectionClass
(
$this
);
throw
new
Exception
(
$ref
->
getName
()
.
' is a singleton and can not be instantiated'
);
}
}
?>
fireEvent.js
0 → 100644
View file @
6705e48
function
fireEvent
(
element
,
event
){
if
(
document
.
createEventObject
){
// dispatch for IE
var
evt
=
document
.
createEventObject
();
return
element
.
fireEvent
(
'on'
+
event
,
evt
)
}
else
{
// dispatch for firefox + others
var
evt
=
document
.
createEvent
(
"HTMLEvents"
);
evt
.
initEvent
(
event
,
true
,
true
);
// event type,bubbling,cancelable
return
!
element
.
dispatchEvent
(
evt
);
}
}
tz-tools.php
View file @
6705e48
...
...
@@ -21,15 +21,28 @@ class TzTools {
_register_script
(
'addEvent'
,
plugins_url
(
'addEvent.js'
,
__FILE__
));
_register_script
(
'xmlhttpHandler'
,
plugins_url
(
'xmlhttpHandler.js'
,
__FILE__
));
_register_script
(
'fireEvent'
,
plugins_url
(
'fireEvent.js'
,
__FILE__
));
add_action
(
'widgets_init'
,
Array
(
'MenuWidget'
,
'init'
));
}
public
static
function
autoloader
(
$class
)
{
$file
=
dirname
(
__FILE__
)
.
'/'
.
$class
.
'.php'
;
$file
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
$class
.
'.php'
;
if
(
is_file
(
$file
))
{
requir
e
(
$file
);
includ
e
(
$file
);
}
}
}
function
add_actions
(
$class
)
{
if
(
!
class_exists
(
$class
))
{
throw
new
Exception
(
"
$class
does not exist"
);
}
$ref
=
new
ReflectionClass
(
$class
);
$actions
=
$ref
->
getMethods
(
ReflectionMethod
::
IS_STATIC
);
foreach
(
$actions
as
$action
)
{
add_action
(
$action
->
name
,
Array
(
$class
,
$action
->
name
));
}
}
?>
...
...
wp_functions.php
View file @
6705e48
...
...
@@ -13,6 +13,11 @@ function _register_script() {
return
call_user_func_array
(
'wp_register_script'
,
$params
);
}
function
_deregister_script
()
{
$params
=
func_get_args
();
return
call_user_func_array
(
'wp_deregister_script'
,
$params
);
}
function
_localize_script
()
{
$params
=
func_get_args
();
return
call_user_func_array
(
'wp_localize_script'
,
$params
);
...
...
Please
register
or
sign in
to post a comment