Changeset 2259310
- Timestamp:
- 03/11/2020 05:56:07 PM (6 years ago)
- Location:
- http-syndication
- Files:
-
- 2 deleted
- 2 edited
-
assets/screenshot-1.png (deleted)
-
assets/screenshot-2.png (deleted)
-
trunk/http_syndication.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
http-syndication/trunk/http_syndication.php
r2259080 r2259310 2 2 /** 3 3 * Plugin Name: http-syndication 4 * Plugin URI: http://sparticipatives.gforge.inria.fr/wp-plugins/5 4 * Description: Allows to offer the content of page to other sites and import content from this or other sites. 6 * Version: 1. 55 * Version: 1.6 7 6 * Author: Thierry.Vieville@inria.fr 8 7 * Author URI: http://www-sop.inria.fr/members/Thierry.Vieville … … 50 49 if ($post) { 51 50 $content = str_replace(']]>', ']]>', apply_filters('the_content', $post->post_content)); 52 if ((!isset($_REQUEST['title'])) || $_REQUEST['title'] != 'false') 53 echo "<h1>".$post->post_title."</h1>\n".$content; 51 if ((!isset($_REQUEST['title'])) || $_REQUEST['title'] != 0) 52 echo "<h1>".$post->post_title."</h1>\n"; 53 echo $content; 54 54 } 55 55 exit(0); … … 80 80 // Implements internal import 81 81 if($post != null) { 82 if (isset($atts['title']) ) {82 if (isset($atts['title']) && $atts['title'] == 1) { 83 83 return $post->post_title; 84 84 } else { … … 88 88 // Gets the filtered contents 89 89 $content = $post->post_content; 90 if (isset($atts['content']) ) {90 if (isset($atts['content']) && $atts['content'] == 1) { 91 91 $content = do_shortcode($content); 92 92 } else { … … 105 105 // Implements external import 106 106 { 107 $boolean_filter = array("body", "noscript", "mediawiki", "httpsyndication"); 107 108 if (ini_get('allow_url_fopen')) { 108 109 // Apply filters on url 109 110 foreach ($atts as $name => $value) { 110 111 $filter = 'http_syndication/url/'.$name; 111 if (has_filter($filter) )112 if (has_filter($filter) && ($value == 1 || !isset($boolean_filter[$name]))) 112 113 $atts['url'] = apply_filters($filter, $atts['url'], $atts); 113 114 } … … 117 118 // Apply filters on content 118 119 { 119 if (!( isset($atts['raw_ref']) || isset($atts['mediawiki'])))120 if (!((isset($atts['raw_ref']) && $atts['raw_ref'] == 1) || (isset($atts['raw_href']) && $atts['raw_href'] == 1) || (isset($atts['mediawiki']) && $atts['mediawiki'] == 1))) 120 121 $content = $this->http_syndication_content_absolute_href($content, $atts['url']); 121 122 foreach ($atts as $name => $value) { 122 123 $filter = 'http_syndication/content/'.$name; 123 if (has_filter($filter) )124 if (has_filter($filter) && ($value == 1 || !isset($boolean_filter[$name]))) 124 125 $content = apply_filters($filter, $content, $atts); 125 126 } -
http-syndication/trunk/readme.txt
r2259080 r2259310 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Allows to offer the content of page to other sites and import content from this or other sites.11 12 10 == Description == 13 11 14 = Offering content to other sites = 12 This plugins offers the following "ground" functionnalities: 15 13 16 Allows to render the raw content of a post or page without any header or menu. 14 1. Display the content of a post or page without any header, sidebar and footer. 15 2. Importing an internal content of the wordpress site 16 3. Importing the content from an external web site 17 4. A few other deprecated functionalities 17 18 18 * Use `?p=#post_id&httpsyndication` 19 * or `?page_id=#page_id&httpsyndication` HTTP requests on your WordPress site. 19 = 1. Displaying a post or page without any header, sidebar and footer = 20 20 21 Other web sites can include pages and posts contents using a web service, the `[import url=..]` tag of this extension, or a `<iframe />` HTML tag. 21 In order to render the raw content of a post or page without any header, sidebar and footer use the link: 22 22 23 The post title (enclosed in `<h1>` HTML tag) and the post content are exported after filtering, while all other elements (menus, etc.) are skipped. 23 http://#mywordpressadress?httpsyndication&p=#post_or_page_id&title=#1_or_0 24 24 25 = Displaying another site page with a specific banner from this site = 25 where: 26 26 27 Using the `[import banner="#page_id" url="#external_url"]#link-text[/import]` shortcode allows to display another site page in an iframe, with a banner from this site sitting on top of the external page. 27 * `#mywordpressadress` is the wordpress web site adress. 28 * `#post_or_page_id` is the post or page id (you can read the post id in the http link when you edit the post). 29 * `#1_or_0 defines whether the post title (enclosed in `<h1>` HTML tag) is displayed (default is `1`, i.e., true). 28 30 29 Inside the `[import ..]` shortcode, the following options allows to adjust the behavior. 31 *Remarks:* 30 32 31 * `header=false` : in order to include or not the usual site header().php on the top of the banner33 * The post content is exported after filtering. 32 34 33 * `height=1000` : in order to adjust the height of the frame for very long external pages. 35 = 2. Importing an internal content of the wordpress site = 34 36 35 * `newtab=1` : in order to open the page and banner in a new browser window. 37 In order to import a post or page contents in another post or page, use the following shortcode: 36 38 37 * `style="border:none;"` : in order to adjust the height of the frame for very long external pages. 39 * `[import id="#post_or_page_id"]` to include the filtered content of another post or page in the current content. 40 * `[import id="#post_or_page_id" content=1]` to include the raw (with shortcode expanded, but not content filter applied) of another post or page in the current content (to be used only if required). 41 * `[import id="#post_or_page_id" title=1]` to include the title of another post or page in the current content. 38 42 39 = Including content from other sites = 43 where: 40 44 41 On the reverse, using the `[import url="#external_resource_location"]` shortcode allows to include the content of another sites in the current content. 45 * `#post_or_page_id` is the post or page id (you can read the post id in the http link when you edit the post). 42 46 43 Inside the `[import ..]` shortcode, the following options allows syndication from sites offering content: 47 *Remarks:* 44 48 45 * `httpsyndication=1` : adds the `?httpsyndication` query to the URL, in order to properly syndicate sites with this plugin activated. 49 * This avoids spurious import, e.g. of social media buttons (contrary to usual [include plugins](http://wordpress.org/plugins/search.php?q=include)). 50 * Shortcode recursion is managed (i.e. stopped when an infinite loop is detected). 46 51 47 * `mediawiki=1` : adds the `?printable=yes&action=render` query to the URL, in order to properly syndicate mediawiki sites. 52 = 3. Importing the content from an external web site = 48 53 49 The following additional options are available:54 In order to import an external a post or page contents in another post or page, use the following shortcode: 50 55 51 * `body=1` : in order to only import the `<body..>..</body>` part of the `<html><head>..</head><body..>..</body></html>` page. 56 [import url="#external_resource_location" ] 52 57 53 * `noscript=1` : in order to delete all `<script..>..</script>` parts, avoiding any active JavaScript running from the imported HTML.54 58 55 * `raw_href=1` : in order to provide raw href values, instead of properly relocating relative href in the source HTML code, as done by default. 59 where: 56 60 57 * Content filtering: 58 * `tag_name=#name` : only extract the content of all tags of the given name, i.e. the `<#name ..>..</#name>` part (for code safety only 100 tags can be extracted). 61 * `#external_resource_location` is the external web site http location. 62 63 Inside the `[import ..]` shortcode, the following options allows to select and adjust the content to import: 64 65 * Content selection: 66 * `body=1` : in order to only import the `<body..>..</body>` part of the `<html><head>..</head><body..>..</body></html>` page. 59 67 * `tag_id=#id` : only extract the content of the 1st tag of the given id, i.e. the `<#tag id="#id">..</#tag>` part, where `#tag` is any tag (e.g., `div`, `span`, ..). 60 68 * `tag_class=#class` : only extract the content of the 1st tag of the given class, i.e. the `<#tag class="#class">..</#tag>` part, where `#tag` is any tag (e.g., `div`, `span`, ..). 69 * `tag_name=#name` : only extract the content of all tags of the given name, i.e. the `<#name ..>..</#name>` part (for code safety only 100 tags can be extracted). 70 * Content filtering: 71 * `noscript=1` : in order to delete all `<script..>..</script>` parts, avoiding any active JavaScript running from the imported HTML. 72 * `raw_href=1` : in order to provide raw href values, instead of properly relocating relative href in the source HTML code, as done by default. 73 * `mediawiki=1` : adds the `?printable=yes&action=render` query to the URL, in order to properly syndicate mediawiki sites. 61 74 * `style=#style` or `class=#class` allows to add a customized class or style attribute to the tag. 62 75 … … 67 80 *Remarks:* 68 81 69 1. The value of a shortcode option, e.g. `body=1` for the option `body`, is irrelevant: Only the fact that the option is defined matters. 70 2. If the external content can not be read, an error message is produced in the page output. 71 3. This functionality requires the `allow_url_fopen` option to be validated in the PHP configuration, otherwise an error message is produced in the page output. 82 * If the external content can not be read, an error message is produced in the page output. 83 * This functionality requires the `allow_url_fopen` option to be validated in the PHP configuration, otherwise an error message is produced in the page output. 84 * By construction the import is "dynamic", i.e., each time the page is loaded, the external content is queried and inserted in the page. Good news, to be sure to have an updated information. Bad news, if the external web site is down or slowed down. You may consider having a [cache mechanism](http://wordpress.org/plugins/wp-super-cache) to overcome related caveats. 85 * The external HTML content is imported with its external CSS class styles. For another WordPress site, the match is expected to be good. If this is an exotic content management system, the situation is less obvious: Local CSS patch is likely required, or some additional content filter has to be hooked. 86 * There is no way to prevent from infinite syndication loops between sites (e.g., a site with a page importing an external page that itself import the inquiring page). 87 * Unless using `noscript=1`, the external JavaScript code is imported. Though security flaws are normally not to be expected considering usual JavaScript security rules, clearly malicious code can easily hugely perturb the page rendering. 88 * The [embed](http://codex.wordpress.org/Embeds) shortcode is a core WordPress feature. It can embed content from many resources via direct link, and the [iframe](http://www.w3schools.com/tags/tag_iframe.asp) allows to safely and obviously include any external site page in "frame". The [iframe plugin](http://wordpress.org/plugins/iframe) works well and properly make the job. The present import is a 3rd alternative, to be preferred when the former fail or mixing pages content is required. 72 89 73 = Including content from this site =74 90 75 * Using the `[import id="#post_or_page_id" ]` shortcode, allows to include the filtered content of another post or page in the current content. A filtered copy is performed. 91 = 4. A few other deprecated functionalities = 76 92 77 * Using the `[import id="#post_or_page_id" content=1]` shortcode, allows to include the unfiltered content of another post or page in the current content. A raw copy is performed: shortcode are expanded, but content filters are not applied. 78 79 Especially useful to avoid spurious import, e.g. of social media buttons (contrary to usual [include plugins](http://wordpress.org/plugins/search.php?q=include)). 80 81 * Using the `[import id="#post_or_page_id" title=1]` shortcode, allows to include the title of another post or page in the current content. 82 83 Shortcode recursion is managed (i.e. stopped when an infinite loop is detected). 84 85 = Refering content of this site with a tiny URL = 93 These additonal functionalities are deprecated but still available for backward compatibility 86 94 87 95 * Using the `?w=#id` query allows to refer any page, post or archive by its numerical index. 88 96 89 97 * Using the `[import wform=1 label="#theinputlabel"]` shortcode, allows to insert a small input field to switch to any page, post or archive given its numerical index. 98 99 * Using the `[import banner="#page_id" url="#external_url"]#link-text[/import]` shortcode allows to display another site page in an iframe, with a banner from this site sitting on top of the external page. Inside the `[import ..]` shortcode, the following options allows to adjust the behavior. 100 * `header=false` : in order to include or not the usual site header().php on the top of the banner 101 * `height=1000` : in order to adjust the height of the frame for very long external pages. 102 * `newtab=1` : in order to open the page and banner in a new browser window. 103 * `style="border:none;"` : in order to adjust the height of the frame for very long external pages. 90 104 91 105 == Installation == … … 103 117 2. Install the plugin and activate it through the 'Plugins' menu in WordPress 104 118 105 == Frequently Asked Questions==119 == Changelog == 106 120 107 *Any question or suggestion?* 121 = 1.6 = 108 122 109 Simply contact us via http://sparticipatives.gforge.inria.fr/wp-plugins 110 111 == Screenshots == 112 113 1. An article shown within its WordPress context 114 115 2. The same article raw content adding `&http_syndication` to its URL 116 117 == Changelog == 123 Add the title option of the offering content to other sites 124 Reorganize the doc page, and update code accordingly 125 Declare deprecated some features, still available. 118 126 119 127 = 1.5 = … … 132 140 = 1.2 = 133 141 134 Add ingthe `[import banner=..]` shortcode functionality.142 Add the `[import banner=..]` shortcode functionality. 135 143 136 144 = 1.1 = … … 143 151 144 152 Nothing special with this trivial plugin, debugged with WP_DEBUG. 145 146 == Upgrade Notice ==147 148 = 1.4 =149 150 Add the refering content by tiny URL functionnality151 152 = 1.3 =153 154 Adapt the shortcode parsing to editor that escape '&'155 156 = 1.2 =157 158 Adding the `[import banner=..]` shortcode functionality.159 160 = 1.1 =161 162 Additional functionality (the `[import ..]` shortcode) is available.163 164 = 1.0 =165 166 Just a trivial plugin, to start with wp-plugins.167 168 == Other notes ==169 170 = About embed/iframe/import alternatives =171 172 * The [embed](http://codex.wordpress.org/Embeds) shortcode is a core WordPress feature. It can embed content from many resources via direct link.173 174 * Using an [iframe](http://www.w3schools.com/tags/tag_iframe.asp) allows to safely and obviously include any external site page in "frame". The [iframe plugin](http://wordpress.org/plugins/iframe) works well and properly make the job.175 176 * Using the present import is only the 3rd alternative. It is to be preferred when mixing both pages content is required (avoid the "frame" rigidity, allow contents to interact, ..).177 178 = About external content import properties =179 180 * Notice that by construction the import is "dynamic", i.e., each time the page is loaded, the external content is queried and inserted in the page. Good news, to be sure to have an updated information. Bad news, if the external web site is down or slowed down. You may consider having a [cache mechanism](http://wordpress.org/plugins/wp-super-cache) to overcome related caveats.181 182 * The external HTML content is imported with its external CSS class styles. For another WordPress site, the match is expected to be good.183 If this is an exotic content management system, the situation is less obvious: Local CSS patch is likely required, or some additional content filter has to be hooked.184 185 * There is no way to prevent from infinite syndication loops between sites (e.g., a site with a page importing an external page that itself import the inquiring page).186 187 * Unless using `noscript=1`, the external JavaScript code is imported. Though security flaws are normally not to be expected considering usual JavaScript security rules, clearly malicious code can easily hugely perturb the page rendering.188 189 = Adding dedicated URL address filter =190 191 Functions can be hooked to define specific URL filtering before getting its content.192 193 * The hook is defined calling `add_filter('http_syndication/url/#name', #function_name)`.194 * The related function is of the form `function #function_name($pre_filtered_url) { .. return $post_filtered_url; }`.195 * The filter is invoked using the shortcode eponymous option name, i.e. `[import #name=1 url=".."]`.196 197 As an example, the `mediawiki` options is implemented as a hook adding `action=render&printable=yes` to the mediawiki URL.198 199 = Adding dedicated URL content filter =200 201 Functions can be hooked to define specific URL content filtering after getting the URL content.202 203 * The hook is defined calling `add_filter('http_syndication/content/#name', #function_name)`.204 * The related function is of the form `function #function_name($pre_filtered_content) { .. return $post_filtered_content; }`.205 * The filter is invoked using the shortcode eponymous option name, i.e. `[import #name=1 content=".."]`.206 207 As an example, the `body` options is implemented as a hook deleting what is not the `<body>..</body>` content.208
Note: See TracChangeset
for help on using the changeset viewer.