'widget-oceanwp-contact-info',
'description' => esc_html__( 'Adds support for Contact Info.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
// Since 1.3.8
add_action( 'admin_head-widgets.php', array( $this, 'social_widget_style' ) );
}
/**
* Custom widget style
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function social_widget_style() {
?>
';
if ( $text ) {
echo '
'. do_shortcode( $text ) .'';
}
// Determine link rel.
$ocean_srt = ''. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .'';
$results = ocean_link_rel( $ocean_srt, $nofollow, $target );
$ocean_sr = $results[0];
$link_rel = $results[1];
// Returns screen reader warning when a link triggers an application.
$ocean_sra = ''. esc_html__( 'Opens in your application', 'ocean-extra' ) .'';
if ( $address ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'map_marker' === $address_icon ) {
Ocean_Extra::oe_svg_icon( $address_icon );
} else {
echo '';
}
}
echo '';
echo '';
}
if ( $phone ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'phone' === $phone_icon ) {
Ocean_Extra::oe_svg_icon( $phone_icon );
} else {
echo '';
}
}
echo '';
echo '';
}
if ( $mobile ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'smartphone' === $mobile_icon ) {
Ocean_Extra::oe_svg_icon( $mobile_icon );
} else {
echo '';
}
}
echo '';
echo '';
}
if ( $fax ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'fax' === $fax_icon ) {
Ocean_Extra::oe_svg_icon( $fax_icon );
} else {
echo '';
}
}
echo '';
echo ''. esc_html( $fax_text ) .'';
echo ''. esc_html( $fax ) .'';
echo '
';
echo '';
}
if ( $email ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'envelope' === $email_icon ) {
Ocean_Extra::oe_svg_icon( $email_icon );
} else {
echo '';
}
}
echo '';
echo '';
}
if ( $web ) {
echo '';
if ( 'no-icons' != $style ) {
if ( 'link' === $web_icon ) {
Ocean_Extra::oe_svg_icon( $web_icon );
} else {
echo '';
}
}
echo '';
echo '';
}
if ( $skype ) {
echo '';
echo '';
if ( $skypetxt ) {
echo esc_html( $skypetxt );
} else {
esc_html__( 'Skype', 'ocean-extra' );
}
echo '';
echo $ocean_sra;
echo '';
}
echo '';
// After widget WP hook
echo $args['after_widget'];
}
/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
* @since 1.0.0
*
* @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 ) {
$instance = $old_instance;
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
$instance['style'] = ! empty( $new_instance['style'] ) ? $new_instance['style'] : '';
$instance['text'] = ! empty( $new_instance['text'] ) ? $new_instance['text'] : '';
$instance['target'] = ! empty( $new_instance['target'] ) ? $new_instance['target'] : '';
$instance['nofollow'] = ! empty( $new_instance['nofollow'] ) ? $new_instance['nofollow'] : '';
$instance['address_icon'] = ! empty( $new_instance['address_icon'] ) ? strip_tags( $new_instance['address_icon'] ) : '';
$instance['address_text'] = ! empty( $new_instance['address_text'] ) ? strip_tags( $new_instance['address_text'] ) : '';
$instance['address'] = ! empty( $new_instance['address'] ) ? strip_tags( $new_instance['address'] ) : '';
$instance['address_link'] = ! empty( $new_instance['address_link'] ) ? esc_url( $new_instance['address_link'] ) : '';
$instance['phone_icon'] = ! empty( $new_instance['phone_icon'] ) ? strip_tags( $new_instance['phone_icon'] ) : '';
$instance['phone_text'] = ! empty( $new_instance['phone_text'] ) ? strip_tags( $new_instance['phone_text'] ) : '';
$instance['phone'] = ! empty( $new_instance['phone'] ) ? strip_tags( $new_instance['phone'] ) : '';
$instance['phone_link'] = ! empty( $new_instance['phone_link'] ) ? strip_tags( $new_instance['phone_link'] ) : '';
$instance['mobile_icon'] = ! empty( $new_instance['mobile_icon'] ) ? strip_tags( $new_instance['mobile_icon'] ) : '';
$instance['mobile_text'] = ! empty( $new_instance['mobile_text'] ) ? strip_tags( $new_instance['mobile_text'] ) : '';
$instance['mobile'] = ! empty( $new_instance['mobile'] ) ? strip_tags( $new_instance['mobile'] ) : '';
$instance['mobile_link'] = ! empty( $new_instance['mobile_link'] ) ? strip_tags( $new_instance['mobile_link'] ) : '';
$instance['fax_icon'] = ! empty( $new_instance['fax_icon'] ) ? strip_tags( $new_instance['fax_icon'] ) : '';
$instance['fax_text'] = ! empty( $new_instance['fax_text'] ) ? strip_tags( $new_instance['fax_text'] ) : '';
$instance['fax'] = ! empty( $new_instance['fax'] ) ? strip_tags( $new_instance['fax'] ) : '';
$instance['email_icon'] = ! empty( $new_instance['email_icon'] ) ? strip_tags( $new_instance['email_icon'] ) : '';
$instance['email_text'] = ! empty( $new_instance['email_text'] ) ? strip_tags( $new_instance['email_text'] ) : '';
$instance['email'] = ! empty( $new_instance['email'] ) ? strip_tags( $new_instance['email'] ) : '';
$instance['emailtxt'] = ! empty( $new_instance['emailtxt'] ) ? strip_tags( $new_instance['emailtxt'] ) : '';
$instance['web_icon'] = ! empty( $new_instance['web_icon'] ) ? strip_tags( $new_instance['web_icon'] ) : '';
$instance['web_text'] = ! empty( $new_instance['web_text'] ) ? strip_tags( $new_instance['web_text'] ) : '';
$instance['web'] = ! empty( $new_instance['web'] ) ? esc_url( $new_instance['web'] ) : '';
$instance['webtxt'] = ! empty( $new_instance['webtxt'] ) ? strip_tags( $new_instance['webtxt'] ) : '';
$instance['skype'] = ! empty( $new_instance['skype'] ) ? strip_tags( $new_instance['skype'] ) : '';
$instance['skypetxt'] = ! empty( $new_instance['skypetxt'] ) ? strip_tags( $new_instance['skypetxt'] ) : '';
return $instance;
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
* @since 1.0.0
*
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
// Parse arguments
$instance = wp_parse_args( (array) $instance,
array(
'title' => esc_attr__( 'Contact Info', 'ocean-extra' ),
'style' => esc_attr__( 'Default', 'ocean-extra' ),
'text' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur, aspernatur, velit. Adipisci, animi, molestiae, neque voluptatum non voluptas atque aperiam.',
'target' => 'self',
'nofollow' => 'no',
'address_icon' => 'map_marker',
'address_text' => esc_attr__( 'Address:', 'ocean-extra' ),
'address' => esc_attr__( 'Street Name, FL 54785', 'ocean-extra' ),
'address_link' => '',
'phone_icon' => 'phone',
'phone_text' => esc_attr__( 'Phone:', 'ocean-extra' ),
'phone' => '621-254-2147',
'phone_link' => '',
'mobile_icon' => 'smartphone',
'mobile_text' => esc_attr__( 'Mobile:', 'ocean-extra' ),
'mobile' => '621-254-2147',
'mobile_link' => '',
'fax_icon' => 'fax',
'fax_text' => esc_attr__( 'Fax:', 'ocean-extra' ),
'fax' => '621-254-2147',
'email_icon' => 'envelope',
'email_text' => esc_attr__( 'Email:', 'ocean-extra' ),
'email' => 'contact@support.com',
'emailtxt' => 'contact@support.com',
'web_icon' => 'link',
'web_text' => esc_attr__( 'Website:', 'ocean-extra' ),
'web' => '#',
'webtxt' => 'yourwebsite.com',
'skype' => 'YourUsername',
'skypetxt' => esc_html__( 'Skype Call Us', 'ocean-extra' ),
)
);
?>