فهرست منبع

coupon插件修改

chengwl 5 سال پیش
والد
کامیت
d96730235f

+ 3 - 0
wp-content/plugins/coupon-creator/languages/coupon-creator.pot

@@ -762,6 +762,9 @@ msgstr ""
 msgid "Deal"
 msgstr ""
 
+msgid "ly_link"
+msgstr "营销连接"
+
 #: src/Cctor/Meta/Fields.php:522
 msgid "Enter coupon deal - 30% OFF! or Buy One Get One Free, etc..."
 msgstr ""

+ 37 - 0
wp-content/plugins/coupon-creator/plugin-engine/src/Pngx/Admin/Ajax.php

@@ -25,9 +25,11 @@ class Pngx__Admin__Ajax {
 		add_action( 'wp_ajax_pngx_variety',  array( $this, 'load_variety' ) );
 
 		add_action( 'wp_ajax_pngx_repeatable',  array( $this, 'load_repeatable' ) );
+		add_action( 'wp_ajax_coupon_info',  array( $this, 'coupon_info' ) );
 
 	}
 
+
 	public function load_templates() {
 
 		// End if not the correct action
@@ -283,5 +285,40 @@ class Pngx__Admin__Ajax {
 		wp_send_json_success( json_encode( $template_fields ) );
 
 	}
+	public function coupon_info(){
+		// End if not the correct action
+		if ( ! isset( $_POST['action'] ) || 'coupon_info' !== $_POST['action'] ) {
+			wp_send_json_error( __( 'A Permission Error has occurred. Please save, reload, and try again.', 'plugin-engine' ) );
+		}
+
+		// End if not correct nonce
+		if ( ! isset( $_POST['nonce'] )) {
+			wp_send_json_error( __( 'Permission Error has occurred. Please save, reload, and try again.', 'plugin-engine' ) );
+		}
+
+		// if ( ! isset( $_POST['option'] ) ) {
+		// 	wp_send_json_error( __( 'No Template ID. Please save, reload, and try again.', 'plugin-engine' ) );
+		// }
+		Pngx__Main::instance()->doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
+		$cctor_args = array(
+			'p'                     => $_POST['coupon_id'],
+			'post_type'             => 'cctor_coupon',
+			'post_status'           => 'publish',
+		);
+		$coupons = new WP_Query( $cctor_args );
+		$info=[];
+		if ( $coupons->have_posts() ) {
+			$coupons->the_post();
+			$meta = get_post_meta($coupons->post->ID, '', true );
+			$info=[
+				'title'=>$coupons->post->post_title,
+				'link'=>$meta['cctor_ly_link'][0],
+				'code'=>$meta['cctor_ly_link_code'][0],
+				'shopname'=>$meta['cctor_ly_shop_name'][0],
+			];
+		}
+
+		wp_send_json_success($info);
+	}
 
 }

+ 13 - 7
wp-content/plugins/coupon-creator/plugin-engine/src/Pngx/Admin/Meta.php

