options = get_option('yofla_360_options'); $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general'; ?>

360° Product Rotation Plugin Settings

'; // This prints out all hidden setting fields settings_fields('yofla_360_option_group'); do_settings_sections('yofla-360-admin-legacy'); submit_button(); echo ''; } elseif ($active_tab == 'x_woocommerce') { echo '
'; // This prints out all hidden setting fields settings_fields('yofla_360_option_group'); do_settings_sections('yofla-360-admin-woocommerce'); submit_button(); echo '
'; } else { ?>

Cache Settings

Utils()->clear_cache()) { echo 'Cache cleared!'; } else { echo 'Failed deleting cache!'; } } ?>

Delete the content of the wp-content/uploads/yofla360/_cache directory. Useful when migrating the site from http to https.

'; wp_nonce_field('test_button_clicked'); echo ''; submit_button('Delete Cache'); echo ''; echo '
'; } // end if/else ?> License Key or Id:', array($this, 'licenseid_callback'), 'yofla-360-admin', 'yofla_360_settings_section_legacy' ); //local engine add_settings_field( 'local_engine', 'Local Engine:', array($this, 'local_engine_callback'), 'yofla-360-admin', 'yofla_360_settings_section_legacy' ); //rotatetooljs_url add_settings_field( 'rotatetooljs_url', 'rotatetool.js url:
(optional)
', array($this, 'rotatetooljs_url_callback'), 'yofla-360-admin', 'yofla_360_settings_section_legacy' ); //global player styles add_settings_field( 'theme_url', 'Override player theme url:
(optional)
', array($this, 'theme_url_callback'), 'yofla-360-admin', 'yofla_360_settings_section_legacy' ); //iframe styles add_settings_field( 'iframe_styles', 'iframe_styles:', array($this, 'iframe_styles_callback'), 'yofla-360-admin', 'yofla_360_settings_section_general' ); //woocomemrce alternate embedding add_settings_field( 'woocommerce_alternate_embedding', 'WooCommerce alternate embedding:', array($this, 'woocommerce_alternate_embedding_callback'), 'yofla-360-admin', 'yofla_360_settings_section_general' ); //gaEnabled add_settings_field( 'ga_enabled', 'ga_enabled:', array($this, 'ga_enabled_callback'), 'yofla-360-admin', 'yofla_360_settings_section_shortcode' ); //ga tracking id add_settings_field( 'ga_tracking_id', 'ga_tracking_id:', array($this, 'ga_tracking_id_callback'), 'yofla-360-admin', 'yofla_360_settings_section_shortcode' ); if (YoFLA360::$isWooCommerce) { add_settings_section( 'yofla_360_settings_section_woocommerce', // ID 'WooCommerce', // Title array($this, 'print_section_info_woocommerce'), // Callback 'yofla-360-admin' // Page ); //url settings add_settings_field( 'woocommerce_360thumb_url', '360 Thumb Url:', array($this, 'woocommerce_360thumb_url_callback'), 'yofla-360-admin', 'yofla_360_settings_section_woocommerce' ); } } /** * Sanitize each setting field as needed * * @param array $input Contains all settings fields as array keys * @return array */ public function sanitize($input) { $new_input = array(); if (isset($input['license_id'])) { $new_input['license_id'] = sanitize_text_field($input['license_id']); } if (isset($input['rotatetooljs_url'])) { $new_input['rotatetooljs_url'] = sanitize_text_field($input['rotatetooljs_url']); $new_input['rotatetooljs_url'] = YoFLA360()->Utils()->addHttp($new_input['rotatetooljs_url']); } if (isset($input['theme_url'])) { $new_input['theme_url'] = sanitize_text_field($input['theme_url']); } if (isset($input['iframe_styles'])) { $new_input['iframe_styles'] = sanitize_text_field($input['iframe_styles']); //remove trailing/leading " or ' $new_input['iframe_styles'] = trim($new_input['iframe_styles'], " '\""); } if (isset($input['ga_tracking_id'])) { $new_input['ga_tracking_id'] = sanitize_text_field($input['ga_tracking_id']); //remove trailing/leading " or ' $new_input['ga_tracking_id'] = trim($new_input['ga_tracking_id'], " '\""); } if (isset($input['ga_enabled'])) { $new_input['ga_enabled'] = 1; } if (isset($input['local_engine'])) { $new_input['local_engine'] = 1; } if (isset($input['woocommerce_alternate_embedding'])) { $new_input['woocommerce_alternate_embedding'] = 1; } if (isset($input['woocommerce_360thumb_url'])) { $new_input['woocommerce_360thumb_url'] = sanitize_text_field($input['woocommerce_360thumb_url']); } return $new_input; } public function print_section_info_general() { echo ''; } /** * Print the Section text */ public function print_section_info() { $this->print_section_info_legacy(); if (isset($this->options['license_id']) && strlen($this->options['license_id']) > 0) { $firstTwoChars = strtolower( substr($this->options['license_id'],0,2)); if($firstTwoChars == 'yc'){ echo '

Thank you.

'; } else{ $data = $this->_get_order_data($this->options['license_id']); if (gettype($data) == 'array') { //$updates_end_days = round((strtotime($data['updatesend'])-time())/(60*60*24)); //$updatesend = date_format(date_create(strtotime($data['updatesend'])), 'g:ia \o\n l jS F Y'); $updatesend = date('jS F Y', strtotime($data['updatesend'])); //$updatesend = $data['updatesend']; $out = ""; $out .= ""; $out .= " "; $out .= " "; $out .= ""; $out .= ""; $out .= " "; $out .= " "; $out .= ""; $out .= ""; $out .= " "; $out .= " "; $out .= ""; $out .= "
"; $out .= " 360° Rotations by:"; $out .= " "; $out .= " {$data['license_holder']}"; $out .= "
"; $out .= " License type:"; $out .= " "; $out .= " {$data['productid']}"; $out .= "
"; $out .= " Free updates until:"; $out .= " "; $out .= " {$updatesend}"; $out .= "
"; echo $out; //update license id if (isset($data['orderuid'])) { $this->options['license_id'] = $data['orderuid']; update_option('yofla_360_options', $this->options); } } elseif (gettype($data) == 'string') { echo '

' . $data . '

'; } else { echo '

License Key is invalid!

'; //remove void option $this->options['license_id'] = ''; update_option('yofla_360_options', $this->options); } } } $msg = '

Please enter your License Key or License ID to replace the free 360° player with a licensed version. License Key will be converted to License ID after submitting.'; $msg .= ' If you are already using a licensed player, entering the License Key here will make '; $msg .= ' all 360° product rotations use the latest 360° player from the cloud.

'; echo $msg; } /** * Print the Section text for shortcode options */ public function print_section_info_woocommerce() { //$msg = '

.'; //$msg .= '

'; $msg = 'WooCommerce Settings'; echo $msg; } /** * Print the Section text for shortcode options */ public function print_section_info_advanced() { //$msg = '

.'; //$msg .= '

'; $msg = ''; echo $msg; } /** * Print the Section text for shortcode options */ public function print_section_cache() { $msg = '

Cache Management'; $msg .= '

'; $msg = ''; echo $msg; } /** * Print the Section text for shortcode options */ public function print_section_info_shortcode() { $msg = '

Set default site-wide default shortcode values for embedding the 360° product rotation.'; $msg .= '

'; echo $msg; } public function print_section_info_legacy() { $msg = '

Settings for the 360° views created by the desktop application "3DRT Setup Utility" '; $msg .= 'The application is being gradually replaced by the web-based version'; $msg .= '

'; echo $msg; } /** * Get the settings option array and print one of its values */ public function licenseid_callback() { printf( '', isset($this->options['license_id']) ? esc_attr($this->options['license_id']) : '' ); } public function local_engine_callback() { $desc = '
If checked, the local rotatetool.js uploaded with the 360 view will be used, instead of the global one.'; printf( '%s', isset($this->options['local_engine']) ? 'checked' : '', $desc ); } public function woocommerce_alternate_embedding_callback() { $desc = '
If checked, the 360 view player is inserted into the product gallery using JavaScript. This might help with multiple product galleries in one page issues.'; printf( '%s', isset($this->options['woocommerce_alternate_embedding']) ? 'checked' : '', $desc ); } /** * Get the settings option array and print one of its values */ public function rotatetooljs_url_callback() { printf( '', isset($this->options['rotatetooljs_url']) ? esc_attr($this->options['rotatetooljs_url']) : '' ); } /** * Get the settings option array and print one of its values */ public function theme_url_callback() { $desc = '
If provided, all 360 views will use this theme. Example: http://www.example.com/360/themes/pure-white/'; printf( ' %s', isset($this->options['theme_url']) ? esc_attr($this->options['theme_url']) : '', $desc ); } /** * Get the settings option array and print one of its values */ public function iframe_styles_callback() { $desc = '
When not set, this default is used: "max-width: 100%; border: 1px solid silver;"'; $desc .= '
You can disable the 360° view border by entering: "max-width: 100%; border: 0px;"'; printf( '%s', isset($this->options['iframe_styles']) ? esc_attr($this->options['iframe_styles']) : '', $desc ); } /** * Get the settings option array and print one of its values */ public function ga_enabled_callback() { $desc = '
Turns on Google Analytics Events Tracking. More Info.'; printf( '%s', isset($this->options['ga_enabled']) ? 'checked' : '', $desc ); } /** * Get the settings option array and print one of its values */ public function ga_tracking_id_callback() { $desc = '
Your Google Analytics profile tracking ID, e.g. UA-123456-7'; printf( '%s', isset($this->options['ga_tracking_id']) ? esc_attr($this->options['ga_tracking_id']) : '', $desc ); } /** * Get the settings html form code */ public function woocommerce_360thumb_url_callback() { printf( '', isset($this->options['woocommerce_360thumb_url']) ? esc_attr($this->options['woocommerce_360thumb_url']) : '' ); } /** * Checks if order data is valid * * @param $license_id * @return array|null */ private function _get_order_data($license_id) { $url = YOFLA_LICENSE_ID_CHECK_URL . $license_id; add_filter('https_local_ssl_verify', '__return_false'); $response = wp_remote_get($url); if (is_wp_error($response)) { $error = $response->get_error_message(); $msg = '

' . 'Error communicating with server! ' . $error . '

'; return $msg; } if ($response && isset($response['body'])) { $body = $response['body']; $data = explode('|', $body); //sucess if ($data[0] == 'ok') { $order_data = array(); $order_data['license_holder'] = $data[1]; $order_data['updatesend'] = $data[2]; $order_data['productid'] = $data[3]; $order_data['orderuid'] = $data[4]; return $order_data; } //error else { return $body; } } return null; } }