DisplayCarouselOptions($_POST['selCarouselId']); echo $mcObject->DisplayCarouselSlides($_POST['selCarouselId']); } else if(isset($_POST['saveCarousel'])){ echo $mcObject->DisplayCarouselOptions($_POST['carouselid']); $Id=$_POST['Id']; $carouselId=$_POST['carouselid']; $BackgroundImageURL=$_POST['BackgroundImageURL']; $BackgroundImageLink=$_POST['BackgroundImageLink']; $BackgroudImageAltText=$_POST['BackgroundImageAltText']; $TitleText=$_POST['TitleText']; for($i=0;$iDeleteCarouselSlides($Id[$i]); else $mcObject->UpdateCarouselSlides($Id[$i], $carouselId, trim($BackgroundImageURL[$i]), trim($BackgroundImageLink[$i]), trim($BackgroudImageAltText[$i]), trim($TitleText[$i])); } else { //add if(trim($BackgroundImageURL[$i])!="") $mcObject->InsertCarouselSlides($carouselId, trim($BackgroundImageURL[$i]),trim($BackgroundImageLink[$i]),trim($BackgroudImageAltText[$i]), trim($TitleText[$i])); } } echo "

Carousel slides updated

"; } else echo $mcObject->DisplayCarouselOptions(); } /** * Admin section WPNewCarousel settings page * @version 1.0 */ function AdminWPNewCarouselsOption(){ $data ='
' .'

WPNewCarousels

'; echo $data; echo '
'; $mcObject=new ManageCarousel(); if(isset($_POST['txtAddCarousel'])){ $error=$mcObject->CheckError(trim($_POST['txtCarouselName']),trim($_POST['txtCarouselWidth']),trim($_POST['txtCarouselHeight'])); if($error=="false"){ $error="New Carousel Added"; $mcObject->InsertNewCarousel(trim($_POST['txtCarouselName']),trim($_POST['txtCarouselWidth']),trim($_POST['txtCarouselHeight'])); echo $mcObject->DisplayInsert($error); } else echo $mcObject->DisplayInsert($error,trim($_POST['txtCarouselName']),trim($_POST['txtCarouselWidth']),trim($_POST['txtCarouselHeight'])); echo $mcObject->DisplayDeleteCarousel(); echo $mcObject->DisplayActivateCarousel(); } else if(isset($_POST['delCarousel'])){ $mcObject->DeleteCarousel($_POST['carouselid'], $_POST['type']); echo $mcObject->DisplayInsert(); echo $mcObject->DisplayDeleteCarousel(); echo $mcObject->DisplayActivateCarousel(); } else if(isset($_POST['actCarousel'])){ $mcObject->ActivateCarousel($_POST['carouselid']); echo $mcObject->DisplayInsert(); echo $mcObject->DisplayDeleteCarousel(); echo $mcObject->DisplayActivateCarousel(); } else{ echo $mcObject->DisplayInsert(); echo $mcObject->DisplayDeleteCarousel(); echo $mcObject->DisplayActivateCarousel(); } echo 'How to use :

1. The WPNewCarousel short code added to your default wordpress editor.

2. Use Shortcode : [wpnewcarousel name="CAROUSEL_NAME" height="" width="" effect="" startslide="" animationspeed="" imagepausetime="" shownav="" hoverpause=""] to display carousel in your web page

3. Only name is the required parameter and others are optional when using carousel short code.

4. height and width are the optional if you pass these parameter in short code then these parameters will replace the default.

5. startslide is the starting slide number, default value is 0.

6. animationspeed is the speed of carousel animation, default value is 500 [ where 1000 = 1sec ].

7. imagepause is the time between image change, default value is 3000.

8. shownav is the flag to show navigation control with carousel or not, default value is true.

9. hoverpause is the flag to stop carousel on mouse over, default value is true.

10. effect is the type of effect you want to show between image transition.
The effect parameter can be any of the following:
sliceDown, sliceDownLeft, sliceUp, sliceUpLeft, sliceUpDown, sliceUpDownLeft, fold, fade, random, slideInRight, slideInLeft, boxRandom, boxRain, boxRainReverse, boxRainGrow, boxRainGrowReverse




Developed by : Arjun Jain

For any help please click here

'; } register_activation_hook( __FILE__, "WPNewCarousels_activate" ); function WPNewCarousels_activate(){ global $wpdb; global $wpnewcarousel_db_version; $mcObject=new ManageCarousel(); if (function_exists('is_multisite') && is_multisite()) { // check if it is a network activation - if so, run the activation function for each blog id if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) { $old_blog = $wpdb->blogid; // Get all blog ids $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs")); foreach ($blogids as $blog_id) { switch_to_blog($blog_id); $mcObject->CreateTable(); } switch_to_blog($old_blog); return; } else $mcObject->CreateTable(); } else $mcObject->CreateTable(); add_option("wpnewcarousel_db_version", $wpnewcarousel_db_version); } /** * WPNewCarousel Shortcode * Accept three parametes Name, Width, Height . Width and Height will replace default width and height set for carousel * Height and Width are the optional Parameters * name is required parameter * Startslide is the starting slide number, default value is 0 * Animationspeed is the speed of carousel animation, default value is 500 [ where 1000 = 1sec ] * imagepause is the time between image change, default value is 3000 * shownav is the flag to show navigation with carousel or not, default value is true * hoverpause is the flag to stop carousel on mouse over, default value is true * effect is the type of effect in image transition * [wpnewcarousel name="YOUR_CAROUSEL_NAME" height="" width="" effect="" startslide="" animationspeed="" imagepausetime="" shownav="" hoverpause=""] * * @since: 1.1 * */ add_shortcode('wpnewcarousel','WPNewCarouselShortcode'); function WPNewCarouselShortcode($atts){ extract(shortcode_atts(array( 'name' => '', 'width' =>'', 'height' =>'', 'startslide'=>'1', 'animationspeed'=>'500', 'imagepausetime'=>'3000', 'shownav'=>'true', 'effect'=>'random', 'hoverpause'=>'true' ),$atts)); if(trim($name)=="") return "Please specify the carousel name"; global $wpdb; $mc=new ManageCarousel(); $carouseltable=$mc->GetCarouselTable(); $carouseldatatable=$mc->GetCarouselDataTable(); $carouselresults=$wpdb->get_results("SELECT Id,CarouselWidth,CarouselHeight FROM $carouseltable WHERE CarouselName='$name' and IsActive=1",ARRAY_A); $carouselid=""; $carouselwidth=""; $carouselheight=""; if(sizeof($carouselresults)==0) return "Please specify the correct carousel name"; foreach ($carouselresults as $cr){ $carouselid=$cr['Id']; $carouselheight=$cr['CarouselHeight']; $carouselwidth=$cr['CarouselWidth']; } /** * Assign default value if value is empty * */ if(trim($height)=="") $height=$carouselheight; if(trim($width)=="") $width=$carouselwidth; if(trim($startslide)=="") $startslide=0; if(trim($animationspeed)=="") $animationspeed=500; if(trim($imagepausetime)=="") $imagepausetime=3000; if(trim($shownav)=="") $shownav=true; if(trim($hoverpause)=="") $hoverpause=true; if(trim($effect)=="") $effect="random"; $results=$wpdb->get_results("SELECT * FROM $carouseldatatable WHERE CarouselId=$carouselid",ARRAY_A); echo ''; $output .= "
"; foreach ($results as $result){ if($result['BackgroundImageLink']!="") $output .=""; $output .="".$result["; if($result['BackgroundImageLink']!="") $output .=''; } $output .= "
"; return $output; } /** * Include js and css * */ add_action( 'wp_head', 'wpnewcarousel_script' ); add_action( 'wp_print_styles', 'WPNewCarousel_Styles' ); function WPNewCarousel_Script() { wp_register_script( 'wpnewcarousel_script_jquery', '/wp-includes/js/jquery/jquery.js' , false, '1.0.0' ); wp_register_script( 'wpnewcarousel_script', path_join( WP_PLUGIN_URL, basename( dirname( __FILE__ ) ) . '/js/jquery.nivo.slider.js' ) , false, '1.0.0' ); wp_print_scripts( array( 'wpnewcarousel_script_jquery', 'wpnewcarousel_script' ) ); } function WPNewCarousel_Styles() { wp_enqueue_style( 'WPNewCarousel_Styles', path_join( WP_PLUGIN_URL, basename( dirname( __FILE__ ) ) . '/css/carousel.css' )); } /** * Add carousel button to editor * */ add_action('init', 'editor_button'); function editor_button() { if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { if ( in_array(basename($_SERVER['PHP_SELF']), array('post-new.php', 'page-new.php', 'post.php', 'page.php') ) ) { add_action('admin_head','add_simple_buttons'); } } } function add_simple_buttons(){ wp_print_scripts( 'quicktags' ); $output = ""; echo $output; } ?>