public function ajax_api() { $paths = FOX_sUtil::glob_recursive(FOX_PATH_AJAX . "/*.js"); $urls = FOX_sUtil::pluginPathToURL($paths); foreach ($urls as $url) { $hash = md5($url); wp_register_script($hash, $url); wp_enqueue_script($hash); } unset($url); }
function test_pluginPathToURL() { // Single path as string // ============================================ $test = FOX_PATH_BASE . "/foo/bar.jpg"; $check = FOX_URL_BASE . "/foo/bar.jpg"; $result = FOX_sUtil::pluginPathToURL($test); $this->assertEquals($check, $result); // Multiple paths as array // ============================================ $test = array(FOX_PATH_BASE . "/foo/bar1.jpg", FOX_PATH_BASE . "/foo/bar2.jpg", FOX_PATH_BASE . "/foo/bar3.jpg"); $check = array(FOX_URL_BASE . "/foo/bar1.jpg", FOX_URL_BASE . "/foo/bar2.jpg", FOX_URL_BASE . "/foo/bar3.jpg"); $result = FOX_sUtil::pluginPathToURL($test); $this->assertEquals($check, $result); }