Plugin Directory

Changeset 2259310


Ignore:
Timestamp:
03/11/2020 05:56:07 PM (6 years ago)
Author:
vthierry
Message:

from makefile

Location:
http-syndication
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • http-syndication/trunk/http_syndication.php

    r2259080 r2259310  
    22/**
    33 * Plugin Name: http-syndication
    4  * Plugin URI: http://sparticipatives.gforge.inria.fr/wp-plugins/
    54 * Description: Allows to offer the content of page to other sites and import content from this or other sites.
    6  * Version: 1.5
     5 * Version: 1.6
    76 * Author: Thierry.Vieville@inria.fr
    87 * Author URI: http://www-sop.inria.fr/members/Thierry.Vieville
     
    5049      if ($post) {
    5150    $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;
    5454      }
    5555      exit(0);
     
    8080      // Implements internal import
    8181      if($post != null) {
    82     if (isset($atts['title'])) {
     82    if (isset($atts['title']) && $atts['title'] == 1) {
    8383      return $post->post_title;
    8484    } else {
     
    8888        // Gets the filtered contents
    8989        $content = $post->post_content;
    90         if (isset($atts['content'])) {
     90        if (isset($atts['content']) && $atts['content'] == 1) {
    9191          $content = do_shortcode($content);
    9292        } else {
     
    105105      // Implements external import
    106106      {
     107    $boolean_filter = array("body", "noscript", "mediawiki", "httpsyndication");
    107108    if (ini_get('allow_url_fopen')) {
    108109      // Apply filters on url
    109110      foreach ($atts as $name => $value) {
    110111        $filter = 'http_syndication/url/'.$name;
    111         if (has_filter($filter))
     112        if (has_filter($filter) && ($value == 1 || !isset($boolean_filter[$name])))
    112113          $atts['url'] = apply_filters($filter, $atts['url'], $atts);
    113114      }
     
    117118        // Apply filters on content
    118119        {
    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)))
    120121        $content = $this->http_syndication_content_absolute_href($content, $atts['url']);
    121122          foreach ($atts as $name => $value) {
    122123        $filter = 'http_syndication/content/'.$name;
    123         if (has_filter($filter))
     124        if (has_filter($filter) && ($value == 1 || !isset($boolean_filter[$name])))
    124125          $content = apply_filters($filter, $content, $atts);
    125126          }
  • http-syndication/trunk/readme.txt

    r2259080 r2259310  
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 Allows to offer the content of page to other sites and import content from this or other sites.
    11 
    1210== Description ==
    1311
    14 = Offering content to other sites =
     12This plugins offers the following "ground" functionnalities:
    1513
    16 Allows to render the raw content of a post or page without any header or menu.
     141. Display the content of a post or page without any header, sidebar and footer.
     152. Importing an internal content of the wordpress site
     163. Importing the content from an external web site
     174. A few other deprecated functionalities
    1718
    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 =
    2020
    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.
     21In order to render the raw content of a post or page without any header, sidebar and footer use the link:
    2222
    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
    2424
    25 = Displaying another site page with a specific banner from this site =
     25where:
    2626
    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).
    2830
    29 Inside the  `[import ..]` shortcode, the following options allows to adjust the behavior.
     31*Remarks:*
    3032
    31 * `header=false` : in order to include or not the usual site header().php on the top of the banner
     33* The post content is exported after filtering.
    3234
    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 =
    3436
    35 * `newtab=1` : in order to open the page and banner in a new browser window.
     37In order to import a post or page contents in another post or page, use the following shortcode:
    3638
    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.
    3842
    39 = Including content from other sites =
     43where:
    4044
    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).
    4246
    43 Inside the  `[import ..]` shortcode, the following options allows syndication from sites offering content:
     47*Remarks:*
    4448
    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).
    4651
    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 =
    4853
    49 The following additional options are available:
     54In order to import an external a post or page contents in another post or page, use the following shortcode:
    5055
    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" ]
    5257
    53 * `noscript=1` : in order to delete all `<script..>..</script>` parts, avoiding any active JavaScript running from the imported HTML.
    5458
    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.
     59where:
    5660
    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
     63Inside 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.
    5967  * `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`, ..).
    6068  * `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.
    6174  * `style=#style` or `class=#class` allows to add a customized class or style attribute to the tag.
    6275
     
    6780*Remarks:*
    6881
    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.
    7289
    73 = Including content from this site =
    7490
    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 =
    7692
    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 =
     93These additonal functionalities are deprecated but still available for backward compatibility
    8694
    8795* Using the `?w=#id` query allows to refer any page, post or archive by its numerical index.
    8896
    8997* 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.
    90104
    91105== Installation ==
     
    1031172. Install the plugin and activate it through the 'Plugins' menu in WordPress
    104118
    105 == Frequently Asked Questions ==
     119== Changelog ==
    106120
    107 *Any question or suggestion?*
     121= 1.6 =
    108122
    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 ==
     123Add the title option of the offering content to other sites
     124Reorganize the doc page, and update code accordingly
     125Declare deprecated some features, still available.
    118126
    119127= 1.5 =
     
    132140= 1.2 =
    133141
    134 Adding the `[import banner=..]` shortcode functionality.
     142Add the `[import banner=..]` shortcode functionality.
    135143
    136144= 1.1 =
     
    143151
    144152Nothing 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 functionnality
    151 
    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.