| @@ -110,8 +110,9 @@ | ||
| 110 | 110 | /* #region backend */ |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | public function multiorder_combine($data, $settings) { |
| 114 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context. | |
| 114 | 115 | $should_combine = apply_filters('nx_should_combine', true, $data, $settings); |
| 115 | 116 | if (!$should_combine || empty($settings['combine_multiorder']) || $settings['combine_multiorder'] != '1') { |
| 116 | 117 | return $data; |
| 117 | 118 | } |
| @@ -116,8 +117,9 @@ | ||
| 116 | 117 | return $data; |
| 117 | 118 | } |
| 118 | 119 | $items = []; |
| 119 | 120 | $item_counts = []; |
| 121 | + $item_titles = []; | |
| 120 | 122 | foreach ($data as $key => $item) { |
| 121 | 123 | $payment_id = !empty($item['id']) ? $item['id'] : $item['product_id']; |
| 122 | 124 | if (!isset($items[$payment_id])) { |
| 123 | 125 | $items[$payment_id] = $item; |
| @@ -122,14 +124,52 @@ | ||
| 122 | 124 | if (!isset($items[$payment_id])) { |
| 123 | 125 | $items[$payment_id] = $item; |
| 124 | 126 | } else { |
| 125 | 127 | $item_counts[$payment_id] = isset($item_counts[$payment_id]) ? ++$item_counts[$payment_id] : 1; |
| 128 | + if ( isset( $item['title'] ) ) { | |
| 129 | + $item_titles[$payment_id][] = $item['title']; | |
| 130 | + } | |
| 126 | 131 | } |
| 127 | 132 | } |
| 128 | 133 | |
| 129 | - $products_more_title = isset($settings['combine_multiorder_text']) && !empty($settings['combine_multiorder_text']) ? __($settings['combine_multiorder_text'], 'notificationx') : __('more products', 'notificationx'); | |
| 134 | + $display = !empty($settings['combine_multiorder_display']) | |
| 135 | + ? $settings['combine_multiorder_display'] | |
| 136 | + : 'count'; | |
| 137 | + | |
| 130 | 138 | foreach ($item_counts as $key => $item) { |
| 131 | - $items[$key]['title'] = $items[$key]['title'] . ' & ' . $item . ' ' . $products_more_title; | |
| 139 | + | |
| 140 | + if ( $display === 'list' && ! empty( $item_titles[$key] ) ) { | |
| 141 | + // List the actual product names, e.g. "Product A & Product B". | |
| 142 | + $products_more_title = implode( | |
| 143 | + __(' & ', 'notificationx'), | |
| 144 | + $item_titles[$key] | |
| 145 | + ); | |
| 146 | + } else { | |
| 147 | + $singular = !empty($settings['combine_multiorder_text']) | |
| 148 | + ? $settings['combine_multiorder_text'] | |
| 149 | + : __('more product', 'notificationx'); | |
| 150 | + | |
| 151 | + $plural = !empty($settings['combine_multiorder_text_plural']) | |
| 152 | + ? $settings['combine_multiorder_text_plural'] | |
| 153 | + : __('more products', 'notificationx'); | |
| 154 | + | |
| 155 | + // Both forms are already resolved here - either a user-entered | |
| 156 | + // override or an already-translated default - so they are never | |
| 157 | + // catalogue msgids. _n() would find no entry and fall back to | |
| 158 | + // exactly this choice, so make it explicit. | |
| 159 | + $more_product_text = sprintf( | |
| 160 | + 1 == $item ? $singular : $plural, | |
| 161 | + $item | |
| 162 | + ); | |
| 163 | + $products_more_title = sprintf('%d %s', $item, $more_product_text); | |
| 164 | + } | |
| 165 | + | |
| 166 | + $items[$key]['title'] = sprintf( | |
| 167 | + /* translators: %1$s: product title, %2$s: combined "and N more products" text */ | |
| 168 | + __('%1$s & %2$s', 'notificationx'), | |
| 169 | + $items[$key]['title'], | |
| 170 | + $products_more_title | |
| 171 | + ); | |
| 132 | 172 | } |
| 133 | 173 | |
| 134 | 174 | // @todo maybe sort |
| 135 | 175 | return $items; |
| @@ -216,9 +256,9 @@ | ||
| 216 | 256 | */ |
| 217 | 257 | public function get_payments( $days, $amount ) { |
| 218 | 258 | // $date = '-' . intval( $days ) . ' days'; |
| 219 | 259 | // $start_date = strtotime( $date ); |
| 220 | - $from = date('Y-m-d H:i:s', $days); | |
| 260 | + $from = gmdate('Y-m-d H:i:s', $days); | |
| 221 | 261 | |
| 222 | 262 | $amount = $amount > 0 ? $amount : -1; |
| 223 | 263 | |
| 224 | 264 | $args = array( |
| @@ -358,8 +398,9 @@ | ||
| 358 | 398 | } |
| 359 | 399 | /* #endregion */ |
| 360 | 400 | |
| 361 | 401 | public function doc(){ |
| 402 | + /* translators: %1$s: Easy Digital Downloads installed & activated link URL, %2$s: documentation link URL, %3$s: Integration with Easy Digital Downloads link URL, %4$s: NotificationX Increase Sales on WordPress link URL */ | |
| 362 | 403 | return sprintf(__('<p>Make sure that you have <a href="%1$s" target="_blank">Easy Digital Downloads installed & activated</a> to use its campaign & product sales data. For further assistance, check out our step by step <a target="_blank" href="%2$s">documentation</a>.</p> |
| 363 | 404 | <p>👉 NotificationX <a target="_blank" href="%3$s">Integration with Easy Digital Downloads</a></p> |
| 364 | 405 | <p><strong>Recommended Blog:</strong></p> |
| 365 | 406 | <p>🔥 How Does <a target="_blank" href="%4$s">NotificationX Increase Sales on WordPress</a> Websites?</p>', 'notificationx'), |