| 1 |
<?php |
| 2 |
require('../../../../wp-load.php'); |
| 3 |
|
| 4 |
global $maxgalleria; |
| 5 |
$common = $maxgalleria->common; |
| 6 |
$image_gallery = $maxgalleria->image_gallery; |
| 7 |
|
| 8 |
$image_ids = $_GET['image_ids']; |
| 9 |
$updated = false; |
| 10 |
|
| 11 |
if ($_POST && check_admin_referer($image_gallery->nonce_image_edit_bulk['action'], $image_gallery->nonce_image_edit_bulk['name'])) { |
| 12 |
$i = 0; |
| 13 |
foreach ($_POST['image-edit-id'] as $image_edit_id) { |
| 14 |
// First update the post itself |
| 15 |
$temp = array(); |
| 16 |
$temp['ID'] = $image_edit_id; |
| 17 |
$temp['post_title'] = stripslashes($_POST['image-edit-title'][$i]); |
| 18 |
$temp['post_excerpt'] = stripslashes($_POST['image-edit-caption'][$i]); |
| 19 |
wp_update_post($temp); |
| 20 |
|
| 21 |
// Determine if we need to prepend http:// to the link |
| 22 |
$link = $_POST['image-edit-link'][$i]; |
| 23 |
if (isset($link) && $link != '') { |
| 24 |
if (!$common->string_starts_with($link, 'http://')) { |
| 25 |
$link = 'http://' . $link; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
// Now update the meta |
| 30 |
update_post_meta($image_edit_id, '_wp_attachment_image_alt', stripslashes($_POST['image-edit-alt'][$i])); |
| 31 |
update_post_meta($image_edit_id, 'maxgallery_attachment_image_link', stripslashes($link)); |
| 32 |
|
| 33 |
// Increment the counter |
| 34 |
$i++; |
| 35 |
} |
| 36 |
|
| 37 |
$updated = true; |
| 38 |
} |
| 39 |
?> |
| 40 |
|
| 41 |
<!DOCTYPE html> |
| 42 |
|
| 43 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 44 |
|
| 45 |
<head> |
| 46 |
<title><?php _e('Edit Bulk Images', 'maxgalleria') ?></title> |
| 47 |
<link rel="stylesheet" type="text/css" media="screen" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700" /> |
| 48 |
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo MAXGALLERIA_PLUGIN_URL ?>/maxgalleria.css" /> |
| 49 |
<?php $maxgalleria->thickbox_l10n_fix() ?> |
| 50 |
<script type="text/javascript" src="<?php echo admin_url() ?>load-scripts.php?load=jquery-core,thickbox,wp-ajax-response,imgareaselect,image-edit"></script> |
| 51 |
<script type="text/javascript"> |
| 52 |
<?php if ($updated) { ?> |
| 53 |
parent.eval("reloadPage()"); |
| 54 |
<?php } ?> |
| 55 |
|
| 56 |
jQuery(document).ready(function() { |
| 57 |
jQuery("#save-button").click(function () { |
| 58 |
jQuery("#image-bulk-edit-form").submit(); |
| 59 |
return false; |
| 60 |
}); |
| 61 |
|
| 62 |
jQuery("#cancel-button").click(function () { |
| 63 |
parent.eval("reloadPage()"); |
| 64 |
}); |
| 65 |
}); |
| 66 |
</script> |
| 67 |
</head> |
| 68 |
|
| 69 |
<body> |
| 70 |
|
| 71 |
<div class="maxgalleria-meta image-edit-bulk"> |
| 72 |
<form id="image-bulk-edit-form" method="post"> |
| 73 |
<?php if (isset($image_ids)) { ?> |
| 74 |
<?php $image_ids_array = explode(',', $image_ids) ?> |
| 75 |
|
| 76 |
<table cellpadding="0" cellspacing="0"> |
| 77 |
<?php foreach ($image_ids_array as $image_id) { ?> |
| 78 |
<?php if (isset($image_id)) { ?> |
| 79 |
<?php $image = get_post($image_id) ?> |
| 80 |
<?php if (isset($image)) { ?> |
| 81 |
<tr> |
| 82 |
<td class="thumb"> |
| 83 |
<?php echo wp_get_attachment_image($image->ID, MAXGALLERIA_META_IMAGE_THUMB_SMALL) ?> |
| 84 |
<input type="hidden" name="image-edit-id[]" value="<?php echo $image->ID ?>" /> |
| 85 |
</td> |
| 86 |
<td> |
| 87 |
<div class="fields"> |
| 88 |
<div class="field"> |
| 89 |
<div class="field-label"> |
| 90 |
<?php _e('Title', 'maxgalleria') ?> |
| 91 |
</div> |
| 92 |
<div class="field-value"> |
| 93 |
<input type="text" name="image-edit-title[]" value="<?php echo $image->post_title ?>" /> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
<div class="clear"></div> |
| 97 |
|
| 98 |
<div class="field"> |
| 99 |
<div class="field-label"> |
| 100 |
<?php _e('Alt Text', 'maxgalleria') ?> |
| 101 |
</div> |
| 102 |
<div class="field-value"> |
| 103 |
<input type="text" name="image-edit-alt[]" value="<?php echo get_post_meta($image->ID, '_wp_attachment_image_alt', true) ?>" /> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
<div class="clear"></div> |
| 107 |
|
| 108 |
<div class="field"> |
| 109 |
<div class="field-label"> |
| 110 |
<?php _e('Caption', 'maxgalleria') ?> |
| 111 |
</div> |
| 112 |
<div class="field-value"> |
| 113 |
<input type="text" name="image-edit-caption[]" value="<?php echo $image->post_excerpt ?>" /> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
<div class="clear"></div> |
| 117 |
|
| 118 |
<div class="field"> |
| 119 |
<div class="field-label"> |
| 120 |
<?php _e('Link', 'maxgalleria') ?> |
| 121 |
</div> |
| 122 |
<div class="field-value last"> |
| 123 |
<input type="text" name="image-edit-link[]" value="<?php echo get_post_meta($image->ID, 'maxgallery_attachment_image_link', true) ?>" /> |
| 124 |
</div> |
| 125 |
</div> |
| 126 |
<div class="clear"></div> |
| 127 |
</div> |
| 128 |
</td> |
| 129 |
</tr> |
| 130 |
<?php } ?> |
| 131 |
<?php } ?> |
| 132 |
<?php } ?> |
| 133 |
</table> |
| 134 |
<?php } ?> |
| 135 |
|
| 136 |
<div class="actions"> |
| 137 |
<div class="save"> |
| 138 |
<input type="button" class="btn btn-primary" id="save-button" value="<?php _e('Save Changes', 'maxgalleria') ?>" /> |
| 139 |
</div> |
| 140 |
<div class="cancel"> |
| 141 |
<input type="button" class="btn" id="cancel-button" value="<?php _e('Cancel', 'maxgalleria') ?>" /> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
|
| 145 |
<?php wp_nonce_field($image_gallery->nonce_image_edit_bulk['action'], $image_gallery->nonce_image_edit_bulk['name']) ?> |
| 146 |
</form> |
| 147 |
</div> |
| 148 |
|
| 149 |
</body> |
| 150 |
|
| 151 |
</html> |
| 152 |
|