Woo_Catalog_Settings

The Woocommerce Catalog Woo Catalog Settings class.

Defined (2)

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

/include/php/settings.php  
  1. class Woo_Catalog_Settings { 
  2.  
  3. private $dir; 
  4.  
  5. private $file; 
  6.  
  7. private $assets_dir; 
  8.  
  9. private $assets_url; 
  10.  
  11. private $settings_base; 
  12.  
  13. private $settings; 
  14.  
  15.  
  16.  
  17. public function __construct( $file ) { 
  18.  
  19. $this->file = $file; 
  20.  
  21. $this->dir = dirname( $this->file ); 
  22.  
  23. $this->assets_dir = trailingslashit( $this->dir ) . 'include'; 
  24.  
  25. $this->assets_url = esc_url( trailingslashit( plugins_url( '/include/', $this->file ) ) ); 
  26.  
  27. $this->settings_base = 'woo_Catalog_'; 
  28.  
  29.  
  30.  
  31. // Initialise settings 
  32.  
  33. add_action( 'admin_init', array( $this, 'init' ) ); 
  34.  
  35.  
  36.  
  37. // Register plugin settings 
  38.  
  39. add_action( 'admin_init' , array( $this, 'register_settings' ) ); 
  40.  
  41.  
  42.  
  43. // Add settings page to menu 
  44.  
  45. add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); 
  46.  
  47.  
  48.  
  49. // Add settings link to plugins page 
  50.  
  51. add_filter( 'plugin_action_links_' . plugin_basename( $this->file ) , array( $this, 'add_settings_link' ) ); 
  52.  
  53.  
  54.  
  55.  
  56. /** 
  57.   
  58. * Initialise settings 
  59.   
  60. * @return void 
  61.   
  62. */ 
  63.  
  64. public function init() { 
  65.  
  66. $this->settings = $this->settings_fields(); 
  67.  
  68.  
  69.  
  70.  
  71. /** 
  72.   
  73. * Add settings page to admin menu 
  74.   
  75. * @return void 
  76.   
  77. */ 
  78.  
  79. public function add_menu_item() { 
  80.  
  81. $page = add_options_page( __( 'Woocommerce Catalog Mode', 'woocommerce-catalog' ) , __( 'Woocommerce Catalog Mode', 'woocommerce-catalog' ) , 'manage_options' , 'woo_Catalog_settings' , array( $this, 'settings_page' ) ); 
  82.  
  83. add_action( 'admin_print_styles-' . $page, array( $this, 'settings_assets' ) ); 
  84.  
  85.  
  86.  
  87.  
  88. /** 
  89.   
  90. * Load settings JS & CSS 
  91.   
  92. * @return void 
  93.   
  94. */ 
  95.  
  96. public function settings_assets() { 
  97.  
  98.  
  99.  
  100.  
  101.  
  102. // We're including the WP media scripts here because they're needed for the image upload field 
  103.  
  104. // If you're not including an image upload then you can leave this function call out 
  105.  
  106. wp_enqueue_media(); 
  107.  
  108. //Required for color picker 
  109. wp_enqueue_style( 'farbtastic' ); 
  110. wp_enqueue_script( 'farbtastic' ); 
  111.  
  112. wp_register_script('custom-jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.js');  
  113. wp_enqueue_script( 'custom-jquery-ui' ); 
  114.  
  115. wp_register_style('woo-infinite-switchButton-style', $this->assets_url . 'css/jquery.switchButton.css'); 
  116. wp_enqueue_style( 'woo-infinite-switchButton-style' ); 
  117.  
  118.  
  119.  
  120. wp_register_style('woo-infinite-scroll-style', $this->assets_url . 'css/admin-style.css'); 
  121. wp_enqueue_style( 'woo-infinite-scroll-style' ); 
  122.  
  123. wp_register_script('custom-woo-switchButton', $this->assets_url . 'js/jquery.switchButton.js', array('farbtastic', 'jquery'), false, true); 
  124. wp_enqueue_script( 'custom-woo-switchButton' ); 
  125.  
  126.  
  127. wp_register_script( 'wpt-admin-js', $this->assets_url . 'js/admin.js', array( 'jquery' ), '1.0.0' ); 
  128.  
  129. wp_enqueue_script( 'wpt-admin-js' ); 
  130.  
  131.  
  132.  
  133.  
  134. /** 
  135.   
  136. * Add settings link to plugin list table 
  137.   
  138. * @param array $links Existing links 
  139.   
  140. * @return array Modified links 
  141.   
  142. */ 
  143.  
  144. public function add_settings_link( $links ) { 
  145.  
  146. $settings_link = '<a href="options-general.php?page=woo_Catalog_settings">' . __( 'Settings', 'woocommerce-catalog' ) . '</a>'; 
  147.  
  148. array_push( $links, $settings_link ); 
  149.  
  150. return $links; 
  151.  
  152.  
  153.  
  154.  
  155. /** 
  156.   
  157. * Build settings fields 
  158.   
  159. * @return array Fields to be displayed on settings page 
  160.   
  161. */ 
  162.  
  163. private function settings_fields() { 
  164.  
  165.  
  166. /**/$args=array(); 
  167. $product_categories = get_terms( 'product_cat', $args ); 
  168. $cat_ids=array(); 
  169. $cat_names=array(); 
  170.  
  171. $cat_ids[] = "all"; 
  172. $cat_names[] = "All categories"; 
  173.  
  174. foreach($product_categories as $v) { 
  175. $cat_names[]= $v->name; 
  176. $cat_ids[] = $v->term_id; 
  177. }  
  178.  
  179. $product_categories=array_combine($cat_ids, $cat_names); 
  180. //print_r($product_categories);exit; 
  181.  
  182. $settings['basic'] = array( 
  183.  
  184. 'title' => __( 'Basic Settings', 'woocommerce-catalog' ),  
  185.  
  186. 'description' => __( 'These are some basic settings to get started.', 'woocommerce-catalog' ),  
  187.  
  188. 'fields' => array( 
  189.  
  190. array( 
  191.  
  192. 'id' => 'catalog_mode',  
  193.  
  194. 'label' => __( 'Catalog mode?', 'woocommerce-catalog' ),  
  195.  
  196. 'description' => __( 'Enable or disable for your eshor the below settings.', 'woocommerce-catalog' ),  
  197.  
  198. 'type' => 'checkbox',  
  199.  
  200. 'default' => '' 
  201.  
  202. ),  
  203.  
  204.  
  205. array( 
  206.  
  207. 'id' => 'catalog_groups',  
  208.  
  209. 'label' => __( 'Apply these settings to the following groups:', 'woocommerce-catalog' ),  
  210.  
  211. 'description' => __( 'Choose the group you want to apply catalogue mode.', 'woocommerce-catalog' ),  
  212.  
  213. 'type' => 'select',  
  214.  
  215. 'options' => array( 'all' => 'All (apply catalog settings for all users)', 'registered_users' => 'Only to registered users', 'non_registered_users' => 'Only to non registered users' ),  
  216.  
  217. 'default' => 'all' 
  218.  
  219. ),  
  220.  
  221. array( 
  222.  
  223. 'id' => 'categories',  
  224.  
  225. 'label' => __( 'Apply these settings to the following categories:', 'woocommerce-catalog' ),  
  226.  
  227. 'description' => __( 'Choose the categories you want to apply catalogue mode.(ctrl + left click to select multiple)', 'woocommerce-catalog' ),  
  228.  
  229. 'type' => 'select_multi',  
  230.  
  231. 'options' => $product_categories,  
  232.  
  233. 'default' => array('all')  
  234.  
  235.  
  236. ),  
  237. array( 
  238.  
  239. 'id' => 'remove_add_to_cart_button',  
  240.  
  241. 'label' => __( 'Remove Add to cart button?', 'woocommerce-catalog' ),  
  242.  
  243. 'description' => __( 'Check this option if you want to remove add to cart button in your catalog.', 'woocommerce-catalog' ),  
  244.  
  245. 'type' => 'checkbox',  
  246.  
  247. 'default' => 'on' 
  248.  
  249. ),  
  250.  
  251. array( 
  252.  
  253. 'id' => 'add_custom_button',  
  254.  
  255. 'label' => __( 'Add custom button instead of add to cart', 'woocommerce-catalog' ),  
  256.  
  257. 'type' => 'checkbox',  
  258.  
  259. 'default' => '' 
  260.  
  261. ),  
  262. array( 
  263.  
  264. 'id' => 'custom_button_type',  
  265.  
  266. 'label' => __( 'Choose from drop-down menu custom button type' , 'woocommerce-catalog' ),  
  267.  
  268. 'type' => 'select',  
  269.  
  270. 'options' => array( 'custom_button_type_read_more' => 'Read More (redirect to product details)', 'custom_button_type_custom' => 'Custom link in all products' ),  
  271.  
  272. 'default' => 'custom_button_type_read_more' 
  273.  
  274. ),  
  275.  
  276. array( 
  277.  
  278. 'id' => 'custom_button_link',  
  279.  
  280. 'label' => __( 'Enter here the link for your custom button' , 'woocommerce-catalog' ),  
  281.  
  282. 'type' => 'text',  
  283.  
  284. 'default' => '',  
  285.  
  286. 'placeholder' => 'http://example.com' 
  287.  
  288. ),  
  289.  
  290. array( 
  291.  
  292. 'id' => 'remove_price',  
  293.  
  294. 'label' => __( 'Remove Price?', 'woocommerce-catalog' ),  
  295.  
  296. 'description' => __( 'Check this option if you want to remove price from product loop and from product details page.', 'woocommerce-catalog' ),  
  297.  
  298. 'type' => 'checkbox',  
  299.  
  300. 'default' => '' 
  301.  
  302.  
  303. ); 
  304.  
  305.  
  306. $settings['btn_more'] = array( 
  307.  
  308. 'title' => __( 'Custom Button Settings', 'woocommerce-catalog' ),  
  309.  
  310. 'description' => __( 'Here are the options for custom button.', 'woocommerce-catalog' ),  
  311.  
  312. 'fields' => array( 
  313.  
  314.  
  315.  
  316.  
  317. array( 
  318. 'id' => 'button_text',  
  319. 'label' => __( 'Change load more text with: ', 'woocommerce-catalog' ),  
  320. 'type' => 'text',  
  321. 'default' => '',  
  322. 'placeholder' => 'More' 
  323. ),  
  324.  
  325. array( 
  326. 'id' => 'button_background',  
  327. 'label' => __( 'Pick a colour for button background', 'woocommerce-catalog' ),  
  328. 'type' => 'color',  
  329. 'default' => '#DDDDDD' 
  330. ),  
  331.  
  332. array( 
  333. 'id' => 'button_color',  
  334. 'label' => __( 'Pick a colour for button text color', 'woocommerce-catalog' ),  
  335. 'type' => 'color',  
  336. 'default' => '#000000' 
  337. ),  
  338.  
  339. array( 
  340. 'id' => 'button_background_hover',  
  341. 'label' => __( 'Pick a colour for button background on mouseover', 'woocommerce-catalog' ),  
  342. 'type' => 'color',  
  343. 'default' => '#EEEEEE' 
  344. ),  
  345.  
  346. array( 
  347. 'id' => 'button_color_hover',  
  348. 'label' => __( 'Pick a colour for button text color on mouseover', 'woocommerce-catalog' ),  
  349. 'type' => 'color',  
  350. 'default' => '#000000' 
  351. ),  
  352.  
  353. array( 
  354. 'id' => 'button_padding',  
  355. 'label' => __( 'Choose padding for your button', 'woocommerce-catalog' ),  
  356. 'type' => 'number',  
  357. 'default' => '',  
  358. 'placeholder' => '10' 
  359. ),  
  360.  
  361. array( 
  362. 'id' => 'button_width',  
  363. 'label' => __( 'Choose width for your button ', 'woocommerce-catalog' ),  
  364. 'type' => 'number',  
  365. 'default' => '',  
  366. 'placeholder' => '80' 
  367. ),  
  368.  
  369. array( 
  370. 'id' => 'button_height',  
  371. 'label' => __( 'Choose height for your button ', 'woocommerce-catalog' ),  
  372. 'type' => 'number',  
  373. 'default' => '',  
  374. 'placeholder' => '15' 
  375. ),  
  376.  
  377. array( 
  378. 'id' => 'button_border_radius',  
  379. 'label' => __( 'Choose border radius for your button ', 'woocommerce-catalog' ),  
  380. 'type' => 'number',  
  381. 'default' => '',  
  382. 'placeholder' => '5' 
  383. ),  
  384.  
  385. array( 
  386. 'id' => 'button_border_width',  
  387. 'label' => __( 'Choose border width for your button ', 'woocommerce-catalog' ),  
  388. 'type' => 'number',  
  389. 'default' => '',  
  390. 'placeholder' => '1' 
  391. ),  
  392.  
  393. array( 
  394. 'id' => 'button_border_color',  
  395. 'label' => __( 'Pick a colour for button border', 'woocommerce-catalog' ),  
  396. 'type' => 'color',  
  397. 'default' => '#000000' 
  398. ),  
  399.  
  400. array( 
  401. 'id' => 'button_font_size',  
  402. 'label' => __( 'Choose font size of button text ', 'woocommerce-catalog' ),  
  403. 'type' => 'number',  
  404. 'default' => '',  
  405. 'placeholder' => '14' 
  406.  
  407. ); 
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416. $settings = apply_filters( 'woo_Catalog_plugin_settings_fields', $settings ); 
  417.  
  418.  
  419.  
  420. return $settings; 
  421.  
  422.  
  423.  
  424.  
  425. /** 
  426.   
  427. * Register plugin settings 
  428.   
  429. * @return void 
  430.   
  431. */ 
  432.  
  433. public function register_settings() { 
  434.  
  435. if( is_array( $this->settings ) ) { 
  436.  
  437. foreach( $this->settings as $section => $data ) { 
  438.  
  439.  
  440.  
  441. // Add section to page 
  442.  
  443. add_settings_section( $section, $data['title'], array( $this, 'settings_section' ), 'woo_Catalog_plugin_settings' ); 
  444.  
  445.  
  446.  
  447. foreach( $data['fields'] as $field ) { 
  448.  
  449.  
  450.  
  451. // Validation callback for field 
  452.  
  453. $validation = ''; 
  454.  
  455. if( isset( $field['callback'] ) ) { 
  456.  
  457. $validation = $field['callback']; 
  458.  
  459.  
  460.  
  461.  
  462. // Register field 
  463.  
  464. $option_name = $this->settings_base . $field['id']; 
  465.  
  466. register_setting( 'woo_Catalog_plugin_settings', $option_name, $validation ); 
  467.  
  468.  
  469.  
  470. // Add field to page 
  471.  
  472. add_settings_field( $field['id'], $field['label'], array( $this, 'display_field' ), 'woo_Catalog_plugin_settings', $section, array( 'field' => $field ) ); 
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480. public function settings_section( $section ) { 
  481.  
  482. $html = '<p> ' . $this->settings[ $section['id'] ]['description'] . '</p>' . "\n"; 
  483.  
  484. echo $html; 
  485.  
  486.  
  487.  
  488.  
  489. /** 
  490.   
  491. * Generate HTML for displaying fields 
  492.   
  493. * @param array $args Field data 
  494.   
  495. * @return void 
  496.   
  497. */ 
  498.  
  499. public function display_field( $args ) { 
  500.  
  501.  
  502.  
  503. $field = $args['field']; 
  504.  
  505.  
  506.  
  507. $html = '<div id=wrapper_'.$this->settings_base . $field['id'].'>'; 
  508.  
  509.  
  510.  
  511. $option_name = $this->settings_base . $field['id']; 
  512.  
  513. $option = get_option( $option_name ); 
  514.  
  515.  
  516.  
  517. $data = ''; 
  518.  
  519. if( isset( $field['default'] ) ) { 
  520.  
  521. $data = $field['default']; 
  522.  
  523. if( $option ) { 
  524.  
  525. $data = $option; 
  526.  
  527.  
  528.  
  529. $field['description']=isset($field['description'])?$field['description']:""; 
  530.  
  531. switch( $field['type'] ) { 
  532.  
  533.  
  534.  
  535. case 'text': 
  536.  
  537. case 'password': 
  538.  
  539. case 'number': 
  540.  
  541. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '"/>' . "\n"; 
  542.  
  543. break; 
  544.  
  545.  
  546.  
  547. case 'text_secret': 
  548.  
  549. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="text" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value=""/>' . "\n"; 
  550.  
  551. break; 
  552.  
  553.  
  554.  
  555. case 'textarea': 
  556.  
  557. $html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '">' . $data . '</textarea><br/>'. "\n"; 
  558.  
  559. break; 
  560.  
  561.  
  562.  
  563. case 'checkbox': 
  564.  
  565. $checked = ''; 
  566.  
  567. if( $option && 'on' == $option ) { 
  568.  
  569. $checked = 'checked="checked"'; 
  570.  
  571.  
  572. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $option_name ) . '" ' . $checked . '/>' . "\n"; 
  573.  
  574. break; 
  575.  
  576.  
  577.  
  578. case 'checkbox_multi': 
  579.  
  580. foreach( $field['options'] as $k => $v ) { 
  581.  
  582. $checked = false; 
  583.  
  584. if( in_array( $k, $data ) ) { 
  585.  
  586. $checked = true; 
  587.  
  588.  
  589. $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; 
  590.  
  591.  
  592. break; 
  593.  
  594.  
  595.  
  596. case 'radio': 
  597.  
  598. foreach( $field['options'] as $k => $v ) { 
  599.  
  600. $checked = false; 
  601.  
  602. if( $k == $data ) { 
  603.  
  604. $checked = true; 
  605.  
  606.  
  607. $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; 
  608.  
  609.  
  610. break; 
  611.  
  612.  
  613.  
  614. case 'select': 
  615.  
  616. $onChange=isset($field['onChange'])?'onchange="'.$field['onChange'].'"':""; 
  617.  
  618. $html .= '<select name="' . esc_attr( $option_name ) . '" '.$onChange.' id="' . esc_attr( $field['id'] ) . '">'; 
  619.  
  620. foreach( $field['options'] as $k => $v ) { 
  621.  
  622. $selected = false; 
  623.  
  624. if( $k == $data ) { 
  625.  
  626. $selected = true; 
  627.  
  628.  
  629. $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v .'</option>'; 
  630.  
  631.  
  632. $html .= '</select> '; 
  633.  
  634. break; 
  635.  
  636.  
  637. case 'select_multi': 
  638.  
  639. $html .= '<select name="' . esc_attr( $option_name ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple">'; 
  640.  
  641. foreach( $field['options'] as $k => $v ) { 
  642.  
  643. $selected = false; 
  644.  
  645. if( in_array( $k, $data ) ) { 
  646.  
  647. $selected = true; 
  648.  
  649.  
  650. $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</label> '; 
  651.  
  652.  
  653. $html .= '</select> '; 
  654.  
  655. break; 
  656.  
  657.  
  658.  
  659. case 'image': 
  660.  
  661. $image_thumb = ''; 
  662.  
  663. if( $data ) { 
  664.  
  665. $image_thumb = wp_get_attachment_thumb_url( $data ); 
  666.  
  667.  
  668. $html .= '<img id="' . $option_name . '_preview" class="image_preview" src="' . $image_thumb . '" /><br/>' . "\n"; 
  669.  
  670. $html .= '<input id="' . $option_name . '_button" type="button" data-uploader_title="' . __( 'Upload an image' , 'woocommerce-catalog' ) . '" data-uploader_button_text="' . __( 'Use image' , 'woocommerce-catalog' ) . '" class="image_upload_button button" value="'. __( 'Upload new image' , 'woocommerce-catalog' ) . '" />' . "\n"; 
  671.  
  672. $html .= '<input id="' . $option_name . '_delete" type="button" class="image_delete_button button" value="'. __( 'Remove image' , 'woocommerce-catalog' ) . '" />' . "\n"; 
  673.  
  674. $html .= '<input id="' . $option_name . '" class="image_data_field" type="hidden" name="' . $option_name . '" value="' . $data . '"/><br/>' . "\n"; 
  675.  
  676. break; 
  677.  
  678.  
  679.  
  680. case 'color': 
  681.  
  682. ?><div class="color-picker" style="position:relative;"> 
  683.  
  684. <input type="text" name="<?php esc_attr_e( $option_name ); ?>" class="color" value="<?php esc_attr_e( $data ); ?>" /> 
  685.  
  686. <div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div> 
  687.  
  688. </div> 
  689.  
  690. <?php 
  691.  
  692. break; 
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699. switch( $field['type'] ) { 
  700.  
  701.  
  702.  
  703. case 'checkbox_multi': 
  704.  
  705. case 'radio': 
  706.  
  707. case 'select_multi': 
  708.  
  709. $html .= '<br/><span class="description">' . $field['description'] . '</span>'; 
  710.  
  711. break; 
  712.  
  713.  
  714.  
  715. default: 
  716. $field['description']= isset($field['description'])?$field['description']:""; 
  717. $html .= '<label for="' . esc_attr( $field['id'] ) . '"><span class="description">' . $field['description'] . '</span></label>' . "\n"; 
  718.  
  719. break; 
  720.  
  721.  
  722. $html .="</div>"; 
  723.  
  724. echo $html; 
  725.  
  726.  
  727.  
  728.  
  729. /** 
  730.   
  731. * Validate individual settings field 
  732.   
  733. * @param string $data Inputted value 
  734.   
  735. * @return string Validated value 
  736.   
  737. */ 
  738.  
  739. public function validate_field( $data ) { 
  740.  
  741. if( $data && strlen( $data ) > 0 && $data != '' ) { 
  742.  
  743. $data = urlencode( strtolower( str_replace( ' ' , '-' , $data ) ) ); 
  744.  
  745.  
  746. return $data; 
  747.  
  748.  
  749.  
  750.  
  751. /** 
  752.   
  753. * Load settings page content 
  754.   
  755. * @return void 
  756.   
  757. */ 
  758.  
  759. public function settings_page() { 
  760.  
  761.  
  762.  
  763. // Build page HTML 
  764.  
  765. $html = '<div class="wrap" id="woo_Catalog_plugin_settings">' . "\n"; 
  766.  
  767. $html .= '<a href="http://codecanyon.net/category/wordpress?ref=pantrif" target="_blank"><img src="'.$this->assets_url.'icons/envato.jpg"/></a>'; 
  768.  
  769. $html .= '<a class="infinite" href="http://codecanyon.net/item/infinite-ajax-scroll-woocommerce/9343295?ref=pantrif" target="_blank"><img src="'.$this->assets_url.'icons/infinite.png"/></a>'; 
  770.  
  771. $html .= '<h2>' . __( 'Woocommerce Catalog Mode' , 'woocommerce-catalog' ) . '</h2>' . "\n"; 
  772.  
  773. $html .= '<form method="post" action="options.php" enctype="multipart/form-data">' . "\n"; 
  774.  
  775.  
  776.  
  777. // Setup navigation 
  778.  
  779. $html .= '<div class="woo_Catalog_setting_sections_wrapper"><ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n"; 
  780.  
  781. /** $html .= '<li><a class="tab all current" href="#all">' . __( 'All' , 'woocommerce-catalog' ) . '</a></li>' . "\n"; 
  782.   
  783.   
  784.   
  785. foreach( $this->settings as $section => $data ) { 
  786.   
  787. $html .= '<li> <a class="tab" href="#' . $section . '">' . $data['title'] . ' | </a></li>' . "\n"; 
  788.   
  789. } */ 
  790.  
  791.  
  792.  
  793. $html .= '</ul></div>' . "\n"; 
  794.  
  795. $html .='If you want to support development of this plugin OR if you want an ad-free version please make a donation:<br/><a class="paypal" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LL4SJ52RDWDDW&lc=GR&item_name=Woocommerce%20Catalog%20Mode¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="" /></a>'; 
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. $html .= '<div class="woo_Catalog_main_settings"><div class="clear"></div>' . "\n"; 
  803.  
  804.  
  805.  
  806. // Get settings fields 
  807.  
  808. ob_start(); 
  809.  
  810. settings_fields( 'woo_Catalog_plugin_settings' ); 
  811.  
  812. do_settings_sections( 'woo_Catalog_plugin_settings' ); 
  813.  
  814. $html .= ob_get_clean(); 
  815.  
  816.  
  817.  
  818. $html .= '<p class="submit">' . "\n"; 
  819.  
  820. $html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save Settings' , 'woocommerce-catalog' ) ) . '" />' . "\n"; 
  821.  
  822. $html .= '</p>' . "\n"; 
  823.  
  824. $html .= '</form>' . "\n"; 
  825.  
  826. $html .= '<a href="http://codecanyon.net/user/pantrif/follow" target="_blank"><img src="'.$this->assets_url.'icons/envato-button-codecanyon.jpg"/></a>'; 
  827.  
  828. $html .='<a class="paypal beer" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LL4SJ52RDWDDW&lc=GR&item_name=Woocommerce%20Catalog%20Mode¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" rel="nofollow"><img src="'.$this->assets_url.'/icons/beer.jpg" alt="" /></a>'; 
  829.  
  830.  
  831.  
  832. $html .= '</div></div>' . "\n"; 
  833.  
  834.  
  835.  
  836. echo $html; 
  837.  
  838.  
  839.  
  840.  
  1. class Woo_Catalog_Settings { 
  2.  
  3. private $dir; 
  4.  
  5. private $file; 
  6.  
  7. private $assets_dir; 
  8.  
  9. private $assets_url; 
  10.  
  11. private $settings_base; 
  12.  
  13. private $settings; 
  14.  
  15.  
  16.  
  17. public function __construct( $file ) { 
  18.  
  19. $this->file = $file; 
  20.  
  21. $this->dir = dirname( $this->file ); 
  22.  
  23. $this->assets_dir = trailingslashit( $this->dir ) . 'include'; 
  24.  
  25. $this->assets_url = esc_url( trailingslashit( plugins_url( '/include/', $this->file ) ) ); 
  26.  
  27. $this->settings_base = 'woo_Catalog_'; 
  28.  
  29.  
  30.  
  31. // Initialise settings 
  32.  
  33. add_action( 'admin_init', array( $this, 'init' ) ); 
  34.  
  35.  
  36.  
  37. // Register plugin settings 
  38.  
  39. add_action( 'admin_init' , array( $this, 'register_settings' ) ); 
  40.  
  41.  
  42.  
  43. // Add settings page to menu 
  44.  
  45. add_action( 'admin_menu' , array( $this, 'add_menu_item' ) ); 
  46.  
  47.  
  48.  
  49. // Add settings link to plugins page 
  50.  
  51. add_filter( 'plugin_action_links_' . plugin_basename( $this->file ) , array( $this, 'add_settings_link' ) ); 
  52.  
  53.  
  54.  
  55.  
  56. /** 
  57.   
  58. * Initialise settings 
  59.   
  60. * @return void 
  61.   
  62. */ 
  63.  
  64. public function init() { 
  65.  
  66. $this->settings = $this->settings_fields(); 
  67.  
  68.  
  69.  
  70.  
  71. /** 
  72.   
  73. * Add settings page to admin menu 
  74.   
  75. * @return void 
  76.   
  77. */ 
  78.  
  79. public function add_menu_item() { 
  80.  
  81. $page = add_options_page( __( 'Woocommerce Catalog Mode', 'woocommerce-catalog' ) , __( 'Woocommerce Catalog Mode', 'woocommerce-catalog' ) , 'manage_options' , 'woo_Catalog_settings' , array( $this, 'settings_page' ) ); 
  82.  
  83. add_action( 'admin_print_styles-' . $page, array( $this, 'settings_assets' ) ); 
  84.  
  85.  
  86.  
  87.  
  88. /** 
  89.   
  90. * Load settings JS & CSS 
  91.   
  92. * @return void 
  93.   
  94. */ 
  95.  
  96. public function settings_assets() { 
  97.  
  98.  
  99.  
  100.  
  101.  
  102. // We're including the WP media scripts here because they're needed for the image upload field 
  103.  
  104. // If you're not including an image upload then you can leave this function call out 
  105.  
  106. wp_enqueue_media(); 
  107.  
  108. //Required for color picker 
  109. wp_enqueue_style( 'farbtastic' ); 
  110. wp_enqueue_script( 'farbtastic' ); 
  111.  
  112. wp_register_script('custom-jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.js');  
  113. wp_enqueue_script( 'custom-jquery-ui' ); 
  114.  
  115. wp_register_style('woo-infinite-switchButton-style', $this->assets_url . 'css/jquery.switchButton.css'); 
  116. wp_enqueue_style( 'woo-infinite-switchButton-style' ); 
  117.  
  118.  
  119.  
  120. wp_register_style('woo-infinite-scroll-style', $this->assets_url . 'css/admin-style.css'); 
  121. wp_enqueue_style( 'woo-infinite-scroll-style' ); 
  122.  
  123. wp_register_script('custom-woo-switchButton', $this->assets_url . 'js/jquery.switchButton.js', array('farbtastic', 'jquery'), false, true); 
  124. wp_enqueue_script( 'custom-woo-switchButton' ); 
  125.  
  126.  
  127. wp_register_script( 'wpt-admin-js', $this->assets_url . 'js/admin.js', array( 'jquery' ), '1.0.0' ); 
  128.  
  129. wp_enqueue_script( 'wpt-admin-js' ); 
  130.  
  131.  
  132.  
  133.  
  134. /** 
  135.   
  136. * Add settings link to plugin list table 
  137.   
  138. * @param array $links Existing links 
  139.   
  140. * @return array Modified links 
  141.   
  142. */ 
  143.  
  144. public function add_settings_link( $links ) { 
  145.  
  146. $settings_link = '<a href="options-general.php?page=woo_Catalog_settings">' . __( 'Settings', 'woocommerce-catalog' ) . '</a>'; 
  147.  
  148. array_push( $links, $settings_link ); 
  149.  
  150. return $links; 
  151.  
  152.  
  153.  
  154.  
  155. /** 
  156.   
  157. * Build settings fields 
  158.   
  159. * @return array Fields to be displayed on settings page 
  160.   
  161. */ 
  162.  
  163. private function settings_fields() { 
  164.  
  165.  
  166. /**/$args=array(); 
  167. $product_categories = get_terms( 'product_cat', $args ); 
  168. $cat_ids=array(); 
  169. $cat_names=array(); 
  170.  
  171. $cat_ids[] = "all"; 
  172. $cat_names[] = "All categories"; 
  173.  
  174. foreach($product_categories as $v) { 
  175. $cat_names[]= $v->name; 
  176. $cat_ids[] = $v->term_id; 
  177. }  
  178.  
  179. $product_categories=array_combine($cat_ids, $cat_names); 
  180. //print_r($product_categories);exit; 
  181.  
  182. $settings['basic'] = array( 
  183.  
  184. 'title' => __( 'Basic Settings', 'woocommerce-catalog' ),  
  185.  
  186. 'description' => __( 'These are some basic settings to get started.', 'woocommerce-catalog' ),  
  187.  
  188. 'fields' => array( 
  189.  
  190. array( 
  191.  
  192. 'id' => 'catalog_mode',  
  193.  
  194. 'label' => __( 'Catalog mode?', 'woocommerce-catalog' ),  
  195.  
  196. 'description' => __( 'Enable or disable for your eshor the below settings.', 'woocommerce-catalog' ),  
  197.  
  198. 'type' => 'checkbox',  
  199.  
  200. 'default' => '' 
  201.  
  202. ),  
  203.  
  204.  
  205. array( 
  206.  
  207. 'id' => 'catalog_groups',  
  208.  
  209. 'label' => __( 'Apply these settings to the following groups:', 'woocommerce-catalog' ),  
  210.  
  211. 'description' => __( 'Choose the group you want to apply catalogue mode.', 'woocommerce-catalog' ),  
  212.  
  213. 'type' => 'select',  
  214.  
  215. 'options' => array( 'all' => 'All (apply catalog settings for all users)', 'registered_users' => 'Only to registered users', 'non_registered_users' => 'Only to non registered users' ),  
  216.  
  217. 'default' => 'all' 
  218.  
  219. ),  
  220.  
  221. array( 
  222.  
  223. 'id' => 'categories',  
  224.  
  225. 'label' => __( 'Apply these settings to the following categories:', 'woocommerce-catalog' ),  
  226.  
  227. 'description' => __( 'Choose the categories you want to apply catalogue mode.(ctrl + left click to select multiple)', 'woocommerce-catalog' ),  
  228.  
  229. 'type' => 'select_multi',  
  230.  
  231. 'options' => $product_categories,  
  232.  
  233. 'default' => array('all')  
  234.  
  235.  
  236. ),  
  237. array( 
  238.  
  239. 'id' => 'remove_add_to_cart_button',  
  240.  
  241. 'label' => __( 'Remove Add to cart button?', 'woocommerce-catalog' ),  
  242.  
  243. 'description' => __( 'Check this option if you want to remove add to cart button in your catalog.', 'woocommerce-catalog' ),  
  244.  
  245. 'type' => 'checkbox',  
  246.  
  247. 'default' => 'on' 
  248.  
  249. ),  
  250.  
  251. array( 
  252.  
  253. 'id' => 'add_custom_button',  
  254.  
  255. 'label' => __( 'Add custom button instead of add to cart', 'woocommerce-catalog' ),  
  256.  
  257. 'type' => 'checkbox',  
  258.  
  259. 'default' => '' 
  260.  
  261. ),  
  262. array( 
  263.  
  264. 'id' => 'custom_button_type',  
  265.  
  266. 'label' => __( 'Choose from drop-down menu custom button type' , 'woocommerce-catalog' ),  
  267.  
  268. 'type' => 'select',  
  269.  
  270. 'options' => array( 'custom_button_type_read_more' => 'Read More (redirect to product details)', 'custom_button_type_custom' => 'Custom link in all products' ),  
  271.  
  272. 'default' => 'custom_button_type_read_more' 
  273.  
  274. ),  
  275.  
  276. array( 
  277.  
  278. 'id' => 'custom_button_link',  
  279.  
  280. 'label' => __( 'Enter here the link for your custom button' , 'woocommerce-catalog' ),  
  281.  
  282. 'type' => 'text',  
  283.  
  284. 'default' => '',  
  285.  
  286. 'placeholder' => 'http://example.com' 
  287.  
  288. ),  
  289.  
  290. array( 
  291.  
  292. 'id' => 'remove_price',  
  293.  
  294. 'label' => __( 'Remove Price?', 'woocommerce-catalog' ),  
  295.  
  296. 'description' => __( 'Check this option if you want to remove price from product loop and from product details page.', 'woocommerce-catalog' ),  
  297.  
  298. 'type' => 'checkbox',  
  299.  
  300. 'default' => '' 
  301.  
  302.  
  303. ); 
  304.  
  305.  
  306. $settings['btn_more'] = array( 
  307.  
  308. 'title' => __( 'Custom Button Settings', 'woocommerce-catalog' ),  
  309.  
  310. 'description' => __( 'Here are the options for custom button.', 'woocommerce-catalog' ),  
  311.  
  312. 'fields' => array( 
  313.  
  314.  
  315.  
  316.  
  317. array( 
  318. 'id' => 'button_text',  
  319. 'label' => __( 'Change load more text with: ', 'woocommerce-catalog' ),  
  320. 'type' => 'text',  
  321. 'default' => '',  
  322. 'placeholder' => 'More' 
  323. ),  
  324.  
  325. array( 
  326. 'id' => 'button_background',  
  327. 'label' => __( 'Pick a colour for button background', 'woocommerce-catalog' ),  
  328. 'type' => 'color',  
  329. 'default' => '#DDDDDD' 
  330. ),  
  331.  
  332. array( 
  333. 'id' => 'button_color',  
  334. 'label' => __( 'Pick a colour for button text color', 'woocommerce-catalog' ),  
  335. 'type' => 'color',  
  336. 'default' => '#000000' 
  337. ),  
  338.  
  339. array( 
  340. 'id' => 'button_background_hover',  
  341. 'label' => __( 'Pick a colour for button background on mouseover', 'woocommerce-catalog' ),  
  342. 'type' => 'color',  
  343. 'default' => '#EEEEEE' 
  344. ),  
  345.  
  346. array( 
  347. 'id' => 'button_color_hover',  
  348. 'label' => __( 'Pick a colour for button text color on mouseover', 'woocommerce-catalog' ),  
  349. 'type' => 'color',  
  350. 'default' => '#000000' 
  351. ),  
  352.  
  353. array( 
  354. 'id' => 'button_padding',  
  355. 'label' => __( 'Choose padding for your button', 'woocommerce-catalog' ),  
  356. 'type' => 'number',  
  357. 'default' => '',  
  358. 'placeholder' => '10' 
  359. ),  
  360.  
  361. array( 
  362. 'id' => 'button_width',  
  363. 'label' => __( 'Choose width for your button ', 'woocommerce-catalog' ),  
  364. 'type' => 'number',  
  365. 'default' => '',  
  366. 'placeholder' => '80' 
  367. ),  
  368.  
  369. array( 
  370. 'id' => 'button_height',  
  371. 'label' => __( 'Choose height for your button ', 'woocommerce-catalog' ),  
  372. 'type' => 'number',  
  373. 'default' => '',  
  374. 'placeholder' => '15' 
  375. ),  
  376.  
  377. array( 
  378. 'id' => 'button_border_radius',  
  379. 'label' => __( 'Choose border radius for your button ', 'woocommerce-catalog' ),  
  380. 'type' => 'number',  
  381. 'default' => '',  
  382. 'placeholder' => '5' 
  383. ),  
  384.  
  385. array( 
  386. 'id' => 'button_border_width',  
  387. 'label' => __( 'Choose border width for your button ', 'woocommerce-catalog' ),  
  388. 'type' => 'number',  
  389. 'default' => '',  
  390. 'placeholder' => '1' 
  391. ),  
  392.  
  393. array( 
  394. 'id' => 'button_border_color',  
  395. 'label' => __( 'Pick a colour for button border', 'woocommerce-catalog' ),  
  396. 'type' => 'color',  
  397. 'default' => '#000000' 
  398. ),  
  399.  
  400. array( 
  401. 'id' => 'button_font_size',  
  402. 'label' => __( 'Choose font size of button text ', 'woocommerce-catalog' ),  
  403. 'type' => 'number',  
  404. 'default' => '',  
  405. 'placeholder' => '14' 
  406.  
  407. ); 
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416. $settings = apply_filters( 'woo_Catalog_plugin_settings_fields', $settings ); 
  417.  
  418.  
  419.  
  420. return $settings; 
  421.  
  422.  
  423.  
  424.  
  425. /** 
  426.   
  427. * Register plugin settings 
  428.   
  429. * @return void 
  430.   
  431. */ 
  432.  
  433. public function register_settings() { 
  434.  
  435. if( is_array( $this->settings ) ) { 
  436.  
  437. foreach( $this->settings as $section => $data ) { 
  438.  
  439.  
  440.  
  441. // Add section to page 
  442.  
  443. add_settings_section( $section, $data['title'], array( $this, 'settings_section' ), 'woo_Catalog_plugin_settings' ); 
  444.  
  445.  
  446.  
  447. foreach( $data['fields'] as $field ) { 
  448.  
  449.  
  450.  
  451. // Validation callback for field 
  452.  
  453. $validation = ''; 
  454.  
  455. if( isset( $field['callback'] ) ) { 
  456.  
  457. $validation = $field['callback']; 
  458.  
  459.  
  460.  
  461.  
  462. // Register field 
  463.  
  464. $option_name = $this->settings_base . $field['id']; 
  465.  
  466. register_setting( 'woo_Catalog_plugin_settings', $option_name, $validation ); 
  467.  
  468.  
  469.  
  470. // Add field to page 
  471.  
  472. add_settings_field( $field['id'], $field['label'], array( $this, 'display_field' ), 'woo_Catalog_plugin_settings', $section, array( 'field' => $field ) ); 
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480. public function settings_section( $section ) { 
  481.  
  482. $html = '<p> ' . $this->settings[ $section['id'] ]['description'] . '</p>' . "\n"; 
  483.  
  484. echo $html; 
  485.  
  486.  
  487.  
  488.  
  489. /** 
  490.   
  491. * Generate HTML for displaying fields 
  492.   
  493. * @param array $args Field data 
  494.   
  495. * @return void 
  496.   
  497. */ 
  498.  
  499. public function display_field( $args ) { 
  500.  
  501.  
  502.  
  503. $field = $args['field']; 
  504.  
  505.  
  506.  
  507. $html = '<div id=wrapper_'.$this->settings_base . $field['id'].'>'; 
  508.  
  509.  
  510.  
  511. $option_name = $this->settings_base . $field['id']; 
  512.  
  513. $option = get_option( $option_name ); 
  514.  
  515.  
  516.  
  517. $data = ''; 
  518.  
  519. if( isset( $field['default'] ) ) { 
  520.  
  521. $data = $field['default']; 
  522.  
  523. if( $option ) { 
  524.  
  525. $data = $option; 
  526.  
  527.  
  528.  
  529. $field['description']=isset($field['description'])?$field['description']:""; 
  530.  
  531. switch( $field['type'] ) { 
  532.  
  533.  
  534.  
  535. case 'text': 
  536.  
  537. case 'password': 
  538.  
  539. case 'number': 
  540.  
  541. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '"/>' . "\n"; 
  542.  
  543. break; 
  544.  
  545.  
  546.  
  547. case 'text_secret': 
  548.  
  549. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="text" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value=""/>' . "\n"; 
  550.  
  551. break; 
  552.  
  553.  
  554.  
  555. case 'textarea': 
  556.  
  557. $html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $option_name ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '">' . $data . '</textarea><br/>'. "\n"; 
  558.  
  559. break; 
  560.  
  561.  
  562.  
  563. case 'checkbox': 
  564.  
  565. $checked = ''; 
  566.  
  567. if( $option && 'on' == $option ) { 
  568.  
  569. $checked = 'checked="checked"'; 
  570.  
  571.  
  572. $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $option_name ) . '" ' . $checked . '/>' . "\n"; 
  573.  
  574. break; 
  575.  
  576.  
  577.  
  578. case 'checkbox_multi': 
  579.  
  580. foreach( $field['options'] as $k => $v ) { 
  581.  
  582. $checked = false; 
  583.  
  584. if( in_array( $k, $data ) ) { 
  585.  
  586. $checked = true; 
  587.  
  588.  
  589. $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; 
  590.  
  591.  
  592. break; 
  593.  
  594.  
  595.  
  596. case 'radio': 
  597.  
  598. foreach( $field['options'] as $k => $v ) { 
  599.  
  600. $checked = false; 
  601.  
  602. if( $k == $data ) { 
  603.  
  604. $checked = true; 
  605.  
  606.  
  607. $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $option_name ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" /> ' . $v . '</label> '; 
  608.  
  609.  
  610. break; 
  611.  
  612.  
  613.  
  614. case 'select': 
  615.  
  616. $onChange=isset($field['onChange'])?'onchange="'.$field['onChange'].'"':""; 
  617.  
  618. $html .= '<select name="' . esc_attr( $option_name ) . '" '.$onChange.' id="' . esc_attr( $field['id'] ) . '">'; 
  619.  
  620. foreach( $field['options'] as $k => $v ) { 
  621.  
  622. $selected = false; 
  623.  
  624. if( $k == $data ) { 
  625.  
  626. $selected = true; 
  627.  
  628.  
  629. $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v .'</option>'; 
  630.  
  631.  
  632. $html .= '</select> '; 
  633.  
  634. break; 
  635.  
  636.  
  637. case 'select_multi': 
  638.  
  639. $html .= '<select name="' . esc_attr( $option_name ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple">'; 
  640.  
  641. foreach( $field['options'] as $k => $v ) { 
  642.  
  643. $selected = false; 
  644.  
  645. if( in_array( $k, $data ) ) { 
  646.  
  647. $selected = true; 
  648.  
  649.  
  650. $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</label> '; 
  651.  
  652.  
  653. $html .= '</select> '; 
  654.  
  655. break; 
  656.  
  657.  
  658.  
  659. case 'image': 
  660.  
  661. $image_thumb = ''; 
  662.  
  663. if( $data ) { 
  664.  
  665. $image_thumb = wp_get_attachment_thumb_url( $data ); 
  666.  
  667.  
  668. $html .= '<img id="' . $option_name . '_preview" class="image_preview" src="' . $image_thumb . '" /><br/>' . "\n"; 
  669.  
  670. $html .= '<input id="' . $option_name . '_button" type="button" data-uploader_title="' . __( 'Upload an image' , 'woocommerce-catalog' ) . '" data-uploader_button_text="' . __( 'Use image' , 'woocommerce-catalog' ) . '" class="image_upload_button button" value="'. __( 'Upload new image' , 'woocommerce-catalog' ) . '" />' . "\n"; 
  671.  
  672. $html .= '<input id="' . $option_name . '_delete" type="button" class="image_delete_button button" value="'. __( 'Remove image' , 'woocommerce-catalog' ) . '" />' . "\n"; 
  673.  
  674. $html .= '<input id="' . $option_name . '" class="image_data_field" type="hidden" name="' . $option_name . '" value="' . $data . '"/><br/>' . "\n"; 
  675.  
  676. break; 
  677.  
  678.  
  679.  
  680. case 'color': 
  681.  
  682. ?><div class="color-picker" style="position:relative;"> 
  683.  
  684. <input type="text" name="<?php esc_attr_e( $option_name ); ?>" class="color" value="<?php esc_attr_e( $data ); ?>" /> 
  685.  
  686. <div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div> 
  687.  
  688. </div> 
  689.  
  690. <?php 
  691.  
  692. break; 
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699. switch( $field['type'] ) { 
  700.  
  701.  
  702.  
  703. case 'checkbox_multi': 
  704.  
  705. case 'radio': 
  706.  
  707. case 'select_multi': 
  708.  
  709. $html .= '<br/><span class="description">' . $field['description'] . '</span>'; 
  710.  
  711. break; 
  712.  
  713.  
  714.  
  715. default: 
  716. $field['description']= isset($field['description'])?$field['description']:""; 
  717. $html .= '<label for="' . esc_attr( $field['id'] ) . '"><span class="description">' . $field['description'] . '</span></label>' . "\n"; 
  718.  
  719. break; 
  720.  
  721.  
  722. $html .="</div>"; 
  723.  
  724. echo $html; 
  725.  
  726.  
  727.  
  728.  
  729. /** 
  730.   
  731. * Validate individual settings field 
  732.   
  733. * @param string $data Inputted value 
  734.   
  735. * @return string Validated value 
  736.   
  737. */ 
  738.  
  739. public function validate_field( $data ) { 
  740.  
  741. if( $data && strlen( $data ) > 0 && $data != '' ) { 
  742.  
  743. $data = urlencode( strtolower( str_replace( ' ' , '-' , $data ) ) ); 
  744.  
  745.  
  746. return $data; 
  747.  
  748.  
  749.  
  750.  
  751. /** 
  752.   
  753. * Load settings page content 
  754.   
  755. * @return void 
  756.   
  757. */ 
  758.  
  759. public function settings_page() { 
  760.  
  761.  
  762.  
  763. // Build page HTML 
  764.  
  765. $html = '<div class="wrap" id="woo_Catalog_plugin_settings">' . "\n"; 
  766.  
  767. $html .= '<a href="http://codecanyon.net/category/wordpress?ref=pantrif" target="_blank"><img src="'.$this->assets_url.'icons/envato.jpg"/></a>'; 
  768.  
  769. $html .= '<a class="infinite" href="http://codecanyon.net/item/infinite-ajax-scroll-woocommerce/9343295?ref=pantrif" target="_blank"><img src="'.$this->assets_url.'icons/infinite.png"/></a>'; 
  770.  
  771. $html .= '<h2>' . __( 'Woocommerce Catalog Mode' , 'woocommerce-catalog' ) . '</h2>' . "\n"; 
  772.  
  773. $html .= '<form method="post" action="options.php" enctype="multipart/form-data">' . "\n"; 
  774.  
  775.  
  776.  
  777. // Setup navigation 
  778.  
  779. $html .= '<div class="woo_Catalog_setting_sections_wrapper"><ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n"; 
  780.  
  781. /** $html .= '<li><a class="tab all current" href="#all">' . __( 'All' , 'woocommerce-catalog' ) . '</a></li>' . "\n"; 
  782.   
  783.   
  784.   
  785. foreach( $this->settings as $section => $data ) { 
  786.   
  787. $html .= '<li> <a class="tab" href="#' . $section . '">' . $data['title'] . ' | </a></li>' . "\n"; 
  788.   
  789. } */ 
  790.  
  791.  
  792.  
  793. $html .= '</ul></div>' . "\n"; 
  794.  
  795. $html .='If you want to support development of this plugin OR if you want an ad-free version please make a donation:<br/><a class="paypal" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LL4SJ52RDWDDW&lc=GR&item_name=Woocommerce%20Catalog%20Mode¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="" /></a>'; 
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. $html .= '<div class="woo_Catalog_main_settings"><div class="clear"></div>' . "\n"; 
  803.  
  804.  
  805.  
  806. // Get settings fields 
  807.  
  808. ob_start(); 
  809.  
  810. settings_fields( 'woo_Catalog_plugin_settings' ); 
  811.  
  812. do_settings_sections( 'woo_Catalog_plugin_settings' ); 
  813.  
  814. $html .= ob_get_clean(); 
  815.  
  816.  
  817.  
  818. $html .= '<p class="submit">' . "\n"; 
  819.  
  820. $html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save Settings' , 'woocommerce-catalog' ) ) . '" />' . "\n"; 
  821.  
  822. $html .= '</p>' . "\n"; 
  823.  
  824. $html .= '</form>' . "\n"; 
  825.  
  826. $html .= '<a href="http://codecanyon.net/user/pantrif/follow" target="_blank"><img src="'.$this->assets_url.'icons/envato-button-codecanyon.jpg"/></a>'; 
  827.  
  828. $html .='<a class="paypal beer" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=LL4SJ52RDWDDW&lc=GR&item_name=Woocommerce%20Catalog%20Mode¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" rel="nofollow"><img src="'.$this->assets_url.'/icons/beer.jpg" alt="" /></a>'; 
  829.  
  830.  
  831.  
  832. $html .= '</div></div>' . "\n"; 
  833.  
  834.  
  835.  
  836. echo $html; 
  837.  
  838.  
  839.  
  840.