Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created March 15, 2013 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancameron/5172588 to your computer and use it in GitHub Desktop.
Save dancameron/5172588 to your computer and use it in GitHub Desktop.
wp_insert_post Title Fix for wp_unique_post_slug latency
diff --git models/groupBuyingCart.class.php models/groupBuyingCart.class.php
index 0c8bee0690f813b094bec94269484c18bd0fc07c..0aba99614a37273440c7d162533abe1707503121 100755
--- models/groupBuyingCart.class.php
+++ models/groupBuyingCart.class.php
@@ -296,8 +296,8 @@ class Group_Buying_Cart extends Group_Buying_Post_Type {
);
} else {
$post = array(
- 'post_title' => self::__( 'Anonymous' ),
- 'post_name' => 'anonymous',
+ 'post_title' => sprintf( self::__( 'Anonymous %s' ), $_SERVER['REMOTE_ADDR'] ),
+ 'post_name' => sprintf( self::__( 'anonymous-%s' ), $_SERVER['REMOTE_ADDR'] ),
'post_status' => 'publish',
'post_type' => self::POST_TYPE,
);
diff --git models/groupBuyingPayment.class.php models/groupBuyingPayment.class.php
index 6785b3a13d7423cd19fe9774bf7276ddb7663724..3bbdfa081c099b4fd111a9b038cca57168870fc0 100644
--- models/groupBuyingPayment.class.php
+++ models/groupBuyingPayment.class.php
@@ -86,8 +86,9 @@ class Group_Buying_Payment extends Group_Buying_Post_Type {
}
public static function new_payment( $args, $status = self::STATUS_COMPLETE ) {
+ $title_suffix = ( isset( $args['transaction_id'] ) ) ? $args['transaction_id'] : microtime();
$default = array(
- 'post_title' => self::__( 'Payment' ),
+ 'post_title' => sprintf( self::__( 'Payment %s' ), $title_suffix ),
'post_status' => $status,
'post_type' => self::POST_TYPE,
);
diff --git models/groupBuyingPurchase.class.php models/groupBuyingPurchase.class.php
index 1fa92b3e8928ac5b02f2dd549a7bde2dab758922..e205b18813ed69d786964cdc9315b16e08c48cd3 100644
--- models/groupBuyingPurchase.class.php
+++ models/groupBuyingPurchase.class.php
@@ -95,8 +95,9 @@ class Group_Buying_Purchase extends Group_Buying_Post_Type {
public static function new_purchase( $args = array() ) {
+ $title_suffix = ( isset( $args['cart'] ) && is_a( $args['cart'], 'Group_Buying_Cart' ) ) ? $args['cart']->get_id() : microtime();
$default = array(
- 'post_title' => self::__( 'Order' ),
+ 'post_title' => sprintf( self::__( 'Order %s' ), $title_suffix ),
'post_status' => 'pending',
'post_type' => self::POST_TYPE,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment