__( '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(); ?>
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 ) . '
' . esc_html( Ranq_Forms_Form_Settings::closed_text( $form_id, $zatvorena ) ) . '