Skip to content

Commit

Permalink
Merge pull request #35 from pluginever/release/1.1.1
Browse files Browse the repository at this point in the history
Release/1.1.1
  • Loading branch information
devsabbirhossain authored Oct 23, 2024
2 parents 650c138 + 349102f commit 01ad211
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 32 deletions.
86 changes: 86 additions & 0 deletions .assets/css/halloween.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
.notice.notice-halloween {
position: relative;
background-image: url('../images/halloween-banner.svg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border: 1px solid #5900a8;
border-left-width: 4px;
.notice-content {
max-width: 75%;
color: #ffffff;
h3 {
color: #ffffff;
font-size: 1.6rem;
line-height: 1.3;
}
p {
font-size: .9rem;
line-height: 1.6;
}
}
.notice-footer {
justify-content: space-between;
border-top: 1px solid #5900a8;
.footer-btn {
display: flex;
gap: 20px;
}
.halloween-upgrade-btn {
background-color: #ffffff;
padding: 5px 12px;
color: #4203A0;
border-radius: 3px;
&:hover{
background-color: #D6CDE4;
}
}
.halloween-remind-btn {
background-color: #FFFFFF52;
padding: 5px 12px;
color: #FFFFFF;
border-radius: 3px;
&:hover{
background-color: #FFFFFF66;
}
}
.halloween-remove-btn {
color: #ffffff;
&:hover{
color: #D6CDE4;
}
}
.halloween-dismiss-btn{
position: absolute;
top: 20px;
right: 30px;
color: #FFFFFF;
&:hover {
color: #D6CDE4;
}
}
.halloween-footer-text {
float: right;
color: #ffffff;
}
}
@media screen and (max-width: 500px ) {
background-position:right;
.notice-body {
align-items: flex-start;
padding-top: 36px;
}
.notice-footer {
flex-direction: column;
.footer-btn {
flex-direction: column;
align-items: center;
gap: 10px;
}
.halloween-dismiss-btn {
top: 8px;
right: 20px;
}
}
}
}
35 changes: 35 additions & 0 deletions .assets/images/halloween-banner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions .assets/images/halloween-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions includes/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'woocommerce_save_product_variation', array( $this, 'wc_variation_images_save_product_variation' ), 10, 1 );
add_action( 'admin_footer', array( $this, 'admin_template_js' ) );
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), PHP_INT_MAX );
add_filter( 'update_footer', array( $this, 'update_footer' ), PHP_INT_MAX );
}

