'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 = ''. esc_html__( 'Opens in a new tab', 'ocean-extra' ) .''; $results = ocean_link_rel( $ocean_srt, $nofollow, $target ); $ocean_sr = $results[0]; $link_rel = $results[1]; // Display custom links. echo ''; // 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] : ''; } ?>