Merge branch 'master' of github.com:woothemes/woocommerce

This commit is contained in:
Claudio Sanches 2015-01-23 11:49:00 -02:00
commit 9f4e3ed409
4 changed files with 27 additions and 16 deletions

View File

@ -142,6 +142,8 @@ class WC_Admin_Webhooks {
do_action( 'woocommerce_webhook_options_save', $webhook->id );
delete_transient( 'woocommerce_webhook_ids' );
// Redirect to webhook edit page to avoid settings save actions
wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=webhooks&edit-webhook=' . $webhook->id . '&updated=1' ) );
exit();
@ -171,6 +173,8 @@ class WC_Admin_Webhooks {
update_post_meta( $webhook_id, '_webhook_pending_delivery', true );
delete_transient( 'woocommerce_webhook_ids' );
// Redirect to edit page
wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=webhooks&edit-webhook=' . $webhook_id . '&created=1' ) );
exit();
@ -227,6 +231,8 @@ class WC_Admin_Webhooks {
$webhooks = array_map( 'absint', (array) $_GET['webhook'] );
delete_transient( 'woocommerce_webhook_ids' );
switch ( $_GET['action'] ) {
case 'trash' :
$this->bulk_trash( $webhooks );
@ -237,7 +243,6 @@ class WC_Admin_Webhooks {
case 'delete' :
$this->bulk_trash( $webhooks, true );
break;
default :
break;
}
@ -275,7 +280,6 @@ class WC_Admin_Webhooks {
*/
public function actions() {
if ( $this->is_webhook_settings_page() ) {
// Save
if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) {
$this->save();

View File

@ -217,6 +217,8 @@ class WC_API_Webhooks extends WC_API_Resource {
do_action( 'woocommerce_api_create_webhook', $webhook->id, $this );
delete_transient( 'woocommerce_webhook_ids' );
return $this->get_webhook( $webhook->id );
} catch ( WC_API_Exception $e ) {
@ -298,6 +300,8 @@ class WC_API_Webhooks extends WC_API_Resource {
do_action( 'woocommerce_api_edit_webhook', $webhook->id, $this );
delete_transient( 'woocommerce_webhook_ids' );
return $this->get_webhook( $id );
} catch ( WC_API_Exception $e ) {
@ -323,6 +327,8 @@ class WC_API_Webhooks extends WC_API_Resource {
do_action( 'woocommerce_api_delete_webhook', $id, $this );
delete_transient( 'woocommerce_webhook_ids' );
// no way to manage trashed webhooks at the moment, so force delete
return $this->delete( $id, 'webhook', true );
}

View File

@ -81,7 +81,9 @@ class WC_Install {
* Install WC
*/
public static function install() {
define( 'WC_INSTALLING', true );
if ( ! defined( 'WC_INSTALLING' ) ) {
define( 'WC_INSTALLING', true );
}
self::create_options();
self::create_tables();

View File

@ -457,19 +457,18 @@ final class WooCommerce {
* @since 2.2
*/
private function load_webhooks() {
$args = array(
'fields' => 'ids',
'post_type' => 'shop_webhook',
'post_status' => 'publish',
);
$query = new WP_Query( $args );
if ( ! empty( $query->posts ) ) {
foreach ( $query->posts as $id ) {
$webhook = new WC_Webhook( $id );
$webhook->enqueue();
}
if ( false === ( $webhooks = get_transient( 'woocommerce_webhook_ids' ) ) ) {
$webhooks = get_posts( array(
'fields' => 'ids',
'post_type' => 'shop_webhook',
'post_status' => 'publish',
'posts_per_page' => -1
) );
set_transient( 'woocommerce_webhook_ids', $webhooks );
}
foreach ( $webhooks as $webhook_id ) {
$webhook = new WC_Webhook( $webhook_id );
$webhook->enqueue();
}
}