listo.php 696 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. ** Retrieve list data from the Listo plugin.
  4. ** Listo http://wordpress.org/plugins/listo/
  5. **/
  6. add_filter( 'wpcf7_form_tag_data_option', 'wpcf7_listo', 10, 3 );
  7. function wpcf7_listo( $data, $options, $args ) {
  8. if ( ! function_exists( 'listo' ) ) {
  9. return $data;
  10. }
  11. $args = wp_parse_args( $args, array() );
  12. $contact_form = wpcf7_get_current_contact_form();
  13. $args['locale'] = $contact_form->locale();
  14. foreach ( (array) $options as $option ) {
  15. $option = explode( '.', $option );
  16. $type = $option[0];
  17. $args['group'] = isset( $option[1] ) ? $option[1] : null;
  18. if ( $list = listo( $type, $args ) ) {
  19. $data = array_merge( (array) $data, $list );
  20. }
  21. }
  22. return $data;
  23. }