Changeset 1975581
- Timestamp:
- 11/16/2018 03:42:33 PM (7 years ago)
- Location:
- local-syndication
- Files:
-
- 2 edited
- 3 copied
-
tags/1.5 (copied) (copied from local-syndication/trunk)
-
tags/1.5/local_syndication.php (copied) (copied from local-syndication/trunk/local_syndication.php) (9 diffs)
-
tags/1.5/readme.txt (copied) (copied from local-syndication/trunk/readme.txt) (5 diffs)
-
trunk/local_syndication.php (modified) (9 diffs)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
local-syndication/tags/1.5/local_syndication.php
r780409 r1975581 2 2 /* 3 3 Plugin Name: Local Syndication 4 Plugin URI: http ://www.willmaster.com/software/WPplugins/4 Plugin URI: https://www.willmaster.com/software/WPplugins/ 5 5 Description: Insert content of any page/file/script at any URL on the Internet into any WordPress post or page. 6 Version: 1. 47 Date: 30 September 20136 Version: 1.5 7 Date: 15 November 2018 8 8 Author: Will Bontrager Software, LLC <will@willmaster.com> 9 Author URI: http ://www.willmaster.com/contact.php9 Author URI: https://www.willmaster.com/contact.php 10 10 */ 11 11 12 12 /* 13 Copyright 2011, 2013 Will Bontrager Software LLC (email: will@willmaster.com)13 Copyright 2011, 2013, 2018 Will Bontrager Software LLC (email: will@willmaster.com) 14 14 15 15 This program is free software; you can redistribute it and/or modify 16 16 it under the terms of the GNU General Public License, version 2, as 17 17 published by the Free Software Foundation. A copy of the license is at 18 http ://www.gnu.org/licenses/old-licenses/gpl-2.0.html18 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 19 19 20 20 This program is distributed in the hope that it will be useful, … … 27 27 Note: This plugin requires WordPress version 3.0 or higher. 28 28 29 Tested up to WP version 3.6.129 Tested up to WP version 4.9.8 30 30 31 31 Information about the Local Syndication plugin can be found here: 32 http ://www.willmaster.com/software/WPplugins/go/lshome_lsplugin32 https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 33 33 34 34 Instructions for using the Local Syndication plugin can be found here: 35 http ://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin35 https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 36 36 */ 37 37 … … 42 42 $url = $atts['url']; 43 43 if( strpos($url,':') === false and strpos($url,'/') !== 0 ) { $url = "/$url"; } 44 if( strpos($url,'/') === 0 ) { $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; }44 if( strpos($url,'/') === 0 and strpos($url,'//') === false ) { $url = will_bontrager_local_syndication_make_httphttps($url) . '://' . $_SERVER['HTTP_HOST'] . $url; } 45 45 $pre_result = $post_result = ''; 46 $js = empty($atts['js']) ? false : true; 47 if( $js ) { $pre_result = '<script type="text/javascript">'; } 48 $iframe = empty($atts['iframe']) ? false : true; 49 $plain = empty($atts['plain']) ? false : true; 50 if( $iframe ) 46 if( ! empty($atts['iframe']) ) 51 47 { 52 unset($atts['url']); 53 unset($atts['iframe']); 54 if( $js ) { unset($atts['js']); } 55 if( $plain ) { unset($atts['plain']); } 56 if( isset($atts['src']) ) { unset($atts['src']); } 57 if( isset($atts['wrap_long_lines']) ) { unset($atts['wrap_long_lines']); } 58 $s .= "<iframe src='$url' "; 59 foreach( $atts as $k => $v ) { $s .= "$k='$v' "; } 60 $s .= '">'; 48 foreach(array('url','iframe','js','script','plain','src','wrap_long_lines') as $key) 49 { 50 if(isset($atts[$key])) { unset($atts[$key]); } 51 } 52 $s = "<iframe src='$url'"; 53 foreach( $atts as $k => $v ) { $s .= " $k='$v'"; } 54 $s .= '>'; 61 55 $post_result = '</iframe>'; 62 56 if( $js ) … … 71 65 if( is_wp_error($response) ) 72 66 { 73 $error_string = $response->get_error_message();67 $error_string = $response->get_error_message(); 74 68 return "WordPress error: $error_string"; 75 69 } 76 $response_content = $response['body'];77 70 if( empty($response['body']) and empty($response['response']['code']) ) 78 71 { … … 85 78 $response['response']['code'] . ' - ' . $response['response']['message']; 86 79 } 87 if( $plain ) 80 $response_content = $response['body']; 81 $js = empty($atts['js']) ? false : true; 82 $isjs = empty($atts['script']) ? false : true; 83 if( $js and $isjs ) { $js = false; } 84 if( $js ) { $pre_result = '<script type="text/javascript">'; } 85 elseif( $isjs ) 88 86 { 89 if( empty($atts['wrap_long_lines']) ) { $wrapdef = 'pre'; } 90 else { $wrapdef = 'pre-wrap'; } 91 $s = "<div style=\"white-space:$wrapdef;"; 87 if( ! preg_match('/^[^<]*<script/is',$response_content) ) 88 { 89 $pre_result = '<script type="text/javascript">'; 90 $post_result = '</script>'; 91 } 92 } 93 if( ! empty($atts['plain']) ) 94 { 95 if( ! empty($atts['showtags']) ) { $response_content = htmlspecialchars($response_content); } 96 $s = empty($atts['wrap_long_lines']) ? '<pre style="white-space:pre; ' : '<div style="white-space:pre-wrap; '; 92 97 if( isset($atts['style']) ) { $s .= $atts['style']; } 93 98 $s .= '"'; … … 101 106 } 102 107 else { $pre_result .= $s; } 103 } # if( $plain )104 elseif( ! $iframe )105 {106 $baseurl = $url;107 $baseurl = preg_replace('/[\#\?].*$/','',$baseurl);108 if( preg_match('/\.\w+$/',$baseurl) )109 {110 $ta = explode('/',$baseurl);111 array_pop($ta);112 $baseurl = implode('/',$ta);113 }114 if( preg_match('/<base\s[^>]*?href=([^>\s]+)/',$response_content,$matches) )115 {116 $ret = preg_replace('!["\']/$!','',$matches[1]);117 $ret = preg_replace('/^["\']*/','',$ret);118 $ret = preg_replace('/["\']*$/','',$ret);119 if( ! empty($ret) ) { $baseurl = $ret; }120 }121 $basepieces = array();122 $http = $domain = '';123 if( ! preg_match('!^\w+://!',$baseurl) ) { $baseurl = ''; }124 else125 {126 $baseurl = preg_replace('!/*$!','',$baseurl);127 $i = strpos($baseurl,'://') + 3;128 $http = substr( $baseurl, 0, $i );129 $basepieces = explode( '/', substr($baseurl,$i) );130 $domain = array_shift($basepieces);131 }132 if( ! empty($baseurl) )133 {134 preg_match_all('/(href=)(["\']?)([^"\'>\s]+)/i',$response_content,$matches);135 will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, $response_content);136 preg_match_all('/(src=)(["\']?)([^"\'>\s]+)/i',$response_content,$matches);137 will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, $response_content);138 }139 108 } 140 109 if( $js ) … … 146 115 } # function will_bontrager_local_syndication() 147 116 148 function will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, &$response_content)149 {150 $done = array();151 $count = count($matches[0]);152 for( $indice=0; $indice<$count; $indice++ )153 {154 $relurl = $matches[3][$indice];155 if( empty($relurl) ) { continue; }156 if( isset($done[$relurl]) ) { continue; }157 if( strpos($relurl,':') ) { continue; }158 if( strpos($relurl,'#') === 0 ) { continue; }159 $done[$relurl] = 1;160 $absurl = will_bontrager_local_syndication_make_absolute($basepieces, $http, $domain, $relurl);161 $matchurl = quotemeta($matches[0][$indice]);162 $matchurl = str_replace('/',"\\".'/',$matchurl);163 $response_content = preg_replace("/$matchurl/i", $matches[1][$indice].$matches[2][$indice].$absurl, $response_content);164 }165 } # function will_bontrager_local_syndication_normalize_urls()166 167 function will_bontrager_local_syndication_make_absolute($basepieces, $http, $domain, $url)168 {169 $bpieces = $basepieces;170 if( strpos($url,'://') ) { return $url; }171 if( strpos($url,'/') === 0 ) { return "$http$domain$url"; }172 $pieces = $tackle = explode('/',$url);173 foreach( $tackle as $piece )174 {175 if( $piece == '.' ) { array_shift($pieces); }176 elseif( $piece == '..' )177 {178 array_shift($pieces);179 if( is_array($bpieces) and count($bpieces) ) { array_pop($bpieces); }180 }181 else { break; }182 }183 $basepiece = count($bpieces) ? implode('/',$bpieces) . '/' : '';184 return "$http$domain/$basepiece" . implode('/',$pieces);185 }186 187 117 function will_bontrager_local_syndication_js_line($s) 188 118 { … … 191 121 $s = str_replace('</',"<'+'/",$s); 192 122 $s = str_replace('/>',"/'+'>",$s); 123 $s = preg_replace('/\b(f)(orm)/i',"$1'+'$2",$s); 124 $s = preg_replace('/\b(in)(put)/i',"$1'+'$2",$s); 193 125 $s = preg_replace('/\b(scr)(ipt)/i',"$1'+'$2",$s); 194 126 $s = preg_replace('/\b(ifr)(ame)/i',"$1'+'$2",$s); 195 127 return "document.writeln('$s');\n"; 196 } 128 } # function will_bontrager_local_syndication_js_line() 197 129 198 130 function will_bontrager_local_syndication_js_block(&$s) … … 202 134 foreach( explode("\n",$s) as $line ) { $s2 .= will_bontrager_local_syndication_js_line($line); } 203 135 return $s2; 204 } 136 } # function will_bontrager_local_syndication_js_block() 137 138 function will_bontrager_local_syndication_make_httphttps($s) 139 { 140 if( isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS']=='on' or $_SERVER['HTTPS']=='1') ) { return 'https'; } 141 return 'http'; 142 } # function will_bontrager_local_syndication_make_httphttps() 205 143 206 144 add_shortcode('syndicate_local','will_bontrager_local_syndication'); -
local-syndication/tags/1.5/readme.txt
r780410 r1975581 1 1 === Local Syndication === 2 2 Contributors: WillBontrager 3 Donate link: http ://www.willmaster.com/plugindonate.php4 Tags: syndication, URL insert, file insert, insert web page, script output, rotate content, shortcode3 Donate link: https://www.willmaster.com/software/WPplugins/go/plugindonate_lsplugin 4 Tags: insert external content, URL insert, file insert, insert web page, script output, rotate content, shortcode 5 5 Requires at least: 3.0 6 Tested up to: 3.6.16 Tested up to: 4.9.8 7 7 Stable tag: trunk 8 Requires PHP: 5.2.4 9 License: GPLv2 or later 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 8 11 9 12 Insert content of any page/file/script at any URL on the Internet into any WordPress post or page. … … 11 14 == Description == 12 15 13 Insert the content of any page/file/script output on the Internet into any WordPress post or page .16 Insert the content of any page/file/script output on the Internet into any WordPress post or page, or to a text widget. 14 17 15 Content is published directly onto the post or page or, optionally, published in an iframe. Content can be converted into JavaScript in an attempt to hide it from spiders and robots.18 Content can be published directly on the page or published in an iframe. 16 19 17 20 Examples of use: 18 21 19 * Frequently updated or time-sensitive content.22 * Frequently updated or time-sensitive content. 20 23 21 * Automated content generated from software.24 * Automated content generated from software. 22 25 23 The plugin is especially useful when you have more than one WordPress installation, perhaps on several domains.26 * Content provided by other websites or remote services. 24 27 25 One file/script can provide content for each WordPress installation. Contact information, special sales, political notices, daily quotes, any content can be provided by that onecentral file or script.28 The plugin is especially useful when you have more than one WordPress installation, perhaps on several domains. Common content across each installation can be pulled in with the URL of one central file - contact information, special sales, political notices, daily quotes, any content can be provided by a central file or script. 26 29 27 Advanced features include the ability to insert the content as JavaScript (to discourage spiders/robots from reading the content) and the ability to insert plain text content with optional CSS formatting. 28 29 More information about the Local Syndication plugin can be found here: http://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 30 More information about the Local Syndication plugin can be found here: https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 30 31 31 32 == Installation == 32 33 33 1. Download local-syndication-plugin.zip from http://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link) 34 Either install the plugin from WordPress.org via your WordPress dashboard and activate it or, optionally, follow these steps to obtain the plugin from the author's website: 34 35 35 1. Decompress the file contents. 36 1. Download local-syndication-plugin.zip from https://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link) 37 38 1. Decompress the downloaded file. 36 39 37 40 1. Upload the local-syndication folder to your WordPress plugins directory (/wp-content/plugins/). … … 39 42 1. Activate the Local Syndication plugin from the WordPress Dashboard. 40 43 41 1. See instructions for using the plugin.42 43 44 == Instructions == 44 45 45 Note: This plugin requires WordPress version 3.0 or higher. 46 Note: This plugin requires WordPress version 3.0 or higher. (Yes, this plugin has been around that long, and still works a treat.) 46 47 47 48 After uploading the Local Syndication plugin to the plugins directory and activating it: 48 49 49 Insert the following shortcode on a line by itself at the point where you want the content to be inserted.50 A. Insert the following shortcode on a line by itself at the point where you want the content to be inserted. 50 51 51 [syndicate_local url="http://example.com/page.html"] 52 '[syndicate_local url="https://example.com/page.html"]' 52 53 53 Replace http://example.come/page.html with the URL to the content.54 B. Replace https://example.come/page.html with the URL to the content. 54 55 55 That is the minimum you need to know to use the Local Syndication plugin. 56 That is the minimum you need to know to use the Local Syndication plugin. With that knowledge, you are good to go. 56 57 57 But there is more to know, including what to do when a page does not publish correctly. 58 59 Instructions for using the Local Syndication plugin can be found here: http://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 58 Yet, there is more. There are advanced features and information about what to do when a page does not publish correctly. 60 59 61 60 Advanced features include: 62 61 63 * The ability to insert the content as JavaScript (to discourage spiders/robots from reading the content).62 * The ability to insert plain text content with optional CSS formatting, with or without making HTML tags visible. 64 63 65 64 * The ability to insert the content into an iframe instead of publishing it directly on the post or page. 66 65 67 * The ability to insert plain text content with optional CSS formatting. 66 * The ability to convert the content into JavaScript before publishing (to discourage spiders/robots from reading the content). 67 68 * The ability to import JavaScript directly to be published as live code. 69 70 Implementation instructions for all features and other good-to-know information are found here: https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 68 71 69 72 == Frequently Asked Questions == … … 71 74 = What if the web page I'm syndicating has relative URLs? = 72 75 73 The plugin does its best to convert relative URLs into absolute http://... URLs so images will display and links will work and relevant CSS and JavaScript files will be imported.76 Unless the content is published in an iframe, relative URLs from an external site will not work. Neither will relative URLs published from your own site when the relative directory is different than where your WordPress page is displayed. 74 77 75 = I see an advanced feature is to publish with JavaScript. Why would I want to publish content with JavaScript? = 78 If links and external content (like images) need to work, the URLs of the href and src attributes need to be absolute https:// or https:// URLs - unless, as noted, the content is published in an iframe where relative URLs are relative to the URL of the content rather than the URL of the WordPress page. 76 79 77 To discourage robots and spiders from reading the syndicated content. It may be desirable to keep ads out of search engine indexes, for example, and perhaps also off-topic content so SE's do not come to wrong conclusions regarding a page's topic. 80 = Why would I want to convert content into JavaScript before publishing it? = 81 82 One reason for using this optional feature would be to discourage robots and spiders from reading the content. It may be desirable to keep ads out of search engine indexes, for example, and perhaps also off-topic content so SE's do not come to wrong conclusions regarding a page's topic. 83 84 = What would importing live JavaScript do for me? = 85 86 Some ads are delivered with JavaScript. Some regular content, such as the Spam-free Form, are delivered with JavaScript. 87 88 There are developers who have determined that syndicated or remotely delivered content provided as JavaScript is desirable because it makes their content accessible by more websites - as compared to requiring specific types of web pages, like PHP (for example). 89 90 As with all content pulled in from remote websites, not only JavaScript code and not only into WordPress, there must be trust that the provider won't send nefarious content or code to your page. Otherwise, it may be prudent to just not do it. 78 91 79 92 == Screenshots == 80 93 81 No screenshots a vailable.94 No screenshots are available because this plugin has no screens, just shortcodes. When you publish a shortcode, you are good to go. 82 95 83 96 == Changelog == 97 98 = 1.5 = 99 Added JavaScript code import and publishing. 100 Added optional visible HTML tags for plain text publishing. 101 Removed relative-to-absolute URL conversion within imported content. 102 Tested to WordPress version 4.9.8. 84 103 85 104 = 1.4 = … … 97 116 == Upgrade Notice == 98 117 118 = 1.5 = 119 Added 2 features and removed 1 (see Changelog). Tested to WordPress version 4.9.8 120 121 = 1.4 = 122 Tested to WordPress version 3.6.1 123 99 124 = 1.3 = 100 125 Changed to use wp_remote_get() instead of creating new instance of WP_Http -
local-syndication/trunk/local_syndication.php
r780409 r1975581 2 2 /* 3 3 Plugin Name: Local Syndication 4 Plugin URI: http ://www.willmaster.com/software/WPplugins/4 Plugin URI: https://www.willmaster.com/software/WPplugins/ 5 5 Description: Insert content of any page/file/script at any URL on the Internet into any WordPress post or page. 6 Version: 1. 47 Date: 30 September 20136 Version: 1.5 7 Date: 15 November 2018 8 8 Author: Will Bontrager Software, LLC <will@willmaster.com> 9 Author URI: http ://www.willmaster.com/contact.php9 Author URI: https://www.willmaster.com/contact.php 10 10 */ 11 11 12 12 /* 13 Copyright 2011, 2013 Will Bontrager Software LLC (email: will@willmaster.com)13 Copyright 2011, 2013, 2018 Will Bontrager Software LLC (email: will@willmaster.com) 14 14 15 15 This program is free software; you can redistribute it and/or modify 16 16 it under the terms of the GNU General Public License, version 2, as 17 17 published by the Free Software Foundation. A copy of the license is at 18 http ://www.gnu.org/licenses/old-licenses/gpl-2.0.html18 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html 19 19 20 20 This program is distributed in the hope that it will be useful, … … 27 27 Note: This plugin requires WordPress version 3.0 or higher. 28 28 29 Tested up to WP version 3.6.129 Tested up to WP version 4.9.8 30 30 31 31 Information about the Local Syndication plugin can be found here: 32 http ://www.willmaster.com/software/WPplugins/go/lshome_lsplugin32 https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 33 33 34 34 Instructions for using the Local Syndication plugin can be found here: 35 http ://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin35 https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 36 36 */ 37 37 … … 42 42 $url = $atts['url']; 43 43 if( strpos($url,':') === false and strpos($url,'/') !== 0 ) { $url = "/$url"; } 44 if( strpos($url,'/') === 0 ) { $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; }44 if( strpos($url,'/') === 0 and strpos($url,'//') === false ) { $url = will_bontrager_local_syndication_make_httphttps($url) . '://' . $_SERVER['HTTP_HOST'] . $url; } 45 45 $pre_result = $post_result = ''; 46 $js = empty($atts['js']) ? false : true; 47 if( $js ) { $pre_result = '<script type="text/javascript">'; } 48 $iframe = empty($atts['iframe']) ? false : true; 49 $plain = empty($atts['plain']) ? false : true; 50 if( $iframe ) 46 if( ! empty($atts['iframe']) ) 51 47 { 52 unset($atts['url']); 53 unset($atts['iframe']); 54 if( $js ) { unset($atts['js']); } 55 if( $plain ) { unset($atts['plain']); } 56 if( isset($atts['src']) ) { unset($atts['src']); } 57 if( isset($atts['wrap_long_lines']) ) { unset($atts['wrap_long_lines']); } 58 $s .= "<iframe src='$url' "; 59 foreach( $atts as $k => $v ) { $s .= "$k='$v' "; } 60 $s .= '">'; 48 foreach(array('url','iframe','js','script','plain','src','wrap_long_lines') as $key) 49 { 50 if(isset($atts[$key])) { unset($atts[$key]); } 51 } 52 $s = "<iframe src='$url'"; 53 foreach( $atts as $k => $v ) { $s .= " $k='$v'"; } 54 $s .= '>'; 61 55 $post_result = '</iframe>'; 62 56 if( $js ) … … 71 65 if( is_wp_error($response) ) 72 66 { 73 $error_string = $response->get_error_message();67 $error_string = $response->get_error_message(); 74 68 return "WordPress error: $error_string"; 75 69 } 76 $response_content = $response['body'];77 70 if( empty($response['body']) and empty($response['response']['code']) ) 78 71 { … … 85 78 $response['response']['code'] . ' - ' . $response['response']['message']; 86 79 } 87 if( $plain ) 80 $response_content = $response['body']; 81 $js = empty($atts['js']) ? false : true; 82 $isjs = empty($atts['script']) ? false : true; 83 if( $js and $isjs ) { $js = false; } 84 if( $js ) { $pre_result = '<script type="text/javascript">'; } 85 elseif( $isjs ) 88 86 { 89 if( empty($atts['wrap_long_lines']) ) { $wrapdef = 'pre'; } 90 else { $wrapdef = 'pre-wrap'; } 91 $s = "<div style=\"white-space:$wrapdef;"; 87 if( ! preg_match('/^[^<]*<script/is',$response_content) ) 88 { 89 $pre_result = '<script type="text/javascript">'; 90 $post_result = '</script>'; 91 } 92 } 93 if( ! empty($atts['plain']) ) 94 { 95 if( ! empty($atts['showtags']) ) { $response_content = htmlspecialchars($response_content); } 96 $s = empty($atts['wrap_long_lines']) ? '<pre style="white-space:pre; ' : '<div style="white-space:pre-wrap; '; 92 97 if( isset($atts['style']) ) { $s .= $atts['style']; } 93 98 $s .= '"'; … … 101 106 } 102 107 else { $pre_result .= $s; } 103 } # if( $plain )104 elseif( ! $iframe )105 {106 $baseurl = $url;107 $baseurl = preg_replace('/[\#\?].*$/','',$baseurl);108 if( preg_match('/\.\w+$/',$baseurl) )109 {110 $ta = explode('/',$baseurl);111 array_pop($ta);112 $baseurl = implode('/',$ta);113 }114 if( preg_match('/<base\s[^>]*?href=([^>\s]+)/',$response_content,$matches) )115 {116 $ret = preg_replace('!["\']/$!','',$matches[1]);117 $ret = preg_replace('/^["\']*/','',$ret);118 $ret = preg_replace('/["\']*$/','',$ret);119 if( ! empty($ret) ) { $baseurl = $ret; }120 }121 $basepieces = array();122 $http = $domain = '';123 if( ! preg_match('!^\w+://!',$baseurl) ) { $baseurl = ''; }124 else125 {126 $baseurl = preg_replace('!/*$!','',$baseurl);127 $i = strpos($baseurl,'://') + 3;128 $http = substr( $baseurl, 0, $i );129 $basepieces = explode( '/', substr($baseurl,$i) );130 $domain = array_shift($basepieces);131 }132 if( ! empty($baseurl) )133 {134 preg_match_all('/(href=)(["\']?)([^"\'>\s]+)/i',$response_content,$matches);135 will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, $response_content);136 preg_match_all('/(src=)(["\']?)([^"\'>\s]+)/i',$response_content,$matches);137 will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, $response_content);138 }139 108 } 140 109 if( $js ) … … 146 115 } # function will_bontrager_local_syndication() 147 116 148 function will_bontrager_local_syndication_normalize_urls($basepieces, $http, $domain, $matches, &$response_content)149 {150 $done = array();151 $count = count($matches[0]);152 for( $indice=0; $indice<$count; $indice++ )153 {154 $relurl = $matches[3][$indice];155 if( empty($relurl) ) { continue; }156 if( isset($done[$relurl]) ) { continue; }157 if( strpos($relurl,':') ) { continue; }158 if( strpos($relurl,'#') === 0 ) { continue; }159 $done[$relurl] = 1;160 $absurl = will_bontrager_local_syndication_make_absolute($basepieces, $http, $domain, $relurl);161 $matchurl = quotemeta($matches[0][$indice]);162 $matchurl = str_replace('/',"\\".'/',$matchurl);163 $response_content = preg_replace("/$matchurl/i", $matches[1][$indice].$matches[2][$indice].$absurl, $response_content);164 }165 } # function will_bontrager_local_syndication_normalize_urls()166 167 function will_bontrager_local_syndication_make_absolute($basepieces, $http, $domain, $url)168 {169 $bpieces = $basepieces;170 if( strpos($url,'://') ) { return $url; }171 if( strpos($url,'/') === 0 ) { return "$http$domain$url"; }172 $pieces = $tackle = explode('/',$url);173 foreach( $tackle as $piece )174 {175 if( $piece == '.' ) { array_shift($pieces); }176 elseif( $piece == '..' )177 {178 array_shift($pieces);179 if( is_array($bpieces) and count($bpieces) ) { array_pop($bpieces); }180 }181 else { break; }182 }183 $basepiece = count($bpieces) ? implode('/',$bpieces) . '/' : '';184 return "$http$domain/$basepiece" . implode('/',$pieces);185 }186 187 117 function will_bontrager_local_syndication_js_line($s) 188 118 { … … 191 121 $s = str_replace('</',"<'+'/",$s); 192 122 $s = str_replace('/>',"/'+'>",$s); 123 $s = preg_replace('/\b(f)(orm)/i',"$1'+'$2",$s); 124 $s = preg_replace('/\b(in)(put)/i',"$1'+'$2",$s); 193 125 $s = preg_replace('/\b(scr)(ipt)/i',"$1'+'$2",$s); 194 126 $s = preg_replace('/\b(ifr)(ame)/i',"$1'+'$2",$s); 195 127 return "document.writeln('$s');\n"; 196 } 128 } # function will_bontrager_local_syndication_js_line() 197 129 198 130 function will_bontrager_local_syndication_js_block(&$s) … … 202 134 foreach( explode("\n",$s) as $line ) { $s2 .= will_bontrager_local_syndication_js_line($line); } 203 135 return $s2; 204 } 136 } # function will_bontrager_local_syndication_js_block() 137 138 function will_bontrager_local_syndication_make_httphttps($s) 139 { 140 if( isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS']=='on' or $_SERVER['HTTPS']=='1') ) { return 'https'; } 141 return 'http'; 142 } # function will_bontrager_local_syndication_make_httphttps() 205 143 206 144 add_shortcode('syndicate_local','will_bontrager_local_syndication'); -
local-syndication/trunk/readme.txt
r780410 r1975581 1 1 === Local Syndication === 2 2 Contributors: WillBontrager 3 Donate link: http ://www.willmaster.com/plugindonate.php4 Tags: syndication, URL insert, file insert, insert web page, script output, rotate content, shortcode3 Donate link: https://www.willmaster.com/software/WPplugins/go/plugindonate_lsplugin 4 Tags: insert external content, URL insert, file insert, insert web page, script output, rotate content, shortcode 5 5 Requires at least: 3.0 6 Tested up to: 3.6.16 Tested up to: 4.9.8 7 7 Stable tag: trunk 8 Requires PHP: 5.2.4 9 License: GPLv2 or later 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 8 11 9 12 Insert content of any page/file/script at any URL on the Internet into any WordPress post or page. … … 11 14 == Description == 12 15 13 Insert the content of any page/file/script output on the Internet into any WordPress post or page .16 Insert the content of any page/file/script output on the Internet into any WordPress post or page, or to a text widget. 14 17 15 Content is published directly onto the post or page or, optionally, published in an iframe. Content can be converted into JavaScript in an attempt to hide it from spiders and robots.18 Content can be published directly on the page or published in an iframe. 16 19 17 20 Examples of use: 18 21 19 * Frequently updated or time-sensitive content.22 * Frequently updated or time-sensitive content. 20 23 21 * Automated content generated from software.24 * Automated content generated from software. 22 25 23 The plugin is especially useful when you have more than one WordPress installation, perhaps on several domains.26 * Content provided by other websites or remote services. 24 27 25 One file/script can provide content for each WordPress installation. Contact information, special sales, political notices, daily quotes, any content can be provided by that onecentral file or script.28 The plugin is especially useful when you have more than one WordPress installation, perhaps on several domains. Common content across each installation can be pulled in with the URL of one central file - contact information, special sales, political notices, daily quotes, any content can be provided by a central file or script. 26 29 27 Advanced features include the ability to insert the content as JavaScript (to discourage spiders/robots from reading the content) and the ability to insert plain text content with optional CSS formatting. 28 29 More information about the Local Syndication plugin can be found here: http://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 30 More information about the Local Syndication plugin can be found here: https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin 30 31 31 32 == Installation == 32 33 33 1. Download local-syndication-plugin.zip from http://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link) 34 Either install the plugin from WordPress.org via your WordPress dashboard and activate it or, optionally, follow these steps to obtain the plugin from the author's website: 34 35 35 1. Decompress the file contents. 36 1. Download local-syndication-plugin.zip from https://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link) 37 38 1. Decompress the downloaded file. 36 39 37 40 1. Upload the local-syndication folder to your WordPress plugins directory (/wp-content/plugins/). … … 39 42 1. Activate the Local Syndication plugin from the WordPress Dashboard. 40 43 41 1. See instructions for using the plugin.42 43 44 == Instructions == 44 45 45 Note: This plugin requires WordPress version 3.0 or higher. 46 Note: This plugin requires WordPress version 3.0 or higher. (Yes, this plugin has been around that long, and still works a treat.) 46 47 47 48 After uploading the Local Syndication plugin to the plugins directory and activating it: 48 49 49 Insert the following shortcode on a line by itself at the point where you want the content to be inserted.50 A. Insert the following shortcode on a line by itself at the point where you want the content to be inserted. 50 51 51 [syndicate_local url="http://example.com/page.html"] 52 '[syndicate_local url="https://example.com/page.html"]' 52 53 53 Replace http://example.come/page.html with the URL to the content.54 B. Replace https://example.come/page.html with the URL to the content. 54 55 55 That is the minimum you need to know to use the Local Syndication plugin. 56 That is the minimum you need to know to use the Local Syndication plugin. With that knowledge, you are good to go. 56 57 57 But there is more to know, including what to do when a page does not publish correctly. 58 59 Instructions for using the Local Syndication plugin can be found here: http://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 58 Yet, there is more. There are advanced features and information about what to do when a page does not publish correctly. 60 59 61 60 Advanced features include: 62 61 63 * The ability to insert the content as JavaScript (to discourage spiders/robots from reading the content).62 * The ability to insert plain text content with optional CSS formatting, with or without making HTML tags visible. 64 63 65 64 * The ability to insert the content into an iframe instead of publishing it directly on the post or page. 66 65 67 * The ability to insert plain text content with optional CSS formatting. 66 * The ability to convert the content into JavaScript before publishing (to discourage spiders/robots from reading the content). 67 68 * The ability to import JavaScript directly to be published as live code. 69 70 Implementation instructions for all features and other good-to-know information are found here: https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin 68 71 69 72 == Frequently Asked Questions == … … 71 74 = What if the web page I'm syndicating has relative URLs? = 72 75 73 The plugin does its best to convert relative URLs into absolute http://... URLs so images will display and links will work and relevant CSS and JavaScript files will be imported.76 Unless the content is published in an iframe, relative URLs from an external site will not work. Neither will relative URLs published from your own site when the relative directory is different than where your WordPress page is displayed. 74 77 75 = I see an advanced feature is to publish with JavaScript. Why would I want to publish content with JavaScript? = 78 If links and external content (like images) need to work, the URLs of the href and src attributes need to be absolute https:// or https:// URLs - unless, as noted, the content is published in an iframe where relative URLs are relative to the URL of the content rather than the URL of the WordPress page. 76 79 77 To discourage robots and spiders from reading the syndicated content. It may be desirable to keep ads out of search engine indexes, for example, and perhaps also off-topic content so SE's do not come to wrong conclusions regarding a page's topic. 80 = Why would I want to convert content into JavaScript before publishing it? = 81 82 One reason for using this optional feature would be to discourage robots and spiders from reading the content. It may be desirable to keep ads out of search engine indexes, for example, and perhaps also off-topic content so SE's do not come to wrong conclusions regarding a page's topic. 83 84 = What would importing live JavaScript do for me? = 85 86 Some ads are delivered with JavaScript. Some regular content, such as the Spam-free Form, are delivered with JavaScript. 87 88 There are developers who have determined that syndicated or remotely delivered content provided as JavaScript is desirable because it makes their content accessible by more websites - as compared to requiring specific types of web pages, like PHP (for example). 89 90 As with all content pulled in from remote websites, not only JavaScript code and not only into WordPress, there must be trust that the provider won't send nefarious content or code to your page. Otherwise, it may be prudent to just not do it. 78 91 79 92 == Screenshots == 80 93 81 No screenshots a vailable.94 No screenshots are available because this plugin has no screens, just shortcodes. When you publish a shortcode, you are good to go. 82 95 83 96 == Changelog == 97 98 = 1.5 = 99 Added JavaScript code import and publishing. 100 Added optional visible HTML tags for plain text publishing. 101 Removed relative-to-absolute URL conversion within imported content. 102 Tested to WordPress version 4.9.8. 84 103 85 104 = 1.4 = … … 97 116 == Upgrade Notice == 98 117 118 = 1.5 = 119 Added 2 features and removed 1 (see Changelog). Tested to WordPress version 4.9.8 120 121 = 1.4 = 122 Tested to WordPress version 3.6.1 123 99 124 = 1.3 = 100 125 Changed to use wp_remote_get() instead of creating new instance of WP_Http
Note: See TracChangeset
for help on using the changeset viewer.