*/
/**
* This function return a value of given theme option name from database.
*
* @since 1.0.0
*
* @param string $option Theme option to return.
* @return mixed The value of theme option.
*/
function gridpal_get_option($option) {
$gridpal_options = get_option('gridpal_options');
if ((is_array($gridpal_options)) && (array_key_exists($option, $gridpal_options))) {
return $gridpal_options[$option];
}
else {
return '';
}
}
function gridpal_is_option_set($option) {
$gridpal_options = get_option('gridpal_options');
if ((is_array($gridpal_options)) && (array_key_exists($option, $gridpal_options))) {
return true;
} else {
return false;
}
}
if ( ! function_exists( 'gridpal_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function gridpal_setup() {
global $wp_version;
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on GridPal, use a find and replace
* to change 'gridpal' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'gridpal', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'gridpal-1218w-autoh-image', 1218, 9999, false );
add_image_size( 'gridpal-680w-autoh-image', 680, 9999, false );
add_image_size( 'gridpal-480w-autoh-image', 480, 9999, false );
}
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__('Primary Menu', 'gridpal'),
'secondary' => esc_html__('Secondary Menu', 'gridpal')
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
$markup = array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' );
add_theme_support( 'html5', $markup );
add_theme_support( 'custom-logo', array(
'height' => 37,
'width' => 280,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
// Support for Custom Header
add_theme_support( 'custom-header', apply_filters( 'gridpal_custom_header_args', array(
'default-image' => '',
'default-text-color' => 'ffffff',
'width' => 1920,
'height' => 400,
'flex-width' => true,
'flex-height' => true,
'wp-head-callback' => 'gridpal_header_style',
'uploads' => true,
) ) );
// Set up the WordPress core custom background feature.
$background_args = array(
'default-color' => 'efefef',
'default-image' => get_template_directory_uri() .'/assets/images/background.jpg',
'default-repeat' => 'repeat',
'default-position-x' => 'left',
'default-position-y' => 'top',
'default-size' => 'auto',
'default-attachment' => 'fixed',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => 'admin_head_callback_func',
'admin-preview-callback' => 'admin_preview_callback_func',
);
add_theme_support( 'custom-background', apply_filters( 'gridpal_custom_background_args', $background_args) );
// Support for Custom Editor Style
add_editor_style( 'css/editor-style.css' );
}
endif;
add_action( 'after_setup_theme', 'gridpal_setup' );
/**
* Layout Functions
*/
function gridpal_hide_footer_widgets() {
$hide_footer_widgets = FALSE;
if ( gridpal_get_option('hide_footer_widgets') ) {
$hide_footer_widgets = TRUE;
}
return apply_filters( 'gridpal_hide_footer_widgets', $hide_footer_widgets );
}
function gridpal_is_header_content_active() {
$header_content_active = TRUE;
if ( gridpal_get_option('hide_header_content') ) {
$header_content_active = FALSE;
}
return apply_filters( 'gridpal_is_header_content_active', $header_content_active );
}
function gridpal_is_primary_menu_active() {
$primary_menu_active = TRUE;
if ( gridpal_get_option('disable_primary_menu') ) {
$primary_menu_active = FALSE;
}
return apply_filters( 'gridpal_is_primary_menu_active', $primary_menu_active );
}
function gridpal_is_menu_social_bar_active() {
$menu_social_bar_active = TRUE;
if ( gridpal_get_option('disable_menu_social_bar') ) {
$menu_social_bar_active = FALSE;
}
return apply_filters( 'gridpal_is_menu_social_bar_active', $menu_social_bar_active );
}
function gridpal_is_secondary_menu_active() {
$secondary_menu_active = TRUE;
if ( gridpal_get_option('disable_secondary_menu') ) {
$secondary_menu_active = FALSE;
}
return apply_filters( 'gridpal_is_secondary_menu_active', $secondary_menu_active );
}
function gridpal_is_social_buttons_active() {
$social_buttons_active = TRUE;
if ( gridpal_get_option('hide_header_social_buttons') ) {
$social_buttons_active = FALSE;
}
return apply_filters( 'gridpal_is_social_buttons_active', $social_buttons_active );
}
function gridpal_is_fitvids_active() {
$fitvids_active = TRUE;
if ( gridpal_get_option('disable_fitvids') ) {
$fitvids_active = FALSE;
}
return apply_filters( 'gridpal_is_fitvids_active', $fitvids_active );
}
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function gridpal_content_width() {
$content_width = 680;
if ( is_page_template( array( 'template-full-width-page.php', 'template-full-width-post.php' ) ) ) {
$content_width = 1218;
}
if ( is_404() ) {
$content_width = 1218;
}
$GLOBALS['content_width'] = apply_filters( 'gridpal_content_width', $content_width ); /* phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedVariableFound */
}
add_action( 'template_redirect', 'gridpal_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function gridpal_widgets_init() {
register_sidebar(array(
'id' => 'gridpal-sidebar-one',
'name' => esc_html__( 'Sidebar 1 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located on the left-hand side of your web page.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-sidebar-two',
'name' => esc_html__( 'Sidebar 2 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located on the right-hand side of your web page.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-fullwidth-widgets',
'name' => esc_html__( 'Top Full Width Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-fullwidth-widgets',
'name' => esc_html__( 'Top Full Width Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-top-widgets',
'name' => esc_html__( 'Above Content Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-top-widgets',
'name' => esc_html__( 'Above Content Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-left-top-widgets',
'name' => esc_html__( 'Top Left Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the left top of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-left-top-widgets',
'name' => esc_html__( 'Top Left Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the left top of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-right-top-widgets',
'name' => esc_html__( 'Top Right Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the right top of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-right-top-widgets',
'name' => esc_html__( 'Top Right Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the right top of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-bottom-widgets',
'name' => esc_html__( 'Below Content Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-bottom-widgets',
'name' => esc_html__( 'Below Content Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-home-fullwidth-bottom-widgets',
'name' => esc_html__( 'Bottom Full Width Widgets (Default HomePage)', 'gridpal' ),
'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-fullwidth-bottom-widgets',
'name' => esc_html__( 'Bottom Full Width Widgets (Everywhere)', 'gridpal' ),
'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on every page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-single-post-bottom-widgets',
'name' => esc_html__( 'Single Post Bottom Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located at the bottom of single post of any post type (except attachments and pages).', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-top-footer',
'name' => esc_html__( 'Footer Top Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located on the top of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-footer-1',
'name' => esc_html__( 'Footer 1 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is the column 1 of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-footer-2',
'name' => esc_html__( 'Footer 2 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is the column 2 of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-footer-3',
'name' => esc_html__( 'Footer 3 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is the column 3 of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-footer-4',
'name' => esc_html__( 'Footer 4 Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is the column 4 of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-bottom-footer',
'name' => esc_html__( 'Footer Bottom Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located on the bottom of the footer of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
register_sidebar(array(
'id' => 'gridpal-404-widgets',
'name' => esc_html__( '404 Page Widgets', 'gridpal' ),
'description' => esc_html__( 'This widget area is located on the 404(not found) page of your website.', 'gridpal' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
'));
}
add_action( 'widgets_init', 'gridpal_widgets_init' );
function gridpal_sidebar_one_widgets() {
dynamic_sidebar( 'gridpal-sidebar-one' );
}
function gridpal_sidebar_two_widgets() {
dynamic_sidebar( 'gridpal-sidebar-two' );
}
function gridpal_top_wide_widgets() { ?>