SlideDeck 2 After get hook-in for overriding deck options


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.