Coder Social home page Coder Social logo

conduit-innovation / gorilla-claw Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 0.0 650 KB

WordPress action / filter runtime toolkit library, with monkey-patching capabilities.

License: MIT License

PHP 100.00%
actions filters hooks-api monkey-patching wordpress

gorilla-claw's People

Contributors

github-actions[bot] avatar talss89 avatar

Stargazers

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

Watchers

 avatar

gorilla-claw's Issues

feature: profiling / timing

It makes sense to me that developers will need to perf check any hooks they monkey-patch in some way.

It would be nice to include a basic API for this. Perhaps something like:

define('GORILLA_PROFILE', true);

/* Do something with hooks */

gorillaclaw_perf_report();

Feature criteria:

  • Need: Minimal performance impact
  • Need: No performance impact when disabled (default)
  • Want: Some kind of machine readable output, so we can integrate with CI pipelines

Injection does not bind scope correctly

Cannot access the original scope / $this from within injected handlers.

$hooks->inject(function($input) {
            $this->{'id'} = 1;
            return $input . '-before-' . $this->{'get_private_id'}();
        }, function($input) {
            $this->{'id'} = 2;
            return $input . '-after-' . $this->{'get_id'}();
        });

Throws: Error: Call to undefined method GorillaClaw\Test\HookTest::get_private_id()

feature: intercept object access

It should be possible to intercept calls / accesses made by a handler to $this, without replacing the original handler.

This means we can register on_call type events that are fired when a filter / action handler tries to access it's own $this. We can then either return a new value to skip execution of the $this->some_method() call, or return null to allow the call to continue.

This is a huge rabbit hole, and will need some thought. In theory we could pre and post process any object accessor similar to how we inject().

  • Create event trigger / handler subsystem
  • Intercept object method calls
  • Override and skip object method calls
  • Intercept property accesses
  • Intercept property writes
  • Recursive HookProxy works (ie. proxying-a-proxy should proxy the original object)

Branch feature/intercept tracks this feature.

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.