Permalink
Browse files

Rename from sc_ to vspi_

  • Loading branch information...
1 parent 8dee28a commit c077271579c6df5a5bc4e11522c8ba9c9ea32592 @mrdavidlaing mrdavidlaing committed Jul 17, 2011
View
@@ -47,14 +47,14 @@ function insert_attachment($file_handler,$post_id,$setthumb='false') {
if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);
return $attach_id;
}
-function sc_check_thumb(){
+function vspi_check_thumb(){
$postid = $_REQUEST['postid'];
if(get_post_meta($postid,'_thumbnail_id')) return false;
return true;
}
if (!empty($_FILES)) {
- $image_id = insert_attachment('Filedata', $_REQUEST['postid'], sc_check_thumb());
+ $image_id = insert_attachment('Filedata', $_REQUEST['postid'], vspi_check_thumb());
}
echo $image_id;
@@ -1,28 +1,28 @@
-div.sc_image {
+div.vspi_image {
float:left;
border: 2px solid black;
position:relative;
margin: 10px;
padding: 2px;
background: #d4d2d2;
}
-div.sc_image a {
+div.vspi_image a {
position:absolute;
top:5px;
background: white;
}
-div.sc_image a.sc_delete {
+div.vspi_image a.vspi_delete {
right:5px;
}
-div.sc_image a.sc_thumb {
+div.vspi_image a.vspi_thumb {
left:5px;
}
-div.sc_thumb {
+div.vspi_thumb {
border: 5px solid #66cc00;
}
-div.sc_thumb .featured_marker {
+div.vspi_thumb .featured_marker {
background-image: url('featured.png');
background-repeat: no-repeat;
z-index: 999;
@@ -6,16 +6,16 @@
*/
jQuery(document).ready(function() {
- var post_id = jQuery('#sc_image_box').data('post_id');
- var sc_image = jQuery('#sc_image');
- if(sc_image.length > 0){
- sc_image.uploadify({
- 'uploader' : sc_image_globals.url + '/uploadify/uploadify.swf',
- 'script' : sc_image_globals.ajax_url,
- 'cancelImg' : sc_image_globals.url + '/uploadify/cancel.png',
+ var post_id = jQuery('#vspi_image_box').data('post_id');
+ var vspi_image = jQuery('#vspi_image');
+ if(vspi_image.length > 0){
+ vspi_image.uploadify({
+ 'uploader' : vspi_image_globals.url + '/uploadify/uploadify.swf',
+ 'script' : vspi_image_globals.ajax_url,
+ 'cancelImg' : vspi_image_globals.url + '/uploadify/cancel.png',
'auto' : true,
'multi' : true,
- 'scriptData' : {'post_id': post_id, 'action': 'sc_image','sc_user':sc_image_globals.user, 'sc_action': 'uploadify', '_wpnonce': sc_image_globals.sc_nonce },
+ 'scriptData' : {'post_id': post_id, 'action': 'vspi_image','vspi_user':vspi_image_globals.user, 'vspi_action': 'uploadify', '_wpnonce': vspi_image_globals.vspi_nonce },
'onError' : function (event, ID, fileObj, errorObj) {
alert(errorObj.type + ' Error: ' + errorObj.info);
//console.log(event,ID,fileObj,errorObj);
@@ -35,22 +35,22 @@ jQuery(document).ready(function() {
function scImageReload() {
- var holder = jQuery('#sc_image_box')
+ var holder = jQuery('#vspi_image_box')
if(holder.length > 0){
var post_id = holder.data('post_id');
- var getUrl = sc_image_globals.ajax_url + '?action=sc_image&sc_action=reload&_wpnonce=' +
- sc_image_globals.sc_nonce + '&id=' + post_id;
+ var getUrl = vspi_image_globals.ajax_url + '?action=vspi_image&vspi_action=reload&_wpnonce=' +
+ vspi_image_globals.vspi_nonce + '&id=' + post_id;
jQuery.getJSON(getUrl, '', function(response) {
holder.empty();
jQuery.each(response, function(a, b) {
- if (b) jQuery('#sc_image_tmpl').tmpl(b).appendTo('#sc_image_box');
+ if (b) jQuery('#vspi_image_tmpl').tmpl(b).appendTo('#vspi_image_box');
});
- jQuery('a.sc_delete').click(function() {
+ jQuery('a.vspi_delete').click(function() {
var parent = jQuery(this).parent();
var id = parent.data('id');
- jQuery.post(sc_image_globals.ajax_url,
- {action: 'sc_image', sc_action:'delete_image', _wpnonce: sc_image_globals.sc_nonce, 'attach_id': id},
+ jQuery.post(vspi_image_globals.ajax_url,
+ {action: 'vspi_image', vspi_action:'delete_image', _wpnonce: vspi_image_globals.vspi_nonce, 'attach_id': id},
function(response) {
console.log(response);
},
@@ -59,12 +59,12 @@ function scImageReload() {
parent.fadeOut("slow");
return false
});
- jQuery('a.sc_thumb').click(function() {
+ jQuery('a.vspi_thumb').click(function() {
var parent = jQuery(this).parent();
- var post_id = jQuery('#sc_image_box').data('post_id');
+ var post_id = jQuery('#vspi_image_box').data('post_id');
var id = parent.data('id');
- jQuery.post(sc_image_globals.ajax_url,
- {action:"sc_image", sc_action: "set_thumbnail", post_id: post_id, thumbnail_id: id, _wpnonce : sc_image_globals.sc_nonce},
+ jQuery.post(vspi_image_globals.ajax_url,
+ {action:"vspi_image", vspi_action: "set_thumbnail", post_id: post_id, thumbnail_id: id, _wpnonce : vspi_image_globals.vspi_nonce},
function(response) {
console.log(response);
scImageReload();
@@ -9,47 +9,47 @@
*/
-function sc_image_admin_init()
+function vspi_image_admin_init()
{
if (is_admin()) {
global $current_user;
get_currentuserinfo();
- define('SC_IMAGE_PLUGIN_PATH', plugins_url('Very-Simple-Post-Images'));
- add_meta_box("sc_image_metabox", "Images", "sc_image_metabox", "post", "normal", "high");
+ define('vspi_image_PLUGIN_PATH', plugins_url('Very-Simple-Post-Images'));
+ add_meta_box("vspi_image_metabox", "Images", "vspi_image_metabox", "post", "normal", "high");
wp_enqueue_script('swfobject');
- wp_enqueue_script('uploadify', SC_IMAGE_PLUGIN_PATH . '/uploadify/jquery.uploadify.v2.1.4.min.js', array('jquery'));
- wp_enqueue_script('sc_image_metabox', SC_IMAGE_PLUGIN_PATH . '/sc_image_metabox.js', array('jquery', 'uploadify'));
- wp_enqueue_style('sc_image_metabox', SC_IMAGE_PLUGIN_PATH . '/sc_image_metabox.css');
+ wp_enqueue_script('uploadify', vspi_image_PLUGIN_PATH . '/uploadify/jquery.uploadify.v2.1.4.min.js', array('jquery'));
+ wp_enqueue_script('vspi_image_metabox', vspi_image_PLUGIN_PATH . '/vspi_image_metabox.js', array('jquery', 'uploadify'));
+ wp_enqueue_style('vspi_image_metabox', vspi_image_PLUGIN_PATH . '/vspi_image_metabox.css');
wp_enqueue_script('jquery_tmpl', 'http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js', array('jquery'));
- wp_enqueue_style('uploadify', SC_IMAGE_PLUGIN_PATH . '/uploadify/uploadify.css');
- wp_localize_script('sc_image_metabox', 'sc_image_globals',
+ wp_enqueue_style('uploadify', vspi_image_PLUGIN_PATH . '/uploadify/uploadify.css');
+ wp_localize_script('vspi_image_metabox', 'vspi_image_globals',
array(
'ajax_url' => admin_url('admin-ajax.php'),
- 'sc_nonce' => wp_create_nonce('sc_nonce'),
- 'url' => SC_IMAGE_PLUGIN_PATH,
+ 'vspi_nonce' => wp_create_nonce('vspi_nonce'),
+ 'url' => vspi_image_PLUGIN_PATH,
'user' => $current_user->ID
)
);
}
}
-add_action("admin_init", "sc_image_admin_init");
+add_action("admin_init", "vspi_image_admin_init");
-function sc_image_metabox($callback)
+function vspi_image_metabox($callback)
{
global $post;
?>
-<input type="file" name="sc_image" id="sc_image"/>
-<div id="sc_image_box" data-post_id="<?php echo $post->ID; ?>">
+<input type="file" name="vspi_image" id="vspi_image"/>
+<div id="vspi_image_box" data-post_id="<?php echo $post->ID; ?>">
</div>
<div class="clearfix"></div>
-<script id="sc_image_tmpl" type="text/x-jquery-tmpl">
+<script id="vspi_image_tmpl" type="text/x-jquery-tmpl">
<div class="${class}" data-id="${id}">
<div class="featured_marker"></div>
- <a class="sc_delete" href="#">Delete</a>
- <a class="sc_thumb" href="#">Featured</a>
+ <a class="vspi_delete" href="#">Delete</a>
+ <a class="vspi_thumb" href="#">Featured</a>
<img src="${src}" width="${width}" height="${height}" alt="thumbnail" />
</div>
</script>
@@ -60,25 +60,25 @@ function sc_image_metabox($callback)
}
-add_action('wp_ajax_sc_image', 'sc_image_ajax');
-add_action('wp_ajax_nopriv_sc_image', 'sc_image_ajax');
+add_action('wp_ajax_vspi_image', 'vspi_image_ajax');
+add_action('wp_ajax_nopriv_vspi_image', 'vspi_image_ajax');
-function sc_image_ajax()
+function vspi_image_ajax()
{
- $sc_action = $_REQUEST['sc_action'];
+ $vspi_action = $_REQUEST['vspi_action'];
//Needed because flash doesn't show as logged in
- if ($sc_action === 'uploadify') {
- wp_set_current_user($_REQUEST['sc_user']);
+ if ($vspi_action === 'uploadify') {
+ wp_set_current_user($_REQUEST['vspi_user']);
}
- check_ajax_referer('sc_nonce', '_wpnonce');
+ check_ajax_referer('vspi_nonce', '_wpnonce');
- switch ($sc_action) {
+ switch ($vspi_action) {
case "reload":
$post_id = $_REQUEST['id'];
- $response = sc_get_thumbs($post_id);
+ $response = vspi_get_thumbs($post_id);
echo json_encode($response);
break;
@@ -131,15 +131,15 @@ function insert_attachment($file_handler, $post_id, $setthumb = 'false')
return $attach_id;
}
- function sc_check_thumb()
+ function vspi_check_thumb()
{
$postid = $_REQUEST['postid'];
if (get_post_meta($postid, '_thumbnail_id')) return false;
return true;
}
if (!empty($_FILES)) {
- $image_id = insert_attachment('Filedata', $_REQUEST['post_id'], sc_check_thumb());
+ $image_id = insert_attachment('Filedata', $_REQUEST['post_id'], vspi_check_thumb());
}
echo $image_id;
@@ -155,7 +155,7 @@ function sc_check_thumb()
* The featured image has the property "featured"
*/
-function sc_get_images($post_id)
+function vspi_get_images($post_id)
{
if (has_post_thumbnail($post_id)) $thumbnail_id = get_post_thumbnail_id($post_id);
$args = array(
@@ -168,30 +168,30 @@ function sc_get_images($post_id)
if (!isset($thumbnail_id)) $thumbnail_id = $attachs[0]->ID;
- $sc_images = array();
+ $vspi_images = array();
$i = 1;
foreach ($attachs as $att) {
$thumbnail = wp_get_attachment_image_src($att->ID, 'thumbnail');
$medium = wp_get_attachment_image_src($att->ID, 'medium');
$large = wp_get_attachment_image_src($att->ID, 'large');
$full = wp_get_attachment_image_src($att->ID, 'full');
- $sc = wp_get_attachment_image_src($att->ID, 'sc_thumb');
+ $sc = wp_get_attachment_image_src($att->ID, 'vspi_thumb');
- $sc_images[$i] = array(
+ $vspi_images[$i] = array(
'id' => $att->ID,
'large' => $large,
'medium' => $medium,
'thumbnail' => $thumbnail,
'full' => $full,
'sc' => $sc
);
- if ($thumbnail_id == $att->ID) $sc_images[$i]['thumb'] = true;
+ if ($thumbnail_id == $att->ID) $vspi_images[$i]['thumb'] = true;
$i++;
}
- return $sc_images;
+ return $vspi_images;
}
-function sc_get_thumbs($post_id)
+function vspi_get_thumbs($post_id)
{
if (has_post_thumbnail($post_id)) $thumbnail_id = get_post_thumbnail_id($post_id);
$args = array(
@@ -204,23 +204,23 @@ function sc_get_thumbs($post_id)
if (!isset($thumbnail_id)) $thumbnail_id = $attachs[0]->ID;
- $sc_images = array();
+ $vspi_images = array();
$i = 1;
foreach ($attachs as $att) {
$thumbnail = wp_get_attachment_image_src($att->ID, 'thumbnail');
- $sc_images[$i] = array(
+ $vspi_images[$i] = array(
'id' => $att->ID,
'src' => $thumbnail[0],
'width' => $thumbnail[1],
'height' => $thumbnail[2]
);
if ($thumbnail_id == $att->ID) {
- $sc_images[$i]['class'] = 'sc_image sc_thumb';
+ $vspi_images[$i]['class'] = 'vspi_image vspi_thumb';
} else {
- $sc_images[$i]['class'] = 'sc_image';
+ $vspi_images[$i]['class'] = 'vspi_image';
}
$i++;
}
- return $sc_images;
+ return $vspi_images;
}

0 comments on commit c077271

Please sign in to comment.