* @package WordPress */ if ( !class_exists( 'WooCommerce_Quick_Donation_Format_Options' ) ) { class WooCommerce_Quick_Donation_Format_Options extends WooCommerce_Quick_Donation_Settings_API { /** * Format an option array into HTML * * * @access public * * @param unknown $setting * * @return string HTML. */ public function settings_options_format( $setting ) { if ( empty( $setting ) ) return false; $defaults = apply_filters( $this->id . '_options_defaults', array( 'name' => '', 'desc' => '', 'placeholder' => '', 'class' => '', 'tip' => '', 'id' => '', 'css' => '', 'type' => 'text', 'std' => '', 'select2' => false, 'multiple' => false, 'options' => array(), 'restrict' => array(), 'settings' => array() ) ); // Each to it's own variable for slim-ness' sakes. $setting = shortcode_atts( $defaults, $setting ); $restrict_defaults = array( 'min' => 0, 'max' => '', 'step' => 'any', ); $setting[ 'restrict' ] = shortcode_atts( $restrict_defaults, $setting[ 'restrict' ] ); $setting[ 'value' ] = $this->get_option( $setting[ 'id' ] ); $setting[ 'value' ] = $setting[ 'value' ] !== false ? maybe_unserialize( $setting[ 'value' ] ) : false; $setting[ 'value' ] = WooCommerce_Quick_Donation_Format_Options::sanitize_value( $setting[ 'value' ], $setting ); $setting[ 'title' ] = $setting[ 'name' ]; $setting[ 'name' ] = $this->id . "_options[{$setting['id']}]"; $setting[ 'grouped' ] = !$setting[ 'title' ] ? ' style="padding-top:0px;"' : ''; $setting[ 'tip' ] = WooCommerce_Quick_Donation_Format_Options::get_formatted_tip( $setting[ 'tip' ] ); $header_types = apply_filters( $this->id . '_options_header_types', array( 'heading', 'title' ) ); extract( $setting ); $description = $desc && !$grouped && $type != 'checkbox' ? ' ' . $desc . '' : ''; $description = ( ( in_array( $type, $header_types ) || $type == 'radio' ) && !empty( $desc ) ) ? '

' . $desc . '

' : $description; ?> > >

'; } ?> min="" max="" step="" class="regular-text " style="" placeholder="" value="" /> $desc ) : ?> />
/> $val ) : ?>
$name, 'id' => $id, 'sort_order' => 'ASC', 'echo' => 0, 'selected' => $selected ); echo str_replace( "'>", "'>", wp_dropdown_pages( $args ) ); echo $description; if ( $select2 ) : ?> id . '_select_options', $options, $setting ); ?> $name ) ); echo $description; break; default : do_action( $this->id . '_options_type_' . $type, $setting ); break; endswitch; /* Footer of the option. */ if ( !in_array( $type, $header_types ) ) echo ''; } /** * * * @param unknown $haystack * @param unknown $current */ private function selected( $haystack, $current ) { if ( is_array( $haystack ) && in_array( $current, $haystack ) ) { $current = $haystack = 1; } selected( $haystack, $current ); } /** * * * @param unknown $haystack * @param unknown $current */ private function checked( $haystack, $current ) { if ( is_array( $haystack ) && !empty( $haystack[ $current ] ) ) { $current = $haystack = 1; } checked( $haystack, $current ); } /** * Format a tooltip given a string * * @param string $tip * * @return string */ private function get_formatted_tip( $tip ) { return $tip ? sprintf( '', $tip ) : ''; } /** * * * @param unknown $value * @param unknown $setting * * @return unknown */ private function sanitize_value( $value, $setting ) { if ( $value !== false && $setting[ 'type' ] != 'wysiwyg' ) { if ( is_array( $value ) ) { foreach ( $value as $key => $output ) { $value[ $key ] = esc_attr( $output ); } } else { $value = esc_attr( $value ); } } return apply_filters( $this->id . '_options_sanitize_value', $value, $setting ); } } }