0
我想能夠調用具有hook
參數的回調方法。如何在wordpress hook中調用帶參數的回調方法?
我已經實現下面的腳本,但它仍然無法工作:
class media{
public function loadScripts($scripts){var_dump($scripts);
foreach($scripts as $script){var_dump($script);
wp_enqueue_script($script['name'], plugins_url().$script['path']);
}
}
public function loadStyles($styles){
foreach($styles as $style){
wp_register_style($style['name'], plugins_url().$style['path']);
wp_enqueue_style($style['name'], plugins_url().$style['path']);
}
}
}
$media = new media();
$scripts = array(
array('name' => 'jquery1', 'path' => '/content-type/js/jquery.min.js'),
array('name' => 'videos_js', 'path' => '/content-type/js/videos.js')
);
add_action('wp_print_scripts', 'loadScripts',10,1);
do_action('wp_print_scripts',$scripts);
我該如何解決這個問題?