__( 'Next', '2ranq-forms' ), 'back' => __( 'Back', '2ranq-forms' ), 'stepOf' => __( 'Step', '2ranq-forms' ), ) ); } /** * Sends the assets only when this page really has a form on it. * * @return void */ public static function maybe_enqueue() { // 🔴 `self::$enqueued` must NOT stand here as a reason to leave. A theme built // out of blocks renders the page BEFORE the head is printed, so the form gets // to turn its own style on before this check even runs. With the old // condition we would leave through the door and the section style would never // arrive: a section placed as a pattern came out bare on a live page. if ( ! is_singular() ) { return; } $post = get_post(); if ( ! $post instanceof WP_Post ) { return; } // Both shortcode names. The new one starts with a digit, the old one stays forever. $ima_formu = has_shortcode( $post->post_content, '2ranq_form' ) || has_shortcode( $post->post_content, 'ranq_form' ) || has_block( 'ranq/form', $post ); // A section placed as a pattern sits in the content as ordinary blocks, so it // cannot be found by the shortcode or by the block. It is recognised by the // class every one of our sections carries. $ima_sekciju = has_shortcode( $post->post_content, '2ranq_widget' ) || has_shortcode( $post->post_content, 'ranq_widget' ) || false !== strpos( $post->post_content, 'alignfull ranq-' ); if ( $ima_sekciju ) { self::enqueue_sections(); return; } if ( $ima_formu ) { self::enqueue(); } } /** * Queues the assets, once per request. * * @return void */ public static function enqueue() { if ( self::$enqueued ) { return; } wp_enqueue_style( 'ranq-forms' ); wp_enqueue_script( 'ranq-forms' ); self::$enqueued = true; } /** * Sends the section style. * * Called only when a section is really being rendered, from the widget or * from the content of a page our pattern sits in. * * @return void */ public static function enqueue_sections() { self::enqueue(); if ( self::$sections_enqueued ) { return; } wp_enqueue_style( 'ranq-forms-sections' ); self::$sections_enqueued = true; } /** * The small form that asks for a password. * * @param int $form_id The form id. * * @return string */ private static function password_gate( $form_id ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- only a message, no action is carried out. $promasaj = isset( $_POST['ranq_forms_password'] ); $style = Ranq_Forms_Design::inline_style( $form_id ); ob_start(); ?>
style="">
0, ), $atts, '2ranq_form' ); $form_id = absint( $atts['id'] ); if ( ! $form_id ) { return ''; } $form = get_post( $form_id ); if ( ! $form instanceof WP_Post || Ranq_Forms_Post_Type::POST_TYPE !== $form->post_type ) { return ''; } $settings = Ranq_Forms_Form_Settings::get( $form_id ); // The form is closed to guests. In place of the form stands the sentence the // owner wrote, so the visitor knows why they see no fields. if ( $settings['login_only'] && ! is_user_logged_in() ) { $text = '' !== $settings['login_text'] ? $settings['login_text'] : __( 'Please log in to use this form.', '2ranq-forms' ); return '

' . esc_html( $text ) . '

'; } // A closed form: before the date, after the date, or filled to the limit. The // same rule holds on sending, because sending can be reached around the page. $zatvorena = Ranq_Forms_Form_Settings::closed_reason( $form_id ); if ( '' !== $zatvorena && ! Ranq_Forms_Submission::was_sent( $form_id ) ) { self::enqueue(); return '

' . esc_html( Ranq_Forms_Form_Settings::closed_text( $form_id, $zatvorena ) ) . '

'; } // A password protected form. In place of the fields stands one password field. if ( ! Ranq_Forms_Form_Settings::password_ok( $form_id ) ) { self::enqueue(); return self::password_gate( $form_id ); } // After a successful send the fields are taken away, unless the owner asks for // them to stay, for example when a form is filled in several times in a row. $hide_after = Ranq_Forms_Submission::was_sent( $form_id ) && ! $settings['confirm_keep']; // The assets only now, once we know the form really exists. self::enqueue(); // The design travels as custom properties in an attribute, not as a file of its // own. Only what differs from the default is printed, so the attribute is short // or not there at all. $style = Ranq_Forms_Design::inline_style( $form_id ); // A form with a file attached has to use a different way of sending, or the // file never reaches the server. $has_file = false; foreach ( Ranq_Forms_Fields::get_form_fields( $form_id ) as $one ) { if ( isset( $one['type'] ) && 'file' === $one['type'] ) { $has_file = true; break; } } ob_start(); ?>
data-form-id="" style="" >
render( $field, $form_id ); } /** * After the fields. The hook has been there since day one so that * modules can attach without touching the core. * * @param int $form_id The form id. */ do_action( 'ranq_forms_render_fields_after', $form_id ); ?>
$message ) { $lines[] = isset( $labels[ $key ] ) ? $labels[ $key ] . ': ' . $message : $message; } return $lines; } }