Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I can't to call the a filter hook on a php external file of wordpress.

This is my code - my_external_file.php -:

<?php
require( dirname(__FILE__) . '/../../../../../../../wp-load.php');

add_filter('init', 'test_function');

function test_function (){
    global $global_text_to_shown;

    $global_text_to_shown = 'Hello World';

}

global $global_text_to_shown;

$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );

//This work fine, shown editor good.
wp_editor( $global_text_to_show, 'content', array( 'media_buttons' => false, 'tinymce' => true, 'quicktags' => $quicktags_settings ) );

//Load js and work fine the editor - wp_editor function.
wp_footer();

?>

The problem is that not load or execute the filter hook and 'test_function' function, can't take value: $global_text_to_shown = 'Hello World';

How i can execute hook on external PHP file?

share|improve this question
    
This PHP file is call: localhost/wp352/wp-content/plugins/test/theme/widgets/rich-text/… –  josecarlos Aug 28 '13 at 21:36
1  
I am pretty sure that wp-load.php will run the init hook before your function gets attached. But please explain what you are doing and why. There may be a better way to do this. –  s_ha_dum Aug 28 '13 at 21:50
    
@s_ha_dum: I need call a hook filter in this php file. The wp_editor, html specifics, not send submit data and i need add this hook add_filter('tiny_mce_before_init', 'update_rte'); this function work fine when i doing on post/page. Can help me now? You need more description about? –  josecarlos Aug 28 '13 at 22:29
1  
That doesn't tell me what you are doing or why. What is the point? What is the end goal? I suspect you may have an XY problem. –  s_ha_dum Aug 28 '13 at 22:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.