true ); if ( isset( $instance['terms_post_id'] ) ) { $options['terms_post_id'] = $instance['terms_post_id']; } echo Affiliates_Registration::render_form( $options ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Save widget options * * @see WP_Widget::update() */ function update( $new_instance, $old_instance ) { $settings = $old_instance; if ( !empty( $new_instance['title'] ) ) { $settings['title'] = strip_tags( $new_instance['title'] ); } else { unset( $settings['title'] ); } if ( !empty( $new_instance['terms_post_id'] ) ) { $terms_post_id = $new_instance['terms_post_id']; if ( $post = get_post( $terms_post_id ) ) { $settings['terms_post_id'] = $post->ID; } else if ( $post = Affiliates_Utility::get_post_by_title( $terms_post_id ) ) { $settings['terms_post_id'] = $post->ID; } else { unset( $settings['terms_post_id'] ); } } return $settings; } /** * Output admin widget options form * * @see WP_Widget::form() */ function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; ?>

'; printf( '', esc_attr__( 'Terms and conditions', 'affiliates' ), esc_attr( $this->get_field_id( 'terms_post_id' ) ), esc_html__( 'Terms Page or Post ID', 'affiliates' ) ); echo ''; echo '
'; echo '' . esc_html__( "Write part of the title or the post ID. If left empty, no terms disclaimer will be shown.", 'affiliates' ) . ''; if ( !empty( $terms_post_id ) && ( $post_title = get_the_title( $terms_post_id ) ) ) { echo '
'; echo ' '; printf( /* translators: link */ esc_html__( 'Terms page: %s', 'affiliates' ) , '' . esc_html( $post_title ) . '' ); echo ''; } echo '

'; } }// class Affiliates_Registration_Widget