Changeset 1005532
- Timestamp:
- 10/11/2014 08:05:50 AM (11 years ago)
- Location:
- jellyfish-invaders
- Files:
-
- 4 added
- 4 edited
-
assets/banner-1544x500.jpg (added)
-
assets/banner-772x250.jpg (modified) (previous)
-
assets/icon-128x128.jpg (added)
-
assets/icon-256x256.jpg (added)
-
trunk/jellyfish_invaders.css (modified) (4 diffs)
-
trunk/jellyfish_invaders.php (modified) (19 diffs)
-
trunk/js/jquery.spritely.js (added)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
jellyfish-invaders/trunk/jellyfish_invaders.css
r648542 r1005532 1 /* 1 /* 2 2 Document : jellyfish_invaders.css 3 3 Created on : 02/01/2013, 1:12:13 PM … … 14 14 width: 220px; 15 15 height: 180px; 16 z-index: 1000;17 16 } 18 17 .medium-invader { … … 23 22 width: 110px; 24 23 height: 90px; 25 z-index: 1000;26 24 } 27 25 .small-invader { … … 32 30 width: 55px; 33 31 height: 45px; 34 z-index: 1000;35 32 } -
jellyfish-invaders/trunk/jellyfish_invaders.php
r822235 r1005532 5 5 Description: Randomly animates retro space invaders on your WordPress blog 6 6 Author: Robert Miller <rob@strawberryjellyfish.com> 7 Version: 0.8 .17 Version: 0.8 8 8 Author URI: http://strawberryjellyfish.com/ 9 9 */ … … 30 30 */ 31 31 32 33 32 // set default options 34 register_activation_hook( __FILE__, 'jellyfish_invaders_default_options' );33 register_activation_hook( __FILE__, 'jellyfish_invaders_default_options' ); 35 34 36 35 // add admin page … … 38 37 39 38 // Register and define the settings 40 add_action( 'admin_init', 'jellyfish_invaders_admin_init');41 42 // enqueue javascript and css43 44 $jellyfish_invaders_options = get_option( 'jellyfish_invaders_options');39 add_action( 'admin_init', 'jellyfish_invaders_admin_init' ); 40 41 // enqueue JavaScript and css 42 43 $jellyfish_invaders_options = get_option( 'jellyfish_invaders_options' ); 45 44 46 45 // only need scripts if viewing blog and invaders are enabled 47 if ( !is_admin() && ($jellyfish_invaders_options['enable'] == true)) {48 add_action( 'wp_enqueue_scripts', 'jellyfish_invaders_queue_scripts');46 if ( !is_admin() && ( $jellyfish_invaders_options['enable'] == true ) ) { 47 add_action( 'wp_enqueue_scripts', 'jellyfish_invaders_queue_scripts' ); 49 48 } 50 49 … … 53 52 * Plugin Functions 54 53 */ 55 56 54 57 55 function jellyfish_invaders_queue_scripts() { … … 59 57 // and css when invaders are needed. This is slightly complicated by the fact 60 58 // 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)) {59 60 $jellyfish_invaders_options = get_option( 'jellyfish_invaders_options' ); 61 $need_invaders = false; 62 63 if ( !is_admin() && ( $jellyfish_invaders_options['enable'] == true ) ) { 66 64 // 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 pages70 // check we need them before queueing up the js and css71 if (is_single() OR is_page()) {72 $cv = get_post_meta( get_the_ID(), 'jellyfish_invaders',true);73 if ( ( $cv != 'true') && ($cv != 'on')){65 $need_invaders = true; 66 if ( $jellyfish_invaders_options['use_custom_field'] == true ) { 67 // but now only show invaders on specific pages 68 // check we need them before queueing up the js and css 69 if ( is_single() or is_page() ) { 70 $cv = get_post_meta( get_the_ID(), 'jellyfish_invaders', true ); 71 if ( ( $cv != 'true' ) && ( $cv != 'on' ) ) { 74 72 // abort: no custom field, no invaders needed 75 73 $need_invaders = false; 76 74 } 77 } else {75 } else { 78 76 // abort: not a single page or post can't show them anyway 79 77 $need_invaders = false; 80 }78 } 81 79 } 82 80 } 83 81 84 if ( $need_invaders) {85 //enqueue Spritely jquery library and js for animation and necessary css to page footer86 wp_register_script( 'spritely', plugins_url( 'js/jquery.spritely -0.6.js', __FILE__ ), array('jquery'), '', true );82 if ( $need_invaders ) { 83 //enqueue Spritely jQuery library and js for animation and necessary css to page footer 84 wp_register_script( 'spritely', plugins_url( 'js/jquery.spritely.js', __FILE__ ), array( 'jquery' ), '', true ); 87 85 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 } 86 wp_enqueue_style( 'jellyfish_invaders_style', plugins_url( 'jellyfish_invaders.css', __FILE__ ) ); 87 add_action( 'wp_footer', 'jellyfish_invaders_print_script', 100 ); 88 } 91 89 } 92 90 … … 103 101 $new_options['number_of_invaders'] = 5; 104 102 $new_options['duration'] = 3000; 105 $new_options['pause'] = 1000; 103 $new_options['pause'] = 1000; 106 104 $new_options['attack_mode'] = 1; 107 105 $new_options['size'] = 2; … … 110 108 $new_options['wiggle'] = true; 111 109 $new_options['random'] = true; 112 $new_options[' no_boundry'] = true;110 $new_options['boundary'] = false; 113 111 $new_options['top'] = 0; 114 112 $new_options['bottom'] = 400; 115 113 $new_options['left'] = 0; 116 114 $new_options['right'] = 800; 117 118 $new_options['version'] = "1.0"; 119 115 $new_options['z_index'] = 999; 116 $new_options['container_element'] = "body"; 117 118 $new_options['version'] = 1.1; 119 120 120 add_option( 'jellyfish_invaders_options', $new_options ); 121 121 } else { 122 122 $existing_options = get_option( 'jellyfish_invaders_options' ); 123 123 if ( $existing_options['version'] < 1.1 ) { 124 //$existing_options['version'] = "1.1"; 125 // add any new options here with version control 124 // new options with version control 125 $existing_options['version'] = 1.1; 126 $existing_options['z_index'] = 999; 127 $existing_options['container_element'] = "body"; 128 $existing_options['boundary'] = false; 126 129 update_option( 'jellyfish_invaders_options', $existing_options ); 127 130 } 128 131 } 129 132 } 130 133 131 134 132 135 function jellyfish_invaders_config_page() { … … 136 139 <h2>Jellyfish Invaders</h2> 137 140 <form action="options.php" method="post"> 138 <?php settings_fields( 'jellyfish_invaders_options'); ?>139 <?php do_settings_sections( 'jellyfish_invaders'); ?>141 <?php settings_fields( 'jellyfish_invaders_options' ); ?> 142 <?php do_settings_sections( 'jellyfish_invaders' ); ?> 140 143 <input name="Submit" type="submit" class="button action" value="Save Changes"/> 141 144 </form> … … 144 147 } 145 148 146 function jellyfish_invaders_admin_init() {149 function jellyfish_invaders_admin_init() { 147 150 register_setting( 'jellyfish_invaders_options', 'jellyfish_invaders_options', 'jellyfish_invaders_validate_options' ); 148 add_settings_section( 'jellyfish_invaders_main', ' Invader Behaviour', 'jellyfish_invaders_behaviour_text', 'jellyfish_invaders');151 add_settings_section( 'jellyfish_invaders_main', 'General Settings', 'jellyfish_invaders_behaviour_text', 'jellyfish_invaders' ); 149 152 add_settings_field( 'jellyfish_invaders_enable', 'Enable Invaders', 'jellyfish_invaders_enable_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 150 153 add_settings_field( 'jellyfish_invaders_use_custom_field', 'Where to show', 'jellyfish_invaders_use_custom_field_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 151 154 add_settings_field( 'jellyfish_invaders_number_of_invaders', 'Number of Invaders', 'jellyfish_invaders_number_of_invaders_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 152 add_settings_field( 'jellyfish_invaders_size', 'Invader Size', 'jellyfish_invaders_size_input', 'jellyfish_invaders', 'jellyfish_invaders_main' );153 add_settings_field( 'jellyfish_invaders_duration', 'Fly Time', 'jellyfish_invaders_duration_input', 'jellyfish_invaders', 'jellyfish_invaders_main' );155 add_settings_field( 'jellyfish_invaders_size', 'Invader Size', 'jellyfish_invaders_size_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 156 add_settings_field( 'jellyfish_invaders_duration', 'Fly Time', 'jellyfish_invaders_duration_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 154 157 add_settings_field( 'jellyfish_invaders_pause', 'Pause Time', 'jellyfish_invaders_pause_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 155 158 add_settings_field( 'jellyfish_invaders_random', 'Random', 'jellyfish_invaders_random_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 156 159 add_settings_field( 'jellyfish_invaders_wiggle', 'Wiggle', 'jellyfish_invaders_wiggle_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 157 160 add_settings_field( 'jellyfish_invaders_attack_mode', 'Attack Mode', 'jellyfish_invaders_attack_mode_input', 'jellyfish_invaders', 'jellyfish_invaders_main' ); 158 add_settings_section( 'jellyfish_invaders_boundry', 'Invader Boundries', 'jellyfish_invaders_boundry_text', 'jellyfish_invaders'); 159 add_settings_field( 'jellyfish_invaders_no_boundry', 'Ignore Boundries', 'jellyfish_invaders_no_boundry_input', 'jellyfish_invaders', 'jellyfish_invaders_boundry' ); 160 add_settings_field( 'jellyfish_invaders_top', 'Top', 'jellyfish_invaders_top_input', 'jellyfish_invaders', 'jellyfish_invaders_boundry' ); 161 add_settings_field( 'jellyfish_invaders_left', 'Left', 'jellyfish_invaders_left_input', 'jellyfish_invaders', 'jellyfish_invaders_boundry' ); 162 add_settings_field( 'jellyfish_invaders_right', 'Right', 'jellyfish_invaders_right_input', 'jellyfish_invaders', 'jellyfish_invaders_boundry' ); 163 add_settings_field( 'jellyfish_invaders_bottom', 'Bottom', 'jellyfish_invaders_bottom_input', 'jellyfish_invaders', 'jellyfish_invaders_boundry' ); 161 add_settings_section( 'jellyfish_invaders_advanced', 'Advanced Settings', 'jellyfish_invaders_advanced_text', 'jellyfish_invaders' ); 162 add_settings_field( 'jellyfish_invaders_container_element', 'Containing Element', 'jellyfish_invaders_container_element_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 163 add_settings_field( 'jellyfish_invaders_z_index', 'Z-index', 'jellyfish_invaders_z_index_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 164 add_settings_field( 'jellyfish_invaders_boundary', 'Use Electric Fence', 'jellyfish_invaders_boundary_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 165 add_settings_field( 'jellyfish_invaders_top', 'Fence Top', 'jellyfish_invaders_top_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 166 add_settings_field( 'jellyfish_invaders_left', 'Fence Left', 'jellyfish_invaders_left_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 167 add_settings_field( 'jellyfish_invaders_right', 'Fence Right', 'jellyfish_invaders_right_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 168 add_settings_field( 'jellyfish_invaders_bottom', 'Fence Bottom', 'jellyfish_invaders_bottom_input', 'jellyfish_invaders', 'jellyfish_invaders_advanced' ); 164 169 } 165 170 // Draw the section header 166 171 function jellyfish_invaders_behaviour_text() { 167 echo ' <p>Here you can set the number and general behaviour of your invaders, too many invaders may effect system performance!</p>';172 echo ''; 168 173 } 169 174 // Draw the section header 170 function jellyfish_invaders_boundry_text() { 171 echo '<p>The following settings can be used to define an area on the page that the invaders will appear in. You can use this to confine them to a specific area on your page, to avoid getting in the way of content for example.</p>'; 172 echo '<p>If you just want them to fly free everywhere check the <b>Ignore Boundries</b> checkbox</p> '; 175 function jellyfish_invaders_advanced_text() { 176 echo '<p>Invaders live in the document body and normally have free 177 roam of the entire page but you can confine them to within a specific page 178 element or set up a virtual electric fence to keep them within a box area 179 you define in pixels.</p> '; 173 180 } 174 181 … … 177 184 $options = get_option( 'jellyfish_invaders_options' ); 178 185 $number_of_invaders = $options['number_of_invaders']; 179 echo "<input id='number_of_invaders' name='jellyfish_invaders_options[number_of_invaders]' type='text' value='$number_of_invaders' /> "; 186 $html = "<input id='number_of_invaders' name='jellyfish_invaders_options[number_of_invaders]' type='text' value='$number_of_invaders' size=5/> "; 187 $html .= '<label for="number_of_invaders"> 1 - 10 is a good number </label>'; 188 echo $html; 180 189 } 181 190 … … 183 192 $options = get_option( 'jellyfish_invaders_options' ); 184 193 $duration = $options['duration']; 185 echo "<input id='duration' name='jellyfish_invaders_options[duration]' type='text' value='$duration' /> "; 194 $html = "<input id='duration' name='jellyfish_invaders_options[duration]' type='text' value='$duration' size=5 /> "; 195 $html .= '<label for="duration">ms (1000 = 1 second)</label>'; 196 echo $html; 186 197 } 187 198 … … 189 200 $options = get_option( 'jellyfish_invaders_options' ); 190 201 $pause = $options['pause']; 191 echo "<input id='pause' name='jellyfish_invaders_options[pause]' type='text' value='$pause' /> "; 202 $html = "<input id='pause' name='jellyfish_invaders_options[pause]' type='text' value='$pause' size=5 /> "; 203 $html .= '<label for="pause">ms</label>'; 204 echo $html; 192 205 } 193 206 … … 195 208 $options = get_option( 'jellyfish_invaders_options' ); 196 209 $html = "<input id='wiggle' name='jellyfish_invaders_options[wiggle]' type='checkbox' ". checked( true, $options['wiggle'], false ). " / > "; 197 $html .= '<label for="wiggle">Invaders wiggle not rest</label>'; 210 $html .= '<label for="wiggle">Invaders wiggle not rest</label>'; 198 211 echo $html; 199 212 } … … 202 215 $options = get_option( 'jellyfish_invaders_options' ); 203 216 $html = "<input id='enable' name='jellyfish_invaders_options[enable]' type='checkbox' ". checked( true, $options['enable'], false ). " / > "; 204 $html .= '<label for="wiggle">Uncheck this to turn the Invaders off</label>'; 217 $html .= '<label for="wiggle">Uncheck this to turn the Invaders off</label>'; 205 218 echo $html; 206 219 } … … 209 222 $options = get_option( 'jellyfish_invaders_options' ); 210 223 $html = "<input id='random' name='jellyfish_invaders_options[random]' type='checkbox' ". checked( true, $options['random'], false ). " / > "; 211 $html .= '<label for="random">Add some variation to duration and delay</label>'; 212 echo $html; 213 } 214 215 function jellyfish_invaders_use_custom_field_input() { 224 $html .= '<label for="random">Add some variation to duration and delay</label>'; 225 echo $html; 226 } 227 228 function jellyfish_invaders_use_custom_field_input() { 216 229 $options = get_option( 'jellyfish_invaders_options' ); 217 230 $use_custom_field = $options['use_custom_field']; 218 $html = '<input type="radio" id="invader_use_custom_field_one" name="jellyfish_invaders_options[use_custom_field]" value="false"' . checked( false, $use_custom_field, false ) . '/>'; 219 $html .= '<label for="invader_size_one">Show Everywhere</label> ' ; 220 $html .= '<input type="radio" id="invader_use_custom_field_two" name="jellyfish_invaders_options[use_custom_field]" value="true"' . checked( true, $use_custom_field, false ) . '/>'; 221 $html .= '<label for="invader_size_two">Only on posts or pages with custom field</label> ' ; 222 echo $html; 223 } 224 function jellyfish_invaders_size_input() { 231 $html = '<input type="radio" id="invader_use_custom_field_one" name="jellyfish_invaders_options[use_custom_field]" value="false"' . checked( false, $use_custom_field, false ) . '/>'; 232 $html .= '<label for="invader_size_one">Show Everywhere</label> ' ; 233 $html .= '<br/><input type="radio" id="invader_use_custom_field_two" name="jellyfish_invaders_options[use_custom_field]" value="true"' . checked( true, $use_custom_field, false ) . '/>'; 234 $html .= '<label for="invader_siz 235 e_two">Only on posts or pages with custom field</label> ' ; 236 echo $html; 237 } 238 function jellyfish_invaders_size_input() { 225 239 $options = get_option( 'jellyfish_invaders_options' ); 226 240 $size = $options['size']; 227 $html = '<input type="radio" id="invader_size_one" name="jellyfish_invaders_options[size]" value="1"' . checked( 1, $size, false ) . '/>'; 228 $html .= '<label for="invader_size_one">Small</label> ' ; 229 $html .= '< input type="radio" id="invader_size_two" name="jellyfish_invaders_options[size]" value="2"' . checked( 2, $size, false ) . '/>';230 $html .= '<label for="invader_size_two">Medium</label> ' ; 231 $html .= '< input type="radio" id="invader_size_three" name="jellyfish_invaders_options[size]" value="3"' . checked( 3, $size, false ) . '/>';241 $html = '<input type="radio" id="invader_size_one" name="jellyfish_invaders_options[size]" value="1"' . checked( 1, $size, false ) . '/>'; 242 $html .= '<label for="invader_size_one">Small</label> ' ; 243 $html .= '<br/><input type="radio" id="invader_size_two" name="jellyfish_invaders_options[size]" value="2"' . checked( 2, $size, false ) . '/>'; 244 $html .= '<label for="invader_size_two">Medium</label> ' ; 245 $html .= '<br/><input type="radio" id="invader_size_three" name="jellyfish_invaders_options[size]" value="3"' . checked( 3, $size, false ) . '/>'; 232 246 $html .= '<label for="invader_size_three">Large</label> '; 233 echo $html; 234 } 235 236 function jellyfish_invaders_attack_mode_input() { 247 echo $html; 248 } 249 250 function jellyfish_invaders_attack_mode_input() { 237 251 $options = get_option( 'jellyfish_invaders_options' ); 238 252 $attack = $options['attack_mode']; 239 $html = '<input type="radio" id="invader_attack_mode_one" name="jellyfish_invaders_options[attack_mode]" value="1"' . checked( 1, $attack, false ) . '/>'; 240 $html .= '<label for="invader_attack_mode_one">Off</label> '; 241 $html .= '<input type="radio" id="invader_attack_mode_two" name="jellyfish_invaders_options[attack_mode]" value="2"' . checked( 2, $attack, false ) . '/>'; 242 $html .= '<label for="invader_attack_mode_two">Solo</label> '; 243 $html .= '<input type="radio" id="invader_attack_mode_three" name="jellyfish_invaders_options[attack_mode]" value="3"' . checked( 3, $attack, false ) . '/>'; 244 $html .= '<label for="invader_attack_mode_two">Squadron</label> '; 245 echo $html; 246 } 247 248 function jellyfish_invaders_no_boundry_input() { 249 $options = get_option( 'jellyfish_invaders_options' ); 250 $html = "<input id='enable' name='jellyfish_invaders_options[no_boundry]' type='checkbox' ". checked( true, $options['no_boundry'], false ). " / > "; 251 $html .= '<label for="wiggle">Let them roam entire page (overrides the settings below)</label>'; 253 $html = '<input type="radio" id="invader_attack_mode_one" name="jellyfish_invaders_options[attack_mode]" value="1"' . checked( 1, $attack, false ) . '/>'; 254 $html .= '<label for="invader_attack_mode_one">Off</label> '; 255 $html .= '<br/><input type="radio" id="invader_attack_mode_two" name="jellyfish_invaders_options[attack_mode]" value="2"' . checked( 2, $attack, false ) . '/>'; 256 $html .= '<label for="invader_attack_mode_two">Solo</label> '; 257 $html .= '<br/><input type="radio" id="invader_attack_mode_three" name="jellyfish_invaders_options[attack_mode]" value="3"' . checked( 3, $attack, false ) . '/>'; 258 $html .= '<label for="invader_attack_mode_three">Squadron</label> '; 259 echo $html; 260 } 261 262 function jellyfish_invaders_z_index_input() { 263 $options = get_option( 'jellyfish_invaders_options' ); 264 $z_index = $options['z_index']; 265 $html = "<input id='z_index' name='jellyfish_invaders_options[z_index]' type='text' value='$z_index' size=5 /> "; 266 $html .= '<label for="z_index">Layer invaders behind / in front of other page elements</label>'; 267 echo $html; 268 } 269 270 function jellyfish_invaders_container_element_input() { 271 $options = get_option( 'jellyfish_invaders_options' ); 272 $container_element = $options['container_element']; 273 $html = "<input id='container_element' name='jellyfish_invaders_options[container_element]' type='text' value='$container_element' /> "; 274 $html .= '<label for="container_element">Element id (eg. #content)</label>'; 275 echo $html; 276 } 277 278 function jellyfish_invaders_boundary_input() { 279 $options = get_option( 'jellyfish_invaders_options' ); 280 $html = "<input id='enable' name='jellyfish_invaders_options[boundary]' type='checkbox' ". checked( true, $options['boundary'], false ). " / > "; 281 $html .= '<label for="enable"> Confine to fenced area (overrides <b>Containing Element</b> option)</label>'; 252 282 echo $html; 253 283 } … … 255 285 $options = get_option( 'jellyfish_invaders_options' ); 256 286 $top = $options['top']; 257 echo "<input id='top' name='jellyfish_invaders_options[top]' type='text' value='$top' /> "; 287 $html = "<input id='top' name='jellyfish_invaders_options[top]' type='text' value='$top' size=5 /> "; 288 $html .= '<label for="top">px</label>'; 289 echo $html; 258 290 } 259 291 function jellyfish_invaders_left_input() { 260 292 $options = get_option( 'jellyfish_invaders_options' ); 261 293 $left = $options['left']; 262 echo "<input id='left' name='jellyfish_invaders_options[left]' type='text' value='$left' /> "; 294 $html = "<input id='left' name='jellyfish_invaders_options[left]' type='text' value='$left' size=5 /> "; 295 $html .= '<label for="left">px</label>'; 296 echo $html; 263 297 } 264 298 function jellyfish_invaders_right_input() { 265 299 $options = get_option( 'jellyfish_invaders_options' ); 266 300 $right = $options['right']; 267 echo "<input id='right' name='jellyfish_invaders_options[right]' type='text' value='$right' /> "; 301 $html = "<input id='right' name='jellyfish_invaders_options[right]' type='text' value='$right' size=5 /> "; 302 $html .= '<label for="right">px</label>'; 303 echo $html; 268 304 } 269 305 function jellyfish_invaders_bottom_input() { 270 306 $options = get_option( 'jellyfish_invaders_options' ); 271 307 $bottom = $options['bottom']; 272 echo "<input id='bottom' name='jellyfish_invaders_options[bottom]' type='text' value='$bottom' /> "; 273 } 274 275 276 // Validate user input 308 $html = "<input id='bottom' name='jellyfish_invaders_options[bottom]' type='text' value='$bottom' size=5 /> "; 309 $html .= '<label for="bottom">px</label>'; 310 echo $html; 311 } 312 313 314 // Validate user input 277 315 function jellyfish_invaders_validate_options( $input ) { 278 316 $valid = array(); 279 280 if ( $input['enable'] == true) {317 318 if ( $input['enable'] == true ) { 281 319 $valid['enable'] = true; 282 320 } else { 283 321 $valid['enable'] = false; 284 322 } 285 286 if ( $input['random'] == true) {323 324 if ( $input['random'] == true ) { 287 325 $valid['random'] = true; 288 326 } else { … … 290 328 } 291 329 292 if ( $input['wiggle'] == true) {330 if ( $input['wiggle'] == true ) { 293 331 $valid['wiggle'] = true; 294 332 } else { … … 296 334 } 297 335 // number of invaders min 1, max 30 298 $valid['number_of_invaders'] = min( 30, max(1, absint($input['number_of_invaders'])));336 $valid['number_of_invaders'] = min( 30, max( 1, absint( $input['number_of_invaders'] ) ) ); 299 337 // duration min 250, max 10000 300 $valid['duration'] = min( 10000, max(250, absint($input['duration'])));338 $valid['duration'] = min( 10000, max( 250, absint( $input['duration'] ) ) ); 301 339 // pause min 0, max 10000 302 $valid['pause'] = min(10000, max(0, absint($input['pause']))); 303 304 $valid['size'] = intval($input['size']); 305 306 $valid['attack_mode'] = intval($input['attack_mode']); 307 308 if ($input['use_custom_field'] == 'true') { 340 $valid['pause'] = min( 10000, max( 0, absint( $input['pause'] ) ) ); 341 342 $valid['size'] = intval( $input['size'] ); 343 344 $valid['attack_mode'] = intval( $input['attack_mode'] ); 345 346 $valid['z_index'] = intval( $input['z_index'] ); 347 $valid['container_element'] = wp_filter_nohtml_kses( $input['container_element'] ); 348 349 if ( $input['use_custom_field'] == 'true' ) { 309 350 $valid['use_custom_field'] = true; 310 351 } else { 311 352 $valid['use_custom_field'] = false; 312 353 } 313 if ($input['no_boundry'] == true) { 314 $valid['no_boundry'] = true; 315 } else { 316 $valid['no_boundry'] = false; 317 } 318 319 $valid['top'] = absint($input['top']); 320 $valid['bottom'] = absint($input['bottom']); 321 $valid['left'] = absint($input['left']); 322 $valid['right'] = absint($input['right']); 354 if ( $input['boundary'] == true ) { 355 $valid['boundary'] = true; 356 } else { 357 $valid['boundary'] = false; 358 } 359 360 $valid['top'] = absint( $input['top'] ); 361 $valid['bottom'] = absint( $input['bottom'] ); 362 $valid['left'] = absint( $input['left'] ); 363 $valid['right'] = absint( $input['right'] ); 364 323 365 324 366 return $valid; 325 367 } 326 368 327 328 329 369 /* 330 * Generate the invaders javascript based on user settings370 * Generate the invaders JavaScript based on user settings 331 371 */ 332 372 333 373 function jellyfish_invaders_print_script() { 334 374 global $wpdb; 335 $options = get_option( 'jellyfish_invaders_options');375 $options = get_option( 'jellyfish_invaders_options' ); 336 376 $count = 0; 337 $script = '';338 377 $small_speed = 2; 339 378 $medium_speed = 1.5; 340 379 $large_speed = 1; 341 342 // check if we are displaying globa blly or ONLY on post/page that380 381 // check if we are displaying globally or ONLY on post/page that 343 382 // has jellyfish_invaders custom field set to TRUE 344 if ( $options['use_custom_field'] == true) {345 if ( is_single() OR is_page()) {346 $cv = get_post_meta( get_the_ID(), 'jellyfish_invaders',true);347 if ( ( $cv != 'true') && ($cv != 'on')){348 // abort: no custom field383 if ( $options['use_custom_field'] == true ) { 384 if ( is_single() or is_page() ) { 385 $cv = get_post_meta( get_the_ID(), 'jellyfish_invaders', true ); 386 if ( ( $cv != 'true' ) && ( $cv != 'on' ) ) { 387 // abort: no custom field 349 388 return; 350 389 } … … 354 393 } 355 394 } 356 357 // first set up variables for things that are applicable to all invaders 358 if ($options['no_boundry'] == true) { 359 // free to roam entire page 360 $top = 0; 361 $left = 0; 362 $right ="jQuery(document).width()-jQuery('#invader0').width()"; 363 $bottom = "jQuery(document).height()-jQuery('#invader0').height()"; 364 } else { 365 // use boundry settings 366 $top = $options['top']; 367 $left = $options['left']; 368 $right = $options['right']; 369 $bottom = $options['bottom']; 370 } 371 395 372 396 // choose class (size of invader depending on settings) 373 397 // as we are acting on sizes here also set up the 374 // appropiate speed and pause bounce 375 if ($options['size'] === 1) { 376 $class='small-invader'; 377 $spd = $small_speed; 378 $bounce = ', bounce:[1, 55, '. 2000 / $spd . ']'; 379 } elseif ($options['size'] === 2) { 380 $class='medium-invader'; 381 $spd = $medium_speed; 382 $bounce = ', bounce:[1, 110, '. 2000 / $spd . ']'; 383 } else { 384 $class='large-invader'; 385 $spd = $large_speed; 386 $bounce = ', bounce:[1, 220, '. 2000 / $spd . ']'; 387 } 388 398 // appropriate speed and pause bounce 399 if ( $options['size'] === 1 ) { 400 $class='small-invader'; 401 $spd = $small_speed; 402 $bounce = ', bounce:[1, 55, '. 2000 / $spd . ']'; 403 $width = 55; 404 $height = 45; 405 } elseif ( $options['size'] === 2 ) { 406 $class='medium-invader'; 407 $spd = $medium_speed; 408 $bounce = ', bounce:[1, 110, '. 2000 / $spd . ']'; 409 $width = 110; 410 $height = 90; 411 } else { 412 $class='large-invader'; 413 $spd = $large_speed; 414 $bounce = ', bounce:[1, 220, '. 2000 / $spd . ']'; 415 $width = 220; 416 $height = 180; 417 } 418 389 419 // blank the pause bounce if it is not wanted 390 if ( $options['wiggle'] != true) {420 if ( $options['wiggle'] != true ) { 391 421 $bounce =''; 392 } 393 394 while ($count < $options['number_of_invaders'] ) { 395 // create js for each invader required, include a bit of random variation 422 } else { 423 $width * 2; 424 } 425 426 $top = $options['top']; 427 $left = $options['left']; 428 $right = $options['right']; 429 $bottom = $options['bottom']; 430 $z_index = $options['z_index'] ? $options['z_index'] : 0 ; 431 $container = $options['container_element'] ? $options['container_element'] : 'body'; 432 433 $script = "var invaderContainer = jQuery('$container');"; 434 435 if ( $options['boundary'] == true ) { 436 // use boundary settings 437 $container = 'body'; 438 $script .= " 439 var invaderContainer = jQuery('$container'); 440 var invaderBoundaryTop = $top; 441 var invaderBoundaryLeft = $left; 442 var invaderBoundaryRight = $right - $width; 443 var invaderBoundaryBottom = $bottom - $height; 444 "; 445 446 } else { 447 // free to roam entire containing element 448 $script .= " 449 var invaderContainer = jQuery('$container'); 450 var invaderBoundaryTop = invaderContainer.offset().top; 451 var invaderBoundaryLeft = invaderContainer.offset().left; 452 var invaderBoundaryRight = ( invaderBoundaryLeft + invaderContainer.width() ) - $width; 453 var invaderBoundaryBottom = ( invaderBoundaryTop + invaderContainer.height() ) - $height; 454 "; 455 } 456 457 while ( $count < $options['number_of_invaders'] ) { 458 // create js for each invader required, include a bit of random variation 396 459 // to the duration and pause to make it less uniform if set in settings 397 if ( $options['random'] == true) {398 $duration = max( 0, ($options['duration']+(($options['duration']/100) * rand(-50, 50))));399 $pause = max( 0, ($options['pause']+(($options['pause']/100) * rand(-50, 50))));460 if ( $options['random'] == true ) { 461 $duration = max( 0, ( $options['duration']+( ( $options['duration']/100 ) * rand( -50, 50 ) ) ) ); 462 $pause = max( 0, ( $options['pause']+( ( $options['pause']/100 ) * rand( -50, 50 ) ) ) ); 400 463 } else { 401 464 $duration = $options['duration']; 402 $pause = $options['pause']; 465 $pause = $options['pause']; 403 466 } 404 $script.="var invaderDiv = jQuery(document.createElement('div')).attr('id','invader$count').addClass('$class').appendTo('body');\n"; 405 $script .= "jQuery('#invader$count').sprite({fps: $spd, no_of_frames: 2 $bounce}).spRandom({top: $top, left: $left, right: $right, bottom: $bottom, speed: $duration, pause: $pause}).active().activeOnClick().bounce;\n"; 467 $script.=" 468 var jellyfishInvaderDiv$count = jQuery('<div>', { id: 'jellyfishInvader$count', class: '$class'}) 469 .css('z-index', $z_index) 470 .appendTo('$container') 471 .sprite({ 472 fps: $spd, 473 no_of_frames: 2 474 $bounce 475 }) 476 .spRandom({ 477 top: invaderBoundaryTop, 478 left: invaderBoundaryLeft, 479 right: invaderBoundaryRight, 480 bottom: invaderBoundaryBottom, 481 speed: $duration, 482 pause: $pause 483 }) 484 .active() 485 .activeOnClick() 486 .bounce; 487 \n"; 406 488 $count ++; 407 489 } 408 490 echo "<script>jQuery(document).ready(function() {"; 409 491 echo $script; 492 410 493 // add a ftytotap even if attack mode is set, either just first invader or all elements with 411 494 // invader classes (hopefully these are just invaders!) 412 if ($options['attack_mode'] === 3) { 413 echo "jQuery('html').flyToTap({el_to_move: '.".$class."', ms: 500, do_once: false});"; 414 } elseif ($options['attack_mode'] === 2) { 415 echo "jQuery('html').flyToTap({el_to_move: '#invader0', ms: 500, do_once: false});"; 416 } 495 if ( $options['attack_mode'] === 3 ) { 496 echo "jQuery('$container').flyToTap({el_to_move: '.".$class."', ms: 500, do_once: false});"; 497 } elseif ( $options['attack_mode'] === 2 ) { 498 echo "jQuery('$container').flyToTap({el_to_move: '#jellyfishInvader0', ms: 500, do_once: false});"; 499 } 500 417 501 echo "});</script>"; 418 502 } -
jellyfish-invaders/trunk/readme.txt
r822235 r1005532 3 3 Author URI: http://strawberryjellyfish.com/ 4 4 Donate link: http://strawberryjellyfish.com/donate/ 5 Plugin URI: http://strawberryjellyfish.com/wordpress-plugin -jellyfish-invaders/5 Plugin URI: http://strawberryjellyfish.com/wordpress-plugins/jellyfish-invaders/ 6 6 Tags: retro, space invaders, 8bit, animation, visual effect, animated aliens, sci fi, gaming, 7 7 Requires at least: 3.0 8 Tested up to: 3.89 Stable tag: 0.8 .18 Tested up to: 4.0 9 Stable tag: 0.8 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html 12 12 13 Add s animated flying retro space invaders to your blog. You can configure,14 number, size, behaviour and where they appear.13 Add pixelated pets to your site in the form of funky animated retro 14 space invaders. 15 15 16 16 == Description == 17 17 18 This plugin for WordPress adds a number of retro space invaders to your blog pages 19 that will randomly fly around, and if you choose home in on any mouse clicks. 18 Your new pixelated pals will randomly fly around, and if you choose, home in 19 on any mouse clicks. The glowing retro 8bit scan-line effect space invaders 20 work on most backgrounds but obviously are more suited to a dark theme. It's 21 easy to configure the number, size, behaviour and where the invaders appear 22 through the comprehensive admin control panel. 20 23 21 You can choose the number, size, speed, and behaviour of the space invaders as 22 well as limit them to a specific area of your pages, a single post, or the entire 23 blog. 24 Demo and more information at the plugin homepage: 24 25 25 Great glowing retro 8bit scanline effect space invaders work on most backgrounds 26 but obviously are more suited to a dark theme. 26 http://strawberryjellyfish/wordpress-plugins/jellyfish-invaders 27 27 28 Demo 28 = Configuring your Invaders = 29 29 30 You can see them in action on the plugin page at 31 http://strawberryjellyfish.com/wordpress-plugin-jellyfish-invaders/ 30 A new settings page will be added to your Admin Appearance section, where you 31 can change the look and behaviour of your new binary buddies. Here's an 32 overview of the available settings: 32 33 33 This plugin uses the excellent Spritely library for jQuery. Read more about 34 Spritely at http://www.spritely.net/ 34 * **Enable Invaders** Turn the invaders off and on. A quick way to 35 temporarily disable the invaders without deactivating the plugin. 35 36 37 * **Where to show** you can choose either everywhere OR only on individual 38 posts or pages. You can use this second option to just show them on your home 39 page or a single post for example. 36 40 37 ==Usage== 41 * **The invaders will look out for a custom field called "jellyfish_invaders" 42 on any post or page. If they find one and it has a value of 'true' or 'on' 43 they will populate the page. 38 44 39 The plugin will show some invaders on every page of your blog when first installed. 40 To change this to your liking you will find a setting page in the Appearance menu 41 of your WordPress admin, Here you can configure your invaders. 45 * **Number of Invaders** how many individual space invaders you want, keep 46 this number quite low to avoid slowing down your page too much 42 47 43 General Settings48 * **Invader Size** size of the invaders 44 49 45 * Enable Invaders - If you want to turn Invaders on or off use this 50 * **Fly Time** how long the invaders fly around before pausing in 51 milliseconds (1000 = 1 second) 46 52 47 * Where to show - you can choose either everywhere OR only on individual posts 48 or pages that contain the custom field "jellyfish_invaders". You can use this 49 second option to just show them on your home page or a single post for example. 50 Simply add the custom field "jellyfish_invaders" with a value of "true" or "on" 51 to any post you want them to appear. 53 * **Pause Time** How long the invaders Pause (or wiggle see below) for 54 between flying cycles. 52 55 53 Boundries 56 * **Random** adds some variation to the time settings so each invader 57 acts a little differently. 54 58 55 By default the invaders will be free to roam randomly around the entire document. 56 If you want to restrict them to an area for example a header, sidebar or blank 57 area on your page to avoid distracting from the main content simply uncheck the 58 "Ignore Boundries" checkbox and fill in the top, left, right and bottom pixel 59 values of your invisible invader electric fence. 59 * **Wiggle** Instead of pausing the invaders will do a missile evasive 60 wiggle. 60 61 62 * **Attack Mode** None, One or All of the invaders will home in on any 63 mouse clicks. 61 64 65 By default the invaders will be free to roam randomly around the entire page, 66 but there are a couple of methods to confine them to specific areas if you wish. 67 68 * **Containing Element** the invaders will only roam within the element set 69 here, normally that's body (the whole page) but you may enter the id of an 70 element on the page to confine them to a specific area. You can see this in 71 effect right here where the invaders have been limited to the section at the 72 top of the page. 73 74 * **Z-Index** If you'd like the invaders to hide behind certain layers on 75 your page you can set an appropriate z-index here, obviously this setting it 76 very dependant on the structure of your WordPress theme. 77 78 * **Use Electric Fence** Check this option and use the top, left, right 79 and bottom options to define a virtual fence that will contain the invaders. 80 The values you enter represent pixels position on the entire document. Note, 81 this option will override any custom setting for Containing Element. 62 82 63 83 == Installation == 64 84 65 Extract the zip file and just drop the contents in the wp-content/plugins/ 66 directory of your WordPress installation and then activate the Plugin from 67 Plugins page. Visit your blog and marvel at the spectacle, then go to the 68 Jellyfish Invaders settings page in the Appearance menu of your WordPress 69 admin to play with the settings. 85 Either install and activate the plugin via your WordPress Admin 70 86 71 == Frequently Asked Questions == 87 Or 72 88 73 None yet 89 Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from 90 Plugins page. 91 92 When first installed the Jellyfish Invaders plugin will show some invaders on 93 every page of your blog. You can easily change this to your liking by visiting 94 the setting page, you will find a link to the settings page in the Appearance 95 menu of your WordPress admin. 96 97 == Frequently Asked Questions == 98 99 == Screenshots == 74 100 75 101 == Changelog == 76 102 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 79 when invaders are actually needed. 80 * 0.6 initial release 103 = 0.8 = 104 * Tested up to WordPress 4.0 105 * Added Containing Element option: Confine invaders to a specific page element 106 * Added Z-index support: Configure invaders z-index for layering in document 107 * Updated Admin screen 108 * Updated Spritely version 109 110 = 0.7 = 111 * changed the way scripts are queued to ensure JavaScript is only included when invaders are actually needed. 112 113 = 0.6 = 114 * Initial release 115 81 116 82 117 == Upgrade Notice == 83 118 84 == Screenshots == 119 There should be no issues upgrading from a previous version. Visit the plugin 120 settings page in Admin > Appearance > jellyfish Invaders to configure new 121 options.
Note: See TracChangeset
for help on using the changeset viewer.