Skip to content

Commit b977325

Browse files
authored
Merge pull request #384 from Automattic/fix/filters-not-firing
Apply filter `liveblog_active_commands` later on so that hooking works
2 parents 7276863 + 2fc4130 commit b977325

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ New iPad announced, launching next week — more info to come. /key
5858
You can add new commands easily with a filter, the most basic command will add a class to entry, so you could do a simple `/highlight` which would add `type-highlight` to the entry container, letting you style the background color:
5959

6060
``` php
61-
add_filter( 'liveblog_active_commands', array( __CLASS__, 'add_highlight_command' ), 10 );
61+
add_filter( 'liveblog_active_commands', 'add_highlight_command', 10 );
6262

6363

64-
public static function add_highlight_command( $commands ) {
64+
function add_highlight_command( $commands ) {
6565
$commands[] = highlight;
6666
return $commands;
6767
}

classes/class-wpcom-liveblog-entry-extend-feature-commands.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function load() {
5656

5757
// Allow plugins, themes, etc. to change
5858
// the current command set.
59-
$this->commands = apply_filters( 'liveblog_active_commands', $this->commands );
59+
add_action( 'after_setup_theme', array( $this, 'custom_commands' ), 10 );
6060

6161
// This is the regex used to revert the
6262
// generated author html back to the
@@ -84,6 +84,13 @@ public function load() {
8484
add_action( 'liveblog_insert_entry', array( $this, 'do_action_per_type' ), 10, 2 );
8585
}
8686

87+
/**
88+
* Returns the custom commands and allows for customizing the command set
89+
*
90+
*/
91+
public function custom_commands() {
92+
$this->commands = apply_filters( 'liveblog_active_commands', $this->commands );
93+
}
8794
/**
8895
* Gets the autocomplete config.
8996
*

0 commit comments

Comments
 (0)