/**
  * add_settings.
  *
  * @version 2.5.7
  * @since   2.5.0
  */
 function add_settings()
 {
     $settings = array();
     $settings = array_merge($settings, array(array('title' => __('Options', 'woocommerce-jetpack'), 'type' => 'title', 'id' => 'wcj_price_by_user_role_options'), array('title' => __('Enable per Product Settings', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'desc_tip' => __('When enabled, this will add new "Booster: Price by User Role" meta box to each product\'s edit page.', 'woocommerce-jetpack'), 'type' => 'checkbox', 'id' => 'wcj_price_by_user_role_per_product_enabled', 'default' => 'yes'), array('title' => __('Show Roles on per Product Settings', 'woocommerce-jetpack'), 'desc' => __('If per product settings is enabled, you can choose which roles to show on product\'s edit page. Leave blank to show all roles.', 'woocommerce-jetpack'), 'type' => 'multiselect', 'id' => 'wcj_price_by_user_role_per_product_show_roles', 'default' => '', 'class' => 'chosen_select', 'options' => wcj_get_user_roles_options()), array('title' => __('Shipping', 'woocommerce-jetpack'), 'desc' => __('Enable', 'woocommerce-jetpack'), 'desc_tip' => __('When enabled, this will apply user role multipliers to shipping calculations.', 'woocommerce-jetpack'), 'type' => 'checkbox', 'id' => 'wcj_price_by_user_role_shipping_enabled', 'default' => 'no'), array('title' => __('Search Engine Bots', 'woocommerce-jetpack'), 'desc' => __('Disable Price by User Role for Bots', 'woocommerce-jetpack'), 'id' => 'wcj_price_by_user_role_for_bots_disabled', 'default' => 'no', 'type' => 'checkbox'), array('type' => 'sectionend', 'id' => 'wcj_price_by_user_role_options')));
     $settings[] = array('title' => __('Roles & Multipliers', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module.', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc&section=general')), 'id' => 'wcj_price_by_user_role_multipliers_options');
     foreach (wcj_get_user_roles() as $role_key => $role_data) {
         $settings = array_merge($settings, array(array('title' => $role_data['name'], 'id' => 'wcj_price_by_user_role_' . $role_key, 'default' => 1, 'type' => 'number', 'custom_attributes' => array('step' => '0.000001', 'min' => '0')), array('desc' => __('Make Empty Price', 'woocommerce-jetpack'), 'id' => 'wcj_price_by_user_role_empty_price_' . $role_key, 'default' => 'no', 'type' => 'checkbox')));
     }
     $settings[] = array('type' => 'sectionend', 'id' => 'wcj_price_by_user_role_multipliers_options');
     return $settings;
 }
 /**
  * create_custom_roles_tool.
  *
  * @version 2.5.3
  * @since   2.5.3
  */
 function create_custom_roles_tool()
 {
     if (isset($_POST['wcj_add_new_role'])) {
         if (!isset($_POST['wcj_custom_role_id']) || '' == $_POST['wcj_custom_role_id'] || !isset($_POST['wcj_custom_role_name']) || '' == $_POST['wcj_custom_role_name']) {
             echo '<p style="color:red;font-weight:bold;">' . __('Both fields are required!', 'woocommerce-jetpack') . '</p>';
         } else {
             if (is_numeric($_POST['wcj_custom_role_id'])) {
                 echo '<p style="color:red;font-weight:bold;">' . __('Role ID must not be numbers only!', 'woocommerce-jetpack') . '</p>';
             } else {
                 $result = add_role($_POST['wcj_custom_role_id'], $_POST['wcj_custom_role_name']);
                 if (null !== $result) {
                     echo '<p style="color:green;font-weight:bold;">' . __('Role successfully added!', 'woocommerce-jetpack') . '</p>';
                 } else {
                     echo '<p style="color:red;font-weight:bold;">' . __('Role already exists!', 'woocommerce-jetpack') . '</p>';
                 }
             }
         }
     }
     if (isset($_GET['wcj_delete_role']) && '' != $_GET['wcj_delete_role']) {
         remove_role($_GET['wcj_delete_role']);
         echo '<p style="color:green;font-weight:bold;">' . sprintf(__('Role %s successfully deleted!', 'woocommerce-jetpack'), $_GET['wcj_delete_role']) . '</p>';
     }
     echo $this->get_tool_header_html('custom_roles');
     $table_data = array();
     $table_data[] = array(__('ID', 'woocommerce-jetpack'), __('Name', 'woocommerce-jetpack'), __('Actions', 'woocommerce-jetpack'));
     $existing_roles = wcj_get_user_roles();
     $default_wp_wc_roles = array('guest', 'administrator', 'editor', 'author', 'contributor', 'subscriber', 'customer', 'shop_manager');
     foreach ($existing_roles as $role_key => $role_data) {
         $delete_html = in_array($role_key, $default_wp_wc_roles) ? '' : '<a href="' . add_query_arg('wcj_delete_role', $role_key) . '">' . __('Delete', 'woocommerce-jetpack') . '</a>';
         $table_data[] = array($role_key, $role_data['name'], $delete_html);
     }
     echo '<h3>' . __('Existing Roles', 'woocommerce-jetpack') . '</h3>';
     echo wcj_get_table_html($table_data, array('table_class' => 'widefat striped'));
     $table_data = array();
     $table_data[] = array(__('ID', 'woocommerce-jetpack'), '<input type="text" name="wcj_custom_role_id">');
     $table_data[] = array(__('Name', 'woocommerce-jetpack'), '<input type="text" name="wcj_custom_role_name">');
     echo '<h3>' . __('Add New Role', 'woocommerce-jetpack') . '</h3>';
     echo '<form method="post" action="' . remove_query_arg('wcj_delete_role') . '">' . wcj_get_table_html($table_data, array('table_class' => 'widefat', 'table_heading_type' => 'vertical', 'table_style' => 'width:20%;min-width:300px;')) . '<p>' . '<input type="submit" name="wcj_add_new_role" class="button-primary" value="' . __('Add', 'woocommerce-jetpack') . '">' . '</p>' . '</form>';
 }
 /**
  * add_settings.
  *
  * @version 2.5.7
  * @since   2.5.7
  */
 function add_settings()
 {
     $settings = array(array('title' => __('Order Minimum Amount', 'woocommerce-jetpack'), 'type' => 'title', 'desc' => __('This section lets you set minimum order amount.', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_options'), array('title' => __('Amount', 'woocommerce-jetpack'), 'desc' => __('Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount', 'default' => 0, 'type' => 'number', 'custom_attributes' => array('step' => '0.0001', 'min' => '0')), array('title' => __('Exclude Shipping from Cart Total', 'woocommerce-jetpack'), 'desc' => __('Exclude', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_exclude_shipping', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Error message', 'woocommerce-jetpack'), 'desc' => apply_filters('booster_get_message', '', 'desc'), 'desc_tip' => __('Message to customer if order is below minimum amount. Default: You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_error_message', 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.', 'type' => 'textarea', 'custom_attributes' => apply_filters('booster_get_message', '', 'readonly'), 'css' => 'width:50%;min-width:300px;'), array('title' => __('Add notice to cart page also', 'woocommerce-jetpack'), 'desc' => __('Add', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_cart_notice_enabled', 'default' => 'no', 'type' => 'checkbox'), array('title' => __('Message on cart page', 'woocommerce-jetpack'), 'desc' => apply_filters('booster_get_message', '', 'desc'), 'desc_tip' => __('Message to customer if order is below minimum amount. Default: You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_cart_notice_message', 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.', 'type' => 'textarea', 'custom_attributes' => apply_filters('booster_get_message', '', 'readonly'), 'css' => 'width:50%;min-width:300px;'), array('title' => __('Stop customer from seeing the Checkout page if minimum amount not reached.', 'woocommerce-jetpack'), 'desc' => __('Redirect back to Cart page', 'woocommerce-jetpack'), 'id' => 'wcj_order_minimum_amount_stop_from_seeing_checkout', 'default' => 'no', 'type' => 'checkbox'), array('type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_options'), array('title' => __('Order Minimum Amount by User Role', 'woocommerce-jetpack'), 'type' => 'title', 'id' => 'wcj_order_minimum_amount_by_ser_role_options', 'desc' => sprintf(__('Custom roles can be added via "Add/Manage Custom Roles" tool in Booster\'s <a href="%s">General</a> module.', 'woocommerce-jetpack'), admin_url('admin.php?page=wc-settings&tab=jetpack&wcj-cat=emails_and_misc&section=general'))));
     $c = array('guest', 'administrator', 'customer');
     $is_r = apply_filters('booster_get_message', '', 'readonly');
     if ('' == $is_r) {
         $is_r = array();
     }
     foreach (wcj_get_user_roles() as $role_key => $role_data) {
         $settings = array_merge($settings, array(array('title' => $role_data['name'], 'id' => 'wcj_order_minimum_amount_by_user_role_' . $role_key, 'default' => 0, 'type' => 'number', 'custom_attributes' => !in_array($role_key, $c) ? array_merge(array('step' => '0.0001', 'min' => '0'), $is_r) : array('step' => '0.0001', 'min' => '0'), 'desc_tip' => !in_array($role_key, $c) ? apply_filters('booster_get_message', '', 'desc_no_link') : '')));
     }
     $settings = array_merge($settings, array(array('type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_by_ser_role_options')));
     return $settings;
 }