function __construct()
 {
     parent::__construct();
     add_action('init', array($this, 'wppizza_add_default_gateways'));
     /*add default COD gateway*/
     /************************************************************************
     			[runs only for frontend]
     		*************************************************************************/
     if (!is_admin()) {
         //|| ( defined( 'DOING_AJAX' ) && DOING_AJAX )
         add_action('init', array($this, 'wppizza_instanciate_gateways_frontend'));
     }
     if (!is_admin()) {
         add_action('init', array($this, 'wppizza_do_gateways'));
         /**output available gateway choices on order page**/
         add_action('init', array($this, 'wppizza_gateway_initialize_order'));
         /*initialize oder into db */
     }
     /************************************************************************
     			[load wpml from parent. used in ajax call, so must be available front and backend ]
     		*************************************************************************/
     add_action('init', array($this, 'wppizza_wpml_localization_gateways'), 99);
     /************************************************************************
     			[runs only in backend]
     		*************************************************************************/
     add_action('admin_init', array($this, 'wppizza_load_gateways_admin'));
     add_action('admin_init', array($this, 'wppizza_available_gateways'), 1);
     /**check if a gateways has been (un)installed and if so, update option**/
 }
 function __construct()
 {
     parent::__construct();
 }
 function __construct()
 {
     parent::__construct();
     self::$_this = $this;
     /************************************************************************
     			[runs in front AND backend]
     		*************************************************************************/
     /*sort categories**/
     add_filter('get_terms', array($this, 'wppizza_do_sort_custom_posts_category'), 10, 2);
     add_action('init', array($this, 'wppizza_require_common_input_validation_functions'));
     /*include input validation functions**/
     add_action('init', array($this, 'wppizza_require_common_output_formatting_functions'));
     /*include output formatting functions**/
     add_action('init', array($this, 'wppizza_require_common_helper_functions'));
     add_action('init', array($this, 'wppizza_register_custom_posttypes'));
     /*register custom posttype*/
     add_action('init', array($this, 'wppizza_register_custom_taxonomies'));
     /*register taxonomies*/
     add_action('init', array($this, 'wppizza_init_sessions'));
     /*needed for admin AND frontend***/
     /**add sessions to keep track of shoppingcart***/
     add_shortcode($this->pluginSlug, array($this, 'wppizza_add_shortcode'));
     //used in ajax request for cart contents so must be available when ajax and on front AND backend!
     /*class to send order emails used via ajax too so must be avialable from bckend too*/
     add_action('init', array($this, 'wppizza_send_order_emails'));
     /*category walker class to get hierarchical wppizza categories in set order ***/
     add_action('init', array($this, 'wppizza_category_walker'));
     /***************
     				[filters]
     			***************/
     /**sanitize db input vars**/
     add_filter('wppizza_filter_sanitize_order', array($this, 'wppizza_filter_sanitize_order'), 10, 1);
     add_filter('wppizza_filter_sanitize_post_vars', array($this, 'wppizza_filter_sanitize_post_vars'), 10, 1);
     add_filter('wppizza_filter_order_summary', array($this, 'wppizza_filter_order_summary_legacy'), 10, 1);
     /***************
     				[selected fields to the registration process]
     			***************/
     add_action('register_form', array($this, 'wppizza_user_register_form_display_fields'));
     add_action('user_register', array($this, 'wppizza_user_register_form_save_fields'), 100);
     /**allow rewriting of single item permalinks**/
     add_filter('wppizza_cpt_args', array($this, 'wppizza_single_item_permalink_rewrite'));
     /************************************************************************
     			[runs only for frontend]
     		*************************************************************************/
     if (!is_admin()) {
         /***EXPERIMENTAL frontend scripts - load straight after jquery ***/
         add_action('wp_enqueue_scripts', array($this, 'wppizza_load_experimental_scripts_and_styles'), 9);
         /***enqueue frontend scripts and styles***/
         add_action('wp_enqueue_scripts', array($this, 'wppizza_register_scripts_and_styles'), $this->pluginOptions['layout']['css_priority']);
         /*dequeue if set**/
         add_action('wp_print_scripts', array($this, 'wppizza_dequeue_scripts'), 100);
         /***************
         				[filters]
         			***************/
         /*include template**/
         add_filter('template_include', array($this, 'wppizza_include_template'), 1);
         /******add js functions to run after cart refresh (if using shortcode type=totals**********************************/
         add_filter('wppizza_filter_js_cart_refresh_functions', array($this, 'wppizza_filter_totals_js_cart_refresh_functions'), 10, 1);
         /**set possibly missing vars if using templates **/
         add_filter('wppizza_loop_top', array($this, 'wppizza_loop_include_vars'), 1);
         /***use loop for single post***/
         add_filter('wppizza_filter_loop', array($this, 'wppizza_filter_loop'), 10, 2);
         /***exclude selected order page from navigation */
         add_filter('get_pages', array($this, 'wppizza_exclude_order_page_from_navigation'));
         /***dont put WPPizza Categories intitle tag */
         add_filter('wp_title', array($this, 'wppizza_filter_title_tag'), 20, 3);
         /***order form, login, logout, register, guest ****/
         add_action('wppizza_order_form_before', array($this, 'wppizza_do_login_form'));
         /**login/logout**/
         add_filter('wp_authenticate', array($this, 'wppizza_authenticate'), 1, 2);
         /*authenticate and redirect**/
         add_filter('login_redirect', array($this, 'wppizza_login_redirect'), 10, 3);
         /**successful login redirect**/
         add_action('wppizza_gateway_choice_before', array($this, 'wppizza_create_user_option'));
         /**continue and register or as guest**/
         /**add additional text to initial order form display (if not empty)**/
         add_action('wppizza_order_form_inside_top', array($this, 'wppizza_do_additional_info_order_form'));
         /**add info**/
         /***reset loop query***/
         add_action('wppizza_loop_template_end', array($this, 'wppizza_reset_loop_query'));
         /**needed by some themes **/
         /***alter search query if/when required**/
         add_filter('pre_get_posts', array($this, 'wppizza_set_search_query'));
         //filter search to include wppizza
         /**filter order items when returned from db as its all stored in a array**/
         add_filter('wppizza_filter_order_db_return', array($this, 'wppizza_filter_order_db_return'), 10, 1);
         /****************************************************************
         				[single menu items]
         				if we are using a template (single-wppizza.php) or default
         				we can ignore the below, otherwise we will have to rewrite
         				some vars and disaply it in a chosen page.
         				(in case we do not want to or are not capable to deal with templates, it's at least something)
         			****************************************************************/
         if (isset($this->pluginOptions['plugin_data']['post_single_template']) && $this->pluginOptions['plugin_data']['post_single_template'] > 0) {
             /**change te permalink of any wppizza menu item to use loop template for single item instead of having to create a different template*/
             add_filter('the_permalink', array($this, 'wppizza_search_results_permalink'));
             /**change the loop query when dealing with single menu items**/
             add_filter('pre_get_posts', array($this, 'wppizza_single_items'));
             /**use loop template to also display single items**/
         }
         /***allow quantities to be changed or order page***/
         if ($this->pluginOptions['layout']['order_page_quantity_change']) {
             /**filter output to add spinner/text input*/
             add_filter('wppizza_filter_order_item_markup', array($this, 'wppizza_order_form_item_quantity_update'), 10, 3);
             /**add update button to page**/
             add_action('wppizza_order_form_last_item', array($this, 'wppizza_order_form_item_quantity_update_button'));
         }
         /***
         				if we want to be able to pass the currently selected category for this item to be able to group and sort items by category in emails etc
         				we add a hidden field to the individual items.
         			**/
         add_action('wppizza_loop_inside_after_content', array($this, 'wppizza_add_category_hidden_field'), 10, 4);
         /**add category to permalink if necessary**/
         add_filter('wppizza_filter_loop_permalink', array($this, 'wppizza_permalink_append_category'), 10, 4);
     }
     /************************************************************************
     			[runs only for admin]
     		*************************************************************************/
     if (is_admin()) {
         /**check requirements*/
         add_action('admin_init', array($this, 'wppizza_check_plugin_requirements'));
         /*check if we have the relevant php version etc**/
         add_action('admin_init', array($this, 'wppizza_admin_options_init'));
         /*if necessary, add the db option table and fill with defaults**/
         add_action('admin_menu', array($this, 'register_admin_menu_pages'));
         add_action('admin_init', array($this, 'wppizza_admin_pages_init'));
         add_action('admin_init', array($this, 'wppizza_admin_metaboxes'));
         add_action('admin_init', array($this, 'wppizza_do_admin_notice'));
         /*if necessary,show admin info screens**/
         add_action('admin_notices', array($this, 'wppizza_dmarc_nag'));
         /*dmarc nag*/
         /***enqueue backend scripts and styles***/
         add_action('admin_enqueue_scripts', array($this, 'wppizza_register_scripts_and_styles_admin'));
         /*when deleting or creating categories*/
         add_filter('delete_' . $this->pluginSlugCategoryTaxonomy . '', array($this, 'wppizza_save_sorted_custom_category'));
         add_action('create_' . $this->pluginSlugCategoryTaxonomy . '', array($this, 'wppizza_save_sorted_custom_category'));
         //runs as ajax call
         /*when saving custom post*/
         add_action('save_post', array($this, 'wppizza_admin_save_metaboxes'), 10, 2);
         /**sort menu item column in admin by name**/
         add_filter('request', array($this, 'wppizza_items_sort'));
         /*add order column**/
         add_action('manage_edit-wppizza_columns', array($this, 'wppizza_new_wppizza_column'));
         add_action('manage_wppizza_posts_custom_column', array($this, 'wppizza_show_order_column'));
         add_filter('manage_edit-wppizza_sortable_columns', array($this, 'wppizza_order_column_register_sortable'));
         //currently not in use
         /**registration fields***/
         add_action('show_user_profile', array($this, 'wppizza_user_info'));
         add_action('edit_user_profile', array($this, 'wppizza_user_info'));
         add_action('personal_options_update', array($this, 'wppizza_user_update_meta'));
         add_action('edit_user_profile_update', array($this, 'wppizza_user_update_meta'));
         /**set capability to update options otherwise only a user with 'manage_options' could update anything. **/
         add_filter('option_page_capability_' . $this->pluginSlug . '', array($this, 'wppizza_admin_option_page_capability'));
         /**allow custom order status fields. priority must be<10**/
         add_action('admin_init', array($this, 'wppizza_set_order_status'), 9);
         /**reports**/
         add_action('admin_init', array($this, 'wppizza_reports'));
         /**dashboard widget**/
         add_action('wp_dashboard_setup', array($this, 'wppizza_dashboard_widget'));
         /**cron to delete old orders**/
         add_action('wppizza_cron', array($this, 'wppizza_cron_do'));
     }
     /************************************************************************************************************************
     			[sort by and print categories to order page, cart and history
     		*************************************************************************************************************************/
     if (!is_admin()) {
         /**registration fields if using themed profile***/
         add_action('show_user_profile', array($this, 'wppizza_user_info'));
         add_action('personal_options_update', array($this, 'wppizza_user_update_meta'));
         /**filter and sort selected items by their categoryies in order page **/
         add_filter('wppizza_order_form_filter_items', array($this, 'wppizza_filter_items_by_category'), 10, 2);
         add_filter('wppizza_orderhistory_filter_items', array($this, 'wppizza_filter_items_by_category'), 10, 4);
         /**print category **/
         add_action('wppizza_order_form_item', array($this, 'wppizza_items_order_form_print_category'));
         add_action('wppizza_orderhistory_item', array($this, 'wppizza_items_show_order_print_category'));
         /******************order history******************/
         add_action('wppizza_get_orderhistory', array($this, 'wppizza_get_orderhistory'), 10, 2);
         add_action('wppizza_history_after_orders', array($this, 'wppizza_orderhistory_pagination'), 10, 3);
         add_filter('wppizza_filter_orderhistory_additional_info', array($this, 'wppizza_filter_order_additional_info'), 10, 1);
         add_filter('wppizza_filter_orderhistory_items_html', array($this, 'wppizza_filter_order_items_html'), 10, 2);
     }
     /****filter transaction id's******/
     add_filter('wppizza_filter_transaction_id', array($this, 'wppizza_filter_transaction_id'), 10, 2);
     /**cart is ajax too so has to be available from is_admin**/
     add_filter('wppizza_cart_filter_items', array($this, 'wppizza_filter_items_by_category'), 10, 2);
     /**print category **/
     add_filter('wppizza_cart_item', array($this, 'wppizza_items_cart_print_category'), 10, 2);
     /************************************************************************
     			[ajax]
     		*************************************************************************/
     add_action('wp_ajax_wppizza_admin_json', array($this, 'wppizza_admin_json'));
     add_action('wp_ajax_wppizza_json', array($this, 'wppizza_json'));
     // non logged in users
     add_action('wp_ajax_nopriv_wppizza_json', array($this, 'wppizza_json'));
 }