<?php
// A)
// inside your template
if ( function_exists( 'the_attachment_stuff()' ) )
{
// do stuff
}
// better/faster
if ( class_exists( 'attachment_plugin_class' ) )
{
// do stuff
}
// B)
// inside your template
do_action( 'the_attachment_suff');
// means setting this inside your plugin
// this avoids throwing errors or aborting if the hook isn't in your template
add_action( 'the_attachment_stuff', 'your_callback_fn' );
// C)
function add_attachment_stuff()
{
if ( ! is_admin() )
return;
// the following is guess and theory...
$content = get_the_content();
$content .= the_attachment_stuff(); // in case the attachment_stuff returns instead of echos the result/output.
}
// @link http://codex.wordpress.org/Plugin_API/Action_Reference
// only add on publish, on 'post_save' we would add it multiple times
add_action( 'publish_post', 'add_attachment_stuff', 100 );
add_action( 'publish_phone', 'add_attachment_stuff', 100 );