Media-> Aboozé Slideshow. To display the slideshow, add: <?php if (function_exists('ab_show')){ ab_show(); } ?> in your template.
Version: 3.0
Author: Aboobacker Omar
Author URI: http://www.aboobacker.com/
This plugin inherits the GPL license from it's parent system, WordPress., customized from WP-Cycle. Thanks Nathan Rice.
*/
$wp_cycle_defaults = apply_filters('wp_cycle_defaults', array(
'rotate' => 1,
'effect' => 'fade', // fade, wipe, scrollUp, scrollDown, scrollLeft, scrollRight, cover, shuffle
'delay' => 3,
'duration' => 1,
'img_width' => 900,
'img_height' => 450,
'div' => 'slideShowItems'
));
// pull the settings from the db
$wp_cycle_settings = get_option('wp_cycle_settings');
$wp_cycle_images = get_option('wp_cycle_images');
// fallback
$wp_cycle_settings = wp_parse_args($wp_cycle_settings, $wp_cycle_defaults);
// this function registers our settings in the db
add_action('admin_init', 'wp_cycle_register_settings1');
function wp_cycle_register_settings1() {
register_setting('wp_cycle_images', 'wp_cycle_images', 'wp_cycle_images_validate1');
register_setting('wp_cycle_settings', 'wp_cycle_settings', 'wp_cycle_settings_validate1');
}
// this function adds the settings page to the Appearance tab
add_action('admin_menu', 'add_wp_cycle_menu1');
function add_wp_cycle_menu1() {
add_submenu_page('upload.php', 'Aboozé Slideshow Settings', 'Aboozé Slideshow', 'upload_files', 'abooze-slideshow', 'wp_cycle_admin_page1');
}
// add "Settings" link to plugin page
add_filter('plugin_action_links_' . plugin_basename(__FILE__) , 'wp_cycle_plugin_action_links1');
function wp_cycle_plugin_action_links1($links) {
$wp_cycle_settings_link = sprintf( '%s', admin_url( 'upload.php?page=abooze-slideshow' ), __('Settings') );
array_unshift($links, $wp_cycle_settings_link);
return $links;
}
function wp_cycle_admin_page1() {
echo '
';
// handle image upload, if necessary
if($_REQUEST['action'] == 'wp_handle_upload')
wp_cycle_handle_upload1();
// delete an image, if necessary
if(isset($_REQUEST['delete']))
wp_cycle_delete_upload1($_REQUEST['delete']);
// the image management form
wp_cycle_images_admin1();
// the settings management form - abooze
wp_cycle_settings_admin1();
echo '
';
}
function wp_cycle_handle_upload1() {
global $wp_cycle_settings, $wp_cycle_images;
// upload the image
$upload = wp_handle_upload($_FILES['wp_cycle'], 0);
// extract the $upload array
extract($upload);
// the URL of the directory the file was loaded in
$upload_dir_url = str_replace(basename($file), '', $url);
// get the image dimensions
list($width, $height) = getimagesize($file);
// if the uploaded file is NOT an image
if(strpos($type, 'image') === FALSE) {
unlink($file); // delete the file
echo 'Sorry, but the file you uploaded does not seem to be a valid image. Please try again.
';
return;
}
/*
// if the image doesn't meet the minimum width/height requirements ...
if($width < $wp_cycle_settings['img_width'] || $height < $wp_cycle_settings['img_height']) {
unlink($file); // delete the image
echo 'Sorry, but this image does not meet the minimum height/width requirements. Please upload another image
';
return;
}
*/
// if the image is larger than the width/height requirements, then scale it down.
if($width > $wp_cycle_settings['img_width'] || $height > $wp_cycle_settings['img_height']) {
// resize the image
$resized = image_resize($file, $wp_cycle_settings['img_width'], $wp_cycle_settings['img_height'], true, 'resized');
$resized_url = $upload_dir_url . basename($resized);
// delete the original
unlink($file);
$file = $resized;
$url = $resized_url;
}
// make the thumbnail
$thumb_height = round((100 * $wp_cycle_settings['img_height']) / $wp_cycle_settings['img_width']);
if(isset($upload['file'])) {
$thumbnail = image_resize($file, 100, $thumb_height, true, 'thumb');
$thumbnail_url = $upload_dir_url . basename($thumbnail);
}
// use the timestamp as the array key and id
$time = date('YmdHis');
// add the image data to the array
$wp_cycle_images[$time] = array(
'id' => $time,
'file' => $file,
'file_url' => $url,
'thumbnail' => $thumbnail,
'thumbnail_url' => $thumbnail_url,
'image_links_to' => ''
);
// add the image information to the database
$wp_cycle_images['update'] = 'Added';
update_option('wp_cycle_images', $wp_cycle_images);
}
// this function deletes the image,
// and removes the image data from the db
function wp_cycle_delete_upload1($id) {
global $wp_cycle_images;
// if the ID passed to this function is invalid,
// halt the process, and don't try to delete.
if(!isset($wp_cycle_images[$id])) return;
// delete the image and thumbnail
unlink($wp_cycle_images[$id]['file']);
unlink($wp_cycle_images[$id]['thumbnail']);
// indicate that the image was deleted
$wp_cycle_images['update'] = 'Deleted';
// remove the image data from the db
unset($wp_cycle_images[$id]);
update_option('wp_cycle_images', $wp_cycle_images);
}
function wp_cycle_settings_update_check1() {
global $wp_cycle_settings;
if(isset($wp_cycle_settings['update'])) {
echo 'Aboozé Slideshow Settings '.$wp_cycle_settings['update'].'
';
unset($wp_cycle_settings['update']);
update_option('wp_cycle_settings', $wp_cycle_settings);
}
}
// this function checks to see if we just added a new image
// if so, it displays the "updated" message.
function wp_cycle_images_update_check1() {
global $wp_cycle_images;
if($wp_cycle_images['update'] == 'Added' || $wp_cycle_images['update'] == 'Deleted' || $wp_cycle_images['update'] == 'Updated') {
echo 'Image(s) '.$wp_cycle_images['update'].' Successfully
';
unset($wp_cycle_images['update']);
update_option('wp_cycle_images', $wp_cycle_images);
}
}
function wp_cycle_images_admin1() { ?>
| Image |
Image Links To |
Actions |
| Image |
Image Links To |
Actions |
$value) {
if($key != 'update') {
$input[$key]['file_url'] = clean_url($value['file_url']);
$input[$key]['thumbnail_url'] = clean_url($value['thumbnail_url']);
if($value['image_links_to'])
$input[$key]['image_links_to'] = clean_url($value['image_links_to']);
}
}
return $input;
}
function ab_show($args = array(), $content = null) {
global $wp_cycle_settings, $wp_cycle_images;
// possible future use
$args = wp_parse_args($args, $wp_cycle_settings);
$newline = "\n"; // line break
echo ''.$newline;
}
// create the shortcode [wp_cycle]
add_shortcode('ab_show', 'wp_cycle_shortcode1');
function wp_cycle_shortcode1($atts) {
// Temp solution, output buffer the echo function.
ob_start();
ab_show();
$output = ob_get_clean();
return $output;
}
add_action( 'wp_head', 'wp_cycle_style1' );
function wp_cycle_style1() {
global $wp_cycle_settings;
?>