WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Dec 11 2011

How to Move a Group from DisplayBuddy Rotate Images to DisplayBuddy Slideshow

Here are a set of functions I recently wrote to move a group from DisplayBuddy Rotate Images to DisplayBuddy Slideshow. The user wanted to add some controls to the rotating images, which meant they needed to use Slideshow instead. So these functions make it extremely easy/fast for the user/developer.

[php]
/**
* Returns Slideshow defaults
*
* @return array defaults
*/
function get_slideshow_defaults() {
return array (
'title' => '',
'images' => array(),
'layout' => 'default' ,
'type' => 'slider' ,
'enable_css_files' => 'true' ,
'image_width' => 500 ,
'image_height' => 300 ,
'thumb_image_width' => 85 ,
'thumb_image_height' => 65 ,
'slider-align' => 'center' ,
'slider-effect' => 'random' ,
'slider-slices' => 15 ,
'slider-animSpeed' => 466 ,
'slider-pauseTime' => 233 ,
'slider-directionNav' => 'true' ,
'slider-directionNavHide' => 'true' ,
'slider-controlNav' => 'true' ,
'slider-controlNavThumbs' => 'false' ,
'slider-keyboardNav' => 'false' ,
'slider-pauseOnHover' => 'true' ,
'slider-captionOpacity' => 0.8 ,
'slider-shadows' => 'true' ,
'cycle-align' => 'center' ,
'cycle-fx' => 'fade' ,
'cycle-timeout' => 4000 ,
'cycle-continuous' => 0,
'cycle-speed' => 1000 ,
'cycle-speedIn' => 0 ,
'cycle-speedOut' => 0 ,
'cycle-sync' => 1 ,
'cycle-random' => 0 ,
'cycle-pause' => 1 ,
'cycle-autostop' => 0 ,
'cycle-autostopCount' => 3 ,
'cycle-delay' => 0,
'cycle-randomizeEffects' => 1,
'cycle-pb_pager' => 0,
);
}
/**
* Moves a group from Rotating Images to Slideshow
* and creates a backup of both for optional reset.
*
* @param string Group name
*/
function wps_move_rigroup_to_slideshow( $name ) {
$pluginbuddy_slideshow = get_option ( 'pluginbuddy_slideshow' );
$rotating_images = get_option ( 'ithemes-rotating-images' );
$count = 0;
$slideshow_defaults = get_slideshow_defaults();
foreach ( $rotating_images['groups'] as $group ) {
$count++;
if ( $group['name'] == $name ) {
$slideshow_defaults['title'] = $group['name'];
foreach ( $group['options']['image_ids'] as $image ) {
$slideshow_defaults['images'][] = $image['attachment_id'];
}
$pluginbuddy_slideshow['groups'][] = $slideshow_defaults;
unset($rotating_images['groups'][$count]);
break;
}
}

//Create backup for reset (future use)
update_option ( 'pluginbuddy_slideshow-backup' , $pluginbuddy_slideshow );
update_option ( 'ithemes-rotating-images-backup' , $rotating_images );

//Save
update_option ( 'pluginbuddy_slideshow' , $pluginbuddy_slideshow );
update_option ( 'ithemes-rotating-images' , $rotating_images );
}

/**
* Moves all groups from Rotating Images to Slideshow
* with an option to exclude some groups
* and creates a backup of both for optional reset.
*
* @param array Group names (string)
*/
function wps_move_rigroups_to_slideshow( $excludes ) {
$rotating_images = get_option ( 'ithemes-rotating-images' );
$count = 0;
$slideshow_defaults = get_slideshow_defaults();
foreach ( $rotating_images['groups'] as $group ) {
$count++;
foreach ( $excludes as $exclude ) {
if ( $group['name'] == $exclude )
continue 2;
}
$slideshow_defaults['title'] = $group['name'];
foreach ( $group['options']['image_ids'] as $image ) {
$slideshow_defaults['images'][] = $image['attachment_id'];
}
$pluginbuddy_slideshow['groups'][] = $slideshow_defaults;
unset($rotating_images['groups'][$count]);
}

//Create backup for reset (future use)
update_option ( 'pluginbuddy_slideshow-backup' , $pluginbuddy_slideshow );
update_option ( 'ithemes-rotating-images-backup' , $rotating_images );

//Save
update_option ( 'pluginbuddy_slideshow' , $pluginbuddy_slideshow );
update_option ( 'ithemes-rotating-images' , $rotating_images );
}
[/php]

Written by Travis Smith · Categorized: Plugins

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in