0

我正在为 WordPress 制作一个自定义选项页面并使用 wp_editor。这是我的代码:

$settings = array('wpautop' => false, 'textarea_name' => $editor_id);
echo '<table class="form-table">';
    echo '<tbody>';
        echo '<tr>';
            echo '<th scope="col">Enabled?</th>';
            echo '<td><input name="emp_enabled" type="checkbox" value="checked" '.$get_settings['emp_enabled'].'><p class="description">Do you want to enable Maintenance Page?</p></td>';
        echo '</tr>';
        echo '<tr>';
            echo '<th scope="col">Background Colour</th>';
            echo '<td><input id="emp_background_colour" class="regular-text ltr emp_background_colour" name="emp_background_colour" type="input" value="'.$get_settings['emp_background_colour'].'"><p class="description">Do you want to set a background colour?</p></td>';
        echo '</tr>';
            echo '<th scope="col">Background Image </th>';
            echo '<td><input id="upload_image_url" class="regular-text ltr" name="emp_background_image" type="input" value="'.$get_settings['emp_background_image'].'"><input id="upload_image_button" class="button" type="button" value="Upload Image" /><p class="description">Do you want to set a background image? This will override Background Colour.</p></td>';
        echo '</tr>';
        echo '<tr>';
            echo '<th scope="col">Content</th>';
            echo '<td>'.wp_editor( $get_settings[$editor_id] , $editor_id, $settings ).'</td>';
        echo '</tr>';
    echo '</tbody>';
echo '</table>';

内容按应有的方式通过,但由于某种原因,编辑器不在表格单元格内,它位于实际表格的上方。

在此处输入图像描述

任何想法为什么会这样?我看不到任何明显的问题,所以如果我缺少某个设置,我会在徘徊吗?

4

1 回答 1

0

在这里您可以创建如下内容:

function editor_tobe_used($user)
{
    if (!current_user_can('edit_posts')) {
        return;
    }
    ?>
    <table class="form-table">
    <tbody>
        <tr>
            <th scope="col">Enabled?</th>
            <td><input name="emp_enabled" type="checkbox" value="checked" <?php echo $get_settings['emp_enabled'];?>'><p class="description">Do you want to enable Maintenance Page?</p></td>
        </tr>
        <tr>
            <th scope="col">Background Colour</th>
            <td><input id="emp_background_colour" class="regular-text ltr emp_background_colour" name="emp_background_colour" type="input" value="<?php $get_settings['emp_background_colour'];?>"><p class="description">Do you want to set a background colour?</p></td>
        </tr>
            <th scope="col">Background Image </th>
            <td><input id="upload_image_url" class="regular-text ltr" name="emp_background_image" type="input" value="<?php $get_settings['emp_background_image'];?>"><input id="upload_image_button" class="button" type="button" value="Upload Image" /><p class="description">Do you want to set a background image? This will override Background Colour.</p></td>
        </tr>
        <tr>
            <th scope="col">Content</th>
            <td> <?php wp_editor( "Your content Goes here" , $editor_id, $settings );?></td>
        </tr>
    </tbody>
</table>
    <?php 
}
于 2018-05-11T09:48:45.413 回答