Tag: theme

Require Dir

if(!function_exists('requireDir')){
function requireDir($dir){
	$dh = @opendir($dir);

	if (!$dh) {
		throw new Exception("Cannot open directory $dir");
	} else {
		while (($file = readdir($dh)) !== false) {
			if ($file != '.' && $file != '..') {
				$requiredFile = $dir . DIRECTORY_SEPARATOR . $file;
				if ('.php' === substr($file, strlen($file) - 4)) {
					require_once $requiredFile;
				} elseif (is_dir($requiredFile)) {
					requireDir($requiredFile);
				}
			}
		}
	closedir($dh);
	}
	unset($dh, $dir, $file, $requiredFile);
}
}

Those wacky theme paths

  • get_template_directory()

    : Returns the absolute template directory path. (PARENT)

  • get_template_directory_uri()

    : Returns the template directory URI.

  • get_stylesheet_directory()

    : Returns the absolute stylesheet directory path. (CHILD)

  • get_stylesheet_directory_uri()

    : Returns the stylesheet directory URI.

See also: How To Load Files Within WordPress Themes