options = get_option( 'tracking_option' ); include 'admin/views/html-admin-page.php'; } /** * Register and add settings */ public function page_init() { // Add the section to reading settings so we can add our // fields to it add_settings_section( 'tracking_section', '', array( $this, 'tracking_section_callback_function' ), 'wp-tracking-codes' ); add_settings_section( 'google_merchant_section', '', array( $this, 'google_merchant_section_callback_function' ), 'wp-tracking-codes' ); // Add the field with the names and function to use for our new // settings, put it in our new section add_settings_field( 'tracking_analytics', 'Google Analytics UA', array( $this, 'tracking_analytics_callback_function' ), 'wp-tracking-codes', 'tracking_section' ); add_settings_field( 'tracking_analytics_remarketing', 'Google Remarketing Conversion ID', array( $this, 'tracking_analytics_remarketing_callback_function' ), 'wp-tracking-codes', 'tracking_section' ); add_settings_field( 'tracking_facebook_pixel_code', 'Facebook Pixel ID', array( $this, 'tracking_facebook_pixel_code_callback_function' ), 'wp-tracking-codes', 'tracking_section' ); add_settings_field( 'tracking_google_tag_manager', 'Google Tag Manager ID', array( $this, 'tracking_google_tag_manager_callback_function' ), 'wp-tracking-codes', 'tracking_section' ); // settings checkbox add_settings_field( 'data_layer_google_tag_manager', 'DataLayer Google Tag Manager', array( $this, 'data_layer_google_tag_manager_callback_function' ), 'wp-tracking-codes', 'google_merchant_section' ); add_settings_field( 'tracking_google_merchant', 'Google Merchant ID - Customer Reviews', array( $this, 'tracking_google_merchant_callback_function' ), 'wp-tracking-codes', 'google_merchant_section' ); add_settings_field( 'tracking_google_merchant_estimative_delivery_days', 'Google Merchant Estimative Delivery Days - Customer Reviews', array( $this, 'tracking_google_merchant_estimative_delivery_days_callback_function' ), 'wp-tracking-codes', 'google_merchant_section' ); // Register our setting so that $_POST handling is done for us and // our callback function just has to echo the register_setting( 'wp-tracking-codes', // Option group 'tracking_option', // Option name array( $this, 'sanitize' ) // Sanitize ); } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys */ public function sanitize( $input ) { $new_input = array(); if( isset( $input['analytics'] ) ) $new_input['analytics'] = sanitize_text_field( $input['analytics'] ); if( isset( $input['analytics_remarketing'] ) ) $new_input['analytics_remarketing'] = sanitize_text_field( $input['analytics_remarketing'] ); if( isset( $input['facebook_pixel_code'] ) ) $new_input['facebook_pixel_code'] = sanitize_text_field( $input['facebook_pixel_code'] ); if( isset( $input['google_tag_manager'] ) ) $new_input['google_tag_manager'] = sanitize_text_field( $input['google_tag_manager'] ); if( isset( $input['google_merchant'] ) ) $new_input['google_merchant'] = sanitize_text_field( $input['google_merchant'] ); if( isset( $input['google_merchant_estimative_delivery_days'] ) ) $new_input['google_merchant_estimative_delivery_days'] = sanitize_text_field( $input['google_merchant_estimative_delivery_days'] ); if( isset( $input['data_layer_google_tag_manager'] ) ) $new_input['data_layer_google_tag_manager'] = sanitize_text_field( $input['data_layer_google_tag_manager'] ); return $new_input; } /** * Print the Section text */ public function tracking_section_callback_function() { // print 'For all:'; } /** * Print the Section text */ public function google_merchant_section_callback_function() { print '
Example: UA-XXXXXXXX-X - Help me
', isset( $this->options['analytics'] ) ? esc_attr( $this->options['analytics']) : '', isset( $this->options['analytics'] ) && !empty($this->options['analytics']) ? 'dashicons-yes' : '' ); } public function tracking_analytics_remarketing_callback_function() { printf( 'Example: 123456789 - Help me
', isset( $this->options['analytics_remarketing'] ) ? esc_attr( $this->options['analytics_remarketing']) : '', isset( $this->options['analytics_remarketing'] ) && !empty($this->options['analytics_remarketing']) ? 'dashicons-yes' : '' ); } public function tracking_facebook_pixel_code_callback_function() { printf( 'Example: 1234567890 - Help me
', isset( $this->options['facebook_pixel_code'] ) ? esc_attr( $this->options['facebook_pixel_code']) : '', isset( $this->options['facebook_pixel_code'] ) && !empty($this->options['facebook_pixel_code']) ? 'dashicons-yes' : '' ); } public function tracking_google_tag_manager_callback_function() { printf( 'Example: GTM-XXXXXX - Help me
', isset( $this->options['google_tag_manager'] ) ? esc_attr( $this->options['google_tag_manager']) : '', isset( $this->options['google_tag_manager'] ) && !empty($this->options['google_tag_manager']) ? 'dashicons-yes' : '' ); } public function tracking_google_merchant_callback_function() { printf( 'Example: 123456789 - Help me
This function activates Seller ratings on the purchase page. How it works?
Example: 9 - The estimated average number of delivery days for all orders
This number added to the order day will be the date that Google will send the survey to the user\'s email, if user allows. How it works?
', isset( $this->options['google_merchant_estimative_delivery_days'] ) ? esc_attr( $this->options['google_merchant_estimative_delivery_days']) : '', isset( $this->options['google_merchant'] ) && !empty($this->options['google_merchant']) && isset( $this->options['google_merchant_estimative_delivery_days'] ) && !empty($this->options['google_merchant_estimative_delivery_days']) ? 'dashicons-yes' : '' ); } public function data_layer_google_tag_manager_callback_function($args) { $options = get_option('tracking_option'); $checked = ( isset($options['data_layer_google_tag_manager']) && $options['data_layer_google_tag_manager'] == 1) ? 1 : 0; printf( 'Activate to use datalayer with Standard Ecommerce (UA) - Help me
', isset( $this->options['data_layer_google_tag_manager'] ) ? esc_attr( $this->options['data_layer_google_tag_manager']) : '' ); } } if( is_admin() ) $RegisterCodes = new RegisterCodes();