Friendlier installer

This commit is contained in:
Mike Jolley 2012-02-15 17:31:44 +00:00
parent b946c532b2
commit d559c5cc87
7 changed files with 103 additions and 42 deletions

View File

@ -104,30 +104,6 @@ function woocommerce_prevent_admin_access() {
endif;
}
/**
* Redirect to settings after installation
*/
function install_woocommerce_redirect() {
global $pagenow, $woocommerce;
if ( is_admin() && isset( $_GET['activate'] ) && ($_GET['activate'] == true) && $pagenow == 'plugins.php' && get_option( "woocommerce_installed" ) == 1 ) :
// Clear transient cache
$woocommerce->clear_product_transients();
// Unset installed flag
update_option( "woocommerce_installed", 0 );
// Flush rewrites
flush_rewrite_rules( false );
// Redirect to settings
wp_redirect(admin_url('admin.php?page=woocommerce&installed=true'));
exit;
endif;
}
/**
* Fix 'insert into post' buttons for images
**/

View File

@ -34,6 +34,29 @@ function woocommerce_admin_menu() {
foreach ($print_css_on as $page) add_action( 'admin_print_styles-'. $page, 'woocommerce_admin_css' );
}
/**
* Admin Notices
*/
add_action( "admin_print_styles", 'woocommerce_admin_notices_styles' );
function woocommerce_admin_notices() {
?>
<div id="message" class="updated woocommerce-message wc-connect">
<div class="squeezer">
<h4><?php _e( '<strong>Welcome to WooCommerce</strong> &#8211; Your almost ready to start selling :)', 'woocommerce' ); ?></h4>
<p class="submit"><a href="<?php echo add_query_arg('install_woocommerce_pages', 'true', admin_url('admin.php?page=woocommerce')); ?>" class="button-primary"><?php _e( 'Install WooCommerce Pages', 'woocommerce' ); ?></a> <a class="skip button-primary" href="<?php echo add_query_arg('skip_install_woocommerce_pages', 'true', admin_url('admin.php?page=woocommerce')); ?>"><?php _e('Skip setup', 'woocommerce'); ?></a></p>
</div>
</div>
<?php
}
function woocommerce_admin_notices_styles() {
if (get_option('woocommerce_installed')!=1 || get_option('skip_install_woocommerce_pages')==1 || woocommerce_get_page_id('shop')>0 || isset($_GET['install_woocommerce_pages']) || isset($_GET['skip_install_woocommerce_pages'])) return;
add_action( 'admin_notices', 'woocommerce_admin_notices' );
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/wc-activation.css', dirname( __FILE__ ) ) );
}
/**
* Admin Includes - loaded conditionally
*/
@ -82,8 +105,8 @@ function woocommerce_attributes_page() {
*/
function activate_woocommerce() {
include_once( 'woocommerce-admin-install.php' );
update_option( "woocommerce_installed", 1 );
update_option( 'skip_install_woocommerce_pages', 0 );
update_option( 'woocommerce_installed', 1 );
do_install_woocommerce();
}
function install_woocommerce() {

View File

@ -45,6 +45,9 @@ function do_install_woocommerce() {
// Update version
update_option( "woocommerce_db_version", $woocommerce->version );
// Flush rewrites
flush_rewrite_rules( false );
}
/**

View File

@ -1048,6 +1048,7 @@ function woocommerce_settings() {
// Add pages button
if (isset($_GET['install_woocommerce_pages']) && $_GET['install_woocommerce_pages']) :
require_once( 'woocommerce-admin-install.php' );
woocommerce_create_pages();
update_option('skip_install_woocommerce_pages', 1);
@ -1060,32 +1061,19 @@ function woocommerce_settings() {
$install_complete = true;
// If we have just activated WooCommerce...
elseif (isset($_GET['installed']) && $_GET['installed']) :
elseif (get_option('woocommerce_installed')==1) :
flush_rewrite_rules( false );
if (woocommerce_get_page_id('shop')>0) :
$install_complete = true;
else :
$show_page_installer = true;
endif;
// If we havn't just installed, but page installed has not been skipped and shop page does not exist...
elseif (!get_option('skip_install_woocommerce_pages') && !woocommerce_get_page_id('shop')) :
$show_page_installer = true;
endif;
if ($show_page_installer) :
echo '<div id="message" class="updated fade">
<p><strong>' . __( 'Welcome to WooCommerce!', 'woocommerce' ) . '</strong></p>
<p>'. __('WooCommerce requires several WordPress pages containing shortcodes in order to work correctly; these include Shop, Cart, Checkout and My Account. To add these pages automatically please click the \'Automatically add pages\' button below, otherwise you can set them up manually. See the \'Pages\' tab in settings for more information.', 'woocommerce') .'</p>
<p><a href="'.remove_query_arg('installed', add_query_arg('install_woocommerce_pages', 'true')).'" class="button button-primary">'. __('Automatically add pages', 'woocommerce') .'</a> <a href="'.remove_query_arg('installed', add_query_arg('skip_install_woocommerce_pages', 'true')).'" class="button">'. __('Skip setup', 'woocommerce') .'</a></p>
</div>';
elseif ($install_complete) :
if ($install_complete) :
update_option('woocommerce_installed', 0);
echo '<div id="message" class="updated fade">
<p style="float:right;">' . __( 'Like WooCommerce? <a href="http://wordpress.org/extend/plugins/woocommerce/">Support us by leaving a rating!</a>', 'woocommerce' ) . '</p>

View File

@ -0,0 +1,70 @@
.woocommerce-message {
position: relative;
z-index: 100;
border: 1px solid #b76ca9 !important;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 15px rgba( 0,0,0,0.04 );
-moz-box-shadow: inset 0 0 15px rgba( 0,0,0,0.04 );
box-shadow: inset 0 0 15px rgba( 0,0,0,0.04 );
overflow: hidden;
line-height: 180%;
padding: 10px 0 5px !important;
background: #cc99c2 url(../images/message.png) no-repeat right bottom !important;
}
.woocommerce-message .squeezer {
max-width: 940px;
margin: 0 0 2px;
padding: 0 10px;
text-align: left;
overflow: hidden;
}
.woocommerce-message h4 {
margin: 0 10px 10px 0;
font-size: 18px;
font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;
font-weight: normal;
color: #fff;
text-shadow: 0px 1px 1px #b574a8;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
display: inline-block;
}
.woocommerce-message p {
margin: -1px 0 0 0 !important;
padding: 0;
display: inline-block;
}
.woocommerce-message p a.button-primary {
font-size: 16px !important;
display: inline-block;
padding: 8px 15px;
color: #fff;
text-align: center;
text-decoration: none;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
border: 1px solid #88537e;
background: #a46497;
-moz-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 );
-webkit-box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 );
box-shadow: inset 0 0 2px rgba( 255,255,255,1), 0 1px 1px rgba( 0,0,0,0.1 );
text-shadow: 0px -1px 0px rgba( 0,0,0,0.3);
-webkit-transition-duration: .3s;
-moz-transition-duration: .3s;
cursor: pointer;
font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",Verdana,"Bitstream Vera Sans",sans-serif;
}
.woocommerce-message p a.button-primary:hover, .woocommerce-message p a.button-primary:active {
background-color: #f0a000;
border-color: #c87800;
-webkit-transition-duration: .3s;
outline: none;
opacity: 1;
}
.woocommerce-message p a.skip {
opacity: 0.5;
}

BIN
assets/images/message.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -101,6 +101,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Quantity based on stock limit on cart page, like the product page
* Fixed category widget hierarchy
* Password error on checkout
* Improved install process
= 1.4.2 - 09/02/2012 =
* Uninstall fix