PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.7
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.7
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / admin / pages / page-campaigns.php

page-campaigns.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.7, at admin/pages/page-campaigns.php

217 lines 14.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * All Campaigns.
4 *
5 * @since 2.0.0
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 $reports = new Merchant_Analytics_Data_Reports();
13 $date_ranges = $reports->get_last_and_previous_7_days_ranges();
14
15 $campaigns_data = $reports->get_all_campaigns( $date_ranges['recent_period'] );
16
17 $total_rows = array_reduce(
18 $campaigns_data,
19 function ( $count, $module ) {
20 return $count + count( $module['campaigns'] ?? array() );
21 },
22 0
23 );
24
25 /**
26 * `merchant_all_campaigns_items_per_page`
27 *
28 * @since 2.0.0
29 */
30 $rows_per_page = apply_filters( 'merchant_all_campaigns_items_per_page', 25 );
31
32 $current_page = isset( $_GET['page'] ) ? max( 1, (int) $_GET['page'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
33 $total_pages = ceil( $total_rows / $rows_per_page );
34 $start_row = ( $current_page - 1 ) * $rows_per_page + 1;
35 $end_row = min( $current_page * $rows_per_page, $total_rows );
36 ?>
37 <div class="merchant-modules-header-heading merchant-modules-header-heading__campaigns">
38 <?php esc_html_e( 'All Campaigns', 'merchant' ); ?>
39 </div>
40
41 <div class="merchant-module-page merchant-page-campaigns merchant-analytics-section all-campaigns-table">
42 <div class="merchant__campaigns-table-nav">
43 <div class="alignleft">
44 <div class="alignleft bulk-action">
45 <select class="bulk-action-selector">
46 <option value=""><?php echo esc_html__( 'Bulk Action', 'merchant' ); ?></option>
47 <option value="active"><?php echo esc_html__( 'Enable', 'merchant' ); ?></option>
48 <option value="inactive"><?php echo esc_html__( 'Disable', 'merchant' ); ?></option>
49 </select>
50 <button class="button js-bulk-action"><?php echo esc_html__( 'Apply', 'merchant' ); ?></button>
51 </div>
52
53 <div class="alignleft search-campaign-box">
54 <button class="button">
55 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 15 15" fill="none">
56 <path d="M13.8906 13.5742L10.582 10.2656C10.5 10.2109 10.418 10.1562 10.3359 10.1562H9.98047C10.8281 9.17188 11.375 7.85938 11.375 6.4375C11.375 3.32031 8.80469 0.75 5.6875 0.75C2.54297 0.75 0 3.32031 0 6.4375C0 9.58203 2.54297 12.125 5.6875 12.125C7.10938 12.125 8.39453 11.6055 9.40625 10.7578V11.1133C9.40625 11.1953 9.43359 11.2773 9.48828 11.3594L12.7969 14.668C12.9336 14.8047 13.1523 14.8047 13.2617 14.668L13.8906 14.0391C14.0273 13.9297 14.0273 13.7109 13.8906 13.5742ZM5.6875 10.8125C3.25391 10.8125 1.3125 8.87109 1.3125 6.4375C1.3125 4.03125 3.25391 2.0625 5.6875 2.0625C8.09375 2.0625 10.0625 4.03125 10.0625 6.4375C10.0625 8.87109 8.09375 10.8125 5.6875 10.8125Z" fill="#939393"/>
57 </svg>
58 </button>
59 <input type="search" class="js-campaign-search" placeholder="<?php echo esc_html__( 'Search Campaigns', 'merchant' ); ?>">
60 </div>
61 </div>
62
63 <div class="alignright">
64 <div class="alignleft filter-campaign">
65 <select class="filter-campaign-selector js-filter-module">
66 <option value=""><?php echo esc_html__( 'All Campaigns', 'merchant' ); ?></option>
67 </select>
68 </div>
69
70 <div class="alignright overview-head">
71 <div class="date-range">
72 <span class="merchant-analytics-loading-spinner"></span>
73 <span class="first-date-range first-date-range-all-campaigns" data-title="<?php echo esc_attr__( 'Date:', 'merchant' ); ?>">
74 <input type="text" class="date-range-input" readonly value="<?php
75 echo esc_attr( implode( ' - ', array_values( $date_ranges['recent_period'] ) ) ) ?>" placeholder="<?php
76 esc_attr_e( 'Date range', 'merchant' ); ?>">
77 </span>
78 </div>
79 </div>
80 </div>
81 </div>
82
83 <div class="campaigns-table-wrapper merchant-page-campaigns">
84 <table class="wp-list-table widefat table-view-list merchant__campaigns-table js-campaigns-table">
85 <thead>
86 <tr>
87 <th class="no-sort"><input type="checkbox"/></th>
88 <th class="merchant-sort" data-sort="string"><?php echo esc_html__( 'Campaign Name', 'merchant' ); ?></th>
89 <th class="merchant-sort" data-sort="string"><?php echo esc_html__( 'Module Name', 'merchant' ); ?></th>
90 <th><?php echo esc_html__( 'Status', 'merchant' ); ?></th>
91 <th class="merchant-sort" data-sort="int"><?php echo esc_html__( 'Impressions', 'merchant' ); ?></th>
92 <th class="merchant-sort" data-sort="int"> <?php echo esc_html__( 'Clicks', 'merchant' ); ?></th>
93 <th class="merchant-sort" data-sort="float"><?php echo esc_html__( 'Revenue', 'merchant' ); ?></th>
94 <th class="merchant-sort" data-sort="float"><?php echo esc_html__( 'CTR', 'merchant' ); ?></th>
95 <th class="merchant-sort" data-sort="int"><?php echo esc_html__( 'Orders', 'merchant' ); ?></th>
96 <th><?php echo esc_html__( 'Action', 'merchant' ); ?></th>
97 </tr>
98 </thead>
99
100 <tbody>
101 <?php
102 $count = 0;
103 foreach ( $campaigns_data as $module_index => $module ) :
104 $module_id = $module['module_id'] ?? '';
105 if ( empty( $module_id ) ) {
106 continue;
107 }
108
109 foreach ( $module['campaigns'] as $campaign_index => $campaign ) :
110 ++$count;
111 $hide = $count > $rows_per_page;
112 ?>
113 <tr
114 class="<?php echo $hide ? esc_attr( 'is-hidden' ) : ''; ?>"
115 <?php if ( $hide ) : ?>
116 style="display: none;"
117 <?php endif; ?>
118 data-module-id="<?php echo esc_attr( $module_id ); ?>"
119 data-campaign-key="<?php echo esc_attr( $campaign['campaign_key'] ?? '' ); ?>"
120 data-campaign-id="<?php echo esc_attr( $campaign['campaign_id'] ); ?>"
121 data-row-count="<?php echo esc_attr( $count ); ?>">
122 <td><input type="checkbox" name="campaign_select[]" value="<?php echo esc_attr( $campaign['title'] ); ?>" /></td>
123 <td class="merchant__campaign-name js-campaign-name"><?php echo esc_html( $campaign['title'] ); ?></td>
124 <td class="merchant__module-name js-module-name" data-module-id="<?php echo esc_attr( $module['module_id'] ); ?>"><?php echo esc_html( $module['module_name'] ); ?></td>
125 <td class="merchant__status merchant-module-page-setting-field-switcher js-status">
126 <?php
127 if ( in_array( $campaign['status'], array( 'active', 'inactive' ), true ) ) {
128 $_id = $module_id . '-campaign-' . $module_index . '-' . $campaign_index;
129 Merchant_Admin_Options::switcher( array( 'id' => $_id ), $campaign['status'] === 'active', $module_id );
130 } else {
131 echo '-';
132 }
133 ?>
134 </td>
135 <td class="merchant__impressions"><?php echo esc_html( $campaign['impression'] ); ?></td>
136 <td class="merchant__clicks"><?php echo esc_html( $campaign['clicks'] ); ?></td>
137 <td class="merchant__revenue"><?php echo wp_kses($campaign['revenue'], merchant_kses_allowed_tags( array( 'all' ) ) ); ?></td>
138 <td class="merchant__ctr"><?php echo esc_html( $campaign['ctr'] ); ?></td>
139 <td class="merchant__orders"><?php echo esc_html( $campaign['orders'] ); ?></td>
140 <td class="merchant__edit">
141 <a href="<?php echo esc_url( $campaign['url'] ); ?>" target="_blank">
142 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">
143 <path d="M8.30399 1.00174C8.90067 0.405063 9.8596 0.405063 10.4563 1.00174L10.7333 1.27876C11.33 1.87543 11.33 2.83437 10.7333 3.43104L6.51398 7.65037C6.3435 7.82085 6.10909 7.97001 5.85338 8.03394L3.7224 8.65192C3.55193 8.69454 3.36014 8.65192 3.23228 8.50276C3.08311 8.3749 3.04049 8.18311 3.08311 8.01263L3.70109 5.88166C3.76502 5.62594 3.91419 5.39154 4.08467 5.22106L8.30399 1.00174ZM9.73175 1.72627C9.53996 1.53448 9.22031 1.53448 9.02852 1.72627L8.38923 2.34425L9.39079 3.3458L10.0088 2.70651C10.2006 2.51473 10.2006 2.19508 10.0088 2.00329L9.73175 1.72627ZM4.68134 6.15869L4.31908 7.41596L5.57635 7.0537C5.66159 7.03239 5.72552 6.98977 5.78945 6.92584L8.66626 4.04903L7.68601 3.06878L4.8092 5.94559C4.74527 6.00952 4.70265 6.07345 4.68134 6.15869ZM4.61741 1.83281C4.89444 1.83281 5.12885 2.06722 5.12885 2.34425C5.12885 2.64258 4.89444 2.85568 4.61741 2.85568H2.23072C1.7406 2.85568 1.37834 3.23926 1.37834 3.70807V9.50431C1.37834 9.99444 1.7406 10.3567 2.23072 10.3567H8.02697C8.49578 10.3567 8.87936 9.99444 8.87936 9.50431V7.11763C8.87936 6.8406 9.09245 6.60619 9.39079 6.60619C9.66782 6.60619 9.90222 6.8406 9.90222 7.11763V9.50431C9.90222 10.5485 9.04983 11.3796 8.02697 11.3796H2.23072C1.18655 11.3796 0.355469 10.5485 0.355469 9.50431V3.70807C0.355469 2.6852 1.18655 1.83281 2.23072 1.83281H4.61741Z" fill="#565865"/>
144 </svg>
145 <?php echo esc_html__( 'Edit', 'merchant' ); ?>
146 </a>
147 </td>
148 </tr>
149 <?php
150 endforeach;
151 endforeach;
152 ?>
153 </tbody>
154 </table>
155
156 <?php if ( ! $total_rows ) : ?>
157 <div class="merchant__campaigns-no-results">
158 <img src="<?php echo esc_url( MERCHANT_URI ); ?>assets/images/admin/no-campaigns.svg" alt="<?php echo esc_attr__( 'No campaign available', 'merchant' ); ?>"/>
159 <span><?php esc_html_e( 'No campaign available', 'merchant' ); ?></span>
160 <span><?php esc_html_e( 'Start by creating and publishing your offers', 'merchant' ); ?></span>
161 </div>
162 <?php endif; ?>
163
164 <div class="merchant__campaigns-pagination-section">
165 <div
166 class="merchant__campaigns-pagination js-pagination"
167 data-total-rows="<?php echo esc_attr( $total_rows ); ?>"
168 data-total-rows-initial="<?php echo esc_attr( $total_rows ); ?>"
169 data-total-pages="<?php echo esc_attr( $total_pages ); ?>"
170 data-total-pages-initial="<?php echo esc_attr( $total_pages ); ?>"
171 data-rows-per-page="<?php echo esc_attr( $rows_per_page ); ?>"
172 data-current-page="<?php echo esc_attr( $current_page ); ?>">
173 <?php if ( $total_pages > 1 ) : ?>
174 <button
175 class="pagination-button prev-page"
176 data-page="<?php echo esc_attr( $current_page - 1 ); ?>"
177 <?php if ( $current_page === 1 ) : ?>
178 style="display: none;"
179 <?php endif; ?>>
180 <svg xmlns="http://www.w3.org/2000/svg" width="7" height="12" viewBox="0 0 7 12" fill="#565865">
181 <path d="M5.16797 11.3301L0.521484 6.48047C0.394531 6.32812 0.34375 6.17578 0.34375 6.02344C0.34375 5.89648 0.394531 5.74414 0.496094 5.61719L5.14258 0.767578C5.37109 0.513672 5.77734 0.513672 6.00586 0.742188C6.25977 0.970703 6.25977 1.35156 6.03125 1.60547L1.79102 6.02344L6.05664 10.4922C6.28516 10.7207 6.28516 11.127 6.03125 11.3555C5.80273 11.584 5.39648 11.584 5.16797 11.3301Z"/>
182 </svg>
183 </button>
184
185 <?php for ( $_page = 1; $_page <= $total_pages; $_page++ ) : ?>
186 <button class="pagination-button<?php echo esc_attr( $_page === $current_page ? ' pagination-active' : '' ); ?>" data-page="<?php echo esc_attr( $_page ); ?>"><?php echo esc_html( $_page ); ?></button>
187 <?php endfor;?>
188
189 <button
190 class="pagination-button next-page"
191 data-page="<?php echo esc_attr( $current_page + 1 ); ?>"
192 <?php if ( $current_page >= $total_pages ) : ?>
193 style="display: none;"
194 <?php endif; ?>>
195 <svg xmlns="http://www.w3.org/2000/svg" width="7" height="12" viewBox="0 0 7 12" fill="#565865">
196 <path d="M1.80664 0.742188L6.45312 5.5918C6.55469 5.71875 6.63086 5.87109 6.63086 6.02344C6.63086 6.17578 6.55469 6.32812 6.45312 6.42969L1.80664 11.2793C1.57812 11.5332 1.17188 11.5332 0.943359 11.3047C0.689453 11.0762 0.689453 10.6953 0.917969 10.4414L5.18359 5.99805L0.917969 1.58008C0.689453 1.35156 0.689453 0.945312 0.943359 0.716797C1.17188 0.488281 1.57812 0.488281 1.80664 0.742188Z"/>
197 </svg>
198 </button>
199 <?php endif; ?>
200 </div>
201 <?php if ( $total_pages > 1 ) : ?>
202 <div class="merchant__campaigns-pagination-results js-pagination-results">
203 <?php
204 printf(
205 /* translators: 1: Start number, 2: End number, 3: Total rows */
206 esc_html__( 'Showing %1$s to %2$s of %3$s items', 'merchant' ),
207 '<span class="pagination-start-row">' . esc_html( $start_row ) . '</span>',
208 '<span class="pagination-end-row">' . esc_html( $end_row ) . '</span>',
209 '<span class="pagination-total-rows">' . esc_html( $total_rows ) . '</span>'
210 );
211 ?>
212 </div>
213 <?php endif; ?>
214 </div>
215 </div>
216 </div>
217