Adjusts the 'try Storefront' button on the 'Addons' screen to be more contextual, depending on the current theme/child theme combination activated.

This commit is contained in:
Matty 2015-11-19 14:27:34 +02:00
parent 50f96217c3
commit 4fc1023d0a
2 changed files with 33 additions and 1 deletions

View File

@ -17,6 +17,38 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Admin_Addons {
/**
* Handles the outputting of a contextually aware Storefront link (points to child themes if Storefront is already active).
*/
public static function output_storefront_button() {
$url = '';
$text = '';
$template = get_option( 'template' );
$stylesheet = get_option( 'stylesheet' );
// If we're using Storefront with a child theme.
if ( 'storefront' == $template && 'storefront' != $stylesheet ) {
$url = 'http:///www.woothemes.com/product-category/themes/storefront-child-theme-themes/';
$text = __( 'View more Storefront child themes', 'woocommerce' );
}
// If we're using Storefront without a child theme.
if ( 'storefront' == $template && 'storefront' == $stylesheet ) {
$url = 'http:///www.woothemes.com/product-category/themes/storefront-child-theme-themes/';
$text = __( 'Need a fresh look? Try Storefront child themes', 'woocommerce' );
}
// If we're not using Storefront at all.
if ( 'storefront' != $template && 'storefront' != $stylesheet ) {
$url = 'http://www.woothemes.com/storefront/';
$text = __( 'Need a theme? Try Storefront', 'woocommerce' );
}
if ( '' != $url && '' != $text ) {
echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
}
}
/**
* Handles output of the reports page in admin.
*/

View File

@ -19,7 +19,7 @@ $theme = wp_get_theme();
<h2>
<?php _e( 'WooCommerce Add-ons/Extensions', 'woocommerce' ); ?>
<a href="http://www.woothemes.com/product-category/woocommerce-extensions/" class="add-new-h2"><?php _e( 'Browse all extensions', 'woocommerce' ); ?></a>
<a href="http://www.woothemes.com/storefront/" class="add-new-h2"><?php _e( 'Need a theme? Try Storefront', 'woocommerce' ); ?></a>
<?php WC_Admin_Addons::output_storefront_button( $theme ); ?>
</h2>
<?php if ( $addons ) : ?>
<ul class="subsubsub">