";
}
echo $args['after_widget'];
}
/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
*
* @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database.
*
* @return array Updated safe values to be saved.
*/
public function update($new_instance, $old_instance) {
//die(print_r($new_instance));
$instance = array();
$instance['title'] = (!empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : '';
$instance['pin_image_url'] = (!empty($new_instance['pin_image_url']) ) ? strip_tags($new_instance['pin_image_url']) : '';
return $instance;
}
}
//Decleration of the Pinterest class for the pinterest profile widget
class APSP_Profile_Widget_Free extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'apsp_profile_widget_free', // Base ID
__('AccessPress Pinterest Profile widget', APSP_WIDGET_CONSTANT ), // Name
array('description' => __('AccessPress Pinterest Profile widget', APSP_WIDGET_CONSTANT ) ) // Args
);
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form($instance) {
if (isset($instance['title'])) {
$title = $instance['title'];
} else {
$title = '';
}
if (isset($instance['profile_name'])) {
$profile_name = $instance['profile_name'];
} else {
$profile_name = '';
}
if (isset($instance['image_width'])) {
$image_width = $instance['image_width'];
} else {
$image_width = '';
}
if (isset($instance['board_height'])) {
$board_height = $instance['board_height'];
} else {
$board_height = '';
}
if (isset($instance['board_width'])) {
$board_width = $instance['board_width'];
} else {
$board_width = '';
}
if (isset($instance['custom_sizes'])) {
$custom_sizes = $instance['custom_sizes'];
} else {
$custom_sizes = '';
}
?>
";
if($instance['profile_name'] == ''){
_e("Please enter the pinterest profile name in widget to make the profile widget appear here", APSP_WIDGET_CONSTANT );
}else{
switch ($instance['custom_sizes']) {
case 'square':
$instance['image_width'] = '80';
$instance['board_height'] = '320';
$instance['board_width'] = '400';
break;
case 'sidebar':
$instance['image_width'] = '60';
$instance['board_height'] = '800';
$instance['board_width'] = '150';
break;
case 'header':
$instance['image_width'] = '115';
$instance['board_height'] = '120';
$instance['board_width'] = '900';
break;
default:
# code...
break;
}
echo do_shortcode("[apsp-profile-widget profile='{$instance['profile_name']}' custom_size='{$instance['custom_sizes']}' image_width='{$instance['image_width']}' board_height='{$instance['board_height']}' board_width='{$instance['board_width']}']");
}
echo "