2012-11-28 24 views
0

工作的東西,我堅持一點。

我有一個在wordpress中的頁面上加載的類文件。 我想要做的就是查找$_GET變量,如果它們存在,並且它們在我的班級中調用函數。

如果有幫助,我可以在我的課程頂部使用構造函數。

無論如何,我可以做到這一點? 他是我的__construct的事情在我的課開始

class mijireh_class extends wpsc_merchant 
{ 
function __construct($purchase_id = null, $is_receiving = false) { 
    $this->name = __('Mijjireh', 'wpsc_gold_cart'); 
    parent::__construct($purchase_id, $is_receiving); 

    if(!class_exists('Mijireh')) { 
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mijireh'. DIRECTORY_SEPARATOR . 'Mijireh.php'; 
    } 

    add_action('init', array(&$this, 'mijireh_notify'), 10, 2); 
} 

public function mijireh_notify() 
{ 
    if(isset($_GET['task']) && $_GET['task'] == 'mijireh_notify') { 
     print $_GET['task']; 
     exit; 
      } 
    } 
} 

我試圖刷新該頁面,並傳遞參數?任務= mijireh_notify & ORDER_NUMBER = 8001354073961,但它不是callngthe功能,我得到了印刷版和退出,所以我應該知道

+0

'如果(isset( $ _GET ['thing'])){yourFunc(); }' –

+0

類似於 add_action('init',myfunction); – misulicus

+0

michael said應該工作,只是把它放在你的「init」函數中,如果$ _GET變量存在,調用必要的類函數 – kennypu

回答

1

對$ _GET數據採取行動:

add_action('init', 'process_get'); 
//function in your class 
function process_get(){ 
if(isset($_GET['som_field'])) { 
    // process $_GET data here 
} 
} 

你的意思是這樣

+0

我試過了,它沒有做任何事情......更新了主代碼和我的代碼 – misulicus