|
Server IP : 10.131.40.8 / Your IP : 216.73.216.15 Web Server : Apache System : Linux webd008.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : ludmqhh ( 137773) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/ludmqhh/www/jscom/../guillaume/wp-content/themes/flexblog/framework/widgets/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* Plugin Name: Author Widget
*/
add_action( 'widgets_init', 'infinity_author_widget_load' );
function infinity_author_widget_load() {
register_widget( 'infinity_author_widget' );
}
class infinity_author_widget extends WP_Widget {
/**
* Widget constructor.
*/
public function __construct() {
parent::__construct(
'infinity_author_widget',
esc_html__( 'Flexblog: Author', 'flexblog' ),
array(
'classname' => 'infinity_author_widget',
'description' => esc_html__( 'Displays Author Widget', 'flexblog' )
),
array(
'width' => 300,
'id_base' => 'infinity_author_widget'
)
);
}
/**
* Widget output.
*/
public function widget( $args, $instance ) {
extract( $args );
$title = esc_attr( $instance['title'] );
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$img_url = esc_attr( $instance['img_url'] );
$img_link = esc_attr( $instance['img_link'] );
$description = esc_attr( $instance['description'] );
echo $before_widget;
if( !empty( $img_url ) ) { ?>
<a href="<?php echo esc_url( $img_link ); ?>" target="_blank">
<img src="<?php echo esc_url( $img_url ); ?>" alt="" />
</a>
<?php }
if ( $title )
echo '<h3>' . esc_attr( $title ) . '</h3>';
if ( $description )
echo '<p>' . esc_attr( $description ) . '</p>';
echo $after_widget;
}
/**
* Saves widget settings.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = esc_attr( $new_instance['title'] );
$instance['img_url'] = esc_attr( $new_instance['img_url'] );
$instance['img_link'] = esc_attr( $new_instance['img_link'] );
$instance['description'] = esc_attr( $new_instance['description'] );
return $instance;
}
/**
* Prints the settings form.
*/
public function form( $instance ) {
// Defaults
$instance = wp_parse_args(
$instance,
array(
'title' => '',
'img_url' => '',
'img_link' => '#',
'description' => ''
)
);
$title = esc_attr( $instance['title'] );
$img_url = esc_attr( $instance['img_url'] );
$img_link = esc_attr( $instance['img_link'] );
$description = esc_attr( $instance['description'] );
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'flexblog' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('img_url')); ?>"><?php esc_html_e( 'Image URL:', 'flexblog' ); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('img_url')); ?>" name="<?php echo esc_attr($this->get_field_name('img_url')); ?>" type="text" value="<?php echo esc_attr($img_url); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('img_link')); ?>"><?php esc_html_e( 'Image Link:', 'flexblog' ); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('img_link')); ?>" name="<?php echo esc_attr($this->get_field_name('img_link')); ?>" type="text" value="<?php echo esc_attr($img_link); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('description')); ?>"><?php esc_html_e( 'Description:', 'flexblog' ); ?></label>
<textarea style="height:200px;" class="widefat" id="<?php echo esc_attr($this->get_field_id('description')); ?>" name="<?php echo esc_attr($this->get_field_name('description')); ?>" type="text"><?php echo esc_attr($description); ?></textarea>
</p>
<?php
}
}
