Skip to content

Commit

Permalink
Merge branch 'pre-1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
itthinx committed Sep 14, 2015
2 parents 59f0565 + 1176707 commit f4e5a6c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
Binary file added images/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: itthinx
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.1.1
Stable tag: 1.0.1
Tested up to: 4.3
Stable tag: 1.0.2
License: GPLv3

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

== Changelog ==

= 1.0.2 =
* Tested with WordPress 4.3.
* Fixed hardcoded database table reference.
* Added a placeholder image used when GD is missing.

= 1.0.1 =
* Tested with WordPress 4.1.1 and WooCommerce 2.3.6.
* WordPress-compliant readme.txt added.
Expand All @@ -50,8 +55,5 @@ You can install the plugin via FTP, see [Manual Plugin Installation](http://code

== Upgrade Notice ==

= 1.0.1 =
* Tested with latest version of WordPress and WooCommerce, also added a compliant readme.txt.

= 1.0.0 =
* Initial release.
= 1.0.2 =
* Tested with WordPress 4.3, added two fixes.
64 changes: 37 additions & 27 deletions woocommerce-product-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,9 @@ public static function run( $n = self::MAX_PER_RUN ) {
public static function get_product_count() {
//$counts = wp_count_posts( 'product' ); // <-- nah ... :|
global $wpdb;
return intval( $wpdb->get_var( "SELECT count(*) FROM wp_posts WHERE post_type = 'product' and post_status = 'publish'" ) );
return intval( $wpdb->get_var(
"SELECT count(*) FROM $wpdb->posts WHERE post_type = 'product' and post_status = 'publish'"
) );
}

public static function create_product() {
Expand Down Expand Up @@ -1055,33 +1057,41 @@ public static function get_content( $n_lines = 10 ) {
* @return string image data
*/
public static function get_image() {
$width = self::IMAGE_WIDTH;
$height = self::IMAGE_HEIGHT;

$image = imagecreatetruecolor( $width, $height );
for( $i = 0; $i <= 11; $i++ ) {
$x = rand( 0, $width );
$y = rand( 0, $height );
$w = rand( 1, $width );
$h = rand( 1, $height );
$red = rand( 0, 255 );
$green = rand( 0, 255 );
$blue = rand( 0, 255 );
$color = imagecolorallocate( $image, $red, $green, $blue );
imagefilledrectangle(
$image,
$x - $w / 2,
$y - $h / 2,
$x + $w / 2,
$y + $h / 2,
$color
);
}
$output = '';
if ( function_exists( 'imagepng' ) ) {
$width = self::IMAGE_WIDTH;
$height = self::IMAGE_HEIGHT;

$image = imagecreatetruecolor( $width, $height );
for( $i = 0; $i <= 11; $i++ ) {
$x = rand( 0, $width );
$y = rand( 0, $height );
$w = rand( 1, $width );
$h = rand( 1, $height );
$red = rand( 0, 255 );
$green = rand( 0, 255 );
$blue = rand( 0, 255 );
$color = imagecolorallocate( $image, $red, $green, $blue );
imagefilledrectangle(
$image,
$x - $w / 2,
$y - $h / 2,
$x + $w / 2,
$y + $h / 2,
$color
);
}

ob_start();
imagepng( $image );
$output = ob_get_clean();
imagedestroy( $image );
ob_start();
imagepng( $image );
$output = ob_get_clean();
imagedestroy( $image );
} else {
$image = file_get_contents( WOOPROGEN_PLUGIN_URL . '/images/placeholder.png' );
ob_start();
echo $image;
$output = ob_get_clean();
}
return $output;

}
Expand Down

0 comments on commit f4e5a6c

Please sign in to comment.