/**
Expand All @@ -40,6 +42,7 @@ public function __construct() {
* @return void
*/
public function admin_scripts_handler() {
wc_variation_images()->scripts->register_style( 'wc-variation-images-halloween', 'css/halloween.css' );
wp_enqueue_style( 'wc-variation-images', WC_VARIATION_IMAGES_ASSETS_URL . 'css/admin.css', array(), WC_VARIATION_IMAGES_VERSION );
wp_register_script( 'wc-variation-images', WC_VARIATION_IMAGES_ASSETS_URL . 'js/admin.js', array( 'jquery' ), WC_VARIATION_IMAGES_VERSION, true );
wp_localize_script(
Expand Down Expand Up @@ -202,4 +205,42 @@ public function wc_variation_images_save_product_variation( $variation_id ) {
}
update_post_meta( $variation_id, 'wc_variation_images_variation_images', $attachment_ids );
}

/**
* Admin footer text.
*
* @param string $footer_text Footer text.
*
* @since 1.1.1
* @return string
*/
public function admin_footer_text( $footer_text ) {
if ( wc_variation_images()->get_review_url() && in_array( get_current_screen()->id, array( 'toplevel_page_wc-variation-images' ), true ) ) {
$footer_text = sprintf(
/* translators: 1: Plugin name 2: WordPress */
__( 'Thank you for using %1$s. If you like it, please leave us a %2$s rating. A huge thank you from PluginEver in advance!', 'wc-variation-images' ),
'<strong>' . esc_html( wc_variation_images()->get_name() ) . '</strong>',
'<a href="' . esc_url( wc_variation_images()->get_review_url() ) . '" target="_blank" class="wc-variation-images-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'wc-variation-images' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
);
}

return $footer_text;
}

/**
* Update footer.
*
* @param string $footer_text Footer text.
*
* @since 1.1.1
* @return string
*/
public function update_footer( $footer_text ) {
if ( in_array( get_current_screen()->id, array( 'toplevel_page_wc-variation-images' ), true ) ) {
/* translators: 1: Plugin version */
$footer_text = sprintf( esc_html__( 'Version %s', 'wc-variation-images' ), wc_variation_images()->get_version() );
}

return $footer_text;
}
}
15 changes: 15 additions & 0 deletions includes/Admin/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ public function admin_notices() {
$installed_time = get_option( 'wc_variation_images_installed' );
$current_time = wp_date( 'U' );

// Halloween offer notice.
$halloween_time = date_i18n( strtotime( '2024-11-11 00:00:00' ) );
if ( $current_time < $halloween_time ) {
wp_enqueue_style( 'wc-variation-images-halloween' );
wc_variation_images()->notices->add(
array(
'message' => __DIR__ . '/views/notices/halloween.php',
'dismissible' => false,
'notice_id' => 'wc_variation_images_promotion',
'style' => 'border-left-color: #8500ff;',
'class' => 'notice-halloween',
)
);
}

if ( ! defined( 'WC_VARIATION_IMAGES_PRO_VERSION' ) ) {
wc_variation_images()->notices->add(
array(
Expand Down
56 changes: 56 additions & 0 deletions includes/Admin/views/notices/halloween.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Admin Halloween notice.
*
* @since 1.1.1
* @return void
*
* @package WooCommerceVariationImages\Admin\Notices
*/

defined( 'ABSPATH' ) || exit;

?>
<div class="notice-body">
<div class="notice-icon">
<img src="<?php echo esc_url( wc_variation_images()->get_assets_url( 'images/halloween-icon.svg' ) ); ?>" alt="WC Variation images">
</div>
<div class="notice-content">
<h3>
<?php esc_html_e( 'Limited Time Offer! PluginEver Halloween Sale: 30% OFF!!', 'wc-variation-images' ); ?>
</h3>
<p>
<?php
echo wp_kses_post(
sprintf(
// translators: 1.Offer Percentage, 2. Coupon Code.
__( 'Spectacular Halloween Deal! Get %1$s on all premium plugins with code %2$s. Don\'t miss out — this offer vanishes soon! 👻', 'wc-variation-images' ),
'<strong>' . esc_attr( '30% OFF' ) . '</strong>',
'<strong>' . esc_attr( 'BIGTREAT30' ) . '</strong>'
)
);
?>
</p>
</div>
</div>
<div class="notice-footer">
<div class="footer-btn">
<a href="<?php echo esc_url( wc_variation_images()->plugin_uri . '?utm_source=plugin&utm_medium=notice&utm_campaign=halloween-2024&discount=bigtreat30' ); ?>" class="primary halloween-upgrade-btn" target="_blank">
<span class="dashicons dashicons-cart"></span>
<?php esc_html_e( 'Claim your discount!!', 'wc-variation-images' ); ?>
</a>
<a href="#" class="halloween-remind-btn" data-snooze="<?php echo esc_attr( WEEK_IN_SECONDS ); ?>">
<span class="dashicons dashicons-clock"></span>
<?php esc_html_e( 'Remind me later', 'wc-variation-images' ); ?>
</a>
<a href="#" class="primary halloween-remove-btn" data-dismiss>
<span class="dashicons dashicons-remove"></span>
<?php esc_html_e( 'Never show this again!', 'wc-variation-images' ); ?>
</a>
<a href="#" class="primary halloween-dismiss-btn" data-dismiss>
<span class="dashicons dashicons-dismiss"></span>
<?php esc_html_e( 'DISMISS', 'wc-variation-images' ); ?>
</a>
</div>
<strong class="halloween-footer-text"><?php esc_html_e( 'Valid until November 10, 2024', 'wc-variation-images' ); ?></strong>
</div>
Loading

0 comments on commit 01ad211

Please sign in to comment.