WC_Dynamic_Gallery_Admin_Interface

The WooCommerce Dynamic Gallery LITE WC Dynamic Gallery Admin Interface class.

Defined (1)

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

/admin/admin-interface.php  
  1. class WC_Dynamic_Gallery_Admin_Interface extends WC_Dynamic_Gallery_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_Dynamic_Gallery_Upgrade' ) ) { 
  127. $new_version = WC_Dynamic_Gallery_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.', 'woo_dgallery' ); 
  133. $has_new_version = 0; 
  134. } else { 
  135. delete_option('wc_dgallery_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 = WOO_DYNAMIC_GALLERY_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.' , 'woo_dgallery' );  
  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.' , 'woo_dgallery' );  
  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.' , 'woo_dgallery' );  
  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', 'woo_dgallery' ),  
  222. '300 italic' => __( 'Thin/Italic', 'woo_dgallery' ),  
  223. 'normal' => __( 'Normal', 'woo_dgallery' ),  
  224. 'italic' => __( 'Italic', 'woo_dgallery' ),  
  225. 'bold' => __( 'Bold', 'woo_dgallery' ),  
  226. 'bold italic' => __( 'Bold/Italic', 'woo_dgallery' ),  
  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', 'woo_dgallery' ),  
  236. 'double' => __( 'Double', 'woo_dgallery' ),  
  237. 'dashed' => __( 'Dashed', 'woo_dgallery' ),  
  238. 'dotted' => __( 'Dotted', 'woo_dgallery' ),  
  239. 'groove' => __( 'Groove', 'woo_dgallery' ),  
  240. 'ridge' => __( 'Ridge', 'woo_dgallery' ),  
  241. 'inset' => __( 'Inset', 'woo_dgallery' ),  
  242. 'outset' => __( 'Outset', 'woo_dgallery' ),  
  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( 'heading' ) ) ) 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( 'heading' ) ) ) 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( 'heading' ) ) ) 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( 'heading' ) ) ) 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( 'heading' ) ) ) 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( 'heading' ) ) ) 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 => heading | 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. */ 
  1011.  
  1012. public function admin_forms( $options, $form_key, $option_name = '', $form_messages = array() ) { 
  1013. global $wc_dgallery_fonts_face, $wc_dgallery_uploader, $current_subtab; 
  1014.  
  1015. $new_settings = array(); $new_single_setting = ''; // :) 
  1016. $admin_message = ''; 
  1017.  
  1018. if ( isset( $_POST['form_name_action'] ) && $_POST['form_name_action'] == $form_key ) { 
  1019.  
  1020. do_action( $this->plugin_name . '_before_settings_save_reset' ); 
  1021. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_before_settings_save' ); 
  1022.  
  1023. // Save settings action 
  1024. if ( isset( $_POST['bt_save_settings'] ) ) { 
  1025. $this->save_settings( $options, $option_name ); 
  1026. $admin_message = $this->get_success_message( ( isset( $form_messages['success_message'] ) ) ? $form_messages['success_message'] : '' ); 
  1027. }  
  1028. // Reset settings action 
  1029. elseif ( isset( $_POST['bt_reset_settings'] ) ) { 
  1030. $this->reset_settings( $options, $option_name, true ); 
  1031. $admin_message = $this->get_success_message( ( isset( $form_messages['reset_message'] ) ) ? $form_messages['reset_message'] : '' ); 
  1032.  
  1033. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_after_settings_save' ); 
  1034. do_action( $this->plugin_name . '_after_settings_save_reset' ); 
  1035. do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_init' ); 
  1036. do_action( $this->plugin_name . '_settings_init' ); 
  1037.  
  1038. $option_values = array(); 
  1039. if ( trim( $option_name ) != '' ) { 
  1040. $option_values = get_option( $option_name, array() ); 
  1041. if ( is_array( $option_values ) ) 
  1042. $option_values = array_map( array( $this, 'admin_stripslashes' ), $option_values ); 
  1043. else 
  1044. $option_values = array(); 
  1045.  
  1046. $default_settings = $this->get_settings_default( $options, $option_name ); 
  1047.  
  1048. $option_values = array_merge($default_settings, $option_values); 
  1049.  
  1050. if ( !is_array( $options ) || count( $options ) < 1 ) return ''; 
  1051. ?> 
  1052.  
  1053. <?php echo $admin_message; ?> 
  1054. <div class="a3rev_panel_container" style="visibility:hidden; height:0; overflow:hidden;" > 
  1055. <form action="" method="post"> 
  1056. <?php do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_start' ); ?> 
  1057. <?php 
  1058. $count_heading = 0; 
  1059. $end_heading_id = false; 
  1060. $header_box_opening = false; 
  1061. $header_sub_box_opening = false; 
  1062.  
  1063. $user_id = get_current_user_id(); 
  1064. $opened_box = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ), true ); 
  1065. if ( empty( $opened_box ) || ! is_array( $opened_box ) ) { 
  1066. $opened_box = array(); 
  1067.  
  1068. $toggle_box_open = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  1069. if ( ! isset( $_POST['bt_save_settings'] ) && 0 == $toggle_box_open ) { 
  1070. delete_user_meta( $user_id, $this->plugin_name . '-' . trim( $form_key ) ); 
  1071.  
  1072. foreach ( $options as $value ) { 
  1073. if ( ! isset( $value['type'] ) ) continue; 
  1074. if ( ! isset( $value['id'] ) ) $value['id'] = ''; 
  1075. if ( ! isset( $value['name'] ) ) $value['name'] = ''; 
  1076. if ( ! isset( $value['class'] ) ) $value['class'] = ''; 
  1077. if ( ! isset( $value['css'] ) ) $value['css'] = ''; 
  1078. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  1079. if ( ! isset( $value['desc'] ) ) $value['desc'] = ''; 
  1080. if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false; 
  1081. if ( ! isset( $value['placeholder'] ) ) $value['placeholder'] = ''; 
  1082.  
  1083. // For way it has an option name 
  1084. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  1085.  
  1086. // Custom attribute handling 
  1087. $custom_attributes = array(); 
  1088.  
  1089. if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) 
  1090. foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) 
  1091. $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; 
  1092.  
  1093. // Description handling 
  1094. if ( $value['desc_tip'] === true ) { 
  1095. $description = ''; 
  1096. $tip = $value['desc']; 
  1097. } elseif ( ! empty( $value['desc_tip'] ) ) { 
  1098. $description = $value['desc']; 
  1099. $tip = $value['desc_tip']; 
  1100. } elseif ( ! empty( $value['desc'] ) ) { 
  1101. $description = $value['desc']; 
  1102. $tip = ''; 
  1103. } else { 
  1104. $description = $tip = ''; 
  1105.  
  1106. if ( $description && in_array( $value['type'], array( 'manual_check_version', 'textarea', 'radio', 'onoff_radio', 'typography', 'border', 'border_styles', 'border_corner', 'box_shadow', 'array_textfields', 'wp_editor', 'upload' ) ) ) { 
  1107. $description = '<div class="desc" style="margin-bottom:5px;">' . $description . '</div>'; 
  1108. } elseif ( $description ) { 
  1109. $description = '<span class="description" style="margin-left:5px;">' . $description . '</span>'; 
  1110.  
  1111. /** 
  1112. * Add Default value into description and description tip if it has shortcode : 
  1113. * [default_value] : apply for normal types 
  1114. * [default_value_width] : apply for image_size type 
  1115. * [default_value_height] : apply for image_size type 
  1116. * [default_value_size] : apply for typography type 
  1117. * [default_value_line_height] : apply for typography type 
  1118. * [default_value_face] : apply for typography type 
  1119. * [default_value_style] : apply for typography, border, border_styles types 
  1120. * [default_value_color] : apply for typography, border, border_styles types 
  1121. * [default_value_width] : apply for border, border_styles types 
  1122. * [default_value_rounded_value]: apply for border, border_corner types 
  1123. * [default_value_top_left_corner]: apply for border, border_corner types 
  1124. * [default_value_top_right_corner]: apply for border, border_corner types 
  1125. * [default_value_bottom_left_corner]: apply for border, border_corner types 
  1126. * [default_value_bottom_right_corner]: apply for border, border_corner types 
  1127. */ 
  1128. if ( $value['type'] == 'image_size' ) { 
  1129. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1130. if ( ! isset( $value['default']['width'] ) ) $value['default']['width'] = ''; 
  1131. if ( ! isset( $value['default']['height'] ) ) $value['default']['height'] = ''; 
  1132. if ( ! isset( $value['default']['crop'] ) ) $value['default']['crop'] = 1; 
  1133.  
  1134. $description = str_replace( '[default_value_width]', $value['default']['width'], $description ); 
  1135. $description = str_replace( '[default_value_height]', $value['default']['height'], $description ); 
  1136. } elseif ( $value['type'] == 'typography' ) { 
  1137. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1138. if ( ! isset( $value['default']['size'] ) ) $value['default']['size'] = ''; 
  1139. if ( ! isset( $value['default']['line_height'] ) ) $value['default']['line_height'] = ''; 
  1140. if ( ! isset( $value['default']['face'] ) ) $value['default']['face'] = ''; 
  1141. if ( ! isset( $value['default']['style'] ) ) $value['default']['style'] = ''; 
  1142. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1143.  
  1144. $description = str_replace( '[default_value_size]', $value['default']['size'], $description ); 
  1145. $description = str_replace( '[default_value_face]', $value['default']['face'], $description ); 
  1146. $description = str_replace( '[default_value_style]', $value['default']['style'], $description ); 
  1147. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1148. } elseif ( in_array( $value['type'], array( 'border', 'border_styles', 'border_corner' ) ) ) { 
  1149. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1150.  
  1151. if ( ! isset( $value['default']['width'] ) ) $value['default']['width'] = ''; 
  1152. if ( ! isset( $value['default']['style'] ) ) $value['default']['style'] = ''; 
  1153. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1154.  
  1155. if ( ! isset( $value['default']['corner'] ) ) $value['default']['corner'] = 'rounded'; 
  1156. if ( ! isset( $value['default']['rounded_value'] ) ) $value['default']['rounded_value'] = ''; 
  1157. if ( ! isset( $value['default']['top_left_corner'] ) ) $value['default']['top_left_corner'] = $value['default']['rounded_value']; 
  1158. if ( ! isset( $value['default']['top_right_corner'] ) ) $value['default']['top_right_corner'] = $value['default']['rounded_value']; 
  1159. if ( ! isset( $value['default']['bottom_left_corner'] ) ) $value['default']['bottom_left_corner'] = $value['default']['rounded_value']; 
  1160. if ( ! isset( $value['default']['bottom_right_corner'] ) ) $value['default']['bottom_right_corner'] = $value['default']['rounded_value']; 
  1161.  
  1162. $description = str_replace( '[default_value_width]', $value['default']['width'], $description ); 
  1163. $description = str_replace( '[default_value_style]', $value['default']['style'], $description ); 
  1164. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1165. $description = str_replace( '[default_value_rounded_value]', $value['default']['rounded_value'], $description ); 
  1166. $description = str_replace( '[default_value_top_left_corner]', $value['default']['top_left_corner'], $description ); 
  1167. $description = str_replace( '[default_value_top_right_corner]', $value['default']['top_right_corner'], $description ); 
  1168. $description = str_replace( '[default_value_bottom_left_corner]', $value['default']['bottom_left_corner'], $description ); 
  1169. $description = str_replace( '[default_value_bottom_right_corner]', $value['default']['bottom_right_corner'], $description ); 
  1170. } elseif ( $value['type'] == 'box_shadow' ) { 
  1171. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1172. if ( ! isset( $value['default']['enable'] ) || trim( $value['default']['enable'] ) == '' ) $value['default']['enable'] = 0; 
  1173. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1174. if ( ! isset( $value['default']['h_shadow'] ) || trim( $value['default']['h_shadow'] ) == '' ) $value['default']['h_shadow'] = '0px'; 
  1175. if ( ! isset( $value['default']['v_shadow'] ) || trim( $value['default']['v_shadow'] ) == '' ) $value['default']['v_shadow'] = '0px'; 
  1176. if ( ! isset( $value['default']['blur'] ) || trim( $value['default']['blur'] ) == '' ) $value['default']['blur'] = '0px'; 
  1177. if ( ! isset( $value['default']['spread'] ) || trim( $value['default']['spread'] ) == '' ) $value['default']['spread'] = '0px'; 
  1178. if ( ! isset( $value['default']['inset'] ) || trim( $value['default']['inset'] ) == '' ) $value['default']['inset'] = ''; 
  1179.  
  1180. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1181. $description = str_replace( '[default_value_h_shadow]', $value['default']['h_shadow'], $description ); 
  1182. $description = str_replace( '[default_value_v_shadow]', $value['default']['v_shadow'], $description ); 
  1183. $description = str_replace( '[default_value_blur]', $value['default']['blur'], $description ); 
  1184. $description = str_replace( '[default_value_spread]', $value['default']['spread'], $description ); 
  1185.  
  1186. } elseif ( $value['type'] == 'bg_color' ) { 
  1187. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  1188. if ( ! isset( $value['default']['enable'] ) || trim( $value['default']['enable'] ) == '' ) $value['default']['enable'] = 0; 
  1189. if ( ! isset( $value['default']['color'] ) || trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1190.  
  1191. $description = str_replace( '[default_value_color]', $value['default']['color'], $description ); 
  1192. } elseif ( $value['type'] != 'multiselect' ) { 
  1193. $description = str_replace( '[default_value]', $value['default'], $description ); 
  1194.  
  1195. if ( $tip && in_array( $value['type'], array( 'checkbox' ) ) ) { 
  1196.  
  1197. $tip = '<p class="description">' . $tip . '</p>'; 
  1198.  
  1199. } elseif ( $tip ) { 
  1200.  
  1201. $tip = '<div class="help_tip a3-plugin-ui-icon a3-plugin-ui-help-icon" data-tip="' . esc_attr( $tip ) . '"></div>'; 
  1202.  
  1203.  
  1204. // Remove [, ] characters from id argument 
  1205. $child_key = false; 
  1206. if ( strstr( $value['id'], '[' ) ) { 
  1207. parse_str( esc_attr( $value['id'] ), $option_array ); 
  1208.  
  1209. // Option name is first key 
  1210. $option_keys = array_keys( $option_array ); 
  1211. $first_key = current( $option_keys ); 
  1212.  
  1213. $id_attribute = $first_key; 
  1214.  
  1215. $child_key = key( $option_array[ $id_attribute ] ); 
  1216. } else { 
  1217. $id_attribute = esc_attr( $value['id'] ); 
  1218.  
  1219. // Get option value when option name is not parse or when it's spearate option 
  1220. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  1221. $option_value = $this->settings_get_option( $value['id'], $value['default'] ); 
  1222. // Get option value when it's an element from option array  
  1223. else { 
  1224. if ( $child_key != false ) { 
  1225. $option_value = ( isset( $option_values[ $id_attribute ][ $child_key ] ) ) ? $option_values[ $id_attribute ][ $child_key ] : $value['default']; 
  1226. } else { 
  1227. $option_value = ( isset( $option_values[ $id_attribute ] ) ) ? $option_values[ $id_attribute ] : $value['default']; 
  1228.  
  1229. // Generate name and id attributes 
  1230. if ( trim( $option_name ) == '' ) { 
  1231. $name_attribute = esc_attr( $value['id'] ); 
  1232. } elseif ( $value['separate_option'] != false ) { 
  1233. $name_attribute = esc_attr( $value['id'] ); 
  1234. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  1235. } else { 
  1236. // Array value 
  1237. if ( strstr( $value['id'], '[' ) ) { 
  1238. $name_attribute = esc_attr( $option_name ) . '[' . $id_attribute . ']' . str_replace( $id_attribute . '[', '[', esc_attr( $value['id'] ) ); 
  1239. } else { 
  1240. $name_attribute = esc_attr( $option_name ) . '[' . esc_attr( $value['id'] ) . ']'; 
  1241. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  1242.  
  1243. // Switch based on type 
  1244. switch( $value['type'] ) { 
  1245.  
  1246. // Heading 
  1247. case 'heading': 
  1248.  
  1249. $is_box = false; 
  1250. if ( isset( $value['is_box'] ) && true == $value['is_box'] ) { 
  1251. $is_box = true; 
  1252.  
  1253. $is_sub = false; 
  1254. if ( isset( $value['is_sub'] ) && true == $value['is_sub'] ) { 
  1255. $is_sub = true; 
  1256.  
  1257. $count_heading++; 
  1258. if ( $count_heading > 1 ) { 
  1259. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  1260. echo '</table>' . "\n\n"; 
  1261. echo '</div>' . "\n\n"; 
  1262. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' ); 
  1263. if ( ! empty( $value['id'] ) ) 
  1264. $end_heading_id = $value['id']; 
  1265. else 
  1266. $end_heading_id = ''; 
  1267.  
  1268. if ( $header_sub_box_opening ) { 
  1269. $header_sub_box_opening = false; 
  1270.  
  1271. // close box inside 
  1272. echo '</div>' . "\n\n"; 
  1273.  
  1274. // close panel box 
  1275. echo '</div>' . "\n\n"; 
  1276.  
  1277. if ( $is_box && $header_box_opening && ! $is_sub ) { 
  1278. $header_box_opening = false; 
  1279.  
  1280. // close box inside 
  1281. echo '</div>' . "\n\n"; 
  1282.  
  1283. // close panel box 
  1284. echo '</div>' . "\n\n"; 
  1285.  
  1286. $view_doc = ( isset( $value['view_doc'] ) ) ? $value['view_doc'] : ''; 
  1287.  
  1288. if ( ! empty( $value['id'] ) ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $value['id'] ) . '_before' ); 
  1289.  
  1290. if ( $is_box ) { 
  1291. $heading_box_id = $count_heading; 
  1292. if ( ! empty( $value['id'] ) ) { 
  1293. $heading_box_id = $value['id']; 
  1294.  
  1295. $toggle_box_class = 'enable_toggle_box_save'; 
  1296.  
  1297. $opened_class = ''; 
  1298. if ( in_array( $heading_box_id, $opened_box ) && 1 == $toggle_box_open ) { 
  1299. $opened_class = 'box_open'; 
  1300.  
  1301. if ( isset( $_POST['bt_save_settings']) && in_array( $heading_box_id, $opened_box ) ) { 
  1302. $opened_class = 'box_open'; 
  1303.  
  1304. // Change to open box for the heading set alway_open = true 
  1305. if ( isset( $value['alway_open'] ) && true == $value['alway_open'] ) { 
  1306. $opened_class = 'box_open'; 
  1307.  
  1308. // Change to close box for the heading set alway_close = true 
  1309. if ( isset( $value['alway_close'] ) && true == $value['alway_close'] ) { 
  1310. $opened_class = ''; 
  1311.  
  1312. // Make the box open on first load with this argument first_open = true 
  1313. if ( isset( $value['first_open'] ) && true == $value['first_open'] ) { 
  1314. $this_box_is_opened = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', true ); 
  1315. if ( empty( $this_box_is_opened ) ) { 
  1316. $opened_class = 'box_open'; 
  1317. add_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', 1 ); 
  1318.  
  1319. // open panel box 
  1320. echo '<div id="'. esc_attr( $value['id'] ) . '" class="a3rev_panel_box '. esc_attr( $value['class'] ) .'" style="'. esc_attr( $value['css'] ) .'">' . "\n\n"; 
  1321.  
  1322. // open box handle 
  1323. echo '<div data-form-key="'. esc_attr( trim( $form_key ) ) .'" data-box-id="'. esc_attr( $heading_box_id ) .'" class="a3rev_panel_box_handle" >' . "\n\n"; 
  1324.  
  1325. echo ( ! empty( $value['name'] ) ) ? '<h3 class="a3-plugin-ui-panel-box '. $toggle_box_class . ' ' . $opened_class . '">'. esc_html( $value['name'] ) .' '. $view_doc .'</h3>' : ''; 
  1326.  
  1327. if ( stristr( $value['class'], 'pro_feature_fields' ) !== false && ! empty( $value['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $value['id'] ) ); 
  1328. elseif ( stristr( $value['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  1329.  
  1330. // close box handle 
  1331. echo '</div>' . "\n\n"; 
  1332.  
  1333. // open box inside 
  1334. echo '<div id="'. esc_attr( $value['id'] ) . '_box_inside" class="a3rev_panel_box_inside '.$opened_class.'" >' . "\n\n"; 
  1335.  
  1336. echo '<div class="a3rev_panel_inner">' . "\n\n"; 
  1337.  
  1338. if ( $is_sub ) { 
  1339. // Mark this heading as a sub box is openning to check for close it on next header box 
  1340. $header_sub_box_opening = true; 
  1341. } else { 
  1342. // Mark this heading as a box is openning to check for close it on next header box 
  1343. $header_box_opening = true; 
  1344.  
  1345. } else { 
  1346. echo '<div id="'. esc_attr( $value['id'] ) . '" class="a3rev_panel_inner '. esc_attr( $value['class'] ) .'" style="'. esc_attr( $value['css'] ) .'">' . "\n\n"; 
  1347. if ( stristr( $value['class'], 'pro_feature_fields' ) !== false && ! empty( $value['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $value['id'] ) ); 
  1348. elseif ( stristr( $value['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  1349.  
  1350. echo ( ! empty( $value['name'] ) ) ? '<h3>'. esc_html( $value['name'] ) .' '. $view_doc .'</h3>' : ''; 
  1351.  
  1352. if ( ! empty( $value['desc'] ) ) { 
  1353. echo '<div class="a3rev_panel_box_description" >' . "\n\n"; 
  1354. echo wpautop( wptexturize( $value['desc'] ) ); 
  1355. echo '</div>' . "\n\n"; 
  1356.  
  1357. echo '<table class="form-table">' . "\n\n"; 
  1358.  
  1359. if ( ! empty( $value['id'] ) ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $value['id'] ) . '_start' ); 
  1360. break; 
  1361.  
  1362. // Google API Key input 
  1363. case 'google_api_key': 
  1364.  
  1365. $google_api_key = $this->settings_get_option( $this->google_api_key_option ); 
  1366. $google_api_key_enable = $this->settings_get_option( $this->google_api_key_option . '_enable', 0 ); 
  1367. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woo_dgallery' ); 
  1368. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woo_dgallery' ); 
  1369.  
  1370. ?><tr valign="top"> 
  1371. <th scope="row" class="titledesc"> 
  1372. <?php echo $tip; ?> 
  1373. <label for="<?php echo $this->google_api_key_option; ?>"><?php echo __( 'Google Fonts API', 'woo_dgallery' ); ?></label> 
  1374. </th> 
  1375. <td class="forminp forminp-onoff_checkbox forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1376. <input 
  1377. name="<?php echo $this->google_api_key_option; ?>_enable" 
  1378. id="<?php echo $this->google_api_key_option; ?>_enable" 
  1379. class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_google_api_key_enable" 
  1380. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1381. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1382. type="checkbox" 
  1383. value="1" 
  1384. <?php checked( $google_api_key_enable, 1 ); ?> 
  1385. /> <span class="description" style="margin-left:5px;"><?php echo __( 'ON to connect to Google Fonts API and have auto font updates direct from Google.', 'woo_dgallery' ); ?></span> 
  1386.  
  1387. <div> </div> 
  1388. <div class="a3rev-ui-google-api-key-container" style="<?php if( 1 != $google_api_key_enable ) { echo 'display: none;'; } ?>"> 
  1389. <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", 'woo_dgallery' ), 'https://developers.google.com/fonts/docs/developer_api#APIKey' ); ?></div> 
  1390. <div class="a3rev-ui-google-api-key-inside  
  1391. <?php 
  1392. if ( $wc_dgallery_fonts_face->is_valid_google_api_key() ) { 
  1393. echo 'a3rev-ui-google-valid-key'; 
  1394. } elseif ( '' != $google_api_key ) { 
  1395. echo 'a3rev-ui-google-unvalid-key'; 
  1396. ?> 
  1397. "> 
  1398. <input 
  1399. name="<?php echo $this->google_api_key_option; ?>" 
  1400. id="<?php echo $this->google_api_key_option; ?>" 
  1401. type="text" 
  1402. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1403. value="<?php echo esc_attr( $google_api_key ); ?>" 
  1404. class="a3rev-ui-text a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1405. placeholder="<?php echo __( 'Google Fonts API Key', 'woo_dgallery' ); ?>" 
  1406. <?php echo implode( ' ', $custom_attributes ); ?> 
  1407. /> 
  1408. <p class="a3rev-ui-google-valid-key-message"><?php echo __( 'Your Google API Key is valid and automatic font updates are enabled.', 'woo_dgallery' ); ?></p> 
  1409. <p class="a3rev-ui-google-unvalid-key-message"><?php echo __( 'Please enter a valid Google API Key.', 'woo_dgallery' ); ?></p> 
  1410. </div> 
  1411. </div> 
  1412. </td> 
  1413. </tr><?php 
  1414.  
  1415. break; 
  1416.  
  1417. // Manual Check New Version when click on the button instead of wait for daily 
  1418. case 'manual_check_version': 
  1419. $version_message = $this->get_version_message(); 
  1420. $new_version_class = ''; 
  1421. if ( '' != trim( $version_message ) ) { 
  1422. $new_version_class = 'a3rev-ui-new-version-message'; 
  1423.  
  1424. ?><tr valign="top"> 
  1425. <th scope="row" class="titledesc"> 
  1426. <?php echo $tip; ?> 
  1427. <label><?php echo __( 'Check New Version', 'woo_dgallery' ); ?></label> 
  1428. </th> 
  1429. <td class="forminp forminp-manual_check_version"> 
  1430. <?php echo $description; ?> 
  1431.  
  1432. <input 
  1433. data-transient-name="<?php echo $this->version_transient; ?>" 
  1434. name="<?php echo $this->plugin_name . '-check-version'; ?>" 
  1435. id="<?php echo $this->plugin_name . '-check-version'; ?>" 
  1436. class="button button-primary a3rev-ui-manual_check_version" 
  1437. type="button" 
  1438. value="<?php echo __( 'Check Now', 'woo_dgallery' ); ?>" 
  1439. /> <span class="a3rev-ui-version-checking"> </span> 
  1440. <p class="a3rev-ui-check-version-message <?php echo $new_version_class; ?>"><?php echo $version_message; ?></p> 
  1441.  
  1442. </td> 
  1443. </tr><?php 
  1444.  
  1445. break; 
  1446.  
  1447. // Toggle Box Open type 
  1448. case 'onoff_toggle_box' : 
  1449.  
  1450. $option_value = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  1451. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woo_dgallery' ); 
  1452. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woo_dgallery' ); 
  1453.  
  1454. ?><tr valign="top"> 
  1455. <th scope="row" class="titledesc"> 
  1456. <?php echo $tip; ?> 
  1457. <label for="<?php echo $this->toggle_box_open_option; ?>"><?php echo __( 'Open Box Display', 'woo_dgallery' ); ?></label> 
  1458. </th> 
  1459. <td class="forminp forminp-onoff_checkbox forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1460. <input 
  1461. name="<?php echo $this->toggle_box_open_option; ?>" 
  1462. id="<?php echo $this->toggle_box_open_option; ?>" 
  1463. class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_toggle_box <?php echo esc_attr( $value['class'] ); ?>" 
  1464. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1465. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1466. type="checkbox" 
  1467. value="1" 
  1468. <?php checked( $option_value, 1 ); ?> 
  1469. <?php echo implode( ' ', $custom_attributes ); ?> 
  1470. /> <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.', 'woo_dgallery' ); ?></span> 
  1471. </td> 
  1472. </tr><?php 
  1473. break; 
  1474.  
  1475. // Standard text inputs and subtypes like 'number' 
  1476. case 'text': 
  1477. case 'email': 
  1478. case 'number': 
  1479. case 'password' : 
  1480.  
  1481. $type = $value['type']; 
  1482.  
  1483. ?><tr valign="top"> 
  1484. <th scope="row" class="titledesc"> 
  1485. <?php echo $tip; ?> 
  1486. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1487. </th> 
  1488. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1489. <input 
  1490. name="<?php echo $name_attribute; ?>" 
  1491. id="<?php echo $id_attribute; ?>" 
  1492. type="<?php echo esc_attr( $type ); ?>" 
  1493. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1494. value="<?php echo esc_attr( $option_value ); ?>" 
  1495. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1496. placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" 
  1497. <?php echo implode( ' ', $custom_attributes ); ?> 
  1498. /> <?php echo $description; ?> 
  1499. </td> 
  1500. </tr><?php 
  1501. break; 
  1502.  
  1503. // Color 
  1504. case 'color' : 
  1505.  
  1506. if ( trim( $value['default'] ) == '' ) $value['default'] = '#515151'; 
  1507. $default_color = ' data-default-color="' . esc_attr( $value['default'] ) . '"'; 
  1508. if ( '' == trim( $option_value ) ) $option_value = 'transparent'; 
  1509.  
  1510. ?><tr valign="top"> 
  1511. <th scope="row" class="titledesc"> 
  1512. <?php echo $tip; ?> 
  1513. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1514. </th> 
  1515. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1516. <input 
  1517. name="<?php echo $name_attribute; ?>" 
  1518. id="<?php echo $id_attribute; ?>" 
  1519. type="text" 
  1520. value="<?php echo esc_attr( $option_value ); ?>" 
  1521. class="a3rev-color-picker" 
  1522. <?php echo $default_color; ?> 
  1523. /> <?php echo $description; ?> 
  1524. </td> 
  1525. </tr><?php 
  1526.  
  1527. break; 
  1528.  
  1529. // Background Color 
  1530. case 'bg_color' : 
  1531.  
  1532. if ( ! isset( $option_value['enable'] ) ) $option_value['enable'] = 0; 
  1533. $enable = $option_value['enable']; 
  1534.  
  1535. if ( trim( $value['default']['color'] ) == '' ) $value['default']['color'] = '#515151'; 
  1536. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  1537.  
  1538. $color = $option_value['color']; 
  1539. if ( '' == trim( $color ) ) $color = 'transparent'; 
  1540.  
  1541. ?><tr valign="top"> 
  1542. <th scope="row" class="titledesc"> 
  1543. <?php echo $tip; ?> 
  1544. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1545. </th> 
  1546. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1547. <input 
  1548. name="<?php echo $name_attribute; ?>[enable]" 
  1549. id="<?php echo $id_attribute; ?>" 
  1550. class="a3rev-ui-bg_color-enable a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  1551. checked_label="<?php _e( 'ON', 'woo_dgallery' ); ?>" 
  1552. unchecked_label="<?php _e( 'OFF', 'woo_dgallery' ); ?>" 
  1553. type="checkbox" 
  1554. value="1" 
  1555. <?php checked( 1, $enable ); ?> 
  1556. <?php echo implode( ' ', $custom_attributes ); ?> 
  1557. /> <?php echo $description; ?> 
  1558. <div style="clear:both;"></div> 
  1559. <div class="a3rev-ui-bg_color-enable-container"> 
  1560. <input 
  1561. name="<?php echo $name_attribute; ?>[color]" 
  1562. id="<?php echo $id_attribute; ?>-color" 
  1563. type="text" 
  1564. value="<?php echo esc_attr( $color ); ?>" 
  1565. class="a3rev-color-picker" 
  1566. <?php echo $default_color; ?> 
  1567. /> 
  1568. </div> 
  1569. </td> 
  1570. </tr><?php 
  1571.  
  1572. break; 
  1573.  
  1574. // Textarea 
  1575. case 'textarea': 
  1576.  
  1577. ?><tr valign="top"> 
  1578. <th scope="row" class="titledesc"> 
  1579. <?php echo $tip; ?> 
  1580. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1581. </th> 
  1582. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1583. <?php echo $description; ?> 
  1584.  
  1585. <textarea 
  1586. name="<?php echo $name_attribute; ?>" 
  1587. id="<?php echo $id_attribute; ?>" 
  1588. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1589. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1590. placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" 
  1591. <?php echo implode( ' ', $custom_attributes ); ?> 
  1592. ><?php echo esc_textarea( $option_value ); ?></textarea> 
  1593. </td> 
  1594. </tr><?php 
  1595. break; 
  1596.  
  1597. // Select boxes 
  1598. case 'select' : 
  1599. case 'multiselect' : 
  1600.  
  1601. if ( trim( $value['class'] ) == '' ) $value['class'] = 'chzn-select'; 
  1602. if ( is_rtl() ) { 
  1603. $value['class'] .= ' chzn-rtl'; 
  1604. if ( ! isset( $value['options'] ) ) $value['options'] = array(); 
  1605.  
  1606. ?><tr valign="top"> 
  1607. <th scope="row" class="titledesc"> 
  1608. <?php echo $tip; ?> 
  1609. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1610. </th> 
  1611. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1612. <select 
  1613. name="<?php echo $name_attribute; ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" 
  1614. id="<?php echo $id_attribute; ?>" 
  1615. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1616. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1617. data-placeholder="<?php echo esc_html( $value['placeholder'] ); ?>" 
  1618. <?php echo implode( ' ', $custom_attributes ); ?> 
  1619. <?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?> 
  1620. <?php 
  1621. if ( is_array( $value['options'] ) && count( $value['options'] ) > 0 ) { 
  1622. foreach ( $value['options'] as $key => $val ) { 
  1623. if ( is_array( $val ) ) { 
  1624. ?> 
  1625. <optgroup label="<?php echo esc_attr( $key ); ?>"> 
  1626. <?php 
  1627. foreach ( $val as $sub_key => $sub_val ) { 
  1628. ?> 
  1629. <option value="<?php echo esc_attr( $sub_key ); ?>" <?php 
  1630.  
  1631. if ( is_array( $option_value ) ) 
  1632. selected( in_array( $sub_key, $option_value ), true ); 
  1633. else 
  1634. selected( $option_value, $sub_key ); 
  1635.  
  1636. ?>><?php echo $sub_val ?></option> 
  1637. <?php 
  1638. ?> 
  1639. </optgroup> 
  1640. <?php 
  1641. } else { 
  1642. ?> 
  1643. <option value="<?php echo esc_attr( $key ); ?>" <?php 
  1644.  
  1645. if ( is_array( $option_value ) ) 
  1646. selected( in_array( $key, $option_value ), true ); 
  1647. else 
  1648. selected( $option_value, $key ); 
  1649.  
  1650. ?>><?php echo $val ?></option> 
  1651. <?php 
  1652. ?> 
  1653. </select> <?php echo $description; ?> 
  1654. </td> 
  1655. </tr><?php 
  1656. break; 
  1657.  
  1658. // Radio inputs 
  1659. case 'radio' : 
  1660.  
  1661. if ( ! isset( $value['options'] ) ) $value['options'] = array(); 
  1662.  
  1663. ?><tr valign="top"> 
  1664. <th scope="row" class="titledesc"> 
  1665. <?php echo $tip; ?> 
  1666. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1667. </th> 
  1668. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1669. <fieldset> 
  1670. <?php echo $description; ?> 
  1671. <ul> 
  1672. <?php 
  1673. if ( is_array( $value['options'] ) && count( $value['options'] ) > 0 ) { 
  1674. foreach ( $value['options'] as $val => $text ) { 
  1675. ?> 
  1676. <li> 
  1677. <label><input 
  1678. name="<?php echo $name_attribute; ?>" 
  1679. value="<?php echo $val; ?>" 
  1680. type="radio" 
  1681. style="<?php echo esc_attr( $value['css'] ); ?>" 
  1682. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $value['class'] ); ?>" 
  1683. <?php echo implode( ' ', $custom_attributes ); ?> 
  1684. <?php checked( $val, $option_value ); ?> 
  1685. /> <span class="description" style="margin-left:5px;"><?php echo $text ?></span></label> 
  1686. </li> 
  1687. <?php 
  1688. ?> 
  1689. </ul> 
  1690. </fieldset> 
  1691. </td> 
  1692. </tr><?php 
  1693. break; 
  1694.  
  1695. // OnOff Radio inputs 
  1696. case 'onoff_radio' : 
  1697.  
  1698. if ( ! isset( $value['onoff_options'] ) ) $value['onoff_options'] = array(); 
  1699.  
  1700. ?><tr valign="top"> 
  1701. <th scope="row" class="titledesc"> 
  1702. <?php echo $tip; ?> 
  1703. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1704. </th> 
  1705. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1706. <fieldset> 
  1707. <?php echo $description; ?> 
  1708. <ul> 
  1709. <?php 
  1710. if ( is_array( $value['onoff_options'] ) && count( $value['onoff_options'] ) > 0 ) { 
  1711. foreach ( $value['onoff_options'] as $i_option ) { 
  1712. if ( ! isset( $i_option['checked_label'] ) ) $i_option['checked_label'] = __( 'ON', 'woo_dgallery' ); 
  1713. if ( ! isset( $i_option['unchecked_label'] ) ) $i_option['unchecked_label'] = __( 'OFF', 'woo_dgallery' ); 
  1714. if ( ! isset( $i_option['val'] ) ) $i_option['val'] = 1; 
  1715. if ( ! isset( $i_option['text'] ) ) $i_option['text'] = ''; 
  1716. ?> 
  1717. <li> 
  1718. <input 
  1719. name="<?php echo $name_attribute; ?>" 
  1720. <?php if ( $i_option['val'] == $option_value ) echo ' checkbox-disabled="true" ' ; ?> 
  1721. class="a3rev-ui-onoff_radio <?php echo esc_attr( $value['class'] ); ?>" 
  1722. checked_label="<?php echo esc_html( $i_option['checked_label'] ); ?>" 
  1723. unchecked_label="<?php echo esc_html( $i_option['unchecked_label'] ); ?>" 
  1724. type="radio" 
  1725. value="<?php echo esc_attr( stripslashes( $i_option['val'] ) ); ?>" 
  1726. <?php checked( esc_attr( stripslashes( $i_option['val'] ) ), $option_value ); ?> 
  1727. <?php echo implode( ' ', $custom_attributes ); ?> 
  1728. /> <span class="description" style="margin-left:5px;"><?php echo $i_option['text'] ?></span> 
  1729. </li> 
  1730. <?php 
  1731. ?> 
  1732. </ul> 
  1733. </fieldset> 
  1734. </td> 
  1735. </tr><?php 
  1736. break; 
  1737.  
  1738. // Checkbox input 
  1739. case 'checkbox' : 
  1740.  
  1741. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  1742. if ( ! isset( $value['hide_if_checked'] ) ) $value['hide_if_checked'] = false; 
  1743. if ( ! isset( $value['show_if_checked'] ) ) $value['show_if_checked'] = false; 
  1744.  
  1745. if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'start' ) ) { 
  1746. ?> 
  1747. <tr valign="top" class="<?php 
  1748. if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked']=='yes') echo 'hidden_option'; 
  1749. if ( $value['hide_if_checked'] == 'option' ) echo 'hide_options_if_checked'; 
  1750. if ( $value['show_if_checked'] == 'option' ) echo 'show_options_if_checked'; 
  1751. ?>"> 
  1752. <th scope="row" class="titledesc"> 
  1753. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1754. </th> 
  1755. <td class="forminp forminp-checkbox"> 
  1756. <fieldset> 
  1757. <?php 
  1758. } else { 
  1759. ?> 
  1760. <fieldset class="<?php 
  1761. if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') echo 'hidden_option'; 
  1762. if ( $value['hide_if_checked'] == 'option') echo 'hide_options_if_checked'; 
  1763. if ( $value['show_if_checked'] == 'option') echo 'show_options_if_checked'; 
  1764. ?>"> 
  1765. <?php 
  1766.  
  1767. ?> 
  1768. <legend class="screen-reader-text"><span><?php echo esc_html( $value['name'] ) ?></span></legend> 
  1769.  
  1770. <label for="<?php echo $id_attribute; ?>"> 
  1771. <input 
  1772. name="<?php echo $name_attribute; ?>" 
  1773. id="<?php echo $id_attribute; ?>" 
  1774. type="checkbox" 
  1775. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  1776. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  1777. <?php echo implode( ' ', $custom_attributes ); ?> 
  1778. /> <?php echo $description; ?></label> <?php echo $tip; ?> 
  1779. <?php 
  1780.  
  1781. if ( ! isset( $value['checkboxgroup'] ) || ( isset( $value['checkboxgroup'] ) && $value['checkboxgroup'] == 'end' ) ) { 
  1782. ?> 
  1783. </fieldset> 
  1784. </td> 
  1785. </tr> 
  1786. <?php 
  1787. } else { 
  1788. ?> 
  1789. </fieldset> 
  1790. <?php 
  1791.  
  1792. break; 
  1793.  
  1794. // OnOff Checkbox input 
  1795. case 'onoff_checkbox' : 
  1796.  
  1797. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  1798. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woo_dgallery' ); 
  1799. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woo_dgallery' ); 
  1800.  
  1801. ?><tr valign="top"> 
  1802. <th scope="row" class="titledesc"> 
  1803. <?php echo $tip; ?> 
  1804. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1805. </th> 
  1806. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1807. <input 
  1808. name="<?php echo $name_attribute; ?>" 
  1809. id="<?php echo $id_attribute; ?>" 
  1810. class="a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  1811. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1812. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1813. type="checkbox" 
  1814. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  1815. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  1816. <?php echo implode( ' ', $custom_attributes ); ?> 
  1817. /> <?php echo $description; ?> 
  1818. </td> 
  1819. </tr><?php 
  1820.  
  1821. break; 
  1822.  
  1823. // Switcher Checkbox input 
  1824. case 'switcher_checkbox' : 
  1825.  
  1826. if ( ! isset( $value['checked_value'] ) ) $value['checked_value'] = 1; 
  1827. if ( ! isset( $value['checked_label'] ) ) $value['checked_label'] = __( 'ON', 'woo_dgallery' ); 
  1828. if ( ! isset( $value['unchecked_label'] ) ) $value['unchecked_label'] = __( 'OFF', 'woo_dgallery' ); 
  1829.  
  1830. ?><tr valign="top"> 
  1831. <th scope="row" class="titledesc"> 
  1832. <?php echo $tip; ?> 
  1833. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  1834. </th> 
  1835. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1836. <input 
  1837. name="<?php echo $name_attribute; ?>" 
  1838. id="<?php echo $id_attribute; ?>" 
  1839. class="a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  1840. checked_label="<?php echo esc_html( $value['checked_label'] ); ?>" 
  1841. unchecked_label="<?php echo esc_html( $value['unchecked_label'] ); ?>" 
  1842. type="checkbox" 
  1843. value="<?php echo esc_attr( stripslashes( $value['checked_value'] ) ); ?>" 
  1844. <?php checked( $option_value, esc_attr( stripslashes( $value['checked_value'] ) ) ); ?> 
  1845. <?php echo implode( ' ', $custom_attributes ); ?> 
  1846. /> <?php echo $description; ?> 
  1847. </td> 
  1848. </tr><?php 
  1849.  
  1850. break; 
  1851.  
  1852. // Image size settings 
  1853. case 'image_size' : 
  1854.  
  1855. $width = $option_value['width']; 
  1856. $height = $option_value['height']; 
  1857. $crop = checked( 1, $option_value['crop'], false ); 
  1858.  
  1859. ?><tr valign="top"> 
  1860. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  1861. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  1862.  
  1863. <label><?php _e( 'Width', 'woo_dgallery' ); ?> <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> 
  1864.  
  1865. <label><?php _e( 'Height', 'woo_dgallery' ); ?> <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> 
  1866.  
  1867. <label><?php _e( 'Hard Crop', 'woo_dgallery' ); ?> <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> 
  1868.  
  1869. </td> 
  1870. </tr><?php 
  1871. break; 
  1872.  
  1873. // Single page selects 
  1874. case 'single_select_page' : 
  1875.  
  1876. if ( trim( $value['class'] ) == '' ) $value['class'] = 'chzn-select-deselect'; 
  1877. if ( is_rtl() ) { 
  1878. $value['class'] .= ' chzn-rtl'; 
  1879.  
  1880. $args = array( 'name' => $name_attribute,  
  1881. 'id' => $id_attribute,  
  1882. 'sort_column' => 'menu_order',  
  1883. 'sort_order' => 'ASC',  
  1884. 'show_option_none' => ' ',  
  1885. 'class' => 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . $value['class'],  
  1886. 'echo' => false,  
  1887. 'selected' => absint( $option_value ) 
  1888. ); 
  1889.  
  1890. if( isset( $value['args'] ) ) 
  1891. $args = wp_parse_args( $value['args'], $args ); 
  1892.  
  1893. ?><tr valign="top"> 
  1894. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  1895. <td class="forminp"> 
  1896. <?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; ?> 
  1897. </td> 
  1898. </tr><?php 
  1899. break; 
  1900.  
  1901. // Font Control 
  1902. case 'typography': 
  1903.  
  1904. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  1905.  
  1906. if ( ! isset( $option_value['line_height'] ) ) { 
  1907. $option_value['line_height'] = '1.4em'; 
  1908.  
  1909. $size = $option_value['size']; 
  1910. $line_height = $option_value['line_height']; 
  1911. $face = $option_value['face']; 
  1912. $style = $option_value['style']; 
  1913. $color = $option_value['color']; 
  1914.  
  1915. ?><tr valign="top"> 
  1916. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  1917. <td class="forminp"> 
  1918. <?php echo $description; ?> 
  1919. <div class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-control"> 
  1920. <!-- Font Size --> 
  1921. <select 
  1922. name="<?php echo $name_attribute; ?>[size]" 
  1923. id="<?php echo $id_attribute; ?>-size" 
  1924. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-size chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  1925. <?php 
  1926. for ( $i = 6; $i <= 70; $i++ ) { 
  1927. ?> 
  1928. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  1929. selected( $size, $i.'px' ); 
  1930. ?>><?php echo esc_attr( $i ); ?>px</option> 
  1931. <?php 
  1932. ?> 
  1933. </select> 
  1934. <!-- Line Height --> 
  1935. <select 
  1936. name="<?php echo $name_attribute; ?>[line_height]" 
  1937. id="<?php echo $id_attribute; ?>-line_height" 
  1938. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-line_height chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  1939. <?php 
  1940. for ( $i = 0.6; $i <= 3.1; $i = $i + 0.1 ) { 
  1941. ?> 
  1942. <option value="<?php echo esc_attr( $i ); ?>em" <?php 
  1943. selected( $line_height, $i.'em' ); 
  1944. ?>><?php echo esc_attr( $i ); ?>em</option> 
  1945. <?php 
  1946. ?> 
  1947. </select> 
  1948. <!-- Font Face --> 
  1949. <select 
  1950. name="<?php echo $name_attribute; ?>[face]" 
  1951. id="<?php echo $id_attribute; ?>-face" 
  1952. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-face chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  1953. <optgroup label="<?php _e( '-- Default Fonts --', 'woo_dgallery' ); ?>"> 
  1954. <?php 
  1955. foreach ( $wc_dgallery_fonts_face->get_default_fonts() as $val => $text ) { 
  1956. ?> 
  1957. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  1958. selected( esc_attr( $val ), esc_attr( $face ) ); 
  1959. ?>><?php echo esc_attr( $text ); ?></option> 
  1960. <?php 
  1961. ?> 
  1962. </optgroup> 
  1963. <optgroup label="<?php _e( '-- Google Fonts --', 'woo_dgallery' ); ?>"> 
  1964. <?php 
  1965. foreach ( $wc_dgallery_fonts_face->get_google_fonts() as $font ) { 
  1966. ?> 
  1967. <option value="<?php echo esc_attr( $font['name'] ); ?>" <?php 
  1968. selected( esc_attr( $font['name'] ), esc_attr( $face ) ); 
  1969. ?>><?php echo esc_attr( $font['name'] ); ?></option> 
  1970. <?php 
  1971. ?> 
  1972. </optgroup> 
  1973. </select>  
  1974.  
  1975. <!-- Font Weight --> 
  1976. <select 
  1977. name="<?php echo $name_attribute; ?>[style]" 
  1978. id="<?php echo $id_attribute; ?>-style" 
  1979. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  1980. <?php 
  1981. foreach ( $this->get_font_weights() as $val => $text ) { 
  1982. ?> 
  1983. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  1984. selected( esc_attr( $val ), esc_attr( $style ) ); 
  1985. ?>><?php echo esc_attr( $text ); ?></option> 
  1986. <?php 
  1987. ?> 
  1988. </select> 
  1989.  
  1990. <!-- Font Color --> 
  1991. <input 
  1992. name="<?php echo $name_attribute; ?>[color]" 
  1993. id="<?php echo $id_attribute; ?>-color" 
  1994. type="text" 
  1995. value="<?php echo esc_attr( $color ); ?>" 
  1996. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?>-color a3rev-color-picker" 
  1997. <?php echo $default_color; ?> 
  1998. />  
  1999.  
  2000. <!-- Preview Button --> 
  2001. <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', 'woo_dgallery'); ?>"><span> </span></a></div> 
  2002.  
  2003. </div> 
  2004.  
  2005. </td> 
  2006. </tr><?php 
  2007.  
  2008. break; 
  2009.  
  2010. // Border Styles & Corner Control 
  2011. case 'border': 
  2012.  
  2013. if ( ! is_array( $value['default'] ) ) $value['default'] = array(); 
  2014.  
  2015. // For Border Styles 
  2016. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2017.  
  2018. $width = $option_value['width']; 
  2019. $style = $option_value['style']; 
  2020. $color = $option_value['color']; 
  2021.  
  2022. // For Border Corner 
  2023. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2024. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2025. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2026.  
  2027. if ( ! isset( $option_value['corner'] ) ) $option_value['corner'] = ''; 
  2028. $corner = $option_value['corner']; 
  2029.  
  2030. if ( ! isset( $option_value['rounded_value'] ) ) $option_value['rounded_value'] = 3; 
  2031. $rounded_value = $option_value['rounded_value']; 
  2032.  
  2033. if ( ! isset( $option_value['top_left_corner'] ) ) $option_value['top_left_corner'] = 3; 
  2034. $top_left_corner = $option_value['top_left_corner']; 
  2035.  
  2036. if ( ! isset( $option_value['top_right_corner'] ) ) $option_value['top_right_corner'] = 3; 
  2037. $top_right_corner = $option_value['top_right_corner']; 
  2038.  
  2039. if ( ! isset( $option_value['bottom_left_corner'] ) ) $option_value['bottom_left_corner'] = 3; 
  2040. $bottom_left_corner = $option_value['bottom_left_corner']; 
  2041.  
  2042. if ( ! isset( $option_value['bottom_right_corner'] ) ) $option_value['bottom_right_corner'] = 3; 
  2043. $bottom_right_corner = $option_value['bottom_right_corner']; 
  2044.  
  2045. if ( trim( $rounded_value ) == '' || trim( $rounded_value ) <= 0 ) $rounded_value = $value['min']; 
  2046. $rounded_value = intval( $rounded_value ); 
  2047.  
  2048. if ( trim( $top_left_corner ) == '' || trim( $top_left_corner ) <= 0 ) $top_left_corner = $rounded_value; 
  2049. $top_left_corner = intval( $top_left_corner ); 
  2050.  
  2051. if ( trim( $top_right_corner ) == '' || trim( $top_right_corner ) <= 0 ) $top_right_corner = $rounded_value; 
  2052. $top_right_corner = intval( $top_right_corner ); 
  2053.  
  2054. if ( trim( $bottom_left_corner ) == '' || trim( $bottom_left_corner ) <= 0 ) $bottom_left_corner = $rounded_value; 
  2055. $bottom_left_corner = intval( $bottom_left_corner ); 
  2056.  
  2057. if ( trim( $bottom_right_corner ) == '' || trim( $bottom_right_corner ) <= 0 ) $bottom_right_corner = $rounded_value; 
  2058. $bottom_right_corner = intval( $bottom_right_corner ); 
  2059.  
  2060. ?><tr valign="top"> 
  2061. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2062. <td class="forminp forminp-border_corner"> 
  2063. <?php echo $description; ?> 
  2064. <div class="a3rev-ui-settings-control"> 
  2065. <!-- Border Width --> 
  2066. <select 
  2067. name="<?php echo $name_attribute; ?>[width]" 
  2068. id="<?php echo $id_attribute; ?>-width" 
  2069. class="a3rev-ui-border_styles-width chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2070. <?php 
  2071. for ( $i = 0; $i <= 20; $i++ ) { 
  2072. ?> 
  2073. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2074. selected( $width, $i.'px' ); 
  2075. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2076. <?php 
  2077. ?> 
  2078. </select>  
  2079.  
  2080. <!-- Border Style --> 
  2081. <select 
  2082. name="<?php echo $name_attribute; ?>[style]" 
  2083. id="<?php echo $id_attribute; ?>-style" 
  2084. class="a3rev-ui-border_styles-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2085. <?php 
  2086. foreach ( $this->get_border_styles() as $val => $text ) { 
  2087. ?> 
  2088. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2089. selected( esc_attr( $val ), esc_attr( $style ) ); 
  2090. ?>><?php echo esc_attr( $text ); ?></option> 
  2091. <?php 
  2092. ?> 
  2093. </select> 
  2094.  
  2095. <!-- Border Color --> 
  2096. <input 
  2097. name="<?php echo $name_attribute; ?>[color]" 
  2098. id="<?php echo $id_attribute; ?>-color" 
  2099. type="text" 
  2100. value="<?php echo esc_attr( $color ); ?>" 
  2101. class="a3rev-ui-border_styles-color a3rev-color-picker" 
  2102. <?php echo $default_color; ?> 
  2103. /> 
  2104.  
  2105. <!-- Preview Button --> 
  2106. <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', 'woo_dgallery'); ?>"><span> </span></a></div> 
  2107.  
  2108. <div style="clear:both; margin-bottom:10px"></div> 
  2109.  
  2110. <!-- Border Corner : Rounded or Square --> 
  2111. <input 
  2112. name="<?php echo $name_attribute; ?>[corner]" 
  2113. id="<?php echo $id_attribute; ?>" 
  2114. class="a3rev-ui-border-corner a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2115. checked_label="<?php _e( 'Rounded', 'woo_dgallery' ); ?>" 
  2116. unchecked_label="<?php _e( 'Square', 'woo_dgallery' ); ?>" 
  2117. type="checkbox" 
  2118. value="rounded" 
  2119. <?php checked( 'rounded', $corner ); ?> 
  2120. <?php echo implode( ' ', $custom_attributes ); ?> 
  2121. />  
  2122.  
  2123. <!-- Border Rounded Value --> 
  2124. <div class="a3rev-ui-border-corner-value-container"> 
  2125. <div class="a3rev-ui-border_corner-top_left"> 
  2126. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Left Corner', 'woo_dgallery' ); ?></span> 
  2127. <div class="a3rev-ui-slide-container"> 
  2128. <div class="a3rev-ui-slide-container-start"> 
  2129. <div class="a3rev-ui-slide-container-end"> 
  2130. <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> 
  2131. </div> 
  2132. </div> 
  2133. <div class="a3rev-ui-slide-result-container"> 
  2134. <input 
  2135. readonly="readonly" 
  2136. name="<?php echo $name_attribute; ?>[top_left_corner]" 
  2137. id="<?php echo $id_attribute; ?>-top_left_corner" 
  2138. type="text" 
  2139. value="<?php echo esc_attr( $top_left_corner ); ?>" 
  2140. class="a3rev-ui-border_top_left_corner a3rev-ui-slider" 
  2141. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2142. </div> 
  2143. </div> 
  2144. </div> 
  2145. <div class="a3rev-ui-border_corner-top_right"> 
  2146. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Right Corner', 'woo_dgallery' ); ?></span>  
  2147. <div class="a3rev-ui-slide-container"> 
  2148. <div class="a3rev-ui-slide-container-start"> 
  2149. <div class="a3rev-ui-slide-container-end"> 
  2150. <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> 
  2151. </div> 
  2152. </div> 
  2153. <div class="a3rev-ui-slide-result-container"> 
  2154. <input 
  2155. readonly="readonly" 
  2156. name="<?php echo $name_attribute; ?>[top_right_corner]" 
  2157. id="<?php echo $id_attribute; ?>-top_right_corner" 
  2158. type="text" 
  2159. value="<?php echo esc_attr( $top_right_corner ); ?>" 
  2160. class="a3rev-ui-border_top_right_corner a3rev-ui-slider" 
  2161. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2162. </div> 
  2163. </div> 
  2164. </div> 
  2165. <div class="a3rev-ui-border_corner-bottom_right"> 
  2166. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Right Corner', 'woo_dgallery' ); ?></span>  
  2167. <div class="a3rev-ui-slide-container"> 
  2168. <div class="a3rev-ui-slide-container-start"> 
  2169. <div class="a3rev-ui-slide-container-end"> 
  2170. <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> 
  2171. </div> 
  2172. </div> 
  2173. <div class="a3rev-ui-slide-result-container"> 
  2174. <input 
  2175. readonly="readonly" 
  2176. name="<?php echo $name_attribute; ?>[bottom_right_corner]" 
  2177. id="<?php echo $id_attribute; ?>-bottom_right_corner" 
  2178. type="text" 
  2179. value="<?php echo esc_attr( $bottom_right_corner ); ?>" 
  2180. class="a3rev-ui-border_bottom_right_corner a3rev-ui-slider" 
  2181. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2182. </div> 
  2183. </div> 
  2184. </div> 
  2185. <div class="a3rev-ui-border_corner-bottom_left"> 
  2186. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Left Corner', 'woo_dgallery' ); ?></span> 
  2187. <div class="a3rev-ui-slide-container">  
  2188. <div class="a3rev-ui-slide-container-start"> 
  2189. <div class="a3rev-ui-slide-container-end"> 
  2190. <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> 
  2191. </div> 
  2192. </div> 
  2193. <div class="a3rev-ui-slide-result-container"> 
  2194. <input 
  2195. readonly="readonly" 
  2196. name="<?php echo $name_attribute; ?>[bottom_left_corner]" 
  2197. id="<?php echo $id_attribute; ?>-bottom_left_corner" 
  2198. type="text" 
  2199. value="<?php echo esc_attr( $bottom_left_corner ); ?>" 
  2200. class="a3rev-ui-border_bottom_left_corner a3rev-ui-slider" 
  2201. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2202. </div> 
  2203. </div> 
  2204. </div> 
  2205. </div> 
  2206. <div style="clear:both"></div> 
  2207. </div> 
  2208.  
  2209. </td> 
  2210. </tr><?php 
  2211.  
  2212. break; 
  2213.  
  2214. // Border Style Control 
  2215. case 'border_styles': 
  2216.  
  2217. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2218.  
  2219. $width = $option_value['width']; 
  2220. $style = $option_value['style']; 
  2221. $color = $option_value['color']; 
  2222.  
  2223. ?><tr valign="top"> 
  2224. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2225. <td class="forminp"> 
  2226. <?php echo $description; ?> 
  2227. <div class="a3rev-ui-settings-control"> 
  2228. <!-- Border Width --> 
  2229. <select 
  2230. name="<?php echo $name_attribute; ?>[width]" 
  2231. id="<?php echo $id_attribute; ?>-width" 
  2232. class="a3rev-ui-border_styles-width chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2233. <?php 
  2234. for ( $i = 0; $i <= 20; $i++ ) { 
  2235. ?> 
  2236. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2237. selected( $width, $i.'px' ); 
  2238. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2239. <?php 
  2240. ?> 
  2241. </select>  
  2242.  
  2243. <!-- Border Style --> 
  2244. <select 
  2245. name="<?php echo $name_attribute; ?>[style]" 
  2246. id="<?php echo $id_attribute; ?>-style" 
  2247. class="a3rev-ui-border_styles-style chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2248. <?php 
  2249. foreach ( $this->get_border_styles() as $val => $text ) { 
  2250. ?> 
  2251. <option value="<?php echo esc_attr( $val ); ?>" <?php 
  2252. selected( esc_attr( $val ), esc_attr( $style ) ); 
  2253. ?>><?php echo esc_attr( $text ); ?></option> 
  2254. <?php 
  2255. ?> 
  2256. </select> 
  2257.  
  2258. <!-- Border Color --> 
  2259. <input 
  2260. name="<?php echo $name_attribute; ?>[color]" 
  2261. id="<?php echo $id_attribute; ?>-color" 
  2262. type="text" 
  2263. value="<?php echo esc_attr( $color ); ?>" 
  2264. class="a3rev-ui-border_styles-color a3rev-color-picker" 
  2265. <?php echo $default_color; ?> 
  2266. /> 
  2267.  
  2268. <!-- Preview Button --> 
  2269. <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', 'woo_dgallery'); ?>"><span> </span></a></div> 
  2270. </div> 
  2271.  
  2272. </td> 
  2273. </tr><?php 
  2274.  
  2275. break; 
  2276.  
  2277. // Border Rounded Corners Control 
  2278. case 'border_corner': 
  2279.  
  2280. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2281. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2282. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2283.  
  2284. if ( ! isset( $option_value['corner'] ) ) $option_value['corner'] = ''; 
  2285. $corner = $option_value['corner']; 
  2286.  
  2287. if ( ! isset( $option_value['rounded_value'] ) ) $option_value['rounded_value'] = 3; 
  2288. $rounded_value = $option_value['rounded_value']; 
  2289.  
  2290. if ( ! isset( $option_value['top_left_corner'] ) ) $option_value['top_left_corner'] = 3; 
  2291. $top_left_corner = $option_value['top_left_corner']; 
  2292.  
  2293. if ( ! isset( $option_value['top_right_corner'] ) ) $option_value['top_right_corner'] = 3; 
  2294. $top_right_corner = $option_value['top_right_corner']; 
  2295.  
  2296. if ( ! isset( $option_value['bottom_left_corner'] ) ) $option_value['bottom_left_corner'] = 3; 
  2297. $bottom_left_corner = $option_value['bottom_left_corner']; 
  2298.  
  2299. if ( ! isset( $option_value['bottom_right_corner'] ) ) $option_value['bottom_right_corner'] = 3; 
  2300. $bottom_right_corner = $option_value['bottom_right_corner']; 
  2301.  
  2302. if ( trim( $rounded_value ) == '' || trim( $rounded_value ) <= 0 ) $rounded_value = $value['min']; 
  2303. $rounded_value = intval( $rounded_value ); 
  2304.  
  2305. if ( trim( $top_left_corner ) == '' || trim( $top_left_corner ) <= 0 ) $top_left_corner = $rounded_value; 
  2306. $top_left_corner = intval( $top_left_corner ); 
  2307.  
  2308. if ( trim( $top_right_corner ) == '' || trim( $top_right_corner ) <= 0 ) $top_right_corner = $rounded_value; 
  2309. $top_right_corner = intval( $top_right_corner ); 
  2310.  
  2311. if ( trim( $bottom_left_corner ) == '' || trim( $bottom_left_corner ) <= 0 ) $bottom_left_corner = $rounded_value; 
  2312. $bottom_left_corner = intval( $bottom_left_corner ); 
  2313.  
  2314. if ( trim( $bottom_right_corner ) == '' || trim( $bottom_right_corner ) <= 0 ) $bottom_right_corner = $rounded_value; 
  2315. $bottom_right_corner = intval( $bottom_right_corner ); 
  2316.  
  2317. ?><tr valign="top"> 
  2318. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2319. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2320. <?php echo $description; ?> 
  2321. <div class="a3rev-ui-settings-control">  
  2322. <!-- Border Corner : Rounded or Square --> 
  2323. <input 
  2324. name="<?php echo $name_attribute; ?>[corner]" 
  2325. id="<?php echo $id_attribute; ?>" 
  2326. class="a3rev-ui-border-corner a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2327. checked_label="<?php _e( 'Rounded', 'woo_dgallery' ); ?>" 
  2328. unchecked_label="<?php _e( 'Square', 'woo_dgallery' ); ?>" 
  2329. type="checkbox" 
  2330. value="rounded" 
  2331. <?php checked( 'rounded', $corner ); ?> 
  2332. <?php echo implode( ' ', $custom_attributes ); ?> 
  2333. />  
  2334.  
  2335. <!-- Preview Button --> 
  2336. <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', 'woo_dgallery'); ?>"><span> </span></a></div> 
  2337.  
  2338. <!-- Border Rounded Value --> 
  2339. <div class="a3rev-ui-border-corner-value-container"> 
  2340. <div class="a3rev-ui-border_corner-top_left"> 
  2341. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Left Corner', 'woo_dgallery' ); ?></span> 
  2342. <div class="a3rev-ui-slide-container"> 
  2343. <div class="a3rev-ui-slide-container-start"> 
  2344. <div class="a3rev-ui-slide-container-end"> 
  2345. <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> 
  2346. </div> 
  2347. </div> 
  2348. <div class="a3rev-ui-slide-result-container"> 
  2349. <input 
  2350. readonly="readonly" 
  2351. name="<?php echo $name_attribute; ?>[top_left_corner]" 
  2352. id="<?php echo $id_attribute; ?>-top_left_corner" 
  2353. type="text" 
  2354. value="<?php echo esc_attr( $top_left_corner ); ?>" 
  2355. class="a3rev-ui-border_top_left_corner a3rev-ui-slider" 
  2356. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2357. </div> 
  2358. </div> 
  2359. </div> 
  2360. <div class="a3rev-ui-border_corner-top_right"> 
  2361. <span class="a3rev-ui-border_corner-span"><?php _e( 'Top Right Corner', 'woo_dgallery' ); ?></span> 
  2362. <div class="a3rev-ui-slide-container">  
  2363. <div class="a3rev-ui-slide-container-start"> 
  2364. <div class="a3rev-ui-slide-container-end"> 
  2365. <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> 
  2366. </div> 
  2367. </div> 
  2368. <div class="a3rev-ui-slide-result-container"> 
  2369. <input 
  2370. readonly="readonly" 
  2371. name="<?php echo $name_attribute; ?>[top_right_corner]" 
  2372. id="<?php echo $id_attribute; ?>-top_right_corner" 
  2373. type="text" 
  2374. value="<?php echo esc_attr( $top_right_corner ); ?>" 
  2375. class="a3rev-ui-border_top_right_corner a3rev-ui-slider" 
  2376. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2377. </div> 
  2378. </div> 
  2379. </div> 
  2380. <div class="a3rev-ui-border_corner-bottom_right"> 
  2381. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Right Corner', 'woo_dgallery' ); ?></span> 
  2382. <div class="a3rev-ui-slide-container">  
  2383. <div class="a3rev-ui-slide-container-start"> 
  2384. <div class="a3rev-ui-slide-container-end"> 
  2385. <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> 
  2386. </div> 
  2387. </div> 
  2388. <div class="a3rev-ui-slide-result-container"> 
  2389. <input 
  2390. readonly="readonly" 
  2391. name="<?php echo $name_attribute; ?>[bottom_right_corner]" 
  2392. id="<?php echo $id_attribute; ?>-bottom_right_corner" 
  2393. type="text" 
  2394. value="<?php echo esc_attr( $bottom_right_corner ); ?>" 
  2395. class="a3rev-ui-border_bottom_right_corner a3rev-ui-slider" 
  2396. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2397. </div> 
  2398. </div> 
  2399. </div> 
  2400. <div class="a3rev-ui-border_corner-bottom_left"> 
  2401. <span class="a3rev-ui-border_corner-span"><?php _e( 'Bottom Left Corner', 'woo_dgallery' ); ?></span>  
  2402. <div class="a3rev-ui-slide-container"> 
  2403. <div class="a3rev-ui-slide-container-start"> 
  2404. <div class="a3rev-ui-slide-container-end"> 
  2405. <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> 
  2406. </div> 
  2407. </div> 
  2408. <div class="a3rev-ui-slide-result-container"> 
  2409. <input 
  2410. readonly="readonly" 
  2411. name="<?php echo $name_attribute; ?>[bottom_left_corner]" 
  2412. id="<?php echo $id_attribute; ?>-bottom_left_corner" 
  2413. type="text" 
  2414. value="<?php echo esc_attr( $bottom_left_corner ); ?>" 
  2415. class="a3rev-ui-border_bottom_left_corner a3rev-ui-slider" 
  2416. /> <span class="a3rev-ui-border_corner-px">px</span> 
  2417. </div> 
  2418. </div> 
  2419. </div> 
  2420. </div> 
  2421. <div style="clear:both"></div> 
  2422. </div> 
  2423. <div style="clear:both"></div> 
  2424. </td> 
  2425. </tr><?php 
  2426.  
  2427. break; 
  2428.  
  2429. // Box Shadow Control 
  2430. case 'box_shadow': 
  2431.  
  2432. $default_color = ' data-default-color="' . esc_attr( $value['default']['color'] ) . '"'; 
  2433.  
  2434. if ( ! isset( $option_value['enable'] ) ) $option_value['enable'] = 0; 
  2435. $enable = $option_value['enable']; 
  2436. if ( ! isset( $option_value['inset'] ) ) $option_value['inset'] = ''; 
  2437. $h_shadow = $option_value['h_shadow']; 
  2438. $v_shadow = $option_value['v_shadow']; 
  2439. $blur = $option_value['blur']; 
  2440. $spread = $option_value['spread']; 
  2441. $color = $option_value['color']; 
  2442. $inset = $option_value['inset']; 
  2443.  
  2444. ?><tr valign="top"> 
  2445. <th scope="row" class="titledesc"><?php echo $tip; ?><?php echo esc_html( $value['name'] ) ?></th> 
  2446. <td class="forminp forminp-box_shadow"> 
  2447. <?php echo $description; ?> 
  2448. <input 
  2449. name="<?php echo $name_attribute; ?>[enable]" 
  2450. id="<?php echo $id_attribute; ?>" 
  2451. class="a3rev-ui-box_shadow-enable a3rev-ui-onoff_checkbox <?php echo esc_attr( $value['class'] ); ?>" 
  2452. checked_label="<?php _e( 'ON', 'woo_dgallery' ); ?>" 
  2453. unchecked_label="<?php _e( 'OFF', 'woo_dgallery' ); ?>" 
  2454. type="checkbox" 
  2455. value="1" 
  2456. <?php checked( 1, $enable ); ?> 
  2457. <?php echo implode( ' ', $custom_attributes ); ?> 
  2458. /> 
  2459. <div style="clear:both;"></div>  
  2460. <div class="a3rev-ui-box_shadow-enable-container"> 
  2461. <div class="a3rev-ui-settings-control"> 
  2462. <!-- Box Horizontal Shadow Size --> 
  2463. <select 
  2464. name="<?php echo $name_attribute; ?>[h_shadow]" 
  2465. id="<?php echo $id_attribute; ?>-h_shadow" 
  2466. class="a3rev-ui-box_shadow-h_shadow chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2467. data-placeholder="<?php _e( 'Horizontal Shadow', 'woo_dgallery' ); ?>" 
  2468. <?php 
  2469. for ( $i = -20; $i <= 20; $i++ ) { 
  2470. ?> 
  2471. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2472. selected( $h_shadow, $i.'px' ); 
  2473. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2474. <?php 
  2475. ?> 
  2476. </select>  
  2477.  
  2478. <!-- Box Vertical Shadow Size --> 
  2479. <select 
  2480. name="<?php echo $name_attribute; ?>[v_shadow]" 
  2481. id="<?php echo $id_attribute; ?>-v_shadow" 
  2482. class="a3rev-ui-box_shadow-v_shadow chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2483. data-placeholder="<?php _e( 'Vertical Shadow', 'woo_dgallery' ); ?>" 
  2484. <?php 
  2485. for ( $i = -20; $i <= 20; $i++ ) { 
  2486. ?> 
  2487. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2488. selected( $v_shadow, $i.'px' ); 
  2489. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2490. <?php 
  2491. ?> 
  2492. </select>  
  2493.  
  2494. <!-- Box Blur Distance --> 
  2495. <select 
  2496. name="<?php echo $name_attribute; ?>[blur]" 
  2497. id="<?php echo $id_attribute; ?>-blur" 
  2498. class="a3rev-ui-box_shadow-blur chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2499. data-placeholder="<?php _e( 'Blur Distance', 'woo_dgallery' ); ?>" 
  2500. <?php 
  2501. for ( $i = 0; $i <= 20; $i++ ) { 
  2502. ?> 
  2503. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2504. selected( $blur, $i.'px' ); 
  2505. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2506. <?php 
  2507. ?> 
  2508. </select>  
  2509.  
  2510. <!-- Box Spread --> 
  2511. <select 
  2512. name="<?php echo $name_attribute; ?>[spread]" 
  2513. id="<?php echo $id_attribute; ?>-spread" 
  2514. class="a3rev-ui-box_shadow-spread chzn-select <?php if ( is_rtl() ) { echo 'chzn-rtl'; } ?>" 
  2515. data-placeholder="<?php _e( 'Spread Size', 'woo_dgallery' ); ?>" 
  2516. <?php 
  2517. for ( $i = 0; $i <= 20; $i++ ) { 
  2518. ?> 
  2519. <option value="<?php echo esc_attr( $i ); ?>px" <?php 
  2520. selected( $spread, $i.'px' ); 
  2521. ?>><?php echo esc_attr( $i ); ?>px</option> 
  2522. <?php 
  2523. ?> 
  2524. </select>  
  2525.  
  2526. <!-- Box Shadow Inset --> 
  2527. <input 
  2528. name="<?php echo $name_attribute; ?>[inset]" 
  2529. id="<?php echo $id_attribute; ?>" 
  2530. class="a3rev-ui-box_shadow-inset a3rev-ui-onoff_checkbox" 
  2531. checked_label="<?php _e( 'INNER', 'woo_dgallery' ); ?>" 
  2532. unchecked_label="<?php _e( 'OUTER', 'woo_dgallery' ); ?>" 
  2533. type="checkbox" 
  2534. value="inset" 
  2535. <?php checked( 'inset', $inset ); ?> 
  2536. <?php echo implode( ' ', $custom_attributes ); ?> 
  2537. />  
  2538.  
  2539. <!-- Box Shadow Color --> 
  2540. <input 
  2541. name="<?php echo $name_attribute; ?>[color]" 
  2542. id="<?php echo $id_attribute; ?>-color" 
  2543. type="text" 
  2544. value="<?php echo esc_attr( $color ); ?>" 
  2545. class="a3rev-ui-box_shadow-color a3rev-color-picker" 
  2546. <?php echo $default_color; ?> 
  2547. /> 
  2548.  
  2549. <!-- Preview Button --> 
  2550. <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', 'woo_dgallery'); ?>"><span> </span></a></div>  
  2551. </div> 
  2552. <div style="clear:both;"></div> 
  2553. </div> 
  2554. </td> 
  2555. </tr><?php 
  2556.  
  2557. break; 
  2558.  
  2559. // Slider Control 
  2560. case 'slider': 
  2561.  
  2562. if ( ! isset( $value['min'] ) ) $value['min'] = 0; 
  2563. if ( ! isset( $value['max'] ) ) $value['max'] = 100; 
  2564. if ( ! isset( $value['increment'] ) ) $value['increment'] = 1; 
  2565. if ( trim( $option_value ) == '' || trim( $option_value ) <= 0 ) $option_value = $value['min']; 
  2566. $option_value = intval( $option_value ); 
  2567.  
  2568. ?><tr valign="top"> 
  2569. <th scope="row" class="titledesc"> 
  2570. <?php echo $tip; ?> 
  2571. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2572. </th> 
  2573. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2574. <div class="a3rev-ui-slide-container"> 
  2575. <div class="a3rev-ui-slide-container-start"><div class="a3rev-ui-slide-container-end"> 
  2576. <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> 
  2577. </div></div> 
  2578. <div class="a3rev-ui-slide-result-container"> 
  2579. <input 
  2580. readonly="readonly" 
  2581. name="<?php echo $name_attribute; ?>" 
  2582. id="<?php echo $id_attribute; ?>" 
  2583. type="text" 
  2584. value="<?php echo esc_attr( $option_value ); ?>" 
  2585. class="a3rev-ui-slider" 
  2586. <?php echo implode( ' ', $custom_attributes ); ?> 
  2587. /> <?php echo $description; ?> 
  2588. </div> 
  2589. </div> 
  2590. </td> 
  2591. </tr><?php 
  2592.  
  2593. break; 
  2594.  
  2595. // Upload Control 
  2596. case 'upload': 
  2597.  
  2598. $class = 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . esc_attr( $value['class'] ); 
  2599.  
  2600. $strip_methods = true; 
  2601. if ( isset( $value['strip_methods'] ) ) { 
  2602. $strip_methods = $value['strip_methods']; 
  2603.  
  2604. if ( strstr( $name_attribute, ']' ) ) { 
  2605. $attachment_id_name_attribute = substr_replace( $name_attribute, '_attachment_id', -1, 0 ); 
  2606. } else { 
  2607. $attachment_id_name_attribute = $name_attribute.'_attachment_id'; 
  2608. $attachment_id = $this->settings_get_option( $attachment_id_name_attribute, 0 ); 
  2609.  
  2610. ?><tr valign="top"> 
  2611. <th scope="row" class="titledesc"> 
  2612. <?php echo $tip; ?> 
  2613. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2614. </th> 
  2615. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2616. <?php echo $description; ?> 
  2617. <?php echo $wc_dgallery_uploader->upload_input( $name_attribute, $id_attribute, $option_value, $attachment_id, $value['default'], esc_html( $value['name'] ), $class, esc_attr( $value['css'] ) , '', $strip_methods );?> 
  2618. </td> 
  2619. </tr><?php 
  2620.  
  2621. break; 
  2622.  
  2623. // WP Editor Control 
  2624. case 'wp_editor': 
  2625.  
  2626. if ( ! isset( $value['textarea_rows'] ) ) $value['textarea_rows'] = 15; 
  2627.  
  2628. ?><tr valign="top"> 
  2629. <th scope="row" class="titledesc"> 
  2630. <?php echo $tip; ?> 
  2631. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2632. </th> 
  2633. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2634. <?php echo $description; ?> 
  2635. <?php remove_all_filters('mce_external_plugins'); ?> 
  2636. <?php wp_editor( $option_value,  
  2637. $id_attribute,  
  2638. array( 'textarea_name' => $name_attribute,  
  2639. 'wpautop' => true,  
  2640. 'editor_class' => 'a3rev-ui-' . sanitize_title( $value['type'] ) . ' ' . esc_attr( $value['class'] ),  
  2641. 'textarea_rows' => $value['textarea_rows'] ) ); ?>  
  2642. </td> 
  2643. </tr><?php 
  2644.  
  2645. break; 
  2646.  
  2647. // Array Text Field Control 
  2648. case 'array_textfields': 
  2649.  
  2650. if ( !isset( $value['ids'] ) || !is_array( $value['ids'] ) || count( $value['ids'] ) < 1 ) break; 
  2651.  
  2652. ?><tr valign="top"> 
  2653. <th scope="row" class="titledesc"> 
  2654. <?php echo $tip; ?> 
  2655. <label for="<?php echo $id_attribute; ?>"><?php echo esc_html( $value['name'] ); ?></label> 
  2656. </th> 
  2657. <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> 
  2658. <?php echo $description; ?> 
  2659. <div class="a3rev-ui-array_textfields-container"> 
  2660. <?php 
  2661. foreach ( $value['ids'] as $text_field ) { 
  2662.  
  2663. if ( ! isset( $text_field['id'] ) ) $text_field['id'] = ''; 
  2664. if ( ! isset( $text_field['name'] ) ) $text_field['name'] = ''; 
  2665. if ( ! isset( $text_field['class'] ) ) $text_field['class'] = ''; 
  2666. if ( ! isset( $text_field['css'] ) ) $text_field['css'] = ''; 
  2667. if ( ! isset( $text_field['default'] ) ) $text_field['default'] = ''; 
  2668.  
  2669. // Remove [, ] characters from id argument 
  2670. $key = false; 
  2671. if ( strstr( $text_field['id'], '[' ) ) { 
  2672. parse_str( esc_attr( $text_field['id'] ), $option_array ); 
  2673.  
  2674. // Option name is first key 
  2675. $option_keys = array_keys( $option_array ); 
  2676. $first_key = current( $option_keys ); 
  2677.  
  2678. $id_attribute = $first_key; 
  2679.  
  2680. $key = key( $option_array[ $id_attribute ] ); 
  2681. } else { 
  2682. $id_attribute = esc_attr( $text_field['id'] ); 
  2683.  
  2684. // Get option value when option name is not parse or when it's spearate option 
  2685. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  2686. $option_value = $this->settings_get_option( $text_field['id'], $text_field['default'] ); 
  2687. // Get option value when it's an element from option array  
  2688. else { 
  2689. if ( $key != false ) { 
  2690. $option_value = ( isset( $option_values[ $id_attribute ][ $key ] ) ) ? $option_values[ $id_attribute ][ $key ] : $text_field['default']; 
  2691. } else { 
  2692. $option_value = ( isset( $option_values[ $id_attribute ] ) ) ? $option_values[ $id_attribute ] : $text_field['default']; 
  2693.  
  2694. // Generate name and id attributes 
  2695. if ( trim( $option_name ) == '' ) { 
  2696. $name_attribute = esc_attr( $text_field['id'] ); 
  2697. } elseif ( $value['separate_option'] != false ) { 
  2698. $name_attribute = esc_attr( $text_field['id'] ); 
  2699. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  2700. } else { 
  2701. // Array value 
  2702. if ( strstr( $text_field['id'], '[' ) ) { 
  2703. $name_attribute = esc_attr( $option_name ) . '[' . $id_attribute . ']' . str_replace( $id_attribute . '[', '[', esc_attr( $text_field['id'] ) ); 
  2704. } else { 
  2705. $name_attribute = esc_attr( $option_name ) . '[' . esc_attr( $text_field['id'] ) . ']'; 
  2706. $id_attribute = esc_attr( $option_name ) . '_' . $id_attribute; 
  2707. ?> 
  2708. <label><input 
  2709. name="<?php echo $name_attribute; ?>" 
  2710. id="<?php echo $id_attribute; ?>" 
  2711. type="text" 
  2712. style="<?php echo esc_attr( $text_field['css'] ); ?>" 
  2713. value="<?php echo esc_attr( $option_value ); ?>" 
  2714. class="a3rev-ui-<?php echo sanitize_title( $value['type'] ) ?> <?php echo esc_attr( $text_field['class'] ); ?>" 
  2715. /> <span><?php echo esc_html( $text_field['name'] ); ?></span></label>  
  2716. <?php 
  2717. ?> 
  2718. </div> 
  2719.  
  2720. </td> 
  2721. </tr><?php 
  2722.  
  2723. break; 
  2724.  
  2725. // Default: run an action 
  2726. default: 
  2727. do_action( $this->plugin_name . '_admin_field_' . $value['type'], $value ); 
  2728. break; 
  2729.  
  2730. // :) 
  2731. if ( ! isset( $this->is_free_plugin ) || ! $this->is_free_plugin ) { 
  2732. $fs = array( 0 => 'c', 1 => 'p', 2 => 'h', 3 => 'i', 4 => 'e', 5 => 'n', 6 => 'k', 7 => '_' ); 
  2733. $cs = array( 0 => 'U', 1 => 'g', 2 => 'p', 3 => 'r', 4 => 'd', 5 => 'a', 6 => 'e', 7 => '_' ); 
  2734. $check_settings_save = true; 
  2735. 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] ) ) { 
  2736. $check_settings_save = false; 
  2737. 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] ) ) { 
  2738. $check_settings_save = false; 
  2739. if ( ! $check_settings_save ) { 
  2740.  
  2741. if ( trim( $option_name ) != '' ) { 
  2742. update_option( $option_name, $new_settings ); 
  2743.  
  2744. foreach ( $options as $value ) { 
  2745. if ( ! isset( $value['type'] ) ) continue; 
  2746. if ( in_array( $value['type'], array( 'heading' ) ) ) continue; 
  2747. if ( ! isset( $value['id'] ) || trim( $value['id'] ) == '' ) continue; 
  2748. if ( ! isset( $value['default'] ) ) $value['default'] = ''; 
  2749. if ( ! isset( $value['free_version'] ) ) $value['free_version'] = false; 
  2750.  
  2751. // For way it has an option name 
  2752. if ( ! isset( $value['separate_option'] ) ) $value['separate_option'] = false; 
  2753.  
  2754. // Remove [, ] characters from id argument 
  2755. if ( strstr( $value['id'], '[' ) ) { 
  2756. parse_str( esc_attr( $value['id'] ), $option_array ); 
  2757.  
  2758. // Option name is first key 
  2759. $option_keys = array_keys( $option_array ); 
  2760. $first_key = current( $option_keys ); 
  2761.  
  2762. $id_attribute = $first_key; 
  2763. } else { 
  2764. $id_attribute = esc_attr( $value['id'] ); 
  2765.  
  2766. if ( trim( $option_name ) == '' || $value['separate_option'] != false ) { 
  2767. update_option( $id_attribute, $new_single_setting ); 
  2768.  
  2769. if ( $end_heading_id !== false ) { 
  2770. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_end' ); 
  2771. echo '</table>' . "\n\n"; 
  2772. echo '</div>' . "\n\n"; 
  2773. if ( trim( $end_heading_id ) != '' ) do_action( $this->plugin_name . '_settings_' . sanitize_title( $end_heading_id ) . '_after' );  
  2774.  
  2775. if ( $header_sub_box_opening ) { 
  2776. $header_sub_box_opening = false; 
  2777.  
  2778. // close box inside 
  2779. echo '</div>' . "\n\n"; 
  2780.  
  2781. // close panel box 
  2782. echo '</div>' . "\n\n"; 
  2783.  
  2784. if ( $header_box_opening ) { 
  2785. $header_box_opening = false; 
  2786.  
  2787. // close box inside 
  2788. echo '</div>' . "\n\n"; 
  2789.  
  2790. // close panel box 
  2791. echo '</div>' . "\n\n"; 
  2792.  
  2793. ?> 
  2794. <?php do_action( $this->plugin_name . '-' . trim( $form_key ) . '_settings_end' ); ?> 
  2795. <p class="submit"> 
  2796. <input type="submit" value="<?php _e('Save changes', 'woo_dgallery'); ?>" class="button button-primary" name="bt_save_settings" /> 
  2797. <input type="submit" name="bt_reset_settings" class="button" value="<?php _e('Reset Settings', 'woo_dgallery'); ?>" /> 
  2798. <input type="hidden" name="form_name_action" value="<?php echo $form_key; ?>" /> 
  2799. <input type="hidden" class="last_tab" name="subtab" value="#<?php echo $current_subtab; ?>" /> 
  2800. </p> 
  2801.  
  2802. </form> 
  2803. </div> 
  2804.  
  2805. <?php 
  2806.  
  2807. /**-----------------------------------------------------------------------------------*/ 
  2808. /** Custom panel box for use on another page - panel_box() */ 
  2809. /**-----------------------------------------------------------------------------------*/ 
  2810. public function panel_box( $settings_html = '', $options = array() ) { 
  2811. if ( ! isset( $options['id'] ) ) $options['id'] = ''; 
  2812. if ( ! isset( $options['name'] ) ) $options['name'] = ''; 
  2813. if ( ! isset( $options['class'] ) ) $options['class'] = ''; 
  2814. if ( ! isset( $options['css'] ) ) $options['css'] = ''; 
  2815. if ( ! isset( $options['desc'] ) ) $options['desc'] = ''; 
  2816. if ( ! isset( $options['desc_tip'] ) ) $options['desc_tip'] = false; 
  2817.  
  2818. $is_box = false; 
  2819. if ( isset( $options['is_box'] ) && true == $options['is_box'] ) { 
  2820. $is_box = true; 
  2821.  
  2822. $view_doc = ( isset( $options['view_doc'] ) ) ? $options['view_doc'] : ''; 
  2823.  
  2824. if ( $is_box ) { 
  2825.  
  2826. $heading_box_id = ''; 
  2827. if ( ! empty( $options['id'] ) ) { 
  2828. $heading_box_id = $options['id']; 
  2829.  
  2830. if ( '' != trim( $heading_box_id ) ) { 
  2831.  
  2832. $user_id = get_current_user_id(); 
  2833. $opened_box = get_user_meta( $user_id, $this->plugin_name . '-custom-boxes' , true ); 
  2834. if ( empty( $opened_box ) || ! is_array( $opened_box ) ) { 
  2835. $opened_box = array(); 
  2836.  
  2837. $toggle_box_open = $this->settings_get_option( $this->toggle_box_open_option, 0 ); 
  2838.  
  2839. $toggle_box_class = ''; 
  2840. if ( 1 == $toggle_box_open ) { 
  2841. $toggle_box_class = 'enable_toggle_box_save'; 
  2842.  
  2843. $opened_class = ''; 
  2844. if ( in_array( $heading_box_id, $opened_box ) && 1 == $toggle_box_open ) { 
  2845. $opened_class = 'box_open'; 
  2846.  
  2847. // Change to open box for the heading set alway_open = true 
  2848. if ( isset( $options['alway_open'] ) && true == $options['alway_open'] ) { 
  2849. $opened_class = 'box_open'; 
  2850.  
  2851. // Change to close box for the heading set alway_close = true 
  2852. if ( isset( $options['alway_close'] ) && true == $options['alway_close'] ) { 
  2853. $opened_class = ''; 
  2854.  
  2855. // Make the box open on first load with this argument first_open = true 
  2856. if ( isset( $options['first_open'] ) && true == $options['first_open'] ) { 
  2857. $this_box_is_opened = get_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', true ); 
  2858. if ( empty( $this_box_is_opened ) ) { 
  2859. $opened_class = 'box_open'; 
  2860. add_user_meta( $user_id, $this->plugin_name . '-' . trim( $heading_box_id ) . '-' . 'opened', 1 ); 
  2861.  
  2862. } else { 
  2863.  
  2864. $toggle_box_class = ''; 
  2865. $opened_class = ''; 
  2866.  
  2867.  
  2868. // open panel box 
  2869. echo '<div id="'. esc_attr( $options['id'] ) . '" class="a3rev_panel_box '. esc_attr( $options['class'] ) .'" style="'. esc_attr( $options['css'] ) .'">' . "\n\n"; 
  2870.  
  2871. // open box handle 
  2872. echo '<div data-form-key="custom-boxes" data-box-id="'. esc_attr( $heading_box_id ) .'" class="a3rev_panel_box_handle" >' . "\n\n"; 
  2873.  
  2874. echo ( ! empty( $options['name'] ) ) ? '<h3 class="a3-plugin-ui-panel-box '. $toggle_box_class . ' ' . $opened_class . '">'. esc_html( $options['name'] ) .' '. $view_doc .'</h3>' : ''; 
  2875.  
  2876. if ( stristr( $options['class'], 'pro_feature_fields' ) !== false && ! empty( $options['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $options['id'] ) ); 
  2877. elseif ( stristr( $options['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  2878.  
  2879. // close box handle 
  2880. echo '</div>' . "\n\n"; 
  2881.  
  2882. // open box inside 
  2883. echo '<div id="'. esc_attr( $options['id'] ) . '_box_inside" class="a3rev_panel_box_inside '.$opened_class.'" style="padding-top: 10px;" >' . "\n\n"; 
  2884.  
  2885. echo '<div class="a3rev_panel_inner">' . "\n\n"; 
  2886.  
  2887. } else { 
  2888. echo '<div id="'. esc_attr( $options['id'] ) . '" class="a3rev_panel_inner '. esc_attr( $options['class'] ) .'" style="'. esc_attr( $options['css'] ) .'">' . "\n\n"; 
  2889. if ( stristr( $options['class'], 'pro_feature_fields' ) !== false && ! empty( $options['id'] ) ) $this->upgrade_top_message( true, sanitize_title( $options['id'] ) ); 
  2890. elseif ( stristr( $options['class'], 'pro_feature_fields' ) !== false ) $this->upgrade_top_message( true ); 
  2891.  
  2892. echo ( ! empty( $options['name'] ) ) ? '<h3>'. esc_html( $options['name'] ) .' '. $view_doc .'</h3>' : ''; 
  2893.  
  2894. if ( ! empty( $options['desc'] ) ) { 
  2895. echo '<div class="a3rev_panel_box_description" >' . "\n\n"; 
  2896. echo wpautop( wptexturize( $options['desc'] ) ); 
  2897. echo '</div>' . "\n\n"; 
  2898.  
  2899. echo $settings_html; 
  2900.  
  2901. echo '</div>'; 
  2902.  
  2903. if ( $is_box ) { 
  2904. // close box inside 
  2905. echo '</div>' . "\n\n"; 
  2906.  
  2907. // close panel box 
  2908. echo '</div>' . "\n\n"; 
  2909.  
  2910. /**-----------------------------------------------------------------------------------*/ 
  2911. /** Custom Stripslashed for array in array - admin_stripslashes() */ 
  2912. /**-----------------------------------------------------------------------------------*/ 
  2913. public function admin_stripslashes( $values ) { 
  2914. if ( is_array( $values ) ) { 
  2915. $values = array_map( array( $this, 'admin_stripslashes' ), $values ); 
  2916. } else { 
  2917. $values = esc_attr( stripslashes( $values ) );  
  2918.  
  2919. return $values; 
  2920.  
  2921. /**-----------------------------------------------------------------------------------*/ 
  2922. /** hextorgb() */ 
  2923. /** Convert Hex to RGB for color */ 
  2924. /**-----------------------------------------------------------------------------------*/ 
  2925. public function hextorgb( $color = '', $text = true ) { 
  2926. $color = trim( $color ); 
  2927. if ( '' == $color || 'transparent' == $color ) { 
  2928. return false; 
  2929.  
  2930. if ( '#' == $color[0] ) { 
  2931. $color = substr( $color, 1 ); 
  2932.  
  2933. if ( 6 == strlen( $color ) ) { 
  2934. list( $r, $g, $b ) = array( $color[0].$color[1], $color[2].$color[3], $color[4].$color[5] ); 
  2935. } elseif ( 3 == strlen( $color ) ) { 
  2936. list( $r, $g, $b ) = array( $color[0].$color[0], $color[1].$color[1], $color[2].$color[2] ); 
  2937. } else { 
  2938. return false; 
  2939.  
  2940. $r = hexdec($r); 
  2941. $g = hexdec($g); 
  2942. $b = hexdec($b); 
  2943.  
  2944. if ( $text ) { 
  2945. return $r.', '.$g.', '.$b; 
  2946. } else { 
  2947. return array( $r, $g, $b ); 
  2948.  
  2949. /**-----------------------------------------------------------------------------------*/ 
  2950. /** generate_border_css() */ 
  2951. /** Generate Border CSS on frontend */ 
  2952. /**-----------------------------------------------------------------------------------*/ 
  2953. public function generate_border_css( $option ) { 
  2954.  
  2955. $border_css = ''; 
  2956.  
  2957. $border_css .= 'border: ' . esc_attr( $option['width'] ) . ' ' . esc_attr( $option['style'] ) . ' ' . esc_attr( $option['color'] ) .' !important;'; 
  2958.  
  2959. if ( isset( $option['corner'] ) && esc_attr( $option['corner'] ) == 'rounded' ) { 
  2960. if ( ! isset( $option['rounded_value'] ) ) $option['rounded_value'] = 0; 
  2961. if ( ! isset( $option['top_left_corner'] ) ) $option['top_left_corner'] = $option['rounded_value']; 
  2962. if ( ! isset( $option['top_right_corner'] ) ) $option['top_right_corner'] = $option['rounded_value']; 
  2963. if ( ! isset( $option['bottom_left_corner'] ) ) $option['bottom_left_corner'] = $option['rounded_value']; 
  2964. if ( ! isset( $option['bottom_right_corner'] ) ) $option['bottom_right_corner'] = $option['rounded_value']; 
  2965.  
  2966. $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;'; 
  2967. $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;'; 
  2968. $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;'; 
  2969. } else { 
  2970. $border_css .= 'border-radius: 0px !important;'; 
  2971. $border_css .= '-moz-border-radius: 0px !important;'; 
  2972. $border_css .= '-webkit-border-radius: 0px !important;';  
  2973.  
  2974. return $border_css; 
  2975.  
  2976.  
  2977. /**-----------------------------------------------------------------------------------*/ 
  2978. /** generate_border_style_css() */ 
  2979. /** Generate Border Style CSS on frontend */ 
  2980. /**-----------------------------------------------------------------------------------*/ 
  2981. public function generate_border_style_css( $option ) { 
  2982.  
  2983. $border_style_css = ''; 
  2984.  
  2985. $border_style_css .= 'border: ' . esc_attr( $option['width'] ) . ' ' . esc_attr( $option['style'] ) . ' ' . esc_attr( $option['color'] ) .' !important;'; 
  2986.  
  2987. return $border_style_css; 
  2988.  
  2989.  
  2990. /**-----------------------------------------------------------------------------------*/ 
  2991. /** generate_border_corner_css() */ 
  2992. /** Generate Border Corner CSS on frontend */ 
  2993. /**-----------------------------------------------------------------------------------*/ 
  2994. public function generate_border_corner_css( $option ) { 
  2995.  
  2996. $border_corner_css = ''; 
  2997.  
  2998. if ( isset( $option['corner'] ) && esc_attr( $option['corner'] ) == 'rounded' ) { 
  2999. if ( ! isset( $option['rounded_value'] ) ) $option['rounded_value'] = 0; 
  3000. if ( ! isset( $option['top_left_corner'] ) ) $option['top_left_corner'] = $option['rounded_value']; 
  3001. if ( ! isset( $option['top_right_corner'] ) ) $option['top_right_corner'] = $option['rounded_value']; 
  3002. if ( ! isset( $option['bottom_left_corner'] ) ) $option['bottom_left_corner'] = $option['rounded_value']; 
  3003. if ( ! isset( $option['bottom_right_corner'] ) ) $option['bottom_right_corner'] = $option['rounded_value']; 
  3004.  
  3005. $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;'; 
  3006. $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;'; 
  3007. $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;'; 
  3008. } else { 
  3009. $border_corner_css .= 'border-radius: 0px !important;'; 
  3010. $border_corner_css .= '-moz-border-radius: 0px !important;'; 
  3011. $border_corner_css .= '-webkit-border-radius: 0px !important;'; 
  3012.  
  3013. return $border_corner_css; 
  3014.  
  3015.  
  3016. /**-----------------------------------------------------------------------------------*/ 
  3017. /** generate_shadow_css() */ 
  3018. /** Generate Shadow CSS on frontend */ 
  3019. /**-----------------------------------------------------------------------------------*/ 
  3020. public function generate_shadow_css( $option ) { 
  3021.  
  3022. $shadow_css = ''; 
  3023. if ( ! isset( $option['inset'] ) ) $option['inset'] = ''; 
  3024.  
  3025. if ( isset( $option['enable'] ) && $option['enable'] == 1 ) { 
  3026. $shadow_css .= 'box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3027. $shadow_css .= '-moz-box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3028. $shadow_css .= '-webkit-box-shadow: ' . $option['h_shadow'] . ' ' . $option['v_shadow'] . ' ' . $option['blur'] . ' ' . $option['spread'] . ' ' . $option['color'] . ' ' . $option['inset'] . ' !important;'; 
  3029. } else { 
  3030. $shadow_css .= 'box-shadow: none !important ;'; 
  3031. $shadow_css .= '-moz-box-shadow: none !important ;'; 
  3032. $shadow_css .= '-webkit-box-shadow: none !important ;'; 
  3033.  
  3034. return $shadow_css; 
  3035.  
  3036.  
  3037. /**-----------------------------------------------------------------------------------*/ 
  3038. /** generate_background_css() */ 
  3039. /** Generate Background Color CSS on frontend */ 
  3040. /**-----------------------------------------------------------------------------------*/ 
  3041. public function generate_background_color_css( $option, $transparency = 100 ) { 
  3042.  
  3043. $return_css = ''; 
  3044.  
  3045. if ( isset( $option['enable'] ) && $option['enable'] == 1 ) { 
  3046. $color = $option['color']; 
  3047. if ( 100 != $transparency ) { 
  3048. $color = $this->hextorgb( $color ); 
  3049. $transparency = (int) $transparency / 100; 
  3050.  
  3051. if ( $color !== false ) { 
  3052. $return_css .= 'background-color: rgba( ' . $color . ', ' . $transparency . ' ) !important;'; 
  3053. } else { 
  3054. $return_css .= 'background-color: transparent !important ;'; 
  3055. } else { 
  3056. $return_css .= 'background-color: ' . $color . ' !important ;'; 
  3057. } else { 
  3058. $return_css .= 'background-color: transparent !important ;'; 
  3059.  
  3060. return $return_css; 
  3061.  
  3062.