Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?
  2. /*
  3. * This filter allows you to hook in to the shortcode parser, check for a shortcode added above and return a value for it using the data passed to the parser.
  4. * $parsed are the current values being parsed.
  5. * $shortcode is the current shortcode passed to the parser.
  6. * $data is the current data available, this can be different types of objects depending on the parser.
  7. * $extra_data is a collaction of various data available within the messages system.
  8. */
  9. function ee_register_new_custom_messages_shortcodes_parser( $parsed, $shortcode, $data, $extra_data, EE_Shortcodes $lib ) {
  10.  
  11. //Check for the datetime shortcodes library as that's one of the libraries we added a custom shortcode to above.
  12. //also check that $data is the expected object (in this case an EE_Datetime as its for the EE_Datetime_Shortcodes library)
  13. if ( $lib instanceof EE_Datetime_Shortcodes && $data instanceof EE_Datetime ) {
  14. //Then check if we are parsing one of our custom shortcodes above.
  15. if ( $shortcode == '[DATETIME_ID]' ) {
  16.  
  17. //Do whatever you need to do here and return the value for that specific datetime.
  18. //In this example it simply returns the ID of the related EE_Datetime.
  19. return $data->ID();
  20. }
  21. }
  22.  
  23. //If not within the correct section, or parsing the correct shortcode,
  24. //Return the currently parsed content.
  25. return $parsed;
  26. }
  27. add_filter( 'FHEE__EE_Shortcodes__parser_after', 'ee_register_new_custom_messages_shortcodes_parser', 10, 5 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement