WordPress.org

Ready to get started?Download WordPress

Forums

Meta Box
[resolved] Fatal error: Only variables can be passed by reference in file-advanced.php (5 posts)

  1. Hamed Momeni
    Member
    Posted 1 year ago #

    I'm having the following error upon activating the plugin.

    Fatal error: Only variables can be passed by reference in .../wp-content/plugins/meta-box/inc/fields/file-advanced.php on line 106

    Can you please help me?

    http://wordpress.org/extend/plugins/meta-box/

  2. mdierks
    Member
    Posted 1 year ago #

    I have the same error after updating to 4.3

  3. mdierks
    Member
    Posted 1 year ago #

    I figured out, that this is the problematic code:

    <% _.each( attachments, function( attachment ) { %>
                    <li id="item_<%= attachment.id %>">
                    <% if ( attachment.sizes.hasOwnProperty( 'thumbnail' ) ) { %>
                    <img src="<%= attachment.sizes.thumbnail.url %>">
                    <% } else { %>
                    <img src="<%= attachment.sizes.full.url %>">
                    <% } %>
                    <div class="rwmb-image-bar">
                    <a title="<?php echo $i18n_edit; ?>" class="rwmb-edit-file" href="<%= attachment.editLink %>" target="_blank"><?php echo $i18n_edit; ?></a> |
                    <a title="<?php echo $i18n_delete; ?>" class="rwmb-delete-file" href="#" data-attachment_id="<%= attachment.id %>">×</a>
                    </div>
                    </li>
                    <% } );%>

    by removing it in image-advanced.php and file-advanced.php the plugin works again, with a few bugs.

  4. Vladimir Mrkela
    Member
    Posted 1 year ago #

    Code below worked for me:

    static function print_templates() {
                $i18n_delete = apply_filters('rwmb_file_delete_string', _x('Delete', 'file upload', 'rwmb'));
                $i18n_edit = apply_filters('rwmb_file_edit_string', _x('Edit', 'file upload', 'rwmb'));
                ?>
                <script id="tmpl-rwmb-file-advanced" type="text/html">
                    <# _.each( attachments, function( attachment ) { #>
                    <li>
                        <div class="rwmb-icon"><img src="<# if ( attachment.type == 'image' ){ #>{{{ attachment.sizes.thumbnail.url }}}<# } else { #>{{{ attachment.icon }}}<# } #>"></div>
                        <div class="rwmb-info">
                            <a href="{{{ attachment.url }}}" target="_blank">{{{ attachment.title }}}</a>
                            <p>{{{ attachment.mime }}}</p>
                            <a title="<?php echo $i18n_edit; ?>" href="{{{ attachment.editLink }}}" target="_blank"><?php echo $i18n_edit; ?></a> |
                            <a title="<?php echo $i18n_delete; ?>" class="rwmb-delete-file" href="#" data-attachment_id="{{{ attachment.id }}}"><?php echo $i18n_delete; ?></a>
                        </div>
                    </li>
                    <# } ); #>
                </script>
                <?php
            }

    Also, you need to add code below in file "file-advanced.js" at the top of: if(!frame) conditional:

    _.templateSettings = {
                        evaluate:    /<#([\s\S]+?)#>/g,
                        interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
                        escape:      /\{\{([^\}]+?)\}\}(?!\})/g
                    };

    Problem is with tags <% %>. If your server has enabled ASP tags, script will crash because it's evaluated as PHP.

  5. Hamed Momeni
    Member
    Posted 1 year ago #

    Thanks guys. I appreciate it.
    It's good to go.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic