Plugin Directory

Changeset 650011


Ignore:
Timestamp:
01/09/2013 01:29:58 AM (13 years ago)
Author:
barteled
Message:

Version 0.2

Location:
simple-slideshow-background/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • simple-slideshow-background/trunk/admin-form.php

    r644112 r650011  
    11<?php
    22function ssbg_form_list_images(){
     3  global $ssbg_settings;
     4
    35  // Create an instructions list table and prepare
    46  $imagesTable = new Slideshow_Background_List_Table();
     
    810    <div id="icon-tools" class="icon32"><br/></div>
    911    <h2><?php echo 'Slideshow Background Images'; ?></h2>
     12    <br/>
    1013    <form id="edit_ssb" action='' method="post">
    1114      <input type="hidden" name="action" value="add_ssb" />
     
    1316    </form>
    1417      <?php $imagesTable->display() ?>
    15     <i><b>Note:</b> All changes are saved automatically.</i>
     18    <i><b>Note:</b> All changes to table are saved automatically.</i>
     19   
     20    <div>
     21      <h2>Settings</h2>
     22     
     23    <form action="" method="post">
     24      <input type="hidden" name="action" value="settings_ssb" />
     25      <table class="form-table">
     26        <tbody>
     27          <tr>
     28            <th scope="row">
     29              <label for="delay">Rotation Timer in Seconds</label>
     30            </th>
     31            <td>
     32              <input name="delay" type="text" id="delay" value="<?php echo $ssbg_settings['delay']; ?>" class="regular-text">
     33            </td>
     34          </tr>
     35          <tr>
     36            <th scope="row">
     37              <label for="enabled">Slideshow Enabled</label>
     38            </th>
     39            <td>
     40              <input name="enabled" type="checkbox" id="enabled" value="enabled" class="regular-text" <?php if($ssbg_settings['enabled']) echo "checked"; ?> >
     41            </td>
     42          </tr>
     43        </tbody>
     44      </table>
     45      <p class="submit"><input type="submit" value="Save Settings" class="button-primary" name="Submit"></p>
     46    </form>
     47 
     48    </div>
    1649  </div>
    1750  <?
  • simple-slideshow-background/trunk/admin-menu.php

    r644112 r650011  
    1010function ssbg_menu_appearance() {
    1111  // WordPress globals
    12   global $ssbg_option;
     12  global $ssbg_option_name, $ssbg_settings, $ssbg_settings_name;
    1313 
    1414  $action = 'default';
     
    1919 
    2020  switch ($action){
     21    case 'settings_ssb':
     22      if(is_numeric($_REQUEST['delay'])) $ssbg_settings['delay'] = $_REQUEST['delay'];
     23      if($_REQUEST['enabled'] == "enabled") $ssbg_settings['enabled'] = true;
     24      else $ssbg_settings['enabled'] = false;
     25      update_option($ssbg_settings_name, $ssbg_settings);
     26      ssbg_form_list_images();
     27      break;
    2128    case 'save_picture':
    2229      $id = $_REQUEST['id'];
    23       $images = get_option($ssbg_option, array());
     30      $images = get_option($ssbg_option_name, array());
    2431      $images[$id]['picture'] = $_REQUEST['picture'.$id];
    25       update_option($ssbg_option, array_values($images));
    26       print $_REQUEST['picture'];
     32      update_option($ssbg_option_name, array_values($images));
     33      //print $_REQUEST['picture'];
    2734      ssbg_form_list_images();
    2835      break;
    2936    case 'delete':
    3037      $id = $_REQUEST['id'];
    31       $images = get_option($ssbg_option, array());
     38      $images = get_option($ssbg_option_name, array());
    3239      unset($images[$id]);
    33       update_option($ssbg_option, array_values($images));
     40      update_option($ssbg_option_name, array_values($images));
    3441      ssbg_form_list_images();
    3542      break;
    3643    case 'add_ssb':
    37       $images = get_option($ssbg_option, array());
     44      $images = get_option($ssbg_option_name, array());
    3845      $images[] = array("picture" => '');
    39       update_option($ssbg_option, array_values($images));
     46      update_option($ssbg_option_name, array_values($images));
    4047      ssbg_form_list_images();
    4148      break;
  • simple-slideshow-background/trunk/admin-table.php

    r644112 r650011  
    8686    // WordPress globals
    8787    global $wpdb;
    88     global $ssbg_option;
     88    global $ssbg_option_name;
    8989       
    9090    /**
     
    102102    $this->_column_headers = array($columns, $hidden, $sortable);
    103103   
    104     $data = get_option($ssbg_option, array());
     104    $data = get_option($ssbg_option_name, array());
    105105    for($id = 0; $id < count($data); $id++){
    106106      $data[$id]['id'] = $id;
  • simple-slideshow-background/trunk/display-background.php

    r644112 r650011  
    22
    33function ssbg_display_background() {
    4     global $ssbg_option;
     4    global $ssbg_option_name, $ssbg_settings;
    55 
    6   $images = get_option($ssbg_option);
    7    
    8     if($images) {
    9         $image_html  = '<img id="ssbg_image1"/>';
    10     $image_html .= '<img id="ssbg_image2"/>';
    11     $image_html .= '<script language="JavaScript1.2">
    12                     var imgs=new Array()
    13                     ';
     6  if($ssbg_settings['enabled']){
     7    $images = get_option($ssbg_option_name);
    148
    15     for($i = 0; $i < count($images); $i++){
    16       $image_html .= 'imgs['.$i.']="'.$images[$i]['picture']."\";\n";
     9    if($images) {
     10      $image_html  = '<img id="ssbg_image1"/>';
     11      $image_html .= '<img id="ssbg_image2"/>';
     12      $image_html .= '<script language="JavaScript1.2">
     13                      var imgs=new Array()
     14                      ';
     15
     16      for($i = 0; $i < count($images); $i++){
     17        $image_html .= 'imgs['.$i.']="'.$images[$i]['picture']."\";\n";
     18      }
     19
     20      $image_html .= '
     21                    if( ! /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
     22                      //preload images
     23                      var pathToImg=new Array()
     24                      for (i=0;i<imgs.length;i++)
     25                      {
     26                        pathToImg[i]=new Image()
     27                        pathToImg[i].src=imgs[i]
     28                      }
     29
     30                      var inc = Math.floor(Math.random()*imgs.length);
     31
     32                      jQuery(\'#ssbg_image1\').attr(\'src\',imgs[inc]);
     33
     34                      fadeout = 1;
     35                      fadein = 2;
     36
     37                      function simpleSlideshow()
     38                      {
     39                        if (inc<imgs.length-1)
     40                          inc++
     41                        else
     42                          inc=0
     43
     44                        jQuery(\'#ssbg_image\'+fadein).css(\'zIndex\', -9999); 
     45                        jQuery(\'#ssbg_image\'+fadeout).css(\'zIndex\', -9998);
     46
     47                        jQuery(\'#ssbg_image\'+fadein).attr(\'src\', imgs[inc]);
     48                        jQuery(\'#ssbg_image\'+fadein).show();
     49
     50                        jQuery(\'#ssbg_image\'+fadeout).fadeOut(1000,function(){});
     51
     52                        temp = fadeout;
     53                        fadeout = fadein;
     54                        fadein = temp;
     55                      }
     56
     57                      jQuery(\'document\').ready(setInterval(function() { simpleSlideshow() },'.$ssbg_settings['delay'].'000));
     58                    }
     59                  </script>';
    1760    }
    18    
    19     $image_html .= '
    20                   if( ! /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
    21                     //preload images
    22                     var pathToImg=new Array()
    23                     for (i=0;i<imgs.length;i++)
    24                     {
    25                       pathToImg[i]=new Image()
    26                       pathToImg[i].src=imgs[i]
    27                     }
    28 
    29                     var inc = Math.floor(Math.random()*imgs.length);
    30 
    31                     jQuery(\'#ssbg_image1\').attr(\'src\',imgs[inc]);
    32 
    33                     fadeout = 1;
    34                     fadein = 2;
    35 
    36                     function simpleSlideshow()
    37                     {
    38                       if (inc<imgs.length-1)
    39                         inc++
    40                       else
    41                         inc=0
    42 
    43                       jQuery(\'#ssbg_image\'+fadein).css(\'zIndex\', -9999); 
    44                       jQuery(\'#ssbg_image\'+fadeout).css(\'zIndex\', -9998);
    45 
    46                       jQuery(\'#ssbg_image\'+fadein).attr(\'src\', imgs[inc]);
    47                       jQuery(\'#ssbg_image\'+fadein).show();
    48 
    49                       jQuery(\'#ssbg_image\'+fadeout).fadeOut(1000,function(){});
    50 
    51                       temp = fadeout;
    52                       fadeout = fadein;
    53                       fadein = temp;
    54                     }
    55 
    56                     jQuery(\'document\').ready(setInterval(function() { simpleSlideshow() },5000));
    57                   }
    58                 </script>';
    59     }
    60     // output the image
    61     echo $image_html;
     61    // output the image
     62    echo $image_html;
     63  }
    6264}
    6365add_action('wp_footer', 'ssbg_display_background');
  • simple-slideshow-background/trunk/readme.txt

    r644112 r650011  
    55Requires at least: 3.0.1
    66Tested up to: 3.4
    7 Stable tag: 4.3
     7Stable tag: 0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2121== Installation ==
    2222
     23Installation from zip:
     24
    23251. From wp-admin interface, select Plugins -> Add New
    24262. Click Upload
     
    26284. Click "Install Now"
    27295. Activate the plugin through the 'Plugins' menu in WordPress
     30
     31Installation from Wordpress Plugin Directory
     32
     331. From wp-admin interface, go to Plugins -> Add New
     342. Search for "Simple Slideshow Background"
     353. Click Install Now under the plugin name
     364. Click Ok to install the plugin
     375. Click Activate Plugin once installed
    2838
    2939== Frequently Asked Questions ==
     
    4252== Changelog ==
    4353
     54= 0.2 =
     55* Added two settings to allow temporarily disabling slideshow and setting timer between images.
     56
    4457= 0.1 =
    4558* First release with simple functionality.
    4659
     60== Upgrade Notice ==
     61
     62= 0.2 =
     63* Added two settings to allow temporarily disabling slideshow and setting timer between images.
    4764
    4865
     66
     67
  • simple-slideshow-background/trunk/simple-slideshow-background.php

    r644112 r650011  
    22/**
    33 * @package simple-slideshow-background
    4  * @version 0.1
     4 * @version 0.2
    55 */
    66/*
     
    1414
    1515// Globals
    16 $ssbg_option = 'simple-slideshow_background_images';
     16$ssbg_option_name = 'simple-slideshow_background_images';
     17$ssbg_settings_name = 'simple-slideshow_settings';
     18
     19$ssbg_settings = get_option($ssbg_settings_name);
     20if(!$ssbg_settings){
     21  // If settings are not yet set, create them based on defaults
     22  $ssbg_settings['delay'] = 5;
     23  $ssbg_settings['enabled'] = true;
     24  update_option($ssbg_settings_name, $ssbg_settings);
     25}
    1726
    1827include_once 'admin-form.php';
Note: See TracChangeset for help on using the changeset viewer.