Plugin Directory

Changeset 434687


Ignore:
Timestamp:
09/07/2011 02:41:12 PM (15 years ago)
Author:
jaredh123
Message:

convert featured galleries dropdowns to containers with gallerys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • prophoto-beta-tester/trunk/pp-beta-tester.php

    r427074 r434687  
    3030        add_action( 'post_pp_loaded', array( &$this, 'fixSlideshowTerms' ) );
    3131        add_action( 'post_pp_loaded', array( &$this, 'deleteSuperHugeSprites' ) );
     32        add_action( 'post_pp_loaded', array( &$this, 'convertFeaturedGalleriesDropdown' ) );
    3233       
    3334        self::fixBadTransient();
     35    }
     36   
     37   
     38    function convertFeaturedGalleriesDropdown() {
     39        if ( ppOpt::test( 'featured_galleries_converted', 'true' ) || pp::site()->svn < 528 ) {
     40            return;
     41        }
     42       
     43        $featuredSlideshows = (array) json_decode( get_option( 'pp_featured_slideshows' ), true );
     44       
     45        $handles = array( 'primary_nav_menu', 'secondary_nav_menu', 'widget_menu_1', 'widget_menu_2', 'widget_menu_3' );
     46        foreach ( $handles as $handle ) {
     47            $structure = $initialStructure = json_decode( ppOpt::id( $handle . '_structure' ), true );
     48
     49            foreach ( (array) $structure as $menuID => $maybeChildren ) {
     50                $menuData = json_decode( ppOpt::menuData( $menuID ), true );
     51                if ( $menuData['type'] == 'internal' && $menuData['internalType'] == 'featured_slideshows' ) {
     52                    if ( !$featuredSlideshows ) {
     53                        if ( is_array( $maybeChildren ) ) {
     54                            foreach ( $mabyeChildren as $childMenuID ) {
     55                                $structure[$childMenuID] = $childMenuID;
     56                            }
     57                        }
     58                        unset( $structure[$menuID] );
     59                    } else {
     60                        $structure[$menuID] = array();
     61                        $menuData['type'] = 'container';
     62                        unset( $menuData['internalType'] );
     63                        ppOpt::update( $menuID, json_encode( $menuData ) );
     64
     65                        $nextID = ppMenuAdmin::highestID( $structure, 0, $handle ) + 1;
     66                        foreach ( $featuredSlideshows as $slideshowID => $slideshow ) {
     67                            $newMenuID = $handle . '_' . $nextID;
     68                            $structure[$menuID][$newMenuID] = $newMenuID;
     69                            $newMenuData = array(
     70                                'type' => 'internal',
     71                                'internalType' => 'gallery',
     72                                'galleryDisplay' => 'popup_slideshow',
     73                                'galleryID' => $slideshowID,
     74                                'text' => $slideshow['title'],
     75                            );
     76                            ppOpt::update( $newMenuID, json_encode( $newMenuData ) );
     77                            $nextID++;
     78                        }
     79                    }
     80                }
     81            }
     82
     83            if ( $structure != $initialStructure ) {
     84                ppOpt::update( $handle . '_structure', json_encode( $structure ) );
     85            }
     86        }
     87        delete_option( 'pp_featured_slideshows' );
     88        ppOpt::update( 'featured_galleries_converted', 'true' );
    3489    }
    3590   
Note: See TracChangeset for help on using the changeset viewer.