'', /* Normally left out: the connection knows which business this site is connected to and fills it in. It is an attribute at all so that a site connected to one business can still link to another's public form -- an agency's own site pointing at a client's waiver, which is a real thing people do. */ 'business' => '', 'label' => __( 'Sign now', 'signsealer' ), ), $atts, 'signsealer_sign' ); $workflow = sanitize_text_field( $atts['workflow'] ); $business = sanitize_text_field( $atts['business'] ); $c = SignSealer_Connection::get(); $own = isset( $c['slug'] ) ? (string) $c['slug'] : ''; if ( '' === $business ) { $business = $own; } if ( '' === $workflow || '' === $business ) { /* Nothing at all to a visitor, and a note to somebody who can fix it. A shortcode that renders an error on a live page tells a customer about a misconfiguration they cannot act on. */ return current_user_can( 'edit_posts' ) ? '

' . esc_html__( 'SignSealer: this shortcode needs a workflow, and this site to be connected — e.g. [signsealer_sign workflow="kayak-waiver"].', 'signsealer' ) . '

' : ''; } /* `/f//
` -- two segments, not one. The business's own slug is the first, which is why the connection stores it at the moment it is made rather than this file guessing. Built here rather than fetched, because a page render should not wait on somebody else's API: a slow call would make every page carrying this shortcode slow, and the address is derivable. */ $url = SIGNSEALER_API_BASE . '/f/' . rawurlencode( $business ) . '/' . rawurlencode( $workflow ); /* And the "Signed with SignSealer" line, when the site's owner turned it on (1.15.0) -- under a button to this site's own business only. White label was asked about for that business; another's form, an agency linking a client's, may be white label, and gets nothing. */ return sprintf( '%s', esc_attr( SignSealer_Button::classes( 'signsealer-sign-button button wp-element-button' ) ), esc_url( $url ), esc_html( $atts['label'] ) ) . ( $business === $own ? SignSealer_Button::credit() : '' ); } }