diff --git a/admin/admin-enqueue.php b/admin/admin-enqueue.php index b7977613..5f72469e 100644 --- a/admin/admin-enqueue.php +++ b/admin/admin-enqueue.php @@ -7,6 +7,7 @@ * @update 1.0.3 */ function wpt_admin_enqueue(){ + /** * Select2 CSS file including. * @@ -18,7 +19,7 @@ function wpt_admin_enqueue(){ * Including UltraAddons CSS form Style */ wp_enqueue_style( 'ultraaddons-css', WPT_Product_Table::getPath( 'BASE_URL' ) . 'assets/css/admin-common.css', array(), WPT_DEV_VERSION, 'all' ); - wp_enqueue_style('ultraaddons-css'); + wp_enqueue_style( 'wpt-admin', WPT_Product_Table::getPath( 'BASE_URL' ) . 'assets/css/admin.css', array('select2'), WPT_DEV_VERSION, 'all' ); @@ -47,6 +48,16 @@ function wpt_admin_enqueue(){ //WordPress Default Media Added only for addmin wp_enqueue_media(); + + /** + * WPT Offer handle, User will able to + * see latest offer only when pro version + * is not installed. + */ + if( ! defined( 'WPT_PRO_DEV_VERSION' ) ){ + wp_enqueue_style( 'wpt-offer-css', WPT_Product_Table::getPath( 'BASE_URL' ) . 'admin/notice/offeres/offer.css', array(), WPT_DEV_VERSION, 'all' ); + wp_enqueue_script( 'wpt-offer-js', WPT_Product_Table::getPath( 'BASE_URL' ) . 'admin/notice/offeres/offer.js', array( 'jquery' ), WPT_DEV_VERSION, true ); + } } } add_action( 'admin_enqueue_scripts', 'wpt_admin_enqueue', 99 ); diff --git a/admin/notice/offeres/images/Black-Friday.png b/admin/notice/offeres/images/Black-Friday.png new file mode 100644 index 00000000..7edcbd2a Binary files /dev/null and b/admin/notice/offeres/images/Black-Friday.png differ diff --git a/admin/notice/offeres/offer.css b/admin/notice/offeres/offer.css new file mode 100644 index 00000000..882adcbc --- /dev/null +++ b/admin/notice/offeres/offer.css @@ -0,0 +1,13 @@ +.wpt-special-offer { + margin-top: 15px; + + background: white; + padding: 0; +} +.wpt-special-offer img.offer_image { + max-height: 200px; + width: auto; +} +a.offer_image_link { + display: block; +} \ No newline at end of file diff --git a/admin/notice/offeres/offer.js b/admin/notice/offeres/offer.js new file mode 100644 index 00000000..91c6a8b0 --- /dev/null +++ b/admin/notice/offeres/offer.js @@ -0,0 +1,106 @@ +(function($) { + 'use strict'; + $(document).ready(function() { + if(! $('body').hasClass('wpt_admin_body')){ + return false; + } + + let wrapper_class = '.wpt-special-offer'; + loadOfferContent(); + + function loadOfferContent(){ + let offer_json = getCookie('wpt_offer_latest'); + if( offer_json !== '' ){ + + offer_json = JSON.parse(offer_json); + console.log(offer_json); + jsonToHtmlMarkup(offer_json); + + }else if(navigator.onLine){ + loadContentByAjax(); + } + + } + + function loadContentByAjax(){ + let url = "https://raw.githubusercontent.com/codersaiful/woo-product-table/master/admin/notice/offeres/offer.json"; + $.ajax({ + url: url, + method: "GET", + dataType: 'json', + success:function(result){ + if(result && result !== ''){ + setCookie('wpt_offer_latest',JSON.stringify(result),2);//For Two days + jsonToHtmlMarkup(result); + } + + }, + error:function(e){ + console.log("Something went wrong."); + } + }); + } + + function jsonToHtmlMarkup(result){ + if(! result.offer.status){ + return; + } + let offer = result.offer, + image_url = offer.image_url, + target_link = offer.target_link, + target_html = offer.target_html, + wrapper_css = offer.wrapper_css, + image_css = offer.image_css; + + + let location_selector = offer.display_wrapper + " " + offer.display_to; + + $(wrapper_class).remove(); + + let image_link_html = ""; + if( image_url && target_link ){ + image_link_html = ` + + `; + } + + if(!target_html){ + target_html="" + } + + let html = `