Plugin Directory

Changeset 623369


Ignore:
Timestamp:
11/10/2012 02:32:50 PM (13 years ago)
Author:
ppfeufer
Message:

v1.6
fixed some api-problems

Location:
wp-spreadshirt
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-spreadshirt/tags/1.6/readme.txt

    r612453 r623369  
    55Requires at least: 3.0.1
    66Tested up to: 3.5
    7 Stable tag: 1.5
     7Stable tag: 1.6
    88
    99Adding a shortcode to show your Spreadshirt-Articles in a page or post.
     
    1414
    1515Example:
    16 `[spreadshirt shop_url="http://chaoz.spreadshirt.de/" shop_id="602194"]`
     16`[spreadshirt shop_url="http://chaoz.spreadshirt.de/" shop_id="602194" shop_location="eu/na"]`
    1717or
    18 `[spreadshirt shop_url="http://chaoz.spreadshirt.de/shop/" shop_id="602194"]`
     18`[spreadshirt shop_url="http://chaoz.spreadshirt.de/shop/" shop_id="602194" shop_location="eu/na"]`
    1919
    2020The Shop-URL **must** contain the trailing slash.
     
    3030
    3131== Changelog ==
     32
     33= 1.6 =
     34* New option for shortcode. `shop_location` Set this to "eu" for european based shops or to "na" for northern america based shops. Spreadshirt has two separated APIs for this location. This will hopefully fix some problems displaying the wrong articles.
    3235
    3336= 1.5 =
  • wp-spreadshirt/tags/1.6/wp-spreadshirt.php

    r612453 r623369  
    44 * Plugin URI: http://ppfeufer.de/wordpress-plugin/wp-spreadshirt/
    55 * Description: Adding a shortcode to show your Spreadshirt-Articles in a page or post.
    6  * Version: 1.5
     6 * Version: 1.6
    77 * Author: H.-Peter Pfeufer
    88 * Author URI: http://ppfeufer.de
     
    8282            extract(shortcode_atts(array(
    8383                'shop_id' => '',
    84                 'shop_url' => ''
     84                'shop_url' => '',
     85                'shop_location' => 'eu'
    8586            ), $atts));
    8687
    8788            if(!empty($shop_id) && !empty($shop_url)) {
    88                 $array_ArticleData = $this->_get_spreadshirt_data($shop_url, $shop_id);
     89                /**
     90                 * Let's see what API we have to talk to.
     91                 *
     92                 * @since 1.6
     93                 * @author ppfeufer
     94                 */
     95                $var_sApiUrl = '';
     96                switch($shop_location) {
     97                    case 'eu':
     98                        $var_sApiUrl = 'http://api.spreadshirt.net/api/v1/shops/' . $shop_id . '/articleCategories/510/articles';
     99                        break;
     100
     101                    case 'na':
     102                        $var_sApiUrl = 'http://api.spreadshirt.com/api/v1/shops/' . $shop_id . '/articleCategories/510/articles';
     103                        break;
     104                } // END switch($shop_location)
     105
     106                $array_ArticleData = $this->_get_spreadshirt_data($shop_url, $var_sApiUrl);
    89107
    90108                if($array_ArticleData === false) {
     
    140158         * @return boolean|multitype:multitype:string
    141159         */
    142         private function _get_spreadshirt_data($var_sShopUri = null, $var_sShopId = null) {
    143             if(!empty($var_sShopUri) && !empty($var_sShopId)) {
     160        private function _get_spreadshirt_data($var_sShopUri = null, $var_sApiUrl) {
     161            if(!empty($var_sShopUri) && !empty($var_sApiUrl)) {
    144162                $array_Articles = get_transient('spreadshirt-article-data');
    145163
    146164                if($array_Articles === false) {
    147                     $var_sXmlShop = wp_remote_retrieve_body(wp_remote_get('http://api.spreadshirt.net/api/v1/shops/' . $var_sShopId . '/articleCategories/510/articles'));
     165                    $var_sXmlShop = wp_remote_retrieve_body(wp_remote_get($var_sApiUrl));
    148166
    149167                    if(is_wp_error($var_sXmlShop)) {
    150168                        return false;
    151169                    } // END if(is_wp_error($var_sXmlShop))
     170
     171                    /**
     172                     * Check if we have a valid XML.
     173                     * If not, the shop seems to be not existing.
     174                     *
     175                     * @since 1.6
     176                     * @author ppfeufer
     177                     */
     178                    if(substr($var_sXmlShop, 0, 5) != "<?xml") {
     179                        echo __('The Shop doesn\'t exist', $this->var_sTextdomain);
     180
     181                        return false;
     182                    } // if(substr($var_sXmlShop, 0, 5) != "<?xml")
    152183
    153184                    try {
  • wp-spreadshirt/trunk/readme.txt

    r612453 r623369  
    55Requires at least: 3.0.1
    66Tested up to: 3.5
    7 Stable tag: 1.5
     7Stable tag: 1.6
    88
    99Adding a shortcode to show your Spreadshirt-Articles in a page or post.
     
    1414
    1515Example:
    16 `[spreadshirt shop_url="http://chaoz.spreadshirt.de/" shop_id="602194"]`
     16`[spreadshirt shop_url="http://chaoz.spreadshirt.de/" shop_id="602194" shop_location="eu/na"]`
    1717or
    18 `[spreadshirt shop_url="http://chaoz.spreadshirt.de/shop/" shop_id="602194"]`
     18`[spreadshirt shop_url="http://chaoz.spreadshirt.de/shop/" shop_id="602194" shop_location="eu/na"]`
    1919
    2020The Shop-URL **must** contain the trailing slash.
     
    3030
    3131== Changelog ==
     32
     33= 1.6 =
     34* New option for shortcode. `shop_location` Set this to "eu" for european based shops or to "na" for northern america based shops. Spreadshirt has two separated APIs for this location. This will hopefully fix some problems displaying the wrong articles.
    3235
    3336= 1.5 =
  • wp-spreadshirt/trunk/wp-spreadshirt.php

    r612453 r623369  
    44 * Plugin URI: http://ppfeufer.de/wordpress-plugin/wp-spreadshirt/
    55 * Description: Adding a shortcode to show your Spreadshirt-Articles in a page or post.
    6  * Version: 1.5
     6 * Version: 1.6
    77 * Author: H.-Peter Pfeufer
    88 * Author URI: http://ppfeufer.de
     
    8282            extract(shortcode_atts(array(
    8383                'shop_id' => '',
    84                 'shop_url' => ''
     84                'shop_url' => '',
     85                'shop_location' => 'eu'
    8586            ), $atts));
    8687
    8788            if(!empty($shop_id) && !empty($shop_url)) {
    88                 $array_ArticleData = $this->_get_spreadshirt_data($shop_url, $shop_id);
     89                /**
     90                 * Let's see what API we have to talk to.
     91                 *
     92                 * @since 1.6
     93                 * @author ppfeufer
     94                 */
     95                $var_sApiUrl = '';
     96                switch($shop_location) {
     97                    case 'eu':
     98                        $var_sApiUrl = 'http://api.spreadshirt.net/api/v1/shops/' . $shop_id . '/articleCategories/510/articles';
     99                        break;
     100
     101                    case 'na':
     102                        $var_sApiUrl = 'http://api.spreadshirt.com/api/v1/shops/' . $shop_id . '/articleCategories/510/articles';
     103                        break;
     104                } // END switch($shop_location)
     105
     106                $array_ArticleData = $this->_get_spreadshirt_data($shop_url, $var_sApiUrl);
    89107
    90108                if($array_ArticleData === false) {
     
    140158         * @return boolean|multitype:multitype:string
    141159         */
    142         private function _get_spreadshirt_data($var_sShopUri = null, $var_sShopId = null) {
    143             if(!empty($var_sShopUri) && !empty($var_sShopId)) {
     160        private function _get_spreadshirt_data($var_sShopUri = null, $var_sApiUrl) {
     161            if(!empty($var_sShopUri) && !empty($var_sApiUrl)) {
    144162                $array_Articles = get_transient('spreadshirt-article-data');
    145163
    146164                if($array_Articles === false) {
    147                     $var_sXmlShop = wp_remote_retrieve_body(wp_remote_get('http://api.spreadshirt.net/api/v1/shops/' . $var_sShopId . '/articleCategories/510/articles'));
     165                    $var_sXmlShop = wp_remote_retrieve_body(wp_remote_get($var_sApiUrl));
    148166
    149167                    if(is_wp_error($var_sXmlShop)) {
    150168                        return false;
    151169                    } // END if(is_wp_error($var_sXmlShop))
     170
     171                    /**
     172                     * Check if we have a valid XML.
     173                     * If not, the shop seems to be not existing.
     174                     *
     175                     * @since 1.6
     176                     * @author ppfeufer
     177                     */
     178                    if(substr($var_sXmlShop, 0, 5) != "<?xml") {
     179                        echo __('The Shop doesn\'t exist', $this->var_sTextdomain);
     180
     181                        return false;
     182                    } // if(substr($var_sXmlShop, 0, 5) != "<?xml")
    152183
    153184                    try {
Note: See TracChangeset for help on using the changeset viewer.