MyLiveSignature at the bottom of every post Version: 0.4 Author: miCRoSCoPiC^eaRthLinG Author URI: http://chaos-laboratory.com License: GPL Last modified: 2008-05-24 11:45pm */ // Database Version $livesig_db_version = "1.0"; // Settings array $livesig_general_settings = array( "signature-placement" => "front" ); // Database: Table installation function livesig_install () { global $wpdb; global $livesig_db_version; global $livesig_general_settings; $table_name = $wpdb->prefix . "livesig"; if( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) { $sql = "CREATE TABLE " . $table_name . " ( id bigint(20) NOT NULL, livesig_code text NOT NULL, UNIQUE KEY id (id) );"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); // Add database version add_option( "livesig_db_version", $livesig_db_version ); // Add default signature placement add_option( "livesig-general-settings", serialize( $livesig_general_settings ) ); } // if } // livesig_install // Admin Panel function livesig_add_pages() { add_options_page( 'LiveSig Options', 'LiveSig', 8, __FILE__, 'livesig_options_page' ); } // livesig_add_pages // Options Page function livesig_options_page() { // Form submitted if( isset( $_POST[ 'livesig-general-update' ] ) ) { $livesig_general_settings[ 'signature-placement' ] = $_POST[ 'signature-placement' ]; update_option( 'livesig-general-settings', serialize( $livesig_general_settings ) ); _e( '

LiveSig General Settings updated.

' ); } $livesig_general_settings = unserialize( get_option( 'livesig-general-settings' ) ); $selected_radio = '
Signature placement:'; $selected_radio .= '
'; _e( '

LiveSig Options

Instructions: This section defines general settings for the LiveSig plug-in. If you change any of the settings here, you\'re required to save them using the Save button on this screen.

Warning: Don\'t confuse this with the Save button in the Signatures section. That is meant for saving the user-specific signatures only.

' . wp_nonce_field( "update-options" ) . $selected_radio . 'More options coming soon...

Usage: Select the Role and User from the list on the left and paste the signature code snippet provided by MyLiveSignature in the space below and hit Save. If you don\'t have your Live Signature yet, please head over to the MyLiveSignature site and get yourself one for free.

Disabling: If you wish to stop displaying your Signature, simply delete the code here for the respective user and press Save. Alternatively, disabling this plug-in should also do the trick - but this will disable the signature for all users.

 User Role:
 Username:
 Status:
Select a User Role role first
 

Paste the MyLiveSignature code here exactly as provided - without any alteration, unless you\'re an an advanced user and know what you are doing.

' ); } // livesig_options_page // Signature Hook: The function that adds the signature after each post function signature_hook( $content = '' ) { // Post global $post; // DB Object global $wpdb; $livesig_general_settings = unserialize( get_option( 'livesig-general-settings' ) ); // Get Signature $signature = $wpdb->get_row( "SELECT livesig_code FROM wp_livesig WHERE wp_livesig.id IN ( SELECT post_author FROM $wpdb->posts WHERE $wpdb->posts.ID = '$post->ID' ) " ); switch( $livesig_general_settings[ 'signature-placement' ] ) { case 'front': // Display singature only in Front Page only if( !is_single() ) { // If code is present add signature if( !empty ( $signature->livesig_code ) ) { // Add signature to content $content_with_signature = $content . "
" . stripslashes( $signature->livesig_code ); // Print out the modified content echo $content_with_signature; } } else echo $content; break; case 'single': // Display singature only in SINGLE mode if( is_single() ) { // If code is present add signature if( !empty ( $signature->livesig_code ) ) { // Add signature to content $content_with_signature = $content . "
" . stripslashes( $signature->livesig_code ); // Print out the modified content echo $content_with_signature; } } else echo $content; break; case 'both': // Display singature in both // If code is present add signature if( !empty ( $signature->livesig_code ) ) { // Add signature to content $content_with_signature = $content . "
" . stripslashes( $signature->livesig_code ); // Print out the modified content echo $content_with_signature; } else echo $content; break; } // switch } // Activation hook register_activation_hook( __FILE__, 'livesig_install' ); // Add Options Page add_action( 'admin_menu', 'livesig_add_pages' ); // Add content hook add_filter( 'the_content', 'signature_hook', 1 ); ?>