February 4, 2016 at 7:29 am
#42238
Theme Horse Support Team
Keymaster
Ok just add below widgets in your child theme widgets. I have registered and added a link for image.
register_widget("ultimate_child_ourteam_widget");
/**************************************************************************************/
/**
* Our Team widget
*/
class ultimate_child_ourteam_widget extends WP_Widget {
function ultimate_child_ourteam_widget() {
$widget_ops = array( 'classname' => 'widget_our_team', 'description' => __( 'Display Our Team ( Our Team Child Layout ) recommendation size ( 300 * 300 )px', 'ultimate' ) );
$control_ops = array( 'width' => 200, 'height' =>250 );
parent::__construct( false, $name = __( 'TH: Our Team Child', 'ultimate' ), $widget_ops, $control_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'number' => '3', 'image1' => '', 'imageurl1' => '', 'text1' => '', 'name1' =>'', 'designation1'=>'','image2'=>'', 'imageurl2' => '','text2'=>'','name2'=>'','designation2'=>'','image3' => '','imageurl3' => '', 'text3' => '', 'name3' =>'', 'designation3'=>'' ) );
$title = strip_tags($instance['title']);
$number = absint( $instance[ 'number' ] );
for ( $i=1; $i<=$number; $i++ ) {
$image = 'image'.$i;
$name = 'name'.$i;
$designation = 'designation'.$i;
$text = 'text'.$i;
$instance[ $image ] = esc_url( $instance[ $image ] );
$instance[ $imageurl ] = esc_url( $instance[ $imageurl ] );
$instance[ $name ] = strip_tags( $instance[ $name ] );
$instance[ $designation ] = strip_tags( $instance[ $designation ] );
$instance[ $text ] = strip_tags( $instance[ $text ] );
}
?>
<p>
<label for="<?php echo $this->get_field_id('number'); ?>">
<?php _e( 'Number of OurTeam:', 'ultimate' ); ?>
</label>
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
<input type="submit" name="savewidget" id="widget-ultimate_ourteam_widget-2-savewidget" class="button button-primary widget-control-save right" value="Save"> <span class="spinner" style="display: none;"></span>
</p>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>">
<?php _e( 'Title:', 'ultimate' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
</p>
<p> </p>
<?php for ( $i=1; $i<=$number; $i++ ) {
$image = 'image'.$i;
$name = 'name'.$i;
$designation = 'designation'.$i;
$text = 'text'.$i;
$instance[ $image ] = esc_url( $instance[ $image ] );
$instance[ $imageurl ] = esc_url( $instance[ $imageurl ] );
$instance[ $name ] = strip_tags( $instance[ $name ] );
$instance[ $designation ] = strip_tags( $instance[ $designation ] );
$instance[ $text ] = strip_tags( $instance[ $text ] );
?>
<p>
<input type="text" class="upload1" id="<?php echo $this->get_field_id($image); ?>" name="<?php echo $this->get_field_name($image); ?>" value="<?php if(isset ( $instance[$image] ) )
echo esc_url( $instance[$image] ); ?>"/>
<input type="button" class="button custom_media_button"name="<?php echo $this->get_field_name($image); ?>" id="custom_media_button_services" value="<?php echo esc_attr( 'Add Image','ultimate'); ?>" onclick="mediaupload.uploader( '<?php echo $this->get_field_id($image); ?>' ); return false;"/>
</p>
<p>
<label for="<?php echo $this->get_field_id('imageurl'); ?>">
<?php _e( 'Image Url '.$i, 'ultimate' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id($imageurl); ?>" name="<?php echo $this->get_field_name($imageurl); ?>" type="text" value="<?php if(isset ( $instance[$imageurl] ) ) echo esc_attr( $instance[$imageurl] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('name'); ?>">
<?php _e( 'Name '.$i, 'ultimate' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id($name); ?>" name="<?php echo $this->get_field_name($name); ?>" type="text" value="<?php if(isset ( $instance[$name] ) ) echo esc_attr( $instance[$name] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('designation'); ?>">
<?php _e( 'Designation '.$i, 'ultimate' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id($designation); ?>" name="<?php echo $this->get_field_name($designation); ?>" type="text" value="<?php if(isset ( $instance[$designation] ) ) echo esc_attr( $instance[$designation] ); ?>" />
</p>
<?php _e( 'OurTeam Description '.$i,'ultimate'); ?>
<textarea class="widefat" rows="8" cols="20" id="<?php echo $this->get_field_id($text); ?>" name="<?php echo $this->get_field_name($text); ?>"><?php if(isset ( $instance[$text] ) ) echo esc_attr( $instance[$text] ); ?></textarea>
<p> </p>
<hr>
<p> </p>
<?php
}
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['number'] = absint( $new_instance['number'] );
for( $i=1; $i<=$instance['number']; $i++ ) {
$image = 'image'.$i;
$imageurl = 'imageurl'.$i;
$name = 'name'.$i;
$designation = 'designation'.$i;
$text = 'text'.$i;
$instance[ $image ] = esc_url_raw( $new_instance[ $image ] );
$instance[ $imageurl ] = esc_url_raw( $new_instance[ $imageurl ] );
$instance[ $name ] = strip_tags( $new_instance[ $name ] );
$instance[ $designation ] = strip_tags( $new_instance[ $designation ] );
$instance[ $text ] = strip_tags( $new_instance[ $text ] );
}
return $instance;
}
function widget( $args, $instance ) {
extract($args);
global $options, $array_of_default_settings;
$options = wp_parse_args( get_option( 'ultimate_theme_options', array() ), ultimate_get_option_defaults());
$title = empty( $instance['title'] ) ? '' : $instance['title'];
$number = empty( $instance['number'] ) ? 2 : $instance['number'];
$image_array = array();
$imageurl_array = array();
$name_array = array();
$designation_array = array();
$text_array = array();
for( $i=1; $i<=$number; $i++ ) {
$image = 'image'.$i;
$name = 'name'.$i;
$designation = 'designation'.$i;
$text = 'text'.$i;
$image = isset( $instance[ $image ] ) ? $instance[ $image ] : '';
$imageurl = isset( $instance[ $imageurl ] ) ? $instance[ $imageurl ] : '';
$name = isset( $instance[ $name ] ) ? $instance[ $name ] : '';
$designation = isset( $instance[ $designation ] ) ? $instance[ $designation ] : '';
$text = isset( $instance[ $text ] ) ? $instance[ $text ] : '';
if( !empty( $image ) || !empty( $name ) || !empty( $designation ) || !empty( $text )) {
if( !empty( $image ) )
array_push( $image_array, $image ); // Push the page id in the array
else array_push($image_array, "");
if( !empty( $name ) )
array_push( $name_array, $name ); // Push the page id in the array
else array_push($name_array, "");
if( !empty( $designation ) )
array_push( $designation_array, $designation ); // Push the page id in the array
else array_push($designation_array, "");
if( !empty( $text ) )
array_push( $text_array, $text ); // Push the page id in the array
else array_push($text_array, "");
}
}
echo $before_widget;
echo '<div class="container clearfix">';
if ( !empty( $title ) ) { echo $before_title . esc_html( $title ) . $after_title; } ?>
<div class="column clearfix">
<?php
$j = 1;
for( $i=0; $i<$number; $i++ ) {
if( $j % 4 == 1 && $j > 1 ) {
$ourteam_class = "one-fourth clearfix-half-team clearfix-fourth";
}
elseif ( $j % 3 == 1 && $j > 1 ) {
if($j<=4 || $j==10){
$ourteam_class = "one-fourth clearfix-third-team";
}else{
$ourteam_class = "one-fourth clearfix-half-team clearfix-third-team";
}
}
elseif ($j % 2 == 1 && $j > 1 ) {
$ourteam_class = "one-fourth clearfix-half-team";
}
else{
$ourteam_class = "one-fourth";
} ?>
<?php if(!empty($image_array[$i]) || !empty($text_array[$i])){?>
<div class="<?php echo $ourteam_class; ?>">
<?php if(!empty($image_array[$i])){ ?>
<div class="our-team-photo"> <a href ="<?php echo $imageurl_array[$i]; ?>"><img src="<?php echo $image_array[$i]; ?>" title="<?php if(!empty($name_array[$i])){ echo $name_array[$i]; } ?>" alt="<?php if(!empty($image_array[$i])){ echo $name_array[$i]; }?>" /> </a></div>
<?php }
if(!empty($text_array[$i])){?>
<div class="our-team-content">
<h3 class="our-team-name"><?php if(!empty($name_array[$i])){ echo $name_array[$i]; } ?></h3> <div class="our-team-designation"><?php if(!empty($designation_array[$i])){ echo' - '; echo $designation_array[$i]; }?></div>
<p><?php echo $text_array[$i]; ?></p>
</div><!-- .our-team-content -->
<?php
} ?>
</div><!-- .one-fourth -->
<?php } ?>
<?php $j++ ;
}
?>
</div>
<?php
echo '</div><!-- .container -->';
echo $after_widget;
}
}
Hope this may help you
Thank you!