Flush rewrite rules and redirect after installation
This commit is contained in:
parent
420bbfa2b9
commit
d37f5eb95a
|
@ -9,27 +9,15 @@
|
|||
* @package WooCommerce
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queue install when activated
|
||||
*/
|
||||
function queue_install_woocommerce() {
|
||||
add_action('init', 'install_woocommerce', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install woocommerce
|
||||
*
|
||||
* Calls each function to install things, and clears the cron jobs and rewrite rules
|
||||
*/
|
||||
function install_woocommerce() {
|
||||
|
||||
global $woocommerce, $woocommerce_settings;
|
||||
global $woocommerce_settings;
|
||||
|
||||
// Include settings so that we can run through defaults
|
||||
include( 'admin-settings.php' );
|
||||
|
||||
// Define post types before we start
|
||||
woocommerce_post_type();
|
||||
include_once( 'admin-settings.php' );
|
||||
|
||||
// Do install
|
||||
woocommerce_default_options();
|
||||
|
@ -37,13 +25,27 @@ function install_woocommerce() {
|
|||
woocommerce_tables_install();
|
||||
woocommerce_default_taxonomies();
|
||||
|
||||
// Flush Rules
|
||||
flush_rewrite_rules( false );
|
||||
|
||||
// Update version
|
||||
update_option( "woocommerce_db_version", WOOCOMMERCE_VERSION );
|
||||
|
||||
// Flag installed so we can redirect
|
||||
update_option( "woocommerce_installed", 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Install woocommerce redirect
|
||||
*/
|
||||
add_action('admin_init', 'install_woocommerce_redirect');
|
||||
function install_woocommerce_redirect() {
|
||||
if (get_option('woocommerce_installed')==1) :
|
||||
update_option( "woocommerce_installed", 0 );
|
||||
flush_rewrite_rules( false );
|
||||
wp_redirect(admin_url('admin.php?page=woocommerce&installed=true'));
|
||||
exit;
|
||||
endif;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default options
|
||||
*
|
||||
|
|
|
@ -589,6 +589,11 @@ function woocommerce_settings() {
|
|||
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your settings have been saved.', 'woothemes' ) . '</strong></p></div>';
|
||||
flush_rewrite_rules( false );
|
||||
endif;
|
||||
|
||||
if (isset($_GET['installed']) && $_GET['installed']) :
|
||||
echo '<div id="message" class="updated fade"><p><strong>' . __( 'WooCommerce has been installed. Enjoy :)', 'woothemes' ) . '</strong></p></div>';
|
||||
flush_rewrite_rules( false );
|
||||
endif;
|
||||
?>
|
||||
<div class="wrap woocommerce">
|
||||
<form method="post" id="mainform" action="">
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
.icon32-posts-shop_coupon{background-position:-475px -6px !important;}
|
||||
.icon32-posts-product_variation{background-position:-533px -6px !important;}
|
||||
.icon32-woocommerce-reports{background-position:-591px -6px !important;}
|
||||
.wrap.woocommerce div.updated{margin-top:10px;}
|
||||
.order_actions{color:#999;font-size:11px;}.order_actions li{border-top:1px solid #fff;border-bottom:1px solid #ddd;padding:6px;margin:0;line-height:1.6em;}
|
||||
#woocommerce-order-items .inside{margin:0;padding:0;background:#fefefe;}
|
||||
#woocommerce-order-items .buttons{float:left;padding-left:6px;vertical-align:top;}#woocommerce-order-items .buttons .item_id{width:300px;vertical-align:top;}
|
||||
|
|
|
@ -55,6 +55,10 @@
|
|||
background-position: -591px -6px !important;
|
||||
}
|
||||
|
||||
.wrap.woocommerce div.updated {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* Orders */
|
||||
.order_actions {
|
||||
color: #999;
|
||||
|
|
|
@ -33,7 +33,7 @@ if (is_admin()) :
|
|||
/**
|
||||
* Installs and upgrades
|
||||
**/
|
||||
register_activation_hook( __FILE__, 'queue_install_woocommerce' );
|
||||
register_activation_hook( __FILE__, 'install_woocommerce' );
|
||||
|
||||
if (get_site_option('woocommerce_db_version') != WOOCOMMERCE_VERSION) add_action('init', 'install_woocommerce', 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue