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