esc_html__( 'Easily embed Formstack forms into your sidebar.', 'formstack' ), ), array( 'width' => 200, ) ); } /** * Render our frontend output. * * @since unknown * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { if ( empty( $instance['formkey'] ) ) { return; } list( $form ) = explode( '-', $instance['formkey'] ); $wp = wp_remote_get( "https://www.formstack.com/forms/wp-ad.php?form={$form}" ); $extras = formstack_get_extra_url_params( $instance ); $script_url = add_query_arg( $extras, "https://www.formstack.com/forms/js.php?{$instance['formkey']}" ); $noscript_url = add_query_arg( $extras, "https://www.formstack.com/forms/?{$instance['formkey']}" ); ?>
fields as $i => $field ) { if ( empty( $new_instance[ $field ] ) ) { unset( $instance[ $field ] ); continue; } $instance[ $field ] = 'true'; if ( 'formkey' === $field ) { $instance[ $field ] = strip_tags( $new_instance[ $field ] ); } } return $instance; } /** * Render our admin side widget form. * * @since unknown * * @param array $instance * @return mixed */ public function form( $instance ) { $settings = get_option( 'formstack_settings', '' ); $client_id = ( isset( $settings['client_id'] ) ) ? $settings['client_id'] : ''; $client_secret = ( isset( $settings['client_secret'] ) ) ? $settings['client_secret'] : ''; $oauth_code = get_option( 'formstack_oauth2_code', '' ); if ( empty( $client_id ) || empty ( $client_secret ) || empty ( $oauth_code ) ) { echo $this->no_app_set_up(); return; } if ( $client_id && $client_secret && $oauth_code ) { $formstack_api = new Formstack_API_V2( array( 'client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => admin_url( 'admin.php?page=Formstack' ), 'code' => $oauth_code ) ); } $form_count = $formstack_api->get_form_count(); if ( empty( $form_count ) ) { printf( '' . esc_attr( 'Your account does not appear to have any forms at the moment, please add some at %s or refresh form cache', 'formstack' ) . '
', 'https://www.formstack.com' ); return; } $fields = array(); foreach ( $this->fields as $i => $field ) { $fields[ $field ] = array( 'id' => $this->get_field_id( $field ), 'name' => $this->get_field_name( $field ), 'value' => ( isset( $instance[ $field ] ) ) ? esc_attr( $instance[ $field ] ) : '', ); } ?>esc_html__( 'I do not need jQuery', 'formstack' ), 'nojqueryui' => esc_html__( 'I do not need jQuery UI', 'formstack' ), 'nomodernizr' => esc_html__( 'I do not need Modernizr', 'formstack' ), 'no_style' => esc_html__( 'Use bare-bones-css', 'formstack' ), 'no_style_strict' => esc_html__( 'Use no CSS', 'formstack' ), ); } } /** * Register our widget. * * @since unknown */ function formstack_widget_init() { register_widget( 'Formstack_Widget' ); } add_action( 'widgets_init', 'formstack_widget_init' );