Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active August 21, 2018 07:47
Show Gist options
  • Select an option

  • Save alanef/2f617ef880f998972049fa6e26b663b7 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/2f617ef880f998972049fa6e26b663b7 to your computer and use it in GitHub Desktop.
shortcode to display hrml
<?php
/*
Plugin Name: My Custom Code
Plugin URI: https://fullworks.net/
Description: Custom code plugin
Version: 1.0
Author: Alan
Author URI: https://fullworks.net/
License: GPL2
*
* No warranty or liability accepted as per GPL
*/
/**
*
* Shortcode to add get html for a remote source
*
* Usage:
* [display_page url="http://example.com"]
*
* simple version no error checking etc
*/
function my_custom_shortcode( $atts ) {
$a = shortcode_atts( array(
'url' => '',
), $atts );
// decode url if it was encode
$a['url'] = urldecode($a['url']);
$html=file_get_contents($a['url']);
// can check for errors here
// add code if headers need to be stripped etc to manipulate the dom using $html
return $html;
}
add_shortcode( 'display_page', 'my_custom_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment