first commit

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-08 12:19:53 -04:00
commit 7c8c8b1c76
4586 changed files with 2050693 additions and 0 deletions
@@ -0,0 +1,431 @@
<?php
/**
* About Me Widget.
*
* @package OceanWP WordPress theme
* @since 1.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Start class.
if ( ! class_exists( 'Ocean_Extra_About_Me_Widget' ) ) {
class Ocean_Extra_About_Me_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
// Declare social services array.
$this->social_services_array = apply_filters( 'ocean_about_me_widget_profiles',
array(
'facebook' => array(
'name' => 'Facebook',
'url' => ''
),
'google-plus' => array(
'name' => 'GooglePlus',
'url' => ''
),
'instagram' => array(
'name' => 'Instagram',
'url' => ''
),
'linkedin' => array(
'name' => 'LinkedIn',
'url' => ''
),
'pinterest' => array(
'name' => 'Pinterest',
'url' => ''
),
'twitter' => array(
'name' => 'Twitter',
'url' => ''
),
'youtube' => array(
'name' => 'Youtube',
'url' => ''
),
)
);
// Start up widget.
parent::__construct(
'ocean_about_me',
esc_html__( '&raquo; About Me', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-about-me about-me-widget',
'description' => esc_html__( 'Adds an About Me widget.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
add_action( 'load-widgets.php', array( $this, 'scripts' ), 100 );
/**
* @since 1.3.8
*
*/
add_action( 'admin_head-widgets.php', array( $this, 'social_widget_style' ) );
add_action( 'admin_footer-widgets.php', array( $this, 'print_scripts' ) );
}
/**
* Enqueue media scripts
*
* @since 1.0.0
*/
public function scripts() {
// If is not customizer to avoid conflict.
if ( is_customize_preview() ) {
return;
}
wp_enqueue_media();
}
/**
* Custom widget style
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function social_widget_style() {
?>
<style>
.oceanwp-about-me-widget-services-list { padding-top: 10px; }
.oceanwp-about-me-widget-services-list li { cursor: move; background: #fafafa; padding: 10px; border: 1px solid #e5e5e5; margin-bottom: 10px; }
.oceanwp-about-me-widget-services-list li p { margin: 0 }
.oceanwp-about-me-widget-services-list li label { margin-bottom: 3px; display: block; color: #222; }
.oceanwp-about-me-widget-services-list li label span.fab { margin-right: 10px }
.oceanwp-about-me-widget-services-list .placeholder { border: 1px dashed #e3e3e3 }
.oceanwp-widget-select { width: 100% }
</style>
<?php
}
/**
* Print scripts.
*
* @since 1.3.8
*/
public function print_scripts() {
// If it's not customizer to avoid conflict.
if ( is_customize_preview() ) {
return;
}
?>
<script>
( function( $ ){
$(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'ocean_about_me';
if (typeof(settings.data) !== 'undefined' && typeof(settings.data.search) !== 'undefined') {
if ( settings.data.search( 'action=save-widget' ) !== 'undefined' && typeof(settings.data.search( 'id_base=' + widget_id_base)) !== 'undefined' ) {
oceanwpSortServices();
}
}
} );
function oceanwpSortServices() {
$( '.oceanwp-about-me-widget-services-list' ).each( function() {
var id = $(this).attr( 'id' );
$( '#'+ id ).sortable( {
placeholder : "placeholder",
opacity : 0.6
} );
} );
}
oceanwpSortServices();
}( jQuery ) );
</script>
<?php
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Get social services.
$social_services = isset( $instance['social_services'] ) ? $instance['social_services'] : '';
// Return if no services defined.
if ( ! $social_services ) {
return;
}
// Define vars.
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$avatar = isset( $instance['avatar'] ) ? $instance['avatar'] : '';
$name = isset( $instance['name'] ) ? $instance['name'] : '';
$text = isset( $instance['text'] ) ? $instance['text'] : '';
$social_style = isset( $instance['social_style'] ) ? $instance['social_style'] : '';
$target = isset( $instance['target'] ) ? $instance['target'] : '';
$nofollow = isset( $instance['nofollow'] ) ? $instance['nofollow'] : '';
// Before widget WP hook.
echo $args['before_widget'];
// Show widget title.
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
?>
<div class="oceanwp-about-me">
<div class="oceanwp-about-me-avatar clr">
<?php
// Display the avatar.
if ( $avatar ) : ?>
<img src="<?php echo esc_url( $avatar ); ?>" alt="<?php echo esc_attr( $title ); ?>" />
<?php
endif;
// Display the name.
if ( $name ) :
?>
<h3 class="oceanwp-about-me-name"><?php echo esc_html( $name ); ?></h3>
<?php endif; ?>
</div><!-- .oceanwp-about-me-avatar -->
<?php
// Display the text.
if ( $text ) :
?>
<div class="oceanwp-about-me-text clr"><?php echo do_shortcode( $text ); ?></div>
<?php
endif;
//Determine link rel
$ocean_srt = '<span class="screen-reader-text">'. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .'</span>';
$results = ocean_link_rel( $ocean_srt, $nofollow, $target );
$ocean_sr = $results[0];
$link_rel = $results[1];
// Display the social.
if ( $social_services ) :
?>
<ul class="oceanwp-about-me-social style-<?php echo esc_attr( $social_style ); ?>">
<?php
// Original Array.
$social_services_array = $this->social_services_array;
// Loop through each item in the array.
foreach( $social_services as $key => $val ) {
$link = ! empty( $social_services[$key]['url'] ) ? $social_services[$key]['url'] : null;
$name = $social_services_array[$key]['name'];
$name = esc_html( $name );
/**
*
* Return correct aria label.
* @since 1.6.4
*/
$aria_label = 'aria-label="'. $name .'"';
// Display social links.
if ( $link ) {
$icon = 'youtube' == $key ? 'youtube' : $key;
$icon = 'pinterest' == $key ? 'pinterest-p' : $icon;
echo '<li class="'. esc_attr( $key ) .'"><a href="'. esc_url( $link ) .'" '. $aria_label .' target="_'. esc_attr( $target ) .'" '. $link_rel .'><i class="fab fa-'. esc_attr( $icon ) .'" aria-hidden="true"></i></a>';
echo $ocean_sr;
echo '</li>';
}
}
?>
</ul>
<?php endif; ?>
</div>
<?php
// 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'] = strip_tags( $new_instance['title'] );
$instance['avatar'] = strip_tags( $new_instance['avatar'] );
$instance['name'] = strip_tags( $new_instance['name'] );
$instance['text'] = $new_instance['text'];
$instance['social_style'] = strip_tags( $new_instance['social_style'] );
$instance['target'] = strip_tags( $new_instance['target'] );
$instance['nofollow'] = strip_tags( $new_instance['nofollow'] );
$instance['social_services'] = $new_instance['social_services'];
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 ) {
$instance = wp_parse_args( ( array ) $instance,
array(
'title' => esc_html__( 'About Me', 'ocean-extra' ),
'avatar' => OE_URL .'assets/img/about-avatar.png',
'name' => esc_html__( 'John Doe', 'ocean-extra' ),
'text' => 'Lorem ipsum ex vix illud nonummy novumtatio et his. At vix patrioque scribentur at fugitertissi ext scriptaset verterem molestiae.',
'social_style' => 'color',
'target' => 'blank',
'nofollow' => 'no',
'social_services' => $this->social_services_array
)
);
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</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( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>"><?php esc_html_e( 'Image URL', 'ocean-extra' ); ?>:</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'avatar' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['avatar'] ); ?>" style="margin-bottom:10px;" />
<input class="oceanwp-widget-upload-button button button-secondary" type="button" value="<?php esc_html_e( 'Upload Image', 'ocean-extra' ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>"><?php esc_html_e( 'Name:', 'ocean-extra' ) ?></label>
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'name' ) ); ?>" value="<?php echo esc_attr( $instance['name'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Description:','ocean-extra' ); ?></label>
<textarea rows="15" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" class="widefat" style="height: 100px;"><?php if( !empty( $instance['text'] ) ) { echo esc_textarea( $instance['text'] ); } ?></textarea>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'social_style' ) ); ?>"><?php esc_html_e( 'Social Style:', 'ocean-extra' ); ?></label>
<br />
<select class='widget-select widefat' name="<?php echo esc_attr( $this->get_field_name( 'social_style' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id('social_style') ); ?>">
<option value="color" <?php selected( $instance['social_style'], 'color' ) ?>><?php esc_html_e( 'Color', 'ocean-extra' ); ?></option>
<option value="light" <?php selected( $instance['social_style'], 'light' ) ?>><?php esc_html_e( 'Light', 'ocean-extra' ); ?></option>
<option value="dark" <?php selected( $instance['social_style'], 'dark' ) ?>><?php esc_html_e( 'Dark', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Social Link Target:', 'ocean-extra' ); ?></label>
<select class='widget-select widefat' name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>">
<option value="blank" <?php selected( $instance['target'], 'blank' ) ?>><?php esc_html_e( 'Blank', 'ocean-extra' ); ?></option>
<option value="self" <?php selected( $instance['target'], 'self' ) ?>><?php esc_html_e( 'Self', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>"><?php esc_html_e( 'Add Nofollow Link Rel:', 'ocean-extra' ); ?></label>
<select class='widget-select widefat' name="<?php echo esc_attr( $this->get_field_name( 'nofollow' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>">
<option value="no" <?php selected( $instance['nofollow'], 'no' ) ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<option value="yes" <?php selected( $instance['nofollow'], 'yes' ) ?>><?php esc_html_e( 'Yes', 'ocean-extra' ); ?></option>
</select>
</p>
<?php
$field_id_services = $this->get_field_id( 'social_services' );
$field_name_services = $this->get_field_name( 'social_services' );
?>
<h3 style="margin-top:20px;margin-bottom:0;"><?php esc_html_e( 'Social Links','ocean-extra' ); ?></h3>
<ul id="<?php echo esc_attr( $field_id_services ); ?>" class="oceanwp-about-me-widget-services-list">
<input type="hidden" id="<?php echo esc_attr( $field_name_services ); ?>" value="<?php echo esc_attr( $field_name_services ); ?>">
<input type="hidden" id="<?php echo esc_attr( wp_create_nonce( 'oceanwp_fontawesome_social_widget_nonce' ) ); ?>">
<?php
// Social array.
$social_services_array = $this->social_services_array;
// Get current services display.
$display_services = isset ( $instance['social_services'] ) ? $instance['social_services']: '';
// Loop through social services to display inputs.
foreach( $display_services as $key => $val ) {
$url = ! empty( $display_services[$key]['url'] ) ? esc_url( $display_services[$key]['url'] ) : null;
$name = $social_services_array[$key]['name'];
?>
<li id="<?php echo esc_attr( $field_id_services ); ?>_0<?php echo esc_attr( $key ); ?>">
<p>
<label for="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-name"><?php echo esc_html( strip_tags( $name ) ); ?>:</label>
<input type="hidden" id="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-url" name="<?php echo esc_attr( $field_name_services .'['.$key.'][name]' ); ?>" value="<?php echo esc_attr( $name ); ?>">
<input type="text" class="widefat" id="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-url" name="<?php echo esc_attr( $field_name_services .'['.$key.'][url]' ); ?>" value="<?php echo esc_attr( $url ); ?>" />
</p>
</li>
<?php } ?>
</ul>
<script type="text/javascript">
(function($) {
"use strict";
$( document ).ready( function() {
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$( '.oceanwp-widget-upload-button' ).click(function(e) {
var send_attachment_bkp = wp.media.editor.send.attachment,
button = $(this),
id = button.prev();
_custom_media = true;
wp.media.editor.send.attachment = function( props, attachment ) {
if ( _custom_media ) {
$( id ).val( attachment.url );
} else {
return _orig_send_attachment.apply( this, [props, attachment] );
};
}
wp.media.editor.open( button );
return false;
} );
$( '.add_media').on('click', function() {
_custom_media = false;
} );
} );
} ) ( jQuery );
</script>
<?php
}
}
}
register_widget( 'Ocean_Extra_About_Me_Widget' );
@@ -0,0 +1,544 @@
<?php
/**
* Contact Info Widget.
*
* @package OceanWP WordPress theme
* @since 1.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Contact_Info_Widget' ) ) {
class Ocean_Extra_Contact_Info_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_contact_info',
esc_html__( '&raquo; Contact Info', 'ocean-extra' ),
array(
'classname' => '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() {
?>
<style>
.oceanwp-infos { background: #fafafa; padding: 16px 10px; border: 1px solid #e5e5e5; margin-bottom: 10px; }
.oceanwp-infos h2 { font-size: 16px; margin: 0 0 10px; }
.oceanwp-infos p { margin: 0 0 8px; }
.oceanwp-infos p:last-child { margin: 0; }
.oceanwp-infos label { margin-bottom: 3px; display: block; color: #222; }
</style>
<?php
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$style = isset( $instance['style'] ) ? $instance['style'] : 'default';
$text = isset( $instance['text'] ) ? $instance['text'] : '';
$target = isset( $instance['target'] ) ? $instance['target'] : 'self';
$nofollow = isset( $instance['nofollow'] ) ? $instance['nofollow'] : '';
$address_icon = isset( $instance['address_icon'] ) ? $instance['address_icon'] : '';
$address_text = isset( $instance['address_text'] ) ? $instance['address_text'] : '';
$address = isset( $instance['address'] ) ? $instance['address'] : '';
$address_link = isset( $instance['address_link'] ) ? $instance['address_link'] : '';
$phone_icon = isset( $instance['phone_icon'] ) ? $instance['phone_icon'] : '';
$phone_text = isset( $instance['phone_text'] ) ? $instance['phone_text'] : '';
$phone = isset( $instance['phone'] ) ? $instance['phone'] : '';
$phone_link = isset( $instance['phone_link'] ) ? $instance['phone_link'] : '';
$mobile_icon = isset( $instance['mobile_icon'] ) ? $instance['mobile_icon'] : '';
$mobile_text = isset( $instance['mobile_text'] ) ? $instance['mobile_text'] : '';
$mobile = isset( $instance['mobile'] ) ? $instance['mobile'] : '';
$mobile_link = isset( $instance['mobile_link'] ) ? $instance['mobile_link'] : '';
$fax_icon = isset( $instance['fax_icon'] ) ? $instance['fax_icon'] : '';
$fax_text = isset( $instance['fax_text'] ) ? $instance['fax_text'] : '';
$fax = isset( $instance['fax'] ) ? $instance['fax'] : '';
$email_icon = isset( $instance['email_icon'] ) ? $instance['email_icon'] : '';
$email_text = isset( $instance['email_text'] ) ? $instance['email_text'] : '';
$email = isset( $instance['email'] ) ? $instance['email'] : '';
$emailtxt = isset( $instance['emailtxt'] ) ? $instance['emailtxt'] : '';
$web_icon = isset( $instance['web_icon'] ) ? $instance['web_icon'] : '';
$web_text = isset( $instance['web_text'] ) ? $instance['web_text'] : '';
$web = isset( $instance['web'] ) ? $instance['web'] : '';
$webtxt = isset( $instance['webtxt'] ) ? $instance['webtxt'] : '';
$skype = isset( $instance['skype'] ) ? $instance['skype'] : '';
$skypetxt = isset( $instance['skypetxt'] ) ? $instance['skypetxt'] : '';
// Before widget WP hook.
echo $args['before_widget'];
// Show widget title.
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
echo '<ul class="contact-info-widget '. esc_attr( $style ) .'">';
if ( $text ) {
echo '<li class="text">'. do_shortcode( $text ) .'</li>';
}
// Determine link rel.
$ocean_srt = '<span class="screen-reader-text">'. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .'</span>';
$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 = '<span class="screen-reader-text">'. esc_html__( 'Opens in your application', 'ocean-extra' ) .'</span>';
if ( $address ) {
echo '<li class="address">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $address_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $address_text ) .'</span>';
if ( ! empty( $address_link ) ) {
echo '<a href="'. esc_url( $address_link ) .'" target="_'. esc_attr( $target ) .'" '. $link_rel .'>';
}
echo '<span class="oceanwp-contact-text">'. esc_html( $address ) .'</span>';
if ( ! empty( $address_link ) ) {
echo '</a>';
echo $ocean_sr;
}
echo '</div>';
echo '</li>';
}
if ( $phone ) {
echo '<li class="phone">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $phone_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $phone_text ) .'</span>';
if ( ! empty( $phone_link ) ) {
echo '<a href="tel:'. esc_attr( $phone_link ) .'">';
}
echo '<span class="oceanwp-contact-text">'. esc_html( $phone ) .'</span>';
if ( ! empty( $phone_link ) ) {
echo '</a>';
echo $ocean_sra;
}
echo '</div>';
echo '</li>';
}
if ( $mobile ) {
echo '<li class="mobile">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $mobile_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $mobile_text ) .'</span>';
if ( ! empty( $mobile_link ) ) {
echo '<a href="tel:'. esc_attr( $mobile_link ) .'">';
}
echo '<span class="oceanwp-contact-text">'. esc_html( $mobile ) .'</span>';
if ( ! empty( $mobile_link ) ) {
echo '</a>';
echo $ocean_sra;
}
echo '</div>';
echo '</li>';
}
if ( $fax ) {
echo '<li class="fax">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $fax_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $fax_text ) .'</span>';
echo '<span class="oceanwp-contact-text">'. esc_html( $fax ) .'</span>';
echo '</div>';
echo '</li>';
}
if ( $email ) {
echo '<li class="email">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $email_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $email_text ) .'</span>';
echo '<span class="oceanwp-contact-text">';
echo '<a href="mailto:'. esc_html( antispambot( $email ) ) .'">';
if ( $emailtxt ) {
echo esc_html( $emailtxt );
} else {
echo antispambot( esc_attr( $email ) );
}
echo '</a>';
echo $ocean_sra;
echo '</span>';
echo '</div>';
echo '</li>';
}
if ( $web ) {
echo '<li class="web">';
if ( 'no-icons' != $style ) {
echo '<i class="'. esc_attr( $web_icon ) .'" aria-hidden="true"></i>';
}
echo '<div class="oceanwp-info-wrap">';
echo '<span class="oceanwp-contact-title">'. esc_html( $web_text ) .'</span>';
echo '<span class="oceanwp-contact-text">';
echo '<a href="'. esc_url( $web ) .'" target="_'. esc_attr( $target ) .'" '. $link_rel .'>';
if ( $webtxt ) {
echo esc_html( $webtxt );
} else {
echo esc_html( $web );
}
echo '</a>';
echo $ocean_sr;
echo '</span>';
echo '</div>';
echo '</li>';
}
if ( $skype ) {
echo '<li class="skype">';
echo '<a href="skype:'. esc_attr( $skype ) .'?call" target="_self" class="oceanwp-skype-button">';
if ( $skypetxt ) {
echo esc_html( $skypetxt );
} else {
esc_html__( 'Skype', 'ocean-extra' );
}
echo '</a>';
echo $ocean_sra;
echo '</li>';
}
echo '</ul>';
// 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' => 'icon-location-pin',
'address_text' => esc_attr__( 'Address:', 'ocean-extra' ),
'address' => esc_attr__( 'Street Name, FL 54785', 'ocean-extra' ),
'address_link' => '',
'phone_icon' => 'icon-phone',
'phone_text' => esc_attr__( 'Phone:', 'ocean-extra' ),
'phone' => '621-254-2147',
'phone_link' => '',
'mobile_icon' => 'icon-screen-smartphone',
'mobile_text' => esc_attr__( 'Mobile:', 'ocean-extra' ),
'mobile' => '621-254-2147',
'mobile_link' => '',
'fax_icon' => 'icon-printer',
'fax_text' => esc_attr__( 'Fax:', 'ocean-extra' ),
'fax' => '621-254-2147',
'email_icon' => 'icon-envelope',
'email_text' => esc_attr__( 'Email:', 'ocean-extra' ),
'email' => 'contact@support.com',
'emailtxt' => 'contact@support.com',
'web_icon' => 'icon-link',
'web_text' => esc_attr__( 'Website:', 'ocean-extra' ),
'web' => '#',
'webtxt' => 'yourwebsite.com',
'skype' => 'YourUsername',
'skypetxt' => esc_html__( 'Skype Call Us', 'ocean-extra' ),
)
);
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'style' ) ); ?>"><?php esc_html_e( 'Style', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo $this->get_field_name( 'style' ); ?>" id="<?php echo $this->get_field_id( 'style' ); ?>">
<option value="default" <?php if ( $instance['style'] == 'default') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Default', 'ocean-extra' ); ?></option>
<option value="big-icons" <?php if ( $instance['style'] == 'big-icons') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Big Icons', 'ocean-extra' ); ?></option>
<option value="no-icons" <?php if ( $instance['style'] == 'no-icons') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'No Icons', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Text', 'ocean-extra' ); ?></label>
<textarea rows="15" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" class="widefat" style="height: 100px;"><?php if( !empty( $instance['text'] ) ) { echo esc_textarea( $instance['text'] ); } ?></textarea>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Links Target', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo $this->get_field_name( 'target' ); ?>" id="<?php echo $this->get_field_id( 'target' ); ?>">
<option value="self" <?php if ( $instance['target'] == 'self') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Self', 'ocean-extra' ); ?></option>
<option value="blank" <?php if ( $instance['target'] == 'blank') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Blank', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>"><?php esc_html_e( 'Add Nofollow Link Rel:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'nofollow' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>">
<option value="no" <?php selected( $instance['nofollow'], 'no' ) ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<option value="yes" <?php selected( $instance['nofollow'], 'yes' ) ?>><?php esc_html_e( 'Yes', 'ocean-extra' ); ?></option>
</select>
</p>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Address:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'address_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'address_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address_icon' ) ); ?>" value="<?php echo esc_attr( $instance['address_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'address_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'address_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address_text' ) ); ?>" value="<?php echo esc_attr( $instance['address_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>"><?php esc_html_e( 'Content', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address' ) ); ?>" value="<?php echo esc_attr( $instance['address'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'address_link' ) ); ?>"><?php esc_html_e( 'Link (optional)', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'address_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address_link' ) ); ?>" value="<?php echo esc_attr( $instance['address_link'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Phone:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'phone_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'phone_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone_icon' ) ); ?>" value="<?php echo esc_attr( $instance['phone_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'phone_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'phone_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone_text' ) ); ?>" value="<?php echo esc_attr( $instance['phone_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>"><?php esc_html_e( 'Content', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone' ) ); ?>" value="<?php echo esc_attr( $instance['phone'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'phone_link' ) ); ?>"><?php esc_html_e( 'Link (optional)', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'phone_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone_link' ) ); ?>" value="<?php echo esc_attr( $instance['phone_link'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Mobile:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'mobile_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'mobile_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'mobile_icon' ) ); ?>" value="<?php echo esc_attr( $instance['mobile_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'mobile_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'mobile_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'mobile_text' ) ); ?>" value="<?php echo esc_attr( $instance['mobile_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'mobile' ) ); ?>"><?php esc_html_e( 'Content', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id('mobile') ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'mobile' ) ); ?>" value="<?php echo esc_attr( $instance['mobile'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'mobile_link' ) ); ?>"><?php esc_html_e( 'Link (optional)', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'mobile_link' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'mobile_link' ) ); ?>" value="<?php echo esc_attr( $instance['mobile_link'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Fax:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'fax_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'fax_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'fax_icon' ) ); ?>" value="<?php echo esc_attr( $instance['fax_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'fax_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'fax_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'fax_text' ) ); ?>" value="<?php echo esc_attr( $instance['fax_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'fax' ) ); ?>"><?php esc_html_e( 'Content', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'fax' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'fax' ) ); ?>" value="<?php echo esc_attr( $instance['fax'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Email:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'email_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'email_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email_icon' ) ); ?>" value="<?php echo esc_attr( $instance['email_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'email_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'email_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email_text' ) ); ?>" value="<?php echo esc_attr( $instance['email_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>"><?php esc_html_e( 'Email Address', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'email' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" value="<?php echo esc_attr( $instance['email'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'emailtxt' ) ); ?>"><?php esc_html_e( 'Email Text', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'emailtxt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'emailtxt' ) ); ?>" value="<?php echo esc_attr( $instance['emailtxt'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Website:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'web_icon' ) ); ?>"><?php esc_html_e( 'Icon Class', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'web_icon' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'web_icon' ) ); ?>" value="<?php echo esc_attr( $instance['web_icon'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'web_text' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id('web_text') ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'web_text' ) ); ?>" value="<?php echo esc_attr( $instance['web_text'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'web' ) ); ?>"><?php esc_html_e( 'URL', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'web' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'web' ) ); ?>" value="<?php echo esc_attr( $instance['web'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'webtxt' ) ); ?>"><?php esc_html_e( 'URL Text', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'webtxt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'webtxt' ) ); ?>" value="<?php echo esc_attr( $instance['webtxt'] ); ?>" />
</p>
</div>
<div class="oceanwp-infos">
<h2><?php esc_html_e( 'Skype:', 'ocean-extra' ); ?></h2>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'skype' ) ); ?>"><?php esc_html_e( 'Username', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'skype' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'skype' ) ); ?>" value="<?php echo esc_attr( $instance['skype'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'skypetxt' ) ); ?>"><?php esc_html_e( 'Text', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'skypetxt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'skypetxt' ) ); ?>" value="<?php echo esc_attr( $instance['skypetxt'] ); ?>" />
</p>
</div>
<?php
}
}
}
register_widget( 'Ocean_Extra_Contact_Info_Widget' );
@@ -0,0 +1,120 @@
<?php
/**
* Custom Header logo widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Custom_Header_Logo_Widget' ) ) {
class Ocean_Extra_Custom_Header_Logo_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_custom_header_logo',
esc_html__( '&raquo; Custom Header Logo', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-custom-header-logo custom-header-logo-widget',
'description' => esc_html__( 'Display the logo for the Custom Header style.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Define vars
$position = isset( $instance['position'] ) ? $instance['position'] : 'left';
// Add classes
$classes = array( 'custom-header-logo', 'clr' );
$classes[] = $position;
$classes = implode( ' ', $classes );
// Before widget WP hook
echo $args['before_widget']; ?>
<div class="<?php echo esc_attr( $classes ); ?>">
<?php
// Logo
get_template_part( 'partials/header/logo' ); ?>
</div>
<?php
// 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['position'] = strip_tags( $new_instance['position'] );
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 ) {
$instance = wp_parse_args( ( array ) $instance, array(
'position' => 'left',
) ); ?>
<p>
<?php esc_html_e( 'This widget is to display with your page builder the logo for the Custom Header style.', 'ocean-extra' ); ?>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('position') ); ?>"><?php esc_html_e( 'Position:', 'ocean-extra' ); ?></label>
<br />
<select class='widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('position') ); ?>" id="<?php echo esc_attr( $this->get_field_id('position') ); ?>">
<option value="left" <?php selected( $instance['position'], 'left' ) ?>><?php esc_html_e( 'Left', 'ocean-extra' ); ?></option>
<option value="right" <?php selected( $instance['position'], 'right' ) ?>><?php esc_html_e( 'Right', 'ocean-extra' ); ?></option>
<option value="center" <?php selected( $instance['position'], 'center' ) ?>><?php esc_html_e( 'Center', 'ocean-extra' ); ?></option>
</select>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Custom_Header_Logo_Widget' );
@@ -0,0 +1,126 @@
<?php
/**
* Custom Header Nav widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Custom_Header_Nav_Widget' ) ) {
class Ocean_Extra_Custom_Header_Nav_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_custom_header_nav',
esc_html__( '&raquo; Custom Header Nav', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-custom-header-nav custom-header-nav-widget',
'description' => esc_html__( 'Display the main menu for the Custom Header style.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Define vars
$position = isset( $instance['position'] ) ? $instance['position'] : 'left';
// Add classes
$classes = array( 'custom-header-nav', 'clr' );
$classes[] = $position;
$classes = implode( ' ', $classes );
// Before widget WP hook
echo $args['before_widget']; ?>
<div class="<?php echo esc_attr( $classes ); ?>">
<?php
// Menu
get_template_part( 'partials/header/nav' );
// Mobile menu
get_template_part( 'partials/mobile/mobile-icon' );
// Drop down mobile menu style
get_template_part( 'partials/mobile/mobile-dropdown' ); ?>
</div>
<?php
// 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['position'] = strip_tags( $new_instance['position'] );
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 ) {
$instance = wp_parse_args( ( array ) $instance, array(
'position' => 'left',
) ); ?>
<p>
<?php esc_html_e( 'This widget is to display with your page builder the menu for the Custom Header style.', 'ocean-extra' ); ?>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('position') ); ?>"><?php esc_html_e( 'Position:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('position') ); ?>" id="<?php echo esc_attr( $this->get_field_id('position') ); ?>">
<option value="left" <?php selected( $instance['position'], 'left' ) ?>><?php esc_html_e( 'Left', 'ocean-extra' ); ?></option>
<option value="right" <?php selected( $instance['position'], 'right' ) ?>><?php esc_html_e( 'Right', 'ocean-extra' ); ?></option>
<option value="center" <?php selected( $instance['position'], 'center' ) ?>><?php esc_html_e( 'Center', 'ocean-extra' ); ?></option>
</select>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Custom_Header_Nav_Widget' );
@@ -0,0 +1,203 @@
<?php
/**
* Custom Links Widget.
*
* @package OceanWP WordPress theme
* @since 1.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Custom_Links_Widget' ) ) {
class Ocean_Extra_Custom_Links_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_custom_links',
esc_html__( '&raquo; Custom Links', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-custom-links custom-links-widget',
'description' => esc_html__( 'Displays custom links.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$count = isset( $instance['count'] ) ? $instance['count'] : '';
$target = isset( $instance['target'] ) ? $instance['target'] : '';
$nofollow = isset( $instance['nofollow'] ) ? $instance['nofollow'] : '';
// Before widget WP hook.
echo $args['before_widget'];
// Show widget title.
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Determine link rel.
$ocean_srt = '<span class="screen-reader-text">'. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .'</span>';
$results = ocean_link_rel( $ocean_srt, $nofollow, $target );
$ocean_sr = $results[0];
$link_rel = $results[1];
// Display custom links.
echo '<ul class="oceanwp-custom-links">';
if ( $count !== '0' ) {
for ( $i=1; $i<=$count; $i++ ) {
$url = isset( $instance["url_".$i] ) ? $instance["url_".$i] : '';
$text = isset( $instance["text_".$i] ) ? $instance["text_".$i]:'';
echo '<li>';
echo '<a href="'. esc_url( $url ) .'" target="_'. esc_attr( $target ) .'" '. $link_rel .'>'. esc_attr( $text ) .'</a>';
echo $ocean_sr;
echo '</li>';
}
}
echo '</ul>';
// After widget WP hook.
echo $args['after_widget'];
}
/**
* Updates the widget control options for the particular instance of the widget.
*
* @since 1.0.0
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
$instance['count'] = ! empty( $new_instance['count'] ) ? strip_tags( $new_instance['count'] ) : '';
$instance['target'] = ! empty( $new_instance['target'] ) ? strip_tags( $new_instance['target'] ) : '';
$instance['nofollow'] = ! empty( $new_instance['nofollow'] ) ? strip_tags( $new_instance['nofollow'] ) : '';
for ( $i=1;$i<=$instance['count'];$i++ ) {
$instance["url_".$i] = ! empty( $new_instance['url_'.$i] ) ? strip_tags( $new_instance['url_'.$i] ) : '';
$instance["text_".$i] = ! empty( $new_instance['text_'.$i] ) ? strip_tags( $new_instance['text_'.$i] ) : '';
}
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.
extract( wp_parse_args( (array) $instance,
array(
'title' => esc_attr__( 'Useful Links', 'ocean-extra' ),
'count' => '5',
'target' => esc_html__( 'Blank', 'ocean-extra' ),
'nofollow' => esc_html__( 'No', 'ocean-extra' ),
) )
);
for ( $i=1;$i<=15;$i++ ) {
$url = 'url_'.$i;
$$url = isset( $instance[$url] ) ? $instance[$url] : '';
$text = 'text_'.$i;
$$text = isset( $instance[$text] ) ? $instance[$text] : '';
}
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Link Target:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>">
<option value="blank" <?php selected( $target, 'blank' ) ?>><?php esc_html_e( 'Blank', 'ocean-extra' ); ?></option>
<option value="self" <?php selected( $target, 'self' ) ?>><?php esc_html_e( 'Self', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>"><?php esc_html_e( 'Add Nofollow Link Rel:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'nofollow' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>">
<option value="no" <?php selected( $nofollow, 'no' ) ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<option value="yes" <?php selected( $nofollow, 'yes' ) ?>><?php esc_html_e( 'Yes', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('count') ); ?>"><?php esc_html_e( 'Number of Custom Links:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name('count') ); ?>" id="<?php echo esc_attr( $this->get_field_id('count') ); ?>">
<option value="1" <?php selected( $count, '1' ) ?>><?php esc_html_e( '1', 'ocean-extra' ); ?></option>
<option value="2" <?php selected( $count, '2' ) ?>><?php esc_html_e( '2', 'ocean-extra' ); ?></option>
<option value="3" <?php selected( $count, '3' ) ?>><?php esc_html_e( '3', 'ocean-extra' ); ?></option>
<option value="4" <?php selected( $count, '4' ) ?>><?php esc_html_e( '4', 'ocean-extra' ); ?></option>
<option value="5" <?php selected( $count, '5' ) ?>><?php esc_html_e( '5', 'ocean-extra' ); ?></option>
<option value="6" <?php selected( $count, '6' ) ?>><?php esc_html_e( '6', 'ocean-extra' ); ?></option>
<option value="7" <?php selected( $count, '7' ) ?>><?php esc_html_e( '7', 'ocean-extra' ); ?></option>
<option value="8" <?php selected( $count, '8' ) ?>><?php esc_html_e( '8', 'ocean-extra' ); ?></option>
<option value="9" <?php selected( $count, '9' ) ?>><?php esc_html_e( '9', 'ocean-extra' ); ?></option>
<option value="10" <?php selected( $count, '10' ) ?>><?php esc_html_e( '10', 'ocean-extra' ); ?></option>
<option value="11" <?php selected( $count, '11' ) ?>><?php esc_html_e( '11', 'ocean-extra' ); ?></option>
<option value="12" <?php selected( $count, '12' ) ?>><?php esc_html_e( '12', 'ocean-extra' ); ?></option>
<option value="13" <?php selected( $count, '13' ) ?>><?php esc_html_e( '13', 'ocean-extra' ); ?></option>
<option value="14" <?php selected( $count, '14' ) ?>><?php esc_html_e( '14', 'ocean-extra' ); ?></option>
<option value="15" <?php selected( $count, '15' ) ?>><?php esc_html_e( '15', 'ocean-extra' ); ?></option>
</select>
</p>
<div class="custom_links_wrap">
<?php for ( $i=1;$i<=15;$i++ ): $url = 'url_'.$i; $text = 'text_'.$i; ?>
<div class="custom_links_<?php echo esc_attr( $i );?>" <?php if ( $i>$count ):?>style="display:none;"<?php endif;?> style="padding-bottom:30px">
<p>
<label for="<?php echo esc_attr( $this->get_field_id( $url ) ); ?>">
<?php printf( '#%s URL:', esc_attr( $i ) );?>
</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $url ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $url ) ); ?>" type="text" value="<?php echo esc_attr( $$url ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( $text ) ); ?>">
<?php printf( '#%s Text:', esc_attr( $i ) );?>
</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $text ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $text ) ); ?>" type="text" value="<?php echo esc_attr( $$text ); ?>" />
</p>
</div>
<?php endfor; ?>
</div>
<?php
}
}
}
register_widget( 'Ocean_Extra_Custom_Links_Widget' );
@@ -0,0 +1,381 @@
<?php
/**
* Custom Menu Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Custom_Menu_Widget' ) ) {
class Ocean_Extra_Custom_Menu_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_custom_menu',
esc_html__( '&raquo; Custom Menu', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-custom-menu custom-menu-widget',
'description' => esc_html__( 'Displays custom menu.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
$position = isset( $instance['position'] ) ? $instance['position'] : 'left';
$dropdown = isset( $instance['dropdown'] ) ? $instance['dropdown'] : 'hover';
$target = isset( $instance['target'] ) ? $instance['target'] : 'icon';
$nav_padding = isset( $instance['nav_padding'] ) ? $instance['nav_padding'] : '';
$nav_link_color = isset( $instance['nav_link_color'] ) ? $instance['nav_link_color'] : '';
$nav_link_hover_color = isset( $instance['nav_link_hover_color'] ) ? $instance['nav_link_hover_color'] : '';
$font_size = isset( $instance['font_size'] ) ? $instance['font_size'] : '';
$line_height = isset( $instance['line_height'] ) ? $instance['line_height'] : '';
$letter_spacing = isset( $instance['letter_spacing'] ) ? $instance['letter_spacing'] : '';
$text_transform = isset( $instance['text_transform'] ) ? $instance['text_transform'] : '';
if ( ! $nav_menu ) {
return;
}
// Before widget WP hook
echo $args['before_widget'];
// Style
if ( $nav_padding && '8px 0' != $nav_padding
|| $nav_link_color && '#555' != $nav_link_color
|| $nav_link_hover_color && '#333' != $nav_link_hover_color
|| $font_size && '13' != $font_size
|| $line_height && '20' != $line_height
|| $letter_spacing && '0.6' != $letter_spacing
|| $text_transform && 'default' != $text_transform ) {
echo '<style type="text/css">';
if ( $nav_padding && '8px 0' != $nav_padding
|| $nav_link_color && '#555' != $nav_link_color
|| $font_size && '13' != $font_size
|| $line_height && '20' != $line_height
|| $letter_spacing && '0.6' != $letter_spacing
|| $text_transform && 'default' != $text_transform ) {
echo '.' . esc_attr( $this->id ) . ' > ul > li > a, .custom-menu-widget .' . esc_attr( $this->id ) . ' .dropdown-menu .sub-menu li a.menu-link{';
if ( $nav_padding && '8px 0' != $nav_padding ) {
echo 'padding:' . esc_attr( $nav_padding ) . ';';
}
if ( $nav_link_color && '#555' != $nav_link_color ) {
echo 'color:' . esc_attr( $nav_link_color ) . ';';
}
if ( $font_size && '13' != $font_size ) {
echo 'font-size:' . esc_attr( $font_size ) . 'px;';
}
if ( $line_height && '20' != $line_height ) {
echo 'line-height:' . esc_attr( $line_height ) . 'px;';
}
if ( $letter_spacing && '0.6' != $letter_spacing ) {
echo 'letter-spacing:' . esc_attr( $letter_spacing ) . 'px;';
}
if ( $text_transform && 'default' != $text_transform ) {
echo 'text-transform:' . esc_attr( $text_transform ) . ';';
}
echo '}';
echo '.custom-menu-widget .' . esc_attr( $this->id ) . '.oceanwp-custom-menu > ul.click-menu .open-this{';
if ( $nav_link_color && '#555' != $nav_link_color ) {
echo 'color:' . esc_attr( $nav_link_color ) . ';';
}
if ( $font_size && '13' != $font_size ) {
echo 'font-size:' . esc_attr( $font_size ) . 'px;';
}
echo '}';
}
if ( $nav_link_hover_color && '#333' != $nav_link_hover_color ) {
echo '.' . esc_attr( $this->id ) . ' > ul > li > a:hover, .custom-menu-widget .' . esc_attr( $this->id ) . ' .dropdown-menu .sub-menu li a.menu-link:hover{';
echo 'color:' . esc_attr( $nav_link_hover_color ) . ';';
echo '}';
echo '.custom-menu-widget .' . esc_attr( $this->id ) . '.oceanwp-custom-menu > ul.click-menu .open-this:hover{';
echo 'color:' . esc_attr( $nav_link_hover_color ) . ';';
echo '}';
}
echo '</style>';
}
// Show widget title
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Menu classes
$menu_classes = array( 'dropdown-menu' );
// Dropdown
if ( 'hover' == $dropdown ) {
$menu_classes[] = 'sf-menu';
} else if ( 'click' == $dropdown ) {
$menu_classes[] = 'click-menu';
}
$menu_classes = implode( ' ', $menu_classes );
$nav_menu_args = array(
'menu' => $nav_menu,
'fallback_cb' => false,
'container' => false,
'menu_class' => $menu_classes,
'walker' => new Ocean_Extra_Nav_Walker(),
);
// Add classes
$classes = array( 'oceanwp-custom-menu', 'clr' );
$classes[] = esc_attr( $this->id );
$classes[] = esc_attr( $position );
$classes[] = 'dropdown-' . esc_attr( $dropdown );
if ( 'click' == $dropdown ) {
$classes[] = 'click-' . esc_attr( $target );
}
$classes = implode( ' ', $classes );
echo '<div class="'. esc_attr( $classes ) .'">';
wp_nav_menu( $nav_menu_args );
echo '</div>';
// After widget WP hook
echo $args['after_widget'];
if ( 'click' == $dropdown ) { ?>
<script type="text/javascript">
( function( $ ) {
$( '.<?php echo esc_attr( $this->id ); ?>.oceanwp-custom-menu.dropdown-click ul.dropdown-menu' ).each( function() {
var IconDown = '<i class="fa fa-angle-down"></i>',
linkHeight = $( this ).find( 'li.menu-item-has-children > a' ).outerHeight(),
target;
$( this ).find( 'li.menu-item-has-children > a' ).prepend( '<div class="open-this">'+ IconDown +'</div>' );
$( this ).find( 'li.menu-item-has-children > a .open-this' ).css( {
'line-height' : linkHeight +'px',
} );
// Target
if ( $( this ).parent().hasClass( 'click-link' ) ) {
target = $( this ).find( 'li.menu-item-has-children > a' );
} else {
target = $( this ).find( '.open-this' );
}
target.on( 'click', function() {
// Target
if ( $( this ).closest( '.<?php echo esc_attr( $this->id ); ?>.oceanwp-custom-menu.dropdown-click' ).hasClass( 'click-link' ) ) {
var parent = $( this ).parent(),
IconDown = $( this ).find( '.open-this' ).parent().parent(),
IconUp = $( this ).find( '.open-this' ).parent().parent();
} else {
var parent = $( this ).parent().parent(),
IconDown = $( this ).parent().parent(),
IconUp = $( this ).parent().parent();
}
if ( parent.hasClass( 'opened' ) ) {
IconDown.removeClass( 'opened' ).find( '> ul' ).slideUp( 200 );
} else {
IconUp.addClass( 'opened' ).find( '> ul' ).slideDown( 200 );
}
// Return false
return false;
} );
} );
} )( jQuery );
</script>
<?php
}
}
/**
* Updates the widget control options for the particular instance of the widget.
*
* @since 1.0.0
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
$instance['nav_menu'] = ! empty( $new_instance['nav_menu'] ) ? strip_tags( $new_instance['nav_menu'] ) : '';
$instance['position'] = strip_tags( $new_instance['position'] );
$instance['dropdown'] = strip_tags( $new_instance['dropdown'] );
$instance['target'] = strip_tags( $new_instance['target'] );
$instance['nav_padding'] = strip_tags( $new_instance['nav_padding'] );
$instance['nav_link_color'] = sanitize_hex_color( $new_instance['nav_link_color'] );
$instance['nav_link_hover_color'] = sanitize_hex_color( $new_instance['nav_link_hover_color'] );
$instance['font_size'] = strip_tags( $new_instance['font_size'] );
$instance['line_height'] = strip_tags( $new_instance['line_height'] );
$instance['letter_spacing'] = strip_tags( $new_instance['letter_spacing'] );
$instance['text_transform'] = strip_tags( $new_instance['text_transform'] );
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 ) {
global $wp_customize;
$instance = wp_parse_args( ( array ) $instance, array(
'title' => '',
'nav_menu' => '',
'position' => 'left',
'dropdown' => 'hover',
'target' => 'icon',
'nav_padding' => '',
'nav_link_color' => '#555',
'nav_link_hover_color' => '#333',
'font_size' => '13',
'line_height' => '20',
'letter_spacing' => '0.6',
'text_transform' => 'default',
) );
// Get menus
$menus = wp_get_nav_menus();
$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
// If no menus exists, direct the user to go and create some. ?>
<p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>>
<?php
if ( $wp_customize instanceof WP_Customize_Manager ) {
$url = 'javascript: wp.customize.panel( "nav_menus" ).focus();';
} else {
$url = admin_url( 'nav-menus.php' );
}
?>
<?php echo sprintf( esc_html__( 'No menus have been created yet. <a href="%s">Create some</a>.', 'ocean-extra' ), esc_attr( $url ) ); ?>
</p>
<div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>"><?php esc_html_e( 'Select Menu:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" id="<?php echo esc_attr( $this->get_field_id( 'nav_menu' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_menu' ) ); ?>">
<option value="0"><?php esc_html_e( '&mdash; Select &mdash;', 'ocean-extra' ); ?></option>
<?php foreach ( $menus as $menu ) : ?>
<option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $instance['nav_menu'], $menu->term_id ); ?>>
<?php echo esc_html( $menu->name ); ?>
</option>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('position') ); ?>"><?php esc_html_e( 'Position:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('position') ); ?>" id="<?php echo esc_attr( $this->get_field_id('position') ); ?>">
<option value="left" <?php selected( $instance['position'], 'left' ) ?>><?php esc_html_e( 'Left', 'ocean-extra' ); ?></option>
<option value="right" <?php selected( $instance['position'], 'right' ) ?>><?php esc_html_e( 'Right', 'ocean-extra' ); ?></option>
<option value="center" <?php selected( $instance['position'], 'center' ) ?>><?php esc_html_e( 'Center', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('dropdown') ); ?>"><?php esc_html_e( 'Dropdown Style:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('dropdown') ); ?>" id="<?php echo esc_attr( $this->get_field_id('dropdown') ); ?>">
<option value="hover" <?php selected( $instance['dropdown'], 'hover' ) ?>><?php esc_html_e( 'Hover', 'ocean-extra' ); ?></option>
<option value="click" <?php selected( $instance['dropdown'], 'click' ) ?>><?php esc_html_e( 'Click', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('target') ); ?>"><?php esc_html_e( 'Target:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('target') ); ?>" id="<?php echo esc_attr( $this->get_field_id('target') ); ?>">
<option value="icon" <?php selected( $instance['target'], 'icon' ) ?>><?php esc_html_e( 'Icon', 'ocean-extra' ); ?></option>
<option value="link" <?php selected( $instance['target'], 'link' ) ?>><?php esc_html_e( 'Link', 'ocean-extra' ); ?></option>
</select>
<small><?php esc_html_e( 'If the Click dropdown style is selected', 'ocean-extra' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nav_padding' ) ); ?>"><?php esc_html_e( 'Menu Padding:', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'nav_padding' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_padding' ) ); ?>" value="<?php echo esc_attr( $instance['nav_padding'] ); ?>" />
<small style="color: #777;"><?php esc_html_e( 'top left bottom right, eg: 15px 8px 15px 25px', 'ocean-extra' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nav_link_color' ) ); ?>"><?php esc_html_e( 'Menu Link Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'nav_link_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_link_color' ) ); ?>" value="<?php echo esc_attr( $instance['nav_link_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nav_link_hover_color' ) ); ?>"><?php esc_html_e( 'Menu Link Hover Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'nav_link_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'nav_link_hover_color' ) ); ?>" value="<?php echo esc_attr( $instance['nav_link_hover_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>"><?php esc_html_e( 'Font Size (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="5" max="50" step="1" id="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'font_size' ) ); ?>" value="<?php echo esc_attr( $instance['font_size'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'line_height' ) ); ?>"><?php esc_html_e( 'Line Height (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="5" max="200" step="1" id="<?php echo esc_attr( $this->get_field_id( 'line_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'line_height' ) ); ?>" value="<?php echo esc_attr( $instance['line_height'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'letter_spacing' ) ); ?>"><?php esc_html_e( 'Letter Spacing (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="0" max="5" step="0.1" id="<?php echo esc_attr( $this->get_field_id( 'letter_spacing' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'letter_spacing' ) ); ?>" value="<?php echo esc_attr( $instance['letter_spacing'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('text_transform') ); ?>"><?php esc_html_e( 'Text Transform:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('text_transform') ); ?>" id="<?php echo esc_attr( $this->get_field_id('position') ); ?>">
<option value="default" <?php selected( $instance['text_transform'], 'default' ) ?>><?php esc_html_e( 'Default', 'ocean-extra' ); ?></option>
<option value="capitalize" <?php selected( $instance['text_transform'], 'capitalize' ) ?>><?php esc_html_e( 'Capitalize', 'ocean-extra' ); ?></option>
<option value="lowercase" <?php selected( $instance['text_transform'], 'lowercase' ) ?>><?php esc_html_e( 'Lowercase', 'ocean-extra' ); ?></option>
<option value="uppercase" <?php selected( $instance['text_transform'], 'uppercase' ) ?>><?php esc_html_e( 'Uppercase', 'ocean-extra' ); ?></option>
</select>
</p>
</div>
<?php
}
}
}
register_widget( 'Ocean_Extra_Custom_Menu_Widget' );
@@ -0,0 +1,338 @@
<?php
/**
* Facebook Like Box widget.
*
* Based on Jetpack Facebook Like Box widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Facebook_Widget' ) ) {
class Ocean_Extra_Facebook_Widget extends WP_Widget {
private $default_height = 300;
private $default_width = 300;
private $max_width = 9999;
private $min_width = 0;
private $max_height = 9999;
private $min_height = 100;
private $default_colorscheme = 'light';
private $allowed_colorschemes = array( 'light', 'dark' );
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_facebook',
esc_html__( '&raquo; Facebook Like Box', 'ocean-extra' ),
array(
'classname' => 'widget_facebook_likebox',
'description' => esc_html__( 'Display a Facebook Like Box to connect visitors to your Facebook Page.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
extract( $args );
$like_args = $this->normalize_facebook_args( $instance['like_args'] );
if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) {
if ( current_user_can('edit_theme_options') ) {
echo $before_widget;
echo '<p>' . sprintf( esc_html__( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%s">widget settings</a>.', 'ocean-extra' ), esc_url( admin_url( 'widgets.php' ) ) ) . '</p>';
echo $after_widget;
}
echo '<!-- Invalid Facebook Page URL -->';
return;
}
$title = apply_filters( 'widget_title', $instance['title'] );
$page_url = set_url_scheme( $like_args['href'], 'https' );
$like_args['show_faces'] = (bool) $like_args['show_faces'] ? 'true' : 'false';
$like_args['stream'] = (bool) $like_args['stream'] ? 'true' : 'false';
$like_args['force_wall'] = (bool) $like_args['force_wall'] ? 'true' : 'false';
$like_args['show_border']= (bool) $like_args['show_border'] ? 'true' : 'false';
$like_args['header'] = (bool) $like_args['header'] ? 'true' : 'false';
$like_bg_colour = apply_filters( 'ocean_fb_likebox_bg', ( 'dark' == $like_args['colorscheme'] ? '#000' : '#fff' ), $like_args['colorscheme'] );
$locale = $this->get_locale();
if ( $locale && 'en_US' != $locale )
$like_args['locale'] = $locale;
$like_args = urlencode_deep( $like_args );
$like_url = add_query_arg(
$like_args,
'https://www.facebook.com/plugins/likebox.php'
);
// Before widget WP hook
echo $args['before_widget'];
if ( ! empty( $title ) ) :
echo $before_title;
$likebox_widget_title = '<a href="' . esc_url( $page_url ) . '">' . esc_html( $title ) . '</a>';
echo apply_filters( 'ocean_facebook_likebox_title', $likebox_widget_title, $title, $page_url );
echo $after_title;
endif; ?>
<iframe src="<?php echo esc_url( $like_url ); ?>" scrolling="no" frameborder="0" style="border: none; overflow: hidden;<?php echo 0 != $like_args['width'] ? ' width: ' . (int) $like_args['width'] . 'px; ' : ''; ?> height: <?php echo (int) $like_args['height']; ?>px; background: <?php echo esc_attr( $like_bg_colour ); ?>"></iframe><?php
// After widget WP hook
echo $args['after_widget'];
do_action( 'ocean_stats_extra', 'widget', 'facebook-likebox' );
}
/**
* 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 = array(
'title' => '',
'like_args' => $this->get_default_args(),
);
$instance['title'] = trim( strip_tags( stripslashes( $new_instance['title'] ) ) );
// Set up widget values
$instance['like_args'] = array(
'href' => trim( strip_tags( stripslashes( $new_instance['href'] ) ) ),
'width' => (int) $new_instance['width'],
'height' => (int) $new_instance['height'],
'colorscheme' => $new_instance['colorscheme'],
'show_faces' => (bool) $new_instance['show_faces'],
'stream' => (bool) $new_instance['stream'],
'show_border' => (bool) $new_instance['show_border'],
'header' => false, // The header just displays "Find us on Facebook"; it's redundant with the title
'force_wall' => (bool) $new_instance['force_wall'],
);
$instance['like_args'] = $this->normalize_facebook_args( $instance['like_args'] );
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 ) {
$instance = wp_parse_args( (array) $instance, array(
'title' => '',
'like_args' => $this->get_default_args()
) );
$like_args = $this->normalize_facebook_args( $instance['like_args'] ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>"><?php esc_html_e( 'Facebook Page URL', 'ocean-extra' ); ?></label>
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'href' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'href' ) ); ?>" value="<?php echo esc_url( $like_args['href'] ); ?>" class="widefat" />
<br />
<small><?php esc_html_e( 'The Like Box only works with ', 'ocean-extra' ); ?><a href="http://www.facebook.com/help/?faq=174987089221178" target="_blank"><?php esc_html_e( 'Facebook Pages', 'ocean-extra' ); ?></a></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>"><?php esc_html_e( 'Width', 'ocean-extra' ); ?></label>
<input type="number" class="smalltext" min="1" max="999" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'width' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'width' ) ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="text-align: center;" />px
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>"><?php esc_html_e( 'Height', 'ocean-extra' ); ?></label>
<input type="number" class="smalltext" min="1" max="999" maxlength="3" name="<?php echo esc_attr( $this->get_field_name( 'height' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'height' ) ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="text-align: center;" />px
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'colorscheme' ) ); ?>"><?php esc_html_e( 'Color Scheme', 'ocean-extra' ); ?></label>
<select name="<?php echo esc_attr( $this->get_field_name( 'colorscheme' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'colorscheme' ) ); ?>">
<option value="light" <?php selected( $like_args['colorscheme'], 'light' ); ?>><?php esc_html_e( 'Light', 'ocean-extra' ); ?></option>
<option value="dark" <?php selected( $like_args['colorscheme'], 'dark' ); ?>><?php esc_html_e( 'Dark', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'show_faces' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_faces' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_faces' ) ); ?>" <?php checked( $like_args['show_faces'] ); ?> />
<?php esc_html_e( 'Show Faces', 'ocean-extra' ); ?>
<br />
<small><?php esc_html_e( 'Show profile photos in the plugin.', 'ocean-extra' ); ?></small>
</label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'stream' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>" <?php checked( $like_args['stream'] ); ?> />
<?php esc_html_e( 'Show Stream', 'ocean-extra' ); ?>
<br />
<small><?php esc_html_e( 'Show the profile stream for the public profile.', 'ocean-extra' ); ?></small>
</label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'show_border' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_border' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_border' ) ); ?>" <?php checked( $like_args['show_border'] ); ?> />
<?php esc_html_e( 'Show Border', 'ocean-extra' ); ?>
<br />
<small><?php esc_html_e( 'Show a border around the plugin.', 'ocean-extra' ); ?></small>
</label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'force_wall' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'force_wall' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'force_wall' ) ); ?>" <?php checked( $like_args['force_wall'] ); ?> />
<?php esc_html_e( 'Show Wall', 'ocean-extra' ); ?>
<br />
<small><?php esc_html_e( 'Show the wall for a Places page rather than friend activity.', 'ocean-extra' ); ?></small>
</label>
</p>
<?php
}
public function get_default_args() {
$defaults = array(
'href' => '',
'width' => $this->default_width,
'height' => $this->default_height,
'colorscheme' => $this->default_colorscheme,
'show_faces' => true,
'stream' => false,
'show_border' => true,
'header' => false,
'force_wall' => false,
);
return apply_filters( 'ocean_facebook_likebox_defaults', $defaults );
}
public function normalize_facebook_args( $args ) {
$args = wp_parse_args( (array) $args, $this->get_default_args() );
// Validate the Facebook Page URL
if ( $this->is_valid_facebook_url( $args['href'] ) ) {
$temp = explode( '?', $args['href'] );
$args['href'] = str_replace( array( 'http://facebook.com', 'https://facebook.com' ), array( 'http://www.facebook.com', 'https://www.facebook.com' ), $temp[0] );
} else {
$args['href'] = '';
}
$args['width'] = $this->normalize_int_value( (int) $args['width'], $this->default_width, $this->max_width, $this->min_width );
$args['height'] = $this->normalize_int_value( (int) $args['height'], $this->default_height, $this->max_height, $this->min_height );
$args['colorscheme'] = $this->normalize_text_value( $args['colorscheme'], $this->default_colorscheme, $this->allowed_colorschemes );
$args['show_faces'] = (bool) $args['show_faces'];
$args['stream'] = (bool) $args['stream'];
$args['show_border'] = (bool) $args['show_border'];
$args['force_wall'] = (bool) $args['force_wall'];
// The height used to be dependent on other widget settings
// If the user changes those settings but doesn't customize the height,
// let's intelligently assign a new height.
if ( in_array( $args['height'], array( 580, 110, 432 ) ) ) {
if( $args['show_faces'] && $args['stream'] ) {
$args['height'] = 580;
} else if( ! $args['show_faces'] && ! $args['stream'] ) {
$args['height'] = 110;
} else {
$args['height'] = 432;
}
}
return $args;
}
public function is_valid_facebook_url( $url ) {
return ( FALSE !== strpos( $url, 'facebook.com' ) ) ? TRUE : FALSE;
}
public function normalize_int_value( $value, $default = 0, $max = 0, $min = 0 ) {
$value = (int) $value;
if ( $max < $value || $min > $value )
$value = $default;
return (int) $value;
}
public function normalize_text_value( $value, $default = '', $allowed = array() ) {
$allowed = (array) $allowed;
if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) )
$value = $default;
return $value;
}
public function guess_locale_from_lang( $lang ) {
if ( 'en' == $lang || 'en_US' == $lang || !$lang ) {
return 'en_US';
}
if ( !class_exists( 'GP_Locales' ) ) {
if ( !defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || !file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
return false;
}
require JETPACK__GLOTPRESS_LOCALES_PATH;
}
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
// WP.com: get_locale() returns 'it'
$locale = GP_Locales::by_slug( $lang );
} else {
// Jetpack: get_locale() returns 'it_IT';
$locale = GP_Locales::by_field( 'wp_locale', $lang );
}
if ( !$locale || empty( $locale->facebook_locale ) ) {
return false;
}
return $locale->facebook_locale;
}
public function get_locale() {
return $this->guess_locale_from_lang( get_locale() );
}
}
}
register_widget( 'Ocean_Extra_Facebook_Widget' );
@@ -0,0 +1,127 @@
<?php
/**
* Flickr Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Flickr_Widget' ) ) {
class Ocean_Extra_Flickr_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_flickr',
esc_html__( '&raquo; Flickr', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-flickr flickr-widget',
'description' => esc_html__( 'Pulls in images from your flickr account.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$number = isset( $instance['number'] ) ? $instance['number'] : '';
$id = isset( $instance['id'] ) ? $instance['id'] : '';
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
}
// Display flickr feed if ID is defined
if ( $id ) : ?>
<div class="oceanwp-flickr-wrap">
<script type="text/javascript" src="https://www.flickr.com/badge_code_v2.gne?count=<?php echo intval( $number ); ?>&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user&amp;user=<?php echo strip_tags( $id ); ?>"></script>
<p class="flickr_stream_wrap"><a class="follow_btn" href="http://www.flickr.com/photos/<?php echo strip_tags( $id ); ?>"><?php esc_html_e( 'View stream on flickr', 'ocean-extra' ); ?></a></p>
</div>
<?php endif;
// 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['number'] = ! empty( $new_instance['number'] ) ? intval( $new_instance['number'] ) : '';
$instance['id'] = ! empty( $new_instance['id'] ) ? strip_tags( $new_instance['id'] ) : '';
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
extract( wp_parse_args( (array) $instance, array(
'title' => esc_attr__( 'Flickr Photos', 'ocean-extra' ),
'id' => '73064996@N08',
'number' => 6
) ) ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('id'); ?>"><?php esc_html_e( 'Flickr ID', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" type="text" value="<?php echo esc_attr( $id ); ?>" />
<small><?php esc_html_e( 'Enter the url of your Flickr page on this site: idgettr.com.', 'ocean-extra' ); ?></small>
</p>
<p>
<label for="<?php echo $this->get_field_id('number'); ?>"><?php esc_html_e( 'Number:', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" />
<small><?php esc_html_e( 'The maximum is 10 images.', 'ocean-extra' ); ?></small>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Flickr_Widget' );
@@ -0,0 +1,562 @@
<?php
/**
* Instagram Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Instagram_Widget' ) ) {
class Ocean_Extra_Instagram_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_instagram',
$name = __( '&raquo; Instagram', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-instagram instagram-widget',
'description' => esc_html__( 'Displays Instagram photos.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
add_action( 'admin_enqueue_scripts', array( $this, 'ocean_extra_instagram_js' ) );
}
/**
* Upload the Javascripts for the media uploader
*/
public function ocean_extra_instagram_js() {
wp_enqueue_script( 'oe-insta-admin-script', OE_URL .'includes/widgets/js/insta-admin.min.js', array( 'jquery' ), false, true );
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Display the widget
echo $this->display_widget( $instance );
// After widget WP hook
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 ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['username'] = $new_instance['username'];
$instance['number'] = $new_instance['number'];
$instance['display_header'] = $new_instance['display_header'];
$instance['avatar'] = strip_tags( $new_instance['avatar'] );
$instance['picture_radius'] = $new_instance['picture_radius'];
$instance['display_name'] = $new_instance['display_name'];
$instance['description'] = $new_instance['description'];
$instance['header_position'] = $new_instance['header_position'];
$instance['header_align'] = $new_instance['header_align'];
$instance['columns'] = strip_tags($new_instance['columns']);
$instance['margin'] = $new_instance['margin'];
$instance['size'] = $new_instance['size'];
$instance['images_link'] = $new_instance['images_link'];
$instance['custom_url'] = $new_instance['custom_url'];
$instance['target'] = $new_instance['target'];
$instance['follow'] = $new_instance['follow'];
return $instance;
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array(
'title' => __('Instagram','ocean-extra'),
'username' => __('adidas','ocean-extra'),
'number' => 10,
'display_header' => __('No','ocean-extra'),
'avatar' => '',
'picture_radius' => __('Rounded','ocean-extra'),
'display_name' => '',
'description' => '',
'header_position' => __('Before','ocean-extra'),
'header_align' => __('Left','ocean-extra'),
'columns' => '',
'margin' => __('Yes','ocean-extra'),
'size' => 'small',
'images_link' => 'image_url',
'custom_url' => '',
'target' => 'blank',
'follow' => __('Follow Us','ocean-extra'),
)); ?>
<div class="oceanwp-container">
<p>
<label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php esc_html_e('Title', 'ocean-extra'); ?></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( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php esc_html_e( '@username or #tag', 'ocean-extra' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['username'] ); ?>" /></label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number Images To Show:', 'ocean-extra' ); ?>
<input class="small-text" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number" min="0" value="<?php echo esc_attr( $instance['number'] ); ?>" />
</label>
</p>
<p class="oceanwp-left">
<label for="<?php echo esc_attr( $this->get_field_id('columns') ); ?>"><?php esc_html_e('Images Style:', 'ocean-extra'); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('columns') ); ?>" id="<?php echo esc_attr( $this->get_field_id('columns') ); ?>">
<option value="style-one" <?php if($instance['columns'] == 'style-one') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Style 1', 'ocean-extra' ); ?></option>
<option value="style-two" <?php if($instance['columns'] == 'style-two') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Style 2', 'ocean-extra' ); ?></option>
<option value="style-three" <?php if($instance['columns'] == 'style-three') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Style 3', 'ocean-extra' ); ?></option>
<option value="style-four" <?php if($instance['columns'] == 'style-four') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Style 4', 'ocean-extra' ); ?></option>
<option value="two-columns" <?php if($instance['columns'] == 'two-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '2 Columns', 'ocean-extra' ); ?></option>
<option value="three-columns" <?php if($instance['columns'] == 'three-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '3 Columns', 'ocean-extra' ); ?></option>
<option value="four-columns" <?php if($instance['columns'] == 'four-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '4 Columns', 'ocean-extra' ); ?></option>
<option value="five-columns" <?php if($instance['columns'] == 'five-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '5 Columns', 'ocean-extra' ); ?></option>
<option value="six-columns" <?php if($instance['columns'] == 'six-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '6 Columns', 'ocean-extra' ); ?></option>
<option value="seven-columns" <?php if($instance['columns'] == 'seven-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '7 Columns', 'ocean-extra' ); ?></option>
<option value="eight-columns" <?php if($instance['columns'] == 'eight-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '8 Columns', 'ocean-extra' ); ?></option>
<option value="nine-columns" <?php if($instance['columns'] == 'nine-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '9 Columns', 'ocean-extra' ); ?></option>
<option value="ten-columns" <?php if($instance['columns'] == 'ten-columns') { ?>selected="selected"<?php } ?>><?php esc_html_e( '10 Columns', 'ocean-extra' ); ?></option>
</select>
</p>
<p class="oceanwp-right">
<label for="<?php echo esc_attr( $this->get_field_id('margin') ); ?>"><?php esc_html_e('Margin:', 'ocean-extra'); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('margin') ); ?>" id="<?php echo esc_attr( $this->get_field_id('margin') ); ?>">
<option value="margin" <?php if($instance['margin'] == 'margin') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Margin', 'ocean-extra' ); ?></option>
<option value="no-margin" <?php if($instance['margin'] == 'no-margin') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'No Margin', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_html_e( 'Photo size', 'ocean-extra' ); ?>:</label>
<select id="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'size' ) ); ?>" class="widefat">
<option value="thumbnail" <?php selected( 'thumbnail', $instance['size'] ); ?>><?php esc_html_e( 'Thumbnail', 'ocean-extra' ); ?></option>
<option value="small" <?php selected( 'small', $instance['size'] ); ?>><?php esc_html_e( 'Small', 'ocean-extra' ); ?></option>
<option value="large" <?php selected( 'large', $instance['size'] ); ?>><?php esc_html_e( 'Large', 'ocean-extra' ); ?></option>
<option value="original" <?php selected( 'original', $instance['size'] ); ?>><?php esc_html_e( 'Original', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'images_link' ) ); ?>"><strong><?php esc_html_e( 'Link To', 'ocean-extra' ); ?></strong>
<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'images_link' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'images_link' ) ); ?>">
<option value="image_url" <?php selected( $instance['images_link'], 'image_url', true); ?>><?php esc_html_e( 'Instagram Image', 'ocean-extra' ); ?></option>
<option value="user_url" <?php selected( $instance['images_link'], 'user_url', true); ?>><?php esc_html_e( 'Instagram Profile', 'ocean-extra' ); ?></option>
<option value="custom_url" <?php selected( $instance['images_link'], 'custom_url', true ); ?>><?php esc_html_e( 'Custom Link', 'ocean-extra' ); ?></option>
</select>
</label>
</p>
<p class="<?php if ( 'custom_url' != $instance['images_link'] ) echo 'hidden'; ?>">
<label for="<?php echo esc_attr( $this->get_field_id( 'custom_url' ) ); ?>"><?php esc_html_e( 'Custom Link:', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'custom_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'custom_url' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['custom_url'] ); ?>" />
<small><?php esc_html_e('Use this field only if the above option is set to <strong>Custom Link</strong>', 'ocean-extra'); ?></small>
</p>
<div class="oceanwp-header-wrap">
<div class="oceanwp-header-options oceanwp-clr">
<h4 class="oceanwp-header-title"><?php esc_html_e( 'Header Options', 'ocean-extra'); ?></h4>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('display_header') ); ?>"><?php esc_html_e('Display Header:', 'ocean-extra'); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('display_header') ); ?>" id="<?php echo esc_attr( $this->get_field_id('display_header') ); ?>">
<option value="no" <?php if($instance['display_header'] == 'no') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<option value="yes" <?php if($instance['display_header'] == 'yes') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Yes', 'ocean-extra' ); ?></option>
</select>
</p>
<div class="oceanwp-display-header-options <?php if ( 'yes' != $instance['display_header'] ) echo 'hidden'; ?>">
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>"><?php esc_html_e( 'Image URL', 'ocean-extra' ); ?>:</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'avatar' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'avatar' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['avatar'] ); ?>" style="margin-bottom:10px;" />
<input class="oceanwp-insta-avatar button button-secondary" type="button" value="<?php esc_html_e( 'Upload Image', 'ocean-extra' ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('picture_radius') ); ?>"><?php esc_html_e( 'Picture Radius:', 'ocean-extra' ); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('picture_radius') ); ?>" id="<?php echo esc_attr( $this->get_field_id('picture_radius') ); ?>">
<option value="rounded" <?php if($instance['picture_radius'] == 'rounded') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Rounded', 'ocean-extra' ); ?></option>
<option value="square" <?php if($instance['picture_radius'] == 'square') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Square', 'ocean-extra'); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'display_name' ) ); ?>"><?php esc_html_e( 'Display Name:', 'ocean-extra' ); ?>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'display_name' ) ); ?>" type="text" placeholder="<?php esc_html_e( 'Default is username', 'ocean-extra' ); ?>" value="<?php echo esc_attr( $instance['display_name'] ); ?>" />
</label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('description') ); ?>"><?php esc_html_e('Description:', 'ocean-extra'); ?></label>
<textarea rows="15" id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" class="widefat" style="height: 100px;"><?php if ( !empty( $instance['description'] ) ) { echo esc_attr( $instance['description'] ); } ?></textarea>
</p>
<p class="oceanwp-left">
<label for="<?php echo esc_attr( $this->get_field_id('header_position') ); ?>"><?php esc_html_e( 'Position:', 'ocean-extra' ); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('header_position') ); ?>" id="<?php echo esc_attr( $this->get_field_id('header_position') ); ?>">
<option value="before" <?php if($instance['header_position'] == 'before') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Before Images', 'ocean-extra' ); ?></option>
<option value="after" <?php if($instance['header_position'] == 'after') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'After Images', 'ocean-extra'); ?></option>
</select>
</p>
<p class="oceanwp-right">
<label for="<?php echo esc_attr( $this->get_field_id('header_align') ); ?>"><?php esc_html_e( 'Align:', 'ocean-extra' ); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('header_align') ); ?>" id="<?php echo esc_attr( $this->get_field_id('header_align') ); ?>">
<option value="left" <?php if($instance['header_align'] == 'left') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Left', 'ocean-extra' ); ?></option>
<option value="right" <?php if($instance['header_align'] == 'right') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Right', 'ocean-extra'); ?></option>
<option value="center" <?php if($instance['header_align'] == 'center') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Center', 'ocean-extra'); ?></option>
</select>
</p>
</div>
</div>
</div>
<p class="oceanwp-left">
<label for="<?php echo esc_attr( $this->get_field_id('target') ); ?>"><?php esc_html_e( 'Button Target:', 'ocean-extra' ); ?></label>
<select class='oceanwp-widget-select widefat' name="<?php echo esc_attr( $this->get_field_name('target') ); ?>" id="<?php echo esc_attr( $this->get_field_id('target') ); ?>">
<option value="blank" <?php if($instance['target'] == 'blank') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Blank', 'ocean-extra' ); ?></option>
<option value="self" <?php if($instance['target'] == 'self') { ?>selected="selected"<?php } ?>><?php esc_html_e( 'Self', 'ocean-extra'); ?></option>
</select>
<small><?php esc_html_e( 'Same or new window', 'ocean-extra' ); ?></small>
</p>
<p class="oceanwp-right">
<label for="<?php echo esc_attr( $this->get_field_id('follow') ); ?>"><?php esc_html_e( 'Button Text:', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('follow') ); ?>" name="<?php echo esc_attr( $this->get_field_name('follow') ); ?>" type="text" value="<?php echo esc_attr( $instance['follow'] ); ?>" />
<small><?php esc_html_e( 'Leave empty for no button', 'ocean-extra' ); ?></small>
</p>
<div style="clear:both;"></div>
</div>
<style type="text/css">
.oceanwp-clr:after { content:"";display:block;visibility:hidden;clear:both;zoom:1;height:0 }
.oceanwp-search-for-container {display: block; margin-bottom: 6px;}
.oceanwp-seach-for {display: inline-block; width: 90px; vertical-align: middle;}
.oceanwp-left,.oceanwp-right{min-height: 48px;}
.oceanwp-left{float: left;width: 48%;}
.oceanwp-right{float: right;width: 48%;}
.oceanwp-header-wrap .oceanwp-header-options {border: 1px solid #cfcfcf;padding: 10px;margin: 25px 0 0;}
.oceanwp-header-wrap .oceanwp-header-title {margin: -22px 0 0 0;background-color: #fff;width: 100px;padding: 3px 10px;border: 1px solid #cfcfcf;text-align: center;}
.oceanwp-header-wrap .oceanwp-header-heading {display: inline-block;width: 100%;margin: 8px 0 10px;}
@media only screen and (max-width: 767px) {
.oceanwp-left,.oceanwp-right{float: none;width: 100%;}
}
</style>
<script type="text/javascript">
(function($) {
"use strict";
$( document ).ready( function() {
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$( '.oceanwp-insta-avatar' ).click(function(e) {
var send_attachment_bkp = wp.media.editor.send.attachment,
button = $(this),
id = button.prev();
_custom_media = true;
wp.media.editor.send.attachment = function( props, attachment ) {
if ( _custom_media ) {
$( id ).val( attachment.url );
} else {
return _orig_send_attachment.apply( this, [props, attachment] );
};
}
wp.media.editor.open( button );
return false;
} );
$( '.add_media').on('click', function() {
_custom_media = false;
} );
} );
} ) ( jQuery );
</script>
<?php
}
/**
* Display the widget.
*/
private function display_widget( $args ) {
$username = isset( $args['username'] ) && !empty( $args['username'] ) ? $args['username'] : 'adidas';
$number = isset( $args['number'] ) ? $args['number'] : 10;
$display_header = isset( $args['display_header'] ) ? $args['display_header'] : 'no';
$avatar = isset( $args['avatar'] ) ? $args['avatar'] : '';
$picture_radius = isset( $args['picture_radius'] ) ? $args['picture_radius'] : 'rounded';
$display_name = isset( $args['display_name'] ) ? $args['display_name'] : '';
$description = isset( $args['description'] ) ? $args['description'] : '';
$header_position = isset( $args['header_position'] ) ? $args['header_position'] : '';
$header_align = isset( $args['header_align'] ) ? $args['header_align'] : '';
$columns = isset( $args['columns'] ) ? $args['columns'] : '';
$margin = isset( $args['margin'] ) ? $args['margin'] : '';
$size = isset( $args['size'] ) ? $args['size'] : 'small';
$images_link = isset( $args['images_link'] ) ? $args['images_link'] : 'local_image_url';
$custom_url = isset( $args['custom_url'] ) ? $args['custom_url'] : '';
$target = isset( $args['target'] ) ? $args['target'] : '';
$follow = isset( $args['follow'] ) ? $args['follow'] : '';
$output = '';
if ( '' !== $username ) {
$media_array = $this->instagram_data( $username );
if ( is_wp_error( $media_array ) ) {
$output .= wp_kses_post( $media_array->get_error_message() );
} else {
// slice list down to required limit.
$media_array = array_slice( $media_array, 0, $number );
if ( 'style-four' == $columns ) {
$output .= '<div class="oceanwp-style-four-wrap">';
}
if ( 'style-four' == $columns ) {
$output .= '<div class="oceanwp-instagram-bar"><a class="instagram-logo" href="https://instagram.com/' . esc_attr( $username ) . '/" target="_blank" rel="nofollow"></a></div>';
}
if ( $display_header != 'no' && $header_position == 'before' ) {
$output .= '<div class="oceanwp-instagram-header oceanwp-before oceanwp-'. esc_attr( $header_align ) .' clr">';
if ( $avatar ) {
$output .= '<div class="oceanwp-instagram-avatar '. esc_attr( $picture_radius ) .'">';
$output .= '<a href="https://instagram.com/'. esc_attr( $username ) .'/" target="_blank" rel="nofollow">';
$output .= '<img src="'. esc_url( $avatar ) .'" alt="'. esc_attr( $username ) .'" />';
$output .= '<span class="oceanwp-instagram-follow"><span>Follow</span></span>';
$output .= '</a>';
$output .= '</div>';
}
$output .= '<div class="oceanwp-instagram-info">';
if ( $display_name == '' ) {
$name = $username;
} else {
$name = $display_name;
}
$output .= '<h3 class="oceanwp-instagram-username"><a href="https://instagram.com/'. esc_attr( $username ) .'/" target="_blank" rel="nofollow">'. $name .'</a></h3>';
if ( $description != '' ) {
$output .= '<p class="oceanwp-instagram-desc">'. do_shortcode( $description ) .'</p>';
}
$output .= '</div>';
$output .= '</div>';
}
$output .= '<ul class="oceanwp-instagram-pics clr '. esc_attr( $columns ) .' '. esc_attr( $margin ) .'">';
foreach( $media_array as $item ) {
if ( 'image_url' == $images_link ) {
$link = $item['link'];
} elseif ( 'user_url' == $images_link ) {
$link = 'instagram.com/' . esc_attr( $username ) . '/';
} elseif ( 'custom_url' == $images_link ) {
$link = $custom_url;
}
$output .= '<li><a href="' . esc_url( $link ) . '" target="' . esc_attr( $target ) . '" ><img src="' . esc_url( $item[$size] ) . '" alt="' . esc_attr( $item['description'] ) . '" title="' . esc_attr( $item['description'] ) . '" /></a></li>';
}
$output .= '</ul>';
if ( $display_header != 'no' && $header_position == 'after' ) {
$output .= '<div class="oceanwp-instagram-header oceanwp-after oceanwp-'. esc_attr( $header_align ) .' clr">';
if ( $avatar ) {
$output .= '<div class="oceanwp-instagram-avatar">';
$output .= '<a href="https://instagram.com/'. esc_attr( $username ) .'/" target="_blank" rel="nofollow">';
$output .= '<img src="'. esc_url( $avatar ) .'" alt="'. esc_attr( $username ) .'" />';
$output .= '<span class="oceanwp-instagram-follow"><span>Follow</span></span>';
$output .= '</a>';
$output .= '</div>';
}
$output .= '<div class="oceanwp-instagram-info">';
if ( $display_name == '' ) {
$name = $username;
} else {
$name = $display_name;
}
$output .= '<h3 class="oceanwp-instagram-username"><a href="https://instagram.com/'. esc_attr( $username ) .'/" target="_blank" rel="nofollow">'. $name .'</a></h3>';
if ( $description != '' ) {
$output .= '<p class="oceanwp-instagram-desc">'. do_shortcode( $description ) .'</p>';
}
$output .= '</div>';
$output .= '</div>';
}
if ( $follow != '' ) {
$output .= '<p class="oceanwp-instagram-link clr"><a href="https://instagram.com/'. esc_attr( $username ) .'/" rel="me" target="_'. esc_attr( $target ) .'">'. esc_attr( $follow ) .'</a></p>';
}
if ( 'style-four' == $columns ) {
$output .= '</div>';
}
}
} else {
$output .= __( 'No images found! <br> Try some other hashtag or username', 'ocean-extra' );
}
return $output;
}
/**
* based on https://gist.github.com/cosmocatalano/4544576
*/
function instagram_data( $username ) {
$username = trim( strtolower( $username ) );
switch ( substr( $username, 0, 1 ) ) {
case '#':
$url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username );
$transient_prefix = 'h';
break;
default:
$url = 'https://instagram.com/' . str_replace( '@', '', $username );
$transient_prefix = 'u';
break;
}
if ( false === ( $instagram = get_transient( 'ocean-insta-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ) ) ) ) {
$remote = wp_remote_get( $url );
if ( is_wp_error( $remote ) ) {
return new WP_Error( 'site_down', esc_html__( 'Unable to communicate with Instagram.', 'ocean-extra' ) );
}
if ( 200 !== wp_remote_retrieve_response_code( $remote ) ) {
return new WP_Error( 'invalid_response', esc_html__( 'Instagram did not return a 200.', 'ocean-extra' ) );
}
$shards = explode( 'window._sharedData = ', $remote['body'] );
$insta_json = explode( ';</script>', $shards[1] );
$insta_array = json_decode( $insta_json[0], true );
if ( ! $insta_array ) {
return new WP_Error( 'bad_json', esc_html__( 'Instagram has returned invalid data.', 'ocean-extra' ) );
}
if ( isset( $insta_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'] ) ) {
$images = $insta_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'];
} elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) {
$images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'];
} else {
return new WP_Error( 'bad_json_2', esc_html__( 'Instagram has returned invalid data.', 'ocean-extra' ) );
}
if ( ! is_array( $images ) ) {
return new WP_Error( 'bad_array', esc_html__( 'Instagram has returned invalid data.', 'ocean-extra' ) );
}
$instagram = array();
foreach ( $images as $image ) {
if ( true === $image['node']['is_video'] ) {
$type = 'video';
} else {
$type = 'image';
}
$caption = __( 'Instagram Image', 'ocean-extra' );
if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) {
$caption = wp_kses( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'], array() );
}
$instagram[] = array(
'description' => $caption,
'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ),
'time' => $image['node']['taken_at_timestamp'],
'comments' => $image['node']['edge_media_to_comment']['count'],
'likes' => $image['node']['edge_liked_by']['count'],
'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ),
'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ),
'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ),
'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ),
'type' => $type,
);
} // End foreach().
// do not set an empty transient - should help catch private or empty accounts.
if ( ! empty( $instagram ) ) {
$instagram = base64_encode( serialize( $instagram ) );
set_transient( 'ocean-insta-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'ocean_instagram_cache_time', HOUR_IN_SECONDS * 2 ) );
}
}
if ( ! empty( $instagram ) ) {
return unserialize( base64_decode( $instagram ) );
} else {
return new WP_Error( 'no_images', esc_html__( 'Instagram did not return any images.', 'ocean-extra' ) );
}
}
}
}
register_widget( 'Ocean_Extra_Instagram_Widget' );
@@ -0,0 +1,43 @@
(function($) {
$(document).ready(function($){
// Hide Custom Url if image link is not set to custom url
$('body').on('change', '.oceanwp-container select[id$="images_link"]', function(e){
var images_link = $(this);
if ( images_link.val() != 'custom_url' ) {
images_link.closest('.oceanwp-container').find('input[id$="custom_url"]').val('').parent().animate({opacity: 'hide' , height: 'hide'}, 200);
} else {
images_link.closest('.oceanwp-container').find('input[id$="custom_url"]').parent().animate({opacity: 'show' , height: 'show'}, 200);
}
});
// Modfiy options when search for is changed
$('body').on('change', '.oceanwp-container input:radio[id$="search_for"]', function(e){
var search_for = $(this);
if ( search_for.val() != 'username' ) {
search_for.closest('.oceanwp-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'hide' , height: 'hide'}, 200);
search_for.closest('.oceanwp-container').find('select[id$="images_link"]').val('image_url');
search_for.closest('.oceanwp-container').find('input[id$="blocked_users"]').closest('p').animate({opacity: 'show' , height: 'show'}, 200);
search_for.closest('.oceanwp-container').find('.oceanwp-header-wrap').animate({opacity: 'hide' , height: 'hide'}, 200);
} else {
search_for.closest('.oceanwp-container').find('select[id$="images_link"] option[value="user_url"]').animate({opacity: 'show' , height: 'show'}, 200);
search_for.closest('.oceanwp-container').find('select[id$="images_link"]').val('image_url');
search_for.closest('.oceanwp-container').find('input[id$="blocked_users"]').closest('p').animate({opacity: 'hide' , height: 'hide'}, 200);
search_for.closest('.oceanwp-container').find('.oceanwp-header-wrap').animate({opacity: 'show' , height: 'show'}, 200);
}
});
// Hide header infos if display header is not set to yesurl
$('body').on('change', '.oceanwp-container select[id$="display_header"]', function(e){
var display_header = $(this);
if ( display_header.val() != 'yes' ) {
display_header.closest('.oceanwp-container').find('.oceanwp-display-header-options').animate({opacity: 'hide' , height: 'hide'}, 200);
} else {
display_header.closest('.oceanwp-container').find('.oceanwp-display-header-options').animate({opacity: 'show' , height: 'show'}, 200);
}
});
}); // Document Ready
})(jQuery);
@@ -0,0 +1 @@
jQuery(document).ready(function(n){n("body").on("change",'.oceanwp-container select[id$="images_link"]',function(e){var i=n(this);"custom_url"!=i.val()?i.closest(".oceanwp-container").find('input[id$="custom_url"]').val("").parent().animate({opacity:"hide",height:"hide"},200):i.closest(".oceanwp-container").find('input[id$="custom_url"]').parent().animate({opacity:"show",height:"show"},200)}),n("body").on("change",'.oceanwp-container input:radio[id$="search_for"]',function(e){var i=n(this);"username"!=i.val()?(i.closest(".oceanwp-container").find('select[id$="images_link"] option[value="user_url"]').animate({opacity:"hide",height:"hide"},200),i.closest(".oceanwp-container").find('select[id$="images_link"]').val("image_url"),i.closest(".oceanwp-container").find('input[id$="blocked_users"]').closest("p").animate({opacity:"show",height:"show"},200),i.closest(".oceanwp-container").find(".oceanwp-header-wrap").animate({opacity:"hide",height:"hide"},200)):(i.closest(".oceanwp-container").find('select[id$="images_link"] option[value="user_url"]').animate({opacity:"show",height:"show"},200),i.closest(".oceanwp-container").find('select[id$="images_link"]').val("image_url"),i.closest(".oceanwp-container").find('input[id$="blocked_users"]').closest("p").animate({opacity:"hide",height:"hide"},200),i.closest(".oceanwp-container").find(".oceanwp-header-wrap").animate({opacity:"show",height:"show"},200))}),n("body").on("change",'.oceanwp-container select[id$="display_header"]',function(e){var i=n(this);"yes"!=i.val()?i.closest(".oceanwp-container").find(".oceanwp-display-header-options").animate({opacity:"hide",height:"hide"},200):i.closest(".oceanwp-container").find(".oceanwp-display-header-options").animate({opacity:"show",height:"show"},200)})});
@@ -0,0 +1,68 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
jQuery(document).ready(function ($) {
$(".oceanwp-newsletter-form-wrap #mc-embedded-subscribe-form").on("submit", function (e) {
e.preventDefault();
var element = $(this);
var email = element.find('.email').val();
var valid = true;
element.find(".err-msg").hide();
if ($.trim(email).length == 0) {
valid = false;
element.find(".email-err.req").show();
} else if (!isValidEmailAddress(email)) {
valid = false;
element.find(".email-err.not-valid").show();
}
if (element.find(".gdpr").length && !element.find(".gdpr").is(":checked")) {
valid = false;
element.find(".gdpr-err.err-msg").show();
}
element.find(".res-msg").hide();
if (valid) {
element.find("button").attr("disabled", true);
var data = {
action: "oceanwp_mailchimp_request",
email: email,
};
$.ajax({
type: 'POST',
url: oceanwpLocalize.ajax_url,
data: data,
success: function( response ) {
element.find("button").attr("disabled", false);
if (response.status) {
element.find(".res-msg.success").show().delay(5000).fadeOut();
} else {
element.find(".res-msg.failed").show().delay(5000).fadeOut();
}
},
complete: function() {
}
});
}
});
});
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
return pattern.test(emailAddress);
};
@@ -0,0 +1 @@
function isValidEmailAddress(e){return new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i).test(e)}jQuery(document).ready(function(n){n(".oceanwp-newsletter-form-wrap #mc-embedded-subscribe-form").on("submit",function(e){e.preventDefault();var d=n(this),i=d.find(".email").val(),a=!0;if(d.find(".err-msg").hide(),0==n.trim(i).length?(a=!1,d.find(".email-err.req").show()):isValidEmailAddress(i)||(a=!1,d.find(".email-err.not-valid").show()),d.find(".gdpr").length&&!d.find(".gdpr").is(":checked")&&(a=!1,d.find(".gdpr-err.err-msg").show()),d.find(".res-msg").hide(),a){d.find("button").attr("disabled",!0);var s={action:"oceanwp_mailchimp_request",email:i};n.ajax({type:"POST",url:oceanwpLocalize.ajax_url,data:s,success:function(e){d.find("button").attr("disabled",!1),e.status?d.find(".res-msg.success").show().delay(5e3).fadeOut():d.find(".res-msg.failed").show().delay(5e3).fadeOut()},complete:function(){}})}})});
@@ -0,0 +1,14 @@
var $j = jQuery.noConflict();
/* ==============================================
ON CLICK
============================================== */
function owpShareOnClick( href ) {
var windowWidth = '640',
windowHeight = '480',
windowTop = screen.height / 2 - windowHeight / 2,
windowLeft = screen.width / 2 - windowWidth / 2,
shareWindow = 'toolbar=0,status=0,width=' + windowWidth + ',height=' + windowHeight + ',top=' + windowTop + ',left=' + windowLeft;
open( href, '', shareWindow );
}
@@ -0,0 +1 @@
var $j=jQuery.noConflict();function owpShareOnClick(t){var e=screen.height/2-240,n=screen.width/2-320;open(t,"","toolbar=0,status=0,width=640,height=480,top="+e+",left="+n)}
@@ -0,0 +1,300 @@
<?php
/**
* MailChimp Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('Ocean_Extra_MailChimp_Widget')) {
class Ocean_Extra_MailChimp_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_mailchimp', esc_html__('&raquo; MailChimp', 'ocean-extra'), array(
'classname' => 'widget-oceanwp-mailchimp mailchimp-widget',
'description' => esc_html__('Displays mailchimp subscription form.', 'ocean-extra'),
'customize_selective_refresh' => true,
)
);
add_action( 'wp_enqueue_scripts', array( $this, 'ocean_extra_mailchimp_js' ) );
add_filter( 'ocean_localize_array', array( $this, 'localize_array' ) );
add_action('wp_ajax_oceanwp_mailchimp_request', array($this, 'oceanwp_mailchimp_request_callback'));
add_action('wp_ajax_nopriv_oceanwp_mailchimp_request', array($this, 'oceanwp_mailchimp_request_callback'));
}
public function oceanwp_mailchimp_request_callback() {
$apikey = get_option( 'owp_mailchimp_api_key' );
$list_id = get_option( 'owp_mailchimp_list_id' );
$email = ( isset( $_POST['email'] ) ) ? $_POST['email'] : '';
$status = FALSE;
if ( $email && $apikey && $list_id ) {
$root = 'https://api.mailchimp.com/3.0';
if ( strstr( $apikey, '-' ) ) {
list( $key, $dc ) = explode( '-', $apikey, 2 );
}
$root = str_replace( 'https://api', 'https://' . $dc . '.api', $root );
$root = rtrim( $root, '/' ) . '/';
$params = array(
'apikey' => $apikey,
'id' => $list_id,
'email' => array( 'email' => $email ),
'double_optin' => FALSE,
'send_welcome' => FALSE,
'replace_interests' => FALSE,
'update_existing' => TRUE
);
$ch = curl_init();
$params = json_encode( $params );
curl_setopt( $ch, CURLOPT_URL, $root . '/lists/subscribe' . '.json' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json',
'Authorization: ' . $apikey
) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
$response_body = curl_exec( $ch );
$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
curl_close( $ch );
if ( $httpCode == 200 ) {
$status = TRUE;
}
}
wp_send_json( array( 'status' => $status ) );
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance) {
$title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
$subscribe_text = isset($instance['subscribe_text']) ? $instance['subscribe_text'] : '';
$mailchimp_gdpr_label = isset($instance['mailchimp_gdpr_label']) ? $instance['mailchimp_gdpr_label'] : '';
$width = isset($instance['width']) ? $instance['width'] : '';
$height = isset($instance['height']) ? $instance['height'] : '';
$placeholder = isset($instance['placeholder']) ? $instance['placeholder'] : '';
$submit_text = isset($instance['submit_text']) ? $instance['submit_text'] : '';
// Sanitize vars
$width = $width ? $width : '';
$height = $height ? $height : '';
// Inline style
$form_style = '';
$input_style = '';
if ($width) {
$form_style .= 'width:' . esc_attr($width) . ';';
}
if ($height) {
$input_style .= 'height:' . esc_attr($height) . ';';
}
if ($form_style) {
$form_style = ' style="' . esc_attr($form_style) . '"';
}
if ($input_style) {
$input_style = ' style="' . esc_attr($input_style) . '"';
}
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ($title) {
echo $args['before_title'] . esc_html($title) . $args['after_title'];
} ?>
<div class="oceanwp-newsletter-form clr">
<div class="oceanwp-newsletter-form-wrap">
<?php if ($subscribe_text) { ?>
<div class="oceanwp-mail-text"><?php echo do_shortcode($subscribe_text); ?></div>
<?php } ?>
<form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate<?php echo wp_kses_post($form_style); ?>>
<div class="email-wrap elem-wrap">
<input type="email" placeholder="<?php echo esc_attr($placeholder); ?>" onfocus="if (this.value == this.defaultValue)this.value = '';" onblur="if (this.value == '')this.value = this.defaultValue;" name="EMAIL" class="required email"<?php echo wp_kses_post($input_style); ?>>
<?php if ($submit_text) { ?>
<button type="submit" value="" name="subscribe" class="button">
<?php echo esc_attr($submit_text); ?>
</button>
<?php } ?>
</div>
<span class="email-err err-msg req" style="display:none;"><?php _e("Email is required.", "ocean-extra"); ?></span>
<span class="email-err err-msg not-valid" style="display:none;"><?php _e("Email not valid.", "ocean-extra"); ?></span>
<?php if ($mailchimp_gdpr_label) { ?>
<div class="gdpr-wrap elem-wrap">
<label><input type="checkbox" name="GDPR" value="1" class="gdpr required"><?php echo $mailchimp_gdpr_label; ?></label>
<span class="gdpr-err err-msg" style="display:none;"><?php _e("This field is required", "ocean-extra"); ?></span>
</div>
<?php } ?>
<div class="success res-msg" style="display:none;"><?php _e("Thanks for your subscription.", "ocean-extra"); ?></div>
<div class="failed res-msg" style="display:none;"><?php _e("Failed to subscribe, please contact admin.", "ocean-extra"); ?></div>
</form>
</div><!--.oceanwp-newsletter-form-wrap-->
</div><!-- .oceanwp-newsletter-form -->
<?php
// 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['subscribe_text'] = !empty($new_instance['subscribe_text']) ? strip_tags($new_instance['subscribe_text']) : '';
$instance['mailchimp_gdpr_label'] = !empty($new_instance['mailchimp_gdpr_label']) ? strip_tags($new_instance['mailchimp_gdpr_label']) : '';
$instance['width'] = !empty($new_instance['width']) ? strip_tags($new_instance['width']) : '';
$instance['height'] = !empty($new_instance['height']) ? strip_tags($new_instance['height']) : '';
$instance['placeholder'] = !empty($new_instance['placeholder']) ? strip_tags($new_instance['placeholder']) : '';
$instance['submit_text'] = !empty($new_instance['submit_text']) ? strip_tags($new_instance['submit_text']) : '';
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__('Newsletter', 'ocean-extra'),
'subscribe_text' => esc_html__('Get all latest content delivered to your email a few times a month. Updates and news about all categories will send to you.', 'ocean-extra'),
'mailchimp_gdpr_label' => esc_attr__('Accept GDPR Terms', 'ocean-extra'),
'width' => '',
'height' => '',
'placeholder' => esc_html__('Your Email', 'ocean-extra'),
'submit_text' => esc_html__('Go', 'ocean-extra'),
));
// If no API KEy and List ID
if ( ! get_option( 'owp_mailchimp_api_key' )
|| ! get_option( 'owp_mailchimp_list_id' ) ) { ?>
<p>
<?php echo sprintf(
__( 'You need to set your Api Key & List Id on the %1$ssettings page%2$s', 'ocean-extra' ),
'<a href="' . add_query_arg( array( 'page' => 'oceanwp-panel&tab=integrations#mailchimp', ), esc_url( admin_url( 'admin.php' ) ) ) . '" target="_blank">',
'</a>' ); ?>
</p>
<?php } ?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title', 'ocean-extra'); ?>:</label>
<input class="widefat" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('subscribe_text')); ?>">
<?php esc_html_e('Text', 'ocean-extra'); ?></label>
<textarea rows="15" id="<?php echo esc_attr($this->get_field_id('subscribe_text')); ?>" name="<?php echo esc_attr($this->get_field_name('subscribe_text')); ?>" class="widefat" style="height: 100px;"><?php
if (!empty($instance['subscribe_text'])) {
echo esc_textarea($instance['subscribe_text']);
}
?></textarea>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('mailchimp_gdpr_label')); ?>"><?php esc_html_e('GDPR Field Label', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('mailchimp_gdpr_label')); ?>" name="<?php echo esc_attr($this->get_field_name('mailchimp_gdpr_label')); ?>" type="text" value="<?php echo esc_attr($instance['mailchimp_gdpr_label']); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('width')); ?>"><?php esc_html_e('Input Width (px)', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('width')); ?>" name="<?php echo esc_attr($this->get_field_name('width')); ?>" type="text" value="<?php echo esc_attr($instance['width']); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('height')); ?>"><?php esc_html_e('Input Height (px)', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('height')); ?>" name="<?php echo esc_attr($this->get_field_name('height')); ?>" type="text" value="<?php echo esc_attr($instance['height']); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('placeholder')); ?>"><?php esc_html_e('Placeholder', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('placeholder')); ?>" name="<?php echo esc_attr($this->get_field_name('placeholder')); ?>" type="text" value="<?php echo esc_attr($instance['placeholder']); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('submit_text')); ?>"><?php esc_html_e('Submit Text', 'ocean-extra'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('submit_text')); ?>" name="<?php echo esc_attr($this->get_field_name('submit_text')); ?>" type="text" value="<?php echo esc_attr($instance['submit_text']); ?>" />
</p>
<?php
}
/**
* Upload the Javascripts for mailchimp
*/
public function ocean_extra_mailchimp_js() {
// Load only if the widget is used
if ( is_active_widget( '', '', 'ocean_mailchimp' ) ) {
wp_enqueue_script('oe-mailchimp-script', OE_URL . 'includes/widgets/js/mailchimp.min.js', array('jquery'), false, true);
}
}
/**
* Localize array.
*/
public function localize_array( $array ) {
$array['ajax_url'] = admin_url( 'admin-ajax.php' );
return $array;
}
}
}
register_widget('Ocean_Extra_MailChimp_Widget');
@@ -0,0 +1,292 @@
<?php
/**
* Recent Posts Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Recent_Posts_Thumbnails_Widget' ) ) {
class Ocean_Extra_Recent_Posts_Thumbnails_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_recent_posts',
esc_html__( '&raquo; Recent Posts', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-recent-posts recent-posts-widget',
'description' => esc_html__( 'Shows a listing of your recent or random posts.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
$this->defaults = array(
'title' => esc_html__( 'Recent Posts', 'ocean-extra' ),
'number' => '3',
'post_type' => 'post',
'taxonomy' => '',
'terms' => '',
'order' => 'DESC',
'orderby' => 'date',
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Parse instance
extract( wp_parse_args( $instance, $this->defaults ) );
// Apply filters to the title
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
} ?>
<ul class="oceanwp-recent-posts clr">
<?php
// Query args
$query_args = array(
'post_type' => $post_type,
'posts_per_page' => $number,
'no_found_rows' => true,
);
// Order params - needs FALLBACK don't ever edit!
if ( ! empty( $orderby ) ) {
$query_args['order'] = $order;
$query_args['orderby'] = $orderby;
} else {
$query_args['orderby'] = $order; // THIS IS THE FALLBACK
}
// Taxonomy args
if ( ! empty( $taxonomy ) && ! empty( $terms ) ) {
// Sanitize terms and convert to array
$terms = str_replace( ', ', ',', $terms );
$terms = explode( ',', $terms );
// Add to query arg
$query_args['tax_query'] = array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $terms,
),
);
}
// Exclude current post
if ( is_singular() ) {
$query_args['post__not_in'] = array( get_the_ID() );
}
// Query posts
$oceanwp_query = new WP_Query( $query_args );
if ( $oceanwp_query->have_posts() ) :
while ( $oceanwp_query->have_posts() ) : $oceanwp_query->the_post(); ?>
<li class="clr">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="recent-posts-thumbnail">
<?php
// Display post thumbnail
the_post_thumbnail( 'thumbnail', array(
'alt' => get_the_title(),
'itemprop' => 'image',
) ); ?>
<span class="overlay"></span>
</a>
<?php } ?>
<div class="recent-posts-details clr">
<div class="recent-posts-details-inner clr">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="recent-posts-title"><?php the_title(); ?></a>
<div class="recent-posts-info clr">
<div class="recent-posts-date"><?php echo get_the_date(); ?><span class="sep">/</span></div>
<div class="recent-posts-comments"><a href="<?php comments_link(); ?>"><?php comments_number( esc_html__( '0 Comments', 'ocean-extra' ), esc_html__( '1 Comment', 'ocean-extra' ), esc_html__( '% Comments', 'ocean-extra' ) ); ?></a></div>
</div>
</div>
</div>
</li>
<?php endwhile; ?>
<?php else : ?>
<p class="not-found">
<?php esc_html_e('No posts found.', 'ocean-extra'); ?>
</p>
<?php endif; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php
// 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['post_type'] = ! empty( $new_instance['post_type'] ) ? strip_tags( $new_instance['post_type'] ) : '';
$instance['taxonomy'] = ! empty( $new_instance['taxonomy'] ) ? strip_tags( $new_instance['taxonomy'] ) : '';
$instance['terms'] = ! empty( $new_instance['terms'] ) ? strip_tags( $new_instance['terms'] ) : '';
$instance['number'] = ! empty( $new_instance['number'] ) ? strip_tags( $new_instance['number'] ) : '';
$instance['order'] = ! empty( $new_instance['order'] ) ? strip_tags( $new_instance['order'] ) : '';
$instance['orderby'] = ! empty( $new_instance['orderby'] ) ? strip_tags( $new_instance['orderby'] ) : '';
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 ) {
extract( wp_parse_args( ( array ) $instance, $this->defaults ) ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?></label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number', 'ocean-extra' ); ?></label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number" min="0" step="1" value="<?php echo esc_attr( $number ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_type' ) ); ?>"><?php esc_html_e( 'Post Type', 'ocean-extra' ); ?></label>
<br />
<select class='oceanwp-select' name="<?php echo esc_attr( $this->get_field_name( 'post_type' ) ); ?>" style="width:100%;">
<option value="post" <?php selected( $post_type, 'post' ); ?>><?php esc_html_e( 'Post', 'ocean-extra' ); ?></option>
<?php
// Get Post Types
$get_post_types = get_post_types( array(
'public' => true,
'_builtin' => false,
), 'objects', 'and' );
foreach ( $get_post_types as $key => $val ) : ?>
<?php if ( $key != 'post' ) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $post_type, $key ); ?>><?php echo esc_html( $val->labels->name ); ?></option>
<?php } ?>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'taxonomy' ) ); ?>"><?php esc_html_e( 'Query By Taxonomy', 'ocean-extra' ); ?></label>
<br />
<select class='oceanwp-select' name="<?php echo esc_attr( $this->get_field_name( 'taxonomy' ) ); ?>" style="width:100%;">
<option value="" <?php if ( ! $taxonomy ) { ?>selected="selected"<?php } ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<?php
// Get Taxonomies
$get_taxonomies = get_taxonomies( array(
'public' => true,
), 'objects' ); ?>
<?php foreach ( $get_taxonomies as $get_taxonomy ) : ?>
<option value="<?php echo esc_attr( $get_taxonomy->name ); ?>" <?php selected( $taxonomy, $get_taxonomy->name ); ?>><?php echo esc_html( ucfirst( $get_taxonomy->labels->singular_name ) ); ?></option>
<?php endforeach; ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'terms' ) ); ?>"><?php esc_html_e( 'Terms', 'ocean-extra' ); ?></label>
<br />
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'terms' ) ); ?>" type="text" value="<?php echo esc_attr( $terms ); ?>" />
<small><?php esc_html_e( 'Enter the term slugs to query by seperated by a "comma"', 'ocean-extra' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order', 'ocean-extra' ); ?></label>
<br />
<select class='oceanwp-select' name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" style="width:100%;">
<option value="DESC" <?php selected( $order, 'DESC', true ); ?>><?php esc_html_e( 'Descending', 'ocean-extra' ); ?></option>
<option value="ASC" <?php selected( $order, 'ASC', true ); ?>><?php esc_html_e( 'Ascending', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order By', 'ocean-extra' ); ?>:</label>
<br />
<select class='oceanwp-select' name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" style="width:100%;">
<?php
// Orderby options
$orderby_array = array (
'date' => esc_html__( 'Date', 'ocean-extra' ),
'title' => esc_html__( 'Title', 'ocean-extra' ),
'modified' => esc_html__( 'Modified', 'ocean-extra' ),
'author' => esc_html__( 'Author', 'ocean-extra' ),
'rand' => esc_html__( 'Random', 'ocean-extra' ),
'comment_count' => esc_html__( 'Comment Count', 'ocean-extra' ),
);
foreach ( $orderby_array as $key => $value ) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $orderby, $key ); ?>>
<?php echo esc_attr( strip_tags( $value ) ); ?>
</option>
<?php } ?>
</select>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Recent_Posts_Thumbnails_Widget' );
@@ -0,0 +1,468 @@
<?php
/**
* Social Share widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Social_Share_Widget' ) ) {
class Ocean_Extra_Social_Share_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
// Start up widget
parent::__construct(
'ocean_social_share',
esc_html__( '&raquo; Social Share', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-social-share social-share',
'description' => esc_html__( 'Display social sharing buttons on your sidebar.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );
}
/**
* Enqueue scripts.
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function enqueue_scripts( $hook_suffix ) {
if ( 'widgets.php' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
}
/**
* Enqueue scripts.
*
* @since 1.0.0
*/
public function social_array() {
$post_id = get_the_ID();
$post_url = get_permalink( $post_id );
$post_title = get_the_title();
// Get SEO meta and use instead if they exist
if ( defined( 'WPSEO_VERSION' ) ) {
if ( $meta = get_post_meta( $post_id, '_yoast_wpseo_twitter-title', true ) ) {
$post_title = $meta;
}
}
// Array
$return = apply_filters( 'ocean_social_share_buttons', array(
'twitter' => array(
'name' => 'Twitter',
'title' => esc_html__( 'Share on Twitter', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-twitter-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M23.954 4.569c-.885.389-1.83.654-2.825.775 1.014-.611 1.794-1.574 2.163-2.723-.951.555-2.005.959-3.127 1.184-.896-.959-2.173-1.559-3.591-1.559-2.717 0-4.92 2.203-4.92 4.917 0 .39.045.765.127 1.124C7.691 8.094 4.066 6.13 1.64 3.161c-.427.722-.666 1.561-.666 2.475 0 1.71.87 3.213 2.188 4.096-.807-.026-1.566-.248-2.228-.616v.061c0 2.385 1.693 4.374 3.946 4.827-.413.111-.849.171-1.296.171-.314 0-.615-.03-.916-.086.631 1.953 2.445 3.377 4.604 3.417-1.68 1.319-3.809 2.105-6.102 2.105-.39 0-.779-.023-1.17-.067 2.189 1.394 4.768 2.209 7.557 2.209 9.054 0 13.999-7.496 13.999-13.986 0-.209 0-.42-.015-.63.961-.689 1.8-1.56 2.46-2.548l-.047-.02z"/>
</svg>',
'url' => 'https://twitter.com/share?text='. wp_strip_all_tags( $post_title ) .'&amp;url='. rawurlencode( esc_url( $post_url ) ),
),
'facebook' => array(
'name' => 'Facebook',
'title' => esc_html__( 'Share on Facebook', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-facebook-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M5.677,12.998V8.123h3.575V6.224C9.252,2.949,11.712,0,14.736,0h3.94v4.874h-3.94
c-0.432,0-0.934,0.524-0.934,1.308v1.942h4.874v4.874h-4.874V24H9.252V12.998H5.677z"/>
</svg>',
'url' => 'https://www.facebook.com/sharer.php?u='. rawurlencode( esc_url( $post_url ) ),
),
'googleplus' => array(
'name' => 'Google+',
'title' => esc_html__( 'Share on Google+', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-googleplus-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M7.636,10.929V13.5h4.331c-0.175,1.104-1.309,3.236-4.331,3.236c-2.607,0-4.735-2.121-4.735-4.736
s2.127-4.736,4.735-4.736c1.484,0,2.476,0.621,3.044,1.157l2.073-1.961C11.422,5.239,9.698,4.5,7.636,4.5C3.415,4.5,0,7.854,0,12
s3.415,7.5,7.636,7.5c4.407,0,7.331-3.043,7.331-7.329c0-0.493-0.055-0.868-0.12-1.243H7.636z"/>
<path d="M21.818,10.929V8.786h-2.182v2.143h-2.182v2.143h2.182v2.143h2.182v-2.143H24c0,0.022,0-2.143,0-2.143
H21.818z"/>
</svg>',
'url' => 'https://plus.google.com/share?url='. rawurlencode( esc_url( $post_url ) ),
),
'pinterest' => array(
'name' => 'Pinterest',
'title' => esc_html__( 'Share on Pinterest', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-pinterest-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M13.757,17.343c-1.487,0-2.886-0.804-3.365-1.717c0,0-0.8,3.173-0.969,3.785
c-0.596,2.165-2.35,4.331-2.487,4.508c-0.095,0.124-0.305,0.085-0.327-0.078c-0.038-0.276-0.485-3.007,0.041-5.235
c0.264-1.118,1.772-7.505,1.772-7.505s-0.44-0.879-0.44-2.179c0-2.041,1.183-3.565,2.657-3.565c1.252,0,1.857,0.94,1.857,2.068
c0,1.26-0.802,3.142-1.216,4.888c-0.345,1.461,0.734,2.653,2.174,2.653c2.609,0,4.367-3.352,4.367-7.323
c0-3.018-2.032-5.278-5.731-5.278c-4.177,0-6.782,3.116-6.782,6.597c0,1.2,0.355,2.047,0.909,2.701
c0.255,0.301,0.29,0.422,0.198,0.767c-0.067,0.254-0.218,0.864-0.281,1.106c-0.092,0.349-0.375,0.474-0.69,0.345
c-1.923-0.785-2.82-2.893-2.82-5.262c0-3.912,3.3-8.604,9.844-8.604c5.259,0,8.72,3.805,8.72,7.89
C21.188,13.307,18.185,17.343,13.757,17.343z"/>
</svg>',
'url' => 'https://www.pinterest.com/pin/create/button/?url='. rawurlencode( esc_url( $post_url ) ) .'&amp;media='. wp_get_attachment_url( get_post_thumbnail_id( $post_id ) ) .'&amp;description='. ( !is_admin() ? urlencode( wp_trim_words( strip_shortcodes( get_the_content( $post_id ) ), 40 ) ) : ''),
),
'linkedin' => array(
'name' => 'LinkedIn',
'title' => esc_html__( 'Share on LinkedIn', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-linkedin-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M6.52,22h-4.13V8.667h4.13V22z M4.436,6.92
c-1.349,0-2.442-1.101-2.442-2.46C1.994,3.102,3.087,2,4.436,2s2.442,1.102,2.442,2.46C6.877,5.819,5.784,6.92,4.436,6.92z
M21.994,22h-4.109c0,0,0-5.079,0-6.999c0-1.919-0.73-2.991-2.249-2.991c-1.652,0-2.515,1.116-2.515,2.991c0,2.054,0,6.999,0,6.999
h-3.96V8.667h3.96v1.796c0,0,1.191-2.202,4.02-2.202c2.828,0,4.853,1.727,4.853,5.298C21.994,17.129,21.994,22,21.994,22z"/>
</svg>',
'url' => 'https://www.linkedin.com/shareArticle?mini=true&amp;url='. rawurlencode( esc_url( $post_url ) ) .'&amp;title='. wp_strip_all_tags( $post_title ) .'&amp;summary='. ( !is_admin() ? urlencode( wp_trim_words( strip_shortcodes( get_the_content( $post_id ) ), 40 ) ) .'&amp;source='. esc_url( home_url( '/' ) ) : ''),
),
'viber' => array(
'name' => 'Viber',
'title' => esc_html__( 'Share on Viber', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-viber-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M14.957,5.825c0.764,0.163,1.349,0.453,1.849,0.921c0.643,0.608,0.996,1.343,1.151,2.4
c0.105,0.689,0.062,0.96-0.182,1.184c-0.229,0.209-0.651,0.217-0.907,0.019c-0.186-0.139-0.244-0.286-0.287-0.685
c-0.05-0.53-0.143-0.902-0.302-1.246c-0.341-0.731-0.942-1.111-1.957-1.235c-0.477-0.058-0.62-0.112-0.775-0.294
c-0.283-0.337-0.174-0.883,0.217-1.084c0.147-0.074,0.209-0.081,0.535-0.062C14.5,5.755,14.798,5.79,14.957,5.825z M14.131,2.902
c2.353,0.344,4.175,1.436,5.369,3.209c0.671,0.999,1.089,2.171,1.233,3.429c0.05,0.461,0.05,1.3-0.004,1.44
c-0.051,0.131-0.213,0.309-0.353,0.383c-0.151,0.078-0.473,0.07-0.651-0.023c-0.298-0.151-0.388-0.391-0.388-1.041
c0-1.002-0.26-2.059-0.709-2.88c-0.512-0.937-1.256-1.711-2.163-2.249c-0.779-0.465-1.93-0.809-2.981-0.894
c-0.38-0.031-0.589-0.108-0.733-0.275c-0.221-0.252-0.244-0.592-0.058-0.875C12.895,2.813,13.205,2.763,14.131,2.902z
M5.002,0.514c0.136,0.047,0.345,0.155,0.465,0.232c0.736,0.488,2.787,3.108,3.458,4.416c0.384,0.747,0.512,1.3,0.392,1.711
C9.193,7.314,8.988,7.547,8.069,8.286C7.701,8.584,7.356,8.89,7.301,8.971C7.162,9.172,7.049,9.567,7.049,9.846
c0.004,0.646,0.423,1.819,0.973,2.721c0.426,0.7,1.19,1.598,1.946,2.287c0.888,0.813,1.671,1.366,2.555,1.804
c1.136,0.565,1.83,0.708,2.337,0.472c0.128-0.058,0.264-0.135,0.306-0.17c0.039-0.035,0.337-0.399,0.663-0.801
c0.628-0.79,0.771-0.917,1.202-1.065c0.547-0.186,1.105-0.135,1.667,0.151c0.427,0.221,1.357,0.797,1.957,1.215
c0.791,0.553,2.481,1.931,2.71,2.206c0.403,0.495,0.473,1.13,0.202,1.831c-0.287,0.739-1.403,2.125-2.182,2.717
c-0.705,0.534-1.206,0.739-1.865,0.77c-0.543,0.027-0.768-0.019-1.461-0.306c-5.442-2.241-9.788-5.585-13.238-10.179
c-1.802-2.4-3.175-4.888-4.113-7.47c-0.547-1.505-0.574-2.16-0.124-2.93c0.194-0.325,1.019-1.13,1.62-1.579
c1-0.743,1.461-1.018,1.83-1.095C4.285,0.371,4.723,0.414,5.002,0.514z M13.864,0.096c1.334,0.166,2.411,0.487,3.593,1.065
c1.163,0.569,1.907,1.107,2.892,2.086c0.923,0.925,1.434,1.626,1.977,2.713c0.756,1.517,1.186,3.321,1.26,5.306
c0.027,0.677,0.008,0.828-0.147,1.022c-0.294,0.375-0.942,0.313-1.163-0.108c-0.07-0.139-0.089-0.259-0.112-0.801
c-0.039-0.832-0.097-1.37-0.213-2.013c-0.458-2.52-1.667-4.532-3.597-5.976c-1.609-1.208-3.272-1.796-5.45-1.924
c-0.737-0.043-0.864-0.07-1.031-0.197c-0.31-0.244-0.326-0.817-0.027-1.084c0.182-0.166,0.31-0.19,0.942-0.17
C13.116,0.027,13.6,0.065,13.864,0.096z"/>
</svg>',
'url' => 'viber://forward?text='. rawurlencode( esc_url( $post_url ) ),
),
'vk' => array(
'name' => 'VK',
'title' => esc_html__( 'Share on VK', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-vk-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M11.701 18.771h1.437s.433-.047.654-.284c.21-.221.21-.63.21-.63s-.031-1.927.869-2.21c.887-.281 2.012 1.86 3.211 2.683.916.629 1.605.494 1.605.494l3.211-.044s1.682-.105.887-1.426c-.061-.105-.451-.975-2.371-2.76-2.012-1.861-1.742-1.561.676-4.787 1.469-1.965 2.07-3.166 1.875-3.676-.166-.48-1.26-.361-1.26-.361l-3.602.031s-.27-.031-.465.09c-.195.119-.314.391-.314.391s-.572 1.529-1.336 2.82c-1.623 2.729-2.268 2.879-2.523 2.699-.604-.391-.449-1.58-.449-2.432 0-2.641.404-3.75-.781-4.035-.39-.091-.681-.15-1.685-.166-1.29-.014-2.378.01-2.995.311-.405.203-.72.652-.539.675.24.03.779.146 1.064.537.375.506.359 1.636.359 1.636s.211 3.116-.494 3.503c-.495.262-1.155-.28-2.595-2.756-.735-1.26-1.291-2.67-1.291-2.67s-.105-.256-.299-.406c-.227-.165-.557-.225-.557-.225l-3.435.03s-.51.016-.689.24c-.166.195-.016.615-.016.615s2.686 6.287 5.732 9.453c2.79 2.902 5.956 2.715 5.956 2.715l-.05-.055z"/>
</svg>',
'url' => 'https://vk.com/share.php?url='. rawurlencode( esc_url( $post_url ) ),
),
'reddit' => array(
'name' => 'Reddit',
'title' => esc_html__( 'Share on Reddit', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-reddit-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M23.999,11.786c0-1.576-1.294-2.858-2.885-2.858c-0.689,0-1.321,0.241-1.817,0.641
c-1.759-1.095-3.991-1.755-6.383-1.895l1.248-3.91l3.43,0.8c0.09,1.237,1.134,2.217,2.405,2.217c1.33,0,2.412-1.072,2.412-2.391
c0-1.318-1.082-2.39-2.412-2.39c-0.93,0-1.739,0.525-2.141,1.291l-3.985-0.93c-0.334-0.078-0.671,0.112-0.775,0.436L11.547,7.65
C8.969,7.712,6.546,8.375,4.658,9.534c-0.49-0.38-1.105-0.607-1.774-0.607C1.293,8.927,0,10.209,0,11.785
c0,0.974,0.495,1.836,1.249,2.351c-0.031,0.227-0.048,0.455-0.048,0.686c0,1.97,1.156,3.803,3.254,5.16
C6.468,21.283,9.13,22,11.952,22s5.485-0.716,7.496-2.018c2.099-1.357,3.254-3.19,3.254-5.16c0-0.21-0.014-0.419-0.041-0.626
C23.464,13.689,23.999,12.798,23.999,11.786 M19.997,3.299c0.607,0,1.102,0.49,1.102,1.091c0,0.602-0.494,1.092-1.102,1.092
s-1.102-0.49-1.102-1.092C18.896,3.789,19.389,3.299,19.997,3.299 M6.805,13.554c0-0.888,0.752-1.633,1.648-1.633
c0.897,0,1.625,0.745,1.625,1.633c0,0.889-0.728,1.61-1.625,1.61C7.557,15.163,6.805,14.442,6.805,13.554 M15.951,18.288
c-0.836,0.827-2.124,1.229-3.939,1.229c-0.004,0-0.008-0.001-0.013-0.001c-0.004,0-0.008,0.001-0.013,0.001
c-1.815,0-3.103-0.402-3.938-1.229c-0.256-0.254-0.256-0.665,0-0.919c0.256-0.253,0.671-0.253,0.927,0
c0.576,0.571,1.561,0.849,3.01,0.849c0.005,0,0.009,0.001,0.013,0.001c0.005,0,0.009-0.001,0.013-0.001
c1.45,0,2.435-0.278,3.012-0.849c0.256-0.254,0.671-0.253,0.927,0C16.206,17.623,16.206,18.034,15.951,18.288 M15.569,15.163
c-0.897,0-1.651-0.721-1.651-1.61s0.754-1.633,1.651-1.633s1.625,0.745,1.625,1.633C17.193,14.442,16.466,15.163,15.569,15.163"/>
</svg>',
'url' => 'https://www.reddit.com/submit?url='. rawurlencode( esc_url( $post_url ) ) .'&amp;title='. wp_strip_all_tags( $post_title ),
),
'tumblr' => array(
'name' => 'Tumblr',
'title' => esc_html__( 'Share on Tumblr', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-tumblr-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M19.44,22.887c-1.034,0.487-1.97,0.828-2.808,1.024
c-0.838,0.195-1.744,0.293-2.718,0.293c-1.106,0-2.083-0.14-2.933-0.418c-0.851-0.279-1.575-0.677-2.175-1.194
c-0.6-0.518-1.017-1.067-1.248-1.649c-0.231-0.581-0.347-1.425-0.347-2.53V9.93H4.56V6.482c0.947-0.309,1.759-0.751,2.434-1.327
C7.67,4.58,8.212,3.889,8.62,3.081C9.029,2.274,9.311,1.247,9.464,0h3.429v6.131h5.747V9.93h-5.747v6.208
c0,1.403,0.074,2.304,0.223,2.702c0.149,0.399,0.426,0.718,0.829,0.954c0.536,0.322,1.148,0.483,1.838,0.483
c1.225,0,2.444-0.399,3.657-1.196V22.887L19.44,22.887z"/>
</svg>',
'url' => 'https://www.tumblr.com/widgets/share/tool?canonicalUrl='. rawurlencode( esc_url( $post_url ) ),
),
'viadeo' => array(
'name' => 'Viadeo',
'title' => esc_html__( 'Share on Viadeo', 'ocean-extra' ),
'icon' => '<svg class="owpss-icon" aria-labelledby="owpss-viadeo-icon" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M21.046,0.546c-1.011,2.159-2.882,2.557-2.882,2.557c-1.87,0.476-2.525,1.202-2.525,1.202
c-1.871,1.889-0.396,4.181-0.396,4.181c4.039-0.922,5.514-4.259,5.514-4.259c-0.181,2.242-4.986,4.887-4.986,4.887
c1.592,1.565,3.111,1.374,4.112,0.775c1.328-0.795,1.968-2.537,1.968-2.537C23.142,3.484,21.046,0.546,21.046,0.546z
M14.424,7.082c0.044,0.662,0.772,12.464-5.445,14.829c0,0,0.571,0.108,1.216,0.079c0,0,7.912-5.015,4.283-14.745
C14.478,7.244,14.463,7.185,14.424,7.082z M11.113,0c1.988,3.356,3.067,6.364,3.311,7.081V7.052C13.936,1.88,11.113,0,11.113,0z"/>
<path d="M16.465,15.438c0,1.192-0.283,2.301-0.85,3.332c-0.566,1.031-1.328,1.825-2.295,2.385
c-0.962,0.559-2.022,0.839-3.169,0.839c-1.153,0-2.207-0.28-3.169-0.839C6.02,20.595,5.253,19.8,4.687,18.769
c-0.566-1.03-0.85-2.139-0.85-3.332c0-1.845,0.62-3.42,1.861-4.725c1.24-1.3,2.725-1.953,4.454-1.953
c0.82,0,1.587,0.152,2.3,0.447c0.073-0.756,0.337-1.457,0.625-2.032c-0.899-0.329-1.87-0.491-2.92-0.491
c-2.496,0-4.561,0.923-6.197,2.772c-1.485,1.673-2.232,3.656-2.232,5.932c0,2.301,0.786,4.313,2.354,6.031
C5.655,23.141,7.677,24,10.152,24c2.466,0,4.488-0.859,6.056-2.581c1.573-1.722,2.354-3.734,2.354-6.031
c0-1.232-0.215-2.375-0.645-3.425c-0.723,0.447-1.406,0.677-1.973,0.8C16.295,13.578,16.465,14.471,16.465,15.438z"/>
</svg>',
'url' => 'https://partners.viadeo.com/share?url='. rawurlencode( esc_url( $post_url ) ),
),
) );
return $return;
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Get social share and
$social_share = isset( $instance['social_share'] ) ? $instance['social_share'] : '';
// Return if no social defined
if ( ! $social_share ) {
return;
}
// Return if no content or search page
if ( empty( get_the_content() )
|| is_search() ) {
return;
}
// Define vars
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$style = isset( $instance['style'] ) ? $instance['style'] : '';
$border_radius = isset( $instance['border_radius'] ) ? $instance['border_radius'] : '';
$twitter_username = isset( $instance['twitter_username'] ) ? $instance['twitter_username'] : '';
$social_name = isset( $instance['social_name'] ) ? $instance['social_name'] : 0;
// Sanitize vars
$border_radius = $border_radius ? $border_radius : '';
// Inline style
$add_style = '';
if ( $border_radius && 'simple' != $style ) {
$add_style .= 'border-radius:'. esc_attr( $border_radius ) .';';
}
if ( $add_style ) {
$add_style = ' style="' . esc_attr( $add_style ) . '"';
}
// Before widget hook
echo $args['before_widget'];
// Display title
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Display the social share. ?>
<ul class="owp-social-share style-<?php echo esc_attr( $style ); ?> name-<?php echo $social_name ? 'shown' : 'hidden'; ?>">
<?php
// Original Array
$social_array = $this->social_array();
// Loop through each item in the array
foreach( $social_share as $social_key ) {
$name = $social_array[$social_key]['name'];
$title = $social_array[$social_key]['title'];
$url = $social_array[$social_key]['url'];
$icon = $social_array[$social_key]['icon'];
if ( $social_key == 'twitter' && !empty( $twitter_username ) ) {
$url = $url . '&amp;via='.$twitter_username;
}
echo '<li class="'. esc_attr( $social_key ) .'">';
echo '<a href="'. $url .'" title="'. esc_attr( $title ) .'" '. wp_kses_post( $add_style ) . ' onclick="owpShareOnClick( this.href );return false;">';
echo '<span class="owp-icon-wrap">';
echo $icon;
echo '</span>';
if( $social_name ) {
echo '<span class="owp-social-name">' . $name . '</span>';
}
echo '</a>';
echo '</li>';
} ?>
</ul>
<?php $this->colors( $args, $instance ); ?>
<?php
// After widget 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 ) {
// Sanitize data
$instance = $old_instance;
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : null;
$instance['style'] = ! empty( $new_instance['style'] ) ? strip_tags( $new_instance['style'] ) : 'light';
$instance['border_radius'] = ! empty( $new_instance['border_radius'] ) ? strip_tags( $new_instance['border_radius'] ) : '';
$instance['border_color'] = ! empty( $new_instance['border_color'] ) ? sanitize_hex_color( $new_instance['border_color'] ) : '';
$instance['bg_color'] = ! empty( $new_instance['bg_color'] ) ? sanitize_hex_color( $new_instance['bg_color'] ) : '';
$instance['color'] = ! empty( $new_instance['color'] ) ? sanitize_hex_color( $new_instance['color'] ) : '';
$instance['twitter_username'] = ! empty( $new_instance['twitter_username'] ) ? sanitize_text_field( $new_instance['twitter_username'] ) : '';
$instance['social_name'] = empty( $new_instance[ 'social_name' ] ) ? 0 : 1;
$instance['social_share'] = $new_instance['social_share'];
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 ) {
$instance = wp_parse_args( ( array ) $instance, array(
'title' => esc_attr__( 'Please share this', 'ocean-extra' ),
'style' => esc_html__( 'Minimal', 'ocean-extra' ),
'border_radius' => '',
'border_color' => '',
'bg_color' => '',
'color' => '',
'twitter_username' => '',
'social_name' => '',
'social_share' => array('twitter', 'facebook', 'googleplus', 'pinterest', 'linkedin', 'viber', 'vk', 'reddit', 'tumblr', 'viadeo'),
) ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</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( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'style' ) ); ?>"><?php esc_html_e( 'Style:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'style' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'style' ) ); ?>">
<option value="minimal" <?php selected( $instance['style'], 'minimal' ) ?>><?php esc_html_e( 'Minimal', 'ocean-extra' ); ?></option>
<option value="colored" <?php selected( $instance['style'], 'colored' ) ?>><?php esc_html_e( 'Colored', 'ocean-extra' ); ?></option>
<option value="dark" <?php selected( $instance['style'], 'dark' ) ?>><?php esc_html_e( 'Dark', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'border_radius' ) ); ?>"><?php esc_html_e( 'Border Radius', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'border_radius' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_radius' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['border_radius'] ); ?>" />
<small><?php esc_html_e( 'Example:', 'ocean-extra' ); ?> 4px</small>
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>"><?php esc_html_e( 'Minimal Style: Border Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['border_color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>"><?php esc_html_e( 'Minimal Style: Background Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'bg_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['bg_color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'color' ) ); ?>"><?php esc_html_e( 'Minimal Style: Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'twitter_username' ) ); ?>"><?php esc_html_e( 'Twitter Username', 'ocean-extra' ); ?>:</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'twitter_username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'twitter_username' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['twitter_username'] ); ?>" />
</p>
<p>
<input class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'social_name' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'social_name' ) ); ?>" type="checkbox" value="1" <?php checked( $instance['social_name'], 1 ); ?> />
<label for="<?php echo $this->get_field_id( 'social_name' ); ?>"><?php esc_html_e( 'Show Social Name', 'ocean-extra' ); ?></label>
</p>
<h3><?php esc_html_e( 'Social Share','ocean-extra' ); ?></h3>
<?php
// Social array
$display_share = $this->social_array();
// Loop through social share to display inputs
foreach( $display_share as $key => $val ) { ?>
<p>
<input class="checkbox" id="<?php echo $this->get_field_id("social_share") . $key; ?>" name="<?php echo $this->get_field_name("social_share"); ?>[]" type="checkbox" value="<?php echo $key; ?>" <?php checked(in_array($key, (array) $instance["social_share"])); ?> />
<label for="<?php echo $this->get_field_id("social_share") . $key; ?>"><?php echo $val['name']; ?></label>
</p>
<?php }
}
/**
* Colors
*
* @since 1.3.8
*
* @param array $instance Previously saved values from database.
*/
public function colors( $args, $instance ) {
// get the widget ID
$id = $args['widget_id'];
// Define vars
$border_color = isset( $instance['border_color'] ) ? sanitize_hex_color( $instance['border_color'] ) : '';
$bg_color = isset( $instance['bg_color'] ) ? sanitize_hex_color( $instance['bg_color'] ) : '';
$color = isset( $instance['color'] ) ? sanitize_hex_color( $instance['color'] ) : '';
if ( $bg_color
|| $color
|| $border_color ) : ?>
<style>
#<?php echo $id; ?>.widget-oceanwp-social-share ul li a {
<?php if ( $bg_color ) { echo 'background-color:' . $bg_color; } ?>;
<?php if ( $color ) { echo 'color:' . $color; } ?>;
<?php if ( $border_color ) { echo 'border-color:' . $border_color; } ?>;
}
</style>
<?php endif; ?>
<?php
}
/**
* Scripts
*/
public function scripts() {
// Load only if the widget is used
if ( is_active_widget( '', '', 'ocean_social_share' ) ) {
wp_enqueue_script( 'oe-social-share', OE_URL . 'includes/widgets/js/share.min.js', array( 'jquery' ), false, true );
}
}
}
}
register_widget( 'Ocean_Extra_Social_Share_Widget' );
@@ -0,0 +1,585 @@
<?php
/**
* Social widget.
*
* @package OceanWP WordPress theme
* @since 1.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Social_Widget' ) ) {
class Ocean_Extra_Social_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
// Declare social services array.
$this->social_services_array = apply_filters( 'ocean_social_widget_profiles',
array(
'twitter' => array(
'name' => 'Twitter',
'url' => '',
),
'facebook' => array(
'name' => 'Facebook',
'url' => '',
),
'instagram' => array(
'name' => 'Instagram',
'url' => '',
),
'google-plus' => array(
'name' => 'GooglePlus',
'url' => '',
),
'linkedin' => array(
'name' => 'LinkedIn',
'url' => '',
),
'pinterest' => array(
'name' => 'Pinterest',
'url' => '',
),
'yelp' => array(
'name' => 'Yelp',
'url' => '',
),
'dribbble' => array(
'name' => 'Dribbble',
'url' => '',
),
'flickr' => array(
'name' => 'Flickr',
'url' => '',
),
'vk' => array(
'name' => 'VK',
'url' => '',
),
'github' => array(
'name' => 'GitHub',
'url' => '',
),
'tumblr' => array(
'name' => 'Tumblr',
'url' => '',
),
'skype' => array(
'name' => 'Skype',
'url' => '',
),
'trello' => array(
'name' => 'Trello',
'url' => '',
),
'foursquare' => array(
'name' => 'Foursquare',
'url' => '',
),
'xing' => array(
'name' => 'Xing',
'url' => '',
),
'vimeo-square' => array(
'name' => 'Vimeo',
'url' => '',
),
'vine' => array(
'name' => 'Vine',
'url' => '',
),
'youtube' => array(
'name' => 'Youtube',
'url' => '',
),
'rss' => array(
'name' => 'RSS',
'url' => '',
),
)
);
// Start up widget.
parent::__construct(
'ocean_social',
esc_html__( '&raquo; Social Icons', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-social social-widget',
'description' => esc_html__( 'Display your social media icons.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
// Since 1.3.8.
add_action( 'admin_head-widgets.php', array( $this, 'social_widget_style' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_footer-widgets.php', array( $this, 'print_scripts' ) );
}
/**
* Custom widget style
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function social_widget_style() {
?>
<style>
.oceanwp-social-widget-services-list { padding-top: 10px; }
.oceanwp-social-widget-services-list li { cursor: move; background: #fafafa; padding: 10px; border: 1px solid #e5e5e5; margin-bottom: 10px; }
.oceanwp-social-widget-services-list li p { margin: 0 }
.oceanwp-social-widget-services-list li label { margin-bottom: 3px; display: block; color: #222; }
.oceanwp-social-widget-services-list li label span.fa { margin-right: 10px }
.oceanwp-social-widget-services-list li label span.fab { margin-right: 10px }
.oceanwp-social-widget-services-list .placeholder { border: 1px dashed #e3e3e3 }
.oceanwp-widget-select { width: 100% }
.color-label { display: block; margin-bottom: 5px; }
</style>
<?php
}
/**
* Enqueue scripts.
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function enqueue_scripts( $hook_suffix ) {
if ( 'widgets.php' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'underscore' );
}
/**
* Print scripts.
*
* @since 1.3.8
*/
public function print_scripts() { ?>
<script>
( function( $ ){
$(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'ocean_social';
if (typeof(settings.data) !== 'undefined' && typeof(settings.data.search) !== 'undefined') {
if ( settings.data.search( 'action=save-widget' ) !== 'undefined' && typeof(settings.data.search( 'id_base=' + widget_id_base)) !== 'undefined' ) {
oceanwpSortServices();
}
}
} );
function oceanwpSortServices() {
$( '.oceanwp-social-widget-services-list' ).each( function() {
var id = $(this).attr( 'id' );
$( '#'+ id ).sortable( {
placeholder : "placeholder",
opacity : 0.6
} );
} );
}
oceanwpSortServices();
function initColorPicker( widget ) {
widget.find( '.color-picker' ).wpColorPicker( {
change: _.throttle( function() { // For Customizer.
$(this).trigger( 'change' );
}, 3000 )
});
}
function onFormUpdate( event, widget ) {
initColorPicker( widget );
}
$( document ).on( 'widget-added widget-updated', onFormUpdate );
$( document ).ready( function() {
$( '#widgets-right .widget:has(.color-picker)' ).each( function () {
initColorPicker( $( this ) );
} );
} );
}( jQuery ) );
</script>
<?php
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
// Get social services.
$social_services = isset( $instance['social_services'] ) ? $instance['social_services'] : '';
// Return if no services defined.
if ( ! $social_services ) {
return;
}
// Define vars.
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$style = isset( $instance['style'] ) ? $instance['style'] : '';
$transition = isset( $instance['transition'] ) ? $instance['transition'] : '';
$target = isset( $instance['target'] ) ? $instance['target'] : '';
$nofollow = isset( $instance['nofollow'] ) ? $instance['nofollow'] : '';
$size = isset( $instance['size'] ) ? $instance['size'] : '';
$font_size = isset( $instance['font_size'] ) ? $instance['font_size'] : '';
$border_radius = isset( $instance['border_radius'] ) ? $instance['border_radius'] : '';
// Sanitize vars.
$size = $size ? $size : '';
$font_size = $font_size ? $font_size : '';
$border_radius = $border_radius ? $border_radius : '';
// Inline style
$add_style = '';
if ( $size && 'simple' != $style ) {
$add_style .= 'height:'. esc_attr( $size ) .';width:'. esc_attr( $size ) .';line-height:'. esc_attr( $size ) .';';
}
if ( $font_size ) {
$add_style .= 'font-size:'. esc_attr( $font_size ) .';';
}
if ( $border_radius && 'simple' != $style ) {
$add_style .= 'border-radius:'. esc_attr( $border_radius ) .';';
}
if ( $add_style ) {
$add_style = ' style="' . esc_attr( $add_style ) . '"';
}
// Before widget hook.
echo $args['before_widget'];
// Display title.
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Determine link rel.
$ocean_srt = '<span class="screen-reader-text">'. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .'</span>';
$results = ocean_link_rel( $ocean_srt, $nofollow, $target );
$ocean_sr = $results[0];
$link_rel = $results[1];
// Display social icons.
?>
<ul class="oceanwp-social-icons <?php echo esc_attr( $transition ); ?> style-<?php echo esc_attr( $style ); ?>">
<?php
// Original Array.
$social_services_array = $this->social_services_array;
// Loop through each item in the array.
foreach( $social_services as $key => $val ) {
$link = ! empty( $social_services[$key]['url'] ) ? $social_services[$key]['url'] : null;
$name = $social_services_array[$key]['name'];
if ( $link ) {
$key = 'vimeo-square' === $key ? 'vimeo' : $key;
$icon = 'youtube' === $key ? 'youtube' : $key;
$icon = 'pinterest' === $key ? 'pinterest-p' : $icon;
$icon = 'bloglovin' === $key ? 'heart' : $icon;
$icon = 'vimeo-square' === $key ? 'vimeo' : $icon;
if ( 'skype' === $key ) {
$link = 'skype:'. esc_attr( $link ) .'?call';
$target = 'self';
if ( $nofollow === 'yes' ) {
$link_rel = 'rel="nofollow"';
} else if ( $nofollow === 'no' || $nofollow === '' ) {
$link_rel = '';
}
$ocean_sr = '';
$ocean_sr_skype = '<span class="screen-reader-text">'. esc_html__( 'Opens in your application', 'ocean-extra' ) .'</span>';
} else {
$link = esc_url( $link );
$ocean_sr_skype = '';
}
echo '<li class="oceanwp-'. esc_attr( $key ) .'">';
echo '<a href="'. $link .'" aria-label="'. esc_attr( $name ) .'" '. wp_kses_post( $add_style ) . ' target="_'. esc_attr( $target ) .'" '. $link_rel .'>';
// Display icons.
if( $icon === 'rss' ) {
echo '<i class="fa fa-'. esc_attr( $icon ) .'" aria-hidden="true"></i>';
} else {
echo '<i class="fab fa-'. esc_attr( $icon ) .'" aria-hidden="true"></i>';
}
echo '</a>';
// Display screen reader text.
echo $ocean_sr;
echo $ocean_sr_skype;
echo '</li>';
}
}
?>
</ul>
<?php $this->colors( $args, $instance ); ?>
<?php
// After widget 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 ) {
// Sanitize data.
$instance = $old_instance;
$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : null;
$instance['style'] = ! empty( $new_instance['style'] ) ? strip_tags( $new_instance['style'] ) : 'light';
$instance['transition'] = ! empty( $new_instance['transition'] ) ? strip_tags( $new_instance['transition'] ) : 'rotate';
$instance['target'] = ! empty( $new_instance['target'] ) ? strip_tags( $new_instance['target'] ) : 'blank';
$instance['nofollow'] = ! empty( $new_instance['nofollow'] ) ? strip_tags( $new_instance['nofollow'] ) : '';
$instance['size'] = ! empty( $new_instance['size'] ) ? strip_tags( $new_instance['size'] ) : '';
$instance['border_radius'] = ! empty( $new_instance['border_radius'] ) ? strip_tags( $new_instance['border_radius'] ) : '';
$instance['bg_color'] = ! empty( $new_instance['bg_color'] ) ? sanitize_hex_color( $new_instance['bg_color'] ) : '';
$instance['bg_hover_color'] = ! empty( $new_instance['bg_hover_color'] ) ? sanitize_hex_color( $new_instance['bg_hover_color'] ) : '';
$instance['color'] = ! empty( $new_instance['color'] ) ? sanitize_hex_color( $new_instance['color'] ) : '';
$instance['color_hover'] = ! empty( $new_instance['color_hover'] ) ? sanitize_hex_color( $new_instance['color_hover'] ) : '';
$instance['border_color'] = ! empty( $new_instance['border_color'] ) ? sanitize_hex_color( $new_instance['border_color'] ) : '';
$instance['border_hover_color'] = ! empty( $new_instance['border_hover_color'] ) ? sanitize_hex_color( $new_instance['border_hover_color'] ) : '';
$instance['font_size'] = ! empty( $new_instance['font_size'] ) ? strip_tags( $new_instance['font_size'] ) : '';
$instance['social_services'] = $new_instance['social_services'];
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 ) {
$instance = wp_parse_args( ( array ) $instance,
array(
'title' => esc_attr__( 'Follow Us', 'ocean-extra' ),
'style' => esc_html__( 'Light', 'ocean-extra' ),
'transition' => esc_html__( 'Rotate', 'ocean-extra' ),
'font_size' => '',
'border_radius' => '',
'bg_color' => '',
'bg_hover_color' => '',
'color' => '',
'color_hover' => '',
'border_color' => '',
'border_hover_color' => '',
'target' => 'blank',
'nofollow' => esc_html__( 'No', 'ocean-extra' ),
'size' => '',
'social_services' => $this->social_services_array,
)
);
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</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( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'style' ) ); ?>"><?php esc_html_e( 'Style:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'style' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'style' ) ); ?>">
<option value="light" <?php selected( $instance['style'], 'light' ) ?>><?php esc_html_e( 'Light', 'ocean-extra' ); ?></option>
<option value="dark" <?php selected( $instance['style'], 'dark' ) ?>><?php esc_html_e( 'Dark', 'ocean-extra' ); ?></option>
<option value="colored" <?php selected( $instance['style'], 'colored' ) ?>><?php esc_html_e( 'Colored', 'ocean-extra' ); ?></option>
<option value="simple" <?php selected( $instance['style'], 'simple' ) ?>><?php esc_html_e( 'Simple', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'transition' ) ); ?>"><?php esc_html_e( 'Transition:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'transition' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'transition' ) ); ?>">
<option value="no-transition" <?php selected( $instance['transition'], 'no-transition' ) ?>><?php esc_html_e( 'None', 'ocean-extra' ); ?></option>
<option value="float" <?php selected( $instance['transition'], 'float' ) ?>><?php esc_html_e( 'Float', 'ocean-extra' ); ?></option>
<option value="rotate" <?php selected( $instance['transition'], 'rotate' ) ?>><?php esc_html_e( 'Rotate', 'ocean-extra' ); ?></option>
<option value="zoomout" <?php selected( $instance['transition'], 'zoomout' ) ?>><?php esc_html_e( 'Zoom Out', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>"><?php esc_html_e( 'Link Target', 'ocean-extra' ); ?>:</label>
<select class="oceanwp-widget-select" name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'target' ) ); ?>">
<option value="blank" <?php selected( $instance['target'], 'blank' ) ?>><?php esc_html_e( 'Blank', 'ocean-extra' ); ?></option>
<option value="self" <?php selected( $instance['target'], 'self' ) ?>><?php esc_html_e( 'Self', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>"><?php esc_html_e( 'Add Nofollow Link Rel:', 'ocean-extra' ); ?></label>
<select class='widefat' name="<?php echo esc_attr( $this->get_field_name( 'nofollow' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'nofollow' ) ); ?>">
<option value="no" <?php selected( $instance['nofollow'], 'no' ) ?>><?php esc_html_e( 'No', 'ocean-extra' ); ?></option>
<option value="yes" <?php selected( $instance['nofollow'], 'yes' ) ?>><?php esc_html_e( 'Yes', 'ocean-extra' ); ?></option>
</select>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_html_e( 'Dimensions', 'ocean-extra' ); ?>:</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'size' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['size'] ); ?>" />
<small><?php esc_html_e( 'Example:', 'ocean-extra' ); ?> 40px</small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>"><?php esc_html_e( 'Font Size', 'ocean-extra' ); ?>:</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'font_size' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['font_size'] ); ?>" />
<small><?php esc_html_e( 'Example:', 'ocean-extra' ); ?> 18px</small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'border_radius' ) ); ?>"><?php esc_html_e( 'Border Radius', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'border_radius' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_radius' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['border_radius'] ); ?>" />
<small><?php esc_html_e( 'Example:', 'ocean-extra' ); ?> 4px</small>
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>"><?php esc_html_e( 'Background Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'bg_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['bg_color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'bg_hover_color' ) ); ?>"><?php esc_html_e( 'Background Color Hover', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'bg_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'bg_hover_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['bg_hover_color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'color' ) ); ?>"><?php esc_html_e( 'Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'color_hover' ) ); ?>"><?php esc_html_e( 'Color Hover', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'color_hover' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'color_hover' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['color_hover'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>"><?php esc_html_e( 'Border Color', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['border_color'] ); ?>" />
</p>
<p>
<label class="color-label" for="<?php echo esc_attr( $this->get_field_id( 'border_hover_color' ) ); ?>"><?php esc_html_e( 'Border Color Hover', 'ocean-extra' ); ?></label>
<input class="color-picker" id="<?php echo esc_attr( $this->get_field_id( 'border_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_hover_color' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['border_hover_color'] ); ?>" />
</p>
<?php
$field_id_services = $this->get_field_id( 'social_services' );
$field_name_services = $this->get_field_name( 'social_services' );
?>
<h3 style="margin-top:20px;margin-bottom:0;"><?php esc_html_e( 'Social Links','ocean-extra' ); ?></h3>
<ul id="<?php echo esc_attr( $field_id_services ); ?>" class="oceanwp-social-widget-services-list">
<input type="hidden" id="<?php echo esc_attr( $field_name_services ); ?>" value="<?php echo esc_attr( $field_name_services ); ?>">
<input type="hidden" id="<?php echo esc_attr( wp_create_nonce( 'oceanwp_fontawesome_social_widget_nonce' ) ); ?>">
<?php
// Social array.
$social_services_array = $this->social_services_array;
// Get current services display.
$display_services = isset ( $instance['social_services'] ) ? $instance['social_services']: '';
// Loop through social services to display inputs.
foreach( $display_services as $key => $val ) {
$url = ! empty( $display_services[$key]['url'] ) ? $display_services[$key]['url'] : null;
$name = $social_services_array[$key]['name'];
?>
<li id="<?php echo esc_attr( $field_id_services ); ?>_0<?php echo esc_attr( $key ); ?>">
<p>
<label for="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-name"><?php echo esc_attr( strip_tags( $name ) ); ?>:</label>
<input type="hidden" id="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-url" name="<?php echo esc_attr( $field_name_services .'['.$key.'][name]' ); ?>" value="<?php echo esc_attr( $name ); ?>">
<input type="text" class="widefat" id="<?php echo esc_attr( $field_id_services ); ?>-<?php echo esc_attr( $key ); ?>-url" name="<?php echo esc_attr( $field_name_services .'['.$key.'][url]' ); ?>" value="<?php echo esc_attr( $url ); ?>" />
</p>
</li>
<?php } ?>
</ul>
<?php
}
/**
* Colors
*
* @since 1.3.8
*
* @param array $instance Previously saved values from database.
*/
public function colors( $args, $instance ) {
// get the widget ID.
$id = $args['widget_id'];
// Define vars.
$bg_color = isset( $instance['bg_color'] ) ? sanitize_hex_color( $instance['bg_color'] ) : '';
$bg_hover_color = isset( $instance['bg_hover_color'] ) ? sanitize_hex_color( $instance['bg_hover_color'] ) : '';
$color = isset( $instance['color'] ) ? sanitize_hex_color( $instance['color'] ) : '';
$color_hover = isset( $instance['color_hover'] ) ? sanitize_hex_color( $instance['color_hover'] ) : '';
$border_color = isset( $instance['border_color'] ) ? sanitize_hex_color( $instance['border_color'] ) : '';
$border_hover_color = isset( $instance['border_hover_color'] ) ? sanitize_hex_color( $instance['border_hover_color'] ) : ''; ?>
<?php
if ( $bg_color || $bg_hover_color
|| $color || $color_hover
|| $border_color || $border_hover_color ) :
?>
<style>
#<?php echo $id; ?>.widget-oceanwp-social ul li a {
<?php if ( $bg_color ) { echo 'background-color:' . $bg_color; } ?>;
<?php if ( $color ) { echo 'color:' . $color; } ?>;
<?php if ( $border_color ) { echo 'border-color:' . $border_color; } ?>;
}
#<?php echo $id; ?>.widget-oceanwp-social ul li a:hover {
<?php if ( $bg_hover_color ) { echo 'background-color:' . $bg_hover_color; } ?>;
<?php if ( $color_hover ) { echo 'color:' . $color_hover .'!important'; } ?>;
<?php if ( $border_hover_color ) { echo 'border-color:' . $border_hover_color .'!important'; } ?>;
}
</style>
<?php endif; ?>
<?php
}
}
}
register_widget( 'Ocean_Extra_Social_Widget' );
@@ -0,0 +1,388 @@
<?php
/**
* Tags widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Tags_Widget' ) ) {
class Ocean_Extra_Tags_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_tags',
esc_html__( '&raquo; Tags Cloud', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-tags tags-widget',
'description' => esc_html__( 'A cloud of your most used tags.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
/**
* Enqueue scripts.
*
* @since 1.3.8
*
* @param string $hook_suffix
*/
public function enqueue_scripts( $hook_suffix ) {
if ( 'widgets.php' !== $hook_suffix ) {
return;
}
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'underscore' );
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$padding = isset( $instance['padding'] ) ? $instance['padding'] : '';
$bg_color = isset( $instance['bg_color'] ) ? $instance['bg_color'] : '';
$bg_hover_color = isset( $instance['bg_hover_color'] ) ? $instance['bg_hover_color'] : '';
$link_color = isset( $instance['link_color'] ) ? $instance['link_color'] : '';
$link_hover_color = isset( $instance['link_hover_color'] ) ? $instance['link_hover_color'] : '';
$border_color = isset( $instance['border_color'] ) ? $instance['border_color'] : '';
$border_hover_color = isset( $instance['border_hover_color'] ) ? $instance['border_hover_color'] : '';
$font_size = isset( $instance['font_size'] ) ? $instance['font_size'] : '';
$line_height = isset( $instance['line_height'] ) ? $instance['line_height'] : '';
$letter_spacing = isset( $instance['letter_spacing'] ) ? $instance['letter_spacing'] : '';
$text_transform = isset( $instance['text_transform'] ) ? $instance['text_transform'] : '';
$current_taxonomy = $this->_get_current_taxonomy( $instance );
if ( ! empty( $instance['title'] ) ) {
$title = $instance['title'];
} else {
if ( 'post_tag' == $current_taxonomy ) {
$title = esc_html__( 'Tags', 'oceanwp' );
} else {
$tax = get_taxonomy($current_taxonomy);
$title = $tax->labels->name;
}
}
/**
* Filters the taxonomy used in the Tag Cloud widget.
*
* @since 2.8.0
* @since 3.0.0 Added taxonomy drop-down.
*
* @see wp_tag_cloud()
*
* @param array $args Args used for the tag cloud widget.
*/
$tag_cloud = wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array(
'taxonomy' => $current_taxonomy,
'echo' => false
) ) );
if ( empty( $tag_cloud ) ) {
return;
}
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
// Before widget WP hook
echo $args['before_widget'];
// Style
if ( $padding && '8px 12px' != $padding
|| $bg_color && '#f8f8f8' != $bg_color
|| $bg_hover_color && '#f1f1f1' != $bg_hover_color
|| $link_color && '#333' != $link_color
|| $link_hover_color && '#333' != $link_hover_color
|| $border_color && '#e9e9e9' != $border_color
|| $link_hover_color && '#333' != $link_hover_color
|| $font_size && '12' != $font_size
|| $line_height && '12' != $line_height
|| $letter_spacing && '0.4' != $letter_spacing
|| $text_transform && 'default' != $text_transform ) {
echo '<style type="text/css">';
if ( $padding && '8px 12px' != $padding
|| $bg_color && '#f8f8f8' != $bg_color
|| $link_color && '#333' != $link_color
|| $border_color && '#e9e9e9' != $border_color
|| $font_size && '12' != $font_size
|| $line_height && '12' != $line_height
|| $letter_spacing && '0.4' != $letter_spacing
|| $text_transform && 'default' != $text_transform ) {
echo '.' . esc_attr( $this->id ) . '.tagcloud a{';
if ( $padding && '8px 12px' != $padding ) {
echo 'padding:' . esc_attr( $padding ) . ';';
}
if ( $bg_color && '#f8f8f8' != $bg_color ) {
echo 'background-color:' . esc_attr( $bg_color ) . ';';
}
if ( $link_color && '#333' != $link_color ) {
echo 'color:' . esc_attr( $link_color ) . ';';
}
if ( $border_color && '#e9e9e9' != $border_color ) {
echo 'border-color:' . esc_attr( $border_color ) . ';';
}
if ( $font_size && '12' != $font_size ) {
echo 'font-size:' . esc_attr( $font_size ) . 'px!important;';
}
if ( $line_height && '12' != $line_height ) {
echo 'line-height:' . esc_attr( $line_height ) . 'px;';
}
if ( $letter_spacing && '0.4' != $letter_spacing ) {
echo 'letter-spacing:' . esc_attr( $letter_spacing ) . 'px;';
}
if ( $text_transform && 'default' != $text_transform ) {
echo 'text-transform:' . esc_attr( $text_transform ) . ';';
}
echo '}';
}
if ( $bg_hover_color && '#f1f1f1' != $bg_hover_color
|| $link_hover_color && '#333' != $link_hover_color
|| $border_hover_color && '#ddd' != $border_hover_color ) {
echo '.' . esc_attr( $this->id ) . '.tagcloud a:hover{';
if ( $bg_hover_color && '#f1f1f1' != $bg_hover_color ) {
echo 'background-color:' . esc_attr( $bg_hover_color ) . ';';
}
if ( $link_hover_color && '#333' != $link_hover_color ) {
echo 'color:' . esc_attr( $link_hover_color ) . ';';
}
if ( $border_hover_color && '#ddd' != $border_hover_color ) {
echo 'border-color:' . esc_attr( $border_hover_color ) . ';';
}
echo '}';
}
echo '</style>';
}
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo '<div class="tagcloud '. esc_attr( $this->id ) .'">';
echo $tag_cloud;
echo "</div>\n";
// 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 = array();
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['taxonomy'] = stripslashes( $new_instance['taxonomy'] );
$instance['padding'] = strip_tags( $new_instance['padding'] );
$instance['bg_color'] = sanitize_hex_color( $new_instance['bg_color'] );
$instance['bg_hover_color'] = sanitize_hex_color( $new_instance['bg_hover_color'] );
$instance['link_color'] = sanitize_hex_color( $new_instance['link_color'] );
$instance['link_hover_color'] = sanitize_hex_color( $new_instance['link_hover_color'] );
$instance['border_color'] = sanitize_hex_color( $new_instance['border_color'] );
$instance['border_hover_color'] = sanitize_hex_color( $new_instance['border_hover_color'] );
$instance['font_size'] = strip_tags( $new_instance['font_size'] );
$instance['line_height'] = strip_tags( $new_instance['line_height'] );
$instance['letter_spacing'] = strip_tags( $new_instance['letter_spacing'] );
$instance['text_transform'] = strip_tags( $new_instance['text_transform'] );
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 ) {
$instance = wp_parse_args( ( array ) $instance, array(
'title' => '',
'padding' => '',
'bg_color' => '#f8f8f8',
'bg_hover_color' => '#f1f1f1',
'link_color' => '#333',
'link_hover_color' => '#333',
'border_color' => '#e9e9e9',
'border_hover_color' => '#ddd',
'font_size' => '12',
'line_height' => '12',
'letter_spacing' => '0.4',
'text_transform' => 'default',
) );
$current_taxonomy = $this->_get_current_taxonomy($instance);
$taxonomies = get_taxonomies( array( 'show_tagcloud' => true ), 'object' );
$id = $this->get_field_id( 'taxonomy' );
$name = $this->get_field_name( 'taxonomy' );
$input = '<input type="hidden" id="' . $id . '" name="' . $name . '" value="%s" />'; ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<?php
switch ( count( $taxonomies ) ) {
// No tag cloud supporting taxonomies found, display error message
case 0:
echo '<p>' . esc_html__( 'The tag cloud will not be displayed since there are no taxonomies that support the tag cloud widget.', 'ocean-extra' ) . '</p>';
printf( $input, '' );
break;
// Just a single tag cloud supporting taxonomy found, no need to display options
case 1:
$keys = array_keys( $taxonomies );
$taxonomy = reset( $keys );
printf( $input, esc_attr( $taxonomy ) );
break;
// More than one tag cloud supporting taxonomy found, display options
default:
printf(
'<p><label for="%1$s">%2$s</label>' .
'<select class="widefat" id="%1$s" name="%3$s">',
$id,
esc_html__( 'Taxonomy:', 'ocean-extra' ),
$name
);
foreach ( $taxonomies as $taxonomy => $tax ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $taxonomy ),
selected( $taxonomy, $current_taxonomy, false ),
$tax->labels->name
);
}
echo '</select></p>';
} ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'padding' ) ); ?>"><?php esc_html_e( 'Padding:', 'ocean-extra' ); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr( $this->get_field_id( 'padding' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'padding' ) ); ?>" value="<?php echo esc_attr( $instance['padding'] ); ?>" />
<small style="color: #777;"><?php esc_html_e( 'top left bottom right, eg: 15px 8px 15px 25px', 'ocean-extra' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>"><?php esc_html_e( 'Background Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'bg_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'bg_color' ) ); ?>" value="<?php echo esc_attr( $instance['bg_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'bg_hover_color' ) ); ?>"><?php esc_html_e( 'Background Hover Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'bg_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'bg_hover_color' ) ); ?>" value="<?php echo esc_attr( $instance['bg_hover_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'link_color' ) ); ?>"><?php esc_html_e( 'Link Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'link_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'link_color' ) ); ?>" value="<?php echo esc_attr( $instance['link_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'link_hover_color' ) ); ?>"><?php esc_html_e( 'Link Hover Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'link_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'link_hover_color' ) ); ?>" value="<?php echo esc_attr( $instance['link_hover_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>"><?php esc_html_e( 'Border Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'border_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_color' ) ); ?>" value="<?php echo esc_attr( $instance['border_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'border_hover_color' ) ); ?>"><?php esc_html_e( 'Border Hover Color:', 'ocean-extra' ); ?></label>
<input class="color-picker" type="text" id="<?php echo esc_attr( $this->get_field_id( 'border_hover_color' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'border_hover_color' ) ); ?>" value="<?php echo esc_attr( $instance['border_hover_color'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>"><?php esc_html_e( 'Font Size (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="5" max="50" step="1" id="<?php echo esc_attr( $this->get_field_id( 'font_size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'font_size' ) ); ?>" value="<?php echo esc_attr( $instance['font_size'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'line_height' ) ); ?>"><?php esc_html_e( 'Line Height (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="5" max="200" step="1" id="<?php echo esc_attr( $this->get_field_id( 'line_height' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'line_height' ) ); ?>" value="<?php echo esc_attr( $instance['line_height'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'letter_spacing' ) ); ?>"><?php esc_html_e( 'Letter Spacing (px):', 'ocean-extra' ); ?></label>
<input class="widefat" type="number" min="0" max="5" step="0.1" id="<?php echo esc_attr( $this->get_field_id( 'letter_spacing' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'letter_spacing' ) ); ?>" value="<?php echo esc_attr( $instance['letter_spacing'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id('text_transform') ); ?>"><?php esc_html_e( 'Text Transform:', 'ocean-extra' ); ?></label>
<select class="widget-select widefat" name="<?php echo esc_attr( $this->get_field_name('text_transform') ); ?>" id="<?php echo esc_attr( $this->get_field_id('position') ); ?>">
<option value="default" <?php selected( $instance['text_transform'], 'default' ) ?>><?php esc_html_e( 'Default', 'ocean-extra' ); ?></option>
<option value="capitalize" <?php selected( $instance['text_transform'], 'capitalize' ) ?>><?php esc_html_e( 'Capitalize', 'ocean-extra' ); ?></option>
<option value="lowercase" <?php selected( $instance['text_transform'], 'lowercase' ) ?>><?php esc_html_e( 'Lowercase', 'ocean-extra' ); ?></option>
<option value="uppercase" <?php selected( $instance['text_transform'], 'uppercase' ) ?>><?php esc_html_e( 'Uppercase', 'ocean-extra' ); ?></option>
<option value="none" <?php selected( $instance['text_transform'], 'none' ) ?>><?php esc_html_e( 'None', 'ocean-extra' ); ?></option>
</select>
</p>
<?php
}
/**
* Retrieves the taxonomy for the current Tag cloud widget instance.
*
* @since 4.4.0
* @access public
*
* @param array $instance Current settings.
* @return string Name of the current taxonomy if set, otherwise 'post_tag'.
*/
public function _get_current_taxonomy($instance) {
if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
return $instance['taxonomy'];
return 'post_tag';
}
}
}
register_widget( 'Ocean_Extra_Tags_Widget' );
@@ -0,0 +1,243 @@
<?php
/**
* Twitter Widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Twitter_Widget' ) ) {
class Ocean_Extra_Twitter_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
public function __construct() {
parent::__construct(
'ocean_twitter',
esc_html__( '&raquo; Twitter', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-twitter twitter-widget',
'description' => esc_html__( 'Pulls in tweets from your twitter account.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$instance['lang'] = substr( strtoupper( get_locale() ), 0, 2 );
echo $args['before_widget'];
$title = isset( $instance['title'] ) ? $instance['title'] : '';
$title = apply_filters( 'widget_title', $title );
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
}
// Start tag output
// This tag is transformed into the widget markup by Twitter's
echo '<a class="twitter-timeline"';
$data_attribs = array(
'width',
'height',
'theme',
'link-color',
'border-color',
'tweet-limit',
'lang'
);
foreach ( $data_attribs as $att ) {
if ( ! empty( $instance[ $att ] ) && ! is_array( $instance[ $att ] ) ) {
echo ' data-' . esc_attr( $att ) . '="' . esc_attr( $instance[ $att ] ) . '"';
}
}
if ( ! empty( $instance['chrome'] ) && is_array( $instance['chrome'] ) ) {
echo ' data-chrome="' . esc_attr( join( ' ', $instance['chrome'] ) ) . '"';
}
if ( $instance['username'] ) {
echo ' href="https://twitter.com/' . esc_attr( $instance['username'] ) . '"';
}
// End tag output
echo '><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>' . esc_html__( 'My Tweets', 'ocean-extra' ) . '</a>';
// End tag output
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 ) {
$instance = array();
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$width = (int) $new_instance['width'];
if ( $width ) {
// From publish.twitter.com: 220 <= width <= 1200
$instance['width'] = min( max( $width, 220 ), 1200 );
} else {
$instance['width'] = '';
}
$height = (int) $new_instance['height'];
if ( $height ) {
// From publish.twitter.com: height >= 200
$instance['height'] = max( $height, 200 );
} else {
$instance['height'] = '';
}
$tweet_limit = (int) $new_instance['tweet-limit'];
if ( $tweet_limit ) {
$instance['tweet-limit'] = min( max( $tweet_limit, 1 ), 20 );
/**
* A timeline with a specified limit is expanded to the height of those Tweets.
* The specified height value no longer applies, so reject the height value
* when a valid limit is set: a widget attempting to save both limit 5 and
* height 400 would be saved with just limit 5.
*/
$instance['height'] = '';
} else {
$instance['tweet-limit'] = null;
}
$instance['username'] = sanitize_text_field( $new_instance['username'] );
$hex_regex = '/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\b/';
foreach ( array( 'link-color', 'border-color' ) as $color ) {
$new_color = sanitize_text_field( $new_instance[ $color ] );
if ( preg_match( $hex_regex, $new_color ) ) {
$instance[ $color ] = $new_color;
}
}
$instance['theme'] = 'light';
if ( in_array( $new_instance['theme'], array( 'light', 'dark' ) ) ) {
$instance['theme'] = $new_instance['theme'];
}
$instance['chrome'] = array();
$chrome_settings = array(
'noheader',
'nofooter',
'noborders',
'transparent',
'noscrollbar',
);
if ( isset( $new_instance['chrome'] ) ) {
foreach ( $new_instance['chrome'] as $chrome ) {
if ( in_array( $chrome, $chrome_settings ) ) {
$instance['chrome'][] = $chrome;
}
}
}
return $instance;
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
$defaults = array(
'title' => esc_html__( 'Follow me on Twitter', 'ocean-extra' ),
'width' => '',
'height' => '400',
'username' => '',
'link-color' => '#f96e5b',
'border-color' => '#e8e8e8',
'theme' => 'light',
'chrome' => array(),
'tweet-limit' => 5,
);
$instance = wp_parse_args( (array) $instance, $defaults );
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'ocean-extra' ); ?></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( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php esc_html_e( 'Width (px):', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" value="<?php echo esc_attr( $instance['width'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'height' ); ?>"><?php esc_html_e( 'Height (px):', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" type="text" value="<?php echo esc_attr( $instance['height'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'tweet-limit' ); ?>"><?php esc_html_e( '# of Tweets Shown:', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tweet-limit' ); ?>" name="<?php echo $this->get_field_name( 'tweet-limit' ); ?>" type="number" min="1" max="20" value="<?php echo esc_attr( $instance['tweet-limit'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php esc_html_e( 'Username:', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" type="text" value="<?php echo esc_attr( $instance['username'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>"><?php esc_html_e( 'Layout Options:', 'ocean-extra' ); ?></label><br />
<input type="checkbox"<?php checked( in_array( 'noheader', $instance['chrome'] ) ); ?> id="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>" name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" value="noheader" /> <label for="<?php echo $this->get_field_id( 'chrome-noheader' ); ?>"><?php esc_html_e( 'No Header', 'ocean-extra' ); ?></label><br />
<input type="checkbox"<?php checked( in_array( 'nofooter', $instance['chrome'] ) ); ?> id="<?php echo $this->get_field_id( 'chrome-nofooter' ); ?>" name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" value="nofooter" /> <label for="<?php echo $this->get_field_id( 'chrome-nofooter' ); ?>"><?php esc_html_e( 'No Footer', 'ocean-extra' ); ?></label><br />
<input type="checkbox"<?php checked( in_array( 'noborders', $instance['chrome'] ) ); ?> id="<?php echo $this->get_field_id( 'chrome-noborders' ); ?>" name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" value="noborders" /> <label for="<?php echo $this->get_field_id( 'chrome-noborders' ); ?>"><?php esc_html_e( 'No Borders', 'ocean-extra' ); ?></label><br />
<input type="checkbox"<?php checked( in_array( 'noscrollbar', $instance['chrome'] ) ); ?> id="<?php echo $this->get_field_id( 'chrome-noscrollbar' ); ?>" name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" value="noscrollbar" /> <label for="<?php echo $this->get_field_id( 'chrome-noscrollbar' ); ?>"><?php esc_html_e( 'No Scrollbar', 'ocean-extra' ); ?></label><br />
<input type="checkbox"<?php checked( in_array( 'transparent', $instance['chrome'] ) ); ?> id="<?php echo $this->get_field_id( 'chrome-transparent' ); ?>" name="<?php echo $this->get_field_name( 'chrome' ); ?>[]" value="transparent" /> <label for="<?php echo $this->get_field_id( 'chrome-transparent' ); ?>"><?php esc_html_e( 'Transparent Background', 'ocean-extra' ); ?></label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'link-color' ); ?>"><?php esc_html_e( 'Link Color (hex):', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'link-color' ); ?>" name="<?php echo $this->get_field_name( 'link-color' ); ?>" type="text" value="<?php echo esc_attr( $instance['link-color'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'border-color' ); ?>"><?php esc_html_e( 'Border Color (hex):', 'ocean-extra' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'border-color' ); ?>" name="<?php echo $this->get_field_name( 'border-color' ); ?>" type="text" value="<?php echo esc_attr( $instance['border-color'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'theme' ); ?>"><?php esc_html_e( 'Timeline Theme:', 'ocean-extra' ); ?></label>
<select name="<?php echo $this->get_field_name( 'theme' ); ?>" id="<?php echo $this->get_field_id( 'theme' ); ?>" class="widefat">
<option value="light"<?php selected( $instance['theme'], 'light' ); ?>><?php esc_html_e( 'Light', 'ocean-extra' ); ?></option>
<option value="dark"<?php selected( $instance['theme'], 'dark' ); ?>><?php esc_html_e( 'Dark', 'ocean-extra' ); ?></option>
</select>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Twitter_Widget' );
@@ -0,0 +1,136 @@
<?php
/**
* Video widget.
*
* @package OceanWP WordPress theme
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Ocean_Extra_Video_Widget' ) ) {
class Ocean_Extra_Video_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
'ocean_video',
esc_html__( '&raquo; Video', 'ocean-extra' ),
array(
'classname' => 'widget-oceanwp-video video-widget',
'description' => esc_html__( 'Easily to display any type of video.', 'ocean-extra' ),
'customize_selective_refresh' => true,
)
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
* @since 1.0.0
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$video_url = isset( $instance['video_url'] ) ? $instance['video_url'] : '';
$description = isset( $instance['video_description'] ) ? $instance['video_description'] : '';
// Before widget WP hook
echo $args['before_widget'];
// Show widget title
if ( $title ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
// Show video
if ( $video_url ) {
echo '<p class="responsive-video-wrap clr">';
echo wp_oembed_get( $video_url, array(
'width' => 270
) );
echo '</p>';
} else {
esc_html_e( 'You forgot to enter a video URL.', 'ocean-extra' );
}
// Show video description if field isn't empty
if ( $description ) {
echo '<div class="oceanwp-video-widget-description">'. do_shortcode( $description ) .'</div>';
}
// 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['video_url'] = ! empty( $new_instance['video_url'] ) ? esc_url( $new_instance['video_url'] ) : '';
$instance['video_description'] = ! empty( $new_instance['video_description'] ) ? strip_tags( $new_instance['video_description'] ) : '';
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__( 'Video', 'ocean-extra' ),
'video_url' => '',
'video_description' => '',
) ); ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'ocean-extra' ); ?>:</label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'video_url' ) ); ?>">
<?php esc_html_e( 'Video URL ', 'ocean-extra' ); ?></label>
<input class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'video_url' ) ); ?>" type="text" value="<?php echo esc_attr( esc_url( $instance['video_url'] ) ); ?>" />
<span style="display:block;padding:5px 0" class="description"><?php esc_html_e( 'Enter in a video URL that is compatible with WordPress\'s built-in oEmbed feature.', 'ocean-extra' ); ?> <a href="http://codex.wordpress.org/Embeds" target="_blank"><?php esc_html_e( 'Learn More', 'ocean-extra' ); ?></a></span>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'video_description' ) ); ?>"><?php esc_html_e( 'Description', 'ocean-extra' ); ?></label>
<textarea rows="15" id="<?php echo esc_attr( $this->get_field_id( 'video_description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'video_description' ) ); ?>" class="widefat" style="height: 100px;"><?php if( !empty( $instance['video_description'] ) ) { echo esc_textarea( $instance['video_description'] ); } ?></textarea>
</p>
<?php
}
}
}
register_widget( 'Ocean_Extra_Video_Widget' );