GithubHelp home page GithubHelp logo

bainternet / php-hooks Goto Github PK

View Code? Open in Web Editor NEW
274.0 274.0 104.0 274 KB

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 .

Home Page: http://bainternet.github.com/PHP-Hooks/

License: GNU General Public License v3.0

PHP 100.00%

php-hooks's People

Contributors

bainternet avatar garyjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-hooks's Issues

Suggestion ...

Hi -- just stumbled upon that class I didn't know about. Very nice job!

One question / suggestion now: where is the PHP-HTTP class based off WordPress' Wp_Http class? ;-)

Different result on multiple hooks

Please tell me how can I perform like this,

if (!function_exists('app_hooks')) {

    function app_hooks() {
        require_once("php-hooks.php");
        global $hooks;
        return $hooks;
    }

}

app_hooks()->add_filter('my_filter', function ($value) {
    echo $value; //output: some value to be passed
    return "x";
});
app_hooks()->add_filter('my_filter', function ($value) {
    echo $value; //output: xy (but should be 'some value to be passed')
    return "y";
});

$my_tabs = array();
$my_tabs[] = app_hooks()->apply_filters('my_filter', 'some value to be passed');

echo "<pre>";
print_r($my_tabs);
exit;

The $my_tabs is giving this output:

Array
(
    [0] => y
)

But I need both values like this:

Array
(
    [0] => x,
    [1] => y
)

Can you please inform me where am I wrong or if this is possible.
Thanks in advance.

typo: $$ -> $


count((array)$$this->filters[$tag][$priority])

count((array)$this->filters[$tag][$priority])

Unable to pass variables using apply_filters

i am unable to pass more than 1 values using apply_filters .
function test(){
return $hook->apply_filters('myeelas', 'tet',31,414);
}
$hook->add_filter('myeelas','te',10,3);
function te(){
var_dump(func_get_args());
}

test();

Composer support

Great work on this project.

Not an issue I know but can we get composer support on this?

Alternatively, I can add composer support and create a pull request?

Richard

possible to return variables?

is it possible to return a variable in one of the hook functions that run for all the rest of the functions on the same hook?

Action & Filter Not Wokring With flexible menu builder

Sir,

I have downloaded your php hooks script and flexible menu builder from github https://github.com/lavary/fleximenu and i have the below code with the filter

$menu = new Menu;
$menu->add('Home', '');
$menu_user = $menu->add('Users', '');
$about = $menu->add('About', 'about');
$about->link->append(' <span class="caret"></span>');
$about->link->attributes(array('class' => 'link-item', 'target' => '_blank'));
$about->attributes('data-model', 'nice');
$about->add('Who we are?', array('url' => 'who-we-are',  'class' => 'navbar-item whoweare','display' => false));
$about->add('What we do?', array('url' => 'what-we-do',  'class' => 'navbar-item whatwedo'));
$menu->add('Portfolio', 'portfolio');
$menu->add('Contact',   'contact');
$hooks->do_action_ref_array( 'menuusers', array( &$menu ) );

$hooks->add_action('menuusers','showusernmenu');
function showusernmenu($menu) {      
    var_dump($menu);
    echo $menu->asUl( array('class' => 'awesome-ul') );
}

its not calling the action function i have vardump do_action_ref_array & add_action and got the return value as true and also debugged and its highlighting at both line [do_action_ref_array & add_action] but my function is not calling

PSR-2

Since this class is to be used outside of WP, and since a lot of the code already doesn't follow the WP code standards, it would make sense to format is using the PSR-2 guidelines.

A few bracket changes here and there, spaces insteads of tabs and so on. To be compatible with PSR-1 (which is a requirement of PSR-2), the methods must be named as camelcase, which would be a BC break. camelCase methods is what all of native PHP classes though (it's WP itself which does things differently.)

I can do a PR, but wanted to see if you'd be interested in moving the project in that direction?

1 do_action for 3 action ?

I have :
$hooks->do_action('notif_collection_action');

And

$classes_actions = array( 
"notif_collection_action"   => array("Notif\NotifListener"),
"notif_collection_action"   => array("User\NotifListener"),
"notif_collection_action"   => array("Ent\NotifListener"));

foreach ($this->classes_actions as $action => $classes) {foreach ($classes as $class) {
$hooks->add_action($action, array( $class, 'action_method' ));
}}

My problem is that only the last action is done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.