houzz.php 845 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /*
  3. * Houzz Embed
  4. *
  5. * Examples:
  6. * Post content:
  7. * - [houzz=http://www.houzz.com/pro/james-crisp]
  8. * - http://www.houzz.com/pro/james-crisp
  9. * Blog sidebar: [houzz=http://www.houzz.com/profile/alon w=200 h=300]
  10. */
  11. // Register oEmbed provider
  12. wp_oembed_add_provider( '#https?://(.+?\.)?houzz\.(com|co\.uk|com\.au|de|fr|ru|jp|it|es|dk|se)/.*#i', 'https://www.houzz.com/oembed', true );
  13. // Create Shortcode
  14. function jetpack_houzz_shortcode( $atts, $content=null ) {
  15. $url = substr( $atts[0], 1 );
  16. $args = array();
  17. if ( isset( $atts['w'] ) && is_numeric( $atts['w'] ) ) {
  18. $args['width'] = $atts['w'];
  19. }
  20. if ( isset( $atts['h'] ) && is_numeric( $atts['h'] ) ) {
  21. $args['height'] = $atts['h'];
  22. }
  23. $oembed = _wp_oembed_get_object();
  24. return $oembed->get_html( $url, $args );
  25. }
  26. add_shortcode( 'houzz', 'jetpack_houzz_shortcode' );