Advertisement
Guest User

NextGen Random CSS Background

a guest
Aug 7th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. class nggHeaderBG extends WP_Widget {
  2. function widget( $args, $instance ) {
  3. global $wpdb;
  4. $items = $instance['items'];
  5. $exclude = $instance['exclude'];
  6. $list = $instance['list'];
  7. $exclude_list = "AND t.gid IN ($list)";
  8. $imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list ORDER by rand() limit {$items}");
  9. foreach($imageList as $image) {
  10. // get the URL constructor
  11. $image = new nggImage($image);
  12.  
  13. /* CVC just create the URL */
  14. $out .= '' . home_url() . '/' . 'index.php?callback=image&pid='.$image->pid.'&width='.$instance['width'].'&height='.$instance['height'];
  15. echo $out;
  16. }
  17. }
  18.  
  19. }// end widget class
  20.  
  21. function nggDisplayRandomCSSBG($number, $width, $height, $exclude, $list, $show) {
  22. $options = array( 'title' => false,
  23. 'items' => 1,
  24. 'show' => 'original',
  25. 'type' => 'random',
  26. 'width' => $width,
  27. 'height' => $height,
  28. 'exclude' => 'allow',
  29. 'list' => $list,
  30. 'webslice' => false );
  31. $ngg_widget = new nggHeaderBG();
  32. $ngg_widget->widget($args = array( 'widget_id'=> 'sidebar_1' ), $options);
  33. }
  34.  
  35. // Writes the style property for the header image background
  36. function cvcRandomBG(){
  37. if (in_array( 'nextgen-gallery/nggallery.php', apply_filters( 'active_plugins', get_option('active_plugins')))) {
  38. if (is_page_template('landing-page-wvup.php')){
  39. if (is_page( 'alumni-giving' )){
  40. ?> style='background-image: url(<?php nggDisplayRandomCSSBG(1,880,350,allow,3);?>);'<?
  41. }else{
  42. ?> style='background-image: url(<?php nggDisplayRandomCSSBG(1,880,350,allow,2);?>);'<?
  43. }
  44. }else{
  45. ?> style='background-image: url(<?php nggDisplayRandomCSSBG(1,880,250,allow,1);?>);'<?
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement