PluginProbe ʕ •ᴥ•ʔ
Event Tickets with Ticket Scanner / 2.6.0
Event Tickets with Ticket Scanner v2.6.0
3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.4 trunk 2.6.0 2.7.0 2.7.1 2.7.10 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3
event-tickets-with-ticket-scanner / index.php
event-tickets-with-ticket-scanner Last commit date
3rd 1 year ago css 1 year ago img 1 year ago languages 1 year ago ticket 1 year ago vendors 1 year ago SASO_EVENTTICKETS.php 1 year ago backend.js 1 year ago changelog.txt 1 year ago db.php 1 year ago index.php 1 year ago init_file.php 1 year ago order_details.js 1 year ago readme.txt 1 year ago saso-eventtickets-validator.js 1 year ago sasoEventtickets_AdminSettings.php 1 year ago sasoEventtickets_Authtoken.php 1 year ago sasoEventtickets_Base.php 1 year ago sasoEventtickets_Core.php 1 year ago sasoEventtickets_Frontend.php 1 year ago sasoEventtickets_Options.php 1 year ago sasoEventtickets_PDF.php 1 year ago sasoEventtickets_Ticket.php 1 year ago sasoEventtickets_TicketBadge.php 1 year ago sasoEventtickets_TicketDesigner.php 1 year ago sasoEventtickets_TicketQR.php 1 year ago ticket_events.js 1 year ago ticket_scanner.js 1 year ago validator.js 1 year ago wc_backend.js 1 year ago wc_frontend.js 1 year ago woocommerce-hooks.php 1 year ago
index.php
1205 lines
1 <?php
2 /**
3 * Plugin Name: Event Tickets with Ticket Scanner
4 * Plugin URI: https://vollstart.com/event-tickets-with-ticket-scanner/docs/
5 * Description: You can create and generate tickets and codes. You can redeem the tickets at entrance using the built-in ticket scanner. You customer can download a PDF with the ticket information. The Premium allows you also to activate user registration and more. This allows your user to register them self to a ticket.
6 * Version: 2.6.0
7 * Author: Vollstart
8 * Author URI: https://vollstart.com
9 * Text Domain: event-tickets-with-ticket-scanner
10 *
11 * Event Tickets with Ticket Scanner is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16 // https://semver.org/
17 // https://developer.wordpress.org/plugins/security/securing-output/
18 // https://developer.wordpress.org/plugins/security/securing-input/
19
20 include_once(plugin_dir_path(__FILE__)."init_file.php");
21
22 if (!defined('SASO_EVENTTICKETS_PLUGIN_VERSION'))
23 define('SASO_EVENTTICKETS_PLUGIN_VERSION', '2.6.0');
24 if (!defined('SASO_EVENTTICKETS_PLUGIN_DIR_PATH'))
25 define('SASO_EVENTTICKETS_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
26
27 include_once plugin_dir_path(__FILE__)."SASO_EVENTTICKETS.php";
28
29 class sasoEventtickets_fakeprem{}
30 class sasoEventtickets {
31 private $_js_version;
32 private $_js_file = 'saso-eventtickets-validator.js';
33 public $_js_nonce = 'sasoEventtickets';
34 public $_do_action_prefix = 'saso_eventtickets_';
35 public $_add_filter_prefix = 'saso_eventtickets_';
36 protected $_prefix = 'sasoEventtickets';
37 protected $_shortcode = 'sasoEventTicketsValidator';
38 protected $_shortcode_mycode = 'sasoEventTicketsValidator_code';
39 protected $_shortcode_eventviews = 'sasoEventTicketsValidator_eventsview';
40 protected $_shortcode_ticket_scanner = 'sasoEventTicketsValidator_ticket_scanner';
41 protected $_divId = 'sasoEventtickets';
42
43 private $_isPrem = null;
44 private $_premium_plugin_name = 'event-tickets-with-ticket-scanner-premium';
45 private $_premium_function_file = 'sasoEventtickets_PremiumFunctions.php';
46 private $PREMFUNCTIONS = null;
47 private $BASE = null;
48 private $CORE = null;
49 private $ADMIN = null;
50 private $FRONTEND = null;
51 private $OPTIONS = null;
52 private $WC = null;
53
54 private $isAllowedAccess = null;
55
56 public function __construct() {
57 $this->_js_version = $this->getPluginVersion();
58 $this->initHandlers();
59 }
60
61 public function initHandlers() {
62 add_action( 'init', [$this, 'load_plugin_textdomain'] );
63 add_action( 'upgrader_process_complete', [$this, 'listener_upgrader_process_complete'], 10, 2 );
64 //add_action('admin_init', [$this, 'initialize_plugin']);
65 if (is_admin()) { // called in backend admin, admin-ajax!
66 $this->init_backend();
67 } else { // called in front end
68 $this->init_frontend();
69 }
70 add_action( 'sasoEventtickets_cronjob_daily', [$this, 'relay_sasoEventtickets_cronjob_daily'], 10, 0 ); // set in tickets.php
71 add_action( 'plugins_loaded', [$this, 'WooCommercePluginLoaded'], 20, 0 );
72 if (basename($_SERVER['SCRIPT_NAME']) == "admin-ajax.php") {
73 add_action('wp_ajax_nopriv_'.$this->_prefix.'_executeFrontend', [$this,'executeFrontend_a'], 10, 0); // nicht angemeldete user, sollen eine antwort erhalten
74 add_action('wp_ajax_'.$this->_prefix.'_executeFrontend', [$this,'executeFrontend_a'], 10, 0); // falls eingeloggt ist
75 add_action('wp_ajax_'.$this->_prefix.'_executeWCBackend', [$this,'executeWCBackend'], 10, 0); // falls eingeloggt ist
76 }
77 if (method_exists($this->getPremiumFunctions(), "initHandlers")) {
78 $this->getPremiumFunctions()->initHandlers();
79 }
80 $this->cronjob_daily_activate();
81 }
82 public function cronjob_daily_activate() {
83 $args = [];
84 if (! wp_next_scheduled ( 'sasoEventtickets_cronjob_daily', $args )) {
85 wp_schedule_event( strtotime("00:05"), 'daily', 'sasoEventtickets_cronjob_daily', $args );
86 }
87 }
88 public function cronjob_daily_deactivate() {
89 wp_clear_scheduled_hook( 'sasoEventtickets_cronjob_daily' );
90 }
91 public function load_plugin_textdomain() {
92 load_plugin_textdomain( 'event-tickets-with-ticket-scanner', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
93 }
94 public function getPluginPath() {
95 return SASO_EVENTTICKETS_PLUGIN_DIR_PATH;
96 }
97 public function getPluginVersion() {
98 return SASO_EVENTTICKETS_PLUGIN_VERSION;
99 }
100 public function getPluginVersions() {
101 $ret = ['basic'=>SASO_EVENTTICKETS_PLUGIN_VERSION, 'premium'=>'', 'debug'=>''];
102 if (defined('SASO_EVENTTICKETS_PREMIUM_PLUGIN_VERSION')) {
103 $ret['premium'] = SASO_EVENTTICKETS_PREMIUM_PLUGIN_VERSION;
104 }
105 if (defined('WP_DEBUG') && WP_DEBUG) {
106 $ret['debug'] = '<span style="color:red;">'.esc_html__('is active', 'event-tickets-with-ticket-scanner').'</span>';
107 }
108 return $ret;
109 }
110 public function getDB() {
111 return SASO_EVENTTICKETS::getDB(plugin_dir_path(__FILE__), "sasoEventticketsDB", $this);
112 }
113 public function getBase() {
114 if ($this->BASE == null) {
115 if (!class_exists('sasoEventtickets_Base')) {
116 include_once plugin_dir_path(__FILE__)."sasoEventtickets_Base.php";
117 }
118 $this->BASE = new sasoEventtickets_Base($this);
119 }
120 return $this->BASE;
121 }
122 public function getCore() {
123 if ($this->CORE == null) {
124 if (!class_exists('sasoEventtickets_Core')) {
125 include_once plugin_dir_path(__FILE__)."sasoEventtickets_Core.php";
126 }
127 $this->CORE = new sasoEventtickets_Core($this);
128 }
129 return $this->CORE;
130 }
131 public function getAdmin() {
132 if ($this->ADMIN == null) {
133 if (!class_exists('sasoEventtickets_AdminSettings')) {
134 include_once plugin_dir_path(__FILE__)."sasoEventtickets_AdminSettings.php";
135 }
136 $this->ADMIN = new sasoEventtickets_AdminSettings($this);
137 }
138 return $this->ADMIN;
139 }
140 public function getFrontend() {
141 if ($this->FRONTEND == null) {
142 if (!class_exists('sasoEventtickets_Frontend')) {
143 include_once plugin_dir_path(__FILE__)."sasoEventtickets_Frontend.php";
144 }
145 $this->FRONTEND = new sasoEventtickets_Frontend($this);
146 }
147 return $this->FRONTEND;
148 }
149 public function getOptions() {
150 if ($this->OPTIONS == null) {
151 if (!class_exists('sasoEventtickets_Options')) {
152 include_once plugin_dir_path(__FILE__)."sasoEventtickets_Options.php";
153 }
154 $this->OPTIONS = new sasoEventtickets_Options($this, $this->_prefix);
155 $this->OPTIONS->initOptions();
156 }
157 return $this->OPTIONS;
158 }
159 public function getNewPDFObject() {
160 if (!class_exists('sasoEventtickets_PDF')) {
161 require_once("sasoEventtickets_PDF.php");
162 }
163 $pdf = new sasoEventtickets_PDF();
164 $pdf->setFontSize($this->getOptions()->getOptionValue('wcTicketPDFFontSize'));
165 $pdf->setFontFamily($this->getOptions()->getOptionValue('wcTicketPDFFontFamily'));
166 $pdf = apply_filters( $this->_add_filter_prefix.'main_getNewPDFObject', $pdf );
167 return $pdf;
168 }
169 public function loadOnce($className, $filename="") {
170 if (!class_exists($className)) {
171 if ($filename == "") $filename = $className;
172 include_once __DIR__.'/'.$filename.'.php';
173 }
174 }
175 public function getWC() {
176 if ($this->WC == null) {
177 $this->loadOnce('sasoEventtickets_WC', "woocommerce-hooks");
178 $this->WC = new sasoEventtickets_WC($this);
179 }
180 return $this->WC;
181 }
182 public function getTicketHandler() {
183 $this->loadOnce('sasoEventtickets_Ticket');
184 return sasoEventtickets_Ticket::Instance($_SERVER["REQUEST_URI"]);
185 }
186 public function getTicketDesignerHandler($template="") {
187 $this->loadOnce('sasoEventtickets_TicketDesigner');
188 return sasoEventtickets_TicketDesigner::Instance($this, $template);
189 }
190 public function getTicketBadgeHandler() {
191 $this->loadOnce('sasoEventtickets_TicketBadge');
192 return sasoEventtickets_TicketBadge::Instance();
193 }
194 public function getTicketQRHandler() {
195 $this->loadOnce('sasoEventtickets_TicketQR');
196 return sasoEventtickets_TicketQR::Instance();
197 }
198 public function getAuthtokenHandler() {
199 $this->loadOnce('sasoEventtickets_Authtoken');
200 return sasoEventtickets_Authtoken::Instance();
201 }
202 public function getPremiumFunctions() {
203 if ($this->_isPrem == null && $this->PREMFUNCTIONS == null) {
204 $this->_isPrem = false;
205 $this->PREMFUNCTIONS = new sasoEventtickets_fakeprem();
206 if (class_exists('sasoEventtickets_PremiumFunctions')) {
207 $this->PREMFUNCTIONS = new sasoEventtickets_PremiumFunctions($this, plugin_dir_path(__FILE__), $this->_prefix, $this->getDB());
208 $this->_isPrem = $this->PREMFUNCTIONS->isPremium();
209 } else { // old approach before v 2.5.7
210 // this is causing issues with base_dir set
211 $premPluginFolder = $this->getPremiumPluginFolder();
212 if (!empty($premPluginFolder)) {
213 $file = $premPluginFolder.$this->_premium_function_file;
214 $premiumFile = plugin_dir_path(__FILE__)."../".$file;
215 if (file_exists($premiumFile)) { // check ob active ist nicht nötig, das das getPremiumPluginFolder schon macht
216 if (!class_exists('sasoEventtickets_PremiumFunctions')) {
217 include_once $premiumFile;
218 }
219 $this->PREMFUNCTIONS = new sasoEventtickets_PremiumFunctions($this, plugin_dir_path(__FILE__), $this->_prefix, $this->getDB());
220 $this->_isPrem = $this->PREMFUNCTIONS->isPremium();
221 }
222 }
223 }
224 }
225 return $this->PREMFUNCTIONS;
226 }
227 private function getPremiumPluginFolder() {
228 $plugins = get_option('active_plugins', []);
229 $premiumFile = "";
230 foreach($plugins as $plugin) {
231 if (strpos(" ".$plugin, $this->_premium_plugin_name) > 0) {
232 $premiumFile = plugin_dir_path($plugin);
233 break;
234 }
235 }
236 return $premiumFile;
237 }
238 public function isPremium() {
239 if ($this->_isPrem == null) $this->getPremiumFunctions();
240 return $this->_isPrem;
241 }
242 public function getPrefix() {
243 return $this->_prefix;
244 }
245 public function getMV() {
246 $v = ['storeip'=>false,'allowuserreg'=>false,'codes_total'=>0x13,'codes'=>0x12,'lists'=>5,'authtokens_total'=>0];
247 $v["codes"] = (int) hexdec(0x80 / 0x002) / 2;
248 $v["codes_total"] = (int) hexdec(0x80 / 0x002) / 2;
249 return $v;
250 }
251 public function listener_upgrader_process_complete( $upgrader_object, $options ) {
252 $current_plugin_path_name = plugin_basename( __FILE__ );
253 if ($options['action'] == 'update' && $options['type'] == 'plugin' ) {
254 if (isset($options['plugins'])) {
255 foreach($options['plugins'] as $each_plugin) {
256 if ($each_plugin==$current_plugin_path_name) {
257 // .......................... YOUR CODES .............
258 }
259 }
260 }
261 }
262 do_action( $this->_do_action_prefix.'main_listener_upgrader_process_complete' );
263 }
264 /**
265 * check for ticket detail page request
266 */
267 public function wc_checkTicketDetailPage() {
268 if( is_404() ){
269 include_once("SASO_EVENTTICKETS.php");
270 // /wp-content/plugins/event-tickets-with-ticket-scanner/ticket/
271 $p = $this->getCore()->getTicketURLPath(true);
272 $t = explode("/", $_SERVER["REQUEST_URI"]);
273 if (count($t) > 1) {
274 if ($t[count($t)-2] != "scanner") {
275 if(substr($_SERVER["REQUEST_URI"], 0, strlen($p)) == $p) {
276 $this->getTicketHandler()->initFilterAndActions();
277 } else {
278 $wcTicketCompatibilityModeURLPath = trim($this->getOptions()->getOptionValue('wcTicketCompatibilityModeURLPath'));
279 $wcTicketCompatibilityModeURLPath = trim(trim($wcTicketCompatibilityModeURLPath, "/"));
280 if (!empty($wcTicketCompatibilityModeURLPath)) {
281 $uri = trim($_SERVER["REQUEST_URI"]);
282 if (!empty($uri)) {
283 $pos = strpos($uri, $wcTicketCompatibilityModeURLPath);
284 if ($pos > 0) {
285 $this->getTicketHandler()->initFilterAndActions();
286 }
287 }
288 }
289 }
290 }
291
292 if ($t[count($t)-2] == "scanner") {
293 if(substr($_SERVER["REQUEST_URI"], 0, strlen($p)) == $p) {
294 //$this->replacingShortcodeTicketScanner();
295 $this->getTicketHandler()->initFilterAndActionsTicketScanner();
296 } else {
297 $wcTicketCompatibilityModeURLPath = trim($this->getOptions()->getOptionValue('wcTicketCompatibilityModeURLPath'));
298 $wcTicketCompatibilityModeURLPath = trim(trim($wcTicketCompatibilityModeURLPath, "/"));
299 if (!empty($wcTicketCompatibilityModeURLPath)) {
300 $uri = trim($_SERVER["REQUEST_URI"]);
301 if (!empty($uri)) {
302 $pos = strpos($_SERVER["REQUEST_URI"], $wcTicketCompatibilityModeURLPath."/scanner/");
303 if ($pos > 0) {
304 $this->getTicketHandler()->initFilterAndActionsTicketScanner();
305 }
306 }
307 }
308 }
309 }
310 }
311 } // endif 404
312 }
313 private function init_frontend() {
314 add_shortcode($this->_shortcode, [$this, 'replacingShortcode']);
315 add_shortcode($this->_shortcode_mycode, [$this, 'replacingShortcodeMyCode']);
316 add_shortcode($this->_shortcode_ticket_scanner, [$this, 'replacingShortcodeTicketScanner']);
317 add_shortcode($this->_shortcode_eventviews, [$this, 'replacingShortcodeEventViews']);
318 do_action( $this->_do_action_prefix.'main_init_frontend' );
319 }
320 private function init_backend() {
321 add_action('admin_menu', [$this, 'register_options_page']);
322 register_activation_hook(__FILE__, [$this, 'plugin_activated']);
323 register_deactivation_hook( __FILE__, [$this, 'plugin_deactivated'] );
324 //register_uninstall_hook( __FILE__, 'sasoEventticketsDB::plugin_uninstall' ); // MUSS NOCH GETESTE WERDEN
325 add_action( 'plugins_loaded', [$this, 'plugins_loaded'] );
326 add_action( 'show_user_profile', [$this, 'show_user_profile'] );
327
328 if (basename($_SERVER['SCRIPT_NAME']) == "admin-ajax.php") {
329 add_action('wp_ajax_'.$this->_prefix.'_executeAdminSettings', [$this,'executeAdminSettings_a'], 10, 0);
330 }
331
332 do_action( $this->_do_action_prefix.'main_init_backend' );
333 }
334 public function WooCommercePluginLoaded() {
335 //$this->getWC(); // um die wc handler zu laden
336 add_action('woocommerce_review_order_after_cart_contents', [$this, 'relay_woocommerce_review_order_after_cart_contents']);
337 add_action('woocommerce_checkout_process', [$this, 'relay_woocommerce_checkout_process']);
338 add_action('woocommerce_before_cart_table', [$this, 'relay_woocommerce_before_cart_table']);
339 add_action('woocommerce_cart_updated', [$this, 'relay_woocommerce_cart_updated']);
340 add_filter('woocommerce_email_attachments', [$this, 'relay_woocommerce_email_attachments'], 10, 3);
341 add_action('woocommerce_checkout_create_order_line_item', [$this, 'relay_woocommerce_checkout_create_order_line_item'], 20, 4 );
342 add_action('woocommerce_check_cart_items', [$this, 'relay_woocommerce_check_cart_items'] );
343 add_action('woocommerce_new_order', [$this, 'relay_woocommerce_new_order'], 10, 1);
344 add_action('woocommerce_checkout_update_order_meta', [$this, 'relay_woocommerce_checkout_update_order_meta'], 20, 2);
345 add_action('woocommerce_order_status_changed', [$this, 'relay_woocommerce_order_status_changed'], 10, 3);
346 add_filter('woocommerce_order_item_display_meta_key', [$this, 'relay_woocommerce_order_item_display_meta_key'], 20, 3 );
347 add_filter('woocommerce_order_item_display_meta_value', [$this, 'relay_woocommerce_order_item_display_meta_value'], 20, 3);
348 add_action('wpo_wcpdf_after_item_meta', [$this, 'relay_wpo_wcpdf_after_item_meta'], 20, 3 );
349 add_action('woocommerce_order_item_meta_start', [$this, 'relay_woocommerce_order_item_meta_start'], 201, 4);
350 add_action('woocommerce_product_after_variable_attributes', [$this, 'relay_woocommerce_product_after_variable_attributes'], 10, 3);
351 add_action('woocommerce_save_product_variation',[$this, 'relay_woocommerce_save_product_variation'], 10 ,2 );
352 add_action('woocommerce_email_order_meta', [$this, 'relay_woocommerce_email_order_meta'], 10, 4 );
353 add_action('woocommerce_thankyou_', [$this, 'relay_woocommerce_thankyou_'], 5);
354 if (wp_doing_ajax()) {
355 // erlaube ajax nonpriv und registriere handler
356 add_action('wp_ajax_nopriv_'.$this->getPrefix().'_executeWCFrontend', [$this,'relay_executeWCFrontend']); // nicht angemeldete user, sollen eine antwort erhalten
357 add_action('wp_ajax_'.$this->getPrefix().'_executeWCFrontend', [$this,'relay_executeWCFrontend']); // nicht angemeldete user, sollen eine antwort erhalten
358 }
359 if (is_admin()) {
360 add_action('woocommerce_delete_order', [$this, 'relay_woocommerce_delete_order'], 10, 1 );
361 add_action('woocommerce_delete_order_item', [$this, 'relay_woocommerce_delete_order_item'], 20, 1);
362 add_action('woocommerce_pre_delete_order_refund', [$this, 'relay_woocommerce_pre_delete_order_refund'], 10, 3);
363 add_action('woocommerce_delete_order_refund', [$this, 'relay_woocommerce_delete_order_refund'], 10, 1 );
364 add_action('woocommerce_order_partially_refunded', [$this, 'relay_woocommerce_order_partially_refunded'], 10, 2);
365 //add_action('woocommerce_update_order', [$this, 'relay_woocommerce_update_order'], 10, 2);
366 add_filter('woocommerce_product_data_tabs', [$this, 'relay_woocommerce_product_data_tabs'], 98 );
367 add_action('woocommerce_product_data_panels', [$this, 'relay_woocommerce_product_data_panels'] );
368 add_action('woocommerce_process_product_meta', [$this, 'relay_woocommerce_process_product_meta'], 10, 2 );
369 add_action('add_meta_boxes', [$this, 'relay_add_meta_boxes']);
370 add_filter('manage_edit-product_columns', [$this, 'relay_manage_edit_product_columns']);
371 add_action('manage_product_posts_custom_column', [$this, 'relay_manage_product_posts_custom_column'], 2);
372 add_filter("manage_edit-product_sortable_columns", [$this, 'relay_manage_edit_product_sortable_columns']);
373 } else {
374 add_action('woocommerce_single_product_summary', [$this, 'relay_woocommerce_single_product_summary']);
375 }
376
377 // set routing -- NEEDS to be replaced by add_rewrite_rule later
378 add_action( 'template_redirect', [$this, 'wc_checkTicketDetailPage'], 1 );
379 //$this->wc_checkTicketDetailPage();
380 add_action('rest_api_init', function () {
381 SASO_EVENTTICKETS::setRestRoutesTicket();
382 });
383
384 do_action( $this->_do_action_prefix.'main_WooCommercePluginLoaded' );
385 }
386 public function relay_woocommerce_review_order_after_cart_contents() {
387 $this->getWC()->woocommerce_review_order_after_cart_contents();
388 }
389 public function relay_woocommerce_checkout_process() {
390 $this->getWC()->woocommerce_checkout_process();
391 }
392 public function relay_woocommerce_before_cart_table() {
393 $this->getWC()->woocommerce_before_cart_table();
394 }
395 public function relay_woocommerce_cart_updated() {
396 $this->getWC()->woocommerce_cart_updated();
397 }
398 public function relay_woocommerce_email_attachments() {
399 $args = func_get_args();
400 return $this->getWC()->woocommerce_email_attachments(...$args);
401 }
402 public function relay_woocommerce_checkout_create_order_line_item() {
403 $args = func_get_args();
404 return $this->getWC()->woocommerce_checkout_create_order_line_item(...$args);
405 }
406 public function relay_woocommerce_check_cart_items() {
407 $this->getWC()->woocommerce_check_cart_items();
408 }
409 public function relay_woocommerce_new_order() {
410 $args = func_get_args();
411 return $this->getWC()->woocommerce_new_order(...$args);
412 }
413 public function relay_woocommerce_checkout_update_order_meta() {
414 $args = func_get_args();
415 return $this->getWC()->woocommerce_checkout_update_order_meta(...$args);
416 }
417 public function relay_executeWCFrontend() {
418 return $this->getWC()->executeWCFrontend();
419 }
420 public function relay_woocommerce_delete_order() {
421 $args = func_get_args();
422 $this->getWC()->woocommerce_delete_order(...$args);
423 }
424 public function relay_woocommerce_delete_order_item() {
425 $args = func_get_args();
426 $this->getWC()->woocommerce_delete_order_item(...$args);
427 }
428 public function relay_woocommerce_pre_delete_order_refund() {
429 $args = func_get_args();
430 $this->getWC()->woocommerce_pre_delete_order_refund(...$args);
431 }
432 public function relay_woocommerce_delete_order_refund() {
433 $args = func_get_args();
434 $this->getWC()->woocommerce_delete_order_refund(...$args);
435 }
436 public function relay_woocommerce_product_data_tabs() {
437 $args = func_get_args();
438 return $this->getWC()->woocommerce_product_data_tabs(...$args);
439 }
440 public function relay_woocommerce_product_data_panels() {
441 $this->getWC()->woocommerce_product_data_panels();
442 }
443 public function relay_woocommerce_process_product_meta() {
444 $args = func_get_args();
445 $this->getWC()->woocommerce_process_product_meta(...$args);
446 }
447 public function relay_add_meta_boxes() {
448 $this->getWC()->add_meta_boxes();
449 }
450 public function relay_manage_edit_product_columns() {
451 $args = func_get_args();
452 return $this->getWC()->manage_edit_product_columns(...$args);
453 }
454 public function relay_manage_product_posts_custom_column() {
455 $args = func_get_args();
456 $this->getWC()->manage_product_posts_custom_column(...$args);
457 }
458 public function relay_manage_edit_product_sortable_columns() {
459 $args = func_get_args();
460 return $this->getWC()->manage_edit_product_sortable_columns(...$args);
461 }
462 public function relay_woocommerce_single_product_summary() {
463 $this->getWC()->woocommerce_single_product_summary();
464 }
465 public function relay_woocommerce_order_status_changed() {
466 $args = func_get_args();
467 $this->getWC()->woocommerce_order_status_changed(...$args);
468 }
469 public function relay_woocommerce_order_partially_refunded() {
470 $args = func_get_args();
471 $this->getWC()->woocommerce_order_partially_refunded(...$args);
472 }
473 public function relay_woocommerce_update_order() {
474 $args = func_get_args();
475 $this->getWC()->woocommerce_update_order(...$args);
476 }
477 public function relay_woocommerce_order_item_display_meta_key() {
478 $args = func_get_args();
479 return $this->getWC()->woocommerce_order_item_display_meta_key(...$args);
480 }
481 public function relay_woocommerce_order_item_display_meta_value() {
482 $args = func_get_args();
483 return $this->getWC()->woocommerce_order_item_display_meta_value(...$args);
484 }
485 public function relay_wpo_wcpdf_after_item_meta() {
486 $args = func_get_args();
487 $this->getWC()->wpo_wcpdf_after_item_meta(...$args);
488 }
489 public function relay_woocommerce_order_item_meta_start() {
490 $args = func_get_args();
491 $this->getWC()->woocommerce_order_item_meta_start(...$args);
492 }
493 public function relay_woocommerce_product_after_variable_attributes() {
494 $args = func_get_args();
495 $this->getWC()->woocommerce_product_after_variable_attributes(...$args);
496 }
497 public function relay_woocommerce_save_product_variation() {
498 $args = func_get_args();
499 $this->getWC()->woocommerce_save_product_variation(...$args);
500 }
501 public function relay_woocommerce_email_order_meta() {
502 $args = func_get_args();
503 $this->getWC()->woocommerce_email_order_meta(...$args);
504 }
505 public function relay_woocommerce_thankyou_() {
506 $args = func_get_args();
507 $this->getWC()->woocommerce_thankyou_(...$args);
508 }
509 public function relay_sasoEventtickets_cronjob_daily() {
510 $this->getTicketHandler()->cronJobDaily();
511 }
512
513 public function plugin_deactivated() {
514 $this->cronjob_daily_deactivate();
515 $this->getDB();
516 sasoEventticketsDB::plugin_deactivated();
517 do_action( $this->_do_action_prefix.'main_plugin_deactivated' );
518 }
519 public function plugin_uninstall() {
520 $this->getDB();
521 sasoEventticketsDB::plugin_uninstall();
522 $this->getAdmin();
523 sasoEventtickets_AdminSettings::plugin_uninstall();
524 do_action( $this->_do_action_prefix.'main_WooCommercePluginLoaded' );
525 }
526 public function plugin_activated($is_network_wide=false) { // und auch für updates, macht es einfacher
527 $this->getDB(); // um installiere Tabellen auszuführen
528 update_option('SASO_EVENTTICKETS_PLUGIN_VERSION', SASO_EVENTTICKETS_PLUGIN_VERSION);
529 $this->getAdmin()->generateFirstCodeList();
530 $this->cronjob_daily_activate();
531 do_action( $this->_do_action_prefix.'activated' );
532 do_action( $this->_do_action_prefix.'main_plugin_activated' );
533 }
534 public function plugins_loaded() {
535 if (SASO_EVENTTICKETS_PLUGIN_VERSION !== get_option('SASO_EVENTTICKETS_PLUGIN_VERSION', '')) $this->plugin_activated(); // vermutlich wurde die aktivierung übersprungen, bei änderungen direkt an den files
536 }
537 public function initialize_plugin() {
538 $this->getDB(); // um installiere Tabellen auszuführen
539 do_action( $this->_do_action_prefix.'initialized' );
540 do_action( $this->_do_action_prefix.'main_initialize_plugin' );
541 }
542 function show_user_profile($profileuser) {
543 $this->getAdmin()->show_user_profile($profileuser);
544 do_action( $this->_do_action_prefix.'main_show_user_profile' );
545 }
546 function register_options_page() {
547 $allowed = $this->isUserAllowedToAccessAdminArea();
548 $allowed = apply_filters( $this->_add_filter_prefix.'main_options_page', $allowed );
549 if ($allowed) {
550 add_options_page(__('Event Tickets', 'event-tickets-with-ticket-scanner'), 'Event Tickets', 'manage_options', 'event-tickets-with-ticket-scanner', [$this,'options_page']);
551 add_menu_page( __('Event Tickets', 'event-tickets-with-ticket-scanner'), 'Event Tickets', 'read', 'event-tickets-with-ticket-scanner', [$this,'options_page'], plugins_url( "",__FILE__ )."/img/icon_event-tickets-with-ticket-scanner_18px.gif", null );
552 }
553 do_action( $this->_do_action_prefix.'main_register_options_page' );
554 }
555
556 function options_page() {
557 $allowed = $this->isUserAllowedToAccessAdminArea();
558 $allowed = apply_filters( $this->_add_filter_prefix.'main_options_page', $allowed );
559 if ( !$allowed ) {
560 wp_die( __( 'You do not have sufficient permissions to access this page.', 'event-tickets-with-ticket-scanner' ) );
561 }
562
563 wp_enqueue_style("wp-jquery-ui-dialog");
564
565 $js_url = "jquery.qrcode.min.js?_v=".$this->_js_version;
566 wp_register_script('ajax_script2', plugins_url( "3rd/".$js_url,__FILE__ ), array('jquery', 'jquery-ui-dialog'));
567 wp_enqueue_script('ajax_script2');
568
569 wp_enqueue_media(); // um die js wp.media lib zu laden
570
571 // einbinden das js starter skript
572 $js_url = $this->_js_file."?_v=".$this->_js_version;
573 if (defined( 'WP_DEBUG')) $js_url .= '&debug=1';
574 wp_register_script('ajax_script_backend', plugins_url( $js_url,__FILE__ ), array('jquery', 'jquery-ui-dialog', 'wp-i18n'));
575 wp_enqueue_script('ajax_script_backend');
576 wp_set_script_translations('ajax_script_backend', 'event-tickets-with-ticket-scanner', __DIR__.'/languages');
577
578 // per script eine variable einbinden, die url hat den wp-admin prefix
579 // damit im backend.js dann die richtige callback url genutzt werden kann
580 $vars = array(
581 '_plugin_home_url' =>plugins_url( "",__FILE__ ),
582 '_action' => $this->_prefix.'_executeAdminSettings',
583 '_max'=>$this->getBase()->getMaxValues(),
584 '_isPremium'=>$this->isPremium(),
585 '_isUserLoggedin'=>is_user_logged_in(),
586 '_premJS'=>$this->isPremium() && method_exists($this->getPremiumFunctions(), "getJSBackendFile") ? $this->getPremiumFunctions()->getJSBackendFile() : '',
587 'url' => admin_url( 'admin-ajax.php' ),
588 'ticket_url' => $this->getCore()->getTicketURLPath(),
589 'nonce' => wp_create_nonce( $this->_js_nonce ),
590 'ajaxActionPrefix' => $this->_prefix,
591 'divPrefix' => $this->_prefix,
592 'divId' => $this->_divId,
593 'jsFiles' => plugins_url( 'backend.js?_v='.$this->_js_version,__FILE__ )
594 );
595 $vars = apply_filters( $this->_add_filter_prefix.'main_options_page', $vars );
596 wp_localize_script(
597 'ajax_script_backend',
598 'Ajax_'.$this->_prefix, // name der injected variable
599 $vars
600 );
601
602 do_action( $this->_do_action_prefix.'main_options_page' );
603
604 $versions = $this->getPluginVersions();
605 $versions_tail = $versions['basic'].($versions['premium'] != "" ? ', Premium: '.$versions['premium'] : '');
606 $version_tail_add = "";
607 if ($versions['debug'] != "") $version_tail_add .= 'DEBUG: '.$versions['debug'].', LANG: '.determine_locale();
608 ?>
609 <div style="padding-top:10px;">
610 <table style="border:none;width:98%;margin-bottom:10px;">
611 <tr>
612 <td style="vertical-align:middle;width:195px;">
613 <img style="height:40px;" src="<?php echo plugins_url( "",__FILE__ ); ?>/img/logo_event-tickets-with-ticket-scanner.gif">
614 </td>
615 <td>
616 <h2 style="margin-top:0;padding-top:0;margin-bottom:5px;">Event Tickets With WooCommerce <?php _e('Version', 'event-tickets-with-ticket-scanner'); ?>: <?php echo $versions_tail; ?></h2>
617 <?php _e('If you like our plugin, then please give us a', 'event-tickets-with-ticket-scanner'); ?> <a target="_blank" href="https://wordpress.org/support/plugin/event-tickets-with-ticket-scanner/reviews?rate=5#new-post">�
618
619
620
621
622 5-Star Rating</a>. <?php echo $version_tail_add; ?>
623 </div>
624 </td>
625 <td style="font-size:20px;vertical-align:middle;text-align:right;" data-id="plugin_info_area_premium_status"></td>
626 </tr>
627 </table>
628 <div style="clear:both;" data-id="plugin_addons"></div>
629 <div style="clear:both;" data-id="plugin_info_area"></div>
630 <div style="clear:both;" id="<?php echo esc_attr($this->_divId); ?>"></div>
631 <div style="margin-top:100px;">
632 <hr>
633 <a name="shortcodedetails"></a>
634 <h3>Documentation</h3>
635 <p><span class="dashicons dashicons-external"></span><a href="https://vollstart.com/event-tickets-with-ticket-scanner/docs/" target="_blank">Click here, to visit the documentation of this plugin.</a></p>
636 <h3><?php _e('Plugin Rating', 'event-tickets-with-ticket-scanner'); ?></h3>
637 <p><?php _e('If you like our plugin, then please give us a', 'event-tickets-with-ticket-scanner'); ?> <a target="_blank" href="https://wordpress.org/support/plugin/event-tickets-with-ticket-scanner/reviews?rate=5#new-post">�
638
639
640
641
642 5-Star Rating</a>.</p>
643 <h3><?php _e('Ticket Sale option', 'event-tickets-with-ticket-scanner'); ?></h3>
644 <p><?php _e('You can use this plugin to sell tickets and even redeem them. Check out the documentation for', 'event-tickets-with-ticket-scanner'); ?> <a target="_blank" href="https://vollstart.com/event-tickets-with-ticket-scanner/docs/#ticket"><?php _e('more details here', 'event-tickets-with-ticket-scanner'); ?></a>.</p>
645 <h3><?php _e('Premium Homepage', 'event-tickets-with-ticket-scanner'); ?></h3>
646 <p><?php _e('You can find more details about the', 'event-tickets-with-ticket-scanner'); ?> <a target="_blank" href="https://vollstart.com/event-tickets-with-ticket-scanner/"><?php _e('premium version here', 'event-tickets-with-ticket-scanner'); ?></a>.</p>
647 <!--
648 <h3>Shortcode parameter In- & Output</h3>
649 <a href="https://vollstart.com/event-tickets-with-ticket-scanner/docs/" target="_blank">Click here for more help about the options</a>
650 <p>You can use your own HTML input, output and trigger component. If you add the parameters (all 3 mandatory to use this feature), then the default input area will not be rendered.</p>
651 <ul>
652 <li><b>inputid</b><br>inputid="html-element-id". The value of this component will be taken. It need to be an HTML input element. We will access the value-parameter of it.</li>
653 <li><b>triggerid</b><br>triggerid="html-element-id". The onclick event of this component will be replaced by our function to call the server validation with the code.</li>
654 <li><b>outputid</b><br>outputid="html-element-id". The content of this component will be replaced by the server result after the check . We will use the innerHTML property of it, so use a DIV, SPAN, TD or similar for best results.</li>
655 </ul>
656 <h3>Shortcode parameter Javascript</h3>
657 <p>You can add your Javascript function name. Both parameters are optional and not required. If functions will be called before the code is sent to the server or displaying the result.</p>
658 <ul>
659 <li><b>jspre</b><br>jspre="function-name". The function will be called. The input parameter will be the code. If your function returns a value, than this returned value will be used otherwise the entered code will be used.</li>
660 <li><b>jsafter</b><br>jsafter="function-name". The function will be called. The input parameter will be the result JSON object from the server.</li>
661 </ul>
662 -->
663 <h3><?php _e('Shortcode to display the event calendar form within a page', 'event-tickets-with-ticket-scanner'); ?></h3>
664 <b>[<?php echo esc_html($this->_shortcode_eventviews); ?>]</b>
665 <p><?php _e('The event calendar form will be displayed. You can add the following parameters to change the output:', 'event-tickets-with-ticket-scanner'); ?></p>
666 <ul>
667 <!--<li>view<br>Values: calendar, list or calendar|list<br>Default: list</li>-->
668 <li>months_to_show<br>Values can be a number higher than 0. Default: 3</li>
669 </ul>
670 <p>CSS file: <a href="<?php echo plugins_url( "",__FILE__ ); ?>/css/calendar.css" target="_blank">calendar.css</a></p>
671 <h3><?php _e('Shortcode to display the assigned tickets and codes of an user within a page', 'event-tickets-with-ticket-scanner'); ?></h3>
672 <b>[<?php echo esc_html($this->_shortcode_mycode); ?>]</b>
673 <p>
674 The list will be human readable in a table - default.<br>
675 You can add two parameter to change the output. <br>
676 format: only json for now possible.
677 display: one or more values. Values are seperated with a comma. Possible values: codes,validation,user,used,confirmedCount,woocommerce,wc_rp,wc_ticket<br>
678 e.g. [<?php echo esc_html($this->_shortcode_mycode); ?> format="json" display="code,wc_ticket"]<br>
679 The return value is a JSON string. So might want to add this shortcode within a Javascript HTML block to access the variable.
680 </p>
681 <h3><?php _e('Shortcode to display the ticket scanner within a page', 'event-tickets-with-ticket-scanner'); ?></h3>
682 <?php _e('Useful if you cannot open the ticket scanner due to security issues.', 'event-tickets-with-ticket-scanner'); ?><br>
683 <b>[<?php echo esc_html($this->_shortcode_ticket_scanner); ?>]</b>
684 <h3><?php _e('PHP Filters', 'event-tickets-with-ticket-scanner'); ?></h3>
685 <p><?php _e('You can use PHP code to register your filter functions for the validation check.', 'event-tickets-with-ticket-scanner'); ?>
686 <a href="https://vollstart.com/event-tickets-with-ticket-scanner/docs/#filters" target="_blank"><?php _e('Click here for more help about the functions', 'event-tickets-with-ticket-scanner'); ?></a>
687 </p>
688 <ul>
689 <li>add_filter('<?php echo $this->_add_filter_prefix.'beforeCheckCodePre'; ?>', 'myfunc', 20, 1)</li>
690 <li>add_filter('<?php echo $this->_add_filter_prefix.'beforeCheckCode'; ?>', 'myfunc', 20, 1)</li>
691 <li>add_filter('<?php echo $this->_add_filter_prefix.'afterCheckCodePre'; ?>', 'myfunc', 20, 1)</li>
692 <li>add_filter('<?php echo $this->_add_filter_prefix.'afterCheckCode'; ?>', 'myfunc', 20, 1)</li>
693 </ul>
694 <p>More BETA filters and actions hooks can be found <a href="https://vollstart.com/event-tickets-with-ticket-scanner/docs/ticket-plugin-api/" target="_blank">here (NOT STABLE, be aware that they might be changed in the future)</a>.
695 <p style="text-align:center;"><a target="_blank" href="https://vollstart.com">VOLLSTART</a> - More plugins: <a target="_blank" href="https://wordpress.org/plugins/serial-codes-generator-and-validator/">Serial Code Validator</a></p>
696 </div>
697 </div>
698 <?php
699 do_action( $this->_do_action_prefix.'options_page' );
700 }
701
702 public function isUserAllowedToAccessAdminArea() {
703 if ($this->isAllowedAccess != null) return $this->isAllowedAccess;
704 if ($this->getOptions()->isOptionCheckboxActive('allowOnlySepcificRoleAccessToAdmin')) {
705 // check welche rollen
706 $user = wp_get_current_user();
707 $user_roles = (array) $user->roles;
708 if (in_array("administrator", $user_roles)) {
709 $this->isAllowedAccess = true;
710 } else {
711 $adminAreaAllowedRoles = $this->getOptions()->getOptionValue('adminAreaAllowedRoles');
712 if (!is_array($adminAreaAllowedRoles)) {
713 if (empty($adminAreaAllowedRoles)) {
714 $adminAreaAllowedRoles = [];
715 } else {
716 $adminAreaAllowedRoles = [$adminAreaAllowedRoles];
717 }
718 }
719 foreach($adminAreaAllowedRoles as $role_name) {
720 if (in_array($role_name, $user_roles)) {
721 $this->isAllowedAccess = true;
722 break;
723 };
724 }
725 }
726 } else {
727 $this->isAllowedAccess = true;
728 }
729 $this->isAllowedAccess = apply_filters( $this->_add_filter_prefix.'main_isUserAllowedToAccessAdminArea', $this->isAllowedAccess );
730 return $this->isAllowedAccess;
731 }
732
733 public function executeAdminSettings_a() {
734 if (!SASO_EVENTTICKETS::issetRPara('a_sngmbh')) return wp_send_json_success("a_sngmbh not provided");
735 return $this->executeAdminSettings(SASO_EVENTTICKETS::getRequestPara('a_sngmbh')); // to prevent WP adds parameters
736 }
737
738 public function executeAdminSettings($a=0, $data=null) {
739 if ($this->isUserAllowedToAccessAdminArea()) {
740 if ($a === 0 && !SASO_EVENTTICKETS::issetRPara('a_sngmbh')) return wp_send_json_success("a not provided");
741
742 if ($data == null) {
743 $data = SASO_EVENTTICKETS::issetRPara('data') ? SASO_EVENTTICKETS::getRequestPara('data') : [];
744 }
745 if ($a === 0 || empty($a) || trim($a) == "") {
746 $a = SASO_EVENTTICKETS::getRequestPara('a_sngmbh');
747 }
748 do_action( $this->_do_action_prefix.'executeAdminSettings', $a, $data );
749 return $this->getAdmin()->executeJSON($a, $data, false, false); // with nonce check
750 }
751 }
752
753 public function executeFrontend_a() {
754 return $this->executeFrontend(); // to prevent WP adds parameters
755 }
756
757 public function executeWCBackend() {
758 if (!SASO_EVENTTICKETS::issetRPara('a_sngmbh')) return wp_send_json_success("a_sngmbh not provided");
759 $data = SASO_EVENTTICKETS::issetRPara('data') ? SASO_EVENTTICKETS::getRequestPara('data') : [];
760 return $this->getWC()->executeJSON(SASO_EVENTTICKETS::getRequestPara('a_sngmbh'), $data);
761 }
762
763 public function executeFrontend($a=0, $data=null) {
764 $sasoEventtickets_Frontend = $this->getFrontend();
765 if ($a === 0 && !SASO_EVENTTICKETS::issetRPara('a_sngmbh')) return wp_send_json_success("a not provided");
766
767 if ($data == null) {
768 $data = SASO_EVENTTICKETS::issetRPara('data') ? SASO_EVENTTICKETS::getRequestPara('data') : [];
769 }
770 if ($a === 0 || empty($a) || trim($a) == "") {
771 $a = SASO_EVENTTICKETS::getRequestPara('a_sngmbh');
772 }
773 do_action( $this->_do_action_prefix.'executeFrontend', $a, $data );
774 return $sasoEventtickets_Frontend->executeJSON($a, $data);
775 }
776
777 public function replacingShortcode($attr=[], $content = null, $tag = '') {
778 add_filter( $this->_add_filter_prefix.'replaceShortcode', [$this, 'replaceShortcode'], 10, 3 );
779 $ret = apply_filters( $this->_add_filter_prefix.'replaceShortcode', $attr, $content, $tag );
780 return $ret;
781 }
782
783 public function setTicketScannerJS() {
784 wp_enqueue_style("wp-jquery-ui-dialog");
785
786 $js_url = "jquery.qrcode.min.js?_v=".$this->getPluginVersion();
787 wp_enqueue_script(
788 'ajax_script2',
789 plugins_url( "3rd/".$js_url,__FILE__ ),
790 array('jquery', 'jquery-ui-dialog')
791 );
792
793 $js_url = plugin_dir_url(__FILE__)."3rd/html5-qrcode.min.js?_v=".$this->getPluginVersion();
794 wp_register_script('html5-qrcode', $js_url, array('jquery', 'jquery-ui-dialog'));
795 wp_enqueue_script('html5-qrcode');
796
797 // https://github.com/nimiq/qr-scanner - NEW scanner lib
798 $js_url = plugin_dir_url(__FILE__)."3rd/qr-scanner-1.4.2/qr-scanner.umd.min.js?_v=".$this->getPluginVersion();
799 wp_register_script('qr-scanner', $js_url, array('jquery', 'jquery-ui-dialog'));
800 wp_enqueue_script('qr-scanner');
801
802 $js_url = "ticket_scanner.js?_v=".$this->getPluginVersion();
803 if (defined('WP_DEBUG')) $js_url .= '&t='.current_time("timestamp");
804 $js_url = plugins_url( $js_url,__FILE__ );
805 wp_register_script('ajax_script_ticket_scanner', $js_url, array('jquery', 'jquery-ui-dialog', 'wp-i18n'));
806 wp_enqueue_script('ajax_script_ticket_scanner');
807 wp_set_script_translations('ajax_script_ticket_scanner', 'event-tickets-with-ticket-scanner', __DIR__.'/languages');
808
809 $ticketScannerDontRememberCamChoice = $this->getOptions()->isOptionCheckboxActive("ticketScannerDontRememberCamChoice") ? true : false;
810
811 $vars = [
812 'root' => esc_url_raw( rest_url() ),
813 '_plugin_home_url' =>plugins_url( "",__FILE__ ),
814 '_action' => $this->_prefix.'_executeAdminSettings',
815 '_isPremium'=>$this->isPremium(),
816 '_isUserLoggedin'=>is_user_logged_in(),
817 '_userId'=>get_current_user_id(),
818 '_restPrefixUrl'=>SASO_EVENTTICKETS::getRESTPrefixURL(),
819 '_siteUrl'=>get_site_url(),
820 '_params'=>["auth"=>$this->getAuthtokenHandler()::$authtoken_param],
821 //'url' => admin_url( 'admin-ajax.php' ), // not used for now in ticketscanner.js
822 'url' => rest_get_server(), // not used for now in ticketscanner.js
823 'nonce' => wp_create_nonce( 'wp_rest' ),
824 //'nonce' => wp_create_nonce( $this->_js_nonce ),
825 'ajaxActionPrefix' => $this->_prefix,
826 'wcTicketCompatibilityModeRestURL' => $this->getOptions()->getOptionValue('wcTicketCompatibilityModeRestURL', ''),
827 'IS_PRETTY_PERMALINK_ACTIVATED' => get_option('permalink_structure') ? true :false,
828 'ticketScannerDontRememberCamChoice' => $ticketScannerDontRememberCamChoice,
829 'ticketScannerStartCamWithoutButtonClicked' => $this->getOptions()->isOptionCheckboxActive('ticketScannerStartCamWithoutButtonClicked'),
830 'ticketScannerDontShowOptionControls' => $this->getOptions()->isOptionCheckboxActive('ticketScannerDontShowOptionControls'),
831 'ticketScannerScanAndRedeemImmediately' => $this->getOptions()->isOptionCheckboxActive('ticketScannerScanAndRedeemImmediately'),
832 'ticketScannerHideTicketInformation' => $this->getOptions()->isOptionCheckboxActive('ticketScannerHideTicketInformation'),
833 'ticketScannerDontShowBtnPDF' => $this->getOptions()->isOptionCheckboxActive('ticketScannerDontShowBtnPDF'),
834 'ticketScannerDontShowBtnBadge' => $this->getOptions()->isOptionCheckboxActive('ticketScannerDontShowBtnBadge'),
835 'ticketScannerDisplayTimes' => $this->getOptions()->isOptionCheckboxActive('ticketScannerDisplayTimes')
836 ];
837 $vars = apply_filters( $this->_add_filter_prefix.'main_setTicketScannerJS', $vars );
838 wp_localize_script(
839 'ajax_script_ticket_scanner',
840 'Ajax_'.$this->_prefix, // name der injected variable
841 $vars
842 );
843
844 do_action( $this->_do_action_prefix.'main_setTicketScannerJS', $js_url );
845 }
846
847 public function replacingShortcodeTicketScanner($attr=[], $content = null, $tag = '') {
848 $this->setTicketScannerJS();
849 return '
850 <center>
851 <div style="width:90%;max-width:1024px;">'.$this->getTicketHandler()->getTicketScannerHTMLBoilerplate().'
852 </div>
853 </center>
854 ';
855 }
856
857 public function getCodesTextAsShortList($codes) {
858 $ret = "";
859 if (count($codes) > 0) {
860 $ret = '<table>';
861 $wcTicketUserProfileDisplayTicketDetailURL = $this->getOptions()->isOptionCheckboxActive("wcTicketUserProfileDisplayTicketDetailURL");
862 $wcTicketUserProfileDisplayRedeemAmount = $this->getOptions()->isOptionCheckboxActive("wcTicketUserProfileDisplayRedeemAmount");
863
864 $label_expired = $this->getOptions()->getOptionValue('wcTicketTransTicketExpired', 'EXPIRED');
865 $label_stolen = $this->getOptions()->getOptionValue('wcTicketTransTicketIsStolen', 'REPORTED AS STOLEN');
866 $label_notvalid = $this->getOptions()->getOptionValue('wcTicketTransTicketNotValid', 'DISABLED');
867
868 $myCodes = [];
869 foreach($codes as $idx => $codeObj) {
870 $metaObj = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
871
872 $_c = '<tr><td style="text-align:right;">'.($idx + 1).'.</td><td>'.$codeObj['code_display'].'</td><td>';
873 if ($codeObj['aktiv'] == 1) {
874 if ($this->getCore()->checkCodeExpired($codeObj)) {
875 $_c .= $label_expired;
876 }
877 } else if ($codeObj['aktiv'] == 0) {
878 $_c .= $label_notvalid;
879 } else if ($codeObj['aktiv'] == 2) {
880 $_c .= $label_stolen;
881 }
882 $_c .= '</td>';
883
884 if ($wcTicketUserProfileDisplayTicketDetailURL) {
885 $_c .= "<td>";
886 $url = $this->getCore()->getTicketURL($codeObj, $metaObj);
887 if (!empty($url)) {
888 $_c .= '<a href="'.$url.'" target="_blank">Ticket Details</a>';
889 }
890 $_c .= "</td>";
891 }
892 if ($wcTicketUserProfileDisplayRedeemAmount && function_exists("wc_get_product")) {
893 $_c .= "<td>";
894 $text_redeem_amount = $this->getTicketHandler()->getRedeemAmountText($codeObj, $metaObj, false);
895 if (!empty($text_redeem_amount)) {
896 $_c .= $text_redeem_amount;
897 }
898 $_c .= "<td>";
899 }
900 $_c .= "</tr>";
901 $myCodes[] = $_c;
902 }
903 $ret .= implode("", $myCodes);
904 $ret .= "</table>";
905 }
906 $ret = apply_filters( $this->_add_filter_prefix.'main_getCodesTextAsShortList', $ret, $codes );
907 return $ret;
908 }
909
910 public function getMyCodeText($user_id, $attr=[], $content = null, $tag = '') {
911 $ret = '';
912 // check ob eingeloggt
913 $pre_text = $this->getOptions()->getOptionValue('userDisplayCodePrefix', '');
914 if (!empty($pre_text)) $pre_text .= " ";
915
916 if ($user_id > 0) {
917 // lade codes mit user_id
918 $codes = $this->getCore()->getCodesByRegUserId($user_id);
919 $ret .= "<b>".$pre_text."</b><br>";
920 $ret .= $this->getCodesTextAsShortList($codes);
921 }
922 if (empty($ret) && $this->getOptions()->isOptionCheckboxActive('userDisplayCodePrefixAlways')) {
923 $ret .= $pre_text;
924 }
925 $ret = apply_filters( $this->_add_filter_prefix.'main_getMyCodeText', $ret, $user_id, $attr, $content, $tag);
926 return $ret;
927 }
928 public function getMyCodeFormatted($user_id, $attr=[], $content = null, $tag = '') {
929 $format = "json";
930 if (isset($attr["format"])) {
931 $format = strtolower(trim(sanitize_key($attr["format"])));
932 }
933 $display = ["codes"];
934 if (isset($attr["display"])) {
935
936 $_d = trim(sanitize_text_field($attr["display"]));
937 $_da = explode(",", $_d);
938 if (count($_da) > 0) {
939 $display = [];
940 }
941 foreach ($_da as $item) {
942 $item = trim($item);
943 $display[] = $item;
944 }
945 }
946
947 $output = [];
948 //codes,validation,user,used,confirmedCount,woocommerce,wc_rp,wc_ticket
949 $codes = $this->getCore()->getCodesByRegUserId($user_id);
950 $metas = [];
951 foreach($codes as $codeObj) {
952 $metas[$codeObj["code"]] = $this->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
953 }
954 foreach ($display as $item) {
955 $output[$item] = [];
956 if ($item == "codes") {
957 foreach($codes as $codeObj) {
958 if (isset($codeObj["meta"])) {
959 unset($codeObj["meta"]);
960 }
961 $output[$item][] = $codeObj;
962 }
963 } elseif($item == "confirmedCount") {
964 foreach($metas as $key => $meta) {
965 $output[$item][] = array_merge(["value"=>$meta[$item]], ["code"=>$key]);
966 }
967 } else {
968 foreach($metas as $key => $m) {
969 if (is_array($m) && isset($m[$item])) {
970 $meta = $m[$item];
971 if (isset($meta["stats_redeemed"])) {
972 unset($meta["stats_redeemed"]);
973 }
974 if (isset($meta["set_by_admin"])) {
975 unset($meta["set_by_admin"]);
976 }
977 if (isset($meta["redeemed_by_admin"])) {
978 unset($meta["redeemed_by_admin"]);
979 }
980 $output[$item][] = array_merge($meta, ["code"=>$key]);
981 }
982 }
983 }
984 }
985
986 switch($format) {
987 case "json":
988 default:
989 $ret = $this->getCore()->json_encode_with_error_handling($output);
990 }
991 $ret = apply_filters( $this->_add_filter_prefix.'main_getMyCodeFormatted', $ret, $user_id, $attr, $content, $tag, $output);
992 return $ret;
993 }
994
995 public function replacingShortcodeMyCode($attr=[], $content = null, $tag = '') {
996 $user_id = get_current_user_id();
997
998 if (count($attr) > 0 && isset($attr["format"])) {
999 return $this->getMyCodeFormatted($user_id, $attr, $content, $tag);
1000 } else {
1001 return $this->getMyCodeText($user_id, $attr, $content, $tag);
1002 }
1003 }
1004
1005 public function replacingShortcodeEventViews($attr=[], $content = null, $tag = '') {
1006 // iterate over all woocommerce products and check if they are an event
1007 $view = "calendar|list";
1008 if (isset($attr["view"])) {
1009 $view = strtolower(trim(sanitize_key($attr["view"])));
1010 }
1011 $months_to_show = 3;
1012 if (isset($attr["months_to_show"])) {
1013 $m = intval($attr["months_to_show"]);
1014 if ($m > 0) $months_to_show = $m;
1015 }
1016
1017 $month_start = strtotime(date("Y-m-1 00:00:00"));
1018 //$month_end = strtotime(date("Y-m-t 23:59:59"));
1019 $month_end = strtotime(date("Y-m-1 23:59:59", strtotime("+".$months_to_show." month", $month_start)));
1020
1021 $products_args = array(
1022 'post_type' => 'product',
1023 'post_status' => 'publish',
1024 'posts_per_page' => -1, // -1 zeigt alle Produkte an
1025 'meta_query' => array(
1026 [
1027 'key' => 'saso_eventtickets_is_ticket',
1028 'value' => 'yes',
1029 'compare' => '='
1030 ]
1031 )
1032 );
1033 $posts = get_posts($products_args); // get only ticket products
1034
1035 $list_infos = [
1036 'months_to_show'=>$months_to_show,
1037 'month_start'=>$month_start,
1038 'month_end'=>$month_end,
1039 'view'=>$view
1040 ];
1041 $products_to_show = [];
1042 // Ergebnisse überprüfen
1043 foreach ($posts as $post) {
1044 $product_ids = [];
1045 $product = wc_get_product( $post->ID );
1046
1047 // check if event is variant product
1048 $is_variable = $product->get_type() == "variable";
1049 if ($is_variable) {
1050 // check if event dates are the same for all variants
1051 $date_is_for_all_variants = get_post_meta( $product_id, 'saso_eventtickets_is_date_for_all_variants', true ) == "yes" ? true : false;
1052 if ($date_is_for_all_variants == false) {
1053 // if not add also the variants
1054 $childs = $product->get_children();
1055 foreach ($childs as $child_id) {
1056 if (get_post_meta($child_id, '_saso_eventtickets_is_not_ticket', true) == "yes") {
1057 continue;
1058 }
1059 $product_ids[] = $child_id;
1060 }
1061 }
1062 } else {
1063 $product_ids[] = $product->get_id();
1064 }
1065
1066 foreach ($product_ids as $product_id) {
1067 $product = wc_get_product( $product_id );
1068 $dates = $this->getTicketHandler()->calcDateStringAllowedRedeemFrom($product_id);
1069 //if ($dates['ticket_end_date_timestamp'] > $month_start && $dates['ticket_start_date_timestamp'] < $month_end) {
1070 if ($dates['ticket_end_date_timestamp'] >= $month_start || ($dates['ticket_start_date_timestamp'] >= $month_start && $dates['ticket_start_date_timestamp'] <= $month_end)) {
1071 // set product to hidden
1072 $product_data = array(
1073 'ID' => $product_id,
1074 'dates' => $dates,
1075 'event'=> [
1076 'location' => trim(get_post_meta( $product_id, 'saso_eventtickets_event_location', true )),
1077 'location_label' => wp_kses_post(trim($this->getAdmin()->getOptionValue("wcTicketTransLocation")))
1078 ],
1079 'product' => [
1080 'title' => $product->get_name(),
1081 'url' => get_permalink($product_id),
1082 'price' =>$product->get_price(),
1083 'price_html' => $product->get_price_html(),
1084 'type' => $product->get_type(),
1085 ]
1086 );
1087 $products_to_show[] = $product_data;
1088 }
1089 }
1090 }
1091
1092 $divId = "sasoEventTicketsValidator_eventsview";
1093
1094 // add js for the events
1095 wp_enqueue_style("wp-jquery-ui-dialog");
1096
1097 $js_url = "ticket_events.js?_v=".$this->getPluginVersion();
1098 if (defined('WP_DEBUG')) $js_url .= '&t='.current_time("timestamp");
1099 $js_url = plugins_url( $js_url,__FILE__ );
1100 wp_register_script('ajax_script_ticket_events', $js_url, array('jquery', 'jquery-ui-dialog', 'wp-i18n'));
1101 wp_enqueue_script('ajax_script_ticket_events');
1102 wp_set_script_translations('ajax_script_ticket_events', 'event-tickets-with-ticket-scanner', __DIR__.'/languages');
1103 wp_enqueue_style("ticket_events_css", plugins_url( "",__FILE__ ).'/css/calendar.css');
1104
1105 // add all events as an array for max 3 months??? or config parameter
1106 $vars = [
1107 'root' => esc_url_raw( rest_url() ),
1108 '_plugin_home_url' =>plugins_url( "",__FILE__ ),
1109 '_action' => $this->_prefix.'_executeFrontendEvents',
1110 '_isPremium'=>$this->isPremium(),
1111 '_isUserLoggedin'=>is_user_logged_in(),
1112 '_userId'=>get_current_user_id(),
1113 '_premJS'=>$this->isPremium() && method_exists($this->getPremiumFunctions(), "getJSFrontEventFile") ? $this->getPremiumFunctions()->getJSFrontEventFile() : '',
1114 '_siteUrl'=>get_site_url(),
1115 'events' => $products_to_show,
1116 'list_infos' => $list_infos,
1117 'format_date' => $this->getOptions()->getOptionDateFormat(),
1118 'format_time' => $this->getOptions()->getOptionTimeFormat(),
1119 'format_datetime' => $this->getOptions()->getOptionDateTimeFormat(),
1120 'url' => admin_url( 'admin-ajax.php' ),
1121 'nonce' => wp_create_nonce( $this->_js_nonce ),
1122 'ajaxActionPrefix' => $this->_prefix,
1123 'divId' => $divId
1124 ];
1125 $vars = apply_filters( $this->_add_filter_prefix.'main_setTicketEventJS', $vars );
1126 wp_localize_script(
1127 'ajax_script_ticket_events',
1128 'Ajax_ticket_events_'.$this->_prefix, // name der injected variable
1129 $vars
1130 );
1131
1132 do_action( $this->_do_action_prefix.'main_setTicketEventJS', $js_url );
1133
1134 $ret = '';
1135 if (!isset($attr['divid']) || trim($attr['divid']) == "") {
1136 $ret .= '<div id="'.$divId.'">'.__('...loading...', 'event-tickets-with-ticket-scanner').'</div>';
1137 }
1138
1139 $ret = apply_filters( $this->_add_filter_prefix.'main_replacingShortcodeEventViews', $ret );
1140 do_action( $this->_do_action_prefix.'main_replacingShortcodeEventViews', $vars, $ret );
1141
1142 return $ret;
1143 }
1144
1145 public function replaceShortcode($attr=[], $content = null, $tag = '') {
1146 // einbinden das js starter skript
1147 $js_url = $this->_js_file."?_v=".$this->_js_version;
1148 if (defined( 'WP_DEBUG')) $js_url .= '&debug=1';
1149 $userDivId = !isset($attr['divid']) || trim($attr['divid']) == "" ? '' : trim($attr['divid']);
1150
1151 $attr = array_change_key_case( (array) $attr, CASE_LOWER );
1152
1153 wp_enqueue_script(
1154 'ajax_script_validator',
1155 plugins_url( $js_url,__FILE__ ),
1156 array('jquery', 'wp-i18n')
1157 );
1158 wp_set_script_translations('ajax_script_validator', 'event-tickets-with-ticket-scanner', __DIR__.'/languages');
1159
1160 $vars = array(
1161 'shortcode_attr'=>json_encode($attr),
1162 '_plugin_home_url' =>plugins_url( "",__FILE__ ),
1163 '_action' => $this->_prefix.'_executeFrontend',
1164 '_isPremium'=>$this->isPremium(),
1165 '_isUserLoggedin'=>is_user_logged_in(),
1166 '_premJS'=>$this->isPremium() && method_exists($this->getPremiumFunctions(), "getJSFrontFile") ? $this->getPremiumFunctions()->getJSFrontFile() : '',
1167 'url' => admin_url( 'admin-ajax.php' ),
1168 'nonce' => wp_create_nonce( $this->_js_nonce ),
1169 'ajaxActionPrefix' => $this->_prefix,
1170 'divPrefix' => $userDivId == "" ? $this->_prefix : $userDivId,
1171 'divId' => $this->_divId,
1172 'jsFiles' => plugins_url( 'validator.js?_v='.$this->_js_version, __FILE__ )
1173 );
1174 $vars['_messages'] = [
1175 'msgCheck0'=>$this->getOptions()->getOptionValue('textValidationMessage0'),
1176 'msgCheck1'=>$this->getOptions()->getOptionValue('textValidationMessage1'),
1177 'msgCheck2'=>$this->getOptions()->getOptionValue('textValidationMessage2'),
1178 'msgCheck3'=>$this->getOptions()->getOptionValue('textValidationMessage3'),
1179 'msgCheck4'=>$this->getOptions()->getOptionValue('textValidationMessage4'),
1180 'msgCheck5'=>$this->getOptions()->getOptionValue('textValidationMessage5'),
1181 'msgCheck6'=>$this->getOptions()->getOptionValue('textValidationMessage6')
1182 ];
1183 $vars = apply_filters( $this->_add_filter_prefix.'main_replaceShortcode', $vars );
1184
1185 if ($this->isPremium() && method_exists($this->getPremiumFunctions(), "addJSFrontFile")) $this->getPremiumFunctions()->addJSFrontFile();
1186
1187 wp_localize_script(
1188 'ajax_script_validator',
1189 'Ajax_'.$this->_prefix, // name of the injected variable
1190 $vars
1191 );
1192 $ret = '';
1193 if (!isset($attr['divid']) || trim($attr['divid']) == "") {
1194 $ret .= '<div id="'.$this->_divId.'">'.__('...loading...', 'event-tickets-with-ticket-scanner').'</div>';
1195 }
1196
1197 $ret = apply_filters( $this->_add_filter_prefix.'main_replaceShortcode_2', $ret );
1198 do_action( $this->_do_action_prefix.'main_replaceShortcode', $vars, $ret );
1199
1200 return $ret;
1201 }
1202 }
1203 $sasoEventtickets = new sasoEventtickets();
1204 ?>
1205