Plugin Directory

Changeset 1975581


Ignore:
Timestamp:
11/16/2018 03:42:33 PM (7 years ago)
Author:
WillBontrager
Message:

updating

Location:
local-syndication
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • local-syndication/tags/1.5/local_syndication.php

    r780409 r1975581  
    22/*
    33Plugin Name: Local Syndication
    4 Plugin URI: http://www.willmaster.com/software/WPplugins/
     4Plugin URI: https://www.willmaster.com/software/WPplugins/
    55Description: Insert content of any page/file/script at any URL on the Internet into any WordPress post or page.
    6 Version: 1.4
    7 Date: 30 September 2013
     6Version: 1.5
     7Date: 15 November 2018
    88Author: Will Bontrager Software, LLC <will@willmaster.com>
    9 Author URI: http://www.willmaster.com/contact.php
     9Author URI: https://www.willmaster.com/contact.php
    1010*/
    1111
    1212/*
    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)
    1414
    1515    This program is free software; you can redistribute it and/or modify
    1616    it under the terms of the GNU General Public License, version 2, as
    1717    published by the Free Software Foundation. A copy of the license is at
    18     http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18    https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1919
    2020    This program is distributed in the hope that it will be useful,
     
    2727Note: This plugin requires WordPress version 3.0 or higher.
    2828
    29 Tested up to WP version 3.6.1
     29Tested up to WP version 4.9.8
    3030
    3131Information about the Local Syndication plugin can be found here:
    32 http://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
     32https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
    3333
    3434Instructions for using the Local Syndication plugin can be found here:
    35 http://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
     35https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
    3636*/
    3737
     
    4242        $url = $atts['url'];
    4343        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; }
    4545        $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']) )
    5147        {
    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 .= '>';
    6155            $post_result = '</iframe>';
    6256            if( $js )
     
    7165        if( is_wp_error($response) )
    7266        {
    73            $error_string = $response->get_error_message();
     67            $error_string = $response->get_error_message();
    7468            return "WordPress error: $error_string";
    7569        }
    76         $response_content = $response['body'];
    7770        if( empty($response['body']) and empty($response['response']['code']) )
    7871        {
     
    8578                $response['response']['code'] . ' - ' . $response['response']['message'];
    8679        }
    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 )
    8886        {
    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; ';
    9297            if( isset($atts['style']) ) { $s .= $atts['style']; }
    9398            $s .= '"';
     
    101106            }
    102107            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             else
    125             {
    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             }
    139108        }
    140109        if( $js )
     
    146115    } # function will_bontrager_local_syndication()
    147116
    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 
    187117    function will_bontrager_local_syndication_js_line($s)
    188118    {
     
    191121        $s = str_replace('</',"<'+'/",$s);
    192122        $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);
    193125        $s = preg_replace('/\b(scr)(ipt)/i',"$1'+'$2",$s);
    194126        $s = preg_replace('/\b(ifr)(ame)/i',"$1'+'$2",$s);
    195127        return "document.writeln('$s');\n";
    196     }
     128    } # function will_bontrager_local_syndication_js_line()
    197129
    198130    function will_bontrager_local_syndication_js_block(&$s)
     
    202134        foreach( explode("\n",$s) as $line ) { $s2 .= will_bontrager_local_syndication_js_line($line); }
    203135        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()
    205143
    206144    add_shortcode('syndicate_local','will_bontrager_local_syndication');
  • local-syndication/tags/1.5/readme.txt

    r780410 r1975581  
    11=== Local Syndication ===
    22Contributors: WillBontrager
    3 Donate link: http://www.willmaster.com/plugindonate.php
    4 Tags: syndication, URL insert, file insert, insert web page, script output, rotate content, shortcode
     3Donate link: https://www.willmaster.com/software/WPplugins/go/plugindonate_lsplugin
     4Tags: insert external content, URL insert, file insert, insert web page, script output, rotate content, shortcode
    55Requires at least: 3.0
    6 Tested up to: 3.6.1
     6Tested up to: 4.9.8
    77Stable tag: trunk
     8Requires PHP: 5.2.4
     9License: GPLv2 or later
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
    811
    912Insert content of any page/file/script at any URL on the Internet into any WordPress post or page.
     
    1114== Description ==
    1215
    13 Insert the content of any page/file/script output on the Internet into any WordPress post or page.
     16Insert the content of any page/file/script output on the Internet into any WordPress post or page, or to a text widget.
    1417
    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.
     18Content can be published directly on the page or published in an iframe.
    1619
    1720Examples of use:
    1821
    19    * Frequently updated or time-sensitive content.
     22* Frequently updated or time-sensitive content.
    2023
    21    * Automated content generated from software.
     24* Automated content generated from software.
    2225
    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.
    2427
    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 one central file or script.
     28The 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.
    2629
    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
     30More information about the Local Syndication plugin can be found here: https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
    3031
    3132== Installation ==
    3233
    33 1. Download local-syndication-plugin.zip from http://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link)
     34Either 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:
    3435
    35 1. Decompress the file contents.
     361. Download local-syndication-plugin.zip from https://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link)
     37
     381. Decompress the downloaded file.
    3639
    37401. Upload the local-syndication folder to your WordPress plugins directory (/wp-content/plugins/).
     
    39421. Activate the Local Syndication plugin from the WordPress Dashboard.
    4043
    41 1. See instructions for using the plugin.
    42 
    4344== Instructions ==
    4445
    45 Note: This plugin requires WordPress version 3.0 or higher.
     46Note: This plugin requires WordPress version 3.0 or higher. (Yes, this plugin has been around that long, and still works a treat.)
    4647
    4748After uploading the Local Syndication plugin to the plugins directory and activating it:
    4849
    49 Insert the following shortcode on a line by itself at the point where you want the content to be inserted.
     50A. Insert the following shortcode on a line by itself at the point where you want the content to be inserted.
    5051
    51 [syndicate_local url="http://example.com/page.html"]
     52'[syndicate_local url="https://example.com/page.html"]'
    5253
    53 Replace http://example.come/page.html with the URL to the content.
     54B. Replace https://example.come/page.html with the URL to the content.
    5455
    55 That is the minimum you need to know to use the Local Syndication plugin.
     56That is the minimum you need to know to use the Local Syndication plugin. With that knowledge, you are good to go.
    5657
    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
     58Yet, there is more. There are advanced features and information about what to do when a page does not publish correctly.
    6059
    6160Advanced features include:
    6261
    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.
    6463
    6564* The ability to insert the content into an iframe instead of publishing it directly on the post or page.
    6665
    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
     70Implementation instructions for all features and other good-to-know information are found here: https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
    6871
    6972== Frequently Asked Questions ==
     
    7174= What if the web page I'm syndicating has relative URLs? =
    7275
    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.
     76Unless 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.
    7477
    75 = I see an advanced feature is to publish with JavaScript. Why would I want to publish content with JavaScript? =
     78If 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.
    7679
    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
     82One 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
     86Some ads are delivered with JavaScript. Some regular content, such as the Spam-free Form, are delivered with JavaScript.
     87
     88There 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
     90As 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.
    7891
    7992== Screenshots ==
    8093
    81 No screenshots available.
     94No screenshots are available because this plugin has no screens, just shortcodes. When you publish a shortcode, you are good to go.
    8295
    8396== Changelog ==
     97
     98= 1.5 =
     99Added JavaScript code import and publishing.
     100Added optional visible HTML tags for plain text publishing.
     101Removed relative-to-absolute URL conversion within imported content.
     102Tested to WordPress version 4.9.8.
    84103
    85104= 1.4 =
     
    97116== Upgrade Notice ==
    98117
     118= 1.5 =
     119Added 2 features and removed 1 (see Changelog). Tested to WordPress version 4.9.8
     120
     121= 1.4 =
     122Tested to WordPress version 3.6.1
     123
    99124= 1.3 =
    100125Changed to use wp_remote_get() instead of creating new instance of WP_Http
  • local-syndication/trunk/local_syndication.php

    r780409 r1975581  
    22/*
    33Plugin Name: Local Syndication
    4 Plugin URI: http://www.willmaster.com/software/WPplugins/
     4Plugin URI: https://www.willmaster.com/software/WPplugins/
    55Description: Insert content of any page/file/script at any URL on the Internet into any WordPress post or page.
    6 Version: 1.4
    7 Date: 30 September 2013
     6Version: 1.5
     7Date: 15 November 2018
    88Author: Will Bontrager Software, LLC <will@willmaster.com>
    9 Author URI: http://www.willmaster.com/contact.php
     9Author URI: https://www.willmaster.com/contact.php
    1010*/
    1111
    1212/*
    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)
    1414
    1515    This program is free software; you can redistribute it and/or modify
    1616    it under the terms of the GNU General Public License, version 2, as
    1717    published by the Free Software Foundation. A copy of the license is at
    18     http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18    https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1919
    2020    This program is distributed in the hope that it will be useful,
     
    2727Note: This plugin requires WordPress version 3.0 or higher.
    2828
    29 Tested up to WP version 3.6.1
     29Tested up to WP version 4.9.8
    3030
    3131Information about the Local Syndication plugin can be found here:
    32 http://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
     32https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
    3333
    3434Instructions for using the Local Syndication plugin can be found here:
    35 http://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
     35https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
    3636*/
    3737
     
    4242        $url = $atts['url'];
    4343        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; }
    4545        $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']) )
    5147        {
    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 .= '>';
    6155            $post_result = '</iframe>';
    6256            if( $js )
     
    7165        if( is_wp_error($response) )
    7266        {
    73            $error_string = $response->get_error_message();
     67            $error_string = $response->get_error_message();
    7468            return "WordPress error: $error_string";
    7569        }
    76         $response_content = $response['body'];
    7770        if( empty($response['body']) and empty($response['response']['code']) )
    7871        {
     
    8578                $response['response']['code'] . ' - ' . $response['response']['message'];
    8679        }
    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 )
    8886        {
    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; ';
    9297            if( isset($atts['style']) ) { $s .= $atts['style']; }
    9398            $s .= '"';
     
    101106            }
    102107            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             else
    125             {
    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             }
    139108        }
    140109        if( $js )
     
    146115    } # function will_bontrager_local_syndication()
    147116
    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 
    187117    function will_bontrager_local_syndication_js_line($s)
    188118    {
     
    191121        $s = str_replace('</',"<'+'/",$s);
    192122        $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);
    193125        $s = preg_replace('/\b(scr)(ipt)/i',"$1'+'$2",$s);
    194126        $s = preg_replace('/\b(ifr)(ame)/i',"$1'+'$2",$s);
    195127        return "document.writeln('$s');\n";
    196     }
     128    } # function will_bontrager_local_syndication_js_line()
    197129
    198130    function will_bontrager_local_syndication_js_block(&$s)
     
    202134        foreach( explode("\n",$s) as $line ) { $s2 .= will_bontrager_local_syndication_js_line($line); }
    203135        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()
    205143
    206144    add_shortcode('syndicate_local','will_bontrager_local_syndication');
  • local-syndication/trunk/readme.txt

    r780410 r1975581  
    11=== Local Syndication ===
    22Contributors: WillBontrager
    3 Donate link: http://www.willmaster.com/plugindonate.php
    4 Tags: syndication, URL insert, file insert, insert web page, script output, rotate content, shortcode
     3Donate link: https://www.willmaster.com/software/WPplugins/go/plugindonate_lsplugin
     4Tags: insert external content, URL insert, file insert, insert web page, script output, rotate content, shortcode
    55Requires at least: 3.0
    6 Tested up to: 3.6.1
     6Tested up to: 4.9.8
    77Stable tag: trunk
     8Requires PHP: 5.2.4
     9License: GPLv2 or later
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
    811
    912Insert content of any page/file/script at any URL on the Internet into any WordPress post or page.
     
    1114== Description ==
    1215
    13 Insert the content of any page/file/script output on the Internet into any WordPress post or page.
     16Insert the content of any page/file/script output on the Internet into any WordPress post or page, or to a text widget.
    1417
    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.
     18Content can be published directly on the page or published in an iframe.
    1619
    1720Examples of use:
    1821
    19    * Frequently updated or time-sensitive content.
     22* Frequently updated or time-sensitive content.
    2023
    21    * Automated content generated from software.
     24* Automated content generated from software.
    2225
    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.
    2427
    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 one central file or script.
     28The 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.
    2629
    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
     30More information about the Local Syndication plugin can be found here: https://www.willmaster.com/software/WPplugins/go/lshome_lsplugin
    3031
    3132== Installation ==
    3233
    33 1. Download local-syndication-plugin.zip from http://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link)
     34Either 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:
    3435
    35 1. Decompress the file contents.
     361. Download local-syndication-plugin.zip from https://www.willmaster.com/download/DownloadHandlerLink.php?file=local-syndication.zip (direct download link)
     37
     381. Decompress the downloaded file.
    3639
    37401. Upload the local-syndication folder to your WordPress plugins directory (/wp-content/plugins/).
     
    39421. Activate the Local Syndication plugin from the WordPress Dashboard.
    4043
    41 1. See instructions for using the plugin.
    42 
    4344== Instructions ==
    4445
    45 Note: This plugin requires WordPress version 3.0 or higher.
     46Note: This plugin requires WordPress version 3.0 or higher. (Yes, this plugin has been around that long, and still works a treat.)
    4647
    4748After uploading the Local Syndication plugin to the plugins directory and activating it:
    4849
    49 Insert the following shortcode on a line by itself at the point where you want the content to be inserted.
     50A. Insert the following shortcode on a line by itself at the point where you want the content to be inserted.
    5051
    51 [syndicate_local url="http://example.com/page.html"]
     52'[syndicate_local url="https://example.com/page.html"]'
    5253
    53 Replace http://example.come/page.html with the URL to the content.
     54B. Replace https://example.come/page.html with the URL to the content.
    5455
    55 That is the minimum you need to know to use the Local Syndication plugin.
     56That is the minimum you need to know to use the Local Syndication plugin. With that knowledge, you are good to go.
    5657
    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
     58Yet, there is more. There are advanced features and information about what to do when a page does not publish correctly.
    6059
    6160Advanced features include:
    6261
    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.
    6463
    6564* The ability to insert the content into an iframe instead of publishing it directly on the post or page.
    6665
    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
     70Implementation instructions for all features and other good-to-know information are found here: https://www.willmaster.com/software/WPplugins/go/lsinstructions_lsplugin
    6871
    6972== Frequently Asked Questions ==
     
    7174= What if the web page I'm syndicating has relative URLs? =
    7275
    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.
     76Unless 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.
    7477
    75 = I see an advanced feature is to publish with JavaScript. Why would I want to publish content with JavaScript? =
     78If 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.
    7679
    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
     82One 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
     86Some ads are delivered with JavaScript. Some regular content, such as the Spam-free Form, are delivered with JavaScript.
     87
     88There 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
     90As 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.
    7891
    7992== Screenshots ==
    8093
    81 No screenshots available.
     94No screenshots are available because this plugin has no screens, just shortcodes. When you publish a shortcode, you are good to go.
    8295
    8396== Changelog ==
     97
     98= 1.5 =
     99Added JavaScript code import and publishing.
     100Added optional visible HTML tags for plain text publishing.
     101Removed relative-to-absolute URL conversion within imported content.
     102Tested to WordPress version 4.9.8.
    84103
    85104= 1.4 =
     
    97116== Upgrade Notice ==
    98117
     118= 1.5 =
     119Added 2 features and removed 1 (see Changelog). Tested to WordPress version 4.9.8
     120
     121= 1.4 =
     122Tested to WordPress version 3.6.1
     123
    99124= 1.3 =
    100125Changed to use wp_remote_get() instead of creating new instance of WP_Http
Note: See TracChangeset for help on using the changeset viewer.