Tweak rating prompt text on click, and change once rated

@bftrick This is to keep the .org folk happy and look less spammy :)
This commit is contained in:
Mike Jolley 2015-02-19 11:38:35 +00:00
parent 049abcfdd3
commit 2caf287258
2 changed files with 21 additions and 2 deletions

View File

@ -164,7 +164,17 @@ class WC_Admin {
// Check to make sure we're on a WooCommerce admin page
if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages ) ) ) {
// Change the footer text
$footer_text = sprintf( __( 'If you like <strong>WooCommerce</strong> please leave us a <a href="%1$s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating on <a href="%1$s" target="_blank">WordPress.org</a>. A huge thank you from WooThemes in advance!', 'woocommerce' ), 'https://wordpress.org/support/view/plugin-reviews/woocommerce?filter=5#postform' );
if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
$footer_text = sprintf( __( 'If you like <strong>WooCommerce</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s rating. A huge thank you from WooThemes in advance!', 'woocommerce' ), '<a href="https://wordpress.org/support/view/plugin-reviews/woocommerce?filter=5#postform" target="_blank" class="wc-rating-link" data-rated="' . __( 'Thanks :)', 'woocommerce' ) . '">', '</a>' );
wc_enqueue_js( "
jQuery('a.wc-rating-link').click(function() {
jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );
jQuery(this).parent().text( jQuery(this).data( 'rated' ) );
});
" );
} else {
$footer_text = __( 'Thank you for selling with WooCommerce.', 'woocommerce' );
}
}
return $footer_text;

View File

@ -65,7 +65,8 @@ class WC_AJAX {
'term_ordering' => false,
'product_ordering' => false,
'refund_line_items' => false,
'delete_refund' => false
'delete_refund' => false,
'rated' => false
);
foreach ( $ajax_events as $ajax_event => $nopriv ) {
@ -1969,6 +1970,14 @@ class WC_AJAX {
die();
}
/**
* Triggered when clicking the rating footer.
*/
public static function rated() {
update_option( 'woocommerce_admin_footer_text_rated', 1 );
die();
}
}
WC_AJAX::init();