Support » Plugins » Hacks » Getting a plugin to activate when remote publishing

  • the following works perfectly fine when updating a post / publishing a post manually. However the plugin wont activate when a post is published remotely. There is so little documentation on ‘xmlrpc_publish_post’ that I really have no idea what it is I’m doing wrong.

    add_action('xmlrpc_publish_post', 'nelioefi_update_url' );
    add_action('the_post', 'nelioefi_update_url' );
    add_action('save_post', 'nelioefi_update_url' );
    add_action('draft_to_publish', 'nelioefi_update_url' );
    add_action('new_to_publish', 'nelioefi_update_url' );
    add_action('pending_to_publish', 'nelioefi_update_url' );
    add_action('future_to_publish', 'nelioefi_update_url' );
    
    function nelioefi_update_url( $post_id ) {
    // get the post object
    $post = get_post( get_the_ID() );
    // we need just the content
    $content = $post->post_content;
    // we need a expression to match things
    $regex = '/src="([^"]*)"/';
    // we want all matches
    preg_match_all( $regex, $content, $matches );
    // reversing the matches array
    $matches = array_reverse($matches);
    
        $urlplz = print_r($matches[0][0], true);
        if ( $urlplz ) update_post_meta( $post_id, _nelioefi_url(), $urlplz );
        }
    
    function remove_images( $content ) {
       $postOutput = preg_replace('/<img[^>]+./','', $content);
       return $postOutput;
    }
    add_filter( 'the_content', 'remove_images', 100 );
  • The topic ‘Getting a plugin to activate when remote publishing’ is closed to new replies.