Advertisement
Guest User

Untitled

a guest
Oct 30th, 2010
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. function slideshow_ajax() {
  2.   global $values, $options;
  3.     $count = count($values);
  4.       if($count == 1) {
  5.         array_push($values, '1');
  6.       }
  7. }
  8.  
  9. function slideshow_jquery() { ?>
  10. <script type="text/javascript">
  11. jQuery(document).ready(function($) {
  12.  
  13.       jQuery('#slideshow_button').click(function() {
  14.           jQuery.post(ajaxurl, { action:"slideshow_action" });
  15.           return false;
  16.       });
  17.  
  18.     });
  19. </script><?php
  20. }
  21. function slideshow_meta_box() {
  22.   global $post, $options, $values;
  23.  
  24.   $meta_box_value = get_post_meta($post->ID, 'slideshow', true);
  25.  
  26.   $options = explode(",", $meta_box_value);
  27.  
  28.   ?><input type="hidden" name="slideshow_noncename" id="slideshow_noncename" value="<?php echo wp_create_nonce('slideshow_nonce'); ?>" /><?php
  29.  
  30.   $values = array('0');
  31.  
  32.   foreach($values as $value) { ?>
  33.   <div style="position: relative; margin: 10px 10px 0 0;">
  34.   <input type="text" id="Image" style="position: relative; right: 0; width: 85%;" name="slideshow[<?php echo $value; ?>]" value="<?php echo $options[$value]; ?>" />
  35.   </div>
  36.   <?php } ?>
  37.  
  38.   <input type="button" id="slideshow_button" name="slideshow_button" value="Add Image" /><?php
  39. }
  40.  
  41. add_action('wp_ajax_slideshow_action', 'slideshow_ajax');
  42. add_action('admin_head', 'slideshow_jquery');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement