WordPress.org

Plugin Directory

Changeset 188456


Ignore:
Timestamp:
12/31/09 16:48:07 (4 years ago)
Author:
vhauri
Message:

commited version 1.1 to trunk

Location:
tagline-rotator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tagline-rotator/trunk/readme.txt

    r179679 r188456  
    44Tags: taglines, random, header 
    55Requires at least: 2.0.2 
    6 Tested up to: 2.8.6 
     6Tested up to: 2.9 
    77Stable tag: trunk 
    88 
     
    1515it within your blog. It offers a couple of advantages over some of the other similar plugins I found, most  
    1616importantly that it uses the mySQL database within WordPress, and therefore should not slow down page loads  
    17 significantly. 
     17significantly. As of version 1.1, it is now WP database prefix compliant, meaning it will use the database prefix stored in your WordPress settings, and should be WPMU compliant. 
    1818 
    1919== Installation == 
     
    4040 
    4141== Known Bugs/Limitations == 
    42 Of course, the current version of this plugin is 1.0, so there are a  
     42Of course, the current version of this plugin is 1.1, so there are a  
    4343couple of bugs/limitations that you should know about. 
    4444 
     
    5656Version 0.4b - 3-13-2009 - Allows compatibility with themes which use either the bloginfo() or get bloginfo() function to display the tagline. 
    5757Version 1.0 - 3-15-2009 - Allows compatibility with themes which use either the bloginfo() or get bloginfo() function to display the tagline. Has been tested good. 
     58Version 1.1 - 12-31-2009 - Plugin database table is now compliant with WordPress database prefix (i.e. it will use the database prefix set by WP, not the previous wp_tagline_rotator). This should make it WPMU compatible as well, although this is still untested. Upgrading automatically through WordPress from a previous version will also rename the database table to use the correct prefix. 
  • tagline-rotator/trunk/tagline-rotator.php

    r102848 r188456  
    55Plugin URI: http://neverblog.net/tagline-rotator-plugin-for-wordpress 
    66Description: Displays a random tagline from a database list. You can manage taglines through Settings->Tagline Rotator. 
    7 Version: 1.0 
     7Version: 1.1 
    88Author: Vasken Hauri 
    99Author URI: http://neverblog.net 
     
    1111 
    1212/*   
    13 Copyright 2008  Vasken Hauri  (email : vhauri (at) gmail dot com) 
     13Copyright 2010  Vasken Hauri  (email : vhauri (at) gmail dot com) 
    1414 
    1515    This program is free software; you can redistribute it and/or modify 
     
    2929*/ 
    3030 
     31 
     32//new in version 1.1 to call the upgrade function 
     33register_activation_hook(__FILE__,'tagline_upgrade_check'); 
     34 
    3135// set the option for the tables to false until created 
    3236add_option('tagline_tables','false'); 
     
    5761function tagline_options_page() { 
    5862 
     63    //new in version 1.1. sets the database value to the wordpress database prefix 
     64    global $wpdb; 
     65    $table_name = $wpdb->prefix . "tagline_rotator"; 
    5966 
    6067//loop through the checkboxes to see what to delete 
     
    6673    { 
    6774 
    68         $query = "DELETE FROM wp_tagline_rotator WHERE id='" . $x . "' LIMIT 1"; 
     75        $query = "DELETE FROM " . $table_name ." WHERE id='" . $x . "' LIMIT 1"; 
    6976        $result = mysql_query($query) or die('Query did not work'); 
    7077   
     
    7986            foreach ($text as $key => $y) 
    8087                { 
    81                     $query = "UPDATE wp_tagline_rotator SET random_tagline='" . $y . "' WHERE id='" . $id_numbers[$key] . "' LIMIT 1"; 
     88                    $query = "UPDATE " . $table_name . " SET random_tagline='" . $y . "' WHERE id='" . $id_numbers[$key] . "' LIMIT 1"; 
    8289                    $result = mysql_query($query) or die ('Could not update tagline');                                   
    8390                } 
     
    8794if(isset($_POST['new_tagline'])) 
    8895{ 
    89  
    90 $new_tagline = $_POST['new_tagline']; 
    91  
    92 $query = "INSERT INTO wp_tagline_rotator SET random_tagline=\"" . $new_tagline . "\""; 
    93 mysql_query($query) or die ('Unable to add tagline.'); 
     96    //new in version 1.1. sets the database value to the wordpress database prefix 
     97    global $wpdb; 
     98    $table_name = $wpdb->prefix . "tagline_rotator"; 
     99 
     100    $new_tagline = $_POST['new_tagline']; 
     101 
     102    $query = "INSERT INTO " . $table_name . " SET random_tagline=\"" . $new_tagline . "\""; 
     103    mysql_query($query) or die ('Unable to add tagline.'); 
    94104 
    95105} 
     
    108118 
    109119<?php 
     120    //new in version 1.1. sets the database value to the wordpress database prefix 
     121    global $wpdb; 
     122    $table_name = $wpdb->prefix . "tagline_rotator"; 
     123 
    110124// delete any empty rows in the form 
    111 $query = "DELETE FROM wp_tagline_rotator WHERE random_tagline = ''"; 
     125$query = "DELETE FROM " . $table_name . " WHERE random_tagline = ''"; 
    112126mysql_query($query); 
    113127 
    114128// and select the non-empty ones to populate our checkboxes 
    115 $query = "SELECT random_tagline,id FROM wp_tagline_rotator WHERE random_tagline!=''"; 
     129$query = "SELECT random_tagline,id FROM " . $table_name . " WHERE random_tagline!=''"; 
    116130$result = mysql_query($query); 
    117131while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
     
    155169function createtables () 
    156170{ 
    157 $tagline_tables = get_option('tagline_tables'); 
    158  
    159  
    160 if($tagline_tables == 'false') 
    161 { 
    162 $query = "CREATE TABLE wp_tagline_rotator (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,random_tagline VARCHAR( 200 ) NOT NULL)"; 
    163 echo $query; 
    164 mysql_query($query) or die ('Could not create tagline table'); 
    165 update_option('tagline_tables','true'); 
    166 } 
     171 
     172    //new in version 1.1. sets the database value to the wordpress database prefix 
     173    global $wpdb; 
     174    $table_name = $wpdb->prefix . "tagline_rotator"; 
     175     
     176    $tagline_tables = get_option('tagline_tables'); 
     177 
     178 
     179    if($tagline_tables == 'false') 
     180    { 
     181        $query = "CREATE TABLE " . $table_name . " (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,random_tagline VARCHAR( 200 ) NOT NULL)"; 
     182        echo $query; 
     183        mysql_query($query) or die ('Could not create tagline table'); 
     184        update_option('tagline_tables','true'); 
     185    } 
    167186 
    168187} 
     
    171190function mybloginfo($output = '') { 
    172191     
    173     $query = "SELECT random_tagline FROM wp_tagline_rotator ORDER BY rand() limit 1"; 
     192    //new in version 1.1. sets the database value to the wordpress database prefix 
     193    global $wpdb; 
     194    $table_name = $wpdb->prefix . "tagline_rotator"; 
     195 
     196    $query = "SELECT random_tagline FROM " . $table_name . " ORDER BY rand() limit 1"; 
    174197    $result = mysql_query($query); 
    175198        while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
     
    179202    return $random_tagline; 
    180203}    
    181 ?> 
     204 
     205//new to version 1.1 function to add version info and check if a table needs to be renamed 
     206 
     207function tagline_upgrade_check(){ 
     208 
     209    //new in version 1.1. sets the database value to the wordpress database prefix 
     210    global $wpdb; 
     211    $table_name = $wpdb->prefix . "tagline_rotator"; 
     212 
     213    $installed_ver = get_option( "tagline_db_version" ); 
     214 
     215    if( $installed_ver != "1.1" ) { 
     216         
     217        if($wpdb->get_var("SHOW TABLES LIKE 'wp_tagline_rotator'") != $table_name) { 
     218             
     219            $query = "RENAME TABLE wp_tagline_rotator TO " . $table_name; 
     220            mysql_query($query) or die('The query failed'); 
     221        } 
     222 
     223        add_option("tagline_db_version", "1.1"); 
     224 
     225   } 
     226} 
     227?> 
Note: See TracChangeset for help on using the changeset viewer.