Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function hmbl_theme_color() {
- global $post;
- $color = hmbl_recursive_find_color($post->ID);
- if ($color != false) : ?>
- <style type="text/css" media="screen">
- .theme-color {
- color: <?php echo $color ?>;
- }
- .theme-background-color {
- background-color: <?php echo $color ?>;
- }
- .theme-border-color {
- border-color: <?php echo $color ?>;
- }
- </style>
- <?php endif;
- }
- add_action('wp_head', 'hmbl_theme_color');
- function hmbl_recursive_find_color($post_id) {
- $use_color = get_field('theme_color_active', $post_id);
- if ($use_color == true) {
- return get_field('theme_color', $post_id);
- } else {
- $post = get_post($post_id);
- if (isset($post->post_parent) && $post->post_parent != 0) {
- return hmbl_recursive_find_color($post->post_parent);
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement