示例#1
0
    } else {
        if (is_search() && ($page_id = getTemplatePageId('search')) > 0) {
            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
        } else {
            if (is_404() && ($page_id = getTemplatePageId('404')) > 0) {
                $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
            } else {
                if (function_exists('is_bbpress') && is_bbpress() && ($page_id = getTemplatePageId('bbpress')) > 0) {
                    $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                } else {
                    if (function_exists('is_buddypress') && is_buddypress() && ($page_id = getTemplatePageId('buddypress')) > 0) {
                        $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                    } else {
                        if (is_single() || is_page() || is_singular() || $wp_query->is_posts_page == 1) {
                            // Current post custom options
                            $page_id = is_single() || is_page() ? get_the_ID() : (isset($wp_query->queried_object_id) ? $wp_query->queried_object_id : getTemplatePageId('template-blog'));
                            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                            $THEMEREX_cat_options = getCategoriesInheritedProperties(getCategoriesByPostId($page_id));
                        }
                    }
                }
            }
        }
    }
}
// Reject old browsers support
global $THEMEREX_jreject;
$THEMEREX_jreject = false;
if (!isset($_COOKIE['jreject'])) {
    wp_enqueue_style('jquery_reject-style', get_template_directory_uri() . '/js/jreject/css/jquery.reject.css', array(), null);
    wp_enqueue_script('jquery_reject', get_template_directory_uri() . '/js/jreject/jquery.reject.js', array('jquery'), null, true);
示例#2
0
 function themerex_posts_per_page_selector($query)
 {
     if (is_admin() || !$query->is_main_query()) {
         return;
     }
     $orderby_set = true;
     $orderby = get_theme_option('blog_sort');
     $order = get_theme_option('blog_order');
     // Set posts per page
     $ppp = (int) get_theme_option('posts_per_page');
     $ppp2 = 0;
     if ($query->is_category()) {
         $cat = (int) $query->get('cat');
         if (empty($cat)) {
             $cat = $query->get('category_name');
         }
         if (!empty($cat)) {
             //$ppp2 = (int) getCategoryInheritedProperty($cat, 'posts_per_page', 0);
             $cat_options = getCategoryInheritedProperties($cat);
             if (isset($cat_options['posts_per_page']) && !empty($cat_options['posts_per_page']) && $cat_options['posts_per_page'] != 'default') {
                 $ppp2 = (int) $cat_options['posts_per_page'];
             }
             if (isset($cat_options['blog_sort']) && !empty($cat_options['blog_sort']) && $cat_options['blog_sort'] != 'default') {
                 $orderby = $cat_options['blog_sort'];
             }
             if (isset($cat_options['blog_order']) && !empty($cat_options['blog_order']) && $cat_options['blog_order'] != 'default') {
                 $order = $cat_options['blog_order'];
             }
         }
     } else {
         if ($query->get('post_type') == 'product' || $query->get('product_cat') != '' || $query->get('product_tag') != '') {
             $orderby_set = false;
             $page_id = get_option('woocommerce_shop_page_id');
         } else {
             if ($query->is_archive()) {
                 $page_id = getTemplatePageId('archive');
             } else {
                 if ($query->is_search()) {
                     $page_id = getTemplatePageId('search');
                 } else {
                     if ($query->is_posts_page == 1) {
                         $page_id = isset($query->queried_object_id) ? $query->queried_object_id : getTemplatePageId('template-blog');
                     } else {
                         $page_id = 0;
                     }
                 }
             }
         }
         if ($page_id > 0) {
             $post_options = get_post_meta($page_id, 'post_custom_options', true);
             if (isset($post_options['posts_per_page']) && !empty($post_options['posts_per_page']) && $post_options['posts_per_page'] != 'default') {
                 $ppp2 = (int) $post_options['posts_per_page'];
             }
             if ($orderby_set) {
                 if (isset($post_options['blog_sort']) && !empty($post_options['blog_sort']) && $post_options['blog_sort'] != 'default') {
                     $orderby = $post_options['blog_sort'];
                 }
                 if (isset($post_options['blog_order']) && !empty($post_options['blog_order']) && $post_options['blog_order'] != 'default') {
                     $order = $post_options['blog_order'];
                 }
             }
         }
     }
     if ($ppp2 > 0) {
         $ppp = $ppp2;
     }
     if ($ppp > 0) {
         $query->set('posts_per_page', $ppp);
     }
     if ($orderby_set) {
         addSortOrderInQuery($query, $orderby, $order);
     }
     // Exclude categories
     $ex = get_theme_option('exclude_cats');
     if (!empty($ex)) {
         $query->set('category__not_in', explode(',', $ex));
     }
 }
示例#3
0
function showBreadcrumbs($args = array())
{
    global $wp_query, $post;
    $args = array_merge(array('home' => '', 'home_url' => '', 'show_all_filters' => true, 'show_all_posts' => true, 'truncate_title' => 0, 'truncate_add' => '...', 'echo' => true), is_array($args) ? $args : array('home' => $args));
    $rez = '';
    $rez2 = '';
    $rez_all = '';
    $type = getBlogType();
    $title = getShortString(getBlogTitle(), $args['truncate_title'], $args['truncate_add']);
    $cat = '';
    $parentTax = '';
    if (!in_array($type, array('home', 'frontpage'))) {
        $need_reset = true;
        $parent = 0;
        $post_id = 0;
        if ($type == 'page' || $type == 'attachment') {
            $pageParentID = isset($wp_query->post->post_parent) ? $wp_query->post->post_parent : 0;
            $post_id = $type == 'page' ? isset($wp_query->post->ID) ? $wp_query->post->ID : 0 : $pageParentID;
            while ($pageParentID > 0) {
                $pageParent = get_post($pageParentID);
                $rez2 = '<li class="cat_post"><a href="' . get_permalink($pageParent->ID) . '">' . getShortString($pageParent->post_title, $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                if (($pageParentID = $pageParent->post_parent) > 0) {
                    $page_id = $pageParentID;
                }
            }
        } else {
            if ($type == 'single') {
                $post_id = isset($wp_query->post->ID) ? $wp_query->post->ID : 0;
            }
        }
        $depth = 0;
        $ex_cats = explode(',', get_theme_option('exclude_cats'));
        $taxonomy = themerex_strpos($type, 'woocommerce') !== false ? array('product_cat') : array('category');
        do {
            if ($depth++ == 0) {
                if (in_array($type, array('single', 'attachment', 'woocommerce_product'))) {
                    if ($type != 'woocommerce_product' && $args['show_all_filters']) {
                        $post_format = get_post_format($post_id);
                        if (($tpl_id = getTemplatePageId('only-' . $post_format)) > 0) {
                            $rez_all .= '<li class="all"><a href="' . get_permalink($tpl_id) . '">' . sprintf(__('All %s', 'themerex'), getPostFormatName($post_format, false)) . '</a></li>';
                        }
                    }
                    $cats = getCategoriesByPostId($post_id, $taxonomy);
                    $cat = $cats ? $cats[0] : false;
                    if ($cat) {
                        if (!in_array($cat['term_id'], $ex_cats)) {
                            $cat_link = get_term_link($cat['slug'], $cat['taxonomy']);
                            $rez2 = '<li class="cat_post"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                        }
                    } else {
                        $post_type = get_post_type($post_id);
                        $parentTax = 'category' . ($post_type == 'post' ? '' : '_' . $post_type);
                    }
                } else {
                    if ($type == 'category') {
                        $cat = get_term_by('id', get_query_var('cat'), 'category', ARRAY_A);
                    } else {
                        if (themerex_strpos($type, 'woocommerce') !== false) {
                            if (is_product_category()) {
                                $cat = get_term_by('slug', get_query_var('product_cat'), 'product_cat', ARRAY_A);
                            }
                        }
                    }
                }
                if ($cat) {
                    $parent = $cat['parent'];
                    $parentTax = $cat['taxonomy'];
                }
            }
            if ($parent) {
                $cat = get_term_by('id', $parent, $parentTax, ARRAY_A);
                if ($cat) {
                    if (!in_array($cat['term_id'], $ex_cats)) {
                        $cat_link = get_term_link($cat['slug'], $cat['taxonomy']);
                        $rez2 = '<li class="cat_parent"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2;
                    }
                    $parent = $cat['parent'];
                }
            }
        } while ($parent);
        if (themerex_strpos($type, 'woocommerce') !== false && !in_array(themerex_strtolower($title), array('shop')) && ($shop_id = get_option('woocommerce_shop_page_id')) > 0) {
            $rez_all = '<li class="all"><a href="' . get_permalink($shop_id) . '">' . __('Shop', 'themerex') . '</a></li>' . $rez_all;
        }
        if ($args['show_all_posts'] && !in_array(themerex_strtolower($title), array('all posts')) && ($blog_id = getTemplatePageId('template-blog')) > 0) {
            $rez_all = '<li class="all"><a href="' . get_permalink($blog_id) . '">' . __('All Posts', 'themerex') . '</a></li>' . $rez_all;
        }
        $rez3 = '';
        if (themerex_strpos($type, 'woocommerce') === false && is_archive() && is_object($post)) {
            $year = get_the_time('Y');
            $month = get_the_time('m');
            if (is_day() || is_month()) {
                $rez3 .= '<li class="cat_parent"><a href="' . get_year_link($year) . '">' . $year . '</a></li>';
            }
            if (is_day()) {
                $rez3 .= '<li class="cat_parent"><a href="' . get_month_link($year, $month) . '">' . prepareDateForTranslation(get_the_date('F')) . '</a></li>';
            }
        }
        if (!is_front_page()) {
            // && !is_home()
            $rez .= '<ul class="breadcrumbs">' . (isset($args['home']) && $args['home'] != '' ? '<li class="home"><a href="' . ($args['home_url'] ? $args['home_url'] : home_url()) . '">' . $args['home'] . '</a></li>' : '') . $rez_all . $rez2 . $rez3 . ($title ? '<li class="current">' . $title . '</li>' : '') . '</ul>';
        }
    }
    if ($args['echo'] && !empty($rez)) {
        echo $rez;
    }
    return $rez;
}
function load_custom_options()
{
    // Theme custom settings from current post and category
    global $THEMEREX_cat_options, $THEMEREX_post_options, $THEMEREX_custom_options, $THEMEREX_shop_options, $wp_query;
    // Current post & category custom options
    $THEMEREX_post_options = $THEMEREX_cat_options = $THEMEREX_custom_options = $THEMEREX_shop_options = array();
    if (is_woocommerce_page() && ($page_id = get_option('woocommerce_shop_page_id')) > 0) {
        $THEMEREX_shop_options = get_post_meta($page_id, 'post_custom_options', true);
    }
    if (is_category()) {
        $cat = (int) get_query_var('cat');
        if (empty($cat)) {
            $cat = get_query_var('category_name');
        }
        $THEMEREX_cat_options = get_category_inherited_properties($cat);
    } else {
        if ((is_day() || is_month() || is_year()) && ($page_id = getTemplatePageId('archive')) > 0) {
            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
        } else {
            if (is_search() && ($page_id = getTemplatePageId('search')) > 0) {
                $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
            } else {
                if (is_404() && ($page_id = getTemplatePageId('404')) > 0) {
                    $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                } else {
                    if (function_exists('is_bbpress') && is_bbpress() && ($page_id = getTemplatePageId('bbpress')) > 0) {
                        $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                    } else {
                        if (function_exists('is_buddypress') && is_buddypress() && ($page_id = getTemplatePageId('buddypress')) > 0) {
                            $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                        } else {
                            if (is_attachment() && ($page_id = getTemplatePageId('attachment')) > 0) {
                                $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                            } else {
                                if (is_single() || is_page() || is_singular() || $wp_query->is_posts_page == 1) {
                                    // Current post custom options
                                    $page_id = is_single() || is_page() ? get_the_ID() : (isset($wp_query->queried_object_id) ? $wp_query->queried_object_id : getTemplatePageId('blog'));
                                    $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true);
                                    $THEMEREX_cat_options = get_categories_inherited_properties(getCategoriesByPostId($page_id));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
function prepareThemeCustomStyles()
{
    // Custom font
    $fonts = getThemeFontsList(false);
    $font = get_custom_option('theme_font');
    $body_bg = get_custom_option('bg_color');
    $theme_color = get_custom_option('theme_color');
    if (isset($fonts[$font])) {
        addThemeCustomStyle("\n\t\t\tbody, button, input, select, textarea {\n\t\t\t\tfont-family: '" . $font . "', " . $fonts[$font]['family'] . ";\n\t\t\t}\n\t\t\tbody {\n\t\t\t\tbackground: " . $body_bg . "\n\t\t\t}\n\t\t");
    }
    // Custom menu
    if (get_custom_option('menu_colored') == 'yes') {
        $menu_name = 'mainmenu';
        if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
            $menu = wp_get_nav_menu_object($locations[$menu_name]);
            if (is_object($menu) && $menu) {
                $menu_items = wp_get_nav_menu_items($menu->term_id);
                $menu_styles = '';
                $menu_slider = get_custom_option('menu_slider') == 'yes';
                if (count($menu_items) > 0) {
                    foreach ($menu_items as $k => $item) {
                        //				if ($item->menu_item_parent==0) {
                        $cur_accent_color = '';
                        if ($item->type == 'taxonomy' && $item->object == 'category') {
                            $cur_accent_color = get_category_inherited_property($item->object_id, 'theme_accent_color');
                        }
                        if ((empty($cur_accent_color) || is_inherit_option($cur_accent_color)) && isset($item->classes[0]) && !empty($item->classes[0])) {
                            $cur_accent_color = (themerex_substr($item->classes[0], 0, 1) != '#' ? '#' : '') . $item->classes[0];
                        }
                        if (!empty($cur_accent_color) && !is_inherit_option($cur_accent_color)) {
                            $menu_styles .= ($item->menu_item_parent == 0 ? "#header_middle_inner #mainmenu li.menu-item-{$item->ID}.current-menu-item > a," : '') . "\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID} > a:hover,\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.sfHover > a {\n\t\t\t\t\t\t\t\t\t\tbackground-color: {$cur_accent_color} !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID} ul {\n\t\t\t\t\t\t\t\t\t\tbackground-color: {$cur_accent_color} !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t";
                        }
                        if ($menu_slider && $item->menu_item_parent == 0) {
                            $menu_styles .= "\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.blob_over:not(.current-menu-item) > a:hover,\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.blob_over.sfHover > a {\n\t\t\t\t\t\t\t\t\t\tbackground-color: transparent !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t";
                        }
                        //				}
                    }
                }
                if (!empty($menu_styles)) {
                    addThemeCustomStyle($menu_styles);
                }
            }
        }
    }
    // Main menu height
    $menu_height = (int) get_custom_option('menu_height');
    if ($menu_height > 20) {
        addThemeCustomStyle("\n\t\t\t#mainmenu > li > a {\n\t\t\t\theight: {$menu_height}px !important;\n\t\t\t\tline-height: {$menu_height}px !important;\n\t\t\t}\n\t\t\t#mainmenu > li ul {\n\t\t\t\ttop: {$menu_height}px !important;\n\t\t\t}\n\t\t\t#header_middle {\n\t\t\t\tmin-height: {$menu_height}px !important;\n\t\t\t}\n\t\t");
    }
    // Submenu width
    $menu_width = (int) get_custom_option('menu_width');
    if ($menu_width > 50) {
        addThemeCustomStyle("\n\t\t\t#mainmenu > li ul {\n\t\t\t\twidth: {$menu_width}px;\n\t\t\t}\n\t\t\t#mainmenu > li ul li ul {\n\t\t\t\tleft: " . ($menu_width + 1) . "px;\n\t\t\t}\n\t\t\t#mainmenu > li:nth-child(n+6) ul li ul {\n\t\t\t\tleft: -" . ($menu_width + 1) . "px;\n\t\t\t}\n\t\t");
    }
    if (!empty($theme_color)) {
        addThemeCustomStyle('
			#sidebar_main .popular_and_commented_tabs .tab_content:not(.style_post_format) .post_item .post_title a:hover, 
			.wp-calendar thead th.prevMonth a:hover,
			.wp-calendar thead th.nextMonth a:hover,
			.wp-calendar tbody td.dayWithPost a:hover,
			.widget_twitter .theme_text a,
			.top_news_section .top_news_term a:hover,
			a:hover,
			.trex_accent_color,
			.post_info .post_title a:hover,
			.link_text_wrap a,
			.sc_quote_icon,
			article.format-link > .icon,
			blockquote.sc_quote,
			article.format-aside > .icon,
			article.format-chat > .icon,
			article.format-status > .icon,
			#nav_pages ul li:hover a,
			#nav_pages ul li:hover span,
			#nav_pages ul li.pager_current span,
			#nav_pages .pager_prev a:hover,
			#nav_pages .pager_next a:hover,
			.isotopeFiltr ul li a:hover,
			section.author .user_links ul li span:hover,
			.comment_content .review .label i,
			.popularFiltr ul li.ui-state-active a span,
			.prev_next_posts .prev_post_icon,
			.prev_next_posts .next_post_icon,
			.prev_next_posts .prev_post_link a:hover,
			.prev_next_posts .next_post_link a:hover,
			.link_pages a:hover,
			.itemscope .post_tags a:hover,
			.article_services section.comments li.comment .comment_header .comment_reply a,
			.swpRightPos .sc_tabs .tabsMenuHead li.ui-tabs-active a,
			.swpRightPos .sc_tabs .tabsMenuHead li a:hover,
			.swpRightPos .addBookmark:hover i,
			.swpRightPos .listBookmarks li:hover a,
			#panelmenu li a:hover,
			.popular_and_commented_tabs ul.tabs li a:hover,
			.popular_and_commented_tabs .tab_content .post_item a:hover,
			.popular_and_commented_tabs .tab_content .post_item i.format-icon.hover:before,
			.footerWidget .popular_and_commented_tabs .tab_content h5.post_title a:hover,
			#sidebar_main .widget ul li a:hover,
			.sc_accordion.sc_accordion_style_1 .sc_accordion_item h4.sc_accordion_title i.icon,
			.sc_dropcaps .sc_dropcap,
			.sc_tooltip_parent,
			.sc_skills.sc_skills_type_counter .sc_skills_item_progress,
			.sc_title_icon,
			.sc_title_bg.sc_title_without_bg,
			.sc_icon,
			.sc_tabs ul.sc_tabs_titles li a .icon,
			.slider_wrap .sc_slider_swiper + .flex-control-nav ul li.current .post_icon,
			.sc_testimonials .flex-direction-nav li a,
			.sc_testimonials.sc_testimonials_style_2 .flex-direction-nav li a:hover,
			.sc_blogger .sc_blogger_item .sc_blogger_title a:hover,
			.sc_blogger.style_list .sc_blogger_item > .icon,
			.sc_blogger.style_carousel .sc_blogger_item .post_links a:hover,
			.sc_blogger.style_carousel .prev_slide:hover,
			.sc_blogger.style_carousel .next_slide:hover,
			.sc_review_panel .sc_review_title,
			.sc_team .sc_team_item .sc_team_item_position,
			.sc_list.sc_list_style_ol li .sc_list_num,
			.sc_list.sc_list_style_ol_filled li .sc_list_num,
			.sc_list.sc_list_style_iconed li:before {
				color: ' . $theme_color . ';
			}
			#nav_pages .pager_prev a:hover,
			#nav_pages .pager_next a:hover,
			.isotopeFiltr ul li.active a,
			.pagination_viewmore .view_more_button:hover,
			.popular_and_commented_tabs ul.tabs li.ui-tabs-active a,
			.link_pages a:hover,
			.popular_and_commented_tabs ul.tabs li a:hover,
			.wp-calendar thead th.prevMonth a:hover,
			.wp-calendar thead th.nextMonth a:hover,
			.wp-calendar tbody td.dayWithPost,
			.sc_dropcaps.sc_dropcaps_style_1 .sc_dropcap,
			.sc_dropcaps.sc_dropcaps_style_2 .sc_dropcap,
			.sc_dropcaps .sc_dropcap,
			.sc_tooltip_parent,
			.sc_blogger .sc_blogger_block_link:hover,
			.sc_blogger.style_carousel .prev_slide:hover,
			input[type="submit"]:hover,
			.sc_blogger.style_carousel .next_slide:hover {
				border-color: ' . $theme_color . ';
			}
			article.format-aside > .article_wrap,
			.isotopeFiltr ul li.active a,
			section.author .user_links span.tooltip,
			.vote_criterias li a:hover:before,
			.vote_criterias li a:active:before,
			.link_pages .pages_popup .popup_inner,
			.popular_and_commented_tabs ul.tabs li.ui-tabs-active a,
			#sidebar_main .widget.widget_recent_entries ul li a:before,
			.widget.widget_flickr .flickr_images a,
			.widget_contact_social .tooltip,
			.sc_dropcaps.sc_dropcaps_style_1 .sc_dropcap,
			.sc_dropcaps.sc_dropcaps_style_2 .sc_dropcap,
			.sc_skills.sc_skills_type_bar .sc_skills_item .sc_skills_item_progress,
			.sc_skills.sc_skills_type_bar .sc_skills_item .sc_skills_item_progress .progress_inner,
			.sc_slider_swiper .progress,
			.sc_testimonials .flex-direction-nav li a:hover,
			.sc_blogger_item .thumb a,
			.sc_blogger_item .thumb a .hover_plus,
			.sc_blogger.style_accordion .sc_blogger_item .sc_blogger_title a:hover,
			.sc_blogger.style_date .sc_blogger_item .post_date_info .month,
			.sc_blogger.style_carousel .sc_blogger_item .overlay_mask,
			.sc_blogger.style_carousel .swiper_scrollbar .swiper-scrollbar-drag,
			.sc_button,
			.sc_blogger .sc_blogger_block_link:hover,
			.sc_list.sc_list_style_ul li:before,
			input[type="submit"]:hover,
			a:hover .sc_title_icon,
			.sc_list.sc_list_style_ol_filled li .sc_list_num {
				background: ' . $theme_color . ';
			}
		');
    }
    // Custom css from theme options
    $css = get_custom_option('custom_css');
    $section1_bg = get_custom_option('section_1_bg');
    $section2_bg = get_custom_option('section_2_bg');
    $section1_font = get_custom_option('section_1_font');
    $section2_font = get_custom_option('section_2_font');
    $section2_top_margin = get_custom_option('section2_margin_top');
    $section2_bottom_margin = get_custom_option('section2_margin_bottom');
    $css .= !empty($section1_font) ? '.section_2 { color: ' . $section2_font . '}' : '';
    $css .= !empty($section1_font) ? '.section_1,#topmenu li a, header .section_1 .login_loguout_link { color: ' . $section1_font . '}' : '';
    $css .= !empty($section1_bg) ? 'header .section_1 { background: ' . $section1_bg . '}' : '';
    $sect2_style = '.section_2 {';
    $sect2_style .= !empty($section2_bg) ? ' background: ' . $section2_bg . ';' : '';
    $sect2_style .= !empty($section2_top_margin) ? ' padding-top: ' . $section2_top_margin . 'px; ' : '';
    $sect2_style .= !empty($section2_bottom_margin) ? ' padding-bottom: ' . $section2_bottom_margin . 'px; ' : '';
    $sect2_style .= '}';
    $css .= !empty($sect2_style) ? $sect2_style : '';
    $constructId = getTemplatePageId('under-construction');
    if (!empty($constructId) && get_the_ID() == $constructId) {
        $construct_thumb = wp_get_attachment_url(get_post_thumbnail_id($constructId));
        $css .= !empty($construct_thumb) ? '#page { background-image: url( ' . $construct_thumb . ' ) }' : '';
    }
    if (!empty($css)) {
        addThemeCustomStyle($css);
    }
    return getThemeCustomStyles();
}
<?php

/*
 * The template for displaying "Page 404"
 * 
 * @package spotlight
*/
$page_id = getTemplatePageId('404');
$post_thumb = wp_get_attachment_url(get_post_thumbnail_id($page_id));
?>
<section class="post no_margin post404<?php 
echo !empty($post_thumb) ? ' post_thumb' : '';
?>
" style="background-image: url(<?php 
echo $post_thumb;
?>
);">
	<div class="container">
		<article class="post_content">
			<div class="page404">
				<div class="titleError"><?php 
_e('404', 'themerex');
?>
</div>
				<div class="error_page_wrap">
					<div class="h2"><?php 
_e('The requested page cannot be found', 'themerex');
?>
</div>
					<p><?php 
_e('Go back, or return to <a href="' . home_url() . '">' . home_url() . '</a> to choose a new page.', 'themerex');