public function init()
 {
     if (!class_exists('Radykal_Settings')) {
         require_once FPD_PLUGIN_DIR . '/framework/class-admin-settings.php';
     }
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-general-settings.php';
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-default-element-options-settings.php';
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-labels-settings.php';
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-fonts-settings.php';
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-advanced-color-settings.php';
     require_once FPD_PLUGIN_DIR . '/inc/settings/class-wc-settings.php';
     //create new settings instance
     $tabs = array('general' => __('General', 'radykal'), 'default_element_options' => __('Default Element Options', 'radykal'), 'labels' => __('Labels', 'radykal'), 'fonts' => __('Fonts', 'radykal'), 'advanced_colors' => __('Advanced Color Config.', 'radykal'));
     if (function_exists('get_woocommerce_currency')) {
         $tabs['woocommerce'] = __('WooCommerce', 'radykal');
     }
     self::$radykal_settings = new Radykal_Settings(array('page_id' => 'fpd_settings', 'tabs' => $tabs));
     //first add blocks
     self::$radykal_settings->add_blocks(array('general' => array('layout-skin' => __('Layout & Skin', 'radykal'), 'colors' => __('Colors', 'radykal'), 'user-interface' => __('User Interface', 'radykal'), 'misc' => __('Miscellaneous', 'radykal'), 'troubleshooting' => __('Troubleshooting', 'radykal')), 'default_element_options' => array('default-image-options' => __('Image Options', 'radykal'), 'default-custom-image-options' => __('Custom Image Options', 'radykal'), 'default-custom-text-options' => __('Custom Text Options', 'radykal'), 'default-common-options' => __('Common Options', 'radykal')), 'labels' => array('product-designer' => __('Product Designer', 'radykal'), 'misc-labels' => __('Miscellaneous', 'radykal')), 'fonts' => array('fonts' => __('Fonts for the typeface dropdown', 'radykal')), 'advanced_colors' => array('hex-names' => __('Define names for your hexadecimal colors.', 'radykal'), 'color-prices' => __('Set own prices for your hexadecimal colors.', 'radykal')), 'woocommerce' => array('wc-product-page' => __('Product Page', 'radykal'), 'wc-sharing' => __('Design Sharing', 'radykal'), 'wc-catalog-listing' => __('Catalog Listing', 'radykal'))));
     self::$radykal_settings->add_blocks_description(array('default-image-options' => __('The default options for custom uploaded images, facebook/instagram photos and Fancy Designs.', 'radykal'), 'default-custom-image-options' => __('The default options for uploaded images by the customer.', 'radykal'), 'default-custom-text-options' => __('The default options for added texts by the customer.', 'radykal')));
     //add general settings
     $general_options = FPD_Settings_General::get_options();
     self::$radykal_settings->add_block_options('layout-skin', $general_options['layout-skin']);
     self::$radykal_settings->add_block_options('colors', $general_options['colors']);
     self::$radykal_settings->add_block_options('user-interface', $general_options['user-interface']);
     self::$radykal_settings->add_block_options('misc', $general_options['misc']);
     self::$radykal_settings->add_block_options('troubleshooting', $general_options['troubleshooting']);
     //add default element options settings
     $default_element_options = FPD_Settings_Default_Element_Options::get_options();
     self::$radykal_settings->add_block_options('default-image-options', $default_element_options['default-image-options']);
     self::$radykal_settings->add_block_options('default-custom-image-options', $default_element_options['default-custom-image-options']);
     self::$radykal_settings->add_block_options('default-custom-text-options', $default_element_options['default-custom-text-options']);
     self::$radykal_settings->add_block_options('default-common-options', $default_element_options['default-common-options']);
     //add labels settings
     $labels_options = FPD_Settings_Labels::get_options();
     self::$radykal_settings->add_block_options('product-designer', $labels_options['product-designer']);
     self::$radykal_settings->add_block_options('misc-labels', $labels_options['misc-labels']);
     //add fonts settings
     $fonts_options = FPD_Settings_Fonts::get_options();
     self::$radykal_settings->add_block_options('fonts', $fonts_options['fonts']);
     //add advanced color settings
     $advanced_color_options = FPD_Settings_Advanced_Colors::get_options();
     self::$radykal_settings->add_block_options('hex-names', $advanced_color_options['hex-names']);
     self::$radykal_settings->add_block_options('color-prices', $advanced_color_options['color-prices']);
     //add wc settings
     $wc_options = FPD_Settings_WooCommerce::get_options();
     self::$radykal_settings->add_block_options('wc-product-page', $wc_options['wc-product-page']);
     self::$radykal_settings->add_block_options('wc-sharing', $wc_options['wc-sharing']);
     self::$radykal_settings->add_block_options('wc-catalog-listing', $wc_options['wc-catalog-listing']);
 }
        public function add_product_designer()
        {
            global $post;
            $product_settings = new FPD_Product_Settings($post->ID);
            $open_in_lightbox = $product_settings->get_option('open_in_lightbox') && trim($product_settings->get_option('start_customizing_button')) != '';
            if (is_fancy_product($product_settings->master_id) && (!$product_settings->customize_button_enabled || $open_in_lightbox)) {
                FPD_Scripts_Styles::$add_script = true;
                $selector = 'fancy-product-designer-' . $product_settings->master_id . '';
                //get availabe fonts
                $available_fonts = $product_settings->get_option('font_families[]') === false ? FPD_Fonts::get_enabled_fonts() : $product_settings->get_option('font_families[]');
                if (!is_array($available_fonts)) {
                    $available_fonts = str_split($available_fonts, strlen($available_fonts));
                }
                //woocommerce
                if (get_post_type($post) === 'product') {
                    $this->output_wc_start();
                }
                //get assigned categories
                $fancy_content_ids = fpd_has_content($product_settings->master_id);
                if (!is_array($fancy_content_ids) || sizeof($fancy_content_ids) === 0) {
                    return;
                }
                //define the designer margins
                $designer_margins = $product_settings->get_option('designer_margin');
                $margin_styles = '';
                if (!empty($designer_margins)) {
                    @parse_str($designer_margins, $designer_margins);
                    foreach ($designer_margins as $margin_key => $margin_val) {
                        $margin_styles .= 'margin-' . $margin_key . ':' . $margin_val . 'px;';
                    }
                }
                //add class if lightbox is enabled
                $modal_box_css = $open_in_lightbox ? ' fpd-lightbox-enabled' : '';
                $source_type = get_post_meta($product_settings->master_id, 'fpd_source_type', true);
                ?>
				<div id="<?php 
                echo $selector;
                ?>
" class="fpd-container <?php 
                echo $product_settings->get_option('frame_shadow');
                echo $modal_box_css;
                ?>
" style="float: <?php 
                echo $product_settings->get_option('designer_floating');
                ?>
; <?php 
                echo $margin_styles;
                ?>
">
					<?php 
                foreach ($fancy_content_ids as $fancy_content_id) {
                    if (empty($source_type) || $source_type == 'category') {
                        $fancy_category = new Fancy_Category($fancy_content_id);
                        echo '<div class="fpd-category" title="' . esc_attr($fancy_category->get_data()->title) . '">';
                        $fancy_products_data = $fancy_category->get_products();
                        foreach ($fancy_products_data as $fancy_product_data) {
                            echo $this->get_product_html($fancy_product_data->ID);
                        }
                        echo '</div>';
                        //category
                    } else {
                        echo $this->get_product_html($fancy_content_id);
                    }
                }
                //output designs
                if (!intval($product_settings->get_option('hide_designs_tab'))) {
                    require_once FPD_PLUGIN_DIR . '/inc/class-designs.php';
                    $fpd_designs = new FPD_Designs($product_settings->get_option('design_categories[]') ? $product_settings->get_option('design_categories[]') : array(), $product_settings->get_image_parameters());
                    $fpd_designs->output();
                }
                ?>

				</div>
				<p class="fpd-not-supported-device-info">
					<strong><?php 
                echo fpd_get_option('fpd_label_not_supported_device_info');
                ?>
</strong>
				</p>

				<script type="text/javascript">

					var fancyProductDesigner,
						$selector,
						$productWrapper,
						$cartForm,
						productCreated = false,
						fpdPrice = 0,
						isReady = false,
						$modalWrapper = null;

					<?php 
                echo fpd_get_option('fpd_jquery_no_conflict') === 'on' ? 'jQuery.noConflict();' : '';
                ?>
					jQuery(document).ready(function() {

						//return;

						$selector = jQuery('#<?php 
                echo $selector;
                ?>
');
						$productWrapper = jQuery('.post-<?php 
                echo $post->ID;
                ?>
');
						$cartForm = jQuery('[name="fpd_product"]:first').parents('form:first');

						var buttonClass = "<?php 
                echo esc_attr(fpd_get_option('fpd_start_customizing_css_class')) == '' ? 'fpd-modal-button' : trim(fpd_get_option('fpd_start_customizing_css_class'));
                ?>
",
							productDesignerWidth = <?php 
                echo $product_settings->get_option('stage_width');
                ?>
,
							customizeBtn = jQuery('#fpd-start-customizing-button');

						if(jQuery('.fpd-lightbox-enabled').size() > 0) {

							$modalWrapper = jQuery('body').append('<div class="fpd-product-lightbox fpd-modal-overlay"><div class="fpd-modal-wrapper"><div class="fpd-modal-buttons"><a href="#" id="fpd-modal-done" class="'+buttonClass+'"><?php 
                echo fpd_get_option('fpd_label_lightbox_submit_button');
                ?>
</a><a href="#" id="fpd-modal-cancel" class="'+buttonClass+'"><?php 
                echo fpd_get_option('fpd_label_lightbox_cancel_button');
                ?>
</a></div></div></div>').find('.fpd-modal-wrapper');

							$selector.clone().prependTo($modalWrapper);
							$selector.remove();
							$selector = jQuery('#<?php 
                echo $selector;
                ?>
');

							jQuery(window).resize(function() {
								$modalWrapper.css('margin-left', -($modalWrapper.outerWidth() / 2)+'px');
							});

							customizeBtn.click(function(evt) {

								if(!isReady) { return false; }

								jQuery('html,body').addClass('fpd-modal-open');
								$modalWrapper.parent('.fpd-modal-overlay').fadeIn(300, function() {
									jQuery('.fpd-context-dialog').removeClass('fpd-modal-hidden');
								});
								jQuery(window).resize();

								evt.preventDefault();

							});

							$modalWrapper.on('click', '#fpd-modal-done', function(evt) {

								jQuery('#fpd-modal-cancel').click();

								if(<?php 
                echo intval(fpd_get_option('fpd_lightbox_add_to_cart'));
                ?>
) {
									$cartForm.find(':submit').click();
								}

								evt.preventDefault();

							})
							.on('click', '#fpd-modal-cancel', function(evt) {

								fancyProductDesigner.closeDialog();
								jQuery('html,body').removeClass('fpd-modal-open');
								$modalWrapper.parent('.fpd-modal-overlay').fadeOut(200);
								evt.preventDefault();

							});

						}

						if(jQuery('.fpd-share-design').size() > 0) {

							jQuery('#fpd-share-button').click(function(evt) {

								evt.preventDefault();

								var scale = $selector.width() > 800 ? Number(800 / $selector.width()).toFixed(2) : 1;
								var data = {
									action: 'fpd_createshareurl',
									image: fancyProductDesigner.getProductDataURL('png', 'transparent', scale),
									product: JSON.stringify(fancyProductDesigner.getProduct()),
								};

								jQuery(".fpd-share-widget, .fpd-share-url").addClass('fpd-hidden');
								jQuery('.fpd-share-process').removeClass('fpd-hidden');

								jQuery.post("<?php 
                echo admin_url('admin-ajax.php');
                ?>
", data, function(response) {

									if(response.share_id !== undefined) {

										var pattern = new RegExp('(share_id=).*?(&|$)'),
											shareUrl = window.location.href;

										if(shareUrl.search(pattern) >= 0){
											shareUrl = shareUrl.replace(pattern,'$1' + response.share_id + '$2');
										}
										else{
											shareUrl = shareUrl + (shareUrl.indexOf('?')>0 ? '&' : '?') + 'share_id=' + response.share_id;
										}
										<?php 
                $shares = fpd_get_option('fpd_sharing_social_networks');
                ?>
										jQuery(".fpd-share-widget").empty().jsSocials({
											url: shareUrl,
											shares: <?php 
                echo is_array($shares) ? json_encode($shares) : '[' . $shares . ']';
                ?>
,
										    showLabel: false,
										    text: "<?php 
                echo fpd_get_option('fpd_label_sharing_default_text');
                ?>
"
										}).removeClass('fpd-hidden');
									}

									jQuery('.fpd-share-process').addClass('fpd-hidden');
									jQuery('.fpd-share-url').attr('href', shareUrl).text(shareUrl).removeClass('fpd-hidden');

								}, 'json');



							});

						}

						var customImagesParams = jQuery.extend(<?php 
                echo $product_settings->get_image_parameters_string();
                ?>
, <?php 
                echo $product_settings->get_custom_image_parameters_string();
                ?>
 );

						var socialPhotoAjaxSettingsOpt = {
							url: "<?php 
                echo plugins_url('/inc/get_image_data_url.php', FPD_PLUGIN_ROOT_PHP);
                ?>
"
						};
						if("<?php 
                echo fpd_get_option('fpd_type_of_uploader');
                ?>
" == 'php') {
							socialPhotoAjaxSettingsOpt = {
								url: "<?php 
                echo admin_url('admin-ajax.php');
                ?>
",
								data: {
									action: 'fpd_uploadsocialphoto'
								}
							};
						}


						//call fancy product designer plugin
						fancyProductDesigner = $selector.fancyProductDesigner({
							width: productDesignerWidth,
							stageHeight: <?php 
                echo $product_settings->get_option('stage_height');
                ?>
,
							imageDownloadable: <?php 
                echo $this->disable_export_btns ? 0 : fpd_get_option('fpd_download_product_image');
                ?>
,
							saveAsPdf: <?php 
                echo $this->disable_export_btns ? 0 : fpd_get_option('fpd_pdf_button');
                ?>
,
							printable: <?php 
                echo $this->disable_export_btns ? 0 : fpd_get_option('fpd_print');
                ?>
,
							allowProductSaving: <?php 
                echo fpd_get_option('fpd_allow_product_saving');
                ?>
,
							fonts: [<?php 
                echo '"' . implode('", "', $available_fonts) . '"';
                ?>
],
							templatesDirectory: "<?php 
                echo plugins_url('/templates/', FPD_PLUGIN_ROOT_PHP);
                ?>
",
							phpDirectory: "<?php 
                echo plugins_url('/inc/', FPD_PLUGIN_ROOT_PHP);
                ?>
",
							facebookAppId: "<?php 
                echo fpd_get_option('fpd_facebook_app_id');
                ?>
",
							instagramClientId: "<?php 
                echo fpd_get_option('fpd_instagram_client_id');
                ?>
",
							instagramRedirectUri: "<?php 
                echo fpd_get_option('fpd_instagram_redirect_uri');
                ?>
",
							patterns: [<?php 
                echo implode(',', $this->get_pattern_urls());
                ?>
],
							viewSelectionPosition: "<?php 
                echo $product_settings->get_option('view_selection_position');
                ?>
",
							viewSelectionFloated: <?php 
                echo $product_settings->get_option('view_selection_floated');
                ?>
,
							zoomStep: <?php 
                echo fpd_get_option('fpd_zoom_step');
                ?>
,
							maxZoom: <?php 
                echo fpd_get_option('fpd_max_zoom');
                ?>
,
							tooltips: <?php 
                echo intval(fpd_get_option('fpd_tooltips'));
                ?>
,
							hexNames: <?php 
                echo FPD_Settings_Advanced_Colors::get_hex_names_object_string();
                ?>
,
							selectedColor:  "<?php 
                echo fpd_get_option('fpd_selected_color');
                ?>
",
							boundingBoxColor:  "<?php 
                echo fpd_get_option('fpd_bounding_box_color');
                ?>
",
							outOfBoundaryColor:  "<?php 
                echo fpd_get_option('fpd_out_of_boundary_color');
                ?>
",
							paddingControl:  <?php 
                echo fpd_get_option('fpd_padding_controls');
                ?>
,
							replaceInitialElements: <?php 
                echo $product_settings->get_option('replace_initial_elements');
                ?>
,
							lazyLoad: <?php 
                echo fpd_get_option('fpd_lazy_load');
                ?>
,
							dialogBoxPositioning: "<?php 
                echo $product_settings->get_option('dialog_box_positioning');
                ?>
",
							socialPhotoAjaxSettings: socialPhotoAjaxSettingsOpt,
							elementParameters: {
								originX: "<?php 
                echo fpd_get_option('fpd_common_parameter_originX');
                ?>
",
								originY: "<?php 
                echo fpd_get_option('fpd_common_parameter_originY');
                ?>
"
							},
							imageParameters: {
								colorPrices: <?php 
                echo $product_settings->get_option('enable_image_color_prices') ? FPD_Settings_Advanced_Colors::get_color_prices() : '{}';
                ?>
							},
							textParameters: {
								font: "<?php 
                echo fpd_get_option('fpd_font');
                ?>
",
								colorPrices: <?php 
                echo $product_settings->get_option('enable_text_color_prices') ? FPD_Settings_Advanced_Colors::get_color_prices() : '{}';
                ?>
							},
							customImageParameters: customImagesParams,
							customTextParameters: <?php 
                echo $product_settings->get_custom_text_parameters_string();
                ?>
,
							labels: <?php 
                echo FPD_Settings_Labels::get_labels_object_string(array('fpd_label_uploadedDesignSizeAlert' => array('minW' => $product_settings->get_option('uploaded_designs_parameter_minW'), 'minH' => $product_settings->get_option('uploaded_designs_parameter_minH'), 'maxW' => $product_settings->get_option('uploaded_designs_parameter_maxW'), 'maxH' => $product_settings->get_option('uploaded_designs_parameter_maxH'))));
                ?>
,
							customAdds: {
								uploads: <?php 
                echo $product_settings->get_option('hide_custom_image_upload') ? 0 : intval(fpd_get_option('fpd_upload_designs'));
                ?>
,
								texts: <?php 
                echo $product_settings->get_option('hide_custom_text') ? 0 : intval(fpd_get_option('fpd_custom_texts'));
                ?>
,
								facebook: <?php 
                echo $product_settings->get_option('hide_facebook_tab') ? 0 : 1;
                ?>
,
								instagram: <?php 
                echo $product_settings->get_option('hide_instagram_tab') ? 0 : 1;
                ?>
							}
						}).data('fancy-product-designer');

						//when load from cart or order, use loadProduct
						$selector.on('ready', function() {

							if(jQuery('.fpd-lightbox-enabled').size() > 0) {
								jQuery('.fpd-context-dialog').addClass('fpd-modal-hidden');
							}

							if(<?php 
                echo $this->form_views === null ? 0 : 1;
                ?>
) {
								var views = <?php 
                echo $this->form_views === null ? 0 : $this->form_views;
                ?>
;
								fancyProductDesigner.loadProduct(views);
							}

							//replace filereader uploader with php uploader
							if("<?php 
                echo fpd_get_option('fpd_type_of_uploader');
                ?>
" == 'php') {

								var $imageInput = jQuery('body').find('.fpd-input-image');

								jQuery('body').find('.fpd-upload-form').off('change').change(function() {

									<?php 
                $login_required = fpd_get_option('fpd_upload_designs_php_logged_in') !== 0 && !is_user_logged_in() ? 1 : 0;
                ?>

									if ( <?php 
                echo $login_required;
                ?>
 ) {
										fancyProductDesigner.showModal("<?php 
                _e('You need to be logged in to upload images!', 'radykal');
                ?>
");
										$imageInput.val('');
										return;
									}

									jQuery('body').find('.fpd-upload-form').ajaxSubmit({
										url: "<?php 
                echo admin_url('admin-ajax.php');
                ?>
",
										dataType: 'json',
										data: {
											action: 'fpduploadimage',
											product_id: <?php 
                echo $post->ID;
                ?>
										},
										type: 'post',
										beforeSubmit: function(arr, $form, options) {

											$phpUploaderInfo.addClass('fpd-show-up')
											.children('p:first').text('<?php 
                _e('Uploading', 'radykal');
                ?>
'+': '+arr[0].value.name);
											$progressBar.children('.fpd-progress-bar-move').css('width', 0);

										},
										success: function(responseText, statusText) {

											if(responseText.code == 200) {
												//successfully uploaded
												fancyProductDesigner.addCustomImage(responseText.url, responseText.filename);
											}
											else {
												//failed
												fancyProductDesigner.showModal(responseText.message);
											}

											$imageInput.val('');
											$phpUploaderInfo.removeClass('fpd-show-up');

										},
										error: function() {

											$imageInput.val('');
											$phpUploaderInfo.removeClass('fpd-show-up');
											fancyProductDesigner.showModal("<?php 
                _e('Server error: Image could not be uploaded, please try again!', 'radykal');
                ?>
");

										},
										uploadProgress: function(evt, pos, total, percentComplete) {
											$progressBar.children('.fpd-progress-bar-move').css('width', percentComplete+'%');
										}
									});

								})

								jQuery('body').append('<div class="fpd-php-uploader-info fpd-snackbar fpd-shadow-1"><p></p><div class="fpd-upload-progess-bar"><div class="fpd-progress-bar-bg"></div><div class="fpd-progress-bar-move"></div></div></div>');

								$phpUploaderInfo = jQuery('body').children('.fpd-php-uploader-info');
								$progressBar = $phpUploaderInfo.children('.fpd-upload-progess-bar');

							}

							//hide loading icon in customize btn
							customizeBtn.removeClass('fpd-disabled')
							.text(customizeBtn.attr('title')).removeAttr('title');

							isReady = true;

						});

					});

				</script>

				<?php 
                //woocommerce
                if (get_post_type($post) === 'product') {
                    $this->output_wc_js();
                } else {
                    $this->output_shortcode_js();
                }
            }
        }