@@ -199,6 +199,7 @@ class Pngx__Admin__Meta {
 					$fields = $this->get_fields();
 
 					foreach ( $fields as $field ) {
+					
 
 						if (
 							isset( $field['section'] ) &&
@@ -208,9 +209,11 @@ class Pngx__Admin__Meta {
 								$tab_slug === $field['tab']
 							)
 						) {
+						
+				
 							// get value of this field if it exists for this post
 							$meta = get_post_meta( $post->ID, $field['id'], true );
-
+							
 							//Wrap Class for Conditionals
 							$wrapclass = isset( $field['wrapclass'] ) ? $field['wrapclass'] : '';
 
@@ -236,6 +239,7 @@ class Pngx__Admin__Meta {
 								<?php
 								continue;
 							}
+					
 
 							//if in template area only get fields with the template value
 							if ( $template_area ) {
@@ -243,11 +247,12 @@ class Pngx__Admin__Meta {
 								if ( ! in_array( $template_area, $field_template ) ) {
 									continue;
 								}
-
-							} elseif ( ! $template_area && isset( $field['template'] ) ) {
-								//if not template area set, but there is a template then do not display the field
-								continue;
 							}
+							// } elseif ( ! $template_area && isset( $field['template'] ) ) {
+							// 	//if not template area set, but there is a template then do not display the field
+							// 	continue;
+							// }
+						
 
 							if ( 'wrap-start' === $field['type'] ) {
 								?>
@@ -268,9 +273,10 @@ class Pngx__Admin__Meta {
 								<?php
 								continue;
 							}
-
+						
+						
 							?>
-
+		
 							<div class="pngx-meta-field-wrap field-wrap-<?php echo esc_html( $field['type'] ); ?> field-wrap-<?php echo esc_html( $field['id'] ); ?> <?php echo esc_html( $wrapclass ); ?>"
 								<?php echo isset( $field['toggle'] ) ? Pngx__Admin__Fields::toggle( $field['toggle'], esc_attr( $field['id'] ) ) : null; ?> >
 

+ 0 - 1
wp-content/plugins/coupon-creator/src/Cctor/Admin/Fields.php

@@ -42,7 +42,6 @@ class Cctor__Coupon__Admin__Fields {
 				break;
 
 			case 'pro_link':
-
 				Cctor__Coupon__Admin__Field__Pro_Link::display( $field, $options, $options_id, $meta );
 
 				break;

+ 22 - 1
wp-content/plugins/coupon-creator/src/Cctor/Assets.php

@@ -134,7 +134,28 @@ class Cctor__Coupon__Assets {
 			filemtime( pngx( 'cctor' )->resource_path . 'css/coupon.css' )
 		);
 		// @formatter:on
-
+		// @formatter:off
+		wp_enqueue_script(
+			'cctor_test_js',
+			pngx( 'cctor' )->resource_url . 'js/coupon-test.js',
+			array(
+				'jquery',
+				// 'media-upload',
+				// 'thickbox',
+				// 'farbtastic',
+				// 'pngx-admin'
+			),
+			filemtime( pngx( 'cctor' )->resource_path . 'js/coupon-test.js' ),
+			true
+		);
+		// @formatter:on
+		// @formatter:off
+		wp_localize_script( 'cctor_test_js', 'pngx_app_ajax', array(
+			'ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ),
+			'nonce'   => wp_create_nonce( 'pngx_' . $post->ID ),
+			'post_id' => $post->ID
+		) );
+		// @formatter:on
 	}
 
 	/*

+ 34 - 0
wp-content/plugins/coupon-creator/src/Cctor/Meta/Fields.php

@@ -444,6 +444,40 @@ class Cctor__Coupon__Meta__Fields {
 			'tab'     => 'links',
 			'priority' => 20.00,
 		);
+		$fields[ $prefix . 'ly_link' ] = array(
+			'label'     => __( 'ly_link', 'coupon-creator' ),
+			'desc'      =>'填写优惠券连接',
+			'id'      => $prefix . 'ly_link',
+			'type'    => 'text',
+			'section' => 'coupon_creator_meta_box',
+			'template'  => array( 'default' ),
+			'tab'     => 'links',
+			'priority' => 20.01,
+		);
+		$fields[ $prefix . 'ly_link_code' ] = array(
+			'label'     => __( 'ly_link_code', 'coupon-creator' ),
+			'desc'      =>'填写优惠券code',
+			'id'      => $prefix . 'ly_link_code',
+			'type'    => 'text',
+			'section' => 'coupon_creator_meta_box',
+			'template'  => array( 'default' ),
+			'tab'     => 'links',
+			'priority' => 20.02,
+		);
+		$fields[ $prefix . 'ly_shop_name' ] = array(
+			'label'     => __( 'ly_shop_name', 'coupon-creator' ),
+			'desc'      =>'填写店铺名称',
+			'id'      => $prefix . 'ly_shop_name',
+			'type'    => 'text',
+			'section' => 'coupon_creator_meta_box',
+			'template'  => array( 'default' ),
+			'tab'     => 'links',
+			'priority' => 20.03,
+		);
+		
+
+
+
 
 		//Links
 		if ( ! defined( 'CCTOR_HIDE_UPGRADE' ) || ! CCTOR_HIDE_UPGRADE ) {

+ 3 - 0
wp-content/plugins/coupon-creator/src/functions/template-build/cctor-shortcode-build.php

@@ -29,6 +29,9 @@ function cctor_shortcode_functions() {
 
 	add_action('cctor_no_show_coupon', 'cctor_show_no_coupon_notice_admin', 10, 3 );
 
+	add_action('cctor_before_coupon_wrap', 'cctor_vodal_dialog', 10, 3 );
+
+
 	/**
 	 * Shortcode Template Hook for all Action and Filters
 	 *

+ 36 - 1
wp-content/plugins/coupon-creator/src/functions/template-functions/cctor-function-links.php

@@ -18,7 +18,7 @@ function cctor_show_img_coupon( $coupon_id, $couponimage ) {
 
 		//Set Image Link
 		?>
-		<a class="coupon_link" onclick='<?php echo esc_js( $cctor_onclick ); ?>' <?php echo $nofollow; ?> href='<?php echo esc_url( get_permalink( $coupon_id ) ); ?>' title='<?php echo __( 'Click to Open in Print View', 'coupon-creator' ); ?>'>
+		<a class="coupon_link"  <?php echo $nofollow; ?> href="javascript:void(0)"    data-coupon-id='<?php echo $coupon_id;?>'  data-ajax-action="coupon_info" title='<?php echo __( 'Click to Open in Print View', 'coupon-creator' ); ?>'>
 		<img class='cctor_coupon_image' src='<?php echo esc_url( $couponimage ); ?>' alt='<?php echo get_the_title( $coupon_id ); ?>' title='<?php echo __( 'Coupon', 'coupon-creator' ); ?> <?php echo get_the_title( $coupon_id ); ?>'>
 		</a><?php
 	} else {
@@ -27,7 +27,42 @@ function cctor_show_img_coupon( $coupon_id, $couponimage ) {
 	}
 
 }
+function cctor_vodal_dialog(){
+	?>
+	<div class="cover">
+        <!-- 弹出框 -->
+        <div class="vodal-dialog">
+            <!-- 关闭按钮 -->
+            <span class="vodal-close"></span>
+            <!-- load -->
+            <div class="row">
+                <div class="auto-redirect">
+					<!-- <div class="loadimg"><img src="img/load.gif"></div> -->
+					<div class="loadimg"><img src="<?php echo esc_url( pngx( 'cctor' )->resource_url )  ?>images/load.gif"></div>
+					<strong style="color:#333;padding-right: 12px;">Code Copied!</strong>
+                    Taking you to <span class="shopname"><span>
+                </div>
+            </div>
+            <div class="modal-body">
+                <section>
+                    <h4 class="coupon-title"></h4>
+                    <div class="cta">
+					<div class="instruction-subtitle">
 
+					</div>
+                        <a href="javascript:;" target="blank" class="btn-cta">
+                            Shop Now</a>
+					</div>
+					<div class="treatment">
+                        Copy this code to apply at checkout.
+                    </div>
+                </section>
+            </div>
+        </div>
+    </div>
+	<?php
+	
+}
 /*
 * Coupon Creator Click to Open in Print View Link
 * @version 1.90

+ 196 - 16
wp-content/plugins/coupon-creator/src/resources/css/coupon.css

@@ -1,8 +1,8 @@
-/*
-	Coupon Creator CSS
-
+/*
+	Coupon Creator CSS
+
 */
-/* Coupon Creator CSS
+/* Coupon Creator CSS
 ------------------------------------------------------------ */
 .cctor-coupon-container,
 .cctor_coupon_container {
@@ -25,7 +25,7 @@
   print-color-adjust: exact;
   -webkit-print-color-adjust: exact; }
 
-/* Standard CSS
+/* Standard CSS
 ------------------------------------------------------------ */
 .cctor-wrap-link,
 .cctor_wrap_link {
@@ -48,7 +48,7 @@
 .coupon-overflow {
   overflow: hidden; }
 
-/* Coupon Contents
+/* Coupon Contents
 ------------------------------------------------------------ */
 .cctor-coupon,
 .cctor_coupon {
@@ -172,7 +172,7 @@
   margin-top: 2px;
   width: 100%; }
 
-/* Coupon CSS Adjustments
+/* Coupon CSS Adjustments
 ------------------------------------------------------------ */
 .cctor_coupon_container a:hover {
   opacity: .8;
@@ -188,7 +188,7 @@ a .cctor_expiration {
 .cctor_terms p {
   margin: 0; }
 
-/* Print View CSS
+/* Print View CSS
 ------------------------------------------------------------ */
 .print-coupon .cctor-oupon-container,
 .print_coupon .cctor_coupon_container {
@@ -220,7 +220,7 @@ a .cctor_expiration {
   .cctor_opencoupon {
     display: none !important; } }
 
-/* Utility CSS
+/* Utility CSS
 ------------------------------------------------------------ */
 .cctor-clear {
   clear: both; }
@@ -234,7 +234,7 @@ a .cctor_expiration {
   content: "";
   display: block; }
 
-/* Coupon Align
+/* Coupon Align
 ------------------------------------------------------------ */
 .cctor-alignnone,
 .cctor_alignnone {
@@ -258,10 +258,10 @@ a .cctor_expiration {
   display: block;
   margin: 10px auto; }
 
-/* Column Classes
-* Modified from these links:
-* Link: http://wpsmith.net/2013/wp/genesis-2-0-drops-fifths-from-column-classes/
-* Link: http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css
+/* Column Classes
+* Modified from these links:
+* Link: http://wpsmith.net/2013/wp/genesis-2-0-drops-fifths-from-column-classes/
+* Link: http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css
 --------------------------------------------- */
 .cctor-row {
   min-height: 1px;
@@ -309,14 +309,14 @@ a .cctor_expiration {
   clear: both;
   margin-left: 0; }
 
-/* Float Clear
+/* Float Clear
 ------------------------------------------------------------ */
 .cctor-clear:after {
   clear: both;
   content: '';
   display: table; }
 
-/* Basic IE7 Support
+/* Basic IE7 Support
 ------------------------------------------------------------ */
 .cctor_coupon {
   *width: 300px; }
@@ -327,3 +327,183 @@ a .cctor_expiration {
 .cctor_terms,
 .cctor_expiration {
   *width: 96%; }
+  * {
+    box-sizing: border-box;
+}
+
+a {
+    text-decoration: none;
+}
+
+img {
+    height: auto;
+    max-width: 100%;
+}
+
+.btn {
+    background-color: #53a318;
+    border: none;
+    width: 140px;
+    height: 35px;
+    color: #fff;
+    font-size: 16px;
+    cursor: pointer;
+    display: block;
+    margin: 300px auto;
+}
+
+button:focus {
+    outline: none;
+}
+
+.cover {
+    background: rgba(0, 0, 0, .3);
+    position: fixed;
+    top: 0;
+    left: 0;
+    z-index: 999;
+    width: 100%;
+    height: 100%;
+}
+
+.vodal-dialog {
+    width: 480px;
+    position: relative;
+    height: auto;
+    max-height: 90%;
+    overflow-y: auto;
+    box-shadow: 0 1px 3px 0 #333;
+    margin: auto;
+    z-index: 99;
+    background-color: #fff;
+    border-radius: 3px;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+}
+
+.vodal-close {
+    position: absolute;
+    cursor: pointer;
+    height: 24px;
+    width: 24px;
+    top: 24px;
+    right: 24px;
+    z-index: 5;
+}
+
+.vodal-close::before, .vodal-close::after {
+    position: absolute;
+    content: "";
+    height: 2px;
+    width: 100%;
+    top: 50%;
+    left: 0;
+    margin-top: -1px;
+    background: #999;
+    border-radius: 100%;
+}
+
+.vodal-close::after {
+    transform: rotate(-45deg);
+}
+
+.vodal-close::before {
+    transform: rotate(45deg);
+}
+
+.modal-body {
+    position: relative;
+    margin: 0 auto;
+    max-width: 1080px;
+    width: 100%;
+}
+
+.modal-body section {
+    position: relative;
+    float: left;
+    min-height: 416px;
+    padding: 32px;
+    width: 100%;
+}
+
+.coupon-title {
+    color: #333;
+    font-size: 36px;
+    font-weight: 300;
+    line-height: 1.22;
+    margin: 0;
+    min-height: 86px;
+}
+
+.cta {
+    margin: 24px 0;
+    display: flex;
+    align-items: center;
+}
+
+.instruction-subtitle {
+    border: 1px dashed #d5d8db;
+    color: #53a318;
+    font-size: 16px;
+    font-weight: 600;
+    line-height: 1.5;
+    margin-right: 10px;
+    padding: 8px 19px;
+}
+
+.btn-cta {
+    background-color: #53a318;
+    min-width: 122px;
+    padding: 8px 19px;
+    color: #fff;
+    display: inline-block;
+    font-size: 16px;
+    line-height: 1.4;
+    border-radius: 2px;
+    position: relative;
+    text-align: center;
+    font-weight: 600;
+}
+
+.last-p {
+    color: #75787b;
+    font-size: 14px;
+    line-height: 1.5;
+}
+
+.low {
+    margin: 0 auto;
+    max-width: 1080px;
+    width: 100%;
+    color: #75787b;
+}
+
+.auto-redirect {
+    background-color: #fff;
+    border-bottom: 1px solid #f6f7f8;
+    font-size: 18px;
+    padding: 8px;
+    text-align: center;
+    font-weight: 400;
+    line-height: 1.5;
+    color: #75787b;
+}
+
+.cover {
+    display: none;
+}
+
+.btn-cta:hover {
+    background-color: rgba(54, 120, 6);
+}
+
+.treatment {
+    margin-bottom: 12px;
+    color: #333;
+    font-size: 14px;
+    font-weight: 600;
+    line-height: 1.43;
+    margin-right: 24px;
+}

BIN
wp-content/plugins/coupon-creator/src/resources/images/load.gif


+ 45 - 0
wp-content/plugins/coupon-creator/src/resources/js/coupon-test.js

@@ -0,0 +1,45 @@
+jQuery(function($){
+	$('.vodal-close').click(function () {
+		$('.cover').hide()
+	})
+	$(document).on('click','.coupon_link', function (e) {
+        e.preventDefault();
+		var $coupon_id = $( this ).data( 'coupon-id' );
+		var $ajax_action = $( this ).data('ajax-action');
+		var vodal=$(document).find('.vodal-dialog')
+		$vodal=$(vodal);
+		$.ajax( {
+			url:pngx_app_ajax.ajaxurl,
+			type: 'post',
+			cache: false,
+			dataType: 'json',
+			data: {
+				nonce: pngx_app_ajax.nonce,
+				// option: $option,
+				coupon_id:$coupon_id,
+				action: $ajax_action
+			},
+			success: function (results) {
+				if (results.success) {
+					data=results.data;
+					$vodal.find('.shopname').html(data.shopname)
+					$vodal.find('.coupon-title').html(data.title)
+					$vodal.find('.instruction-subtitle').html(data.code)
+					$('.cover').css('display', 'flex')
+					window.setTimeout(function () {
+						console.log(data.link);
+						window.location.assign(data.link);
+					}, 6000);
+				} else {
+
+
+				}
+
+			}
+		} );
+
+	} );
+
+} );
+
+