Skip to content

Commit

Permalink
version 1.1.1; fixes excerpt
Browse files Browse the repository at this point in the history
  • Loading branch information
itthinx committed Mar 3, 2016
1 parent cac859a commit 0a405a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://www.itthinx.com/plugins/woocommerce-product-generator/
Tags: automatic, benchmark, example, generator, performance, product, products, sample, test, tester, testing, test-tool, woocommerce
Requires at least: 4.0
Tested up to: 4.4.2
Stable tag: 1.1.0
Stable tag: 1.1.1
License: GPLv3

A sample product generator for WooCommerce.
Expand Down Expand Up @@ -40,6 +40,9 @@ You can install the plugin via FTP, see [Manual Plugin Installation](http://code

== Changelog ==

= 1.1.1 =
* Fixed the excerpt creation and avoiding duplicate lines in it.

= 1.1.0 =
* Creating excerpts, too.

Expand All @@ -63,5 +66,5 @@ You can install the plugin via FTP, see [Manual Plugin Installation](http://code

== Upgrade Notice ==

= 1.1.0 =
= 1.1.1 =
* With this release, product short descriptions or excerpts are also created.
12 changes: 9 additions & 3 deletions woocommerce-product-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* Plugin Name: WooCommerce Product Generator
* Plugin URI: http://www.itthinx.com/
* Description: A sample product generator for WooCommerce.
* Version: 1.1.0
* Version: 1.1.1
* Author: itthinx
* Author URI: http://www.itthinx.com
* Donate-Link: http://www.itthinx.com
* License: GPLv3
*/

define( 'WOOPROGEN_PLUGIN_VERSION', '1.1.0' );
define( 'WOOPROGEN_PLUGIN_VERSION', '1.1.1' );
define( 'WOOPROGEN_PLUGIN_DOMAIN', 'woocommerce-product-generator' );
define( 'WOOPROGEN_PLUGIN_URL', WP_PLUGIN_URL . '/woocommerce-product-generator' );

Expand Down Expand Up @@ -1044,13 +1044,19 @@ public static function get_title( $n_words = 3 ) {
public static function get_excerpt( $n_lines = 3, $contents = null ) {
if ( $contents === null ) {
$contents = trim( stripslashes( get_option( 'woocommerce-product-generator-contents', self::DEFAULT_CONTENTS ) ) );
} else {
$contents = str_ireplace( '</p>', "\n", $contents );
$contents = str_ireplace( '<p>', '', $contents );
}
$contents = explode( "\n", $contents );
$content = array();
$n = count( $contents );
$n_lines = rand( 1, $n_lines );
for ( $i = 1; $i <= $n_lines ; $i++ ) {
$content[] = $contents[rand( 0, $n - 1 )];
$maybe_content = $contents[rand( 0, $n - 1 )];
if ( !in_array( $maybe_content, $content ) ) {
$content[] = $maybe_content;
}
}
$content = "<p>" . implode( "</p><p>", $content ) . "</p>";
return $content;
Expand Down

0 comments on commit 0a405a1

Please sign in to comment.