简体   繁体   English

functions.php在WordPress中导致白页

[英]functions.php causing white pages in WordPress

For some reason, when I edit my functions.php, various pages turn white. 出于某种原因,当我编辑我的functions.php时,各种页面变为白色。 For exmaple, with this code: 例如,使用以下代码:

    <?php
    /* Add a custom field to the field editor (See editor screenshot) */
    add_action("gform_field_standard_settings", "my_standard_settings", 10, 2);
    function my_standard_settings($position, $form_id){
        // Create settings on position 25 (right after Field Label)
        if($position == 25){
?>
            <li class="admin_label_setting field_setting" style="display: list-item; ">
                <label for="field_placeholder">Placeholder Text
                    <!-- Tooltip to help users understand what this field does -->
                    <a href="javascript:void(0);" class="tooltip tooltip_form_field_placeholder" tooltip="&lt;h6&gt;Placeholder&lt;/h6&gt;Enter the placeholder/default text for this field.">(?)</a>
                </label>
                <input type="text" id="field_placeholder" class="fieldwidth-3" size="35" onkeyup="SetFieldProperty('placeholder', this.value);">
            </li>
<?php
        }
    }
    /* Now we execute some javascript technicalitites for the field to load correctly */
    add_action("gform_editor_js", "my_gform_editor_js");
    function my_gform_editor_js(){
?>
        <script>
            //binding to the load field settings event to initialize the checkbox
            $(document).bind("gform_load_field_settings", function(event, field, form){
                $("#field_placeholder").val(field["placeholder"]);
            });
        </script>

<?php
    }
    /* We use jQuery to read the placeholder value and inject it to its field */
    add_action('gform_enqueue_scripts',"my_gform_enqueue_scripts", 10, 2);
    function my_gform_enqueue_scripts($form, $is_ajax=false){
?>
        <script>
            jQuery(function(){
                <?php
                    /* Go through each one of the form fields */
                    foreach($form['fields'] as $i=>$field){
                        /* Check if the field has an assigned placeholder */
                        if(isset($field['placeholder']) && !empty($field['placeholder'])){
                            /* If a placeholder text exists, inject it as a new property to the field using jQuery */
                ?>
                jQuery('#input_<?php echo $form['id']?>_<?php echo $field['id']?>').attr('placeholder','<?php echo $field['placeholder']?>');
                <?php
                        }
                    }
                ?>
            });
        </script>
<?php
    }
?>

Updating pages leaves me at a blank white page (at url: /wp-admin/post.php). 更新页面使我处于空白页面(在url:/wp-admin/post.php)。 Another piece of code I was trying to use, from this tutorial: 我在本教程中尝试使用的另一段代码:

http://www.doitwithwp.com/pre-populate-fields-using-gravity-forms/ http://www.doitwithwp.com/pre-populate-fields-using-gravity-forms/

Causes a blank, white pages at the log in page. 在登录页面中显示空白页面。 I'm running the latest version of WordPress. 我正在运行最新版本的WordPress。 Any ideas why this would be happening? 有什么想法会发生这种情况吗?

Try removing any whitespace before the start PHP tag. 尝试在启动PHP标记之前删除任何空格。 Sometimes this causes a great trouble. 有时这会造成很大的麻烦。 Generally make sure it does not echo anything, as this file ONLY contains functions for later use and serves no content. 通常要确保它不会回显任何内容,因为此文件仅包含供以后使用的函数,并且不提供任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM