2011-09-18 83 views
0

这似乎是一个简单的问题,但已被证明很难找到信息。如何覆盖WordPress插件显示

我正在处理一些有可怕输出的WordPress插件 - 特别是事件日历1.6.5。这个插件有PHP文件事件内容的输出像gridview.phplist.php的的single.phptable.php。我熟悉这些文件调用的函数来重写插件的工作方式,但我需要更改整个显示格式以适合我的主题。

有没有办法覆盖这些显示文件,或者我只是做我自己的主题文件,并调用插件文件使用相同的功能?

回答

2

我在寻找相似的答案。我不完全确定事件日历是如何实现的,但是从Business Directly Plugin类似的经验来讲,你可以通过钩住你自己的方法从主题的functions.php文件中覆盖钩子。

这里是一个除了我写了覆盖钩“wpbdm_show加上市形式”:

/* 
* Fix the horrible output of wpbusdirman_displaypostform() from wpbusdirman.php 
* 
* This is done by overriding the wpbdm_show-add-listing-form hook with my own function 
*/ 
add_filter('wpbdm_show-add-listing-form', 'alternative_wpbusdirman_displaypostform', 10, 4); 

// Ensure that the method signature is the same (same order of vars, same 
function alternative_wpbusdirman_displaypostform($makeactive = 1, $wpbusdirmanerrors = '', $neworedit = 'new', $wpbdmlistingid = '') 
{ 
    // This assumes that the Business Directory Plugin is installed 
    if (!function_exists("wpbusdirman_displaypostform")) 
    { 
     // If the funct doesn't exist then it probably isn't installed 
     return ''; 
    } 

    // Call the method and regex parse out the bits we don't want 
    $original_output = wpbusdirman_displaypostform($makeactive, $wpbusdirmanerrors, $neworedit, $wpbdmlistingid); 

    // Do some fixing of the output. In this example we do nothing and just return what we received. 

    return $original_output . " WE EDITED IT!"; 
}