Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 8 months ago

#30464 closed defect (bug) (worksforme)

kses_allowed_protocols filter not working

Reported by: hatul's profile hatul Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: General Keywords: close
Focuses: Cc:

Description

I try add filter to allowed protocols but its not working.

My code:

function wpse_allow_sms_protocol( $protocols ) {
    $protocols = array('sms');
    return $protocols;
}

add_filter( 'kses_allowed_protocols', 'wpse_allow_sms_protocol' );
print_r(wp_allowed_protocols());

print:

 Array ( [0] => http [1] => https [2] => ftp [3] => ftps [4] => mailto [5] => news [6] => irc [7] => gopher [8] => nntp [9] => feed [10] => telnet [11] => mms [12] => rtsp [13] => svn [14] => tel [15] => fax [16] => xmpp ) 

I found this problem in forum too without answer.

Change History (6)

#1 @miqrogroove
10 years ago

You are probably trying to hook the filter after the filter runs. Make sure you are adding filters during initialization.

#2 @miqrogroove
10 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

For reference, the 'kses_allowed_protocols' filter runs before the 'init' action. Try using the 'plugins_loaded' action, or just hook the filter at the top of your plugin.

Last edited 10 years ago by miqrogroove (previous) (diff)

#3 @DrewAPicture
10 years ago

  • Milestone Awaiting Review deleted

#4 @hatul
10 years ago

  • Keywords close added

thanks. if I run its in plugins_loaded the code is working.

function wpse_allow_sms_protocol( $protocols ) {
    $protocols = array('sms');
    return $protocols;
}
add_action('plugins_loaded', function(){add_filter('kses_allowed_protocols', 'wpse_allow_sms_protocol' );});
print_r(wp_allowed_protocols());

#5 @hatul
10 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I wrong. My code still not working.
I get:

Array ( [0] => http [1] => https [2] => ftp [3] => ftps [4] => mailto [5] => news [6] => irc [7] => gopher [8] => nntp [9] => feed [10] => telnet [11] => mms [12] => rtsp [13] => svn [14] => tel [15] => fax [16] => xmpp ) 

#6 @miqrogroove
10 years ago

  • Resolution set to worksforme
  • Status changed from reopened to closed

I suggest getting help in the support areas. We do not offer support services on Trac tickets.

Note: See TracTickets for help on using tickets.