WC_Compare_Admin_Interface

The WooCommerce Compare Products LITE WC Compare Admin Interface class.

Defined (1)

The class is defined in the following location(s).

/admin/admin-interface.php  
  1. class WC_Compare_Admin_Interface extends WC_Compare_Admin_UI 
  2.  
  3. /**-----------------------------------------------------------------------------------*/ 
  4. /** Admin Interface Constructor */ 
  5. /**-----------------------------------------------------------------------------------*/ 
  6. public function __construct() { 
  7.  
  8. $this->admin_includes(); 
  9.  
  10. add_action( 'init', array( $this, 'init_scripts' ) ); 
  11. add_action( 'init', array( $this, 'init_styles' ) ); 
  12.  
  13. // AJAX hide yellow message dontshow 
  14. add_action( 'wp_ajax_'.$this->plugin_name.'_a3_admin_ui_event', array( $this, 'a3_admin_ui_event' ) ); 
  15. add_action( 'wp_ajax_nopriv_'.$this->plugin_name.'_a3_admin_ui_event', array( $this, 'a3_admin_ui_event' ) ); 
  16.  
  17.  
  18. /**-----------------------------------------------------------------------------------*/ 
  19. /** Init scripts */ 
  20. /**-----------------------------------------------------------------------------------*/ 
  21. public function init_scripts() { 
  22. $admin_pages = $this->admin_pages(); 
  23.  
  24. if ( is_admin() && isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $admin_pages ) ) { 
  25. add_action( 'admin_enqueue_scripts', array( $this, 'admin_script_load' ) ); 
  26. do_action( $this->plugin_name . '_init_scripts' ); 
  27.  
  28. add_action( 'admin_print_scripts', array( $this, 'admin_localize_printed_scripts' ), 5 ); 
  29. add_action( 'admin_print_footer_scripts', array( $this, 'admin_localize_printed_scripts' ), 5 ); 
  30.  
  31. /**-----------------------------------------------------------------------------------*/ 
  32. /** Init styles */ 
  33. /**-----------------------------------------------------------------------------------*/ 
  34. public function init_styles() { 
  35. $admin_pages = $this->admin_pages(); 
  36.  
  37. if ( is_admin() && isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $admin_pages ) ) { 
  38. add_action( 'admin_enqueue_scripts', array( $this, 'register_fontawesome_style' ), 0 ); 
  39. add_action( 'admin_enqueue_scripts', array( $this, 'admin_css_load' ) ); 
  40. do_action( $this->plugin_name . '_init_styles' ); 
  41.  
  42. public function register_fontawesome_style() { 
  43. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; 
  44. wp_register_style( 'font-awesome-styles', $this->admin_plugin_url() . '/assets/css/font-awesome' . $suffix . '.css', array(), '4.5.0', 'all' ); 
  45.  
  46. /**-----------------------------------------------------------------------------------*/ 
  47. /** admin_script_load */ 
  48. /**-----------------------------------------------------------------------------------*/ 
  49.  
  50. public function admin_script_load() { 
  51.  
  52. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; 
  53. $rtl = is_rtl() ? '.rtl' : ''; 
  54.  
  55. wp_register_script( 'chosen', $this->admin_plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), true, false ); 
  56. wp_register_script( 'a3rev-chosen-new', $this->admin_plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), true, false ); 
  57. wp_register_script( 'a3rev-style-checkboxes', $this->admin_plugin_url() . '/assets/js/iphone-style-checkboxes' . $rtl . '.js', array('jquery'), true, false ); 
  58. wp_register_script( 'jquery-ui-slider-rtl', $this->admin_plugin_url() . '/assets/js/ui-slider/jquery.ui.slider.rtl' . $suffix . '.js', array('jquery'), true, true ); 
  59.  
  60. wp_register_script( 'a3rev-admin-ui-script', $this->admin_plugin_url() . '/assets/js/admin-ui-script.js', array('jquery'), true, true ); 
  61. wp_register_script( 'a3rev-typography-preview', $this->admin_plugin_url() . '/assets/js/a3rev-typography-preview.js', array('jquery'), false, true ); 
  62. wp_register_script( 'a3rev-settings-preview', $this->admin_plugin_url() . '/assets/js/a3rev-settings-preview.js', array('jquery'), false, true ); 
  63. wp_register_script( 'jquery-tiptip', $this->admin_plugin_url() . '/assets/js/tipTip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), true, true ); 
  64. wp_register_script( 'a3rev-metabox-ui', $this->admin_plugin_url() . '/assets/js/data-meta-boxes.js', array( 'jquery' ), true, true ); 
  65. wp_register_script( 'jquery-rwd-image-maps', $this->admin_plugin_url() . '/assets/js/rwdImageMaps/jquery.rwdImageMaps.min.js', array( 'jquery' ), true, true ); 
  66.  
  67. wp_enqueue_script( 'jquery' ); 
  68. wp_enqueue_script( 'wp-color-picker' ); 
  69. if ( is_rtl() ) { 
  70. wp_enqueue_script( 'jquery-ui-slider-rtl' ); 
  71. } else { 
  72. wp_enqueue_script( 'jquery-ui-slider' ); 
  73. wp_enqueue_script( 'chosen' ); 
  74. wp_enqueue_script( 'a3rev-chosen-new' ); 
  75. wp_enqueue_script( 'a3rev-style-checkboxes' ); 
  76. wp_enqueue_script( 'a3rev-admin-ui-script' ); 
  77. wp_enqueue_script( 'a3rev-typography-preview' ); 
  78. wp_enqueue_script( 'a3rev-settings-preview' ); 
  79. wp_enqueue_script( 'jquery-tiptip' ); 
  80. wp_enqueue_script( 'a3rev-metabox-ui' ); 
  81.  
  82. } // End admin_script_load() 
  83.  
  84. /**-----------------------------------------------------------------------------------*/ 
  85. /** admin_localize_printed_scripts: Localize scripts only when enqueued */ 
  86. /**-----------------------------------------------------------------------------------*/ 
  87.  
  88. public function admin_localize_printed_scripts() { 
  89. $rtl = is_rtl() ? 1 : 0; 
  90.  
  91. if ( wp_script_is( 'a3rev-admin-ui-script' ) ) { 
  92. wp_localize_script( 'a3rev-admin-ui-script', 'a3_admin_ui_script_params', apply_filters( 'a3_admin_ui_script_params', array( 
  93. 'ajax_url' => admin_url( 'admin-ajax.php' ),  
  94. 'plugin' => $this->plugin_name,  
  95. 'security' => wp_create_nonce( $this->plugin_name . '_a3_admin_ui_event' ),  
  96. 'rtl' => $rtl,  
  97. ) ) ); 
  98.  
  99. } // End admin_localize_printed_scripts() 
  100.  
  101. public function a3_admin_ui_event() { 
  102. check_ajax_referer( $this->plugin_name. '_a3_admin_ui_event', 'security' ); 
  103. if ( isset( $_REQUEST['type'] ) ) { 
  104. switch ( trim( $_REQUEST['type'] ) ) { 
  105. case 'open_close_panel_box': 
  106. $form_key = $_REQUEST['form_key']; 
  107. $box_id = $_REQUEST['box_id']; 
  108. $is_open = $_REQUEST['is_open']; 
  109.  
  110. $user_id = get_current_user_id(); 
  111. $opened_box = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ), true ); 
  112. if ( empty( $opened_box ) || ! is_array( $opened_box ) ) { 
  113. $opened_box = array(); 
  114. if ( 1 == $is_open && ! in_array( $box_id, $opened_box ) ) { 
  115. $opened_box[] = $box_id; 
  116. } elseif ( 0 == $is_open && in_array( $box_id, $opened_box ) ) { 
  117. $opened_box = array_diff( $opened_box, array( $box_id ) ); 
  118. update_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ), $opened_box ); 
  119. break; 
  120.  
  121. case 'check_new_version': 
  122. $transient_name = $_REQUEST['transient_name']; 
  123. delete_transient( $transient_name ); 
  124.  
  125. $new_version = ''; 
  126. if ( class_exists( 'WC_Compare_Upgrade' ) ) { 
  127. $new_version = WC_Compare_Upgrade::get_version_info(); 
  128.  
  129. $version_message = $this->get_version_message(); 
  130. $has_new_version = 1; 
  131. if ( '' == trim( $version_message ) ) { 
  132. $version_message = __( 'Great! You have the latest version installed.', 'woocommerce-compare-products' ); 
  133. $has_new_version = 0; 
  134. } else { 
  135. delete_option('woo_compare_product_lite_clean_on_deletion'); 
  136. if ( is_array( $new_version ) && 'valid' == $new_version['is_valid_key'] ) { 
  137. $current_update_plugins = get_site_transient( 'update_plugins' ); 
  138. if ( isset( $current_update_plugins->response ) ) { 
  139. $plugin_name = WOOCP_NAME; 
  140. if ( empty( $current_update_plugins->response[$plugin_name] ) ) { 
  141. $current_update_plugins->response[$plugin_name] = new stdClass(); 
  142. $current_update_plugins->response[$plugin_name]->url = "http://www.a3rev.com"; 
  143. $current_update_plugins->response[$plugin_name]->slug = get_option( $this->plugin_option_key ); 
  144. $current_update_plugins->response[$plugin_name]->package = $new_version["url"]; 
  145. $current_update_plugins->response[$plugin_name]->new_version = $new_version['version']; 
  146. $current_update_plugins->response[$plugin_name]->upgrade_notice = $new_version['upgrade_notice']; 
  147. $current_update_plugins->response[$plugin_name]->id = "0"; 
  148. set_site_transient( 'update_plugins', $current_update_plugins ); 
  149.  
  150. $response_data = array( 
  151. 'has_new_version' => $has_new_version,  
  152. 'version_message' => $version_message,  
  153. ); 
  154. echo json_encode( $response_data ); 
  155. break; 
  156.  
  157. die(); 
  158.  
  159.  
  160. /**-----------------------------------------------------------------------------------*/ 
  161. /** admin_css_load */ 
  162. /**-----------------------------------------------------------------------------------*/ 
  163.  
  164. public function admin_css_load () { 
  165. global $wp_version; 
  166.  
  167. $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; 
  168.  
  169. wp_enqueue_style( 'a3rev-admin-ui-style', $this->admin_plugin_url() . '/assets/css/admin-ui-style' . $suffix . '.css' ); 
  170.  
  171. if ( version_compare( $wp_version, '3.8', '>=' ) ) { 
  172. wp_enqueue_style( 'a3rev-admin-flat-ui-style', $this->admin_plugin_url() . '/assets/css/admin-flat-ui-style' . $suffix . '.css' ); 
  173. wp_enqueue_style( 'wp-color-picker' ); 
  174. wp_enqueue_style( 'a3rev-chosen-new-style', $this->admin_plugin_url() . '/assets/js/chosen/chosen' . $suffix . '.css' ); 
  175. wp_enqueue_style( 'a3rev-tiptip-style', $this->admin_plugin_url() . '/assets/js/tipTip/tipTip.css' ); 
  176. wp_enqueue_style( 'a3rev-metabox-ui-style', $this->admin_plugin_url() . '/assets/css/a3_admin_metabox.css' ); 
  177.  
  178. if ( is_rtl() ) { 
  179. wp_enqueue_style( 'a3rev-admin-ui-style-rtl', $this->admin_plugin_url() . '/assets/css/admin-ui-style.rtl' . $suffix . '.css' ); 
  180. wp_enqueue_style( 'a3rev-metabox-ui-style-rtl', $this->admin_plugin_url() . '/assets/css/a3_admin_metabox.rtl' . $suffix . '.css' ); 
  181.  
  182. } // End admin_css_load() 
  183.  
  184. /**-----------------------------------------------------------------------------------*/ 
  185. /** get_success_message */ 
  186. /**-----------------------------------------------------------------------------------*/ 
  187. public function get_success_message( $message = '' ) { 
  188. if ( trim( $message ) == '' ) $message = __( 'Settings successfully saved.' , 'woocommerce-compare-products' );  
  189. return '<div class="updated" id=""><p>' . $message . '</p></div>'; 
  190.  
  191. /**-----------------------------------------------------------------------------------*/ 
  192. /** get_error_message */ 
  193. /**-----------------------------------------------------------------------------------*/ 
  194. public function get_error_message( $message = '' ) { 
  195. if ( trim( $message ) == '' ) $message = __( 'Error: Settings can not save.' , 'woocommerce-compare-products' );  
  196. return '<div class="error" id=""><p>' . $message . '</p></div>'; 
  197.  
  198. /**-----------------------------------------------------------------------------------*/ 
  199. /** get_reset_message */ 
  200. /**-----------------------------------------------------------------------------------*/ 
  201. public function get_reset_message( $message = '' ) { 
  202. if ( trim( $message ) == '' ) $message = __( 'Settings successfully reseted.' , 'woocommerce-compare-products' );  
  203. return '<div class="updated" id=""><p>' . $message . '</p></div>'; 
  204.  
  205. /**-----------------------------------------------------------------------------------*/ 
  206. /** admin_includes */ 
  207. /** Include required core files used in admin UI. 
  208. /**-----------------------------------------------------------------------------------*/ 
  209. public function admin_includes() { 
  210. // Includes Font Face Lib 
  211. include_once( 'includes/fonts_face.php' ); 
  212.  
  213. // Includes Uploader Lib 
  214. include_once( 'includes/uploader/class-uploader.php' ); 
  215.  
  216. /**-----------------------------------------------------------------------------------*/ 
  217. /** Get Font Weights */ 
  218. /**-----------------------------------------------------------------------------------*/ 
  219. public function get_font_weights() { 
  220. $font_weights = array ( 
  221. '300' => __( 'Thin', 'woocommerce-compare-products' ),  
  222. '300 italic' => __( 'Thin/Italic', 'woocommerce-compare-products' ),  
  223. 'normal' => __( 'Normal', 'woocommerce-compare-products' ),  
  224. 'italic' => __( 'Italic', 'woocommerce-compare-products' ),  
  225. 'bold' => __( 'Bold', 'woocommerce-compare-products' ),  
  226. 'bold italic' => __( 'Bold/Italic', 'woocommerce-compare-products' ),  
  227. ); 
  228. return apply_filters( $this->plugin_name . '_font_weights', $font_weights ); 
  229.  
  230. /**-----------------------------------------------------------------------------------*/ 
  231. /** Get Border Styles */ 
  232. /**-----------------------------------------------------------------------------------*/ 
  233. public function get_border_styles() { 
  234. $border_styles = array ( 
  235. 'solid' => __( 'Solid', 'woocommerce-compare-products' ),  
  236. 'double' => __( 'Double', 'woocommerce-compare-products' ),  
  237. 'dashed' => __( 'Dashed', 'woocommerce-compare-products' ),  
  238. 'dotted' => __( 'Dotted', 'woocommerce-compare-products' ),  
  239. 'groove' => __( 'Groove', 'woocommerce-compare-products' ),  
  240. 'ridge' => __( 'Ridge', 'woocommerce-compare-products' ),  
  241. 'inset' => __( 'Inset', 'woocommerce-compare-products' ),  
  242. 'outset' => __( 'Outset', 'woocommerce-compare-products' ),  
  243. ); 
  244. return apply_filters( $this->plugin_name . '_border_styles', $border_styles ); 
  245.  
  246. /**-----------------------------------------------------------------------------------*/ 
  247. /** Get Settings Default Function - get_settings_default */ 
  248. /** Just called for when option values is an array and it's in single option name for all settings 
  249. /**-----------------------------------------------------------------------------------*/ 
  250.  
  251. public function get_settings_default( $options, $option_name = '' ) { 
  252.  
  253. $default_settings = array(); 
  254.  
  255. if ( !is_array( $options ) || count( $options ) < 1 ) return $default_settings; 
  256.  
  257. foreach ( $options as $value ) { 
  258. if ( ! isset( $value['type'] ) ) continue; 
  259. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  260. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  261. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  262.  
  263. switch ( $value['type'] ) { 
  264.  
  265. // Array textfields 
  266. case 'array_textfields' : 
  267. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  268.  
  269. foreach ( $value['ids'] as $text_field ) { 
  270. if ( ! isset( $text_field['id'] ) || trim( $text_field['id'] ) == '' ) continue; 
  271. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  272.  
  273. // Do not include when it's separate option 
  274. if ( isset( $text_field['separate_option'] ) && $text_field['separate_option'] != false ) continue; 
  275.  
  276. // Remove [, ] characters from id argument 
  277. if ( strstr( $text_field['id'], '[' ) ) { 
  278. parse_str( esc_attr( $text_field['id'] ), $option_array ); 
  279.  
  280. // Option name is first key 
  281. $option_keys = array_keys( $option_array ); 
  282. $first_key = current( $option_keys ); 
  283.  
  284. $id_attribute = $first_key; 
  285. } else { 
  286. $id_attribute = esc_attr( $text_field['id'] ); 
  287.  
  288. $default_settings[$id_attribute] = $text_field['default']; 
  289.  
  290. break; 
  291.  
  292. default : 
  293. // Do not include when it's separate option 
  294. if ( isset( $value['separate_option'] ) && $value['separate_option'] != false ) continue; 
  295.  
  296. // Remove [, ] characters from id argument 
  297. if ( strstr( $value['id'], '[' ) ) { 
  298. parse_str( esc_attr( $value['id'] ), $option_array ); 
  299.  
  300. // Option name is first key 
  301. $option_keys = array_keys( $option_array ); 
  302. $first_key = current( $option_keys ); 
  303.  
  304. $id_attribute = $first_key; 
  305. } else { 
  306. $id_attribute = esc_attr( $value['id'] ); 
  307.  
  308. // Backward compatibility to old settings don't have line_height option for typography 
  309. if ( 'typography' == $value['type'] && ! isset( $value['default']['line_height'] ) ) { 
  310. $value['default']['line_height'] = '1.4em'; 
  311.  
  312. $default_settings[$id_attribute] = $value['default']; 
  313.  
  314. break; 
  315.  
  316. if ( trim( $option_name ) != '' ) $default_settings = apply_filters( $this->plugin_name . '_' . $option_name . '_default_settings' , $default_settings ); 
  317. if ( ! is_array( $default_settings ) ) $default_settings = array(); 
  318.  
  319. return $default_settings; 
  320.  
  321.  
  322. /**-----------------------------------------------------------------------------------*/ 
  323. /** Get Settings Function - get_settings */ 
  324. /**-----------------------------------------------------------------------------------*/ 
  325.  
  326. public function get_settings( $options, $option_name = '' ) { 
  327.  
  328. if ( !is_array( $options ) || count( $options ) < 1 ) return; 
  329.  
  330. $new_settings = array(); $new_single_setting = ''; // :) 
  331.  
  332. // Get settings for option values is an array and it's in single option name for all settings 
  333. if ( trim( $option_name ) != '' ) { 
  334. global ${$option_name}; 
  335.  
  336. $default_settings = $this->get_settings_default( $options, $option_name ); 
  337.  
  338. $current_settings = get_option( $option_name ); 
  339. if ( ! is_array( $current_settings ) ) $current_settings = array(); 
  340. $current_settings = array_merge( $default_settings, $current_settings ); 
  341.  
  342. $current_settings = array_map( array( $this, 'admin_stripslashes' ), $current_settings ); 
  343. $current_settings = apply_filters( $this->plugin_name . '_' . $option_name . '_get_settings' , $current_settings ); 
  344.  
  345. $$option_name = $current_settings; 
  346.  
  347.  
  348. // Get settings for option value is stored as a record or it's spearate option 
  349. foreach ( $options as $value ) { 
  350. if ( ! isset( $value['type'] ) ) continue; 
  351. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  352. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  353. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  354.  
  355. // For way it has an option name 
  356. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  357.  
  358. // Remove [, ] characters from id argument 
  359. if ( strstr( $value['id'], '[' ) ) { 
  360. parse_str( esc_attr( $value['id'] ), $option_array ); 
  361.  
  362. // Option name is first key 
  363. $option_keys = array_keys( $option_array ); 
  364. $first_key = current( $option_keys ); 
  365.  
  366. $id_attribute = $first_key; 
  367. } else { 
  368. $id_attribute = esc_attr( $value['id'] ); 
  369.  
  370. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  371. global ${$id_attribute}; 
  372.  
  373. $current_setting = get_option( $id_attribute, $value['default'] ); 
  374.  
  375. switch ( $value['type'] ) { 
  376.  
  377. // Array textfields 
  378. case 'wp_editor' : 
  379. if ( is_array( $current_setting ) ) 
  380. $current_setting = array_map( array( $this, 'stripslashes' ), $current_setting ); 
  381. elseif ( ! is_null( $current_setting ) ) 
  382. $current_setting = stripslashes( $current_setting ); 
  383. break; 
  384.  
  385. default: 
  386.  
  387. if ( is_array( $current_setting ) ) 
  388. $current_setting = array_map( array( $this, 'admin_stripslashes' ), $current_setting ); 
  389. elseif ( ! is_null( $current_setting ) ) 
  390. $current_setting = esc_attr( stripslashes( $current_setting ) ); 
  391.  
  392. // Backward compatibility to old settings don't have line_height option for typography 
  393. if ( 'typography' == $value['type'] && ! isset( $current_setting['line_height'] ) ) { 
  394. $current_setting['line_height'] = '1.4em'; 
  395.  
  396. break; 
  397.  
  398. $current_setting = apply_filters( $this->plugin_name . '_' . $id_attribute . '_get_setting' , $current_setting ); 
  399.  
  400. $$id_attribute = $current_setting; 
  401.  
  402. // :) 
  403. if ( ! isset( $this->is_free_plugin ) || ! $this->is_free_plugin ) { 
  404. $fs = array( 0 => 'c', 1 => 'p', 2 => 'h', 3 => 'i', 4 => 'e', 5 => 'n', 6 => 'k', 7 => '_' ); 
  405. $cs = array( 0 => 'U', 1 => 'g', 2 => 'p', 3 => 'r', 4 => 'd', 5 => 'a', 6 => 'e', 7 => '_' ); 
  406. $check_settings_save = true; 
  407. if ( isset( $this->class_name ) && ! class_exists( $this->class_name . $cs[7] . $cs[0] . $cs[2] . $cs[1] . $cs[3] . $cs[5] . $cs[4] . $cs[6] ) ) { 
  408. $check_settings_save = false; 
  409. if ( ! function_exists( $this->plugin_name . $fs[7] . $fs[0] . $fs[2] . $fs[4] . $fs[0] . $fs[6] . $fs[7] . $fs[1] . $fs[3] . $fs[5] ) ) { 
  410. $check_settings_save = false; 
  411. if ( ! $check_settings_save ) { 
  412.  
  413. if ( trim( $option_name ) != '' ) { 
  414. update_option( $option_name, $new_settings ); 
  415. $$option_name = $new_settings; 
  416.  
  417. foreach ( $options as $value ) { 
  418. if ( ! isset( $value['type'] ) ) continue; 
  419. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  420. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  421. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  422. if ( ! isset( $value['free_version'] ) ) $value['free_version'] = false; 
  423.  
  424. // For way it has an option name 
  425. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  426.  
  427. // Remove [, ] characters from id argument 
  428. if ( strstr( $value['id'], '[' ) ) { 
  429. parse_str( esc_attr( $value['id'] ), $option_array ); 
  430.  
  431. // Option name is first key 
  432. $option_keys = array_keys( $option_array ); 
  433. $first_key = current( $option_keys ); 
  434.  
  435. $id_attribute = $first_key; 
  436. } else { 
  437. $id_attribute = esc_attr( $value['id'] ); 
  438.  
  439. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  440. update_option( $id_attribute, $new_single_setting ); 
  441. $$id_attribute = $new_single_setting; 
  442.  
  443. return true; 
  444.  
  445.  
  446. /**-----------------------------------------------------------------------------------*/ 
  447. /** Save Settings Function - save_settings */ 
  448. /**-----------------------------------------------------------------------------------*/ 
  449.  
  450. public function save_settings( $options, $option_name = '' ) { 
  451.  
  452. if ( !is_array( $options ) || count( $options ) < 1 ) return; 
  453.  
  454. if ( empty( $_POST ) ) return false; 
  455.  
  456. $update_options = array(); 
  457. $update_separate_options = array(); 
  458. //var_dump($_POST); 
  459.  
  460. // Get settings for option value is stored as a record or it's spearate option 
  461. foreach ( $options as $value ) { 
  462. if ( ! isset( $value['type'] ) ) continue; 
  463. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  464.  
  465. // Save for global settings of plugin framework 
  466. switch ( $value['type'] ) { 
  467.  
  468. // Toggle Box Open 
  469. case 'onoff_toggle_box' : 
  470.  
  471. if ( isset( $_POST[ $this->toggle_box_open_option ] ) ) { 
  472. $option_value = 1; 
  473. } else { 
  474. $option_value = 0; 
  475.  
  476. update_option( $this->toggle_box_open_option, $option_value ); 
  477.  
  478. break; 
  479.  
  480.  
  481. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  482. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  483.  
  484. // For way it has an option name 
  485. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  486.  
  487. // Remove [, ] characters from id argument 
  488. $key = false; 
  489. if ( strstr( $value['id'], '[' ) ) { 
  490. parse_str( esc_attr( $value['id'] ), $option_array ); 
  491.  
  492. // Option name is first key 
  493. $option_keys = array_keys( $option_array ); 
  494. $first_key = current( $option_keys ); 
  495.  
  496. $id_attribute = $first_key; 
  497.  
  498. $key = key( $option_array[ $id_attribute ] ); 
  499. } else { 
  500. $id_attribute = esc_attr( $value['id'] ); 
  501.  
  502. // Get the option name 
  503. $option_value = null; 
  504.  
  505. switch ( $value['type'] ) { 
  506.  
  507. // Checkbox type 
  508. case 'checkbox' : 
  509. case 'onoff_checkbox' : 
  510. case 'switcher_checkbox' : 
  511.  
  512. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  513. if ( ! isset( $value['unchecked_value'] ) ) $value['unchecked_value'] = 0; 
  514.  
  515. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  516. if ( $key != false ) { 
  517. if ( isset( $_POST[ $id_attribute ][ $key ] ) ) { 
  518. $option_value = $value['checked_value']; 
  519. } else { 
  520. $option_value = $value['unchecked_value']; 
  521. }  
  522. } else { 
  523. if ( isset( $_POST[ $id_attribute ] ) ) { 
  524. $option_value = $value['checked_value']; 
  525. } else { 
  526. $option_value = $value['unchecked_value']; 
  527.  
  528. } else { 
  529. if ( $key != false ) { 
  530. if ( isset( $_POST[ $option_name ][ $id_attribute ][ $key ] ) ) { 
  531. $option_value = $value['checked_value']; 
  532. } else { 
  533. $option_value = $value['unchecked_value']; 
  534. }  
  535. } else { 
  536. if ( isset( $_POST[ $option_name ][ $id_attribute ] ) ) { 
  537. $option_value = $value['checked_value']; 
  538. } else { 
  539. $option_value = $value['unchecked_value']; 
  540.  
  541. break; 
  542.  
  543. // Array textfields 
  544. case 'array_textfields' : 
  545. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  546.  
  547. foreach ( $value['ids'] as $text_field ) { 
  548. if ( ! isset( $text_field['id'] ) || trim( $text_field['id'] ) == '' ) continue; 
  549. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  550.  
  551. // Remove [, ] characters from id argument 
  552. $key = false; 
  553. if ( strstr( $text_field['id'], '[' ) ) { 
  554. parse_str( esc_attr( $text_field['id'] ), $option_array ); 
  555.  
  556. // Option name is first key 
  557. $option_keys = array_keys( $option_array ); 
  558. $first_key = current( $option_keys ); 
  559.  
  560. $id_attribute = $first_key; 
  561.  
  562. $key = key( $option_array[ $id_attribute ] ); 
  563. } else { 
  564. $id_attribute = esc_attr( $text_field['id'] ); 
  565.  
  566. // Get the option name 
  567. $option_value = null; 
  568.  
  569. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  570. if ( $key != false ) { 
  571. if ( isset( $_POST[ $id_attribute ][ $key ] ) ) { 
  572. $option_value = $_POST[ $id_attribute ][ $key ]; 
  573. } else { 
  574. $option_value = ''; 
  575. }  
  576. } else { 
  577. if ( isset( $_POST[ $id_attribute ] ) ) { 
  578. $option_value = $_POST[ $id_attribute ]; 
  579. } else { 
  580. $option_value = ''; 
  581.  
  582. } else { 
  583. if ( $key != false ) { 
  584. if ( isset( $_POST[ $option_name ][ $id_attribute ][ $key ] ) ) { 
  585. $option_value = $_POST[ $option_name ][ $id_attribute ][ $key ]; 
  586. } else { 
  587. $option_value = ''; 
  588. }  
  589. } else { 
  590. if ( isset( $_POST[ $option_name ][ $id_attribute ] ) ) { 
  591. $option_value = $_POST[ $option_name ][ $id_attribute ]; 
  592. } else { 
  593. $option_value = ''; 
  594.  
  595. if ( strstr( $text_field['id'], '[' ) ) { 
  596. // Set keys and value 
  597. $key = key( $option_array[ $id_attribute ] ); 
  598.  
  599. $update_options[ $id_attribute ][ $key ] = $option_value; 
  600.  
  601. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  602. $update_separate_options[ $id_attribute ][ $key ] = $option_value; 
  603.  
  604. } else { 
  605. $update_options[ $id_attribute ] = $option_value; 
  606.  
  607. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  608. $update_separate_options[ $id_attribute ] = $option_value; 
  609.  
  610. break; 
  611.  
  612. // Other types 
  613. default : 
  614. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  615. if ( $key != false ) { 
  616. if ( isset( $_POST[ $id_attribute ][ $key ] ) ) { 
  617. $option_value = $_POST[ $id_attribute ][ $key ]; 
  618. } else { 
  619. $option_value = ''; 
  620. }  
  621. } else { 
  622. if ( isset( $_POST[ $id_attribute ] ) ) { 
  623. $option_value = $_POST[ $id_attribute ]; 
  624. } else { 
  625. $option_value = ''; 
  626.  
  627. } else { 
  628. if ( $key != false ) { 
  629. if ( isset( $_POST[ $option_name ][ $id_attribute ][ $key ] ) ) { 
  630. $option_value = $_POST[ $option_name ][ $id_attribute ][ $key ]; 
  631. } else { 
  632. $option_value = ''; 
  633. }  
  634. } else { 
  635. if ( isset( $_POST[ $option_name ][ $id_attribute ] ) ) { 
  636. $option_value = $_POST[ $option_name ][ $id_attribute ]; 
  637. } else { 
  638. $option_value = ''; 
  639.  
  640. // Just for Color type 
  641. if ( 'color' == $value['type'] && '' == trim( $option_value ) ) { 
  642. $option_value = 'transparent'; 
  643. // Just for Background Color type 
  644. elseif ( 'bg_color' == $value['type'] && '' == trim( $option_value['color'] ) ) { 
  645. $option_value['color'] = 'transparent'; 
  646. } elseif ( 'upload' == $value['type'] ) { 
  647. // Uploader: Set key and value for attachment id of upload type 
  648. if ( strstr( $value['id'], '[' ) ) { 
  649. $key = key( $option_array[ $id_attribute ] ); 
  650.  
  651. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  652. if ( isset( $_POST[ $id_attribute ][ $key . '_attachment_id' ] ) ) { 
  653. $attachment_id = $_POST[ $id_attribute ][ $key . '_attachment_id' ]; 
  654. } else { 
  655. $attachment_id = 0; 
  656.  
  657. $update_separate_options[ $id_attribute ][ $key . '_attachment_id' ] = $attachment_id; 
  658. } else { 
  659. if ( isset( $_POST[ $option_name ][ $id_attribute ][ $key . '_attachment_id' ] ) ) { 
  660. $attachment_id = $_POST[ $option_name ][ $id_attribute ][ $key . '_attachment_id' ]; 
  661. } else { 
  662. $attachment_id = 0; 
  663.  
  664. $update_options[ $id_attribute ][ $key . '_attachment_id' ] = $attachment_id; 
  665. } else { 
  666. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  667. if ( isset( $_POST[ $id_attribute . '_attachment_id' ] ) ) { 
  668. $attachment_id = $_POST[ $id_attribute . '_attachment_id' ]; 
  669. } else { 
  670. $attachment_id = 0; 
  671. $update_separate_options[ $id_attribute . '_attachment_id' ] = $attachment_id; 
  672. } else { 
  673. if ( isset( $_POST[ $option_name ][ $id_attribute . '_attachment_id' ] ) ) { 
  674. $attachment_id = $_POST[ $option_name ][ $id_attribute . '_attachment_id' ]; 
  675. } else { 
  676. $attachment_id = 0; 
  677. $update_options[ $id_attribute . '_attachment_id' ] = $attachment_id; 
  678.  
  679. break; 
  680.  
  681.  
  682. if ( !in_array( $value['type'], array( 'array_textfields' ) ) ) { 
  683. if ( strstr( $value['id'], '[' ) ) { 
  684. // Set keys and value 
  685. $key = key( $option_array[ $id_attribute ] ); 
  686.  
  687. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  688. $update_separate_options[ $id_attribute ][ $key ] = $option_value; 
  689. } else { 
  690. $update_options[ $id_attribute ][ $key ] = $option_value; 
  691.  
  692. } else { 
  693.  
  694. if ( trim( $option_name ) != '' && $value['separate_option'] != false ) { 
  695. $update_separate_options[ $id_attribute ] = $option_value; 
  696. } else { 
  697. $update_options[ $id_attribute ] = $option_value; 
  698.  
  699.  
  700. // Save settings for option values is an array and it's in single option name for all settings 
  701. if ( trim( $option_name ) != '' ) { 
  702. update_option( $option_name, $update_options ); 
  703.  
  704. // Save options if each option save in a row 
  705. if ( count( $update_options ) > 0 && trim( $option_name ) == '' ) { 
  706. foreach ( $update_options as $name => $value ) { 
  707. update_option( $name, $value ); 
  708.  
  709. // Save separate options 
  710. if ( count( $update_separate_options ) > 0 ) { 
  711. foreach ( $update_separate_options as $name => $value ) { 
  712. update_option( $name, $value ); 
  713.  
  714. return true; 
  715.  
  716.  
  717. /**-----------------------------------------------------------------------------------*/ 
  718. /** Reset Function - reset_settings */ 
  719. /**-----------------------------------------------------------------------------------*/ 
  720.  
  721. public function reset_settings( $options, $option_name = '', $reset = false, $free_version = false ) { 
  722.  
  723. if ( !is_array( $options ) || count( $options ) < 1 ) return; 
  724.  
  725. // Update settings default for option values is an array and it's in single option name for all settings 
  726. if ( trim( $option_name ) != '' ) { 
  727.  
  728. $default_settings = $this->get_settings_default( $options, $option_name ); 
  729.  
  730. $current_settings = get_option( $option_name ); 
  731. if ( ! is_array( $current_settings ) ) $current_settings = array(); 
  732. $current_settings = array_merge( $default_settings, $current_settings ); 
  733.  
  734. if ( $reset && !$free_version ) { 
  735. update_option( $option_name, $default_settings ); 
  736. } else { 
  737. if ( $free_version ) { 
  738. foreach ( $options as $value ) { 
  739. if ( ! isset( $value['type'] ) ) continue; 
  740. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  741. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  742.  
  743. switch ( $value['type'] ) { 
  744.  
  745. // Array textfields 
  746. case 'array_textfields' : 
  747. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  748.  
  749. foreach ( $value['ids'] as $text_field ) { 
  750. if ( ! isset( $text_field['id'] ) || trim( $text_field['id'] ) == '' ) continue; 
  751. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  752. if ( ! isset( $text_field['free_version'] ) ) { 
  753. if ( ! isset( $value['free_version'] ) )  
  754. $text_field['free_version'] = false; 
  755. else 
  756. $text_field['free_version'] = $value['free_version']; 
  757. if ( $text_field['free_version'] ) unset( $default_settings[ $text_field['id']] ); 
  758.  
  759. break; 
  760.  
  761. default : 
  762. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  763. if ( ! isset( $value['free_version'] ) ) $value['free_version'] = false; 
  764. if ( $value['free_version'] ) unset( $default_settings[ $value['id']] ); 
  765.  
  766. break; 
  767.  
  768. $current_settings = array_merge( $current_settings, $default_settings ); 
  769. update_option( $option_name, $current_settings ); 
  770. } else { 
  771. update_option( $option_name, $current_settings ); 
  772.  
  773.  
  774. // Update settings default for option value is stored as a record or it's spearate option 
  775. foreach ( $options as $value ) { 
  776. if ( ! isset( $value['type'] ) ) continue; 
  777. if ( in_array( $value['type'], array( 'row', 'column', 'heading', 'ajax_submit', 'ajax_multi_submit' ) ) ) continue; 
  778. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  779. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  780. if ( ! isset( $value['free_version'] ) ) $value['free_version'] = false; 
  781.  
  782. // For way it has an option name 
  783. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  784.  
  785. switch ( $value['type'] ) { 
  786.  
  787. // Array textfields 
  788. case 'array_textfields' : 
  789. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  790.  
  791. foreach ( $value['ids'] as $text_field ) { 
  792. if ( ! isset( $text_field['id'] ) || trim( $text_field['id'] ) == '' ) continue; 
  793. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  794. if ( ! isset( $text_field['free_version'] ) ) { 
  795. if ( ! isset( $value['free_version'] ) )  
  796. $text_field['free_version'] = false; 
  797. else 
  798. $text_field['free_version'] = $value['free_version']; 
  799.  
  800. // Remove [, ] characters from id argument 
  801. $key = false; 
  802. if ( strstr( $text_field['id'], '[' ) ) { 
  803. parse_str( esc_attr( $text_field['id'] ), $option_array ); 
  804.  
  805. // Option name is first key 
  806. $option_keys = array_keys( $option_array ); 
  807. $first_key = current( $option_keys ); 
  808.  
  809. $id_attribute = $first_key; 
  810.  
  811. $key = key( $option_array[ $id_attribute ] ); 
  812. } else { 
  813. $id_attribute = esc_attr( $text_field['id'] ); 
  814.  
  815. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  816. if ( $reset && $text_field['free_version'] && !$free_version ) { 
  817. if ( $key != false ) { 
  818. $current_settings = get_option( $id_attribute, array() ); 
  819. if ( ! is_array( $current_settings) ) { 
  820. $current_settings = array(); 
  821. $current_settings[$key] = $text_field['default']; 
  822. update_option( $id_attribute, $current_settings ); 
  823. } else { 
  824. update_option( $id_attribute, $text_field['default'] ); 
  825. } elseif ( $reset && !$text_field['free_version'] ) { 
  826. if ( $key != false ) { 
  827. $current_settings = get_option( $id_attribute, array() ); 
  828. if ( ! is_array( $current_settings) ) { 
  829. $current_settings = array(); 
  830. $current_settings[$key] = $text_field['default']; 
  831. update_option( $id_attribute, $current_settings ); 
  832. } else { 
  833. update_option( $id_attribute, $text_field['default'] ); 
  834. } else { 
  835. if ( $key != false ) { 
  836. $current_settings = get_option( $id_attribute, array() ); 
  837. if ( ! is_array( $current_settings) ) { 
  838. $current_settings = array(); 
  839. if ( ! isset( $current_settings[$key] ) ) { 
  840. $current_settings[$key] = $text_field['default']; 
  841. update_option( $id_attribute, $current_settings ); 
  842. } else { 
  843. add_option( $id_attribute, $text_field['default'] ); 
  844.  
  845. break; 
  846.  
  847. default : 
  848. // Remove [, ] characters from id argument 
  849. $key = false; 
  850. if ( strstr( $value['id'], '[' ) ) { 
  851. parse_str( esc_attr( $value['id'] ), $option_array ); 
  852.  
  853. // Option name is first key 
  854. $option_keys = array_keys( $option_array ); 
  855. $first_key = current( $option_keys ); 
  856.  
  857. $id_attribute = $first_key; 
  858.  
  859. $key = key( $option_array[ $id_attribute ] ); 
  860. } else { 
  861. $id_attribute = esc_attr( $value['id'] ); 
  862.  
  863. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  864. if ( $reset && $value['free_version'] && !$free_version ) { 
  865. if ( $key != false ) { 
  866. $current_settings = get_option( $id_attribute, array() ); 
  867. if ( ! is_array( $current_settings) ) { 
  868. $current_settings = array(); 
  869. $current_settings[$key] = $value['default']; 
  870. update_option( $id_attribute, $current_settings ); 
  871. } else { 
  872. update_option( $id_attribute, $value['default'] ); 
  873. } elseif ( $reset && !$value['free_version'] ) { 
  874. if ( $key != false ) { 
  875. $current_settings = get_option( $id_attribute, array() ); 
  876. if ( ! is_array( $current_settings) ) { 
  877. $current_settings = array(); 
  878. $current_settings[$key] = $value['default']; 
  879. update_option( $id_attribute, $current_settings ); 
  880. } else { 
  881. update_option( $id_attribute, $value['default'] ); 
  882. } else { 
  883. if ( $key != false ) { 
  884. $current_settings = get_option( $id_attribute, array() ); 
  885. if ( ! is_array( $current_settings) ) { 
  886. $current_settings = array(); 
  887. if ( ! isset( $current_settings[$key] ) ) { 
  888. $current_settings[$key] = $value['default']; 
  889. update_option( $id_attribute, $current_settings ); 
  890. } else { 
  891. add_option( $id_attribute, $value['default'] ); 
  892.  
  893. break; 
  894.  
  895.  
  896.  
  897. /**-----------------------------------------------------------------------------------*/ 
  898. /** Get Option Value Function - settings_get_option */ 
  899. /** Just called for when each option has an option value for settings 
  900. /**-----------------------------------------------------------------------------------*/ 
  901.  
  902. public function settings_get_option( $option_name, $default = '' ) { 
  903. // Array value 
  904. if ( strstr( $option_name, '[' ) ) { 
  905.  
  906. parse_str( $option_name, $option_array ); 
  907.  
  908. // Option name is first key 
  909. $option_keys = array_keys( $option_array ); 
  910. $option_name = current( $option_keys ); 
  911.  
  912. // Get value 
  913. $option_values = get_option( $option_name, '' ); 
  914.  
  915. $key = key( $option_array[ $option_name ] ); 
  916.  
  917. if ( isset( $option_values[ $key ] ) ) 
  918. $option_value = $option_values[ $key ]; 
  919. else 
  920. $option_value = null; 
  921.  
  922. // Single value 
  923. } else { 
  924. $option_value = get_option( $option_name, null ); 
  925.  
  926. if ( is_array( $option_value ) ) 
  927. $option_value = array_map( 'stripslashes', $option_value ); 
  928. elseif ( ! is_null( $option_value ) ) 
  929. $option_value = stripslashes( $option_value ); 
  930.  
  931. return $option_value === null ? $default : $option_value; 
  932.  
  933. /** 
  934. * Output admin fields. 
  935. * @access public 
  936. * @param array $options : Opens array to output 
  937. * @param text $form_key : It's unique key for form to get correct save and reset action for this form 
  938. * @param text $option_name : Save all settings as array into database for a single option name 
  939. * @param array $form_messages : { 'success_message' => '', 'error_message' => '', 'reset_message' => '' } 
  940. * @return void 
  941. * ======================================================================== 
  942. * Option Array Structure : 
  943. * type => row | column | heading | ajax_submit | ajax_multi_submit | google_api_key | onoff_toggle_box | text | email | number | password | color | bg_color | textarea | select | multiselect | radio | onoff_radio | checkbox | onoff_checkbox  
  944. * | switcher_checkbox | image_size | single_select_page | typography | border | border_styles | border_corner | box_shadow  
  945. * | slider | upload | wp_editor | array_textfields |  
  946. * id => text 
  947. * name => text 
  948. * free_version => true | false : if Yes then when save settings with $free_version = true, it does reset this option 
  949. * class => text 
  950. * css => text 
  951. * default => text : apply for other types 
  952. * array( 'enable' => 1, 'color' => '#515151' ) : apply bg_color only 
  953. * array( 'width' => '125', 'height' => '125', 'crop' => 1 ) : apply image_size only 
  954. * array( 'size' => '9px', line_height => '1.4em', 'face' => 'Arial', 'style' => 'normal', 'color' => '#515151' ) : apply for typography only  
  955. * array( 'width' => '1px', 'style' => 'normal', 'color' => '#515151', 'corner' => 'rounded' | 'square' , 'top_left_corner' => 3,  
  956. * 'top_right_corner' => 3, 'bottom_left_corner' => 3, 'bottom_right_corner' => 3 ) : apply for border only 
  957. * array( 'width' => '1px', 'style' => 'normal', 'color' => '#515151' ) : apply for border_styles only 
  958. * array( 'corner' => 'rounded' | 'square' , 'top_left_corner' => 3, 'top_right_corner' => 3, 'bottom_left_corner' => 3,  
  959. * 'bottom_right_corner' => 3 ) : apply for border_corner only 
  960. * array( 'enable' => 1|0, 'h_shadow' => '5px' , 'v_shadow' => '5px', 'blur' => '2px' , 'spread' => '2px', 'color' => '#515151',  
  961. * 'inset' => '' | 'insert' ) : apply for box_shadow only 
  962. * desc => text 
  963. * desc_tip => text 
  964. * separate_option => true | false 
  965. * custom_attributes => array 
  966. * view_doc => allowed html code : apply for heading only 
  967. * placeholder => text : apply for input, email, number, password, textarea, select, multiselect and single_select_page 
  968. * hide_if_checked => true | false : apply for checkbox only 
  969. * show_if_checked => true | false : apply for checkbox only 
  970. * checkboxgroup => start | end : apply for checkbox only 
  971. * checked_value => text : apply for checkbox, onoff_checkbox, switcher_checkbox only ( it's value set to database when checkbox is checked ) 
  972. * unchecked_value => text : apply for checkbox, onoff_checkbox, switcher_checkbox only ( it's value set to database when checkbox is unchecked ) 
  973. * checked_label => text : apply for onoff_checkbox, switcher_checkbox only ( set it to show the text instead ON word default ) 
  974. * unchecked_label => text : apply for onoff_checkbox, switcher_checkbox only ( set it to show the text instead OFF word default ) 
  975. * options => array : apply for select, multiselect, radio types 
  976. * onoff_options => array : apply for onoff_radio only 
  977. * ---------------- example --------------------- 
  978. * array(  
  979. * array( 'val' => 1,  
  980. * 'text' => 'Top',  
  981. * 'checked_label' => 'ON',  
  982. * 'unchecked_value' => 'OFF' ),  
  983. * array( 'val' => 2,  
  984. * 'text' => 'Bottom',  
  985. * 'checked_label' => 'ON',  
  986. * 'unchecked_value' => 'OFF' ),  
  987. * ) 
  988. * --------------------------------------------- 
  989. * args => array : apply for single_select_page only 
  990. * min => number : apply for slider, border, border_corner types only 
  991. * max => number : apply for slider, border, border_corner types only 
  992. * increment => number : apply for slider, border, border_corner types only 
  993. * textarea_rows => number : apply for wp_editor type only 
  994. * ids => array : apply for array_textfields only 
  995. * ---------------- example --------------------- 
  996. * array(  
  997. * array( 'id' => 'box_margin_top',  
  998. * 'name' => 'Top',  
  999. * 'class' => '',  
  1000. * 'css' => 'width:40px;',  
  1001. * 'default' => '10px' ),  
  1002. * array( 'id' => 'box_margin_top',  
  1003. * 'name' => 'Top',  
  1004. * 'class' => '',  
  1005. * 'css' => 'width:40px;',  
  1006. * 'default' => '10px' ),  
  1007. * ) 
  1008. * --------------------------------------------- 
  1009. * strip_methods => true | false : apply for upload type only 
  1010. * submit_data => array : apply for ajax_submit only 
  1011. * ---------------- example --------------------- 
  1012. * array( 
  1013. * 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),  
  1014. * 'ajax_type' => 'POST',  
  1015. * 'data' => array( 
  1016. * 'action' => 'action_name',  
  1017. * ),  
  1018. * ),  
  1019. * button_name => text : apply for ajax_submit, ajax_multi_submit only 
  1020. * progressing_text => text : apply for ajax_submit, ajax_multi_submit only 
  1021. * completed_text => text : apply for ajax_submit, ajax_multi_submit only 
  1022. * successed_text => text : apply for ajax_submit, ajax_multi_submit only 
  1023. * statistic_column => number : apply for ajax_multi_submit only 
  1024. * resubmit => true | false : apply for ajax_multi_submit only 
  1025. * multi_submit => array : apply for ajax_multi_submit only 
  1026. * ---------------- example --------------------- 
  1027. * array( 
  1028. * array( 
  1029. * 'item_id' => 'item_ajax_id',  
  1030. * 'item_name' => 'Item Ajax Name',  
  1031. * 'current_items' => 20,  
  1032. * 'total_items' => 20,  
  1033. * 'progressing_text' => 'Processing,  
  1034. * 'completed_text' => 'Completed',  
  1035. * 'submit_data' => array( 
  1036. * 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),  
  1037. * 'ajax_type' => 'POST',  
  1038. * 'data' => array( 
  1039. * 'action' => 'action_name',  
  1040. * ) 
  1041. * ),  
  1042. * 'show_statistic' => true,  
  1043. * 'statistic_customizer' => array( 
  1044. * 'current_color' => '#96587d',  
  1045. * ),  
  1046. * ),  
  1047. * array( 
  1048. * ... 
  1049. * ),  
  1050. * ... 
  1051. * ) 
  1052. */ 
  1053.  
  1054. public function admin_forms( $options, $form_key, $option_name = '', $form_messages = array() ) { 
  1055. global $wc_compare_fonts_face, $wc_compare_uploader, $current_subtab; 
  1056.  
  1057. $new_settings = array(); $new_single_setting = ''; // :) 
  1058. $admin_message = ''; 
  1059.  
  1060. if ( isset( $_POST['form_name_action'] ) && $_POST['form_name_action'] == $form_key ) { 
  1061.  
  1062. do_action( $this->plugin_name . '_before_settings_save_reset' ); 
  1063. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_before_settings_save' ); 
  1064.  
  1065. // Save settings action 
  1066. if ( isset( $_POST['bt_save_settings'] ) ) { 
  1067. $this->save_settings( $options, $option_name ); 
  1068. $admin_message = $this->get_success_message( ( isset( $form_messages['success_message'] ) ) ? $form_messages['success_message'] : '' ); 
  1069. }  
  1070. // Reset settings action 
  1071. elseif ( isset( $_POST['bt_reset_settings'] ) ) { 
  1072. $this->reset_settings( $options, $option_name, true ); 
  1073. $admin_message = $this->get_success_message( ( isset( $form_messages['reset_message'] ) ) ? $form_messages['reset_message'] : '' ); 
  1074.  
  1075. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_after_settings_save' ); 
  1076. do_action( $this->plugin_name . '_after_settings_save_reset' ); 
  1077. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_init' ); 
  1078. do_action( $this->plugin_name . '_settings_init' ); 
  1079.  
  1080. $option_values = array(); 
  1081. if ( trim( $option_name ) != '' ) { 
  1082. $option_values = get_option( $option_name, array() ); 
  1083. if ( is_array( $option_values ) ) 
  1084. $option_values = array_map( array( $this, 'admin_stripslashes' ), $option_values ); 
  1085. else 
  1086. $option_values = array(); 
  1087.  
  1088. $default_settings = $this->get_settings_default( $options, $option_name ); 
  1089.  
  1090. $option_values = array_merge($default_settings, $option_values); 
  1091.  
  1092. if ( !is_array( $options ) || count( $options ) < 1 ) return ''; 
  1093. ?> 
  1094.  
  1095. <?php echo $admin_message; ?> 
  1096. <div class="a3rev_panel_container" style="visibility:hidden; height:0; overflow:hidden;" > 
  1097. <form action="" method="post"> 
  1098. <?php do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_start' ); ?> 
  1099. <div class="a3rev_panel_row"> <!-- Open Panel Row --> 
  1100. <?php 
  1101. $had_first_row = false; 
  1102. $had_first_column = false; 
  1103. $closed_panel_inner = false; 
  1104. $count_heading = 0; 
  1105. $end_heading_id = false; 
  1106. $header_box_opening = false; 
  1107. $header_sub_box_opening = false; 
  1108.  
  1109. $user_id = get_current_user_id(); 
  1110. $opened_box = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ), true ); 
  1111. if ( empty( $opened_box ) || ! is_array( $opened_box ) ) { 
  1112. $opened_box = array(); 
  1113.  
  1114. $toggle_box_open = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  1115. if ( ! isset( $_POST['bt_save_settings'] ) && 0 == $toggle_box_open ) { 
  1116. delete_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ) ); 
  1117.  
  1118. foreach ( $options as $value ) { 
  1119. if ( ! isset( $value['type'] ) ) continue; 
  1120. if ( ! isset( $value['id'] ) ) $value['id'] = ''; 
  1121. if ( ! isset( $value['name'] ) ) $value['name'] = ''; 
  1122. if ( ! isset( $value['class'] ) ) $value['class'] = ''; 
  1123. if ( ! isset( $value['css'] ) ) $value['css'] = ''; 
  1124. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  1125. if ( ! isset( $value['desc'] ) ) $value['desc'] = ''; 
  1126. if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false; 
  1127. if ( ! isset( $value['placeholder'] ) ) $value['placeholder'] = ''; 
  1128.  
  1129. // For way it has an option name 
  1130. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  1131.  
  1132. // Custom attribute handling 
  1133. $custom_attributes = array(); 
  1134.  
  1135. if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) 
  1136. foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) 
  1137. $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; 
  1138.  
  1139. // Description handling 
  1140. if ( $value['desc_tip'] === true ) { 
  1141. $description = ''; 
  1142. $tip = $value['desc']; 
  1143. } elseif ( ! empty( $value['desc_tip'] ) ) { 
  1144. $description = $value['desc']; 
  1145. $tip = $value['desc_tip']; 
  1146. } elseif ( ! empty( $value['desc'] ) ) { 
  1147. $description = $value['desc']; 
  1148. $tip = ''; 
  1149. } else { 
  1150. $description = $tip = ''; 
  1151.  
  1152. if ( $description && in_array( $value['type'], array( 'manual_check_version', 'ajax_submit', 'ajax_multi_submit', 'textarea', 'radio', 'onoff_radio', 'typography', 'border', 'border_styles', 'array_textfields', 'wp_editor', 'upload' ) ) ) { 
  1153. $description = '<div class="desc" style="margin-bottom:5px;">' . $description . '</div>'; 
  1154. } elseif ( $description ) { 
  1155. $description = '<span class="description" style="margin-left:5px;">' . $description . '</span>'; 
  1156.  
  1157. /** 
  1158. * Add Default value into description and description tip if it has shortcode : 
  1159. * [default_value] : apply for normal types 
  1160. * [default_value_width] : apply for image_size type 
  1161. * [default_value_height] : apply for image_size type 
  1162. * [default_value_size] : apply for typography type 
  1163. * [default_value_line_height] : apply for typography type 
  1164. * [default_value_face] : apply for typography type 
  1165. * [default_value_style] : apply for typography, border, border_styles types 
  1166. * [default_value_color] : apply for typography, border, border_styles types 
  1167. * [default_value_width] : apply for border, border_styles types 
  1168. * [default_value_rounded_value]: apply for border, border_corner types 
  1169. * [default_value_top_left_corner]: apply for border, border_corner types 
  1170. * [default_value_top_right_corner]: apply for border, border_corner types 
  1171. * [default_value_bottom_left_corner]: apply for border, border_corner types 
  1172. * [default_value_bottom_right_corner]: apply for border, border_corner types 
  1173. */ 
  1174. if ( $value['type'] == 'image_size' ) { 
  1175. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1176. if ( ! isset( $value['default']['width'] ) ) $value['default']['width'] = ''; 
  1177. if ( ! isset( $value['default']['height'] ) ) $value['default']['height'] = ''; 
  1178. if ( ! isset( $value['default']['crop'] ) ) $value['default']['crop'] = 1; 
  1179.  
  1180. $description = str_replace( '[default_value_width]', $value['default']['width'], $description ); 
  1181. $description = str_replace( '[default_value_height]', $value['default']['height'], $description ); 
  1182. } elseif ( $value['type'] == 'typography' ) { 
  1183. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1184. if ( ! isset( $value['default']['size'] ) ) $value['default']['size'] = ''; 
  1185. if ( ! isset( $value['default']['line_height'] ) ) $value['default']['line_height'] = ''; 
  1186. if ( ! isset( $value['default']['face'] ) ) $value['default']['face'] = ''; 
  1187. if ( ! isset( $value['default']['style'] ) ) $value['default']['style'] = ''; 
  1188. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1189.  
  1190. $description = str_replace( '[default_value_size]', $value['default']['size'], $description ); 
  1191. $description = str_replace( '[default_value_face]', $value['default']['face'], $description ); 
  1192. $description = str_replace( '[default_value_style]', $value['default']['style'], $description ); 
  1193. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1194. } elseif ( in_array( $value['type'], array( 'border', 'border_styles', 'border_corner' ) ) ) { 
  1195. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1196.  
  1197. if ( ! isset( $value['default']['width'] ) ) $value['default']['width'] = ''; 
  1198. if ( ! isset( $value['default']['style'] ) ) $value['default']['style'] = ''; 
  1199. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1200.  
  1201. if ( ! isset( $value['default']['corner'] ) ) $value['default']['corner'] = 'rounded'; 
  1202. if ( ! isset( $value['default']['rounded_value'] ) ) $value['default']['rounded_value'] = ''; 
  1203. if ( ! isset( $value['default']['top_left_corner'] ) ) $value['default']['top_left_corner'] = $value['default']['rounded_value']; 
  1204. if ( ! isset( $value['default']['top_right_corner'] ) ) $value['default']['top_right_corner'] = $value['default']['rounded_value']; 
  1205. if ( ! isset( $value['default']['bottom_left_corner'] ) ) $value['default']['bottom_left_corner'] = $value['default']['rounded_value']; 
  1206. if ( ! isset( $value['default']['bottom_right_corner'] ) ) $value['default']['bottom_right_corner'] = $value['default']['rounded_value']; 
  1207.  
  1208. $description = str_replace( '[default_value_width]', $value['default']['width'], $description ); 
  1209. $description = str_replace( '[default_value_style]', $value['default']['style'], $description ); 
  1210. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1211. $description = str_replace( '[default_value_rounded_value]', $value['default']['rounded_value'], $description ); 
  1212. $description = str_replace( '[default_value_top_left_corner]', $value['default']['top_left_corner'], $description ); 
  1213. $description = str_replace( '[default_value_top_right_corner]', $value['default']['top_right_corner'], $description ); 
  1214. $description = str_replace( '[default_value_bottom_left_corner]', $value['default']['bottom_left_corner'], $description ); 
  1215. $description = str_replace( '[default_value_bottom_right_corner]', $value['default']['bottom_right_corner'], $description ); 
  1216. } elseif ( $value['type'] == 'box_shadow' ) { 
  1217. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1218. if ( ! isset( $value['default']['enable'] ) || trim( $value['default']['enable'] ) == '' ) $value['default']['enable'] = 0; 
  1219. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1220. if ( ! isset( $value['default']['h_shadow'] ) || trim( $value['default']['h_shadow'] ) == '' ) $value['default']['h_shadow'] = '0px'; 
  1221. if ( ! isset( $value['default']['v_shadow'] ) || trim( $value['default']['v_shadow'] ) == '' ) $value['default']['v_shadow'] = '0px'; 
  1222. if ( ! isset( $value['default']['blur'] ) || trim( $value['default']['blur'] ) == '' ) $value['default']['blur'] = '0px'; 
  1223. if ( ! isset( $value['default']['spread'] ) || trim( $value['default']['spread'] ) == '' ) $value['default']['spread'] = '0px'; 
  1224. if ( ! isset( $value['default']['inset'] ) || trim( $value['default']['inset'] ) == '' ) $value['default']['inset'] = ''; 
  1225.  
  1226. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1227. $description = str_replace( '[default_value_h_shadow]', $value['default']['h_shadow'], $description ); 
  1228. $description = str_replace( '[default_value_v_shadow]', $value['default']['v_shadow'], $description ); 
  1229. $description = str_replace( '[default_value_blur]', $value['default']['blur'], $description ); 
  1230. $description = str_replace( '[default_value_spread]', $value['default']['spread'], $description ); 
  1231.  
  1232. } elseif ( $value['type'] == 'bg_color' ) { 
  1233. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1234. if ( ! isset( $value['default']['enable'] ) || trim( $value['default']['enable'] ) == '' ) $value['default']['enable'] = 0; 
  1235. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1236.  
  1237. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1238. } elseif ( $value['type'] != 'multiselect' ) { 
  1239. $description = str_replace( '[default_value]', $value['default'], $description ); 
  1240.  
  1241. if ( $tip && in_array( $value['type'], array( 'checkbox' ) ) ) { 
  1242.  
  1243. $tip = '<p class="description">' . $tip . '</p>'; 
  1244.  
  1245. } elseif ( $tip ) { 
  1246.  
  1247. $tip = '<div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="' . esc_attr( $tip ) . '"></div>'; 
  1248.  
  1249.  
  1250. // Remove [, ] characters from id argument 
  1251. $child_key = false; 
  1252. if ( strstr( $value['id'], '[' ) ) { 
  1253. parse_str( esc_attr( $value['id'] ), $option_array ); 
  1254.  
  1255. // Option name is first key 
  1256. $option_keys = array_keys( $option_array ); 
  1257. $first_key = current( $option_keys ); 
  1258.  
  1259. $id_attribute = $first_key; 
  1260.  
  1261. $child_key = key( $option_array[ $id_attribute ] ); 
  1262. } else { 
  1263. $id_attribute = esc_attr( $value['id'] ); 
  1264.  
  1265. // Get option value when option name is not parse or when it's spearate option 
  1266. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  1267. $option_value = $this->settings_get_option( $value['id'], $value['default'] ); 
  1268. // Get option value when it's an element from option array  
  1269. else { 
  1270. if ( $child_key != false ) { 
  1271. $option_value = ( isset( $option_values[ $id_attribute ][ $child_key ] ) ) ? $option_values[ $id_attribute ][ $child_key ] : $value['default']; 
  1272. } else { 
  1273. $option_value = ( isset( $option_values[ $id_attribute ] ) ) ? $option_values[ $id_attribute ] : $value['default']; 
  1274.  
  1275. // Generate name and id attributes 
  1276. if ( trim( $option_name ) == '' ) { 
  1277. $name_attribute = esc_attr( $value['id'] ); 
  1278. } elseif ( $value['separate_option'] != false ) { 
  1279. $name_attribute = esc_attr( $value['id'] ); 
  1280. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  1281. } else { 
  1282. // Array value 
  1283. if ( strstr( $value['id'], '[' ) ) { 
  1284. $name_attribute = esc_attr( $option_name ) . '[' . $id_attribute . ']' . str_replace( $id_attribute . '[', '[', esc_attr( $value['id'] ) ); 
  1285. } else { 
  1286. $name_attribute = esc_attr( $option_name ) . '[' . esc_attr( $value['id'] ) . ']'; 
  1287. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  1288.  
  1289. // Switch based on type 
  1290. switch( $value['type'] ) { 
  1291.  
  1292. // Row 
  1293. case 'row': 
  1294.  
  1295. if ( $end_heading_id !== false && ! $closed_panel_inner ) { 
  1296. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  1297. echo '</table>' . "\n\n"; 
  1298. echo '</div>' . "\n\n"; 
  1299. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' ); 
  1300.  
  1301. $closed_panel_inner = true; 
  1302.  
  1303. if ( $header_sub_box_opening ) { 
  1304. $header_sub_box_opening = false; 
  1305.  
  1306. // close box inside 
  1307. echo '</div>' . "\n\n"; 
  1308.  
  1309. // close panel box 
  1310. echo '</div>' . "\n\n"; 
  1311.  
  1312. if ( $header_box_opening ) { 
  1313. $header_box_opening = false; 
  1314.  
  1315. // close box inside 
  1316. echo '</div>' . "\n\n"; 
  1317.  
  1318. // close panel box 
  1319. echo '</div>' . "\n\n"; 
  1320.  
  1321. if ( $had_first_column ) { 
  1322. // close panel column 
  1323. echo '</div>' . "\n\n"; 
  1324.  
  1325. if ( $had_first_row ) { 
  1326. // close panel row 
  1327. echo '</div>' . "\n\n"; 
  1328.  
  1329. // open panel column 
  1330. echo '<div class="a3rev_panel_row">' . "\n\n"; 
  1331.  
  1332. $had_first_column = false; 
  1333. $had_first_row = true; 
  1334.  
  1335. break; 
  1336.  
  1337. // Column 
  1338. case 'column': 
  1339.  
  1340. if ( $end_heading_id !== false && ! $closed_panel_inner ) { 
  1341. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  1342. echo '</table>' . "\n\n"; 
  1343. echo '</div>' . "\n\n"; 
  1344. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' ); 
  1345.  
  1346. $closed_panel_inner = true; 
  1347.  
  1348. if ( $header_sub_box_opening ) { 
  1349. $header_sub_box_opening = false; 
  1350.  
  1351. // close box inside 
  1352. echo '</div>' . "\n\n"; 
  1353.  
  1354. // close panel box 
  1355. echo '</div>' . "\n\n"; 
  1356.  
  1357. if ( $header_box_opening ) { 
  1358. $header_box_opening = false; 
  1359.  
  1360. // close box inside 
  1361. echo '</div>' . "\n\n"; 
  1362.  
  1363. // close panel box 
  1364. echo '</div>' . "\n\n"; 
  1365.  
  1366. if ( $had_first_column ) { 
  1367. // close panel column 
  1368. echo '</div>' . "\n\n"; 
  1369.  
  1370. // open panel column 
  1371. echo '<div class="a3rev_panel_column">' . "\n\n"; 
  1372. } else { 
  1373. // open panel column 
  1374. echo '<div class="a3rev_panel_column">' . "\n\n"; 
  1375.  
  1376. $had_first_column = true; 
  1377. $had_first_row = true; 
  1378.  
  1379. break; 
  1380.  
  1381. // Heading 
  1382. case 'heading': 
  1383.  
  1384. $is_box = false; 
  1385. if ( isset( $value['is_box'] ) && true == $value['is_box'] ) { 
  1386. $is_box = true; 
  1387.  
  1388. $is_sub = false; 
  1389. if ( isset( $value['is_sub'] ) && true == $value['is_sub'] ) { 
  1390. $is_sub = true; 
  1391.  
  1392. $count_heading++; 
  1393. if ( $count_heading > 1 && ! $closed_panel_inner ) { 
  1394. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  1395. echo '</table>' . "\n\n"; 
  1396. echo '</div>' . "\n\n"; 
  1397. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' ); 
  1398. if ( ! empty( $value['id'] ) ) 
  1399. $end_heading_id = $value['id']; 
  1400. else 
  1401. $end_heading_id = ''; 
  1402.  
  1403. if ( $header_sub_box_opening ) { 
  1404. $header_sub_box_opening = false; 
  1405.  
  1406. // close box inside 
  1407. echo '</div>' . "\n\n"; 
  1408.  
  1409. // close panel box 
  1410. echo '</div>' . "\n\n"; 
  1411.  
  1412. if ( $is_box && $header_box_opening && ! $is_sub ) { 
  1413. $header_box_opening = false; 
  1414.  
  1415. // close box inside 
  1416. echo '</div>' . "\n\n"; 
  1417.  
  1418. // close panel box 
  1419. echo '</div>' . "\n\n"; 
  1420.  
  1421. $view_doc = ( isset( $value['view_doc'] ) ) ? $value['view_doc'] : ''; 
  1422.  
  1423. if ( ! empty( $value['id'] ) ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $value['id'] ) . '_before' ); 
  1424.  
  1425. if ( $is_box ) { 
  1426. $heading_box_id = $count_heading; 
  1427. if ( ! empty( $value['id'] ) ) { 
  1428. $heading_box_id = $value['id']; 
  1429.  
  1430. $toggle_box_class = 'enable_toggle_box_save'; 
  1431.  
  1432. $opened_class = ''; 
  1433. if ( in_array( $heading_box_id, $opened_box ) && 1 == $toggle_box_open ) { 
  1434. $opened_class = 'box_open'; 
  1435.  
  1436. if ( isset( $_POST['bt_save_settings']) && in_array( $heading_box_id, $opened_box ) ) { 
  1437. $opened_class = 'box_open'; 
  1438.  
  1439. // Change to open box for the heading set alway_open = true 
  1440. if ( isset( $value['alway_open'] ) && true == $value['alway_open'] ) { 
  1441. $opened_class = 'box_open'; 
  1442.  
  1443. // Change to close box for the heading set alway_close = true 
  1444. if ( isset( $value['alway_close'] ) && true == $value['alway_close'] ) { 
  1445. $opened_class = ''; 
  1446.  
  1447. // Make the box open on first load with this argument first_open = true 
  1448. if ( isset( $value['first_open'] ) && true == $value['first_open'] ) { 
  1449. $this_box_is_opened = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', true ); 
  1450. if ( empty( $this_box_is_opened ) ) { 
  1451. $opened_class = 'box_open'; 
  1452. add_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', 1 ); 
  1453.  
  1454. $box_handle_class = ''; 
  1455. if ( isset( $value['is_active'] ) && true == $value['is_active'] ) { 
  1456. $box_handle_class .= 'box_active'; 
  1457.  
  1458. if ( isset( $_GET['box_open'] ) && $_GET['box_open'] == $value['id'] ) { 
  1459. $opened_class = 'box_open'; 
  1460.  
  1461. // open panel box 
  1462. echo '<div id="'. esc_attr( $value['id'] ) . '" class="a3rev_panel_box '. esc_attr( $value['class'] ) .'" style="'. esc_attr( $value['css'] ) .'">' . "\n\n"; 
  1463.  
  1464. // open box handle 
  1465. echo '<div data-form-key="'. esc_attr( trim( $form_key ) ) .'" data-box-id="'. esc_attr( $heading_box_id ) .'" class="a3rev_panel_box_handle ' . $box_handle_class .'" >' . "\n\n"; 
  1466.  
  1467. echo ( ! empty( $value['name'] ) ) ? '<h3 class="a3-plugin-ui-panel-box '. $toggle_box_class . ' ' . $opened_class . '">'. esc_html( $value['name'] ) .' '. $view_doc .'</h3>' : ''; 
  1468.  
  1469. if ( stristr( $value['class'], 'pro_feature_fields' ) !== false && ! empty( $value['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $value['id'] ) ); 
  1470. elseif ( stristr( $value['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  1471.  
  1472. // close box handle 
  1473. echo '</div>' . "\n\n"; 
  1474.  
  1475. // open box inside 
  1476. echo '<div id="'. esc_attr( $value['id'] ) . '_box_inside" class="a3rev_panel_box_inside '.$opened_class.'" >' . "\n\n"; 
  1477.  
  1478. echo '<div class="a3rev_panel_inner">' . "\n\n"; 
  1479.  
  1480. if ( $is_sub ) { 
  1481. // Mark this heading as a sub box is openning to check for close it on next header box 
  1482. $header_sub_box_opening = true; 
  1483. } else { 
  1484. // Mark this heading as a box is openning to check for close it on next header box 
  1485. $header_box_opening = true; 
  1486.  
  1487. } else { 
  1488. echo '<div id="'. esc_attr( $value['id'] ) . '" class="a3rev_panel_inner '. esc_attr( $value['class'] ) .'" style="'. esc_attr( $value['css'] ) .'">' . "\n\n"; 
  1489. if ( stristr( $value['class'], 'pro_feature_fields' ) !== false && ! empty( $value['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $value['id'] ) ); 
  1490. elseif ( stristr( $value['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  1491.  
  1492. echo ( ! empty( $value['name'] ) ) ? '<h3>'. esc_html( $value['name'] ) .' '. $view_doc .'</h3>' : ''; 
  1493.  
  1494. if ( ! empty( $value['desc'] ) ) { 
  1495. echo '<div class="a3rev_panel_box_description" >' . "\n\n"; 
  1496. echo wpautop( wptexturize( $value['desc'] ) ); 
  1497. echo '</div>' . "\n\n"; 
  1498.  
  1499. $closed_panel_inner = false; 
  1500.  
  1501. echo '<table class="form-table">' . "\n\n"; 
  1502.  
  1503. if ( ! empty( $value['id'] ) ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $value['id'] ) . '_start' ); 
  1504. break; 
  1505.  
  1506. // Google API Key input 
  1507. case 'google_api_key': 
  1508.  
  1509. $google_api_key = $this->settings_get_option( $this->google_api_key_option ); 
  1510. $google_api_key_enable = $this->settings_get_option( $this->google_api_key_option . '_enable', 0 ); 
  1511. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woocommerce-compare-products' ); 
  1512. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woocommerce-compare-products' ); 
  1513.  
  1514. ?><tr valign="top"> 
  1515. <th scope="row" class="titledesc"> 
  1516. <?php echo $tip; ?> 
  1517. <label for="<?php echo $this->google_api_key_option; ?>"><?php echo __( 'Google Fonts API', 'woocommerce-compare-products' ); ?></label> 
  1518. </th> 
  1519. <td class="forminp forminp-onoff_checkbox forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1520. <input 
  1521. name="<?php echo $this->google_api_key_option; ?>_enable" 
  1522. id="<?php echo $this->google_api_key_option; ?>_enable" 
  1523. class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_google_api_key_enable" 
  1524. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1525. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1526. type="checkbox" 
  1527. value="1" 
  1528. <?php checked( $google_api_key_enable, 1 ); ?> 
  1529. /> <span class="description" style="margin-left:5px;"><?php echo __( 'ON to connect to Google Fonts API and have auto font updates direct from Google.', 'woocommerce-compare-products' ); ?></span> 
  1530.  
  1531. <div> </div> 
  1532. <div class="a3rev-ui-google-api-key-container" style="<?php if( 1 != $google_api_key_enable ) { echo 'display: none;'; } ?>"> 
  1533. <div class="a3rev-ui-google-api-key-description"><?php echo sprintf( __( "Enter your existing Google Fonts API Key below. Don't have a key? Visit <a href='%s' target='_blank'>Google Developer API</a> to create a key", 'woocommerce-compare-products' ), 'https://developers.google.com/fonts/docs/developer_api#APIKey' ); ?></div> 
  1534. <div class="a3rev-ui-google-api-key-inside  
  1535. <?php 
  1536. if ( $wc_compare_fonts_face->is_valid_google_api_key() ) { 
  1537. echo 'a3rev-ui-google-valid-key'; 
  1538. } elseif ( '' != $google_api_key ) { 
  1539. echo 'a3rev-ui-google-unvalid-key'; 
  1540. ?> 
  1541. "> 
  1542. <input 
  1543. name="<?php echo $this->google_api_key_option; ?>" 
  1544. id="<?php echo $this->google_api_key_option; ?>" 
  1545. type="text" 
  1546. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1547. value="<?php echo esc_attr( $google_api_key ); ?>" 
  1548. class="a3rev-ui-text a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1549. placeholder="<?php echo __( 'Google Fonts API Key', 'woocommerce-compare-products' ); ?>" 
  1550. <?php echo implode( ' ', $custom_attributes ); ?> 
  1551. /> 
  1552. <p class="a3rev-ui-google-valid-key-message"><?php echo __( 'Your Google API Key is valid and automatic font updates are enabled.', 'woocommerce-compare-products' ); ?></p> 
  1553. <p class="a3rev-ui-google-unvalid-key-message"><?php echo __( 'Please enter a valid Google API Key.', 'woocommerce-compare-products' ); ?></p> 
  1554. </div> 
  1555. </div> 
  1556. </td> 
  1557. </tr><?php 
  1558.  
  1559. break; 
  1560.  
  1561. // Manual Check New Version when click on the button instead of wait for daily 
  1562. case 'manual_check_version': 
  1563. $version_message = $this->get_version_message(); 
  1564. $new_version_class = ''; 
  1565. if ( '' != trim( $version_message ) ) { 
  1566. $new_version_class = 'a3rev-ui-new-version-message'; 
  1567.  
  1568. ?><tr valign="top"> 
  1569. <th scope="row" class="titledesc"> 
  1570. <?php echo $tip; ?> 
  1571. <label><?php echo __( 'Check New Version', 'woocommerce-compare-products' ); ?></label> 
  1572. </th> 
  1573. <td class="forminp forminp-manual_check_version"> 
  1574. <?php echo $description; ?> 
  1575.  
  1576. <input 
  1577. data-transient-name="<?php echo $this->version_transient; ?>" 
  1578. name="<?php echo $this->plugin_name . '-check-version'; ?>" 
  1579. id="<?php echo $this->plugin_name . '-check-version'; ?>" 
  1580. class="button button-primary a3rev-ui-manual_check_version" 
  1581. type="button" 
  1582. value="<?php echo __( 'Check Now', 'woocommerce-compare-products' ); ?>" 
  1583. /> <span class="a3rev-ui-version-checking"> </span> 
  1584. <p class="a3rev-ui-check-version-message <?php echo $new_version_class; ?>"><?php echo $version_message; ?></p> 
  1585.  
  1586. </td> 
  1587. </tr><?php 
  1588.  
  1589. break; 
  1590.  
  1591. // Ajax Submit type 
  1592. case 'ajax_submit' : 
  1593. $button_name = $value['button_name']; 
  1594. $progressing_text = $value['progressing_text']; 
  1595. $completed_text = $value['completed_text']; 
  1596. $successed_text = $value['successed_text']; 
  1597. $submit_data = json_encode( $value['submit_data'] ); 
  1598.  
  1599. ?><tr valign="top"> 
  1600. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  1601. <td class="forminp"> 
  1602.  
  1603. <div class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-control"> 
  1604.  
  1605. <button 
  1606. name="<?php echo $name_attribute; ?>" 
  1607. id="<?php echo $id_attribute; ?>" 
  1608. data-submit_data="<?php echo esc_attr( $submit_data ); ?>" 
  1609. type="button" 
  1610. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-button <?php echo esc_attr( $value['class'] ); ?>" 
  1611. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1612. <?php echo implode( ' ', $custom_attributes ); ?> 
  1613. ><?php echo $button_name; ?></button> 
  1614. <span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-successed"><?php echo $successed_text; ?></span> 
  1615. <span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-errors"></span> 
  1616.  
  1617. <!-- Progress Bar --> 
  1618. <div class="a3rev-ui-progress-bar-wrap"> 
  1619. <div class="a3rev-ui-progress-inner"></div> 
  1620. <div class="a3rev-ui-progressing-text"><?php echo $progressing_text; ?></div> 
  1621. <div class="a3rev-ui-completed-text"><?php echo $completed_text; ?></div> 
  1622. </div> 
  1623.  
  1624. </div> 
  1625. <?php echo $description; ?> 
  1626. </td> 
  1627. </tr><?php 
  1628.  
  1629. break; 
  1630.  
  1631. // Ajax Multi Submit type 
  1632. case 'ajax_multi_submit' : 
  1633. $resubmit = $value['resubmit']; 
  1634. $button_name = $value['button_name']; 
  1635. $progressing_text = $value['progressing_text']; 
  1636. $completed_text = $value['completed_text']; 
  1637. $successed_text = $value['successed_text']; 
  1638. $statistic_column = isset( $value['statistic_column'] ) ? $value['statistic_column'] : 1; 
  1639.  
  1640. $multi_current_items = 0; 
  1641. $multi_total_items = 0; 
  1642.  
  1643. $multi_submit = $value['multi_submit']; 
  1644. $multi_ajax = array(); 
  1645. if ( is_array( $multi_submit ) && count( $multi_submit ) > 0 ) { 
  1646. $number_ajax = 0; 
  1647. $old_item_id = ''; 
  1648. foreach ( $multi_submit as $single_submit ) { 
  1649. $multi_current_items += (int) $single_submit['current_items']; 
  1650. $multi_total_items += (int) $single_submit['total_items']; 
  1651.  
  1652. $single_submit['next_item_id'] = ''; 
  1653. $multi_ajax[$single_submit['item_id']] = $single_submit; 
  1654.  
  1655. if ( $number_ajax > 0 ) { 
  1656. $multi_ajax[$old_item_id]['next_item_id'] = $single_submit['item_id']; 
  1657. $old_item_id = $single_submit['item_id']; 
  1658.  
  1659. $number_ajax++; 
  1660. $multi_ajax = json_encode( $multi_ajax ); 
  1661.  
  1662. ?><tr valign="top"> 
  1663. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  1664. <td class="forminp"> 
  1665.  
  1666. <div class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-control"> 
  1667. <?php echo $description; ?> 
  1668. <button 
  1669. data-resubmit="<?php echo $resubmit ? 1 : 0 ; ?>" 
  1670. name="<?php echo $name_attribute; ?>" 
  1671. id="<?php echo $id_attribute; ?>" 
  1672. data-multi_ajax="<?php echo esc_attr( $multi_ajax ); ?>" 
  1673. type="button" 
  1674. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-button <?php echo esc_attr( $value['class'] ); ?>" 
  1675. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1676. <?php echo implode( ' ', $custom_attributes ); ?> 
  1677. ><?php echo $button_name; ?></button> 
  1678. <span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-successed"><?php echo $successed_text; ?></span> 
  1679. <span class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-errors"></span> 
  1680.  
  1681. <!-- Progress Bar --> 
  1682. <div class="a3rev-ui-progress-bar-wrap"> 
  1683. <div class="a3rev-ui-progress-inner" data-current="<?php echo $multi_current_items; ?>" data-total="<?php echo $multi_total_items; ?>" ></div> 
  1684. <div class="a3rev-ui-progressing-text"><?php echo $progressing_text; ?></div> 
  1685. <div class="a3rev-ui-completed-text"><?php echo $completed_text; ?></div> 
  1686. </div> 
  1687. <div style="clear: both;"></div> 
  1688.  
  1689. <!-- Status Object --> 
  1690. <div class="a3rev-ui-statistics-wrap"> 
  1691. <?php if ( $multi_total_items > 0 ) { 
  1692. $column_width = round( (100 / $statistic_column ), 2, PHP_ROUND_HALF_DOWN ); 
  1693. foreach ( $multi_submit as $single_submit ) { 
  1694.  
  1695. $current_items = (int) $single_submit['current_items']; 
  1696. $total_items = (int) $single_submit['total_items']; 
  1697.  
  1698. // Calculate deg value for cirlce 
  1699. $current_deg = 360; 
  1700. $left_deg = 360; 
  1701. $right_deg = 180; 
  1702. $pie_class = 'pie-more-50'; 
  1703. if ( $current_items < $total_items ) { 
  1704. $current_deg = round( ( $current_items / $total_items ) * 360 ); 
  1705. if ( $current_deg <= 180 ) { 
  1706. $left_deg = $right_deg = $current_deg; 
  1707. $pie_class = ''; 
  1708. } else { 
  1709. $right_deg = 180; 
  1710. $left_deg = $current_deg; 
  1711.  
  1712. $statistic_customizer = isset ( $single_submit['statistic_customizer'] ) ? $single_submit['statistic_customizer'] : false; 
  1713. if ( $statistic_customizer ) { 
  1714. $current_color = isset( $statistic_customizer['current_color'] ) ? $statistic_customizer['current_color'] : ''; 
  1715. ?> 
  1716. <div style="<?php echo ( isset( $single_submit['show_statistic'] ) && ! $single_submit['show_statistic'] ) ? 'display:none;' : ''; ?> width: <?php echo $column_width; ?>%;" class="a3rev-ui-statistic-item a3rev-ui-statistic-<?php echo esc_attr( $single_submit['item_id'] ); ?>"> 
  1717. <div class="a3rev-ui-pie-wrap"> 
  1718. <div class="a3rev-ui-pie <?php echo esc_attr( $pie_class); ?>"> 
  1719. <div class="a3rev-ui-pie-left-side a3rev-ui-pie-half-circle" style="transform: rotate(<?php echo $left_deg; ?>deg); <?php echo ( ! empty( $current_color ) ? 'border-color:' . $current_color : '' ); ?>"></div> 
  1720. <div class="a3rev-ui-pie-right-side a3rev-ui-pie-half-circle" style="transform: rotate(<?php echo $right_deg; ?>deg); <?php echo ( ! empty( $current_color ) ? 'border-color:' . $current_color : '' ); ?>"></div> 
  1721. </div> 
  1722. <div class="a3rev-ui-pie-shadow"></div> 
  1723. </div> 
  1724. <div class="a3rev-ui-statistic-text"> 
  1725. <span class="a3rev-ui-statistic-current-item" data-current="<?php echo $current_items; ?>" ><?php echo $current_items; ?></span> 
  1726. <span class="a3rev-ui-statistic-separate">/</span> 
  1727. <span class="a3rev-ui-statistic-total-item"><?php echo $total_items; ?></span> 
  1728. <br /> 
  1729. <span class="a3rev-ui-statistic-item-name"><?php echo $single_submit['item_name']; ?></span> 
  1730. </div> 
  1731. </div> 
  1732. <?php 
  1733. } ?> 
  1734. </div> 
  1735. <div style="clear: both;"></div> 
  1736. </div> 
  1737. </td> 
  1738. </tr><?php 
  1739.  
  1740. break; 
  1741.  
  1742. // Toggle Box Open type 
  1743. case 'onoff_toggle_box' : 
  1744.  
  1745. $option_value = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  1746. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woocommerce-compare-products' ); 
  1747. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woocommerce-compare-products' ); 
  1748.  
  1749. ?><tr valign="top"> 
  1750. <th scope="row" class="titledesc"> 
  1751. <?php echo $tip; ?> 
  1752. <label for="<?php echo $this->toggle_box_open_option; ?>"><?php echo __( 'Open Box Display', 'woocommerce-compare-products' ); ?></label> 
  1753. </th> 
  1754. <td class="forminp forminp-onoff_checkbox forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1755. <input 
  1756. name="<?php echo $this->toggle_box_open_option; ?>" 
  1757. id="<?php echo $this->toggle_box_open_option; ?>" 
  1758. class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_toggle_box <?php echo esc_attr( $value['class'] ); ?>" 
  1759. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1760. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1761. type="checkbox" 
  1762. value="1" 
  1763. <?php checked( $option_value, 1 ); ?> 
  1764. <?php echo implode( ' ', $custom_attributes ); ?> 
  1765. /> <span class="description" style="margin-left:5px;"><?php echo __( 'ON and each admin panel setting box OPEN | CLOSED position are saved each time changes are SAVED.', 'woocommerce-compare-products' ); ?></span> 
  1766. </td> 
  1767. </tr><?php 
  1768. break; 
  1769.  
  1770. // Standard text inputs and subtypes like 'number' 
  1771. case 'text': 
  1772. case 'email': 
  1773. case 'number': 
  1774. case 'password' : 
  1775.  
  1776. $type = $value['type']; 
  1777.  
  1778. ?><tr valign="top"> 
  1779. <th scope="row" class="titledesc"> 
  1780. <?php echo $tip; ?> 
  1781. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1782. </th> 
  1783. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1784. <input 
  1785. name="<?php echo $name_attribute; ?>" 
  1786. id="<?php echo $id_attribute; ?>" 
  1787. type="<?php echo esc_attr( $type ); ?>" 
  1788. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1789. value="<?php echo esc_attr( $option_value ); ?>" 
  1790. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1791. placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" 
  1792. <?php echo implode( ' ', $custom_attributes ); ?> 
  1793. /> <?php echo $description; ?> 
  1794. </td> 
  1795. </tr><?php 
  1796. break; 
  1797.  
  1798. // Color 
  1799. case 'color' : 
  1800.  
  1801. if ( trim( $value['default'] ) == '' ) $value['default'] = '#515151'; 
  1802. $default_color = ' data-default-color="' . esc_attr( $value['default'] ) . '"'; 
  1803. if ( '' == trim( $option_value ) ) $option_value = 'transparent'; 
  1804.  
  1805. ?><tr valign="top"> 
  1806. <th scope="row" class="titledesc"> 
  1807. <?php echo $tip; ?> 
  1808. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1809. </th> 
  1810. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1811. <input 
  1812. name="<?php echo $name_attribute; ?>" 
  1813. id="<?php echo $id_attribute; ?>" 
  1814. type="text" 
  1815. value="<?php echo esc_attr( $option_value ); ?>" 
  1816. class="a3rev-color-picker" 
  1817. <?php echo $default_color; ?> 
  1818. /> <?php echo $description; ?> 
  1819. </td> 
  1820. </tr><?php 
  1821.  
  1822. break; 
  1823.  
  1824. // Background Color 
  1825. case 'bg_color' : 
  1826.  
  1827. if ( ! isset( $option_value['enable'] ) ) $option_value['enable'] = 0; 
  1828. $enable = $option_value['enable']; 
  1829.  
  1830. if ( trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1831. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  1832.  
  1833. $color = $option_value['color']; 
  1834. if ( '' == trim( $color ) ) $color = 'transparent'; 
  1835.  
  1836. ?><tr valign="top"> 
  1837. <th scope="row" class="titledesc"> 
  1838. <?php echo $tip; ?> 
  1839. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1840. </th> 
  1841. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1842. <input 
  1843. name="<?php echo $name_attribute; ?>[enable]" 
  1844. id="<?php echo $id_attribute; ?>" 
  1845. class="a3rev-ui-bg_color-enable a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  1846. checked_label="<?php _e( 'ON', 'woocommerce-compare-products' ); ?>" 
  1847. unchecked_label="<?php _e( 'OFF', 'woocommerce-compare-products' ); ?>" 
  1848. type="checkbox" 
  1849. value="1" 
  1850. <?php checked( 1, $enable ); ?> 
  1851. <?php echo implode( ' ', $custom_attributes ); ?> 
  1852. /> <?php echo $description; ?> 
  1853. <div style="clear:both;"></div> 
  1854. <div class="a3rev-ui-bg_color-enable-container"> 
  1855. <input 
  1856. name="<?php echo $name_attribute; ?>[color]" 
  1857. id="<?php echo $id_attribute; ?>-color" 
  1858. type="text" 
  1859. value="<?php echo esc_attr( $color ); ?>" 
  1860. class="a3rev-color-picker" 
  1861. <?php echo $default_color; ?> 
  1862. /> 
  1863. </div> 
  1864. </td> 
  1865. </tr><?php 
  1866.  
  1867. break; 
  1868.  
  1869. // Textarea 
  1870. case 'textarea': 
  1871.  
  1872. ?><tr valign="top"> 
  1873. <th scope="row" class="titledesc"> 
  1874. <?php echo $tip; ?> 
  1875. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1876. </th> 
  1877. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1878. <?php echo $description; ?> 
  1879.  
  1880. <textarea 
  1881. name="<?php echo $name_attribute; ?>" 
  1882. id="<?php echo $id_attribute; ?>" 
  1883. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1884. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1885. placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" 
  1886. <?php echo implode( ' ', $custom_attributes ); ?> 
  1887. ><?php echo esc_textarea( $option_value ); ?></textarea> 
  1888. </td> 
  1889. </tr><?php 
  1890. break; 
  1891.  
  1892. // Select boxes 
  1893. case 'select' : 
  1894. case 'multiselect' : 
  1895.  
  1896. if ( trim( $value['class'] ) == '' ) $value['class'] = 'chzn-select'; 
  1897. if ( is_rtl() ) { 
  1898. $value['class'] .= ' chzn-rtl'; 
  1899. if ( ! isset( $value['options'] ) ) $value['options'] = array(); 
  1900.  
  1901. ?><tr valign="top"> 
  1902. <th scope="row" class="titledesc"> 
  1903. <?php echo $tip; ?> 
  1904. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1905. </th> 
  1906. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1907. <select 
  1908. name="<?php echo $name_attribute; ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" 
  1909. id="<?php echo $id_attribute; ?>" 
  1910. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1911. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1912. data-placeholder="<?php echo esc_html( $value['placeholder'] ); ?>" 
  1913. <?php echo implode( ' ', $custom_attributes ); ?> 
  1914. <?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?> 
  1915. <?php 
  1916. if ( is_array( $value['options'] ) && count( $value['options'] ) > 0 ) { 
  1917. foreach ( $value['options'] as $key => $val ) { 
  1918. if ( is_array( $val ) ) { 
  1919. ?> 
  1920. <optgroup label="<?php echo esc_attr( $key ); ?>"> 
  1921. <?php 
  1922. foreach ( $val as $sub_key => $sub_val ) { 
  1923. ?> 
  1924. <option value="<?php echo esc_attr( $sub_key ); ?>" <?php 
  1925.  
  1926. if ( is_array( $option_value ) ) 
  1927. selected( in_array( $sub_key, $option_value ), true ); 
  1928. else 
  1929. selected( $option_value, $sub_key ); 
  1930.  
  1931. ?>><?php echo $sub_val ?></option> 
  1932. <?php 
  1933. ?> 
  1934. </optgroup> 
  1935. <?php 
  1936. } else { 
  1937. ?> 
  1938. <option value="<?php echo esc_attr( $key ); ?>" <?php 
  1939.  
  1940. if ( is_array( $option_value ) ) 
  1941. selected( in_array( $key, $option_value ), true ); 
  1942. else 
  1943. selected( $option_value, $key ); 
  1944.  
  1945. ?>><?php echo $val ?></option> 
  1946. <?php 
  1947. ?> 
  1948. </select> <?php echo $description; ?> 
  1949. </td> 
  1950. </tr><?php 
  1951. break; 
  1952.  
  1953. // Radio inputs 
  1954. case 'radio' : 
  1955.  
  1956. if ( ! isset( $value['options'] ) ) $value['options'] = array(); 
  1957.  
  1958. ?><tr valign="top"> 
  1959. <th scope="row" class="titledesc"> 
  1960. <?php echo $tip; ?> 
  1961. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1962. </th> 
  1963. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1964. <fieldset> 
  1965. <?php echo $description; ?> 
  1966. <ul> 
  1967. <?php 
  1968. if ( is_array( $value['options'] ) && count( $value['options'] ) > 0 ) { 
  1969. foreach ( $value['options'] as $val => $text ) { 
  1970. ?> 
  1971. <li> 
  1972. <label><input 
  1973. name="<?php echo $name_attribute; ?>" 
  1974. value="<?php echo $val; ?>" 
  1975. type="radio" 
  1976. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1977. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1978. <?php echo implode( ' ', $custom_attributes ); ?> 
  1979. <?php checked( $val, $option_value ); ?> 
  1980. /> <span class="description" style="margin-left:5px;"><?php echo $text ?></span></label> 
  1981. </li> 
  1982. <?php 
  1983. ?> 
  1984. </ul> 
  1985. </fieldset> 
  1986. </td> 
  1987. </tr><?php 
  1988. break; 
  1989.  
  1990. // OnOff Radio inputs 
  1991. case 'onoff_radio' : 
  1992.  
  1993. if ( ! isset( $value['onoff_options'] ) ) $value['onoff_options'] = array(); 
  1994.  
  1995. ?><tr valign="top"> 
  1996. <th scope="row" class="titledesc"> 
  1997. <?php echo $tip; ?> 
  1998. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1999. </th> 
  2000. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2001. <fieldset> 
  2002. <?php echo $description; ?> 
  2003. <ul> 
  2004. <?php 
  2005. if ( is_array( $value['onoff_options'] ) && count( $value['onoff_options'] ) > 0 ) { 
  2006. foreach ( $value['onoff_options'] as $i_option ) { 
  2007. if ( ! isset( $i_option['checked_label'] ) ) $i_option['checked_label'] = __( 'ON', 'woocommerce-compare-products' ); 
  2008. if ( ! isset( $i_option['unchecked_label'] ) ) $i_option['unchecked_label'] = __( 'OFF', 'woocommerce-compare-products' ); 
  2009. if ( ! isset( $i_option['val'] ) ) $i_option['val'] = 1; 
  2010. if ( ! isset( $i_option['text'] ) ) $i_option['text'] = ''; 
  2011. ?> 
  2012. <li> 
  2013. <input 
  2014. name="<?php echo $name_attribute; ?>" 
  2015. <?php if ( $i_option['val'] == $option_value ) echo ' checkbox-disabled="true" ' ; ?> 
  2016. class="a3rev-ui-onoff_radio <?php echo esc_attr( $value['class'] ); ?>" 
  2017. checked_label="<?php echo esc_html( $i_option['checked_label'] ); ?>" 
  2018. unchecked_label="<?php echo esc_html( $i_option['unchecked_label'] ); ?>" 
  2019. type="radio" 
  2020. value="<?php echo esc_attr( stripslashes( $i_option['val'] ) ); ?>" 
  2021. <?php checked( esc_attr( stripslashes( $i_option['val'] ) ), $option_value ); ?> 
  2022. <?php echo implode( ' ', $custom_attributes ); ?> 
  2023. /> <span class="description" style="margin-left:5px;"><?php echo $i_option['text'] ?></span> 
  2024. </li> 
  2025. <?php 
  2026. ?> 
  2027. </ul> 
  2028. </fieldset> 
  2029. </td> 
  2030. </tr><?php 
  2031. break; 
  2032.  
  2033. // Checkbox input 
  2034. case 'checkbox' : 
  2035.  
  2036. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  2037. if ( ! isset( $value['hide_if_checked'] ) ) $value['hide_if_checked'] = false; 
  2038. if ( ! isset( $value['show_if_checked'] ) ) $value['show_if_checked'] = false; 
  2039.  
  2040. if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'start' ) ) { 
  2041. ?> 
  2042. <tr valign="top" class="<?php 
  2043. if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked']=='yes') echo 'hidden_option'; 
  2044. if ( $value['hide_if_checked'] == 'option' ) echo 'hide_options_if_checked'; 
  2045. if ( $value['show_if_checked'] == 'option' ) echo 'show_options_if_checked'; 
  2046. ?>"> 
  2047. <th scope="row" class="titledesc"> 
  2048. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2049. </th> 
  2050. <td class="forminp forminp-checkbox"> 
  2051. <fieldset> 
  2052. <?php 
  2053. } else { 
  2054. ?> 
  2055. <fieldset class="<?php 
  2056. if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') echo 'hidden_option'; 
  2057. if ( $value['hide_if_checked'] == 'option') echo 'hide_options_if_checked'; 
  2058. if ( $value['show_if_checked'] == 'option') echo 'show_options_if_checked'; 
  2059. ?>"> 
  2060. <?php 
  2061.  
  2062. ?> 
  2063. <legend class="screen-reader-text"><span><?php echo esc_html( $value['name'] ) ?></span></legend> 
  2064.  
  2065. <label for="<?php echo $id_attribute; ?>"> 
  2066. <input 
  2067. name="<?php echo $name_attribute; ?>" 
  2068. id="<?php echo $id_attribute; ?>" 
  2069. type="checkbox" 
  2070. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  2071. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  2072. <?php echo implode( ' ', $custom_attributes ); ?> 
  2073. /> <?php echo $description; ?></label> <?php echo $tip; ?> 
  2074. <?php 
  2075.  
  2076. if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'end' ) ) { 
  2077. ?> 
  2078. </fieldset> 
  2079. </td> 
  2080. </tr> 
  2081. <?php 
  2082. } else { 
  2083. ?> 
  2084. </fieldset> 
  2085. <?php 
  2086.  
  2087. break; 
  2088.  
  2089. // OnOff Checkbox input 
  2090. case 'onoff_checkbox' : 
  2091.  
  2092. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  2093. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woocommerce-compare-products' ); 
  2094. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woocommerce-compare-products' ); 
  2095.  
  2096. ?><tr valign="top"> 
  2097. <th scope="row" class="titledesc"> 
  2098. <?php echo $tip; ?> 
  2099. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2100. </th> 
  2101. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2102. <input 
  2103. name="<?php echo $name_attribute; ?>" 
  2104. id="<?php echo $id_attribute; ?>" 
  2105. class="a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2106. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  2107. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  2108. type="checkbox" 
  2109. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  2110. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  2111. <?php echo implode( ' ', $custom_attributes ); ?> 
  2112. /> <?php echo $description; ?> 
  2113. </td> 
  2114. </tr><?php 
  2115.  
  2116. break; 
  2117.  
  2118. // Switcher Checkbox input 
  2119. case 'switcher_checkbox' : 
  2120.  
  2121. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  2122. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woocommerce-compare-products' ); 
  2123. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woocommerce-compare-products' ); 
  2124.  
  2125. ?><tr valign="top"> 
  2126. <th scope="row" class="titledesc"> 
  2127. <?php echo $tip; ?> 
  2128. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2129. </th> 
  2130. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2131. <input 
  2132. name="<?php echo $name_attribute; ?>" 
  2133. id="<?php echo $id_attribute; ?>" 
  2134. class="a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2135. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  2136. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  2137. type="checkbox" 
  2138. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  2139. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  2140. <?php echo implode( ' ', $custom_attributes ); ?> 
  2141. /> <?php echo $description; ?> 
  2142. </td> 
  2143. </tr><?php 
  2144.  
  2145. break; 
  2146.  
  2147. // Image size settings 
  2148. case 'image_size' : 
  2149.  
  2150. $width = $option_value['width']; 
  2151. $height = $option_value['height']; 
  2152. $crop = checked( 1, $option_value['crop'], false ); 
  2153.  
  2154. ?><tr valign="top"> 
  2155. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2156. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2157.  
  2158. <label><?php _e( 'Width', 'woocommerce-compare-products' ); ?> <input name="<?php echo $name_attribute; ?>[width]" id="<?php echo $id_attribute; ?>-width" type="text" class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-width" value="<?php echo $width; ?>" /></label> 
  2159.  
  2160. <label><?php _e( 'Height', 'woocommerce-compare-products' ); ?> <input name="<?php echo $name_attribute; ?>[height]" id="<?php echo $id_attribute; ?>-height" type="text" class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-height" value="<?php echo $height; ?>" /></label> 
  2161.  
  2162. <label><?php _e( 'Hard Crop', 'woocommerce-compare-products' ); ?> <input name="<?php echo $name_attribute; ?>[crop]" id="<?php echo $id_attribute; ?>-crop" type="checkbox" class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-crop" <?php echo $crop; ?> /></label> 
  2163.  
  2164. </td> 
  2165. </tr><?php 
  2166. break; 
  2167.  
  2168. // Single page selects 
  2169. case 'single_select_page' : 
  2170.  
  2171. if ( trim( $value['class'] ) == '' ) $value['class'] = 'chzn-select-deselect'; 
  2172. if ( is_rtl() ) { 
  2173. $value['class'] .= ' chzn-rtl'; 
  2174.  
  2175. $args = array( 'name' => $name_attribute,  
  2176. 'id' => $id_attribute,  
  2177. 'sort_column' => 'menu_order',  
  2178. 'sort_order' => 'ASC',  
  2179. 'show_option_none' => ' ',  
  2180. 'class' => 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . $value['class'],  
  2181. 'echo' => false,  
  2182. 'selected' => absint( $option_value ) 
  2183. ); 
  2184.  
  2185. if( isset( $value['args'] ) ) 
  2186. $args = wp_parse_args( $value['args'], $args ); 
  2187.  
  2188. ?><tr valign="top"> 
  2189. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2190. <td class="forminp"> 
  2191. <?php echo str_replace(' id=', " data-placeholder='" . esc_html( $value['placeholder'] ) . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages( $args ) ); ?> <?php echo $description; ?> 
  2192. </td> 
  2193. </tr><?php 
  2194. break; 
  2195.  
  2196. // Font Control 
  2197. case 'typography': 
  2198.  
  2199. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2200.  
  2201. if ( ! isset( $option_value['line_height'] ) ) { 
  2202. $option_value['line_height'] = '1.4em'; 
  2203.  
  2204. $size = $option_value['size']; 
  2205. $line_height = $option_value['line_height']; 
  2206. $face = $option_value['face']; 
  2207. $style = $option_value['style']; 
  2208. $color = $option_value['color']; 
  2209.  
  2210. ?><tr valign="top"> 
  2211. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2212. <td class="forminp"> 
  2213. <?php echo $description; ?> 
  2214. <div class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-control"> 
  2215. <!-- Font Size --> 
  2216. <select 
  2217. name="<?php echo $name_attribute; ?>[size]" 
  2218. id="<?php echo $id_attribute; ?>-size" 
  2219. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-size chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2220. <?php 
  2221. for ( $i = 6; $i <= 70; $i++ ) { 
  2222. ?> 
  2223. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2224. selected( $size, $i.'px' ); 
  2225. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2226. <?php 
  2227. ?> 
  2228. </select> 
  2229. <!-- Line Height --> 
  2230. <select 
  2231. name="<?php echo $name_attribute; ?>[line_height]" 
  2232. id="<?php echo $id_attribute; ?>-line_height" 
  2233. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-line_height chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2234. <?php 
  2235. for ( $i = 0.6; $i <= 3.1; $i = $i + 0.1 ) { 
  2236. ?> 
  2237. <option value="<?php echo esc_attr( $i ); ?>em" <?php 
  2238. selected( $line_height, $i.'em' ); 
  2239. ?>><?php echo esc_attr( $i ); ?>em</option> 
  2240. <?php 
  2241. ?> 
  2242. </select> 
  2243. <!-- Font Face --> 
  2244. <select 
  2245. name="<?php echo $name_attribute; ?>[face]" 
  2246. id="<?php echo $id_attribute; ?>-face" 
  2247. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-face chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2248. <optgroup label="<?php _e( '-- Default Fonts --', 'woocommerce-compare-products' ); ?>"> 
  2249. <?php 
  2250. foreach ( $wc_compare_fonts_face->get_default_fonts() as $val => $text ) { 
  2251. ?> 
  2252. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2253. selected( esc_attr( $val ), esc_attr( $face ) ); 
  2254. ?>><?php echo esc_attr( $text ); ?></option> 
  2255. <?php 
  2256. ?> 
  2257. </optgroup> 
  2258. <optgroup label="<?php _e( '-- Google Fonts --', 'woocommerce-compare-products' ); ?>"> 
  2259. <?php 
  2260. foreach ( $wc_compare_fonts_face->get_google_fonts() as $font ) { 
  2261. ?> 
  2262. <option value="<?php echo esc_attr( $font['name'] ); ?>" <?php 
  2263. selected( esc_attr( $font['name'] ), esc_attr( $face ) ); 
  2264. ?>><?php echo esc_attr( $font['name'] ); ?></option> 
  2265. <?php 
  2266. ?> 
  2267. </optgroup> 
  2268. </select>  
  2269.  
  2270. <!-- Font Weight --> 
  2271. <select 
  2272. name="<?php echo $name_attribute; ?>[style]" 
  2273. id="<?php echo $id_attribute; ?>-style" 
  2274. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2275. <?php 
  2276. foreach ( $this->get_font_weights() as $val => $text ) { 
  2277. ?> 
  2278. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2279. selected( esc_attr( $val ), esc_attr( $style ) ); 
  2280. ?>><?php echo esc_attr( $text ); ?></option> 
  2281. <?php 
  2282. ?> 
  2283. </select> 
  2284.  
  2285. <!-- Font Color --> 
  2286. <input 
  2287. name="<?php echo $name_attribute; ?>[color]" 
  2288. id="<?php echo $id_attribute; ?>-color" 
  2289. type="text" 
  2290. value="<?php echo esc_attr( $color ); ?>" 
  2291. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-color a3rev-color-picker" 
  2292. <?php echo $default_color; ?> 
  2293. />  
  2294.  
  2295. <!-- Preview Button --> 
  2296. <div class="a3rev-ui-typography-preview"><a href="#" class="a3rev-ui-typography-preview-button button submit-button" title="<?php _e( 'Preview your customized typography settings', 'woocommerce-compare-products' ); ?>"><span> </span></a></div> 
  2297.  
  2298. </div> 
  2299.  
  2300. </td> 
  2301. </tr><?php 
  2302.  
  2303. break; 
  2304.  
  2305. // Border Styles & Corner Control 
  2306. case 'border': 
  2307.  
  2308. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  2309.  
  2310. // For Border Styles 
  2311. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2312.  
  2313. $width = $option_value['width']; 
  2314. $style = $option_value['style']; 
  2315. $color = $option_value['color']; 
  2316.  
  2317. // For Border Corner 
  2318. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2319. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2320. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2321.  
  2322. if ( ! isset( $option_value['corner'] ) ) $option_value['corner'] = ''; 
  2323. $corner = $option_value['corner']; 
  2324.  
  2325. if ( ! isset( $option_value['rounded_value'] ) ) $option_value['rounded_value'] = 3; 
  2326. $rounded_value = $option_value['rounded_value']; 
  2327.  
  2328. if ( ! isset( $option_value['top_left_corner'] ) ) $option_value['top_left_corner'] = 3; 
  2329. $top_left_corner = $option_value['top_left_corner']; 
  2330.  
  2331. if ( ! isset( $option_value['top_right_corner'] ) ) $option_value['top_right_corner'] = 3; 
  2332. $top_right_corner = $option_value['top_right_corner']; 
  2333.  
  2334. if ( ! isset( $option_value['bottom_left_corner'] ) ) $option_value['bottom_left_corner'] = 3; 
  2335. $bottom_left_corner = $option_value['bottom_left_corner']; 
  2336.  
  2337. if ( ! isset( $option_value['bottom_right_corner'] ) ) $option_value['bottom_right_corner'] = 3; 
  2338. $bottom_right_corner = $option_value['bottom_right_corner']; 
  2339.  
  2340. if ( trim( $rounded_value ) == '' || trim( $rounded_value ) <= 0 ) $rounded_value = $value['min']; 
  2341. $rounded_value = intval( $rounded_value ); 
  2342.  
  2343. if ( trim( $top_left_corner ) == '' || trim( $top_left_corner ) <= 0 ) $top_left_corner = $rounded_value; 
  2344. $top_left_corner = intval( $top_left_corner ); 
  2345.  
  2346. if ( trim( $top_right_corner ) == '' || trim( $top_right_corner ) <= 0 ) $top_right_corner = $rounded_value; 
  2347. $top_right_corner = intval( $top_right_corner ); 
  2348.  
  2349. if ( trim( $bottom_left_corner ) == '' || trim( $bottom_left_corner ) <= 0 ) $bottom_left_corner = $rounded_value; 
  2350. $bottom_left_corner = intval( $bottom_left_corner ); 
  2351.  
  2352. if ( trim( $bottom_right_corner ) == '' || trim( $bottom_right_corner ) <= 0 ) $bottom_right_corner = $rounded_value; 
  2353. $bottom_right_corner = intval( $bottom_right_corner ); 
  2354.  
  2355. ?><tr valign="top"> 
  2356. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2357. <td class="forminp forminp-border_corner"> 
  2358. <?php echo $description; ?> 
  2359. <div class="a3rev-ui-settings-control"> 
  2360. <!-- Border Width --> 
  2361. <select 
  2362. name="<?php echo $name_attribute; ?>[width]" 
  2363. id="<?php echo $id_attribute; ?>-width" 
  2364. class="a3rev-ui-border_styles-width chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2365. <?php 
  2366. for ( $i = 0; $i <= 20; $i++ ) { 
  2367. ?> 
  2368. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2369. selected( $width, $i.'px' ); 
  2370. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2371. <?php 
  2372. ?> 
  2373. </select>  
  2374.  
  2375. <!-- Border Style --> 
  2376. <select 
  2377. name="<?php echo $name_attribute; ?>[style]" 
  2378. id="<?php echo $id_attribute; ?>-style" 
  2379. class="a3rev-ui-border_styles-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2380. <?php 
  2381. foreach ( $this->get_border_styles() as $val => $text ) { 
  2382. ?> 
  2383. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2384. selected( esc_attr( $val ), esc_attr( $style ) ); 
  2385. ?>><?php echo esc_attr( $text ); ?></option> 
  2386. <?php 
  2387. ?> 
  2388. </select> 
  2389.  
  2390. <!-- Border Color --> 
  2391. <input 
  2392. name="<?php echo $name_attribute; ?>[color]" 
  2393. id="<?php echo $id_attribute; ?>-color" 
  2394. type="text" 
  2395. value="<?php echo esc_attr( $color ); ?>" 
  2396. class="a3rev-ui-border_styles-color a3rev-color-picker" 
  2397. <?php echo $default_color; ?> 
  2398. /> 
  2399.  
  2400. <!-- Preview Button --> 
  2401. <div class="a3rev-ui-settings-preview"><a href="#" class="a3rev-ui-border-preview-button a3rev-ui-settings-preview-button button submit-button" title="<?php _e( 'Preview your customized border settings', 'woocommerce-compare-products' ); ?>"><span> </span></a></div> 
  2402. <span class="description" style="margin-left:5px;"><?php echo __( '0px = No Border', 'woocommerce-compare-products' ); ?></span> 
  2403. <div style="clear:both; margin-bottom:10px"></div> 
  2404.  
  2405. <!-- Border Corner : Rounded or Square --> 
  2406. <input 
  2407. name="<?php echo $name_attribute; ?>[corner]" 
  2408. id="<?php echo $id_attribute; ?>" 
  2409. class="a3rev-ui-border-corner a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2410. checked_label="<?php _e( 'Rounded', 'woocommerce-compare-products' ); ?>" 
  2411. unchecked_label="<?php _e( 'Square', 'woocommerce-compare-products' ); ?>" 
  2412. type="checkbox" 
  2413. value="rounded" 
  2414. <?php checked( 'rounded', $corner ); ?> 
  2415. <?php echo implode( ' ', $custom_attributes ); ?> 
  2416. />  
  2417.  
  2418. <!-- Border Rounded Value --> 
  2419. <div class="a3rev-ui-border-corner-value-container"> 
  2420. <div class="a3rev-ui-border_corner-top_left"> 
  2421. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Left Corner', 'woocommerce-compare-products' ); ?></span> 
  2422. <div class="a3rev-ui-slide-container"> 
  2423. <div class="a3rev-ui-slide-container-start"> 
  2424. <div class="a3rev-ui-slide-container-end"> 
  2425. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-top_left_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2426. </div> 
  2427. </div> 
  2428. <div class="a3rev-ui-slide-result-container"> 
  2429. <input 
  2430. readonly="readonly" 
  2431. name="<?php echo $name_attribute; ?>[top_left_corner]" 
  2432. id="<?php echo $id_attribute; ?>-top_left_corner" 
  2433. type="text" 
  2434. value="<?php echo esc_attr( $top_left_corner ); ?>" 
  2435. class="a3rev-ui-border_top_left_corner a3rev-ui-slider" 
  2436. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2437. </div> 
  2438. </div> 
  2439. </div> 
  2440. <div class="a3rev-ui-border_corner-top_right"> 
  2441. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Right Corner', 'woocommerce-compare-products' ); ?></span>  
  2442. <div class="a3rev-ui-slide-container"> 
  2443. <div class="a3rev-ui-slide-container-start"> 
  2444. <div class="a3rev-ui-slide-container-end"> 
  2445. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-top_right_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2446. </div> 
  2447. </div> 
  2448. <div class="a3rev-ui-slide-result-container"> 
  2449. <input 
  2450. readonly="readonly" 
  2451. name="<?php echo $name_attribute; ?>[top_right_corner]" 
  2452. id="<?php echo $id_attribute; ?>-top_right_corner" 
  2453. type="text" 
  2454. value="<?php echo esc_attr( $top_right_corner ); ?>" 
  2455. class="a3rev-ui-border_top_right_corner a3rev-ui-slider" 
  2456. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2457. </div> 
  2458. </div> 
  2459. </div> 
  2460. <div class="a3rev-ui-border_corner-bottom_right"> 
  2461. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Right Corner', 'woocommerce-compare-products' ); ?></span>  
  2462. <div class="a3rev-ui-slide-container"> 
  2463. <div class="a3rev-ui-slide-container-start"> 
  2464. <div class="a3rev-ui-slide-container-end"> 
  2465. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-bottom_right_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2466. </div> 
  2467. </div> 
  2468. <div class="a3rev-ui-slide-result-container"> 
  2469. <input 
  2470. readonly="readonly" 
  2471. name="<?php echo $name_attribute; ?>[bottom_right_corner]" 
  2472. id="<?php echo $id_attribute; ?>-bottom_right_corner" 
  2473. type="text" 
  2474. value="<?php echo esc_attr( $bottom_right_corner ); ?>" 
  2475. class="a3rev-ui-border_bottom_right_corner a3rev-ui-slider" 
  2476. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2477. </div> 
  2478. </div> 
  2479. </div> 
  2480. <div class="a3rev-ui-border_corner-bottom_left"> 
  2481. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Left Corner', 'woocommerce-compare-products' ); ?></span> 
  2482. <div class="a3rev-ui-slide-container">  
  2483. <div class="a3rev-ui-slide-container-start"> 
  2484. <div class="a3rev-ui-slide-container-end"> 
  2485. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-bottom_left_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2486. </div> 
  2487. </div> 
  2488. <div class="a3rev-ui-slide-result-container"> 
  2489. <input 
  2490. readonly="readonly" 
  2491. name="<?php echo $name_attribute; ?>[bottom_left_corner]" 
  2492. id="<?php echo $id_attribute; ?>-bottom_left_corner" 
  2493. type="text" 
  2494. value="<?php echo esc_attr( $bottom_left_corner ); ?>" 
  2495. class="a3rev-ui-border_bottom_left_corner a3rev-ui-slider" 
  2496. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2497. </div> 
  2498. </div> 
  2499. </div> 
  2500. </div> 
  2501. <div style="clear:both"></div> 
  2502. </div> 
  2503.  
  2504. </td> 
  2505. </tr><?php 
  2506.  
  2507. break; 
  2508.  
  2509. // Border Style Control 
  2510. case 'border_styles': 
  2511.  
  2512. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2513.  
  2514. $width = $option_value['width']; 
  2515. $style = $option_value['style']; 
  2516. $color = $option_value['color']; 
  2517.  
  2518. ?><tr valign="top"> 
  2519. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2520. <td class="forminp"> 
  2521. <?php echo $description; ?> 
  2522. <div class="a3rev-ui-settings-control"> 
  2523. <!-- Border Width --> 
  2524. <select 
  2525. name="<?php echo $name_attribute; ?>[width]" 
  2526. id="<?php echo $id_attribute; ?>-width" 
  2527. class="a3rev-ui-border_styles-width chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2528. <?php 
  2529. for ( $i = 0; $i <= 20; $i++ ) { 
  2530. ?> 
  2531. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2532. selected( $width, $i.'px' ); 
  2533. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2534. <?php 
  2535. ?> 
  2536. </select>  
  2537.  
  2538. <!-- Border Style --> 
  2539. <select 
  2540. name="<?php echo $name_attribute; ?>[style]" 
  2541. id="<?php echo $id_attribute; ?>-style" 
  2542. class="a3rev-ui-border_styles-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2543. <?php 
  2544. foreach ( $this->get_border_styles() as $val => $text ) { 
  2545. ?> 
  2546. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2547. selected( esc_attr( $val ), esc_attr( $style ) ); 
  2548. ?>><?php echo esc_attr( $text ); ?></option> 
  2549. <?php 
  2550. ?> 
  2551. </select> 
  2552.  
  2553. <!-- Border Color --> 
  2554. <input 
  2555. name="<?php echo $name_attribute; ?>[color]" 
  2556. id="<?php echo $id_attribute; ?>-color" 
  2557. type="text" 
  2558. value="<?php echo esc_attr( $color ); ?>" 
  2559. class="a3rev-ui-border_styles-color a3rev-color-picker" 
  2560. <?php echo $default_color; ?> 
  2561. /> 
  2562.  
  2563. <!-- Preview Button --> 
  2564. <div class="a3rev-ui-settings-preview"><a href="#" class="a3rev-ui-border-preview-button a3rev-ui-settings-preview-button button submit-button" title="<?php _e( 'Preview your customized border styles settings', 'woocommerce-compare-products' ); ?>"><span> </span></a></div> 
  2565. <span class="description" style="margin-left:5px;"><?php echo __( '0px = No Border', 'woocommerce-compare-products' ); ?></span> 
  2566. </div> 
  2567.  
  2568. </td> 
  2569. </tr><?php 
  2570.  
  2571. break; 
  2572.  
  2573. // Border Rounded Corners Control 
  2574. case 'border_corner': 
  2575.  
  2576. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2577. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2578. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2579.  
  2580. if ( ! isset( $option_value['corner'] ) ) $option_value['corner'] = ''; 
  2581. $corner = $option_value['corner']; 
  2582.  
  2583. if ( ! isset( $option_value['rounded_value'] ) ) $option_value['rounded_value'] = 3; 
  2584. $rounded_value = $option_value['rounded_value']; 
  2585.  
  2586. if ( ! isset( $option_value['top_left_corner'] ) ) $option_value['top_left_corner'] = 3; 
  2587. $top_left_corner = $option_value['top_left_corner']; 
  2588.  
  2589. if ( ! isset( $option_value['top_right_corner'] ) ) $option_value['top_right_corner'] = 3; 
  2590. $top_right_corner = $option_value['top_right_corner']; 
  2591.  
  2592. if ( ! isset( $option_value['bottom_left_corner'] ) ) $option_value['bottom_left_corner'] = 3; 
  2593. $bottom_left_corner = $option_value['bottom_left_corner']; 
  2594.  
  2595. if ( ! isset( $option_value['bottom_right_corner'] ) ) $option_value['bottom_right_corner'] = 3; 
  2596. $bottom_right_corner = $option_value['bottom_right_corner']; 
  2597.  
  2598. if ( trim( $rounded_value ) == '' || trim( $rounded_value ) <= 0 ) $rounded_value = $value['min']; 
  2599. $rounded_value = intval( $rounded_value ); 
  2600.  
  2601. if ( trim( $top_left_corner ) == '' || trim( $top_left_corner ) <= 0 ) $top_left_corner = $rounded_value; 
  2602. $top_left_corner = intval( $top_left_corner ); 
  2603.  
  2604. if ( trim( $top_right_corner ) == '' || trim( $top_right_corner ) <= 0 ) $top_right_corner = $rounded_value; 
  2605. $top_right_corner = intval( $top_right_corner ); 
  2606.  
  2607. if ( trim( $bottom_left_corner ) == '' || trim( $bottom_left_corner ) <= 0 ) $bottom_left_corner = $rounded_value; 
  2608. $bottom_left_corner = intval( $bottom_left_corner ); 
  2609.  
  2610. if ( trim( $bottom_right_corner ) == '' || trim( $bottom_right_corner ) <= 0 ) $bottom_right_corner = $rounded_value; 
  2611. $bottom_right_corner = intval( $bottom_right_corner ); 
  2612.  
  2613. ?><tr valign="top"> 
  2614. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2615. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2616. <div class="a3rev-ui-settings-control">  
  2617. <!-- Border Corner : Rounded or Square --> 
  2618. <input 
  2619. name="<?php echo $name_attribute; ?>[corner]" 
  2620. id="<?php echo $id_attribute; ?>" 
  2621. class="a3rev-ui-border-corner a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2622. checked_label="<?php _e( 'Rounded', 'woocommerce-compare-products' ); ?>" 
  2623. unchecked_label="<?php _e( 'Square', 'woocommerce-compare-products' ); ?>" 
  2624. type="checkbox" 
  2625. value="rounded" 
  2626. <?php checked( 'rounded', $corner ); ?> 
  2627. <?php echo implode( ' ', $custom_attributes ); ?> 
  2628. />  
  2629.  
  2630. <!-- Preview Button --> 
  2631. <div class="a3rev-ui-settings-preview"><a href="#" class="a3rev-ui-border-preview-button a3rev-ui-settings-preview-button button submit-button" title="<?php _e( 'Preview your customized border settings', 'woocommerce-compare-products' ); ?>"><span> </span></a></div> 
  2632. <?php echo $description; ?> 
  2633. <!-- Border Rounded Value --> 
  2634. <div class="a3rev-ui-border-corner-value-container"> 
  2635. <div class="a3rev-ui-border_corner-top_left"> 
  2636. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Left Corner', 'woocommerce-compare-products' ); ?></span> 
  2637. <div class="a3rev-ui-slide-container"> 
  2638. <div class="a3rev-ui-slide-container-start"> 
  2639. <div class="a3rev-ui-slide-container-end"> 
  2640. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-top_left_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2641. </div> 
  2642. </div> 
  2643. <div class="a3rev-ui-slide-result-container"> 
  2644. <input 
  2645. readonly="readonly" 
  2646. name="<?php echo $name_attribute; ?>[top_left_corner]" 
  2647. id="<?php echo $id_attribute; ?>-top_left_corner" 
  2648. type="text" 
  2649. value="<?php echo esc_attr( $top_left_corner ); ?>" 
  2650. class="a3rev-ui-border_top_left_corner a3rev-ui-slider" 
  2651. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2652. </div> 
  2653. </div> 
  2654. </div> 
  2655. <div class="a3rev-ui-border_corner-top_right"> 
  2656. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Right Corner', 'woocommerce-compare-products' ); ?></span> 
  2657. <div class="a3rev-ui-slide-container">  
  2658. <div class="a3rev-ui-slide-container-start"> 
  2659. <div class="a3rev-ui-slide-container-end"> 
  2660. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-top_right_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2661. </div> 
  2662. </div> 
  2663. <div class="a3rev-ui-slide-result-container"> 
  2664. <input 
  2665. readonly="readonly" 
  2666. name="<?php echo $name_attribute; ?>[top_right_corner]" 
  2667. id="<?php echo $id_attribute; ?>-top_right_corner" 
  2668. type="text" 
  2669. value="<?php echo esc_attr( $top_right_corner ); ?>" 
  2670. class="a3rev-ui-border_top_right_corner a3rev-ui-slider" 
  2671. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2672. </div> 
  2673. </div> 
  2674. </div> 
  2675. <div class="a3rev-ui-border_corner-bottom_right"> 
  2676. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Right Corner', 'woocommerce-compare-products' ); ?></span> 
  2677. <div class="a3rev-ui-slide-container">  
  2678. <div class="a3rev-ui-slide-container-start"> 
  2679. <div class="a3rev-ui-slide-container-end"> 
  2680. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-bottom_right_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2681. </div> 
  2682. </div> 
  2683. <div class="a3rev-ui-slide-result-container"> 
  2684. <input 
  2685. readonly="readonly" 
  2686. name="<?php echo $name_attribute; ?>[bottom_right_corner]" 
  2687. id="<?php echo $id_attribute; ?>-bottom_right_corner" 
  2688. type="text" 
  2689. value="<?php echo esc_attr( $bottom_right_corner ); ?>" 
  2690. class="a3rev-ui-border_bottom_right_corner a3rev-ui-slider" 
  2691. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2692. </div> 
  2693. </div> 
  2694. </div> 
  2695. <div class="a3rev-ui-border_corner-bottom_left"> 
  2696. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Left Corner', 'woocommerce-compare-products' ); ?></span>  
  2697. <div class="a3rev-ui-slide-container"> 
  2698. <div class="a3rev-ui-slide-container-start"> 
  2699. <div class="a3rev-ui-slide-container-end"> 
  2700. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>-bottom_left_corner_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2701. </div> 
  2702. </div> 
  2703. <div class="a3rev-ui-slide-result-container"> 
  2704. <input 
  2705. readonly="readonly" 
  2706. name="<?php echo $name_attribute; ?>[bottom_left_corner]" 
  2707. id="<?php echo $id_attribute; ?>-bottom_left_corner" 
  2708. type="text" 
  2709. value="<?php echo esc_attr( $bottom_left_corner ); ?>" 
  2710. class="a3rev-ui-border_bottom_left_corner a3rev-ui-slider" 
  2711. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2712. </div> 
  2713. </div> 
  2714. </div> 
  2715. </div> 
  2716. <div style="clear:both"></div> 
  2717. </div> 
  2718. <div style="clear:both"></div> 
  2719. </td> 
  2720. </tr><?php 
  2721.  
  2722. break; 
  2723.  
  2724. // Box Shadow Control 
  2725. case 'box_shadow': 
  2726.  
  2727. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2728.  
  2729. if ( ! isset( $option_value['enable'] ) ) $option_value['enable'] = 0; 
  2730. $enable = $option_value['enable']; 
  2731. if ( ! isset( $option_value['inset'] ) ) $option_value['inset'] = ''; 
  2732. $h_shadow = $option_value['h_shadow']; 
  2733. $v_shadow = $option_value['v_shadow']; 
  2734. $blur = $option_value['blur']; 
  2735. $spread = $option_value['spread']; 
  2736. $color = $option_value['color']; 
  2737. $inset = $option_value['inset']; 
  2738.  
  2739. ?><tr valign="top"> 
  2740. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2741. <td class="forminp forminp-box_shadow"> 
  2742. <input 
  2743. name="<?php echo $name_attribute; ?>[enable]" 
  2744. id="<?php echo $id_attribute; ?>" 
  2745. class="a3rev-ui-box_shadow-enable a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2746. checked_label="<?php _e( 'ON', 'woocommerce-compare-products' ); ?>" 
  2747. unchecked_label="<?php _e( 'OFF', 'woocommerce-compare-products' ); ?>" 
  2748. type="checkbox" 
  2749. value="1" 
  2750. <?php checked( 1, $enable ); ?> 
  2751. <?php echo implode( ' ', $custom_attributes ); ?> 
  2752. /> 
  2753. <?php echo $description; ?> 
  2754. <div style="clear:both;"></div>  
  2755. <div class="a3rev-ui-box_shadow-enable-container"> 
  2756. <div class="a3rev-ui-settings-control"> 
  2757. <!-- Box Horizontal Shadow Size --> 
  2758. <select 
  2759. name="<?php echo $name_attribute; ?>[h_shadow]" 
  2760. id="<?php echo $id_attribute; ?>-h_shadow" 
  2761. class="a3rev-ui-box_shadow-h_shadow chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2762. data-placeholder="<?php _e( 'Horizontal Shadow', 'woocommerce-compare-products' ); ?>" 
  2763. <?php 
  2764. for ( $i = -20; $i <= 20; $i++ ) { 
  2765. ?> 
  2766. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2767. selected( $h_shadow, $i.'px' ); 
  2768. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2769. <?php 
  2770. ?> 
  2771. </select>  
  2772.  
  2773. <!-- Box Vertical Shadow Size --> 
  2774. <select 
  2775. name="<?php echo $name_attribute; ?>[v_shadow]" 
  2776. id="<?php echo $id_attribute; ?>-v_shadow" 
  2777. class="a3rev-ui-box_shadow-v_shadow chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2778. data-placeholder="<?php _e( 'Vertical Shadow', 'woocommerce-compare-products' ); ?>" 
  2779. <?php 
  2780. for ( $i = -20; $i <= 20; $i++ ) { 
  2781. ?> 
  2782. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2783. selected( $v_shadow, $i.'px' ); 
  2784. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2785. <?php 
  2786. ?> 
  2787. </select>  
  2788.  
  2789. <!-- Box Blur Distance --> 
  2790. <select 
  2791. name="<?php echo $name_attribute; ?>[blur]" 
  2792. id="<?php echo $id_attribute; ?>-blur" 
  2793. class="a3rev-ui-box_shadow-blur chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2794. data-placeholder="<?php _e( 'Blur Distance', 'woocommerce-compare-products' ); ?>" 
  2795. <?php 
  2796. for ( $i = 0; $i <= 20; $i++ ) { 
  2797. ?> 
  2798. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2799. selected( $blur, $i.'px' ); 
  2800. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2801. <?php 
  2802. ?> 
  2803. </select>  
  2804.  
  2805. <!-- Box Spread --> 
  2806. <select 
  2807. name="<?php echo $name_attribute; ?>[spread]" 
  2808. id="<?php echo $id_attribute; ?>-spread" 
  2809. class="a3rev-ui-box_shadow-spread chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2810. data-placeholder="<?php _e( 'Spread Size', 'woocommerce-compare-products' ); ?>" 
  2811. <?php 
  2812. for ( $i = 0; $i <= 20; $i++ ) { 
  2813. ?> 
  2814. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2815. selected( $spread, $i.'px' ); 
  2816. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2817. <?php 
  2818. ?> 
  2819. </select>  
  2820.  
  2821. <!-- Box Shadow Inset --> 
  2822. <input 
  2823. name="<?php echo $name_attribute; ?>[inset]" 
  2824. id="<?php echo $id_attribute; ?>" 
  2825. class="a3rev-ui-box_shadow-inset a3rev-ui-onoff_checkbox" 
  2826. checked_label="<?php _e( 'INNER', 'woocommerce-compare-products' ); ?>" 
  2827. unchecked_label="<?php _e( 'OUTER', 'woocommerce-compare-products' ); ?>" 
  2828. type="checkbox" 
  2829. value="inset" 
  2830. <?php checked( 'inset', $inset ); ?> 
  2831. <?php echo implode( ' ', $custom_attributes ); ?> 
  2832. />  
  2833.  
  2834. <!-- Box Shadow Color --> 
  2835. <input 
  2836. name="<?php echo $name_attribute; ?>[color]" 
  2837. id="<?php echo $id_attribute; ?>-color" 
  2838. type="text" 
  2839. value="<?php echo esc_attr( $color ); ?>" 
  2840. class="a3rev-ui-box_shadow-color a3rev-color-picker" 
  2841. <?php echo $default_color; ?> 
  2842. /> 
  2843.  
  2844. <!-- Preview Button --> 
  2845. <div class="a3rev-ui-settings-preview"><a href="#" class="a3rev-ui-box_shadow-preview-button a3rev-ui-settings-preview-button button submit-button" title="<?php _e( 'Preview your customized box shadow settings', 'woocommerce-compare-products' ); ?>"><span> </span></a></div>  
  2846. </div> 
  2847. <div style="clear:both;"></div> 
  2848. </div> 
  2849. </td> 
  2850. </tr><?php 
  2851.  
  2852. break; 
  2853.  
  2854. // Slider Control 
  2855. case 'slider': 
  2856.  
  2857. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2858. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2859. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2860. if ( trim( $option_value ) == '' || trim( $option_value ) <= 0 ) $option_value = $value['min']; 
  2861. $option_value = intval( $option_value ); 
  2862.  
  2863. ?><tr valign="top"> 
  2864. <th scope="row" class="titledesc"> 
  2865. <?php echo $tip; ?> 
  2866. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2867. </th> 
  2868. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2869. <div class="a3rev-ui-slide-container"> 
  2870. <div class="a3rev-ui-slide-container-start"><div class="a3rev-ui-slide-container-end"> 
  2871. <div class="a3rev-ui-slide" id="<?php echo $id_attribute; ?>_div" min="<?php echo esc_attr( $value['min'] ); ?>" max="<?php echo esc_attr( $value['max'] ); ?>" inc="<?php echo esc_attr( $value['increment'] ); ?>"></div> 
  2872. </div></div> 
  2873. <div class="a3rev-ui-slide-result-container"> 
  2874. <input 
  2875. readonly="readonly" 
  2876. name="<?php echo $name_attribute; ?>" 
  2877. id="<?php echo $id_attribute; ?>" 
  2878. type="text" 
  2879. value="<?php echo esc_attr( $option_value ); ?>" 
  2880. class="a3rev-ui-slider" 
  2881. <?php echo implode( ' ', $custom_attributes ); ?> 
  2882. /> <?php echo $description; ?> 
  2883. </div> 
  2884. </div> 
  2885. </td> 
  2886. </tr><?php 
  2887.  
  2888. break; 
  2889.  
  2890. // Upload Control 
  2891. case 'upload': 
  2892.  
  2893. $class = 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . esc_attr( $value['class'] ); 
  2894.  
  2895. $strip_methods = true; 
  2896. if ( isset( $value['strip_methods'] ) ) { 
  2897. $strip_methods = $value['strip_methods']; 
  2898.  
  2899. if ( strstr( $name_attribute, ']' ) ) { 
  2900. $attachment_id_name_attribute = substr_replace( $name_attribute, '_attachment_id', -1, 0 ); 
  2901. } else { 
  2902. $attachment_id_name_attribute = $name_attribute.'_attachment_id'; 
  2903. $attachment_id = $this->settings_get_option( $attachment_id_name_attribute, 0 ); 
  2904.  
  2905. ?><tr valign="top"> 
  2906. <th scope="row" class="titledesc"> 
  2907. <?php echo $tip; ?> 
  2908. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2909. </th> 
  2910. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2911. <?php echo $description; ?> 
  2912. <?php echo $wc_compare_uploader->upload_input( $name_attribute, $id_attribute, $option_value, $attachment_id, $value['default'], esc_html( $value['name'] ), $class, esc_attr( $value['css'] ) , '', $strip_methods );?> 
  2913. </td> 
  2914. </tr><?php 
  2915.  
  2916. break; 
  2917.  
  2918. // WP Editor Control 
  2919. case 'wp_editor': 
  2920.  
  2921. if ( ! isset( $value['textarea_rows'] ) ) $value['textarea_rows'] = 15; 
  2922.  
  2923. ?><tr valign="top"> 
  2924. <th scope="row" class="titledesc"> 
  2925. <?php echo $tip; ?> 
  2926. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2927. </th> 
  2928. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2929. <?php echo $description; ?> 
  2930. <?php remove_all_filters('mce_external_plugins'); ?> 
  2931. <?php wp_editor( $option_value,  
  2932. $id_attribute,  
  2933. array( 'textarea_name' => $name_attribute,  
  2934. 'wpautop' => true,  
  2935. 'editor_class' => 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . esc_attr( $value['class'] ),  
  2936. 'textarea_rows' => $value['textarea_rows'] ) ); ?>  
  2937. </td> 
  2938. </tr><?php 
  2939.  
  2940. break; 
  2941.  
  2942. // Array Text Field Control 
  2943. case 'array_textfields': 
  2944.  
  2945. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  2946.  
  2947. ?><tr valign="top"> 
  2948. <th scope="row" class="titledesc"> 
  2949. <?php echo $tip; ?> 
  2950. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2951. </th> 
  2952. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2953. <?php echo $description; ?> 
  2954. <div class="a3rev-ui-array_textfields-container"> 
  2955. <?php 
  2956. foreach ( $value['ids'] as $text_field ) { 
  2957.  
  2958. if ( ! isset( $text_field['id'] ) ) $text_field['id'] = ''; 
  2959. if ( ! isset( $text_field['name'] ) ) $text_field['name'] = ''; 
  2960. if ( ! isset( $text_field['class'] ) ) $text_field['class'] = ''; 
  2961. if ( ! isset( $text_field['css'] ) ) $text_field['css'] = ''; 
  2962. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  2963.  
  2964. // Remove [, ] characters from id argument 
  2965. $key = false; 
  2966. if ( strstr( $text_field['id'], '[' ) ) { 
  2967. parse_str( esc_attr( $text_field['id'] ), $option_array ); 
  2968.  
  2969. // Option name is first key 
  2970. $option_keys = array_keys( $option_array ); 
  2971. $first_key = current( $option_keys ); 
  2972.  
  2973. $id_attribute = $first_key; 
  2974.  
  2975. $key = key( $option_array[ $id_attribute ] ); 
  2976. } else { 
  2977. $id_attribute = esc_attr( $text_field['id'] ); 
  2978.  
  2979. // Get option value when option name is not parse or when it's spearate option 
  2980. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  2981. $option_value = $this->settings_get_option( $text_field['id'], $text_field['default'] ); 
  2982. // Get option value when it's an element from option array  
  2983. else { 
  2984. if ( $key != false ) { 
  2985. $option_value = ( isset( $option_values[ $id_attribute ][ $key ] ) ) ? $option_values[ $id_attribute ][ $key ] : $text_field['default']; 
  2986. } else { 
  2987. $option_value = ( isset( $option_values[ $id_attribute ] ) ) ? $option_values[ $id_attribute ] : $text_field['default']; 
  2988.  
  2989. // Generate name and id attributes 
  2990. if ( trim( $option_name ) == '' ) { 
  2991. $name_attribute = esc_attr( $text_field['id'] ); 
  2992. } elseif ( $value['separate_option'] != false ) { 
  2993. $name_attribute = esc_attr( $text_field['id'] ); 
  2994. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  2995. } else { 
  2996. // Array value 
  2997. if ( strstr( $text_field['id'], '[' ) ) { 
  2998. $name_attribute = esc_attr( $option_name ) . '[' . $id_attribute . ']' . str_replace( $id_attribute . '[', '[', esc_attr( $text_field['id'] ) ); 
  2999. } else { 
  3000. $name_attribute = esc_attr( $option_name ) . '[' . esc_attr( $text_field['id'] ) . ']'; 
  3001. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  3002. ?> 
  3003. <label><input 
  3004. name="<?php echo $name_attribute; ?>" 
  3005. id="<?php echo $id_attribute; ?>" 
  3006. type="text" 
  3007. style="<?php echo esc_attr( $text_field['css'] ); ?>" 
  3008. value="<?php echo esc_attr( $option_value ); ?>" 
  3009. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $text_field['class'] ); ?>" 
  3010. /> <span><?php echo esc_html( $text_field['name'] ); ?></span></label>  
  3011. <?php 
  3012. ?> 
  3013. </div> 
  3014.  
  3015. </td> 
  3016. </tr><?php 
  3017.  
  3018. break; 
  3019.  
  3020. // Default: run an action 
  3021. default: 
  3022. do_action( $this->plugin_name . '_admin_field_' . $value['type'], $value ); 
  3023. break; 
  3024.  
  3025. // :) 
  3026. if ( ! isset( $this->is_free_plugin ) || ! $this->is_free_plugin ) { 
  3027. $fs = array( 0 => 'c', 1 => 'p', 2 => 'h', 3 => 'i', 4 => 'e', 5 => 'n', 6 => 'k', 7 => '_' ); 
  3028. $cs = array( 0 => 'U', 1 => 'g', 2 => 'p', 3 => 'r', 4 => 'd', 5 => 'a', 6 => 'e', 7 => '_' ); 
  3029. $check_settings_save = true; 
  3030. if ( isset( $this->class_name ) && ! class_exists( $this->class_name . $cs[7] . $cs[0] . $cs[2] . $cs[1] . $cs[3] . $cs[5] . $cs[4] . $cs[6] ) ) { 
  3031. $check_settings_save = false; 
  3032. if ( ! function_exists( $this->plugin_name . $fs[7] . $fs[0] . $fs[2] . $fs[4] . $fs[0] . $fs[6] . $fs[7] . $fs[1] . $fs[3] . $fs[5] ) ) { 
  3033. $check_settings_save = false; 
  3034. if ( ! $check_settings_save ) { 
  3035.  
  3036. if ( trim( $option_name ) != '' ) { 
  3037. update_option( $option_name, $new_settings ); 
  3038.  
  3039. foreach ( $options as $value ) { 
  3040. if ( ! isset( $value['type'] ) ) continue; 
  3041. if ( in_array( $value['type'], array( 'heading' ) ) ) continue; 
  3042. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  3043. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  3044. if ( ! isset( $value['free_version'] ) ) $value['free_version'] = false; 
  3045.  
  3046. // For way it has an option name 
  3047. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  3048.  
  3049. // Remove [, ] characters from id argument 
  3050. if ( strstr( $value['id'], '[' ) ) { 
  3051. parse_str( esc_attr( $value['id'] ), $option_array ); 
  3052.  
  3053. // Option name is first key 
  3054. $option_keys = array_keys( $option_array ); 
  3055. $first_key = current( $option_keys ); 
  3056.  
  3057. $id_attribute = $first_key; 
  3058. } else { 
  3059. $id_attribute = esc_attr( $value['id'] ); 
  3060.  
  3061. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  3062. update_option( $id_attribute, $new_single_setting ); 
  3063.  
  3064. if ( $end_heading_id !== false && ! $closed_panel_inner ) { 
  3065. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  3066. echo '</table>' . "\n\n"; 
  3067. echo '</div>' . "\n\n"; 
  3068. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' );  
  3069.  
  3070. if ( $header_sub_box_opening ) { 
  3071. $header_sub_box_opening = false; 
  3072.  
  3073. // close box inside 
  3074. echo '</div>' . "\n\n"; 
  3075.  
  3076. // close panel box 
  3077. echo '</div>' . "\n\n"; 
  3078.  
  3079. if ( $header_box_opening ) { 
  3080. $header_box_opening = false; 
  3081.  
  3082. // close box inside 
  3083. echo '</div>' . "\n\n"; 
  3084.  
  3085. // close panel box 
  3086. echo '</div>' . "\n\n"; 
  3087.  
  3088. if ( $had_first_column ) { 
  3089. // close panel column 
  3090. echo '</div>' . "\n\n"; 
  3091.  
  3092. ?> 
  3093. </div> <!-- Close Panel Row --> 
  3094. <?php do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_end' ); ?> 
  3095. <p class="submit"> 
  3096. <input type="submit" value="<?php _e('Save changes', 'woocommerce-compare-products' ); ?>" class="button button-primary" name="bt_save_settings" /> 
  3097. <input type="submit" name="bt_reset_settings" class="button" value="<?php _e('Reset Settings', 'woocommerce-compare-products' ); ?>" /> 
  3098. <input type="hidden" name="form_name_action" value="<?php echo $form_key; ?>" /> 
  3099. <input type="hidden" class="last_tab" name="subtab" value="#<?php echo $current_subtab; ?>" /> 
  3100. </p> 
  3101.  
  3102. </form> 
  3103. </div> 
  3104.  
  3105. <?php 
  3106.  
  3107. /**-----------------------------------------------------------------------------------*/ 
  3108. /** Custom panel box for use on another page - panel_box() */ 
  3109. /**-----------------------------------------------------------------------------------*/ 
  3110. public function panel_box( $settings_html = '', $options = array() ) { 
  3111. if ( ! isset( $options['id'] ) ) $options['id'] = ''; 
  3112. if ( ! isset( $options['name'] ) ) $options['name'] = ''; 
  3113. if ( ! isset( $options['class'] ) ) $options['class'] = ''; 
  3114. if ( ! isset( $options['css'] ) ) $options['css'] = ''; 
  3115. if ( ! isset( $options['desc'] ) ) $options['desc'] = ''; 
  3116. if ( ! isset( $options['desc_tip'] ) ) $options['desc_tip'] = false; 
  3117.  
  3118. $is_box = false; 
  3119. if ( isset( $options['is_box'] ) && true == $options['is_box'] ) { 
  3120. $is_box = true; 
  3121.  
  3122. $view_doc = ( isset( $options['view_doc'] ) ) ? $options['view_doc'] : ''; 
  3123.  
  3124. if ( $is_box ) { 
  3125.  
  3126. $heading_box_id = ''; 
  3127. if ( ! empty( $options['id'] ) ) { 
  3128. $heading_box_id = $options['id']; 
  3129.  
  3130. if ( '' != trim( $heading_box_id ) ) { 
  3131.  
  3132. $user_id = get_current_user_id(); 
  3133. $opened_box = get_user_meta( $user_id, $this->plugin_name . '-custom-boxes' , true ); 
  3134. if ( empty( $opened_box ) || ! is_array( $opened_box ) ) { 
  3135. $opened_box = array(); 
  3136.  
  3137. $toggle_box_open = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  3138.  
  3139. $toggle_box_class = ''; 
  3140. if ( 1 == $toggle_box_open ) { 
  3141. $toggle_box_class = 'enable_toggle_box_save'; 
  3142.  
  3143. $opened_class = ''; 
  3144. if ( in_array( $heading_box_id, $opened_box ) && 1 == $toggle_box_open ) { 
  3145. $opened_class = 'box_open'; 
  3146.  
  3147. // Change to open box for the heading set alway_open = true 
  3148. if ( isset( $options['alway_open'] ) && true == $options['alway_open'] ) { 
  3149. $opened_class = 'box_open'; 
  3150.  
  3151. // Change to close box for the heading set alway_close = true 
  3152. if ( isset( $options['alway_close'] ) && true == $options['alway_close'] ) { 
  3153. $opened_class = ''; 
  3154.  
  3155. // Make the box open on first load with this argument first_open = true 
  3156. if ( isset( $options['first_open'] ) && true == $options['first_open'] ) { 
  3157. $this_box_is_opened = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', true ); 
  3158. if ( empty( $this_box_is_opened ) ) { 
  3159. $opened_class = 'box_open'; 
  3160. add_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', 1 ); 
  3161.  
  3162. } else { 
  3163.  
  3164. $toggle_box_class = ''; 
  3165. $opened_class = ''; 
  3166.  
  3167.  
  3168. // open panel box 
  3169. echo '<div id="'. esc_attr( $options['id'] ) . '" class="a3rev_panel_box '. esc_attr( $options['class'] ) .'" style="'. esc_attr( $options['css'] ) .'">' . "\n\n"; 
  3170.  
  3171. // open box handle 
  3172. echo '<div data-form-key="custom-boxes" data-box-id="'. esc_attr( $heading_box_id ) .'" class="a3rev_panel_box_handle" >' . "\n\n"; 
  3173.  
  3174. echo ( ! empty( $options['name'] ) ) ? '<h3 class="a3-plugin-ui-panel-box '. $toggle_box_class . ' ' . $opened_class . '">'. esc_html( $options['name'] ) .' '. $view_doc .'</h3>' : ''; 
  3175.  
  3176. if ( stristr( $options['class'], 'pro_feature_fields' ) !== false && ! empty( $options['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $options['id'] ) ); 
  3177. elseif ( stristr( $options['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  3178.  
  3179. // close box handle 
  3180. echo '</div>' . "\n\n"; 
  3181.  
  3182. // open box inside 
  3183. echo '<div id="'. esc_attr( $options['id'] ) . '_box_inside" class="a3rev_panel_box_inside '.$opened_class.'" style="padding-top: 10px;" >' . "\n\n"; 
  3184.  
  3185. echo '<div class="a3rev_panel_inner">' . "\n\n"; 
  3186.  
  3187. } else { 
  3188. echo '<div id="'. esc_attr( $options['id'] ) . '" class="a3rev_panel_inner '. esc_attr( $options['class'] ) .'" style="'. esc_attr( $options['css'] ) .'">' . "\n\n"; 
  3189. if ( stristr( $options['class'], 'pro_feature_fields' ) !== false && ! empty( $options['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $options['id'] ) ); 
  3190. elseif ( stristr( $options['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  3191.  
  3192. echo ( ! empty( $options['name'] ) ) ? '<h3>'. esc_html( $options['name'] ) .' '. $view_doc .'</h3>' : ''; 
  3193.  
  3194. if ( ! empty( $options['desc'] ) ) { 
  3195. echo '<div class="a3rev_panel_box_description" >' . "\n\n"; 
  3196. echo wpautop( wptexturize( $options['desc'] ) ); 
  3197. echo '</div>' . "\n\n"; 
  3198.  
  3199. echo $settings_html; 
  3200.  
  3201. echo '</div>'; 
  3202.  
  3203. if ( $is_box ) { 
  3204. // close box inside 
  3205. echo '</div>' . "\n\n"; 
  3206.  
  3207. // close panel box 
  3208. echo '</div>' . "\n\n"; 
  3209.  
  3210. /**-----------------------------------------------------------------------------------*/ 
  3211. /** Custom Stripslashed for array in array - admin_stripslashes() */ 
  3212. /**-----------------------------------------------------------------------------------*/ 
  3213. public function admin_stripslashes( $values ) { 
  3214. if ( is_array( $values ) ) { 
  3215. $values = array_map( array( $this, 'admin_stripslashes' ), $values ); 
  3216. } else { 
  3217. $values = esc_attr( stripslashes( $values ) );  
  3218.  
  3219. return $values; 
  3220.  
  3221. /**-----------------------------------------------------------------------------------*/ 
  3222. /** hextorgb() */ 
  3223. /** Convert Hex to RGB for color */ 
  3224. /**-----------------------------------------------------------------------------------*/ 
  3225. public function hextorgb( $color = '', $text = true ) { 
  3226. $color = trim( $color ); 
  3227. if ( '' == $color || 'transparent' == $color ) { 
  3228. return false; 
  3229.  
  3230. if ( '#' == $color[0] ) { 
  3231. $color = substr( $color, 1 ); 
  3232.  
  3233. if ( 6 == strlen( $color ) ) { 
  3234. list( $r, $g, $b ) = array( $color[0].$color[1], $color[2].$color[3], $color[4].$color[5] ); 
  3235. } elseif ( 3 == strlen( $color ) ) { 
  3236. list( $r, $g, $b ) = array( $color[0].$color[0], $color[1].$color[1], $color[2].$color[2] ); 
  3237. } else { 
  3238. return false; 
  3239.  
  3240. $r = hexdec($r); 
  3241. $g = hexdec($g); 
  3242. $b = hexdec($b); 
  3243.  
  3244. if ( $text ) { 
  3245. return $r.', '.$g.', '.$b; 
  3246. } else { 
  3247. return array( $r, $g, $b ); 
  3248.  
  3249. /**-----------------------------------------------------------------------------------*/ 
  3250. /** generate_border_css() */ 
  3251. /** Generate Border CSS on frontend */ 
  3252. /**-----------------------------------------------------------------------------------*/ 
  3253. public function generate_border_css( $option ) { 
  3254.  
  3255. $border_css = ''; 
  3256.  
  3257. $border_css .= 'border: ' . esc_attr( $option['width'] ) . ' ' . esc_attr( $option['style'] ) . ' ' . esc_attr( $option['color'] ) .' !important;'; 
  3258.  
  3259. if ( isset( $option['corner'] ) && esc_attr( $option['corner'] ) == 'rounded' ) { 
  3260. if ( ! isset( $option['rounded_value'] ) ) $option['rounded_value'] = 0; 
  3261. if ( ! isset( $option['top_left_corner'] ) ) $option['top_left_corner'] = $option['rounded_value']; 
  3262. if ( ! isset( $option['top_right_corner'] ) ) $option['top_right_corner'] = $option['rounded_value']; 
  3263. if ( ! isset( $option['bottom_left_corner'] ) ) $option['bottom_left_corner'] = $option['rounded_value']; 
  3264. if ( ! isset( $option['bottom_right_corner'] ) ) $option['bottom_right_corner'] = $option['rounded_value']; 
  3265.  
  3266. $border_css .= 'border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3267. $border_css .= '-moz-border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3268. $border_css .= '-webkit-border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3269. } else { 
  3270. $border_css .= 'border-radius: 0px !important;'; 
  3271. $border_css .= '-moz-border-radius: 0px !important;'; 
  3272. $border_css .= '-webkit-border-radius: 0px !important;';  
  3273.  
  3274. return $border_css; 
  3275.  
  3276.  
  3277. /**-----------------------------------------------------------------------------------*/ 
  3278. /** generate_border_style_css() */ 
  3279. /** Generate Border Style CSS on frontend */ 
  3280. /**-----------------------------------------------------------------------------------*/ 
  3281. public function generate_border_style_css( $option ) { 
  3282.  
  3283. $border_style_css = ''; 
  3284.  
  3285. $border_style_css .= 'border: ' . esc_attr( $option['width'] ) . ' ' . esc_attr( $option['style'] ) . ' ' . esc_attr( $option['color'] ) .' !important;'; 
  3286.  
  3287. return $border_style_css; 
  3288.  
  3289.  
  3290. /**-----------------------------------------------------------------------------------*/ 
  3291. /** generate_border_corner_css() */ 
  3292. /** Generate Border Corner CSS on frontend */ 
  3293. /**-----------------------------------------------------------------------------------*/ 
  3294. public function generate_border_corner_css( $option ) { 
  3295.  
  3296. $border_corner_css = ''; 
  3297.  
  3298. if ( isset( $option['corner'] ) && esc_attr( $option['corner'] ) == 'rounded' ) { 
  3299. if ( ! isset( $option['rounded_value'] ) ) $option['rounded_value'] = 0; 
  3300. if ( ! isset( $option['top_left_corner'] ) ) $option['top_left_corner'] = $option['rounded_value']; 
  3301. if ( ! isset( $option['top_right_corner'] ) ) $option['top_right_corner'] = $option['rounded_value']; 
  3302. if ( ! isset( $option['bottom_left_corner'] ) ) $option['bottom_left_corner'] = $option['rounded_value']; 
  3303. if ( ! isset( $option['bottom_right_corner'] ) ) $option['bottom_right_corner'] = $option['rounded_value']; 
  3304.  
  3305. $border_corner_css .= 'border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3306. $border_corner_css .= '-moz-border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3307. $border_corner_css .= '-webkit-border-radius: ' . $option['top_left_corner'] . 'px ' . $option['top_right_corner'] . 'px ' . $option['bottom_right_corner'] . 'px ' . $option['bottom_left_corner'] . 'px !important;'; 
  3308. } else { 
  3309. $border_corner_css .= 'border-radius: 0px !important;'; 
  3310. $border_corner_css .= '-moz-border-radius: 0px !important;'; 
  3311. $border_corner_css .= '-webkit-border-radius: 0px !important;'; 
  3312.  
  3313. return $border_corner_css; 
  3314.  
  3315.  
  3316. /**-----------------------------------------------------------------------------------*/ 
  3317. /** generate_shadow_css() */ 
  3318. /** Generate Shadow CSS on frontend */ 
  3319. /**-----------------------------------------------------------------------------------*/ 
  3320. public function generate_shadow_css( $option ) { 
  3321.  
  3322. $shadow_css = ''; 
  3323. if ( ! isset( $option['inset'] ) ) $option['inset'] = ''; 
  3324.  
  3325. if ( isset( $option['enable'] ) && $option['enable'] == 1 ) { 
  3326. $shadow_css .= 'box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3327. $shadow_css .= '-moz-box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3328. $shadow_css .= '-webkit-box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3329. } else { 
  3330. $shadow_css .= 'box-shadow: none !important ;'; 
  3331. $shadow_css .= '-moz-box-shadow: none !important ;'; 
  3332. $shadow_css .= '-webkit-box-shadow: none !important ;'; 
  3333.  
  3334. return $shadow_css; 
  3335.  
  3336.  
  3337. /**-----------------------------------------------------------------------------------*/ 
  3338. /** generate_background_css() */ 
  3339. /** Generate Background Color CSS on frontend */ 
  3340. /**-----------------------------------------------------------------------------------*/ 
  3341. public function generate_background_color_css( $option, $transparency = 100 ) { 
  3342.  
  3343. $return_css = ''; 
  3344.  
  3345. if ( isset( $option['enable'] ) && $option['enable'] == 1 ) { 
  3346. $color = $option['color']; 
  3347. if ( 100 != $transparency ) { 
  3348. $color = $this->hextorgb( $color ); 
  3349. $transparency = (int) $transparency / 100; 
  3350.  
  3351. if ( $color !== false ) { 
  3352. $return_css .= 'background-color: rgba( ' . $color . ', ' . $transparency . ' ) !important;'; 
  3353. } else { 
  3354. $return_css .= 'background-color: transparent !important ;'; 
  3355. } else { 
  3356. $return_css .= 'background-color: ' . $color . ' !important ;'; 
  3357. } else { 
  3358. $return_css .= 'background-color: transparent !important ;'; 
  3359.  
  3360. return $return_css; 
  3361.  
  3362.