Plugin Directory

Changeset 822235


Ignore:
Timestamp:
12/15/2013 01:12:20 AM (12 years ago)
Author:
toxicToad
Message:

Update for WordPress 3.8 compatibility

Location:
jellyfish-invaders/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • jellyfish-invaders/trunk/jellyfish_invaders.php

    r648631 r822235  
    22/*
    33  Plugin Name: Jellyfish Invaders
    4   Plugin URI: http://strawberryjellyfish.com/wordpress-plugin-jellyfish-invaders/
     4  Plugin URI: http://strawberryjellyfish.com/jellyfish-invaders/
    55  Description: Randomly animates retro space invaders on your WordPress blog
    66  Author: Robert Miller <rob@strawberryjellyfish.com>
    7   Version: 0.6
     7  Version: 0.8.1
    88  Author URI: http://strawberryjellyfish.com/
    99 */
    10 ?>
    11 <?php
     10
     11/*
     12This program is free software; you can redistribute it and/or modify
     13it under the terms of the GNU General Public License as published by
     14the Free Software Foundation; either version 2 of the License, or
     15(at your option) any later version.
     16
     17This program is distributed in the hope that it will be useful,
     18but WITHOUT ANY WARRANTY; without even the implied warranty of
     19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     20GNU General Public License for more details.
     21
     22You should have received a copy of the GNU General Public License
     23along with this program; if not, write to the Free Software
     24Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     25Online: http://www.gnu.org/licenses/gpl.txt
     26*/
     27
    1228/*
    1329 *  Hooks and Actions
     
    3147if (!is_admin() && ($jellyfish_invaders_options['enable'] == true)) {
    3248    add_action('wp_enqueue_scripts', 'jellyfish_invaders_queue_scripts');
    33     add_action('wp_footer', 'jellyfish_invaders_print_script',100);
    3449}
    3550
     
    4156
    4257function jellyfish_invaders_queue_scripts() {
    43     //enqueue Spritely jquery library for animation and necessary css to page footer
    44     wp_register_script( 'spritely', plugins_url( 'js/jquery.spritely-0.6.js', __FILE__ ), array('jquery'), '', true );
    45     wp_enqueue_script( 'spritely' );
    46     wp_enqueue_style( 'jellyfish_invaders_style',plugins_url( 'jellyfish_invaders.css', __FILE__ ) );
     58    // to save unnecessary requests and bandwidth, only include js scripts
     59    // and css when invaders are needed. This is slightly complicated by the fact
     60    // we can have them displaying on a per post basis.
     61   
     62    $jellyfish_invaders_options = get_option('jellyfish_invaders_options');
     63    $need_invaders = false;   
     64
     65    if (!is_admin() && ($jellyfish_invaders_options['enable'] == true)) {
     66        // most likely we need to print scripts
     67       $need_invaders = true;
     68       if ($jellyfish_invaders_options['use_custom_field'] == true) {
     69           // but now only show invaders on specific pages
     70           // check we need them before queueing up the js and css
     71           if (is_single() OR is_page()) {
     72                $cv = get_post_meta(get_the_ID(), 'jellyfish_invaders',true);
     73                if ( ($cv != 'true') && ($cv != 'on')){ 
     74                    // abort: no custom field, no invaders needed
     75                    $need_invaders = false;
     76                }
     77           } else {
     78                // abort: not a single page or post can't show them anyway
     79                $need_invaders = false;
     80           }
     81        }
     82    }
     83
     84    if ($need_invaders) {
     85    //enqueue Spritely jquery library and js for animation and necessary css to page footer
     86        wp_register_script( 'spritely', plugins_url( 'js/jquery.spritely-0.6.js', __FILE__ ), array('jquery'), '', true );
     87        wp_enqueue_script( 'spritely' );
     88        wp_enqueue_style( 'jellyfish_invaders_style',plugins_url( 'jellyfish_invaders.css', __FILE__ ) );
     89        add_action('wp_footer', 'jellyfish_invaders_print_script',100);
     90    } 
    4791}
    4892
     
    94138    <?php settings_fields('jellyfish_invaders_options'); ?>
    95139    <?php do_settings_sections('jellyfish_invaders'); ?>
    96     <input name="Submit" type="submit" value="Save Changes"/>
     140    <input name="Submit" type="submit" class="button action" value="Save Changes"/>
    97141    </form>
    98142</div>
  • jellyfish-invaders/trunk/readme.txt

    r648542 r822235  
    66Tags: retro, space invaders, 8bit, animation, visual effect, animated aliens, sci fi, gaming,
    77Requires at least: 3.0
    8 Tested up to: 3.5
    9 Stable tag: 0.6
     8Tested up to: 3.8
     9Stable tag: 0.8.1
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7474
    7575== Changelog ==
    76 0.6     initial release
     76
     77* 0.8.1 tweaked admin for WordPress 3.8
     78* 0.75  changed the way scripts are queued to ensure javascript is only included
     79when invaders are actually needed.       
     80* 0.6   initial release
    7781
    7882== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.