2017 © Pedro Peláez
 

wordpress-muplugin wp-exhale

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

image

devgeniem/wp-exhale

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  • Monday, January 16, 2017
  • by devgeniem
  • Repository
  • 8 Watchers
  • 0 Stars
  • 460 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

WP Plugin: Exhale

Developer friendly framework for creating xml data exports from WordPress. This works only with php7.0 or better because we use scalar type hinting., (*1)

Install plugin

$ composer require devgeniem/wp-exhale
$ wp plugin activate wp-exhale

Usage

You need to define class which extends our parent class Exhale\Base\XML. This class is autocalled when suitable request comes and you don't need to hook it anywhere., (*2)

For example this could look like:, (*3)

<?php
/**
 * This class exists so that users of Exhale can start producing xml really quickly
 */
class MyProviderName implements \Exhale\Type\XML {
    /**
     * Returns exportable apartments to Vuokraovi
     */
    static public function get_export_data() : array {
        return array('item' => 'value');
    }

    /**
     * If you need to wrap your data into custom element you can use this
     * Empty array is ignored
     */
    static public function xml_root_element() : array {
        return array(
            'name' => 'wrapper'
        );
    }

    /**
     * This function can be used to map custom namespaces into the xml
     * Empty array is ignored
     */
    static public function xml_namespaces() : array {
        return array(
            'http://www.w3.org/2001/XMLSchema-instance' => 'xsi',
        );
    }
}

This class now automatically provides custom data export from: http://yoursite.com/api/export/myprovidername.xml, (*4)

With contents:, (*5)

<wrapper xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <item>value</item>
</wrapper>

How it works?

This plugin uses sabre/xml inside. The array from get_export_data() function is mapped into xml write operation in sabre/xml. This way you get all the good things from sabre/xml as well., (*6)

If the exhale url is requested the XML is produced in plugins_loaded hook and then process is stopped immediately., (*7)

Settings

You can override default exporter url by defining in wp-config:, (*8)

define('EXHALE_URL_PREFIX','/my-custom/api/url/');

The earlier example would now be accessible from: http://yoursite.com/api/export/myprovidername.xml, (*9)

Special cases

If you want to add attributes to your elements or have multiple elements with same key you can do this with sabre/xml compatible custom arrays:, (*10)

static public function get_export_data() {
        return array(
            [
                'name' => 'item',
                'attributes' => [
                    'url' => 'http://yoursite.com'
                ],
                'value' => 'value'
            ],
            [
                'name' => 'item',
                'attributes' => [
                    'url' => 'http://example.com'
                ],
                'value' => 'nothing'
            ],
        );
    }

This will produce following xml:, (*11)

<item url="http://yoursite.com">value</item>
<item url="http://example.com">nothing</item>

License

GPLv3, (*12)

The Versions

16/01 2017

dev-AddFix

dev-AddFix http://geniem.com

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

01/12 2016

dev-master

9999999-dev http://geniem.com

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

01/12 2016

0.1.5

0.1.5.0 http://geniem.com

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

01/12 2016

dev-HookFix

dev-HookFix http://geniem.com

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

12/09 2016

0.1.4

0.1.4.0 http://geniem.com

Creates Developer friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

02/08 2016

0.1.3

0.1.3.0 http://geniem.com

Creates Deveploper friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

02/08 2016

0.1.2

0.1.2.0 http://geniem.com

Creates Deveploper friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

02/08 2016

0.1.1

0.1.1.0 http://geniem.com

Creates Deveploper friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter

02/08 2016

0.1

0.1.0.0 http://geniem.com

Creates Deveploper friendly xml api endpoint for 3rd party integrations on your data.

  Sources   Download

MIT

The Requires

 

wordpress framework wp exporter