-1
Может ли кто-нибудь мне помочь, как заставить этот виджет работать? Он копируется из исходного кода, но в одном файле было много виджетов. Я вырезал только этот, потому что мне нужен этот отдельно стоящий. Я не могу загрузить его как плагин. Вот код:Как исправить этот виджет Wordpress
<?php
/**
----> Custom Pricing Box Widget
**/
add_action('widgets_init', 'load_pricing_box_widget');
function load_pricing_box_widget() {
\t register_widget('Price_Box');
}
class Price_Box extends WP_Widget {
\t function Price_Box() {
\t \t $widget_ops = array('classname' => 'plan', 'description' => __('Custom Pricing box widget - for the Home-Page only!', 'example'));
\t \t $control_ops = array('width' => 300, 'height' => 550, 'id_base' => 'pricing-box');
\t \t $this->WP_Widget('pricing-box', __('Bluz Themes - Pricing Box', 'example'), $widget_ops, $control_ops);
\t }
\t function widget($args, $instance) {
\t \t extract($args);
\t \t $title = apply_filters('widget_title', $instance['title']);
\t \t $content = $instance['content'];
\t \t $price = $instance['price'];
\t \t $longer = $instance['longer'];
\t \t $per = $instance['per'];
\t \t $button_link = $instance['button_link'];
\t \t $button_color = $instance['button_color'];
\t \t echo $before_widget;
\t \t \t
\t \t if ($title)
\t \t \t echo $before_title . $title . $after_title;
\t \t
\t \t echo '<div class="content">';
\t \t if ($longer) { echo '<div class="price" style="font-size:20px;">'; } else {echo '<div class="price">';}
\t \t
echo '<div class="inside">';
\t \t \t \t \t echo $price.'<br><span>'.$per.'</span>';
\t \t \t \t echo '</div>';
\t \t \t \t \t echo '<a href="'.$button_link.'" class="sml-btn '.$button_color.'">Order Now!</a>';
\t \t \t echo '</div>';
\t \t
\t \t
\t \t if ($content)
\t \t \t printf('%1$s' , $content);
\t \t
\t \t echo '</div>';
\t \t echo $after_widget;
\t }
\t function update($new_instance, $old_instance) {
\t \t $instance = $old_instance;
\t \t /* Strip tags for title and name to remove HTML (important for text inputs). */
\t \t $instance['title'] = strip_tags($new_instance['title']);
\t \t $instance['content'] = stripslashes($new_instance['content']);
\t \t $instance['price'] = strip_tags($new_instance['price']);
\t \t $instance['longer'] = $new_instance['longer'];
\t \t $instance['per'] = strip_tags($new_instance['per']);
\t \t $instance['button_link'] = strip_tags($new_instance['button_link']);
\t \t $instance['button_color'] = $new_instance['button_color'];
\t \t return $instance;
\t }
\t function form($instance) {
\t \t $defaults = array('title' => __('Pricing Box Title', 'example'), 'content' => __('This is our pricing box content, you can use html to style it', 'example'), 'button_color' => __('red', 'example'));
\t \t $instance = wp_parse_args((array) $instance, $defaults); ?>
\t \t <!-- Widget Title: Text Input -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Pricing Box Title:', 'hybrid'); ?></label>
\t \t \t <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:97%;" class="widefat" />
\t \t </p>
\t \t <!-- Your Content: Text Input -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('content'); ?>"><?php _e('Content (You can use HTML):', 'example'); ?></label>
\t \t \t <textarea id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>" type="textarea" cols="12" rows="12" class="widefat" ><?php echo $instance['content']; ?></textarea>
\t \t </p>
<!-- Widget Price: Text Input -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('price'); ?>"><?php _e('Price:', 'example'); ?></label>
\t \t \t <input id="<?php echo $this->get_field_id('price'); ?>" name="<?php echo $this->get_field_name('price'); ?>" value="<?php echo $instance['price']; ?>" style="width:97%;" class="widefat" />
\t \t </p>
<!-- Widget Per: Text Input -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('per'); ?>"><?php _e('Price Per... <em>(examples: /month, /year, /day)</em>:', 'example'); ?></label>
\t \t \t <input id="<?php echo $this->get_field_id('per'); ?>" name="<?php echo $this->get_field_name('per'); ?>" value="<?php echo $instance['per']; ?>" style="width:97%;" class="widefat" />
\t \t </p>
\t \t <!-- Price Longer? Checkbox -->
\t \t <p>
\t \t \t <input class="checkbox" type="checkbox" <?php if($instance['longer'] == true) { ?>checked="checked"<?php } ?> id="<?php echo $this->get_field_id('longer'); ?>" name="<?php echo $this->get_field_name('longer'); ?>" />
\t \t \t <label for="<?php echo $this->get_field_id('longer'); ?>"><?php _e('<strong>Check this if your price is longer the 2 Didgets</strong>', 'example'); ?></label>
\t \t </p>
<!-- Widget Button Link: Text Input -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('button_link'); ?>"><?php _e('The url you want the "order now!" button to link to:', 'example'); ?></label>
\t \t \t <input id="<?php echo $this->get_field_id('button_link'); ?>" name="<?php echo $this->get_field_name('button_link'); ?>" value="<?php echo $instance['button_link']; ?>" style="width:97%;" class="widefat" />
\t \t </p>
<!-- Button Color: Select Box -->
\t \t <p>
\t \t \t <label for="<?php echo $this->get_field_id('button_color'); ?>"><?php _e('Choose a color for the "order now!" button <em>(default color is red)</em>:', 'example'); ?></label>
\t \t \t <select id="<?php echo $this->get_field_id('button_color'); ?>" name="<?php echo $this->get_field_name('button_color'); ?>" class="widefat" style="width:100%;">
\t \t \t \t <option <?php if ('red' == $instance['button_color']) echo 'selected="selected"'; ?>>red</option>
\t \t \t \t <option <?php if ('orange' == $instance['button_color']) echo 'selected="selected"'; ?>>orange</option>
\t \t \t \t <option <?php if ('green' == $instance['button_color']) echo 'selected="selected"'; ?>>green</option>
\t \t \t \t <option <?php if ('blue' == $instance['button_color']) echo 'selected="selected"'; ?>>blue</option>
\t \t \t \t <option <?php if ('grey' == $instance['button_color']) echo 'selected="selected"'; ?>>grey</option>
\t \t \t \t <option <?php if ('black' == $instance['button_color']) echo 'selected="selected"'; ?>>black</option>
\t \t \t \t <option <?php if ('special' == $instance['button_color']) echo 'selected="selected"'; ?>>special</option>
\t \t \t </select>
\t \t </p>
?>
Класс Price_Box и форма функции() никогда не закрываются (}). – bobdye