PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.14
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.14
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 All 177 releases
disco / backend / DashboardWidget.php

DashboardWidget.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.14, at backend/DashboardWidget.php

325 lines 26.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Disco Dashboard Widget
5 *
6 * @package Disco
7 * @author WebAppick
8 * @license GPL 2.0+
9 * @copyright 2024 WebAppick
10 */
11
12 namespace Disco\Backend;
13
14 use Disco\App\Disco;
15 use Disco\Engine\Base;
16
17 /**
18 * Adds a WordPress dashboard widget showing campaign stats and latest blog posts.
19 */
20 class DashboardWidget extends Base {
21
22 /**
23 * Initialize the class.
24 *
25 * @return void|bool
26 */
27 public function initialize() {
28 if ( ! parent::initialize() ) {
29 return;
30 }
31
32 add_action( 'wp_dashboard_setup', array( $this, 'register_widget' ) );
33 }
34
35 /**
36 * Register the dashboard widget.
37 *
38 * @return void
39 */
40 public function register_widget() {
41 wp_add_dashboard_widget(
42 'disco_dashboard_widget',
43 __( 'Disco — Discount Campaigns', 'disco' ),
44 array( $this, 'render_widget' ),
45 null,
46 null,
47 'normal',
48 'high'
49 );
50 }
51
52 /**
53 * Render the widget content.
54 *
55 * @return void
56 */
57 public function render_widget() {
58 $stats = $this->get_campaign_stats();
59 $posts = $this->get_blog_posts();
60 $is_pro = Disco::is_pro();
61 $has_campaigns = $stats['total'] > 0;
62
63 $new_campaign_url = admin_url( 'admin.php?page=disco-create-discount#/disco' );
64 $campaigns_url = admin_url( 'admin.php?page=disco-create-discount' );
65 $settings_url = admin_url( 'admin.php?page=disco-create-discount#/settings' );
66 $pro_url = 'https://discoplugin.com/?utm_source=wp_wedget&utm_medium=free-pro&utm_campaign=free-pro&utm_id=1#pricing';
67 $blog_url = 'https://discoplugin.com/blog/';
68 $docs_url = 'https://discoplugin.com/docs/';
69 $support_url = 'https://wordpress.org/support/plugin/disco/';
70 $review_url = 'https://wordpress.org/support/plugin/disco/reviews/#new-post';
71 ?>
72 <div class="disco-dw">
73
74 <!-- Header -->
75 <div class="disco-dw-header">
76 <div class="disco-dw-brand">
77 <svg width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg">
78 <path d="M37.5575 11.25L37.5366 11.2356C36.9709 10.8185 36.2697 10.7143 35.7327 10.945C35.0028 11.2591 34.0148 11.1209 33.1976 10.5161C32.3803 9.91136 31.9567 9.00941 32.0428 8.21954C32.1066 7.63692 31.8003 6.99825 31.2346 6.57986L31.0026 6.4065C30.4383 5.98811 29.737 5.88514 29.1987 6.11585C28.4688 6.42997 27.4808 6.29181 26.6636 5.68703C25.8464 5.08224 25.4241 4.17898 25.5101 3.39042C25.5726 2.8078 25.2663 2.16913 24.7007 1.75074L24.6811 1.7364C23.4833 0.851388 21.944 0.903524 21.244 1.8524L5.83516 22.7069C5.13392 23.6558 5.53668 25.1417 6.73451 26.0267L6.75406 26.041C7.31974 26.4594 8.02097 26.5624 8.55797 26.3317C9.28788 26.0176 10.2759 26.1557 11.0931 26.7605C11.9103 27.3653 12.3339 28.2685 12.2479 29.0571C12.1841 29.6397 12.4904 30.2784 13.056 30.6968L13.2919 30.8701C13.8576 31.2885 14.5589 31.3915 15.0959 31.1621C15.8258 30.848 16.8138 30.9848 17.631 31.5896C18.4482 32.1944 18.8666 33.1068 18.7819 33.8888C18.718 34.4714 19.0243 35.1114 19.59 35.5285L19.6096 35.5428C20.8074 36.4279 22.3467 36.3757 23.0466 35.4268L38.4568 14.5723C39.1568 13.6209 38.754 12.135 37.5575 11.25Z" fill="#24292E"/>
79 <path d="M21.4262 36.6616C20.6644 36.6499 19.9261 36.3956 19.3186 35.9356L19.2991 35.9213C18.5965 35.3999 18.212 34.6035 18.2954 33.8358C18.3645 33.192 17.9891 32.4647 17.3361 31.9837C16.6831 31.5027 15.8776 31.3555 15.2833 31.6109C14.5755 31.9159 13.6983 31.783 12.9958 31.2642L12.7612 31.0909C12.0586 30.5695 11.6741 29.7731 11.7575 29.0054C11.8279 28.3615 11.4512 27.6342 10.7982 27.152C10.1452 26.6697 9.33972 26.525 8.74537 26.7805C8.03762 27.0855 7.16173 26.9526 6.45919 26.4338L6.43834 26.4195C5.79137 25.9538 5.31915 25.2847 5.09713 24.5191C4.88728 23.7449 5.0072 22.9993 5.43732 22.418L20.8462 1.5622C21.2763 0.98218 21.9528 0.649811 22.7544 0.619833C23.5534 0.605726 24.3339 0.860999 24.9702 1.34453L24.9897 1.35886C25.6923 1.88023 26.0768 2.67661 25.9934 3.44432C25.9243 4.0882 26.301 4.8155 26.9527 5.29776C27.6044 5.78002 28.4112 5.9247 29.0055 5.66923C29.7146 5.36423 30.5905 5.49718 31.293 6.01594L31.5276 6.18929C32.2302 6.71065 32.6147 7.50703 32.5312 8.27474C32.4609 8.91862 32.8375 9.64592 33.4906 10.1282C34.1436 10.6104 34.9491 10.7564 35.5434 10.4997C36.2512 10.1947 37.1284 10.3276 37.8296 10.8464L37.8504 10.862C38.498 11.3269 38.9707 11.9956 39.193 12.7611C39.4015 13.5353 39.2816 14.2808 38.8515 14.8622L23.4413 35.718C23.0125 36.298 22.3347 36.6303 21.5331 36.6603L21.4262 36.6616ZM15.9206 30.5135C16.0817 30.5137 16.2426 30.5268 16.4016 30.5526C16.9491 30.6476 17.467 30.8688 17.9143 31.1987C18.3615 31.5285 18.7258 31.9579 18.9784 32.4529C19.2131 32.9109 19.3122 33.4264 19.2639 33.9388C19.2195 34.3559 19.4594 34.8238 19.8778 35.1327L19.8973 35.1471C20.3552 35.5 20.9186 35.6882 21.4966 35.6815C21.7184 35.685 21.938 35.6375 22.1385 35.5426C22.339 35.4477 22.5149 35.3079 22.6527 35.134L38.0629 14.2795C38.1883 14.0964 38.2701 13.887 38.302 13.6674C38.3338 13.4478 38.3149 13.2238 38.2467 13.0126C38.0816 12.4589 37.7362 11.9762 37.2652 11.6414L37.2457 11.6271C36.8273 11.3182 36.3085 11.2257 35.924 11.3912C35.4479 11.5874 34.9258 11.6443 34.4186 11.5554C33.8711 11.4596 33.3535 11.2378 32.9065 10.9075C32.4595 10.5773 32.0954 10.1476 31.843 9.65244C31.6084 9.19394 31.5094 8.67804 31.5576 8.16525C31.6019 7.74947 31.3608 7.28024 30.9437 6.97133L30.7078 6.79798C30.2894 6.48907 29.7706 6.39653 29.3861 6.56206C28.9104 6.75823 28.3888 6.81519 27.882 6.72629C27.334 6.63049 26.8159 6.40842 26.3686 6.07767C25.9214 5.74692 25.5573 5.31657 25.3052 4.82071C25.0705 4.36221 24.9715 3.84631 25.0197 3.33352C25.064 2.91774 24.8242 2.44851 24.4058 2.13961L24.3863 2.12527C23.9281 1.77291 23.3649 1.58471 22.787 1.59087C22.5652 1.58759 22.3457 1.63524 22.1453 1.73014C21.9448 1.82505 21.7688 1.96469 21.6308 2.1383L6.22067 23.0006C6.09573 23.1837 6.01422 23.3928 5.98237 23.6122C5.95053 23.8315 5.96917 24.0552 6.03689 24.2662C6.20156 24.8202 6.54711 25.3029 7.01835 25.6374L7.0379 25.6518C7.4563 25.9607 7.97505 26.0532 8.35956 25.8877C8.83569 25.6915 9.35776 25.6345 9.86499 25.7234C10.4131 25.8194 10.9313 26.0417 11.3786 26.3726C11.8258 26.7036 12.1899 27.1342 12.4418 27.6303C12.6749 28.0893 12.7739 28.6048 12.7273 29.1175C12.6817 29.5333 12.9228 30.0025 13.3412 30.3114L13.5758 30.4848C13.9942 30.7937 14.5129 30.8862 14.8974 30.7207C15.2209 30.583 15.569 30.5124 15.9206 30.5135Z" fill="#24292E"/>
80 <path d="M37.8753 31.8914C37.8756 31.3908 38.019 30.9007 38.2888 30.479C38.5586 30.0573 38.9433 29.7215 39.3977 29.5114C39.7226 29.3652 39.9987 29.1288 40.1933 28.8303C40.3878 28.5318 40.4926 28.1837 40.4952 27.8274V27.5237C40.4927 27.1672 40.388 26.8189 40.1934 26.5202C39.9989 26.2215 39.7227 25.9848 39.3977 25.8384C38.9434 25.6284 38.5587 25.2928 38.289 24.8712C38.0194 24.4495 37.8761 23.9595 37.8761 23.459C37.8761 22.9585 38.0194 22.4685 38.289 22.0469C38.5587 21.6252 38.9434 21.2896 39.3977 21.0796C39.7228 20.9334 39.9991 20.6968 40.1936 20.398C40.3882 20.0992 40.4928 19.7509 40.4952 19.3943V19.3696C40.4952 18.628 40.2006 17.9167 39.6764 17.3922C39.1521 16.8677 38.441 16.5728 37.6993 16.5725H3.73257C2.99096 16.5728 2.27984 16.8677 1.75556 17.3922C1.23128 17.9167 0.936767 18.628 0.936768 19.3696V19.3943C0.939074 19.7509 1.04373 20.0992 1.23828 20.398C1.43284 20.6968 1.70911 20.9334 2.03424 21.0796C2.48855 21.2896 2.87327 21.6252 3.1429 22.0469C3.41254 22.4685 3.55582 22.9585 3.55582 23.459C3.55582 23.9595 3.41254 24.4495 3.1429 24.8712C2.87327 25.2928 2.48855 25.6284 2.03424 25.8384C1.7092 25.9848 1.43302 26.2215 1.23849 26.5202C1.04395 26.8189 0.939234 27.1672 0.936768 27.5237V27.8274C0.939323 28.1837 1.04409 28.5318 1.23863 28.8303C1.43317 29.1288 1.70931 29.3652 2.03424 29.5114C2.48855 29.7213 2.87327 30.057 3.1429 30.4786C3.41254 30.9003 3.55582 31.3903 3.55582 31.8908C3.55582 32.3912 3.41254 32.8813 3.1429 33.3029C2.87327 33.7245 2.48855 34.0602 2.03424 34.2701C1.7093 34.4167 1.43321 34.6533 1.23869 34.9521C1.04418 35.2508 0.939393 35.599 0.936768 35.9554V35.9815C0.936768 36.723 1.23133 37.4341 1.75564 37.9584C2.27996 38.4827 2.99108 38.7773 3.73257 38.7773H37.6993C38.4408 38.7773 39.152 38.4827 39.6763 37.9584C40.2006 37.4341 40.4952 36.723 40.4952 35.9815V35.9554C40.4925 35.599 40.3877 35.2508 40.1932 34.9521C39.9987 34.6533 39.7226 34.4167 39.3977 34.2701C38.9432 34.0605 38.5583 33.725 38.2885 33.3035C38.0187 32.8819 37.8753 32.3919 37.8753 31.8914Z" fill="#0BC88A"/>
81 <path d="M37.6928 39.2644H3.72603C2.85557 39.2633 2.02105 38.9171 1.40554 38.3016C0.790032 37.6861 0.443784 36.8515 0.442749 35.9811V35.955C0.442817 35.5041 0.575145 35.0632 0.823344 34.6868C1.0694 34.3124 1.41583 34.0147 1.82306 33.8278C2.19332 33.6573 2.50695 33.3843 2.72679 33.041C2.94663 32.6977 3.06348 32.2986 3.06348 31.891C3.06348 31.4833 2.94663 31.0843 2.72679 30.741C2.50695 30.3977 2.19332 30.1246 1.82306 29.9541C1.41583 29.7673 1.0694 29.4696 0.823344 29.0952C0.575145 28.7188 0.442817 28.2778 0.442749 27.827V27.5233C0.442791 27.072 0.575111 26.6306 0.823344 26.2537C1.06985 25.88 1.41619 25.5829 1.82306 25.3961C2.19332 25.2256 2.50695 24.9525 2.72679 24.6093C2.94663 24.266 3.06348 23.8669 3.06348 23.4592C3.06348 23.0516 2.94663 22.6525 2.72679 22.3092C2.50695 21.966 2.19332 21.6929 1.82306 21.5224C1.41583 21.3355 1.0694 21.0379 0.823344 20.6634C0.575111 20.2866 0.442791 19.8452 0.442749 19.3939V19.3692C0.443439 18.4985 0.789535 17.6636 1.40508 17.0478C2.02063 16.432 2.85534 16.0856 3.72603 16.0846H37.6928C38.5635 16.0856 39.3982 16.432 40.0138 17.0478C40.6293 17.6636 40.9754 18.4985 40.9761 19.3692V19.3939C40.9761 19.8452 40.8437 20.2866 40.5955 20.6634C40.3494 21.0379 40.003 21.3355 39.5958 21.5224C39.2255 21.6929 38.9119 21.966 38.6921 22.3092C38.4722 22.6525 38.3554 23.0516 38.3554 23.4592C38.3554 23.8669 38.4722 24.266 38.6921 24.6093C38.9119 24.9525 39.2255 25.2256 39.5958 25.3961C40.003 25.583 40.3494 25.8806 40.5955 26.2551C40.8438 26.6314 40.9762 27.0724 40.9761 27.5233V27.827C40.976 28.2778 40.8437 28.7188 40.5955 29.0952C40.3494 29.4696 40.003 29.7673 39.5958 29.9541C39.2255 30.1246 38.9119 30.3977 38.6921 30.741C38.4722 31.0843 38.3554 31.4833 38.3554 31.891C38.3554 32.2986 38.4722 32.6977 38.6921 33.041C38.9119 33.3843 39.2255 33.6573 39.5958 33.8278C40.003 34.0147 40.3494 34.3124 40.5955 34.6868C40.8437 35.0632 40.976 35.5041 40.9761 35.955V35.9811C40.9751 36.8515 40.6288 37.6861 40.0133 38.3016C39.3978 38.9171 38.5633 39.2633 37.6928 39.2644ZM3.72603 17.0595C3.11414 17.0609 2.52775 17.3048 2.09532 17.7377C1.66289 18.1706 1.41969 18.7573 1.419 19.3692V19.3939C1.42246 19.6572 1.50094 19.914 1.64524 20.1343C1.78953 20.3545 1.99364 20.529 2.23363 20.6374C2.77244 20.8864 3.2287 21.2844 3.54848 21.7845C3.86826 22.2845 4.0382 22.8657 4.0382 23.4592C4.0382 24.0528 3.86826 24.634 3.54848 25.134C3.2287 25.6341 2.77244 26.0321 2.23363 26.2811C1.99365 26.3891 1.78949 26.5634 1.64518 26.7834C1.50086 27.0035 1.42239 27.2601 1.419 27.5233V27.827C1.42255 28.0901 1.50109 28.3467 1.64538 28.5667C1.78968 28.7867 1.99374 28.961 2.23363 29.0691C2.77244 29.3181 3.2287 29.7162 3.54848 30.2162C3.86826 30.7163 4.0382 31.2974 4.0382 31.891C4.0382 32.4845 3.86826 33.0657 3.54848 33.5658C3.2287 34.0658 2.77244 34.4639 2.23363 34.7129C1.99365 34.8208 1.78949 34.9951 1.64518 35.2151C1.50086 35.4352 1.42239 35.6919 1.419 35.955V35.9811C1.41969 36.5931 1.66311 37.1798 2.09586 37.6125C2.5286 38.0453 3.11534 38.2887 3.72733 38.2894H37.6928C38.3046 38.2884 38.891 38.0448 39.3234 37.6121C39.7559 37.1794 39.9992 36.5928 39.9998 35.9811V35.955C39.9965 35.6919 39.918 35.4352 39.7737 35.2151C39.6294 34.9951 39.4252 34.8208 39.1852 34.7129C38.6464 34.4639 38.1901 34.0658 37.8704 33.5658C37.5506 33.0657 37.3806 32.4845 37.3806 31.891C37.3806 31.2974 37.5506 30.7163 37.8704 30.2162C38.1901 29.7162 38.6464 29.3181 39.1852 29.0691C39.4251 28.961 39.6292 28.7867 39.7735 28.5667C39.9178 28.3467 39.9963 28.0901 39.9998 27.827V27.5233C39.9965 27.2601 39.918 27.0035 39.7737 26.7834C39.6294 26.5634 39.4252 26.3891 39.1852 26.2811C38.6464 26.0321 38.1901 25.6341 37.8704 25.134C37.5506 24.634 37.3806 24.0528 37.3806 23.4592C37.3806 22.8657 37.5506 22.2845 37.8704 21.7845C38.1901 21.2844 38.6464 20.8864 39.1852 20.6374C39.4252 20.529 39.6293 20.3545 39.7736 20.1343C39.9179 19.914 39.9964 19.6572 39.9998 19.3939V19.3692C39.9992 18.7573 39.756 18.1706 39.3235 17.7377C38.8911 17.3048 38.3047 17.0609 37.6928 17.0595H3.72603Z" fill="#24292E"/>
82 <path d="M30.1344 39.2644C30.0704 39.2645 30.0069 39.252 29.9477 39.2276C29.8885 39.2032 29.8347 39.1673 29.7894 39.122C29.7441 39.0767 29.7082 39.0228 29.6837 38.9636C29.6593 38.9044 29.6468 38.8409 29.647 38.7769V37.0955C29.647 36.9662 29.6983 36.8422 29.7898 36.7508C29.8812 36.6594 30.0052 36.608 30.1344 36.608C30.2637 36.608 30.3877 36.6594 30.4791 36.7508C30.5706 36.8422 30.6219 36.9662 30.6219 37.0955V38.7769C30.6219 38.9062 30.5706 39.0302 30.4791 39.1216C30.3877 39.213 30.2637 39.2644 30.1344 39.2644ZM30.1344 35.5301C30.0704 35.5303 30.0069 35.5178 29.9477 35.4933C29.8885 35.4689 29.8347 35.433 29.7894 35.3877C29.7441 35.3424 29.7082 35.2886 29.6837 35.2294C29.6593 35.1701 29.6468 35.1067 29.647 35.0426V32.9911C29.647 32.8618 29.6983 32.7378 29.7898 32.6464C29.8812 32.5549 30.0052 32.5036 30.1344 32.5036C30.2637 32.5036 30.3877 32.5549 30.4791 32.6464C30.5706 32.7378 30.6219 32.8618 30.6219 32.9911V35.0426C30.6219 35.1719 30.5706 35.2959 30.4791 35.3873C30.3877 35.4787 30.2637 35.5301 30.1344 35.5301ZM30.1344 31.4257C30.0704 31.4258 30.0069 31.4133 29.9477 31.3889C29.8885 31.3645 29.8347 31.3286 29.7894 31.2833C29.7441 31.238 29.7082 31.1842 29.6837 31.1249C29.6593 31.0657 29.6468 31.0023 29.647 30.9382V28.8866C29.647 28.7573 29.6983 28.6334 29.7898 28.5419C29.8812 28.4505 30.0052 28.3992 30.1344 28.3992C30.2637 28.3992 30.3877 28.4505 30.4791 28.5419C30.5706 28.6334 30.6219 28.7573 30.6219 28.8866V30.9382C30.6219 31.0675 30.5706 31.1915 30.4791 31.2829C30.3877 31.3743 30.2637 31.4257 30.1344 31.4257ZM30.1344 27.3212C30.0704 27.3214 30.0069 27.3089 29.9477 27.2845C29.8885 27.26 29.8347 27.2241 29.7894 27.1788C29.7441 27.1335 29.7082 27.0797 29.6837 27.0205C29.6593 26.9613 29.6468 26.8978 29.647 26.8338V24.7822C29.647 24.6529 29.6983 24.5289 29.7898 24.4375C29.8812 24.3461 30.0052 24.2947 30.1344 24.2947C30.2637 24.2947 30.3877 24.3461 30.4791 24.4375C30.5706 24.5289 30.6219 24.6529 30.6219 24.7822V26.8338C30.6219 26.9631 30.5706 27.087 30.4791 27.1785C30.3877 27.2699 30.2637 27.3212 30.1344 27.3212ZM30.1344 23.2168C30.0704 23.217 30.0069 23.2045 29.9477 23.1801C29.8885 23.1556 29.8347 23.1197 29.7894 23.0744C29.7441 23.0291 29.7082 22.9753 29.6837 22.9161C29.6593 22.8569 29.6468 22.7934 29.647 22.7293V20.6765C29.647 20.5472 29.6983 20.4232 29.7898 20.3318C29.8812 20.2404 30.0052 20.189 30.1344 20.189C30.2637 20.189 30.3877 20.2404 30.4791 20.3318C30.5706 20.4232 30.6219 20.5472 30.6219 20.6765V22.7293C30.6219 22.8586 30.5706 22.9826 30.4791 23.074C30.3877 23.1655 30.2637 23.2168 30.1344 23.2168ZM30.1344 19.1124C30.0052 19.1124 29.8812 19.061 29.7898 18.9696C29.6983 18.8782 29.647 18.7542 29.647 18.6249V16.572C29.647 16.4428 29.6983 16.3188 29.7898 16.2274C29.8812 16.1359 30.0052 16.0846 30.1344 16.0846C30.2637 16.0846 30.3877 16.1359 30.4791 16.2274C30.5706 16.3188 30.6219 16.4428 30.6219 16.572V18.6249C30.6216 18.7541 30.5701 18.8779 30.4788 18.9692C30.3874 19.0606 30.2636 19.112 30.1344 19.1124Z" fill="#24292E"/>
83 <path d="M10.9765 24.6024C10.9747 24.0451 11.1382 23.4997 11.4465 23.0354C11.7548 22.571 12.1939 22.2086 12.7083 21.9939C13.2227 21.7793 13.7891 21.722 14.336 21.8295C14.883 21.9369 15.3857 22.2042 15.7806 22.5975C16.1756 22.9908 16.4449 23.4924 16.5547 24.0388C16.6644 24.5853 16.6095 25.152 16.397 25.6673C16.1845 26.1825 15.8239 26.6232 15.3608 26.9334C14.8978 27.2436 14.3531 27.4095 13.7957 27.41C13.426 27.4119 13.0595 27.3406 12.7173 27.2003C12.3752 27.0601 12.0642 26.8535 11.8021 26.5926C11.5401 26.3317 11.3323 26.0215 11.1906 25.68C11.0489 25.3384 10.9761 24.9722 10.9765 24.6024ZM15.017 24.6024C15.0121 24.3616 14.9361 24.1276 14.7986 23.9299C14.6611 23.7321 14.4681 23.5795 14.244 23.4911C14.02 23.4027 13.7748 23.3826 13.5393 23.4332C13.3038 23.4838 13.0885 23.603 12.9206 23.7756C12.7526 23.9483 12.6395 24.1668 12.5953 24.4035C12.5512 24.6403 12.5781 24.8849 12.6726 25.1064C12.7671 25.328 12.9251 25.5167 13.1265 25.6487C13.328 25.7807 13.564 25.8502 13.8048 25.8485C13.9662 25.8468 14.1257 25.8131 14.274 25.7495C14.4223 25.6858 14.5565 25.5933 14.6688 25.4775C14.7812 25.3616 14.8695 25.2246 14.9286 25.0744C14.9877 24.9242 15.0164 24.7638 15.0131 24.6024H15.017ZM12.9081 33.1906L19.0537 22.1598C19.0839 22.0897 19.1357 22.0309 19.2015 21.992C19.2674 21.9531 19.3438 21.9361 19.4199 21.9435H20.9319C21.1808 21.9435 21.2642 22.1103 21.1469 22.3267L15.0209 33.3574C14.9908 33.4274 14.9392 33.486 14.8736 33.5246C14.808 33.5633 14.7318 33.5801 14.656 33.5725H13.1193C12.8703 33.5725 12.7869 33.4069 12.9042 33.1906H12.9081ZM17.6421 30.8979C17.6403 30.3408 17.8037 29.7956 18.1118 29.3314C18.4198 28.8672 18.8587 28.5047 19.3727 28.2899C19.8868 28.0751 20.453 28.0175 20.9998 28.1246C21.5465 28.2316 22.0493 28.4983 22.4444 28.8911C22.8395 29.2839 23.1093 29.785 23.2196 30.3311C23.3299 30.8772 23.2758 31.4438 23.0641 31.9591C22.8524 32.4745 22.4926 32.9155 22.0302 33.2263C21.5679 33.5371 21.0237 33.7039 20.4666 33.7054C20.096 33.7085 19.7285 33.6382 19.3854 33.4984C19.0422 33.3587 18.7301 33.1524 18.4671 32.8913C18.2041 32.6303 17.9954 32.3197 17.8531 31.9775C17.7109 31.6354 17.6378 31.2684 17.6382 30.8979H17.6421ZM21.6826 30.8979C21.6778 30.6571 21.6018 30.4231 21.4642 30.2253C21.3267 30.0276 21.1337 29.8749 20.9097 29.7866C20.6856 29.6982 20.4404 29.6781 20.2049 29.7287C19.9694 29.7793 19.7542 29.8984 19.5862 30.0711C19.4182 30.2437 19.3051 30.4622 19.261 30.699C19.2168 30.9358 19.2437 31.1804 19.3383 31.4019C19.4328 31.6235 19.5907 31.8121 19.7921 31.9442C19.9936 32.0762 20.2296 32.1457 20.4705 32.1439C20.6315 32.1416 20.7904 32.1074 20.9382 32.0434C21.086 31.9795 21.2196 31.8869 21.3315 31.7711C21.4434 31.6554 21.5314 31.5186 21.5903 31.3688C21.6492 31.2189 21.6779 31.0589 21.6748 30.8979H21.6826Z" fill="white"/>
84 </svg>
85
86 <div class="disco-dw-brand-text">
87 <strong><?php esc_html_e( 'Disco', 'disco' ); ?></strong>
88 <span><?php esc_html_e( 'Discount Rules For WooCommerce', 'disco' ); ?></span>
89 </div>
90 </div>
91 <?php if ( ! $is_pro ) : ?>
92 <a href="<?php echo esc_url( $pro_url ); ?>" target="_blank" rel="noopener noreferrer" class="disco-dw-pro-btn">
93 <?php esc_html_e( '🔒 Unlock Pro', 'disco' ); ?>
94 </a>
95 <?php endif; ?>
96 </div>
97
98 <!-- Stats -->
99 <div class="disco-dw-stats">
100 <div class="disco-dw-stat">
101 <span class="disco-dw-stat-num disco-dw-num-green"><?php echo esc_html( $stats['active'] ); ?></span>
102 <span class="disco-dw-stat-label"><?php esc_html_e( 'Active Campaigns', 'disco' ); ?></span>
103 </div>
104 <div class="disco-dw-stat disco-dw-stat-mid">
105 <span class="disco-dw-stat-num disco-dw-num-dark"><?php echo esc_html( $stats['total'] ); ?></span>
106 <span class="disco-dw-stat-label"><?php esc_html_e( 'Total Created', 'disco' ); ?></span>
107 </div>
108 <div class="disco-dw-stat">
109 <span class="disco-dw-stat-num disco-dw-num-orange"><?php echo esc_html( $stats['expiring_soon'] ); ?></span>
110 <span class="disco-dw-stat-label"><?php esc_html_e( 'Expiring Soon', 'disco' ); ?></span>
111 </div>
112 </div>
113
114 <?php if ( $has_campaigns ) : ?>
115
116 <!-- Action Buttons (has campaigns state) -->
117 <div class="disco-dw-actions">
118 <a href="<?php echo esc_url( $new_campaign_url ); ?>" class="disco-dw-btn disco-dw-btn-primary disco-dw-btn-create">
119 <?php esc_html_e( '+ New Campaign', 'disco' ); ?>
120 </a>
121 <a href="<?php echo esc_url( $campaigns_url ); ?>" class="disco-dw-btn disco-dw-btn-campaigns disco-dw-btn-secondary">
122 <?php esc_html_e( '📋 Campaigns', 'disco' ); ?>
123 </a>
124 <a href="<?php echo esc_url( $settings_url ); ?>" class="disco-dw-btn disco-dw-btn-secondary disco-dw-btn-settings">
125 <?php esc_html_e( '⚙️ Settings', 'disco' ); ?>
126 </a>
127 </div>
128
129 <?php else : ?>
130
131 <!-- Empty State (no campaigns) -->
132 <div class="disco-dw-empty">
133 <p class="disco-dw-empty-title"><?php esc_html_e( 'Your store has no active discounts', 'disco' ); ?></p>
134 <p class="disco-dw-empty-desc"><?php esc_html_e( 'Stores using automated discounts see up to 34% higher average order value. Start in 2 minutes', 'disco' ); ?></p>
135 <a href="<?php echo esc_url( $new_campaign_url ); ?>" class="disco-dw-btn disco-dw-btn-primary disco-dw-btn-lg">
136 <?php esc_html_e( '+ Create Your First Campaign', 'disco' ); ?>
137 </a>
138 </div>
139
140 <?php endif; ?>
141
142 <!-- Learn & Grow Blog -->
143 <?php if ( ! empty( $posts ) ) : ?>
144 <div class="disco-dw-blog">
145 <div class="disco-dw-blog-header">
146 <span class="disco-dw-blog-heading"><?php esc_html_e( 'LEARN & GROW', 'disco' ); ?></span>
147 <a href="<?php echo esc_url( $blog_url ); ?>" target="_blank" rel="noopener noreferrer" class="disco-dw-all-articles">
148 <?php esc_html_e( 'All articles →', 'disco' ); ?>
149 </a>
150 </div>
151 <ul class="disco-dw-blog-list">
152 <?php foreach ( $posts as $post ) : ?>
153 <li class="disco-dw-blog-item">
154 <div class="disco-dw-blog-meta">
155 <?php if ( ! empty( $post['category'] ) ) : ?>
156 <span class="disco-dw-blog-cat"><?php echo esc_html( strtoupper( $post['category'] ) ); ?></span>
157 <?php endif; ?>
158 <?php if ( $post['is_new'] ) : ?>
159 <span class="disco-dw-blog-new"><?php esc_html_e( 'NEW', 'disco' ); ?></span>
160 <?php endif; ?>
161 </div>
162 <a href="<?php echo esc_url( $post['link'] ); ?>" target="_blank" rel="noopener noreferrer" class="disco-dw-blog-title">
163 <?php echo esc_html( $post['title'] ); ?>
164 </a>
165 </li>
166 <?php endforeach; ?>
167 </ul>
168 </div>
169 <?php endif; ?>
170
171 <!-- Footer -->
172 <div class="disco-dw-footer">
173 <div class="disco-dw-footer-links">
174 <a href="<?php echo esc_url( $docs_url ); ?>" target="_blank" rel="noopener noreferrer">
175 <?php esc_html_e( '📖 Help & Docs', 'disco' ); ?>
176 </a>
177 <a href="<?php echo esc_url( $support_url ); ?>" target="_blank" rel="noopener noreferrer">
178 <?php esc_html_e( '💬 Support', 'disco' ); ?>
179 </a>
180 <a href="<?php echo esc_url( $review_url ); ?>" target="_blank" rel="noopener noreferrer">
181 <span class="disco-dw-footer-links-icon">
182 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
183 <g clip-path="url(#clip0_6250_3255)">
184 <path d="M13.9635 5.37035C13.8719 5.08687 13.6204 4.88552 13.3229 4.85871L9.28216 4.49181L7.68432 0.751919C7.56651 0.477834 7.29819 0.300415 7.00007 0.300415C6.70195 0.300415 6.43364 0.477834 6.31582 0.75256L4.71798 4.49181L0.67656 4.85871C0.379616 4.88617 0.128816 5.08687 0.0366355 5.37035C-0.0555452 5.65384 0.0295858 5.96478 0.254216 6.16078L3.30857 8.83947L2.40791 12.8069C2.34201 13.0986 2.45523 13.4001 2.69727 13.5751C2.82737 13.6691 2.97958 13.7169 3.13307 13.7169C3.26542 13.7169 3.39669 13.6813 3.51451 13.6108L7.00007 11.5276L10.4844 13.6108C10.7393 13.7641 11.0607 13.7501 11.3022 13.5751C11.5444 13.3996 11.6575 13.0979 11.5916 12.8069L10.6909 8.83947L13.7453 6.16131C13.9699 5.96478 14.0557 5.65437 13.9635 5.37035Z" fill="#FFC107"/>
185 </g>
186 <defs>
187 <clipPath id="clip0_6250_3255">
188 <rect width="14" height="14" fill="white"/>
189 </clipPath>
190 </defs>
191 </svg>
192 </span>
193 <span>
194 <?php esc_html_e( 'Rate Us', 'disco' ); ?>
195 </span>
196 </a>
197 </div>
198 <span class="disco-dw-version">v<?php echo esc_html( DISCO_VERSION ); ?></span>
199 </div>
200
201 </div>
202 <?php
203 }
204
205 /**
206 * Get campaign stats: total, active, and expiring soon (within 7 days).
207 *
208 * @return array{total: int, active: int, expiring_soon: int}
209 */
210 private function get_campaign_stats() {
211 global $wpdb;
212
213 $rows = $wpdb->get_results( //phpcs:ignore WordPress.DB.DirectDatabaseQuery
214 "SELECT status, data FROM {$wpdb->prefix}disco_campaigns",
215 OBJECT
216 );
217
218 $total = 0;
219 $active = 0;
220 $expiring_soon = 0;
221 $now = current_time( 'timestamp' ); //phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
222 $seven_days = $now + ( 7 * DAY_IN_SECONDS );
223
224 foreach ( $rows as $row ) {
225 $total++;
226
227 if ( '1' === $row->status ) {
228 $active++;
229 }
230
231 if ( ! empty( $row->data ) ) {
232 $data = json_decode( $row->data, true );
233
234 if ( ! empty( $data['discount_valid_to'] ) ) {
235 $expires = strtotime( $data['discount_valid_to'] );
236
237 if ( $expires && $expires >= $now && $expires <= $seven_days ) {
238 $expiring_soon++;
239 }
240 }
241 }
242 }
243
244 return array(
245 'total' => $total,
246 'active' => $active,
247 'expiring_soon' => $expiring_soon,
248 );
249 }
250
251 /**
252 * Fetch the latest 3 blog posts from discoplugin.com with transient caching.
253 *
254 * @return array Array of posts with 'title', 'link', 'category', and 'is_new' keys.
255 */
256 private function get_blog_posts() {
257 $cache_key = 'disco_blog_posts_cache';
258 $cached = get_transient( $cache_key );
259
260 if ( false !== $cached ) {
261 return $cached;
262 }
263
264 $response = wp_remote_get(
265 'https://discoplugin.com/wp-json/wp/v2/posts?_embed&per_page=3&orderby=date&order=desc',
266 array( 'timeout' => 8 )
267 );
268
269 if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
270 return array();
271 }
272
273 $body = wp_remote_retrieve_body( $response );
274 $items = json_decode( $body, true );
275
276 if ( ! is_array( $items ) ) {
277 return array();
278 }
279
280 $posts = array();
281 $two_weeks = 14 * DAY_IN_SECONDS;
282
283 foreach ( $items as $item ) {
284 $title = isset( $item['title']['rendered'] ) ? wp_strip_all_tags( $item['title']['rendered'] ) : '';
285 $link = isset( $item['link'] ) ? esc_url_raw( $item['link'] ) : '';
286
287 if ( empty( $title ) || empty( $link ) ) {
288 continue;
289 }
290
291 // Category from embedded terms.
292 $category = '';
293 if ( ! empty( $item['_embedded']['wp:term'] ) ) {
294 foreach ( $item['_embedded']['wp:term'] as $term_group ) {
295 foreach ( $term_group as $term ) {
296 if ( isset( $term['taxonomy'] ) && 'category' === $term['taxonomy'] ) {
297 $category = sanitize_text_field( $term['name'] );
298 break 2;
299 }
300 }
301 }
302 }
303
304 // "NEW" badge if published within the last 14 days.
305 $is_new = false;
306 if ( ! empty( $item['date_gmt'] ) ) {
307 $published = strtotime( $item['date_gmt'] );
308 $is_new = $published && ( time() - $published ) < $two_weeks;
309 }
310
311 $posts[] = array(
312 'title' => $title,
313 'link' => $link,
314 'category' => $category,
315 'is_new' => $is_new,
316 );
317 }
318
319 // Cache for 6 hours.
320 set_transient( $cache_key, $posts, 6 * HOUR_IN_SECONDS );
321
322 return $posts;
323 }
324 }
325