Writing editor content to a file

You should hook save_post instead of publish_post. publish_post only runs when a post is initially published and won’t catch subsequent saves.

Additionally, the publish_post hook passes parameters to your function and those should be used to retrieve info about the post being published rather get_the_content(), which only works when you’re inside the loop.

I think you’re looking for something like this:

function pht_write_file($post_id){
    if(get_post_status($post_id) !== 'publish') return; //only run if post is published
    $post = get_post($post_id);
    $content = $post->post_content;
    $file = WP_PLUGIN_DIR."/myplugin/test.xml"; 
}
add_action('save_post', 'pht_write_file');

This function will also correctly hook to publish_post in the case where you did mean for the text to only be saved on publish instead of on save.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş