Plugin Directory

Changeset 431364


Ignore:
Timestamp:
08/31/2011 06:16:14 PM (15 years ago)
Author:
s_ruben
Message:
 
Location:
useful-banner-manager/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • useful-banner-manager/trunk/readme.txt

    r320150 r431364  
    44Tags: banner manager, ads manager, banners, ads, advertisement, buddypress
    55Requires at least: 2.9
    6 Tested up to: 3.0.2
     6Tested up to: 3.2.1
    77
    88This banner manager plugin helps to manage the banners easily over the WordPress blog. It works with BuddyPress too.
     
    23232. Activate the plugin through the Plugins menu in WordPress.
    24243. Go to "Banner Manager" panel and add banners.
    25 4. To show the banners in the sidebar, go to the "Appearance"->"Widgets" panel and drag-and-drop the "UBM banners" box into your sidebar, configure options and save them.
    26 5. To show the banners in a post or a page, add [useful_banner_manager banners=2,6 count=1] (where the numbers 2 and 6 (banners=2,6) are the IDs of the banners which would be shown, the number 1 (count=1) is the count of the banners which would be shown) into the post or the page.
    27 6. Also the banners can be shown by adding `<?php if(function_exists("useful_banner_manager_banners")){ useful_banner_manager_banners("2,6",1); } ?>` (where the first argument ("2,6") is a string of the banners' IDs, separated by commas, and the second argument is the banners' count which would be shown).
     25
     26= Add banners =
     27
     28* To show the banners in the sidebar, go to the "Appearance"->"Widgets" panel and drag-and-drop the "UBM banners" box into your sidebar, configure options and save them.
     29* To show the banners in a post or a page, add [useful_banner_manager banners=2,6 count=1] (where the numbers 2 and 6 (banners=2,6) are the IDs of the banners which would be shown, the number 1 (count=1) is the count of the banners which would be shown) into the post or the page.
     30* Also the banners can be shown by adding `<?php if(function_exists("useful_banner_manager_banners")){ useful_banner_manager_banners("2,6",1); } ?>` (where the first argument ("2,6") is a string of the banners' IDs, separated by commas, and the second argument is the banners' count which would be shown).
     31
     32= Add banners rotations =
     33
     34* To show the banners rotations in the sidebar, go to the "Appearance"->"Widgets" panel and drag-and-drop the "UBM banners rotation" box into your sidebar, configure the options and save them.
     35* To show the banners in a post or a page, add [useful_banner_manager_banner_rotation banners=2,6 interval=5 width=468 height=60 orderby=rand] (where the numbers 2 and 6 (banners=2,6) are the IDs of the banners which would be shown, the number 5 (interval=1) is the seconds of the delay between banners rotations, the numbers 468 and 60 are the width and height of the banners which will be rotating and set "orderby" option to "rand" to show the banners in random order or "order" (orderby=rand or orderby=order)) into the post or the page.
     36* Also the banners rotations can be shown by adding `<?php if(function_exists("useful_banner_manager_banners_rotation")){ useful_banner_manager_banners_rotation("2,6",5,468,60,"rand"); } ?>` (where the first argument ("2,6") is a string of the banners' IDs, separated by commas,  the second argument (5) is the seconds of the delay between banners rotations, the third and forth arguments (468 and 60) are the width and height of the banners which will be rotating and put the fifth argument ("rand"), which is optional, to show the banners in random order).
    2837
    2938== Frequently Asked Questions ==
     
    3342== Screenshots ==
    3443
    35 1. Administration Interface
     441. Manage Banners
    3645
    3746== Changelog ==
    3847
     48= 1.1 =
     49* Added banners rotation function.
     50* Added new options for banners - "Image Alt" and "Link Rel".
     51* Fixed some bugs.
     52
    3953= 1.0 =
    4054* First release.
  • useful-banner-manager/trunk/useful-banner-manager.php

    r320112 r431364  
    44Plugin URI: http://rubensargsyan.com/wordpress-plugin-useful-banner-manager/
    55Description: This banner manager plugin helps to manage the banners easily over the WordPress blog. It works with BuddyPress too. <a href="admin.php?page=useful-banner-manager.php">Banner Manager</a>
    6 Version: 1.0
     6Version: 1.1
    77Author: Ruben Sargsyan
    88Author URI: http://rubensargsyan.com/
    99*/
    1010
    11 /*  Copyright 2010 Ruben Sargsyan (email: [email protected])
     11/*  Copyright 2011 Ruben Sargsyan (email: [email protected])
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    3434    $useful_banner_manager_table_name = $wpdb->prefix."useful_banner_manager_banners";
    3535    $useful_banner_manager_plugin_prefix = "useful_banner_manager_";
    36     $useful_banner_manager_version = "1.0";
     36    $useful_banner_manager_version = "1.1";
    3737
    3838    $charset_collate = "";
     
    5252            "banner_type VARCHAR(4) NOT NULL,".
    5353            "banner_title VARCHAR(255) NOT NULL,".
     54            "banner_alt TEXT NOT NULL,".
    5455            "banner_link VARCHAR(255) NOT NULL,".
    5556            "link_target VARCHAR(7) NOT NULL,".
     57            "link_rel VARCHAR(8) NOT NULL,".
    5658            "banner_width INT(11) NOT NULL,".
    5759            "banner_height INT(11) NOT NULL,".
     
    9496    ?>
    9597    <div class="wrap">
     98      <div style="float: right; margin: 20px 0 0 0"><a href="http://blorner.com" target="_blank"><img src="http://banners.blorner.com/blorner.com-468x60.jpg" alt="Blorner" style="border: none" /></a></div>
    9699      <h1><?php echo $useful_banner_manager_plugin_title; ?></h1>
    97100      <h2>Banners</h2>
     
    99102      if(isset($_GET[$useful_banner_manager_plugin_prefix."banner_id"]) && is_numeric($_GET[$useful_banner_manager_plugin_prefix."banner_id"]) && intval($_GET[$useful_banner_manager_plugin_prefix."banner_id"])>0){
    100103          if($_GET["page"]==basename(__FILE__)){
    101               if(isset($_POST[$share_buttons_simple_use_plugin_prefix."save_banner"])){
     104              if(isset($_POST[$useful_banner_manager_plugin_prefix."save_banner"])){
    102105                  $banner_id = intval($_GET[$useful_banner_manager_plugin_prefix."banner_id"]);
    103106
     
    126129                      $banner_title = htmlentities(trim(stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_title"])),ENT_QUOTES);
    127130                  }
     131
     132                  $banner_alt = htmlentities(trim(stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_alt"])),ENT_QUOTES);
     133
    128134                  $banner_link = trim(str_replace(array("\"","'"),array("",""),stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_link"])));
    129135                  if($banner_link!=""){
     
    146152                  }else{
    147153                      $link_target = "";
     154                  }
     155
     156                  if($banner_link!=""){
     157                      switch($_POST[$useful_banner_manager_plugin_prefix."link_rel"]){
     158                          case "nofollow":
     159                          $link_rel = "nofollow";
     160                          break;
     161                          default:
     162                          $link_rel = "dofollow";
     163                      }
     164                  }else{
     165                      $link_rel = "";
    148166                  }
    149167
     
    196214
    197215                  if(empty($errors)){
    198                       useful_banner_manager_update_banner($banner_id,$banner_name,$banner_type,$banner_title,$banner_link,$link_target,$banner_width,$banner_height,$active_until,$banner_order,$is_visible,$banner_edited_by,$last_edited_date);
     216                      useful_banner_manager_update_banner($banner_id,$banner_name,$banner_type,$banner_title,$banner_alt,$banner_link,$link_target,$link_rel,$banner_width,$banner_height,$active_until,$banner_order,$is_visible,$banner_edited_by,$last_edited_date);
    199217                      if($_FILES[$useful_banner_manager_plugin_prefix."banner_file"]["error"]==0){
    200218                          if(file_exists(ABSPATH."wp-content/uploads/useful_banner_manager_banners/".$banner_old_file)){
     
    227245
    228246          if(!empty($banner)){
    229       ?>
     247          ?>
    230248          <form method="post" enctype="multipart/form-data">
    231249            <table id="useful_banner_manager_edit_banner">
     
    240258                        if($banner->banner_type!="swf"){
    241259                        ?>
    242                             <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_title); ?>" />
     260                            <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_alt); ?>" />
    243261                          <?php
    244262                          }else{
     
    265283                </tr>
    266284                <tr>
     285                    <td width="25%" valign="middle"><strong>Image Alt</strong></td>
     286                    <td width="75%">
     287                        <input type="text" name="<?php echo($useful_banner_manager_plugin_prefix); ?>banner_alt" id="<?php echo($useful_banner_manager_plugin_prefix); ?>banner_alt" style="width: 300px" <?php if(isset($errors) && !empty($errors)){ echo('value="'.$banner_alt.'"'); }else{ echo('value="'.$banner->banner_alt.'"'); } ?> /> <small>Not for swf files.</small>
     288                    </td>
     289                </tr>
     290                <tr>
    267291                    <td width="25%" valign="middle"><strong>Banner Link</strong></td>
    268292                    <td width="75%">
     
    278302                            <option value="_blank" <?php if(isset($errors) && !empty($errors) && $link_target=="_blank"){ echo('selected="selected"'); }elseif((!isset($errors) || empty($errors)) && $banner->link_target=="_blank"){ echo('selected="selected"'); } ?>>_blank</option>
    279303                            <option value="_parent" <?php if(isset($errors) && !empty($errors) && $link_target=="_parent"){ echo('selected="selected"'); }elseif((!isset($errors) || empty($errors)) && $banner->link_target=="_parent"){ echo('selected="selected"'); } ?>>_parent</option>
     304                        </select> <small>Not for swf files.</small>
     305                    </td>
     306                </tr>
     307                <tr>
     308                    <td width="25%" valign="middle"><strong>Link Rel</strong></td>
     309                    <td width="75%">
     310                        <select id="<?php echo($useful_banner_manager_plugin_prefix); ?>link_rel" name="<?php echo($useful_banner_manager_plugin_prefix); ?>link_rel" style="width: 80px">
     311                            <option value="dofollow" <?php if(isset($errors) && !empty($errors) && $link_target=="dofollow"){ echo('selected="selected"'); }elseif((!isset($errors) || empty($errors)) && $banner->link_rel=="dofollow"){ echo('selected="selected"'); } ?>>dofollow</option>
     312                            <option value="nofollow" <?php if(isset($errors) && !empty($errors) && $link_target=="nofollow"){ echo('selected="selected"'); }elseif((!isset($errors) || empty($errors)) && $banner->link_rel=="nofollow"){ echo('selected="selected"'); } ?>>nofollow</option>
    280313                        </select> <small>Not for swf files.</small>
    281314                    </td>
     
    320353            </table>
    321354            <p class="submit">
    322                 <input name="<?php echo($share_buttons_simple_use_plugin_prefix); ?>save_banner" type="submit" value="Save" /> <a href="admin.php?page=useful-banner-manager.php">Cancel</a>
     355                <input name="<?php echo($useful_banner_manager_plugin_prefix); ?>save_banner" type="submit" value="Save" /> <a href="admin.php?page=useful-banner-manager.php">Cancel</a>
    323356            </p>
    324357          </form>
     
    329362      }else{
    330363        if($_GET["page"]==basename(__FILE__)){
    331             if(isset($_POST[$share_buttons_simple_use_plugin_prefix."add_banner"])){
     364            if(isset($_POST[$useful_banner_manager_plugin_prefix."add_banner"])){
    332365                $errors = array();
    333366                $banner_name_parts = explode(".",$_FILES[$useful_banner_manager_plugin_prefix."banner_file"]["name"]);
     
    344377                    $banner_title = htmlentities(trim(stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_title"])),ENT_QUOTES);
    345378                }
     379
     380                $banner_alt = htmlentities(trim(stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_alt"])),ENT_QUOTES);
     381
    346382                $banner_link = trim(str_replace(array("\"","'"),array("",""),stripslashes($_POST[$useful_banner_manager_plugin_prefix."banner_link"])));
    347383                if($banner_link!=""){
     
    366402                }
    367403
     404                if($banner_link!=""){
     405                      switch($_POST[$useful_banner_manager_plugin_prefix."link_rel"]){
     406                          case "nofollow":
     407                          $link_rel = "nofollow";
     408                          break;
     409                          default:
     410                          $link_rel = "dofollow";
     411                      }
     412                  }else{
     413                      $link_rel = "";
     414                  }
     415
    368416                if(isset($_POST[$useful_banner_manager_plugin_prefix."auto_sizes"]) && !in_array("banner_type",$errors)){
    369417                    if($banner_type!="swf"){
     
    413461
    414462                if(empty($errors)){
    415                     $added_banner_id = useful_banner_manager_add_banner($banner_name,$banner_type,$banner_title,$banner_link,$link_target,$banner_width,$banner_height,$added_date,$active_until,$banner_order,$is_visible,$banner_added_by);
     463                    $added_banner_id = useful_banner_manager_add_banner($banner_name,$banner_type,$banner_title,$banner_alt,$banner_link,$link_target,$link_rel,$banner_width,$banner_height,$added_date,$active_until,$banner_order,$is_visible,$banner_added_by);
    416464                    move_uploaded_file($banner_tmp_file,ABSPATH."wp-content/uploads/useful_banner_manager_banners/".$added_banner_id."-".$banner_name.".".$banner_type);
    417465                    echo('<div id="message" class="updated fade"><p><strong>New banner added.</strong></p></div>');
     
    432480            }
    433481
    434             if(isset($_POST[$share_buttons_simple_use_plugin_prefix."delete"])){
     482            if(isset($_POST[$useful_banner_manager_plugin_prefix."delete"])){
    435483                if(isset($_POST[$useful_banner_manager_plugin_prefix."banner_id"]) && is_numeric($_POST[$useful_banner_manager_plugin_prefix."banner_id"])){
    436484                    $banner_id = intval($_POST[$useful_banner_manager_plugin_prefix."banner_id"]);
     
    461509              </tr>
    462510              <tr>
     511                  <td width="25%" valign="middle"><strong>Image Alt</strong></td>
     512                  <td width="75%">
     513                      <input type="text" name="<?php echo($useful_banner_manager_plugin_prefix); ?>banner_alt" id="<?php echo($useful_banner_manager_plugin_prefix); ?>banner_alt" style="width: 300px" <?php if(isset($errors) && !empty($errors)){ echo('value="'.$banner_alt.'"'); } ?> /> <small>Not for swf files.</small>
     514                  </td>
     515              </tr>
     516              <tr>
    463517                  <td width="25%" valign="middle"><strong>Banner Link</strong></td>
    464518                  <td width="75%">
     
    474528                          <option value="_blank" <?php if(isset($errors) && !empty($errors) && $link_target=="_blank"){ echo('selected="selected"'); } ?>>_blank</option>
    475529                          <option value="_parent" <?php if(isset($errors) && !empty($errors) && $link_target=="_parent"){ echo('selected="selected"'); } ?>>_parent</option>
     530                      </select> <small>Not for swf files.</small>
     531                  </td>
     532              </tr>
     533              <tr>
     534                  <td width="25%" valign="middle"><strong>Link Rel</strong></td>
     535                  <td width="75%">
     536                      <select id="<?php echo($useful_banner_manager_plugin_prefix); ?>link_rel" name="<?php echo($useful_banner_manager_plugin_prefix); ?>link_rel" style="width: 80px">
     537                          <option value="dofollow" <?php if(isset($errors) && !empty($errors) && $link_rel=="dofollow"){ echo('selected="selected"'); }elseif(!isset($errors) || empty($errors)){ echo('selected="selected"'); } ?>>dofollow</option>
     538                          <option value="nofollow" <?php if(isset($errors) && !empty($errors) && $link_rel=="nofollow"){ echo('selected="selected"'); } ?>>nofollow</option>
    476539                      </select> <small>Not for swf files.</small>
    477540                  </td>
     
    516579          </table>
    517580          <p class="submit">
    518               <input name="<?php echo($share_buttons_simple_use_plugin_prefix); ?>add_banner" type="submit" value="Add banner" />
     581              <input name="<?php echo($useful_banner_manager_plugin_prefix); ?>add_banner" type="submit" value="Add banner" />
    519582          </p>
    520583        </form>
     
    536599              <thead>
    537600                <tr>
    538                     <th scope="col" width="2%">ID</th>
    539                     <th scope="col" width="4%">Type</th>
    540                     <th scope="col" width="15%">Title</th>
    541                     <th scope="col" width="28%">Link</th>
     601                    <th scope="col" width="3%">ID</th>
     602                    <th scope="col" width="5%">Type</th>
     603                    <th scope="col" width="12%">Title</th>
     604                    <th scope="col" width="23%">Link</th>
     605                    <th scope="col" width="6%">Rel</th>
    542606                    <th scope="col" width="9%">Added Date</th>
    543607                    <th scope="col" width="9%">Active Until</th>
     
    555619                    <th scope="col">Title</th>
    556620                    <th scope="col">Link</th>
     621                    <th scope="col">Rel</th>
    557622                    <th scope="col">Added Date</th>
    558623                    <th scope="col">Active Until</th>
     
    573638                    <td><?php echo($banner->banner_title); ?></td>
    574639                    <td><?php echo($banner->banner_link); ?></td>
     640                    <td><?php echo($banner->link_rel); ?></td>
    575641                    <td><?php echo($banner->added_date); ?></td>
    576642                    <td><?php if($banner->active_until==-1){ echo("No date"); }else{ echo($banner->active_until); } ?></td>
     
    590656                      <form method="post">
    591657                          <p class="submit">
    592                             <input name="delete" type="submit" value="Delete" onclick="javascript:if(!confirm('Are you sure you want to delete the banner &quot;<?php echo($banner->banner_title); ?>&quot;?')){ return false; }" />
     658                            <input name="<?php echo($useful_banner_manager_plugin_prefix); ?>delete" type="submit" value="Delete" onclick="javascript:if(!confirm('Are you sure you want to delete the banner &quot;<?php echo($banner->banner_title); ?>&quot;?')){ return false; }" />
    593659                            <input type="hidden" name="<?php echo($useful_banner_manager_plugin_prefix); ?>banner_id" value="<?php echo($banner->id); ?>" />
    594660                          </p>
     
    605671      ?>
    606672      <br />
    607       <p><strong style="color: #FF0000">To have the statistics of the impressions and the clicks of the banners, get the premium version only for <span style="font-size: 16px">$9.99</span>. To get the premium version of the plugin, just contact by the <a href="http://rubensargsyan.com/contact/" target="_blank">contact from</a>.</strong></p>
     673      <p><strong style="color: #FF0000">To have more features in this plugin (statistics of the impressions and the clicks of the banners, etc.) get the premium version of it. Read more about the premium version on its <a href="http://rubensargsyan.com/wordpress-plugin-ubm-premium/" target="_blank">homepage</a>.</strong></p>
    608674    </div>
    609675    <?php
    610676}
    611677
    612 function useful_banner_manager_add_banner($banner_name,$banner_type,$banner_title,$banner_link,$link_target,$banner_width,$banner_height,$added_date,$active_until,$banner_order,$is_visible,$banner_added_by){
     678function useful_banner_manager_add_banner($banner_name,$banner_type,$banner_title,$banner_alt,$banner_link,$link_target,$link_rel,$banner_width,$banner_height,$added_date,$active_until,$banner_order,$is_visible,$banner_added_by){
    613679    global $wpdb, $useful_banner_manager_table_name;
    614680
    615     $query = "INSERT INTO ".$useful_banner_manager_table_name." (banner_name,banner_type,banner_title,banner_link,link_target,banner_width,banner_height,added_date,active_until,banner_order,is_visible,banner_added_by) VALUES ('".$banner_name."','".$banner_type."','".$banner_title."','".$banner_link."','".$link_target."','".$banner_width."','".$banner_height."','".$added_date."','".$active_until."','".$banner_order."','".$is_visible."','".$banner_added_by."');";
     681    $query = "INSERT INTO ".$useful_banner_manager_table_name." (banner_name,banner_type,banner_title,banner_alt,banner_link,link_target,link_rel,banner_width,banner_height,added_date,active_until,banner_order,is_visible,banner_added_by) VALUES ('".$banner_name."','".$banner_type."','".$banner_title."','".$banner_alt."','".$banner_link."','".$link_target."','".$link_rel."','".$banner_width."','".$banner_height."','".$added_date."','".$active_until."','".$banner_order."','".$is_visible."','".$banner_added_by."');";
    616682    $wpdb->query($query);
    617    
     683
    618684    $banner_id = $wpdb->insert_id;
    619685
     
    621687}
    622688
    623 function useful_banner_manager_update_banner($banner_id,$banner_name,$banner_type,$banner_title,$banner_link,$link_target,$banner_width,$banner_height,$active_until,$banner_order,$is_visible,$banner_edited_by,$last_edited_date){
     689function useful_banner_manager_update_banner($banner_id,$banner_name,$banner_type,$banner_title,$banner_alt,$banner_link,$link_target,$link_rel,$banner_width,$banner_height,$active_until,$banner_order,$is_visible,$banner_edited_by,$last_edited_date){
    624690    global $wpdb, $useful_banner_manager_table_name;
    625691
    626     $query = "UPDATE ".$useful_banner_manager_table_name." SET banner_name='".$banner_name."', banner_type='".$banner_type."', banner_title='".$banner_title."', banner_link='".$banner_link."', link_target='".$link_target."', banner_width='".$banner_width."', banner_height='".$banner_height."', active_until='".$active_until."', banner_order='".$banner_order."', is_visible='".$is_visible."', banner_edited_by='".$banner_edited_by."', last_edited_date='".$last_edited_date."' WHERE id='".$banner_id."';";
     692    $query = "UPDATE ".$useful_banner_manager_table_name." SET banner_name='".$banner_name."', banner_type='".$banner_type."', banner_title='".$banner_title."', banner_alt='".$banner_alt."', banner_link='".$banner_link."', link_target='".$link_target."', link_rel='".$link_rel."', banner_width='".$banner_width."', banner_height='".$banner_height."', active_until='".$active_until."', banner_order='".$banner_order."', is_visible='".$is_visible."', banner_edited_by='".$banner_edited_by."', last_edited_date='".$last_edited_date."' WHERE id='".$banner_id."';";
    627693    $wpdb->query($query);
    628694}
     
    645711    global $wpdb, $useful_banner_manager_table_name;
    646712
    647     $query = "SELECT id,banner_type,banner_title,banner_link,added_date,active_until,banner_order,is_visible,banner_added_by FROM ".$useful_banner_manager_table_name." ORDER BY id ASC;";
     713    $query = "SELECT id,banner_type,banner_title,banner_link,link_rel,added_date,active_until,banner_order,is_visible,banner_added_by FROM ".$useful_banner_manager_table_name." ORDER BY id ASC;";
    648714    $banners = $wpdb->get_results($query);
    649715
     
    683749
    684750     function widget($args, $instance){
    685         global $wpdb, $useful_banner_manager_table_name, $useful_banner_manager_plugin_url;
     751        global $wpdb, $useful_banner_manager_table_name;
    686752
    687753        extract($args);
     
    717783                    if($banner->banner_link!=""){
    718784                    ?>
    719                         <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>">
     785                        <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>" rel="<?php echo($banner->link_rel); ?>">
    720786                    <?php
    721787                    }
    722788                ?>
    723                     <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_title); ?>" />
     789                    <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_alt); ?>" />
    724790                    <?php
    725791                    if($banner->banner_link!=""){
     
    741807            <?php
    742808            }
    743 
    744             echo($after_widget);
    745         }
     809        }
     810
     811        echo($after_widget);
    746812     }
    747813
     
    762828
    763829     function form($instance){
    764         global $wpdb, $useful_banner_manager_table_name, $useful_banner_manager_plugin_prefix;
     830        global $wpdb, $useful_banner_manager_table_name;
    765831
    766832        $instance = wp_parse_args((array)$instance,array("title"=>"","banners_ids"=>""));
     
    801867}
    802868
     869class Useful_Banner_Manager_Rotation_Widget extends WP_Widget{
     870     function Useful_Banner_Manager_Rotation_Widget(){
     871        $widget_opions = array('classname' => 'useful_banner_manager_rotation_widget', 'description' => __('Useful banner manager banners rotation'));
     872        $this->WP_Widget('useful-banner-manager-banners-rotation', 'UBM banners rotation', $widget_opions);
     873     }
     874
     875     function widget($args, $instance){
     876        global $wpdb, $useful_banner_manager_table_name;
     877
     878        extract($args);
     879
     880        $title = $instance["title"];
     881        $banners_ids = $instance["banners_ids"];
     882        $interval = $instance["interval"];
     883        $width = $instance["width"];
     884        $height = $instance["height"];
     885        if($instance["orderby"]=="rand"){
     886            $orderby = "RAND()";
     887        }else{
     888            $orderby = "banner_order, id DESC";
     889        }
     890
     891
     892        echo($before_widget);
     893        if(!empty($title)){
     894            echo($before_title.$title.$after_title);
     895        }
     896
     897        if(!empty($banners_ids)){
     898            $query = "SELECT * FROM ".$useful_banner_manager_table_name." WHERE (";
     899            $banners_ids_query = array();
     900
     901            foreach($banners_ids as $banner_id){
     902                $banners_ids_query[] = "id='".$banner_id."'";
     903            }
     904
     905            $query .= implode(" OR ",$banners_ids_query);
     906
     907            $query .= ") AND (active_until=-1 OR active_until>='".date("Y-m-d")."') AND is_visible='yes' ORDER BY ".$orderby.";";
     908
     909            $banners = $wpdb->get_results($query);
     910
     911            ?>
     912            <div id="<?php echo($args["widget_id"]); ?>" class="useful_banner_manager_banners_rotation" style="overflow: hidden; width: <?php echo($width); ?>px; height: <?php echo($height); ?>px;">
     913            <?php
     914            $first_banner = true;
     915            foreach($banners as $banner){
     916                ?>
     917                <div class="useful_banner_manager_rotating_banner"<?php if($first_banner){ $first_banner = false; }else{ echo(' style="display: none"'); } ?>>
     918                    <?php
     919                    if($banner->banner_link!=""){
     920                    ?>
     921                        <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>" rel="<?php echo($banner->link_rel); ?>">
     922                    <?php
     923                    }
     924                ?>
     925                    <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($width); ?>" height="<?php echo($height); ?>" alt="<?php echo($banner->banner_alt); ?>" />
     926                    <?php
     927                    if($banner->banner_link!=""){
     928                    ?>
     929                        </a>
     930                    <?php
     931                    }
     932                    ?>
     933                </div>
     934                <?php
     935            }
     936            ?>
     937            </div>
     938            <script type="text/javascript">
     939            jQuery(function($){
     940                $(document).ready(function(){
     941                    var useful_banner_manager_banners_rotation_block = "<?php echo($args['widget_id']); ?>";
     942                    var interval_between_rotations = <?php echo(($interval*1000)); ?>;
     943                    if($("#"+useful_banner_manager_banners_rotation_block+" .useful_banner_manager_rotating_banner").length>1){
     944                        setTimeout("useful_banner_manager_rotate_banners('"+useful_banner_manager_banners_rotation_block+"',"+interval_between_rotations+")",interval_between_rotations);
     945                    }
     946                });
     947            });
     948            </script>
     949            <?php
     950        }
     951
     952        echo($after_widget);
     953     }
     954
     955     function update($new_instance, $old_instance){
     956        $instance = $old_instance;
     957        $instance["title"] = strip_tags($new_instance["title"]);
     958        $instance["banners_ids"] = $new_instance["banners_ids"];
     959        if(is_numeric($new_instance["interval"]) && intval($new_instance["interval"])>0){
     960            $instance["interval"] = intval($new_instance["interval"]);
     961        }elseif(is_numeric($old_instance["interval"]) && intval($old_instance["interval"])>0){
     962            $instance["interval"] = intval($old_instance["interval"]);
     963        }else{
     964            $instance["interval"] = 10;
     965        }
     966        if(is_numeric($new_instance["width"]) && intval($new_instance["width"])>0){
     967            $instance["width"] = intval($new_instance["width"]);
     968        }elseif(is_numeric($old_instance["width"]) && intval($old_instance["width"])>0){
     969            $instance["width"] = intval($old_instance["width"]);
     970        }else{
     971            $instance["width"] = 180;
     972        }
     973        if(is_numeric($new_instance["height"]) && intval($new_instance["height"])>0){
     974            $instance["height"] = intval($new_instance["height"]);
     975        }elseif(is_numeric($old_instance["height"]) && intval($old_instance["height"])>0){
     976            $instance["height"] = intval($old_instance["height"]);
     977        }else{
     978            $instance["height"] = 180;
     979        }
     980        if($new_instance["orderby"]=="rand"){
     981            $instance["orderby"] = "rand";
     982        }else{
     983            $instance["orderby"] = "banner_order, id";
     984        }
     985
     986
     987        return $instance;
     988     }
     989
     990     function form($instance){
     991        global $wpdb, $useful_banner_manager_table_name;
     992
     993        $instance = wp_parse_args((array)$instance,array("title"=>"","banners_ids"=>""));
     994        $title = strip_tags($instance["title"]);
     995        $banners_ids = $instance["banners_ids"];
     996        if($instance["interval"]){
     997            $interval =  intval($instance["interval"]);
     998        }else{
     999            $interval =  10;
     1000        }
     1001        if($instance["width"]){
     1002            $width =  intval($instance["width"]);
     1003        }else{
     1004            $width =  180;
     1005        }
     1006        if($instance["height"]){
     1007            $height =  intval($instance["height"]);
     1008        }else{
     1009            $height =  180;
     1010        }
     1011
     1012
     1013        $banners = $wpdb->get_results("SELECT id, banner_name, banner_type, banner_title FROM ".$useful_banner_manager_table_name." WHERE is_visible='yes' ORDER BY id ASC;");
     1014
     1015        if($banners){
     1016            ?>
     1017            <p><label for="<?php echo($this->get_field_id("title")); ?>">Title:</label>
     1018            <input class="widefat" id="<?php echo($this->get_field_id("title")); ?>" name="<?php echo($this->get_field_name("title")); ?>" type="text" value="<?php echo(esc_attr($title)); ?>" /></p>
     1019            <table width="100%" style="border-collapse: collapse">
     1020            <caption>Banners</caption>
     1021            <?php
     1022            foreach($banners as $banner){
     1023                if($banner->banner_type=="swf"){
     1024                    continue;
     1025                }
     1026            ?>
     1027                <tr><td width="90%" style="border: 1px solid #f1f1f1; text-align: left; padding: 2px 5px"><label for="<?php echo($this->get_field_id("banners_ids")); ?>_<?php echo($banner->id); ?>"><?php echo($banner->banner_title); ?></label></td><td width="10%" style="border: 1px solid #f1f1f1; text-align: center; padding: 2px 0"><input class="checkbox" id="<?php echo($this->get_field_id("banners_ids")); ?>_<?php echo($banner->id); ?>" name="<?php echo($this->get_field_name("banners_ids")); ?>[]" type="checkbox" value="<?php echo($banner->id); ?>" <?php if(is_array($banners_ids)){ if(in_array($banner->id,$banners_ids)){ echo('checked="checked"'); } } ?> /></td></tr>
     1028            <?php
     1029            }
     1030            ?>
     1031            </table><br />
     1032            <p><label for="<?php echo($this->get_field_id("interval")); ?>">Interval:</label>
     1033            <input id="<?php echo($this->get_field_id("interval")); ?>" name="<?php echo($this->get_field_name("interval")); ?>" type="text" value="<?php echo(esc_attr($interval)); ?>" size="2" /> seconds</p>
     1034            <p><label for="<?php echo($this->get_field_id("width")); ?>">Width of rotating banners:</label>
     1035            <input id="<?php echo($this->get_field_id("width")); ?>" name="<?php echo($this->get_field_name("width")); ?>" type="text" value="<?php echo(esc_attr($width)); ?>" size="2" /></p>
     1036            <p><label for="<?php echo($this->get_field_id("height")); ?>">Height of rotating banners:</label>
     1037            <input id="<?php echo($this->get_field_id("height")); ?>" name="<?php echo($this->get_field_name("height")); ?>" type="text" value="<?php echo(esc_attr($height)); ?>" size="2" /></p>
     1038            <p><label for="<?php echo($this->get_field_id("orderby")); ?>">Order by rand:</label>
     1039            <input class="checkbox" id="<?php echo($this->get_field_id("orderby")); ?>" name="<?php echo($this->get_field_name("orderby")); ?>" type="checkbox" value="rand" <?php if($instance["orderby"]=="rand"){ echo('checked="checked"'); } ?> />
     1040            </p>
     1041            <?php
     1042        }else{
     1043        ?>
     1044            <p>There is no visible banner. <a href="admin.php?page=useful-banner-manager.php">Settings</a></p>
     1045        <?php
     1046        }
     1047     }
     1048}
     1049
    8031050function useful_banner_manager_widget_init(){
    8041051    if(!is_blog_installed()){
     
    8071054
    8081055    register_widget('Useful_Banner_Manager_Widget');
    809 
    810     do_action('widgets_init');
    811 }
     1056    register_widget('Useful_Banner_Manager_Rotation_Widget');
     1057}
     1058
     1059$banners_rotation_id = 1;
    8121060
    8131061function add_useful_banner_manager_banners($content){
    814     global $wpdb, $useful_banner_manager_table_name,$useful_banner_manager_plugin_url;
    815 
    816     if(preg_match_all("/\[useful_banner_manager banners=(.*) count=([0-9]+)\]/i",$content,$matches,PREG_SET_ORDER)){
     1062    global $wpdb, $useful_banner_manager_table_name, $banners_rotation_id;
     1063
     1064    if(preg_match_all("/\[useful_banner_manager banners=(.[^\]]*) count=([0-9]+)\]/i",$content,$matches,PREG_SET_ORDER)){
    8171065        foreach($matches as $match){
    8181066            $banners_ids = explode(",",$match[1]);
    819             $count = intval($match[2]);
     1067            $count = $match[2];
    8201068
    8211069            $query = "SELECT * FROM (SELECT * FROM ".$useful_banner_manager_table_name." WHERE (";
     
    8321080            $banners = $wpdb->get_results($query);
    8331081
    834             $the_banner = "";
    835 
    836             foreach($banners as $banner){
    837                 $the_banner .= '<div class="useful_banner_manager_banner">';
    838 
    839                 if($banner->banner_type!="swf"){
     1082            if($banners){
     1083                $the_banner = "";
     1084
     1085                foreach($banners as $banner){
     1086                    $the_banner .= '<div class="useful_banner_manager_banner">';
     1087
     1088                    if($banner->banner_type!="swf"){
     1089                        if($banner->banner_link!=""){
     1090                            $the_banner .= '<a href="'.$banner->banner_link.'" target="'.$banner->link_target.'">';
     1091                        }
     1092                        $the_banner .= '<img src="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'" width="'.$banner->banner_width.'" height="'.$banner->banner_height.'" alt="'.$banner->banner_title.'" />';
     1093
     1094                        if($banner->banner_link!=""){
     1095                            $the_banner .= '</a>';
     1096                        }
     1097                    }else{
     1098                        $the_banner .= '<object width="'.$banner->banner_width.'" height="'.$banner->banner_height.'">
     1099                            <param name="movie" value="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'">
     1100                            <embed src="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'" width="'.$banner->banner_width.'" height="'.$banner->banner_height.'">
     1101                            </embed>
     1102                        </object>';
     1103                    }
     1104                    $the_banner .= '</div>';
     1105                }
     1106
     1107                $content = str_replace($match[0],$the_banner,$content);
     1108            }
     1109        }
     1110    }
     1111
     1112    if(preg_match_all("/\[useful_banner_manager_banner_rotation banners=(.[^\]]*) interval=([0-9]+) width=([0-9]+) height=([0-9]+) orderby=(rand)\]/i",$content,$matches,PREG_SET_ORDER)){
     1113        foreach($matches as $match){
     1114            $banners_ids = explode(",",$match[1]);
     1115            $interval = $match[2];
     1116            $width = $match[3];
     1117            $height = $match[4];
     1118            if($match[5]=="rand"){
     1119                $orderby = "RAND()";
     1120            }else{
     1121                $orderby = "banner_order, id DESC";
     1122            }
     1123
     1124            $query = "SELECT * FROM (SELECT * FROM ".$useful_banner_manager_table_name." WHERE (";
     1125            $banners_ids_query = array();
     1126
     1127            foreach($banners_ids as $banner_id){
     1128                $banners_ids_query[] = "id='".trim($banner_id)."'";
     1129            }
     1130
     1131            $query .= implode(" OR ",$banners_ids_query);
     1132
     1133            $query .= ") AND (active_until=-1 OR active_until>='".date("Y-m-d")."') AND banner_type!='swf' AND is_visible='yes' ORDER BY ".$orderby.") as banners ORDER BY banner_order DESC;";
     1134
     1135            $banners = $wpdb->get_results($query);
     1136
     1137            if($banners){
     1138                $the_banner = '<div id="useful-banner-manager-banners-rotation-n'.$banners_rotation_id.'" class="useful_banner_manager_banners_rotation" style="overflow: hidden; width: '.$width.'px; height: '.$height.'px;">';
     1139
     1140                $first_banner = true;
     1141                foreach($banners as $banner){
     1142                    $the_banner .= '<div class="useful_banner_manager_rotating_banner"';
     1143                    if($first_banner){
     1144                        $first_banner = false;
     1145                    }else{
     1146                        $the_banner .= ' style="display: none"';
     1147                    }
     1148                    $the_banner .= '>';
     1149
    8401150                    if($banner->banner_link!=""){
    841                         $the_banner .= '<a href="'.$banner->banner_link.'" target="'.$banner->link_target.'">';
    842                     }
    843                     $the_banner .= '<img src="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'" width="'.$banner->banner_width.'" height="'.$banner->banner_height.'" alt="'.$banner->banner_title.'" />';
     1151                        $the_banner .= '<a href="'.$banner->banner_link.'" target="'.$banner->link_target.'" rel="'.$banner->link_rel.'">';
     1152                    }
     1153
     1154                    $the_banner .= '<img src="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id.'-'.$banner->banner_name.'.'.$banner->banner_type.'" width="'.$width.'" height="'.$height.'" alt="'.$banner->banner_alt.'" />';
    8441155
    8451156                    if($banner->banner_link!=""){
    8461157                        $the_banner .= '</a>';
    8471158                    }
    848                 }else{
    849                     $the_banner .= '<object width="'.$banner->banner_width.'" height="'.$banner->banner_height.'">
    850                         <param name="movie" value="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'">
    851                         <embed src="'.get_home_url().'/wp-content/uploads/useful_banner_manager_banners/'.$banner->id."-".$banner->banner_name.'.'.$banner->banner_type.'" width="'.$banner->banner_width.'" height="'.$banner->banner_height.'">
    852                         </embed>
    853                     </object>';
    854                 }
     1159
     1160                    $the_banner .= '</div>';
     1161                }
     1162
    8551163                $the_banner .= '</div>';
    856             }
    857 
    858             $content = str_replace($match[0],$the_banner,$content);
     1164
     1165                $the_banner .= '<script type="text/javascript">
     1166                jQuery(function($){
     1167                    $(document).ready(function(){
     1168                        var useful_banner_manager_banners_rotation_block = "useful-banner-manager-banners-rotation-n'.$banners_rotation_id.'";
     1169                        var interval_between_rotations = '.($interval*1000).';
     1170                        if($("#"+useful_banner_manager_banners_rotation_block+" .useful_banner_manager_rotating_banner").length>1){
     1171                            setTimeout("useful_banner_manager_rotate_banners(\'"+useful_banner_manager_banners_rotation_block+"\',"+interval_between_rotations+")",interval_between_rotations);
     1172                        }
     1173                    });
     1174                });
     1175                </script>';
     1176
     1177                $banners_rotation_id++;
     1178
     1179                $content = str_replace($match[0],$the_banner,$content);
     1180            }
    8591181        }
    8601182    }
     
    8641186
    8651187function useful_banner_manager_banners($banners,$count){
    866     global $wpdb, $useful_banner_manager_table_name, $useful_banner_manager_plugin_url;
     1188    global $wpdb, $useful_banner_manager_table_name;
    8671189
    8681190    if(!is_numeric($count) || intval($count)<1){
     
    8731195
    8741196    foreach($banners_ids as $key => $banner_id){
    875         if(!is_numeric($banner_id) || intval($count)<1){
     1197        if(!is_numeric($banner_id) || intval($banner_id)<1){
    8761198            unset($banners_ids[$key]);
    8771199        }
     
    8821204    }
    8831205
    884     $count = intval($count);
    885 
    8861206    $query = "SELECT * FROM (SELECT * FROM ".$useful_banner_manager_table_name." WHERE (";
    8871207    $banners_ids_query = array();
     
    8971217    $banners = $wpdb->get_results($query);
    8981218
    899     foreach($banners as $banner){
    900     ?>
    901         <div class="useful_banner_manager_banner">
     1219    if($banners){
     1220        foreach($banners as $banner){
     1221        ?>
     1222            <div class="useful_banner_manager_banner">
     1223            <?php
     1224            if($banner->banner_type!="swf"){
     1225                if($banner->banner_link!=""){
     1226                ?>
     1227                    <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>" rel="<?php echo($banner->link_rel); ?>">
     1228                <?php
     1229                }
     1230            ?>
     1231                <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_alt); ?>" />
     1232                <?php
     1233                if($banner->banner_link!=""){
     1234                ?>
     1235                    </a>
     1236                <?php
     1237                }
     1238            }else{
     1239            ?>
     1240                <object width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>">
     1241                    <param name="movie" value="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>">
     1242                    <embed src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>">
     1243                    </embed>
     1244                </object>
     1245            <?php
     1246            }
     1247            ?>
     1248            </div>
    9021249        <?php
    903         if($banner->banner_type!="swf"){
    904             if($banner->banner_link!=""){
    905             ?>
    906                 <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>">
     1250        }
     1251    }
     1252}
     1253
     1254function useful_banner_manager_banners_rotation($banners,$interval,$width,$height,$orderby=""){
     1255    global $wpdb, $useful_banner_manager_table_name, $banners_rotation_id;
     1256
     1257    if($orderby=="rand"){
     1258        $orderby = "RAND()";
     1259    }else{
     1260        $orderby = "banner_order, id DESC";
     1261    }
     1262
     1263    if(!is_numeric($interval) || intval($interval)<=0){
     1264        return false;
     1265    }
     1266
     1267    if(!is_numeric($width) || intval($width)<=0){
     1268        return false;
     1269    }
     1270
     1271    if(!is_numeric($height) || intval($height)<=0){
     1272        return false;
     1273    }
     1274
     1275    $banners_ids = explode(",",$banners);
     1276
     1277    foreach($banners_ids as $key => $banner_id){
     1278        if(!is_numeric($banner_id) || intval($banner_id)<1){
     1279            unset($banners_ids[$key]);
     1280        }
     1281    }
     1282
     1283    if(empty($banners_ids)){
     1284        return false;
     1285    }
     1286
     1287    $query = "SELECT * FROM (SELECT * FROM ".$useful_banner_manager_table_name." WHERE (";
     1288    $banners_ids_query = array();
     1289
     1290    foreach($banners_ids as $banner_id){
     1291        $banners_ids_query[] = "id='".trim($banner_id)."'";
     1292    }
     1293
     1294    $query .= implode(" OR ",$banners_ids_query);
     1295
     1296    $query .= ") AND (active_until=-1 OR active_until>='".date("Y-m-d")."') AND banner_type!='swf' AND is_visible='yes' ORDER BY ".$orderby.") as banners ORDER BY banner_order DESC;";
     1297
     1298    $banners = $wpdb->get_results($query);
     1299
     1300    if($banners){
     1301        ?>
     1302        <div id="useful-banner-manager-banners-rotation-n<?php echo($banners_rotation_id); ?>" class="useful_banner_manager_banners_rotation" style="overflow: hidden; width: <?php echo($width); ?>px; height: <?php echo($height); ?>px;">
     1303        <?php
     1304        $first_banner = true;
     1305        foreach($banners as $banner){
     1306            ?>
     1307            <div class="useful_banner_manager_rotating_banner"<?php if($first_banner){ $first_banner = false; }else{ echo(' style="display: none"'); } ?>>
     1308                <?php
     1309                if($banner->banner_link!=""){
     1310                ?>
     1311                    <a href="<?php echo($banner->banner_link); ?>" target="<?php echo($banner->link_target); ?>" rel="<?php echo($banner->link_rel); ?>">
     1312                <?php
     1313                }
     1314            ?>
     1315                <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($width); ?>" height="<?php echo($height); ?>" alt="<?php echo($banner->banner_alt); ?>" />
     1316                <?php
     1317                if($banner->banner_link!=""){
     1318                ?>
     1319                    </a>
     1320                <?php
     1321                }
     1322                ?>
     1323            </div>
    9071324            <?php
    908             }
    909         ?>
    910             <img src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>" alt="<?php echo($banner->banner_title); ?>" />
    911             <?php
    912             if($banner->banner_link!=""){
    913             ?>
    914                 </a>
    915             <?php
    916             }
    917         }else{
    918         ?>
    919             <object width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>">
    920                 <param name="movie" value="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>">
    921                 <embed src="<?php bloginfo("url"); ?>/wp-content/uploads/useful_banner_manager_banners/<?php echo($banner->id."-".$banner->banner_name); ?>.<?php echo($banner->banner_type); ?>" width="<?php echo($banner->banner_width); ?>" height="<?php echo($banner->banner_height); ?>">
    922                 </embed>
    923             </object>
    924         <?php
    9251325        }
    9261326        ?>
    9271327        </div>
    928     <?php
     1328        <script type="text/javascript">
     1329        jQuery(function($){
     1330            $(document).ready(function(){
     1331                var useful_banner_manager_banners_rotation_block = "useful-banner-manager-banners-rotation-n<?php echo($banners_rotation_id); ?>";
     1332                var interval_between_rotations = <?php echo(($interval*1000)); ?>;
     1333                if($("#"+useful_banner_manager_banners_rotation_block+" .useful_banner_manager_rotating_banner").length>1){
     1334                    setTimeout("useful_banner_manager_rotate_banners('"+useful_banner_manager_banners_rotation_block+"',"+interval_between_rotations+")",interval_between_rotations);
     1335                }
     1336            });
     1337        });
     1338        </script>
     1339        <?php
     1340        $banners_rotation_id++;
    9291341    }
    9301342}
     
    9331345add_filter('the_content', 'add_useful_banner_manager_banners');
    9341346
    935 add_action('init', 'useful_banner_manager_widget_init', 1);
     1347wp_enqueue_script('jquery');
     1348wp_enqueue_script('useful_banner_manager_scripts',$useful_banner_manager_plugin_url."scripts.js");
     1349add_action('widgets_init', 'useful_banner_manager_widget_init');
    9361350add_action('plugins_loaded','useful_banner_manager_load');
    9371351add_action("admin_menu", "useful_banner_manager_menu");
Note: See TracChangeset for help on using the changeset viewer.