function slideshow_ajax() {
global $values, $options;
$count = count($values);
if($count == 1) {
array_push($values, '1');
}
}
function slideshow_jquery() { ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery('#slideshow_button').click(function() {
jQuery.post(ajaxurl, { action:"slideshow_action" });
return false;
});
});
</script><?php
}
function slideshow_meta_box() {
global $post, $options, $values;
$meta_box_value = get_post_meta($post->ID, 'slideshow', true);
$options = explode(",", $meta_box_value);
?><input type="hidden" name="slideshow_noncename" id="slideshow_noncename" value="<?php echo wp_create_nonce('slideshow_nonce'); ?>" /><?php
$values = array('0');
foreach($values as $value) { ?>
<div style="position: relative; margin: 10px 10px 0 0;">
<input type="text" id="Image" style="position: relative; right: 0; width: 85%;" name="slideshow[<?php echo $value; ?>]" value="<?php echo $options[$value]; ?>" />
</div>
<?php } ?>
<input type="button" id="slideshow_button" name="slideshow_button" value="Add Image" /><?php
}
add_action('wp_ajax_slideshow_action', 'slideshow_ajax');
add_action('admin_head', 'slideshow_jquery');