Last active
June 28, 2019 03:13
-
-
Save emadelawady/204263a6be5a5b238a7ba88cc5806e23 to your computer and use it in GitHub Desktop.
this gist for bring styles by php magic, i didn't use built-in array's or string's functions just some logic, i like the way i can print "link rel" dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* get header , functions and footer | |
* with include built-in func | |
* you should def your directories paths | |
*/ | |
// header.php | |
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title>title</title> | |
<?php | |
// you can set first param | |
// the second is on by default | |
// you can set the second to off | |
// then is will hide the style | |
echo on_styles('main', 'on'); | |
echo on_styles('uikit.min', 'on'); | |
?> | |
</head> | |
<body> | |
<?php | |
echo "Header is here"; | |
?> | |
<h1>hello world</h1> | |
// footer.php | |
</body> | |
</html> | |
// functions.php | |
<php | |
/** | |
** enqueue styles | |
**/ | |
function on_styles($style = NULL, $switch = NULL) { | |
$mainStyle = ''; | |
if ($style == $style && $switch == 'on') { | |
$mainStyle = $style; | |
} elseif($style == $style && $switch == 'off') { | |
$mainStyle = ''; | |
} | |
if ($mainStyle == $style) { | |
$link_rel = '<link rel="stylesheet" href="' . $css_path_here . $style .'.css"> ' . PHP_EOL ; | |
return $link_rel; | |
} | |
} | |
?> | |
// index.php | |
<?php | |
/* get header , functions and footer | |
* with include built-in func | |
* you better define your directories paths | |
*/ | |
include $path_to_hdr_here . 'header.php'; | |
include 'functions.php'; | |
include $path_to_foo_here . 'footer.php'; | |
?> | |
hola from egypt ragnar is here | |
this is v.1 im gonna work upon it hardly later | |
notice this is for personal practice and you can do what ever you want with code | |
this gist will be updated | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment