Custom fields and uk-switcher doesn't work


I had problem with uk-switcher. Everythingh works fine on my local machine, but when I upload files to server - it's not. And by this I mean, that fields are visible on page when editing, but after save i see empty markup (without output).

I made second test - use some fields in other sections, and they works fine.

Below code for register metaboxes (which work):

add_action( 'admin_init', 'register_section5' );
function register_section5() {
    $fields = array(
        array(
            'id' => 'section5_checkbox',
            'label' => 'Wyświetlaj sekcję 5 (Dane kontaktowe)',
            'type' => 'checkbox',
            'default' => true
        ),
        array(
          'id' => 'section5_main_header',
          'label' => 'Nagłowek sekcji',
          'type' => 'text',
          'description' => 'Pozostaw pole puste, a nagłówek nie będzie wyświetlany.'
        ),
        array(
          'id' => 'section5_main_text',
          'label' => 'Tekst główny sekcji',
          'type' => 'textarea',
          'description' => 'Pozostaw pole puste, a tekst nie będzie wyświetlany.'
        ),
        array(
            'id' => 'section5_tab1',
            'label' => 'Pierwsza zakładka',
            'type' => 'group',
            'db_group' => bool,
            'fields' => array(
                array(
                    'id' => 'section5_header_1',
                    'label' => 'Nazwa pierwszej zakładki',
                    'type' => 'text'
                ),
                array(
                    'id' => 'section5_text_1',
                    'label' => 'Treść pierwszej zakładki',
                    'type' => 'textarea'
                )
            )
        ),
        array(
            'id' => 'section5_tab2',
            'label' => 'Druga zakładka',
            'type' => 'group',
            'db_group' => bool,
            'fields' => array(
                array(
                    'id' => 'section5_header_2',
                    'label' => 'Nazwa drugiej zakładki',
                    'type' => 'text'
                ),
                array(
                    'id' => 'section5_text_2',
                    'label' => 'Treść drugiej zakładki',
                    'type' => 'textarea'
                )
            )
        ),
        array(
            'id' => 'section5_tab3',
            'label' => 'Trzecia zakładka',
            'type' => 'group',
            'db_group' => bool,
            'fields' => array(
                array(
                    'id' => 'section5_header_3',
                    'label' => 'Nazwa trzeciej zakładki',
                    'type' => 'text'
                ),
                array(
                    'id' => 'section5_text_3',
                    'label' => 'Treść trzeciej zakładki',
                    'type' => 'textarea'
                )
            )
        )
    );
    beans_register_post_meta( $fields, array( 'strona_glowna.php' ), 'tm_section5', array( 'title' => ( 'Sekcja 5 (Dane kontaktowe)' ) ) );
}

and for display content on page:

if ( beans_get_post_meta( 'section5_checkbox' ) ) {
    add_action( 'beans_post_content_after_markup', 'add_section_5' );

function add_section_5() {
$total = 3; // I use variable, to iterate, because I want to add more fields in the future
    ?>
    <section class="uk-block tm-section-5">
        <div class="uk-container uk-container-center uk-grid uk-flex uk-flex-middle">
            <div class="uk-width-1-3 uk-hidden-small">
                <div class="uk-margin-large-right">
                    <img class="aligncenter uk-margin-right" src="img.png" />
                </div>
            </div>
            <div class="uk-width-medium-2-3">
                <h3 class="uk-text-center uk-margin-bottom uk-text-muted"><?php echo beans_get_post_meta( 'section5_main_header' ); ?></h3>
                <h4 class="uk-text-center"><?php echo beans_get_post_meta( 'section5_main_text' ); ?></h4>
                <div class="uk-grid uk-margin-large-top">
                    <div class="uk-width-small-1-3">
                        <ul class="uk-nav uk-nav-side uk-text-center" data-uk-switcher="{connect:'#kontakty', animation: 'fade'}">
                        <?php
                            for ($i=1; $i<=$total; $i++) {
                                $r1 .= '<li>';
                                $r1 .= '<a href><i class="uk-icon-caret-right"></i>';
                                $r1 .= beans_get_post_meta( "section5_header_{$i}" );
                                $r1 .= '</a>';
                                $r1 .= '</li>';
                            }
                        echo $r1;
                        ?>
                        </ul>
                    </div>
                    <div class="uk-width-small-2-3 uk-flex uk-flex-middle uk-flex-center">
                        <ul id="kontakty" class="uk-switcher">
                        <?php
                            for ($i=1; $i<=$total; $i++) {
                                $r2 .= '<li>';
                                $r2 .= beans_get_post_meta( "section5_text_{$i}" );
                                $r2 .= '</li>';
                            }
                            echo $r2;
                            ?>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <?php
}
}

Write a reply

Login or register to write a reply, it's free!