Plugin Directory

Changeset 632485


Ignore:
Timestamp:
11/30/2012 11:20:14 PM (13 years ago)
Author:
ppfeufer
Message:

v1.6.2
More sanitizing of article-uri. Spreadshirt has a very inconsistent way to rewrite special chars -.-

Location:
wp-spreadshirt
Files:
4 edited
1 copied

Legend:

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

    r626825 r632485  
    55Requires at least: 3.0.1
    66Tested up to: 3.5
    7 Stable tag: 1.6.1
     7Stable tag: 1.6.2
    88
    99Adding a shortcode to show your Spreadshirt-Articles in a page or post.
     
    3030
    3131== Changelog ==
     32
     33= 1.6.2 =
     34* More sanitizing of article-uri. Spreadshirt has a very inconsistent way to rewrite special chars -.-
    3235
    3336= 1.6.1 =
  • wp-spreadshirt/tags/1.6.2/wp-spreadshirt.php

    r626825 r632485  
    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.6.1
     6 * Version: 1.6.2
    77 * Author: H.-Peter Pfeufer
    88 * Author URI: http://ppfeufer.de
     
    218218                                'ü',
    219219                                'Ü',
    220                                 'ß'
     220                                'ß',
     221                                '\''
    221222                            );
    222223                            $array_Replace = array(
     
    231232                                'ue',
    232233                                'ue',
    233                                 'ss'
     234                                'ss',
     235                                '-'
    234236                            );
    235237
     
    247249                             */
    248250                            if(preg_match('/\/shop\//',  $var_sShopUri)) {
     251
     252                                $var_sArticleUri = preg_replace('/\/shop\//', '', $var_sShopUri) . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
     253                            } else {
    249254                                $var_sArticleUri = $var_sShopUri . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
    250                             } else {
    251                                 $var_sArticleUri = $var_sShopUri . 'shop/' . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
    252255                            } // END if(preg_match('/\/shop\//',  $var_sShopUri))
    253256
     
    255258                                'article-name' => (string) $obj_ArticleData->name,
    256259                                'article-description' => (string) $obj_ArticleData->description,
    257                                 'article-uri' => $var_sArticleUri,
     260                                'article-uri' => $this->reduce_dashes($var_sArticleUri, '-', 1),
    258261                                'article-image' => (string) $article->resources->resource->attributes('http://www.w3.org/1999/xlink'),
    259262                                'article-price-vatExcluded' => (string) $obj_ArticleData->price->vatExcluded,
     
    277280
    278281        /**
     282         * mehrfach wiederholende Zeichen aus einem String entfernen
     283         *
     284         * @param string $string Zu bearbeitender String
     285         * @param string $chars Zeichen die beachtet werden sollen
     286         * @param int $maxRepeats
     287         * @return string
     288         *
     289         * @since 1.6.2
     290         * @author ppfeufer
     291         */
     292        private function reduce_dashes($var_sString, $var_sChars, $var_iMaxRepeats) {
     293            $patternParts = array();
     294
     295            foreach(str_split($var_sChars) as $char) {
     296                $patternParts[] = sprintf('%s{%d,}', $char, $var_iMaxRepeats);
     297            }
     298
     299            $var_sString = preg_replace_callback(
     300                sprintf('/%s/i', join('|', $patternParts)),
     301                create_function('$matches', 'return $matches[0][0];'),
     302                $var_sString
     303            );
     304
     305            return $var_sString;
     306        }
     307
     308        /**
    279309         * Etwas CSS in den <head> schubsen
    280310         *
  • wp-spreadshirt/trunk/readme.txt

    r626825 r632485  
    55Requires at least: 3.0.1
    66Tested up to: 3.5
    7 Stable tag: 1.6.1
     7Stable tag: 1.6.2
    88
    99Adding a shortcode to show your Spreadshirt-Articles in a page or post.
     
    3030
    3131== Changelog ==
     32
     33= 1.6.2 =
     34* More sanitizing of article-uri. Spreadshirt has a very inconsistent way to rewrite special chars -.-
    3235
    3336= 1.6.1 =
  • wp-spreadshirt/trunk/wp-spreadshirt.php

    r626825 r632485  
    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.6.1
     6 * Version: 1.6.2
    77 * Author: H.-Peter Pfeufer
    88 * Author URI: http://ppfeufer.de
     
    218218                                'ü',
    219219                                'Ü',
    220                                 'ß'
     220                                'ß',
     221                                '\''
    221222                            );
    222223                            $array_Replace = array(
     
    231232                                'ue',
    232233                                'ue',
    233                                 'ss'
     234                                'ss',
     235                                '-'
    234236                            );
    235237
     
    247249                             */
    248250                            if(preg_match('/\/shop\//',  $var_sShopUri)) {
     251
     252                                $var_sArticleUri = preg_replace('/\/shop\//', '', $var_sShopUri) . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
     253                            } else {
    249254                                $var_sArticleUri = $var_sShopUri . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
    250                             } else {
    251                                 $var_sArticleUri = $var_sShopUri . 'shop/' . $var_sArticleUri . '-A' . (int) $article->attributes()->id;
    252255                            } // END if(preg_match('/\/shop\//',  $var_sShopUri))
    253256
     
    255258                                'article-name' => (string) $obj_ArticleData->name,
    256259                                'article-description' => (string) $obj_ArticleData->description,
    257                                 'article-uri' => $var_sArticleUri,
     260                                'article-uri' => $this->reduce_dashes($var_sArticleUri, '-', 1),
    258261                                'article-image' => (string) $article->resources->resource->attributes('http://www.w3.org/1999/xlink'),
    259262                                'article-price-vatExcluded' => (string) $obj_ArticleData->price->vatExcluded,
     
    277280
    278281        /**
     282         * mehrfach wiederholende Zeichen aus einem String entfernen
     283         *
     284         * @param string $string Zu bearbeitender String
     285         * @param string $chars Zeichen die beachtet werden sollen
     286         * @param int $maxRepeats
     287         * @return string
     288         *
     289         * @since 1.6.2
     290         * @author ppfeufer
     291         */
     292        private function reduce_dashes($var_sString, $var_sChars, $var_iMaxRepeats) {
     293            $patternParts = array();
     294
     295            foreach(str_split($var_sChars) as $char) {
     296                $patternParts[] = sprintf('%s{%d,}', $char, $var_iMaxRepeats);
     297            }
     298
     299            $var_sString = preg_replace_callback(
     300                sprintf('/%s/i', join('|', $patternParts)),
     301                create_function('$matches', 'return $matches[0][0];'),
     302                $var_sString
     303            );
     304
     305            return $var_sString;
     306        }
     307
     308        /**
    279309         * Etwas CSS in den <head> schubsen
    280310         *
Note: See TracChangeset for help on using the changeset viewer.