Support » Plugin: Live Blogging » [Bug fix] Unhooking of filters not working for class methods

  • L.S.,

    I encountered a quite annoying oversight in the offered ‘unhooking of filters’-functionality.

    The Live-blogging plugin poses that it provides a way to unhook filters from the_content. However, it only allow for unhooking of global namespace functions, not for the unhooking of class methods – which is the more commonly used/preferred way of building plugins-.

    I’ve rewritten the relevant code to allow for both functions and class methods.

    You will need to replace the function live_blogging_get_entry() in the
    /wp-content/plugins/live-blogging/live-blogging.php file (line 1068 – line 1110 in v2.2.6) with the code I provide you with here:
    http://pastebin.com/H9q2je9Z

    Once the function has been replaced, the user can add the following to the Live Blogging Settings -> Advanced Settings to make the unhooking work for class method:
    class_object_variable_name, method_name
    where class_object_variable_name is the variable name of the instantiatied object in the global namespace.

    Hope this helps & that you will include this fix in the next version of the plugin.

    Smile,
    Juliette

    http://wordpress.org/extend/plugins/live-blogging/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Hi jrf,

    If you want to raise this as a pull request (the code has changed significantly since what you’ve posted above) I can merge this in: https://github.com/cnorthwood/liveblogging

    Thanks

    Hi Chris,

    Pull request has been send 😉

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    And merged, thanks!

    Excellent! Thanks 😉

    Can I get an example of using:
    class_object_variable_name, method_name

    The add filter line for the Send to Kindle Plugin looks like this:
    add_filter( ‘the_content’, array( $this, ‘attach_to_content’ ) );

    I cannot get it to work.

    @rlg,

    Looks like my code did get merged with the development code @ Github, but has not been released yet, so it will only work if you download the latest version of the plugin from GitHub.

    Secondly, the Send to Kindle Plugin does not instantiate their class with a variable in the global namespace, so I can see your problem.

    You could make it work, but you’d need to edit the Send to Kindle plugin to do so.

    At the bottom of their send-to-kindle.php file, look for the following code:

    function STK_loader() {
            $kindle_loader = STK_Button::get_instance();
            include_once( dirname( __FILE__ ) . '/jetpack.php' );
    }
    
    add_action( 'init', 'STK_loader' );

    And replace the second line with:

    $GLOBALS['kindle_loader'] = STK_Button::get_instance();

    If you do that *and* use the latest version of the Liveblogging plugin downloaded from GitHub, you could then unhook it by adding the following to the settings:

    kindle_loader, attach_to_content

    Hope this helps!

    Smile,
    Juliette

    Hi Juliette,

    I did not download from github, but copied your code from the pastebin link above.

    Anyway, thank you for your kindess and swift response, the mod worked like a charm! I was trying to do something like above, but had the incorrect syntax, thanks for teaching me something new.

    You’re very welcome, glad to hear it works 😉

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Bug fix] Unhooking of filters not working for class methods’ is closed to new replies.