Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /*
- * 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.
- * $parsed are the current values being parsed.
- * $shortcode is the current shortcode passed to the parser.
- * $data is the current data available, this can be different types of objects depending on the parser.
- * $extra_data is a collaction of various data available within the messages system.
- */
- function ee_register_new_custom_messages_shortcodes_parser( $parsed, $shortcode, $data, $extra_data, EE_Shortcodes $lib ) {
- //Check for the datetime shortcodes library as that's one of the libraries we added a custom shortcode to above.
- //also check that $data is the expected object (in this case an EE_Datetime as its for the EE_Datetime_Shortcodes library)
- if ( $lib instanceof EE_Datetime_Shortcodes && $data instanceof EE_Datetime ) {
- //Then check if we are parsing one of our custom shortcodes above.
- if ( $shortcode == '[DATETIME_ID]' ) {
- //Do whatever you need to do here and return the value for that specific datetime.
- //In this example it simply returns the ID of the related EE_Datetime.
- return $data->ID();
- }
- }
- //If not within the correct section, or parsing the correct shortcode,
- //Return the currently parsed content.
- return $parsed;
- }
- 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