null, 'lead' => null, 'bg' => null, 'text' => null, 'image' => null, 'rows' => null, 'slot' => false, 'phone' => null, 'email' => null, 'street' => null, 'city' => null, 'hours' => null, 'values' => array(), ); } /** * Hooks up. * * @return void */ public static function hooks() { add_action( 'init', array( __CLASS__, 'register' ), 20 ); } /** * Registers the group and every section. * * @return void */ public static function register() { if ( ! function_exists( 'register_block_pattern' ) ) { return; } if ( function_exists( 'register_block_pattern_category' ) ) { register_block_pattern_category( self::CATEGORY, array( 'label' => __( '2ranq Forms', '2ranq-forms' ) ) ); } foreach ( self::all() as $key => $pattern ) { register_block_pattern( '2ranq-forms/' . $key, array( 'title' => $pattern['title'], 'description' => $pattern['description'], 'categories' => array( self::CATEGORY ), 'keywords' => array( 'contact', 'form', '2ranq' ), 'content' => $pattern['content'], ) ); } } /** * The company details, out of the settings. * * @return array */ private static function details() { $saved = get_option( 'ranq_forms_company', array() ); $saved = is_array( $saved ) ? $saved : array(); $filled = array(); foreach ( $saved as $key => $value ) { if ( is_string( $value ) && '' !== trim( $value ) ) { $filled[ $key ] = $value; } } // The order matters. The trade details come first, because they are what makes // the example look like a real place. Over them go the details the site owner // typed in, because those are their true ones. That way the example is full // before the owner enters anything, and the moment they do, theirs wins. $base = array( 'name' => get_bloginfo( 'name' ), 'street' => __( '1200 Market Street, Suite 400', '2ranq-forms' ), 'city' => __( 'San Francisco, CA 94103', '2ranq-forms' ), 'phone' => '(415) 555-0134', 'email' => (string) get_option( 'admin_email' ), 'hours' => __( 'Monday to Friday, 9am to 5pm', '2ranq-forms' ), ); foreach ( array( 'name', 'street', 'city', 'phone', 'email', 'hours' ) as $key ) { if ( isset( self::$biz[ $key ] ) && '' !== self::$biz[ $key ] ) { $base[ $key ] = self::$biz[ $key ]; } } $out = array_merge( $base, $filled ); // What is typed into the widget itself beats both the trade and the global // ones, because it is closest to what a person is looking at right now. foreach ( array( 'phone', 'email', 'street', 'city', 'hours' ) as $key ) { if ( isset( self::$opts[ $key ] ) && is_string( self::$opts[ $key ] ) && '' !== self::$opts[ $key ] ) { $out[ $key ] = self::$opts[ $key ]; } } return $out; } /** * The phone number in a shape that can be dialled with a tap. * * @param string $phone The number as it is written. * * @return string */ /** * The custom properties, out of what a person changed. * * ONLY what differs from the default is printed, so the record is short or * not there at all. The defaults sit in the style sheet, once. * * @param string $layout The pattern key. * * @return string */ private static function css_vars( $layout ) { $vrednosti = self::$opts['values']; if ( ! is_array( $vrednosti ) || ! $vrednosti ) { return ''; } $opis = Ranq_Forms_Widget::controls_for( $layout ); $out = ''; foreach ( $vrednosti as $kljuc => $vrednost ) { if ( ! isset( $opis[ $kljuc ]['var'] ) ) { continue; } $jedinica = isset( $opis[ $kljuc ]['unit'] ) ? $opis[ $kljuc ]['unit'] : ''; if ( ! $jedinica && 'size' === $opis[ $kljuc ]['type'] ) { $jedinica = 'px'; } $out .= '--' . $opis[ $kljuc ]['var'] . ':' . $vrednost . $jedinica . ';'; } return $out; } /** * One value a person changed, or the default. * * @param string $kljuc The key. * @param string $inace What to use when it was not changed. * * @return string */ private static function val( $kljuc, $inace ) { $v = self::$opts['values']; return ( is_array( $v ) && isset( $v[ $kljuc ] ) && '' !== $v[ $kljuc ] ) ? (string) $v[ $kljuc ] : $inace; } private static function mail_link( $email, $style = '' ) { $email = (string) $email; // An incomplete address is printed as plain text. A link to "milos@" leads // nowhere, and a visitor would click it. if ( ! is_email( $email ) ) { return '' . esc_html( $email ) . ''; } return '' . esc_html( $email ) . ''; } private static function tel( $phone ) { return 'tel:' . preg_replace( '/[^0-9+]/', '', $phone ); } /** * An icon as an image embedded in the address itself. * * Why this way and not as a file: the icon then costs no extra request to the * server, it cannot go missing, and a person can still swap it for their own, * because it is an ordinary image in the page. * * @param string $path The drawing path. * @param string $color The colour. * * @return string */ private static function icon( $path, $color = '#5b4be0', $width = '1.6' ) { $svg = '' . $path . ''; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- this is not code hiding, it is an image embedded in an address. return 'data:image/svg+xml;base64,' . base64_encode( $svg ); } /** * The icon drawings. * * @return array */ private static function shapes() { return array( 'car' => '', 'plane' => '', 'phone' => '', 'pin' => '', 'mail' => '', 'clock' => '', 'check' => '', 'chat' => '', ); } /** * One row of detail: an icon and then the text. * * @param string $shape The drawing key. * @param string $title The label. * @param string $value The value, which may be a link. * @param string $color The icon colour. * @param bool $light Whether the text is light. * * @return string */ private static function row( $shape, $title, $value, $color = '#5b4be0', $light = false ) { $shapes = self::shapes(); $icon = self::icon( isset( $shapes[ $shape ] ) ? $shapes[ $shape ] : $shapes['pin'], $color ); $attr = $light ? ' {"style":{"color":{"text":"#ffffff"}}}' : ''; $class = $light ? ' class="has-text-color" style="color:#ffffff"' : ''; // `isStackedOnMobile` set to false is REQUIRED. Without it WordPress drops the // icon into a row of its own above the text on a phone, and the row of detail // looks broken. Checked at a width of 390. return '' . '
' . '' . '
' . '' . '
' . '' . '
' . '' . '
' . '' . '' . esc_html( $title ) . '
' . $value . '

' . '' . '
' . '
'; } /** * Our form as a block. The form is chosen after inserting. * * @return string */ private static function form_block() { // In the live preview an empty slot goes where the form is, so the builder can // drop the REAL form a person is assembling into it. That way the card shows // both the section and the form, and every change lands inside at once. if ( self::$opts['slot'] ) { return '
'; } return ''; } /** * A place for the image, with an instruction instead of an empty hole. * * @param string $radius The corner radius. * * @return string */ private static function image_block( $radius = '14px', $class = '' ) { // An image MUST have a source. An `` with no source draws nothing, so a // hole would be left where the image goes and nobody would know it goes there. // // A scene is drawn, not a camera icon. The icon looked like a broken image, // so the whole section felt unfinished before a person even got round to // putting their own in. $svg = '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . ''; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- an image embedded in an address, not code hiding. $src = 'data:image/svg+xml;base64,' . base64_encode( $svg ); // The trade photograph, when it has arrived in `assets/img/`. While it has // not, the drawn scene stays, so the section works without a single photo. if ( isset( self::$biz['photo'] ) && '' !== self::$biz['photo'] ) { $photo = Ranq_Forms_Business::photo( self::$biz['photo'] ); if ( $photo ) { $src = esc_url( $photo ); } } // Your own image goes through `esc_url`. The embedded thumbnail must not, // because `esc_url` does not let `data:` through and the address would be empty. if ( is_string( self::$opts['image'] ) && '' !== self::$opts['image'] ) { $src = esc_url( self::$opts['image'] ); } // The width at a hundred percent: without it the image sits at its natural // size and stays smaller than the column, so the layout looks crooked. return '' . '
' . '' . esc_attr__( 'Click to replace with a photo of your shop, office or team', '2ranq-forms' ) . '' . '
'; } /* ------------------------------------------------------------------ Six families of layout The half and half split was measured, not chosen: ten out of twelve of our sites that split a section in two use a split between 47 and 55 percent. ------------------------------------------------------------------ */ /** * 2ranq.com, taken value by value. * * @param array $b The trade. * @param array $d The details. * * @return string */ private static function exact_2ranq( $b, $d ) { // The rows come from the SAME list as every other section, only in the look // taken from 2ranq. Were they hard coded here, the "which details are shown" // switches would not work on this section, and nobody would know why. $redovi = array( 'mail' => array( __( 'Email', '2ranq-forms' ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '', esc_html( $d['email'] ) ), 'phone' => array( __( 'Phone', '2ranq-forms' ), esc_url( self::tel( $d['phone'] ) ), esc_html( $d['phone'] ) ), 'pin' => array( __( 'Address', '2ranq-forms' ), '', esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ) ), 'clock' => array( __( 'Open', '2ranq-forms' ), '', esc_html( $d['hours'] ) ), ); $wanted = self::$opts['rows']; $mark = self::$opts['slot']; // A table with rules. The label is 112 pixels wide, 12/400, uppercase, letter // spacing 1.5. The value 16/500. A 1 pixel #2b2b2b rule above every row and // under the last one. Spacing 16 above and below. All read off the site. $tabela = '
'; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $vrednost = $r[1] ? '' . $r[2] . '' : '' . $r[2] . ''; $tabela .= '
' . '' . esc_html( $r[0] ) . '' . $vrednost . '
'; } $tabela .= '
'; // The `data-ranq-part` markers are REQUIRED, otherwise the live preview in the // builder does not know what to change while a person types a heading and text. $left = '' . '

// ' . esc_html( self::val( 'eyebrow_text', __( 'Contact', '2ranq-forms' ) ) ) . '

' . '

' . esc_html( $b['heading'] ) . '

' . '

' . esc_html( $b['lead'] ) . '

' . $tabela . ''; $right = '
' . self::form_block() . '
' . '

' . esc_html( self::val( 'fine_text', __( 'We answer within one working day.', '2ranq-forms' ) ) ) . '

'; // A 715 to 585 split out of 1300, read off the site. // The `wrap` marker is REQUIRED, otherwise a colour change in the side panel // has nothing to take hold of and the preview does not change. $vars = self::css_vars( 'site-2ranq' ); return '' . '
' . '
' . '
' . $left . '
' . '
' . $right . '
' . '
' . '
'; } /** * transfergaja.rs, taken value by value. * * @param array $b The pattern. * @param array $d The details. * * @return string */ private static function exact_gaja( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); // The icons are line drawings and large, 50 pixels, in the accent colour. A // thinner line than usual, because the original uses thin drawings. $boja = self::val( 'icon', '#f8b54a' ); $redovi = array( 'phone' => array( 'phone', __( 'Call us', '2ranq-forms' ), esc_url( self::tel( $d['phone'] ) ), esc_html( $d['phone'] ), ), 'mail' => array( 'mail', __( 'Send us an email', '2ranq-forms' ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '', esc_html( $d['email'] ), ), 'pin' => array( 'pin', __( 'Where we are', '2ranq-forms' ), '', esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), ), 'clock' => array( 'clock', __( 'When we work', '2ranq-forms' ), '', esc_html( $d['hours'] ), ), ); $wanted = self::$opts['rows']; $levo = '
'; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $ikona = self::icon( $shapes[ $r[0] ], $boja, '1.2' ); $naslov = $r[2] ? '' . esc_html( $r[1] ) . '' : '' . esc_html( $r[1] ) . ''; $levo .= '
' . '' . '
' . $naslov . '' . $r[3] . '
' . '
'; } $levo .= '
'; $desno = '

' . esc_html( self::val( 'eyebrow_text', __( 'Contact', '2ranq-forms' ) ) ) . '

' . '

' . esc_html( $b['heading'] ) . '

' . '

' . esc_html( $b['lead'] ) . '

'; $vars = self::css_vars( 'site-gaja' ); return '' . '
' . '
' . '
' . $levo . '
' . '
' . $desno . '' . self::form_block() . '
' . '
' . '
'; } /** * The booking card, taken from transfergaja.rs. * * Unlike the other sections, there is no column of details here. The whole * card is the form, because that is what the original does: a person comes to * book a ride, not to read an address. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_gaja_book( $b, $d ) { unset( $d ); $mark = self::$opts['slot']; $shapes = self::shapes(); $oblik = self::val( 'badge_shape', 'car' ); $ikona = isset( $shapes[ $oblik ] ) ? $shapes[ $oblik ] : $shapes['car']; $zaglavlje = '
' . '' . '' . '' . '' . '' . esc_html( $b['heading'] ) . '' . '' . esc_html( $b['lead'] ) . '' . '' . '
'; $vars = self::css_vars( 'site-gaja-book' ); return '' . '
' . '
' . '' . $zaglavlje . '' . '
' . self::form_block() . '
' . '
' . '
'; } /** * The section taken from mitaleks.rs. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_mitaleks( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#4a9a4f' ); $redovi = array( 'pin' => array( 'pin', esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'phone' => array( 'phone', esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'mail' => array( 'mail', esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'clock' => array( 'clock', esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $tekst = $r[2] ? '' . $r[1] . '' : '' . $r[1] . ''; $spisak .= '
  • ' . '' . $tekst . '
  • '; } $levo = '

    ' . esc_html( $b['heading'] ) . '

    ' . '

    ' . esc_html( $b['lead'] ) . '

    ' . '' . '

    ' . esc_html( $b['name'] ) . '

    ' . '
      ' . $spisak . '
    '; $vars = self::css_vars( 'site-mitaleks' ); return '' . '
    ' . '
    ' . '
    ' . $levo . '
    ' . '
    ' . self::form_block() . '
    ' . '
    ' . '
    '; } /** * The section taken from ortopedijauna.rs. * * No columns. One strong sentence across the full width, then the form on a * white card in the middle. That is what the original does. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_una( $b, $d ) { $mark = self::$opts['slot']; $veza = '' . esc_html( self::val( 'call_text', __( 'give us a call', '2ranq-forms' ) ) ) . ''; $gore = '

    ' . '' . esc_html( $b['heading'] ) . ' ' . $veza . '

    '; $vars = self::css_vars( 'site-una' ); return '' . '
    ' . '
    ' . '' . $gore . '' . '
    ' . self::form_block() . '
    ' . '
    ' . '
    '; } /** * The section taken from mary-jana.com. * * Both columns have a heading of their own, and next to the heading runs a * thin line all the way to the end of the column. The details are in a two by * two grid, because that is how the original arranges them. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_maryjana( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#875e41' ); $redovi = array( 'phone' => array( 'phone', __( 'Phone', '2ranq-forms' ), esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'mail' => array( 'mail', __( 'Email', '2ranq-forms' ), esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'pin' => array( 'pin', __( 'Address', '2ranq-forms' ), esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'clock' => array( 'clock', __( 'Open', '2ranq-forms' ), esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $mreza = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $vrednost = $r[3] ? '' . $r[2] . '' : $r[2]; $mreza .= '
    ' . '' . '' . esc_html( $r[1] ) . ' ' . '' . $vrednost . '' . '
    '; } $levo = '

    ' . esc_html( $b['heading'] ) . '

    ' . '
    ' . $mreza . '
    '; $naslovForme = '

    ' . esc_html( self::val( 'form_title', __( 'Send an email', '2ranq-forms' ) ) ) . '

    '; $vars = self::css_vars( 'site-maryjana' ); return '' . '
    ' . '
    ' . '
    ' . $levo . '
    ' . '
    ' . $naslovForme . '' . self::form_block() . '
    ' . '
    ' . '
    '; } /** * The section taken from cryptomenjacnica.com. * * Everything is centred: the heading, one line under it, three buttons for * the phone, WhatsApp and Telegram, then the form below them. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_crypto( $b, $d ) { $mark = self::$opts['slot']; $cifre = preg_replace( '/[^0-9]/', '', $d['phone'] ); $tg = trim( (string) self::val( 'tg_handle', '' ) ); $dugmad = '' . esc_html( self::val( 'call_text', __( 'Call us', '2ranq-forms' ) ) ) . '' . '' . esc_html( self::val( 'wa_text', __( 'WhatsApp', '2ranq-forms' ) ) ) . ''; if ( '' !== $tg ) { $dugmad .= '' . esc_html( self::val( 'tg_text', __( 'Telegram', '2ranq-forms' ) ) ) . ''; } $gore = '

    ' . esc_html( $b['heading'] ) . '

    ' . '

    ' . esc_html( $b['lead'] ) . '

    ' . '
    ' . $dugmad . '
    '; $vars = self::css_vars( 'site-crypto' ); return '' . '
    ' . '
    ' . '' . $gore . '' . '
    ' . self::form_block() . '
    ' . '
    ' . '
    '; } /** * The section taken from sigurnitelefoni.com. * * The image and the details sit together on a grey card, with the form beside * it. The form has no labels, only placeholder text, as in the original. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_sigurni( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#4a81d3' ); $redovi = array( 'pin' => array( 'pin', __( 'Where we are', '2ranq-forms' ), esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'phone' => array( 'phone', __( 'Call, Viber or WhatsApp', '2ranq-forms' ), esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'mail' => array( 'mail', __( 'Email', '2ranq-forms' ), esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'clock' => array( 'clock', __( 'When we work', '2ranq-forms' ), esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $vrednost = $r[3] ? '' . $r[2] . '' : $r[2]; $spisak .= '
    ' . '' . '' . esc_html( $r[1] ) . '' . '' . $vrednost . '' . '
    '; } $slika = self::val( 'image', RANQ_FORMS_URL . 'assets/img/desk-laptop.webp' ); $kartica = '
    ' . '' . '
    ' . $spisak . '
    ' . '
    '; $gore = '

    ' . esc_html( $b['heading'] ) . '

    ' . '

    ' . esc_html( $b['lead'] ) . '

    '; $vars = self::css_vars( 'site-sigurni' ); return '' . '
    ' . '
    ' . '' . $gore . '' . '
    ' . '' . $kartica . '' . '
    ' . self::form_block() . '
    ' . '
    ' . '
    ' . '
    '; } /** * The section taken from fizikalneterapije.rs. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_fizio( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#075aad' ); $redovi = array( 'phone' => array( 'phone', esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'pin' => array( 'pin', esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'mail' => array( 'mail', esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'clock' => array( 'clock', esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $tekst = $r[2] ? '' . $r[1] . '' : '' . $r[1] . ''; $spisak .= '
    ' . '' . $tekst . '
    '; } $slika = self::val( 'image', RANQ_FORMS_URL . 'assets/img/physio-room.webp' ); $desno = '

    ' . esc_html( $b['heading'] ) . '

    ' . '
    ' . $spisak . '
    '; $vars = self::css_vars( 'site-fizio' ); return '' . '
    ' . '
    ' . '
    ' . '' . '
    ' . '
    ' . $desno . '' . self::form_block() . '
    ' . '
    ' . '
    '; } /** * The section taken from belgradehotspot.com. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_hotspot( $b, $d ) { unset( $d ); $mark = self::$opts['slot']; $gore = '

    ' . esc_html( $b['heading'] ) . '

    '; if ( '' !== $b['lead'] ) { $gore .= '

    ' . esc_html( $b['lead'] ) . '

    '; } $vars = self::css_vars( 'site-hotspot' ); return '' . '
    ' . '
    ' . '' . $gore . '' . self::form_block() . '
    ' . '
    '; } /** * The section taken from cvecaranena.rs. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_cvecara( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#c2185b' ); $redovi = array( 'pin' => array( 'pin', __( 'Our address', '2ranq-forms' ), esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'mail' => array( 'mail', __( 'Email', '2ranq-forms' ), esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'phone' => array( 'phone', __( 'Phone', '2ranq-forms' ), esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'clock' => array( 'clock', __( 'Open', '2ranq-forms' ), esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $vrednost = $r[3] ? '' . $r[2] . '' : $r[2]; $spisak .= '
    ' . '' . '' . esc_html( $r[1] ) . '' . '' . $vrednost . '' . '
    '; } $slika = self::val( 'image', RANQ_FORMS_URL . 'assets/img/storefront.webp' ); $gore = '

    ' . esc_html( $b['heading'] ) . '

    ' . '

    ' . esc_html( $b['lead'] ) . '

    '; $karticaGore = '

    ' . esc_html( self::val( 'card_title', __( 'Contact details', '2ranq-forms' ) ) ) . '

    ' . '
    ' . $spisak . '
    '; $vars = self::css_vars( 'site-cvecara' ); return '' . '
    ' . '
    ' . '' . $gore . '' . '
    ' . '' . '
    ' . '' . $karticaGore . '' . self::form_block() . '
    ' . '
    ' . '
    ' . '
    '; } /** * The section taken from medijacijabeograd.com. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_medijacija( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#f88054' ); $redovi = array( 'phone' => array( 'phone', esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'mail' => array( 'mail', esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'pin' => array( 'pin', esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'clock' => array( 'clock', esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $tekst = $r[2] ? '' . $r[1] . '' : '' . $r[1] . ''; $spisak .= '
    ' . '' . $tekst . '
    '; } $slika = self::val( 'image', RANQ_FORMS_URL . 'assets/img/office-reception.webp' ); $sitno = self::val( 'note_text', '' ); $desno = '' . '

    ' . esc_html( $b['name'] ) . '

    '; if ( '' !== $sitno ) { $desno .= '

    ' . esc_html( $sitno ) . '

    '; } $desno .= '
    ' . $spisak . '
    '; $vars = self::css_vars( 'site-medijacija' ); return '' . '
    ' . '
    ' . '
    ' . self::form_block() . '
    ' . '
    ' . $desno . '
    ' . '
    ' . '
    '; } /** * The section taken from fairplay.org.rs. * * @param array $b The trade. * @param array $d The details for display. * * @return string */ private static function exact_fairplay( $b, $d ) { $mark = self::$opts['slot']; $shapes = self::shapes(); $boja = self::val( 'icon', '#ffcc01' ); $redovi = array( 'phone' => array( 'phone', __( 'Phone contact', '2ranq-forms' ), esc_html( $d['phone'] ), esc_url( self::tel( $d['phone'] ) ) ), 'mail' => array( 'mail', __( 'Email', '2ranq-forms' ), esc_html( $d['email'] ), is_email( $d['email'] ) ? 'mailto:' . esc_attr( $d['email'] ) : '' ), 'pin' => array( 'pin', __( 'Office', '2ranq-forms' ), esc_html( $d['street'] ) . ', ' . esc_html( $d['city'] ), '' ), 'clock' => array( 'clock', __( 'Open', '2ranq-forms' ), esc_html( $d['hours'] ), '' ), ); $wanted = self::$opts['rows']; $spisak = ''; foreach ( $redovi as $kljuc => $r ) { if ( is_array( $wanted ) && ! in_array( $kljuc, $wanted, true ) ) { continue; } $vrednost = $r[3] ? '' . $r[2] . '' : $r[2]; $spisak .= '
    ' . '' . '' . '' . esc_html( $r[1] ) . '' . '' . $vrednost . '' . '
    '; } $vars = self::css_vars( 'site-fairplay' ); return '' . '
    ' . '
    ' . '

    ' . esc_html( $b['heading'] ) . '

    ' . '
    ' . '
    ' . $spisak . '
    ' . '
    ' . self::form_block() . '
    ' . '
    ' . '
    ' . '
    '; } /** * Every section. * * Each one is a COPY of one of our own live sites, built by the rules in * `10-PRAVILA-FULL-WIDGET.md`. The old, generic sections were deleted: they * were not copies but approximations, and the plugin carries only what is * genuinely good. * * @param array $args The changes the form owner makes. * * @return array */ public static function all( $args = array() ) { self::$opts = array_merge( self::blank_opts(), is_array( $args ) ? $args : array() ); $out = array(); foreach ( Ranq_Forms_Business::all() as $b ) { self::$biz = $b; $sadrzaj = self::render_one( $b ); if ( '' === $sadrzaj ) { continue; } $out[ $b['key'] ] = array( 'title' => $b['title'], 'description' => $b['description'], 'group' => $b['group'], 'purpose' => isset( $b['purpose'] ) ? $b['purpose'] : 'plain', 'style' => isset( $b['style'] ) ? $b['style'] : '', 'content' => $sadrzaj, ); } self::$biz = array(); /** * Adding sections from modules. * * @param array $patterns The sections. */ return apply_filters( 'ranq_forms_patterns', $out ); } /** * Assembles one section. Empty when the pattern has not been built. * * @param array $b The pattern. * * @return string */ private static function render_one( $b ) { $d = self::details(); switch ( $b['family'] ) { case 'exact-2ranq': return self::exact_2ranq( $b, $d ); case 'exact-gaja': return self::exact_gaja( $b, $d ); case 'exact-gaja-book': return self::exact_gaja_book( $b, $d ); case 'exact-mitaleks': return self::exact_mitaleks( $b, $d ); case 'exact-una': return self::exact_una( $b, $d ); case 'exact-maryjana': return self::exact_maryjana( $b, $d ); case 'exact-crypto': return self::exact_crypto( $b, $d ); case 'exact-sigurni': return self::exact_sigurni( $b, $d ); case 'exact-fizio': return self::exact_fizio( $b, $d ); case 'exact-hotspot': return self::exact_hotspot( $b, $d ); case 'exact-cvecara': return self::exact_cvecara( $b, $d ); case 'exact-medijacija': return self::exact_medijacija( $b, $d ); case 'exact-fairplay': return self::exact_fairplay( $b, $d ); } return ''; } }