true ); if ( isset( $instance['terms_post_id'] ) ) { $options['terms_post_id'] = $instance['terms_post_id']; } echo Affiliates_Registration::render_form( $options, $widget_id ); echo $after_widget; } /** * 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'] ) : ''; ?>

"; echo ''; echo ''; echo '
'; echo '' . __( "Write part of the title or the post ID. If left empty, no terms disclaimer will be shown.", AFFILIATES_PLUGIN_DOMAIN ) . ''; if ( !empty( $terms_post_id ) && ( $post_title = get_the_title( $terms_post_id ) ) ) { echo '
'; echo ' ' . sprintf( __( "Terms page: %s", AFFILIATES_PLUGIN_DOMAIN ) , '' . $post_title . '' ) . ''; } echo '

'; } }// class Affiliates_Registration_Widget ?>