Wordpress 在多站点中添加_选项

Wordpress 在多站点中添加_选项,wordpress,Wordpress,我想在多站点的wp\u options表中添加名为enable\u image的选项。i、 e每个博客id。我想获取复选框的值并将其保存在wp_选项表中。 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To Upload') ?></span></legend> <label for

我想在多站点的
wp\u options
表中添加名为
enable\u image
的选项。i、 e每个博客id。我想获取复选框的值并将其保存在wp_选项表中。

<td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To   Upload') ?></span></legend>
<label for="enable_app1">

<input name="enable_app1" type="checkbox" id="enable_app1" value="1" <?php checked('1',  get_option('enable_image')); ?> />

<?php _e('Yes Allow Contributor To Upload.') ?></label><br />
</fieldset></td>
</tr>



请帮助我

我将建议一种不同的方法来实现这一点,我认为这正是您真正想要的。首先,在整个网络范围内使用

<td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To   Upload') ?></span></legend>
<label for="enable_app1">

<input name="enable_app1" type="checkbox" id="enable_app1" value="1" <?php checked('1',  get_option('enable_image')); ?> />

<?php _e('Yes Allow Contributor To Upload.') ?></label><br />
</fieldset></td>
</tr>
然后,无论何时需要使用此值,都可以按如下方式检索它:

<td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To   Upload') ?></span></legend>
<label for="enable_app1">

<input name="enable_app1" type="checkbox" id="enable_app1" value="1" <?php checked('1',  get_option('enable_image')); ?> />

<?php _e('Yes Allow Contributor To Upload.') ?></label><br />
</fieldset></td>
</tr>
if( get_option( 'enable_app1' ) ) {
    $enable_app1 = get_option( 'enable_app1' );
}
else {
    $enable_app1 = get_site_option( 'enable_app1' );
}
也就是说,如果已经为这个博客设置了一个值,那么就使用它。否则,请使用已在网络范围内设置的选项。这允许管理员在本地覆盖这些选项,同时保存工作,以便在每个博客上显式设置值

<td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To   Upload') ?></span></legend>
<label for="enable_app1">

<input name="enable_app1" type="checkbox" id="enable_app1" value="1" <?php checked('1',  get_option('enable_image')); ?> />

<?php _e('Yes Allow Contributor To Upload.') ?></label><br />
</fieldset></td>
</tr>

如果您不需要在本地重写内容,您可以单独使用
update\u site\u选项
。与在每个博客上设置值相比,它更可取,并且具有相同的效果。但是,如果您想这样做,您也可以先检查网络范围选项是否已设置,然后使用操作挂钩更新本地值以匹配它。

@mazherulhaq,请检查:。@brasofilo您是对的,但过去几天我无法接受任何答案,因为我只有1个声誉
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Allow Contributor To   Upload') ?></span></legend>
<label for="enable_app1">

<input name="enable_app1" type="checkbox" id="enable_app1" value="1" <?php checked('1',  get_option('enable_image')); ?> />

<?php _e('Yes Allow Contributor To Upload.') ?></label><br />
</fieldset></td>
</tr>