get_var("SHOW TABLES LIKE '" . XMASB_QUOTES_TABLE . "'") != XMASB_QUOTES_TABLE) { $sql = "CREATE TABLE " . XMASB_QUOTES_TABLE . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, author tinytext NOT NULL default '', quote text NOT NULL, imgsrc tinytext NOT NULL default '', visible boolean NOT NULL default 1, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); $author = "Bob Dole"; $quote = "The internet is a great way to get on the net."; $insert = "INSERT INTO " . XMASB_QUOTES_TABLE . " (author, quote) VALUES " . "('Bart', 'Remember, you can always find East by staring directly at the sun.'), " . "('Homer', 'Kids, you tried your best and you failed miserably. The lesson is, never try.'), " . "('Burns', 'A lifetime of working with nuclear power has left me with a healthy green glow... and left me as impotent as a Nevada boxing commissioner.'), " . "('Lisa', 'Solitude never hurt anyone. Emily Dickinson lived alone, and she wrote some of the most beautiful poetry the world has ever known... then went crazy as a loon.'), " . "('Marge', 'You should listen to your heart, and not the voices in your head.'), " . "('Moe', 'Call this an unfair generalization if you must, but old people are no good at everything.'), " . "(Ralph', 'Your toys are fun to touch. Mine are all sticky.')"; $results = $wpdb->query( $insert ); add_option("xmasb_quotes_db_version", $xmasb_quotes_db_version); } $installed_ver = get_option( "xmasb_quotes_db_version" ); if( $installed_ver != $xmasb_quotes_db_version ) { $sql = "CREATE TABLE " . XMASB_QUOTES_TABLE . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, author tinytext NOT NULL default '', quote text NOT NULL, imgsrc tinytext NOT NULL default '', visible boolean NOT NULL default 1, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); update_option( "xmasb_quotes_db_version", $xmasb_quotes_db_version ); } } function xmasb_random_quote () { global $wpdb; $table_name = $wpdb->prefix . "xmasb_quotes"; $sql = "SELECT * FROM " . XMASB_QUOTES_TABLE . " where visible=true ORDER BY RAND() limit 1"; $quotes = $wpdb->get_results($sql); if ( !empty($quotes) ) { xmasb_print_quote($quotes[0], true); } else { echo ""; } } function xmasb_print_quote ($quote, $showimage = false) { if (is_user_logged_in()) { ?>
author . '.gif'; if (file_exists($quoteimg)) { ?> $quote->author visible ) { ?>
quote; ?>
quote; ?>
author) ) { ?>
author; ?>
query($sql); if ( $sqlresponse == 1 ) { $sql = "select id from " . XMASB_QUOTES_TABLE . " where quote='" . mysql_real_escape_string($quote) . "'" . " and author='" . mysql_real_escape_string($author) . "' and visible='" . mysql_real_escape_string($visible) . "' limit 1"; $quotes = $wpdb->get_results($sql); if ( empty($quotes) || empty($quotes[0]->id) ) { ?>

That didn't go too well, and I really don't know why...

Quote has been added with id id?>.

1 ) { ?>

All hell is lose. quotes added!

get_results($sql); $sql = "SELECT * FROM " . XMASB_QUOTES_TABLE . " order by id"; $quotes = $wpdb->get_results($sql); if ( empty($quotes)) { echo "No quotes found!"; $mode = "new"; } else { ?>

XmasB Quotes

query($sql); if ( $sqlresponse == 1 ) { ?>

Quote has been edited.

Could not edit quote.

Failure: No quote ID given.

query($sql); if ( $sqlresponse == 1 ) { ?>

Quote deleted successfully

Failure: Could not delete quote.

Mode: " . $mode . "

"; } if ( $quoteID !== false ) { if ( intval($quoteID) != $quoteID ) { ?>

WTH?!?

get_results("select * from " . XMASB_QUOTES_TABLE . " where id='" . mysql_real_escape_string($quoteID) . "' limit 1"); if ( empty($quote) ) { ?>

No quote found for id

XmasB Quotes

">
visible==1 ) echo "checked" ?>/>
visible==0 ) echo "checked" ?>/>

Last 10 quotes added get_results($sql); if ( empty($quotes)) { echo "No quotes found!"; } else { ?>
    "; xmasb_print_quote($quote); echo ""; } ?>
\n"; # JS inclusion echo "\n"; } /* Widget code */ function widget_xmasb_quotes_init() { if ( !function_exists('register_sidebar_widget') ) return; function widget_xmasb_quotes($args) { extract($args); $options = get_option('widget_xmasb_quotes'); $title = $options['title']; echo $before_widget . $before_title . $title . $after_title; if ( !function_exists('xmasb_random_quote') ) { echo '
Cannot find the XmasB quotes plugin. If you have installed it check if you have activated it. If you have not installed it, you can download it from xmasb.com.
'; } else { xmasb_random_quote(); } echo $after_widget; } function widget_xmasb_quotes_control() { $options = get_option('widget_xmasb_quotes'); if ( !is_array($options) ) $options = array('title'=>'XmasB Quotes'); if ( $_POST['xmasb_quotes-submit'] ) { $options['title'] = strip_tags(stripslashes($_POST['xmasb_quotes-title'])); update_option('widget_xmasb_quotes', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); echo '

'; echo ''; } register_sidebar_widget('XmasB Quotes', 'widget_xmasb_quotes'); register_widget_control('XmasB Quotes', 'widget_xmasb_quotes_control', 300, 100); } # Add 'XmasB Quotes' page to Wordpress' Manage menu function xmasb_quotes_add_management_page() { if (function_exists('add_management_page')) { add_management_page('XmasB Quotes', 'XmasB Quotes', 8, basename(__FILE__), 'xmasb_quotes_management_page'); } } # Init Widget add_action('plugins_loaded', 'widget_xmasb_quotes_init'); # CSS/JS inclusion in HEAD add_action('wp_head', 'xmasb_quotes_head_inclusion'); add_action('admin_head', 'xmasb_quotes_head_inclusion'); add_action('activate_' . dirname(plugin_basename(__FILE__)) . '/' . basename(plugin_basename(__FILE__)), 'xmasb_quotes_install'); add_action('admin_menu', 'xmasb_quotes_add_management_page');