normalize_settings_args( $args ) ); // output checkbox printf( '', $id, $setting_name, $value, checked( $value, $current, false ), $class ); // output description. if ( isset( $description ) ) { printf( '
%s
', $description ); } } /** * Text input callback. * * args: * option_name - name of the main option * id - key of the setting * size - size of the text input (em) * default - default setting (optional) * description - description (optional) * type - type (optional) * * @return void. */ public function text_input( $args ) { extract( $this->normalize_settings_args( $args ) ); // echo '';var_dump($this->normalize_settings_args( $args ));echo ''; if (empty($type)) { $type = 'text'; } if ($type == 'number') { $width = ($size * 10) + 25; $style = "width: {$width}px"; } else { $style = ''; } printf( '', $type, $id, $setting_name, $current, $size, $placeholder, $class, $style ); // output description. if ( isset( $description ) ) { printf( '
%s
', $description ); } } /** * Color picker callback. * * args: * option_name - name of the main option * id - key of the setting * size - size of the text input (em) * default - default setting (optional) * description - description (optional) * * @return void. */ public function color_picker( $args ) { extract( $this->normalize_settings_args( $args ) ); // echo '';var_dump($this->normalize_settings_args( $args ));echo ''; printf( '', $id, $setting_name, $current, $size, $class ); // output description. if ( isset( $description ) ) { printf( '
%s
', $description ); } } /** * Textarea callback. * * args: * option_name - name of the main option * id - key of the setting * width - width of the text input (em) * height - height of the text input (lines) * default - default setting (optional) * description - description (optional) * * @return void. */ public function textarea( $args ) { extract( $this->normalize_settings_args( $args ) ); printf( '%3$s', $id, $setting_name, $current, $width, $height, $placeholder ); // output description. if ( isset( $description ) ) { printf( '%s
', $description ); } } /** * Select element callback. * * @param array $args Field arguments. * * @return string Select field. */ public function select( $args ) { extract( $this->normalize_settings_args( $args ) ); printf( ''; if (isset($custom)) { printf( '%s
', $args['description'] ); } } public function radio_button( $args ) { extract( $this->normalize_settings_args( $args ) ); foreach ( $options as $key => $label ) { printf( '', $id, $setting_name, $key, checked( $current, $key, false ) ); printf( '%s
', $args['description'] ); } } /** * Multiple text element callback. * @param array $args Field arguments. * @return string Text input field. */ public function multiple_text_input( $args ) { extract( $this->normalize_settings_args( $args ) ); if (!empty($header)) { echo "{$header}:
"; } foreach ($fields as $name => $field) { $label = $field['label']; $size = $field['size']; $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; if (isset($field['label_width'])) { $style = sprintf( 'style="display:inline-block; width:%1$s;"', $field['label_width'] ); } else { $style = ''; } $suffix = isset($field['suffix']) ? $field['suffix'] : ''; // output field label printf( '', $id, $name, $style, $label ); // output field $field_current = isset($current[$name]) ? $current[$name] : ''; printf( '%7$s%s
', $args['description'] ); } } public function order_status_select( $args ) { // get list of WooCommerce statuses if ( version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) { $statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) ); foreach ( $statuses as $status ) { $order_statuses[esc_attr( $status->slug )] = esc_html__( $status->name, 'woocommerce' ); } } else { $statuses = wc_get_order_statuses(); foreach ( $statuses as $status_slug => $status ) { $status_slug = 'wc-' === substr( $status_slug, 0, 3 ) ? substr( $status_slug, 3 ) : $status_slug; $order_statuses[$status_slug] = $status; } } // select order status $args['options'] = $order_statuses; $this->select( $args ); } public function shipping_methods_package_types( $args ) { extract( $this->normalize_settings_args( $args ) ); foreach ($package_types as $package_type => $package_type_title) { printf ('%s
', $description ); } } // Shipping method search callback. public function shipping_method_search( $args ) { extract( $this->normalize_settings_args( $args ) ); if (isset($package_type)) { $setting_name = "{$setting_name}[{$package_type}]"; $current = isset($current[$package_type]) ? $current[$package_type] : ''; } // get shipping methods $available_shipping_methods = array(); $shipping_methods = WC()->shipping->load_shipping_methods(); // echo '';var_dump($shipping_methods);echo ''; if ( $shipping_methods ) { foreach ( $shipping_methods as $key => $shipping_method ) { // Automattic / WooCommerce Table Rate Shipping if ( $key == 'table_rate' && class_exists('WC_Table_Rate_Shipping') && class_exists('WC_Shipping_Zones')) { $zones = WC_Shipping_Zones::get_zones(); foreach ($zones as $zone_data) { if (isset($zone_data['id'])) { $zone_id = $zone_data['id']; } elseif (isset($zone_data['zone_id'])) { $zone_id = $zone_data['zone_id']; } else { continue; } $zone = WC_Shipping_Zones::get_zone($zone_id); $zone_methods = $zone->get_shipping_methods( false ); foreach ( $zone_methods as $key => $shipping_method ) { if ( $shipping_method->id == 'table_rate' && method_exists( $shipping_method, 'get_shipping_rates') ) { $zone_table_rates = $shipping_method->get_shipping_rates(); foreach ($zone_table_rates as $zone_table_rate) { $rate_label = ! empty( $zone_table_rate->rate_label ) ? $zone_table_rate->rate_label : "{$shipping_method->title} ({$zone_table_rate->rate_id})"; $available_shipping_methods["table_rate:{$shipping_method->instance_id}:{$zone_table_rate->rate_id}"] = "{$zone->get_zone_name()} - {$rate_label}"; } } } } continue; } // Bolder Elements Table Rate Shipping if ( $key == 'betrs_shipping' && is_a($shipping_method, 'BE_Table_Rate_Method') && class_exists('WC_Shipping_Zones') ) { $zones = WC_Shipping_Zones::get_zones(); foreach ($zones as $zone_data) { if (isset($zone_data['id'])) { $zone_id = $zone_data['id']; } elseif (isset($zone_data['zone_id'])) { $zone_id = $zone_data['zone_id']; } else { continue; } $zone = WC_Shipping_Zones::get_zone($zone_id); $zone_methods = $zone->get_shipping_methods( false ); foreach ( $zone_methods as $key => $shipping_method ) { if ( $shipping_method->id == 'betrs_shipping' ) { $shipping_method_options = get_option( $shipping_method->id . '_options-' . $shipping_method->instance_id ); if (isset($shipping_method_options['settings'])) { foreach ($shipping_method_options['settings'] as $zone_table_rate) { $rate_label = ! empty( $zone_table_rate['title'] ) ? $zone_table_rate['title'] : "{$shipping_method->title} ({$zone_table_rate['option_id']})"; $available_shipping_methods["betrs_shipping_{$shipping_method->instance_id}-{$zone_table_rate['option_id']}"] = "{$zone->get_zone_name()} - {$rate_label}"; } } } } } continue; } $method_title = !empty($shipping_methods[$key]->method_title) ? $shipping_methods[$key]->method_title : $shipping_methods[$key]->title; $available_shipping_methods[ $key ] = $method_title; // split flat rate by shipping class if ( ( $key == 'flat_rate' || $key == 'legacy_flat_rate' ) && version_compare( WOOCOMMERCE_VERSION, '2.4', '>=' ) ) { $shipping_classes = WC()->shipping->get_shipping_classes(); foreach ($shipping_classes as $shipping_class) { if ( ! isset( $shipping_class->term_id ) ) { continue; } $id = $shipping_class->term_id; $name = esc_html( "{$method_title} - {$shipping_class->name}" ); $method_class = esc_attr( $key ).":".$id; $available_shipping_methods[ $method_class ] = $name; } } } } ?> %s', $description ); } } public function enhanced_select( $args ) { extract( $this->normalize_settings_args( $args ) ); ?> %s', $description ); } } public function delivery_option_enable( $args ) { extract( $this->normalize_settings_args( $args ) ); // checkbox (enable) $cb_args = array( 'id' => "{$id}_enabled", 'class' => 'wcmp_delivery_option' ); // number (fee) $fee_args = array( 'id' => "{$id}_fee", 'type' => 'text', 'size' => '5', ); ?> checkbox( array_merge( $args, $cb_args ) ); ?>
| : | € text_input( array_merge( $args, $fee_args ) ); ?> |
| checkbox( array_merge( $common_args, $cb_args ) ); ?> |