2011-09-18 105 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!"; 
}