Posted By

Jamie on 08/09/12


Tagged

functions hook override slidedeck


Versions (?)

SlideDeck 2 After get hook-in for overriding deck options


 / Published in: PHP
 

Allows a SlideDeck user to hook into the options array after the SlideDeck is fetched from the database. Options can then be modified based on the request.

  1. /**
  2.  * Hook-in to slidedeck_after_get filter
  3.  *
  4.  * @return array
  5.  */
  6. function slidedeck_after_get( $slidedeck ) {
  7. global $SlideDeckPlugin;
  8. /**
  9.   * For this example, I'm fetching the twitter handle from the request URI, but
  10.   * you could get this from custom post meta or another source too.
  11.   */
  12. $twitter_handle = (string) $_REQUEST['twitter_handle'];
  13.  
  14. // Specify the SlideDeck ID or this will affect all decks!
  15. if( $slidedeck['id'] == 48842 ) {
  16. $slidedeck['options']['twitter_username'] = $twitter_handle;
  17. }
  18.  
  19. return $slidedeck;
  20. }
  21. add_action( 'slidedeck_after_get', 'slidedeck_after_get' );

Report this snippet  

You need to login to post a comment.