(免责声明:我是一名设计师,只是出于需要才成为程序员。这意味着我可以读一些PHP代码,但我自己写起来比较困难。我希望我能做得更好,而这篇文章是为了更好地理解PHP。我可能不知道如何以正确的方式甚至使用正确的术语来问这个问题,所以请耐心等待。)
我有一个自定义的帖子类型插件,它向管理屏幕添加了一些自定义字段,包括一个视频元框字段。Now I need to remove the video field, and I\'m wondering if you can do that fairly easy with some sort of clever unset/unregister/remove function?
我想我已经从插件中识别出了相关的代码,但我当然不想编辑插件本身,而是想在函数文件或类似文件中添加一些代码。你能给我指出正确的方向吗?
<?php
/**
* Class SixTenPressSermonsCustomFields
*/
class SixTenPressSermonsCustomFields extends SixTenPressCustomFields {
/* shortened for sake of the question */
/**
* Define the custom sermon fields.
* @return array
*/
protected function get_file_fields() {
$this->setting = sixtenpresssermons_get_setting();
return array(
array(
\'type\' => \'file\',
\'setting\' => \'mp3\',
\'label\' => __( \'Audio\', \'sixtenpress-sermons\' ),
\'description\' => __( \'Upload the audio file (MP3 format) or paste the URL for external MP3 (eg, SoundCloud).\', \'sixtenpress-sermons\' ),
\'library\' => array( \'audio\' ),
),
array(
\'type\' => \'file\',
\'setting\' => \'video\',
\'label\' => __( \'Video\', \'sixtenpress-sermons\' ),
\'description\' => __( \'Upload the video file (MP4 format) or paste the URL for external video (YouTube, Vimeo).\', \'sixtenpress-sermons\' ),
\'library\' => array( \'video\' ),
),
array(
\'type\' => \'file\',
\'setting\' => \'file\',
\'label\' => __( \'File\', \'sixtenpress-sermons\' ),
\'description\' => __( \'Upload a related file (pdf format). This could be sermon notes or a weekly bulletin.\', \'sixtenpress-sermons\' ),
\'library\' => array( \'application\' ),
),
);
}
我可以在函数中使用一些东西吗。删除上面视频字段的php文件?比如可能:<?php
function remove_video_field() {
/* not working, just guessing */
unset( sixtenpresssermons_get_setting );
/*specify Video option here somehow? */
}
add_action(\'remove_video_field\',\'SixTenPressSermonsCustomFields\');
// also not working, just me guessing here