Skip to content

Commit

Permalink
step #5 - template 9 integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithabdulrahman committed Nov 10, 2021
1 parent b6cb708 commit 713ec23
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/admin/css/dist/admin.min.css

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions assets/admin/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jQuery(document).ready(function ($) {
SIX: 'Template Six',
SEVEN: 'Template Seven',
EIGHT: 'Template Eight',
NINE: 'Template Nine',
};
var couponTypes = {
COUPON: 'Coupon',
Expand Down Expand Up @@ -762,7 +763,7 @@ jQuery(document).ready(function ($) {

function wpcd_onCouponTemplateFieldChange() {
var currentTemplate = $(this).val();

console.log("currentTemplate: ",currentTemplate)
if (
currentTemplate === templates.TWO ||
currentTemplate === templates.SIX ||
Expand Down Expand Up @@ -1617,6 +1618,7 @@ jQuery(document).ready(function ($) {
SIX: 'Template Six',
SEVEN: 'Template Seven',
EIGHT: 'Template Eight',
NINE: 'Template Nine',

};
var couponTypes = {
Expand All @@ -1628,6 +1630,7 @@ jQuery(document).ready(function ($) {
var couponPreview = previewWrap.find('.wpcd-coupon-preview');
var couponDefault = $('.wpcd-coupon');
var couponEight = $('.wpcd-coupon-eight');
var couponNine = $('.wpcd-coupon-nine');
var couponOne = $('.wpcd-coupon-one');
var couponTwo = $('.wpcd-coupon-two');
var couponThree = $('.wpcd-coupon-three');
Expand Down Expand Up @@ -1672,6 +1675,8 @@ jQuery(document).ready(function ($) {
couponSeven.show("slow");
} else if (currentTemplate === templates.EIGHT) {
couponEight.show('slow');
} else if (currentTemplate === templates.NINE) {
couponNine.show('slow');
}
}

Expand Down Expand Up @@ -1991,4 +1996,4 @@ function wpcd_ajax_import_success_count(success, returnData) {
if (success && returnData) {
return this.successCount;
}
}
}
2 changes: 1 addition & 1 deletion assets/css/dist/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jQuery(document).ready(function ($) {
};
wpcd_moreLessDescription();


console.log("here")
$.each($('#wpcd_cat_ul > li'), function () {
if ($(this).children('a').attr('href') === window.location.href) {
$(this).children('a').addClass('active');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public static function getFields()
'Template Six',
'Template Seven',
'Template Eight',
'Template Nine',
)
),
array(
Expand Down
28 changes: 28 additions & 0 deletions includes/classes/wpcd-preview-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,34 @@ class="wpcd-btn masterTooltip wpcd-deal-button"
</div>
</div><!-- End of Default Preview -->
<!-- Template Nine Preview -->
<div class="wpcd-coupon-preview wpcd-coupon-nine">
<div class="wpcd-coupon-content wpcd-col-2-8">
<div class="wpcd-coupon-nine-header">
<div class="wpcd-col-1-4">
<h1 class="wpcd-coupon-title">
<a href="#" target="_blank" rel="nofollow">' . esc_html( $title ) . '</a></h1>
</div>
<div class="wpcd-col-1-4 second-div">
<div class="wpcd-coupon-not-hidden">
<div class="wpcd-coupon-code wpcd-col-2-4">
<button
class="wpcd-btn masterTooltip wpcd-coupon-button"
title="' . esc_attr( $coupon_hover_text ) . '"
data-clipboard-text="'. esc_attr( $coupon_code ) . '">
<span class="wpcd_coupon_icon"></span>
<span class="coupon-code-button">' . esc_html( $coupon_code ) . '</span>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div><!-- End of Template Nine Preview -->
<!-- Template One Preview -->
<div class="wpcd-coupon-preview wpcd-coupon-one">
<div class="wpcd-col-one-1-8">
Expand Down
7 changes: 7 additions & 0 deletions includes/classes/wpcd-short-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ public static function wpcd_coupon( $atts ) {
$template->get_template_part( 'shortcode-eight__premium_only' );
$output = ob_get_clean();

} elseif ( $coupon_template == 'Template Nine' ) {

$argcss = 'shortcode_nine';
ob_start();
$template->get_template_part( 'shortcode-nine__premium_only' );
$output = ob_get_clean();

} else {

$argcss = 'shortcode_default';
Expand Down
120 changes: 120 additions & 0 deletions includes/templates/shortcode/shortcode-nine__premium_only.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

/**
*
* This exits from the script if it's accessed
* directly from somewhere else.
*
*/
if (!defined('ABSPATH')) {
exit;
}

/**
* This is the default Shortcode template.
*
* @since 1.2
*/
global $coupon_id;
$title = get_the_title();
$description = get_post_meta($coupon_id, 'coupon_details_description', true);
$discount_text = get_post_meta($coupon_id, 'coupon_details_discount-text', true);
$coupon_type = get_post_meta($coupon_id, 'coupon_details_coupon-type', true);
$link = get_post_meta($coupon_id, 'coupon_details_link', true);
$coupon_code = get_post_meta($coupon_id, 'coupon_details_coupon-code-text', true);
$show_print_links = get_option('wpcd_coupon-print-link');
$deal_text = get_post_meta($coupon_id, 'coupon_details_deal-button-text', true);
$show_expiration = get_post_meta($coupon_id, 'coupon_details_show-expiration', true);
$expire_date = get_post_meta($coupon_id, 'coupon_details_expire-date', true);
$expireDateFormat = get_option('wpcd_expiry-date-format');
$hide_coupon = get_post_meta($coupon_id, 'coupon_details_hide-coupon', true);
$coupon_hover_text = get_option('wpcd_coupon-hover-text');
$deal_hover_text = get_option('wpcd_deal-hover-text');
$no_expiry = get_option('wpcd_no-expiry-message');
$expire_text = get_option('wpcd_expire-text');
$expired_text = get_option('wpcd_expired-text');
$hide_coupon_text = get_option('wpcd_hidden-coupon-text');
$hidden_coupon_hover_text = get_option('wpcd_hidden-coupon-hover-text');
$copy_button_text = get_option('wpcd_copy-button-text');
$coupon_title_tag = get_option('wpcd_coupon-title-tag', 'h1');
$coupon_share = get_option('wpcd_coupon-social-share');
$dt_coupon_type_name = get_option('wpcd_dt-coupon-type-text');
$dt_deal_type_name = get_option('wpcd_dt-deal-type-text');
$disable_coupon_title_link = get_option('wpcd_disable-coupon-title-link');
$wpcd_text_to_show = get_option('wpcd_text-to-show');
$wpcd_custom_text = get_option('wpcd_custom-text');
$wpcd_eight_btn_text = get_option('wpcd_eight-button-text');
$today = date('d-m-Y');
$button_class = 'wpcd-btn-' . $coupon_id;

$dt_coupon_type_name = (!empty($dt_coupon_type_name)) ? $dt_coupon_type_name : __('Coupon', 'wp-coupons-and-deals');
$dt_deal_type_name = (!empty($dt_deal_type_name)) ? $dt_deal_type_name : __('Deal', 'wp-coupons-and-deals');
$expire_text = (!empty($expire_text)) ? $expire_text : __('Expires On: ', 'wp-coupons-and-deals');
$expired_text = (!empty($expired_text)) ? $expired_text : __('Expired On: ', 'wp-coupons-and-deals');
$no_expiry = (!empty($no_expiry)) ? $no_expiry : __("Doesn't expire", 'wp-coupons-and-deals');
$coupon_code = (!empty($coupon_code) ? $coupon_code : __('COUPONCODE', 'wp-coupons-and-deals'));
$deal_text = (!empty($deal_text) ? $deal_text : __('Claim This Deal', 'wp-coupons-and-deals'));
$coupon_hover_text = (!empty($coupon_hover_text)) ? $coupon_hover_text : __('Click To Copy Coupon', 'wp-coupons-and-deals');
$deal_hover_text = (!empty($deal_hover_text)) ? $deal_hover_text : __('Click Here To Get This Deal');
$wpcd_eight_btn_text = (!empty($wpcd_eight_btn_text)) ? $wpcd_eight_btn_text : __('GET THE DEAL', 'wp-coupons-and-deals');

$wpcd_template_eight_theme = get_post_meta($coupon_id, 'coupon_details_template-eight-theme', true);

$linkTarget = get_option("wpcd_coupon-link-target");
$target = ($linkTarget == "on") ? "_self" : "_blank";

if ($wpcd_text_to_show == 'description') {
$wpcd_custom_text = $description;
} else if (empty($wpcd_custom_text)) {
$wpcd_custom_text = __("Click on 'Copy' to Copy the Coupon Code.", 'wp-coupons-and-deals');
}
if (!$link && WPCD_Amp::wpcd_amp_is()) $link = "#";

$expireDateFormatFun = wpcd_getExpireDateFormatFun($expireDateFormat);
if (!empty($expire_date) && (string)(int)$expire_date == $expire_date) {
$expire_date = date($expireDateFormatFun, $expire_date);
}

wp_enqueue_script('wpcd-clipboardjs');
$template = new WPCD_Template_Loader();

$wpcd_uniq_attr = '';
if (function_exists('wpcd_uniq_attr') && !WPCD_Amp::wpcd_amp_is() &&
!empty($show_print_links) && $show_print_links == 'on') {
$wpcd_uniq_attr = wpcd_uniq_attr(10);
}

?>

<!-- Template Nine Preview -->
<div class="wpcd-coupon-preview wpcd-coupon-nine">

<div class="wpcd-coupon-content wpcd-col-2-8">
<div class="wpcd-coupon-nine-header">
<div class="wpcd-col-1-4">
<h1 class="wpcd-coupon-title">
<a href="#" target="_blank" rel="nofollow"><?= esc_html($title) ?></a></h1>
</div>
<div class="wpcd-col-1-4 second-div">
<div class="wpcd-coupon-not-hidden">
<div class="wpcd-coupon-code wpcd-col-2-4">
<button
class="wpcd-btn masterTooltip wpcd-coupon-button"
title="<?= esc_html($coupon_hover_text) ?>"
data-clipboard-text="<?= esc_html($coupon_code) ?>">
<span class="wpcd_coupon_icon"></span>
<span class="coupon-code-button"><?= esc_html($coupon_code) ?></span>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div><!-- End of Template Nine Preview -->

<?php
if (!WPCD_Amp::wpcd_amp_is() && !empty($show_print_links) && $show_print_links == 'on') {
// wpcd_coupon_print_link($wpcd_uniq_attr);
}
?>

0 comments on commit 713ec23

Please sign in to comment.