first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* Sample implementation of the Custom Header feature
*
* You can add an optional custom header image to header.php like so ...
*
<?php the_header_image_tag(); ?>
*
* @link https://developer.wordpress.org/themes/functionality/custom-headers/
*
* @package Water Delivery
*/
/**
* Set up the WordPress core custom header feature.
*
* @uses water_delivery_header_style()
*/
function water_delivery_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'water_delivery_custom_header_args', array(
'default-image' => '',
'default-text-color' => '8373CE',
'width' => 1920,
'height' => 1080,
'flex-height' => true,
'wp-head-callback' => 'water_delivery_header_style',
) ) );
// Register default headers.
register_default_headers( array(
'default-banner' => array(
'url' => '%s/assets/images/default-header.jpg',
'thumbnail_url' => '%s/assets/images/default-header.jpg',
'description' => esc_html_x( 'Default Banner', 'header image description', 'water-delivery' ),
),
) );
}
add_action( 'after_setup_theme', 'water_delivery_custom_header_setup' );
function water_delivery_header_style() {
$header_text_color = get_header_textcolor();
/*
* If no custom options for text are set, let's bail.
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: HEADER_TEXTCOLOR.
*/
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
return;
}
// If we get this far, we have custom styles. Let's do this.
// Has the text been hidden?
if ( ! display_header_text() ) :
$custom_css = ".site-title,
.site-description {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
}";
// If the user has set a custom color for the text use that.
else :
$custom_css = ".site-title a,
.site-description {
color: #" . esc_attr( $header_text_color ) . "}";
endif;
wp_add_inline_style( 'water-delivery-style', $custom_css );
}
add_action( 'wp_enqueue_scripts', 'water_delivery_header_style' );

View File

@@ -0,0 +1,57 @@
<?php
/**
* Water Delivery Theme Customizer
*
* @package Water Delivery
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function water_delivery_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
// Register custom section types.
$wp_customize->register_section_type( 'water_delivery_Customize_Section_Upsell' );
// Load customize sanitize.
include get_template_directory() . '/inc/customizer/sanitize.php';
// Load customize sanitize.
include get_template_directory() . '/inc/customizer/active-callback.php';
// Load topbar sections option.
include get_template_directory() . '/inc/customizer/topbar.php';
// Load header sections option.
include get_template_directory() . '/inc/customizer/theme-section.php';
// Load home page sections option.
include get_template_directory() . '/inc/customizer/home-section.php';
}
add_action( 'customize_register', 'water_delivery_customize_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function water_delivery_customize_preview_js() {
wp_enqueue_script( 'water_delivery_customizer', get_template_directory_uri() . '/inc/customizer/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'water_delivery_customize_preview_js' );
/**
*
*/
function water_delivery_customize_backend_scripts() {
wp_enqueue_style( 'water-delivery-fontawesome-all', get_template_directory_uri() . '/assets/css/all.css' );
wp_enqueue_style( 'water-delivery-admin-customizer-style', get_template_directory_uri() . '/inc/customizer/css/customizer-style.css' );
wp_enqueue_script( 'water-delivery-admin-customizer', get_template_directory_uri() . '/inc/customizer/js/customizer-script.js', array( 'jquery', 'customize-controls' ), '20151215', true );
}
add_action( 'customize_controls_enqueue_scripts', 'water_delivery_customize_backend_scripts', 10 );

View File

@@ -0,0 +1,90 @@
<?php
/**
* Active callback functions.
*
* @package Water Delivery
*/
function water_delivery_featured_slider_active( $control ) {
if( $control->manager->get_setting( 'theme_options[enable_featured_slider_section]' )->value() == true ) {
return true;
}else{
return false;
}
}
function water_delivery_featured_slider_page( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_slider_content_type]' )->value();
return ( water_delivery_featured_slider_active( $control ) && ( 'featured_slider_page' == $content_type ) );
}
function water_delivery_featured_slider_post( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_slider_content_type]' )->value();
return ( water_delivery_featured_slider_active( $control ) && ( 'featured_slider_post' == $content_type ) );
}
function water_delivery_featured_services_active( $control ) {
if( $control->manager->get_setting( 'theme_options[enable_featured_services_section]' )->value() == true ) {
return true;
}else{
return false;
}
}
function water_delivery_featured_services_page( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_services_content_type]' )->value();
return ( water_delivery_featured_services_active( $control ) && ( 'featured_services_page' == $content_type ) );
}
function water_delivery_featured_services_post( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_services_content_type]' )->value();
return ( water_delivery_featured_services_active( $control ) && ( 'featured_services_post' == $content_type ) );
}
function water_delivery_featured_features_active( $control ) {
if( $control->manager->get_setting( 'theme_options[enable_featured_features_section]' )->value() == true ) {
return true;
}else{
return false;
}
}
function water_delivery_featured_features_page( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_features_content_type]' )->value();
return ( water_delivery_featured_features_active( $control ) && ( 'featured_features_page' == $content_type ) );
}
function water_delivery_featured_features_post( $control ) {
$content_type = $control->manager->get_setting( 'theme_options[featured_features_content_type]' )->value();
return ( water_delivery_featured_features_active( $control ) && ( 'featured_features_post' == $content_type ) );
}
function water_delivery_featured_posts_active( $control ) {
if( $control->manager->get_setting( 'theme_options[enable_featured_posts_section]' )->value() == true ) {
return true;
}else{
return false;
}
}
/**
* Active Callback for top bar section
*/
function water_delivery_contact_info_ac( $control ) {
$show_contact_info = $control->manager->get_setting( 'theme_options[show_header_contact_info]')->value();
$control_id = $control->id;
if ( $control_id == 'theme_options[header_phone]' && $show_contact_info ) return true;
return false;
}
function water_delivery_social_links_active( $control ) {
if( $control->manager->get_setting( 'theme_options[show_header_social_links]' )->value() == true ) {
return true;
}else{
return false;
}
}

View File

@@ -0,0 +1,206 @@
/**
* Custom Css for backend
*
* @package Water Delivery
*/
#water-delivery-img-container li {
padding: 3px;
}
#water-delivery-img-container .water-delivery-radio-img-selected {
border: 3px solid #dd3333;
}
/**
* Custom Css for backend
*
* Repeater Text
*
*/
.customize-control-repeater-text .repeater-text-fields .set {
margin-bottom: 5px;
padding-right: 15px;
position: relative;
}
.customize-control-repeater-text .repeater-text-fields input {
margin-bottom: 5px!important;
}
.customize-control-repeater-text .btn-remove-field {
color: red;
position: absolute;
right: -7px;
top: 3px;
}
.customize-control-repeater-text .btn-remove-field span {
text-decoration: none;
}
.customize-control-repeater-text .btn-remove-field:active,
.customize-control-repeater-text .btn-remove-field:focus {
outline: none;
-webkit-box-shadow: none;
box-shadow: none;
}
#customize-control-theme_options-enable_frontpage_content span.customize-inside-control-row {
width: 100%;
}
#customize-control-theme_options-enable_frontpage_content label {
width: 52px;
position: relative;
}
input[type="range"] {
width: 100%;
background-color: #033b62;
-webkit-appearance: none;
height: 3px;
border-radius: 5px;
outline: none;
}
.customize-control-radio-image #water-delivery-img-container {
display: flex;
align-items: center;
}
.customize-control-title {
margin-bottom: 10px;
}
#icons-list-wrapper {
display: none;
position: fixed;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 3000000;
background-color: rgb(0 0 0 / 80%);
}
#icons-list-wrapper.active {
display: block !important;
}
#icons-list-wrapper .icons-list {
background-color: #fff;
padding: 30px 30px 0;
max-width: 1000px;
width: 90%;
height: 70%;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: auto;
z-index: 1;
}
#icons-list-wrapper .icons-list li {
width: 89px;
height: 89px;
line-height: 110px;
text-align: center;
background: #f0f0f1;
cursor: pointer;
margin: 10px;
box-shadow: inset 0 0 15px rgb(0 0 0 / 10%), inset 0 0 0 1px rgb(0 0 0 / 5%);
}
#icons-list-wrapper .icons-list ul {
display: flex;
flex-wrap: wrap;
}
#icons-list-wrapper .icons-list li.active {
box-shadow: inset 0 0 2px 3px #fff, inset 0 0 0 7px #4f94d4;
outline: 2px solid transparent;
outline-offset: -6px;
}
#icons-list-wrapper .icons-list i {
font-size: 38px;
}
#icons-list-wrapper .save-icon,
#icons-list-wrapper .close-button {
font-size: 14px;
line-height: 28px;
padding: 5px 20px;
display: inline-block;
background: #2271b1;
border-color: #2271b1;
color: #fff;
cursor: pointer;
border-width: 1px;
border-style: solid;
border-radius: 3px;
margin-left: 10px;
}
#icons-list-wrapper .close-button {
background: #e91e63;
border-color: #e91e63;
}
#icons-list-wrapper .save-icon:hover,
#icons-list-wrapper .save-icon:focus {
background: #135e96;
border-color: #135e96;
color: #fff;
}
#icons-list-wrapper .close-button:hover,
#icons-list-wrapper .close-button:focus {
background: #da0950;
border-color: #da0950;
color: #fff;
}
#icons-list-wrapper .action-buttons {
position: sticky;
bottom: -1px;
width: 100%;
background-color: #fff;
padding: 20px 0;
}
.customize-control {
padding: 15px;
width: 88%;
background-color: #fff;
box-shadow: 0 0 10px rgb(0 0 0 / 5%);
}
.control-section .accordion-section-title,
.customize-pane-child .accordion-section-title {
padding: 14px 10px 14px 15px;
}
input[type=color],
input[type=date],
input[type=datetime-local],
input[type=datetime],
input[type=email],
input[type=month],
input[type=number],
input[type=password],
input[type=search],
input[type=tel],
input[type=text],
input[type=time],
input[type=url],
input[type=week],
select {
height: 40px;
padding: 15px;
}
textarea {
padding: 15px;
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* Default theme options.
*
* @package Water Delivery
*/
if ( ! function_exists( 'water_delivery_get_default_theme_options' ) ) :
/**
* Get default theme options.
*
* @since 1.0.0
*
* @return array Default theme options.
*/
function water_delivery_get_default_theme_options() {
$defaults = array();
// Top Bar
$defaults['show_header_contact_info'] = false;
$defaults['show_header_social_links'] = false;
$defaults['header_social_links'] = array();
// Front Page Content
$defaults['enable_frontpage_content'] = true;
// Slider Section
$defaults['enable_featured_slider_section'] = false;
$defaults['featured_slider_content_type'] = 'featured_slider_page';
$defaults['featured_slider_category_readmore_text'] = esc_html__('Read More','water-delivery');
$defaults['data_slick_speed'] = 1000;
$defaults['data_slick_infinite'] = 1;
$defaults['data_slick_dots'] = 1;
$defaults['data_slick_arrows'] = 1;
$defaults['data_slick_autoplay'] = 0;
$defaults['data_slick_draggable'] = 1;
$defaults['data_slick_fade'] = 1;
$defaults['number_of_featured_slider_items'] = 6;
// Services Section
$defaults['enable_featured_services_section'] = false;
$defaults['featured_services_section_title'] = 'Services';
$defaults['number_of_featured_services_items'] = 6;
$defaults['featured_services_column'] = 'col-3';
$defaults['featured_services_content_type'] = 'featured_services_page';
// Features Section
$defaults['enable_featured_features_section'] = false;
$defaults['featured_features_section_title'] = 'Features';
$defaults['number_of_featured_features_items'] = 6;
$defaults['featured_features_column'] = 'col-4';
$defaults['featured_features_content_type'] = 'featured_features_page';
// Theme Options
$defaults['show_header_image'] = 'header-image-enable';
$defaults['show_page_title'] = 'page-title-enable';
$defaults['layout_options_blog'] = 'no-sidebar';
$defaults['layout_options_archive'] = 'no-sidebar';
$defaults['layout_options_page'] = 'no-sidebar';
$defaults['layout_options_single'] = 'right-sidebar';
$defaults['excerpt_length'] = 25;
$defaults['readmore_text'] = esc_html__('Learn More','water-delivery');
$defaults['your_latest_posts_title'] = esc_html__('Blog','water-delivery');
//Footer section
$defaults['copyright_text'] = esc_html__( 'Copyright &copy; All rights reserved.', 'water-delivery' );
// Pass through filter.
$defaults = apply_filters( 'water_delivery_filter_default_theme_options', $defaults );
return $defaults;
}
endif;
/**
* Get theme options
*/
if ( ! function_exists( 'water_delivery_get_option' ) ) :
/**
* Get theme option
*
* @since 1.0.0
*
* @param string $key Option key.
* @return mixed Option value.
*/
function water_delivery_get_option( $key ) {
$default_options = water_delivery_get_default_theme_options();
if ( empty( $key ) ) {
return;
}
$theme_options = (array)get_theme_mod( 'theme_options' );
$theme_options = wp_parse_args( $theme_options, $default_options );
$value = null;
if ( isset( $theme_options[ $key ] ) ) {
$value = $theme_options[ $key ];
}
return $value;
}
endif;

View File

@@ -0,0 +1,25 @@
<?php
/**
* Home Page Options.
*
* @package Water Delivery
*/
$default = water_delivery_get_default_theme_options();
// Add Panel.
$wp_customize->add_panel( 'home_page_panel',
array(
'title' => __( 'Homepage Sections', 'water-delivery' ),
'priority' => 130,
'capability' => 'edit_theme_options',
)
);
/**
* Section Customizer Options.
*/
require get_template_directory() . '/inc/customizer/home-sections/featured-slider.php';
require get_template_directory() . '/inc/customizer/home-sections/featured-features.php';
require get_template_directory() . '/inc/customizer/home-sections/featured-services.php';

View File

@@ -0,0 +1,193 @@
<?php
/**
* Features Section options.
*
* @package Water Delivery
*/
$default = water_delivery_get_default_theme_options();
// Features Section
$wp_customize->add_section( 'section_featured_features',
array(
'title' => __( 'Features Section', 'water-delivery' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'panel' => 'home_page_panel',
)
);
// Enable Section
$wp_customize->add_setting('theme_options[enable_featured_features_section]',
array(
'default' => $default['enable_featured_features_section'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[enable_featured_features_section]',
array(
'label' => __('Enable Section', 'water-delivery'),
'section' => 'section_featured_features',
'settings' => 'theme_options[enable_featured_features_section]',
'type' => 'checkbox',
)
);
$wp_customize->add_setting( 'theme_options[featured_features_section_title]',
array(
'capability' => 'edit_theme_options',
'default' => $default['featured_features_section_title'],
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control( 'theme_options[featured_features_section_title]',
array(
'type' => 'text',
'section' => 'section_featured_features',
'label' => __( 'Section Title', 'water-delivery' ),
)
);
// Items
$wp_customize->add_setting('theme_options[number_of_featured_features_items]',
array(
'default' => $default['number_of_featured_features_items'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_number_range'
)
);
$wp_customize->add_control('theme_options[number_of_featured_features_items]',
array(
'label' => __('Items (Max: 6)', 'water-delivery'),
'section' => 'section_featured_features',
'settings' => 'theme_options[number_of_featured_features_items]',
'type' => 'number',
'active_callback' => 'water_delivery_featured_features_active',
'input_attrs' => array(
'min' => 1,
'max' => 6,
'step' => 1,
),
)
);
// Column
$wp_customize->add_setting('theme_options[featured_features_column]',
array(
'default' => $default['featured_features_column'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[featured_features_column]',
array(
'label' => __('Column', 'water-delivery'),
'section' => 'section_featured_features',
'settings' => 'theme_options[featured_features_column]',
'type' => 'radio-image',
'active_callback' => 'water_delivery_featured_features_active',
'choices' => array(
'col-1' => esc_url(get_template_directory_uri()) . '/assets/images/column-1.jpg',
'col-2' => esc_url(get_template_directory_uri()) . '/assets/images/column-2.jpg',
'col-3' => esc_url(get_template_directory_uri()) . '/assets/images/column-3.jpg',
'col-4' => esc_url(get_template_directory_uri()) . '/assets/images/column-4.jpg',
'col-5' => esc_url(get_template_directory_uri()) . '/assets/images/column-5.jpg',
'col-6' => esc_url(get_template_directory_uri()) . '/assets/images/column-6.jpg',
),
))
);
// Content Type
$wp_customize->add_setting('theme_options[featured_features_content_type]',
array(
'default' => $default['featured_features_content_type'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control('theme_options[featured_features_content_type]',
array(
'label' => __('Content Type', 'water-delivery'),
'section' => 'section_featured_features',
'settings' => 'theme_options[featured_features_content_type]',
'type' => 'select',
'active_callback' => 'water_delivery_featured_features_active',
'choices' => array(
'featured_features_page' => __('Page','water-delivery'),
'featured_features_post' => __('Post','water-delivery'),
),
)
);
$number_of_featured_features_items = water_delivery_get_option( 'number_of_featured_features_items' );
for( $i=1; $i<=$number_of_featured_features_items; $i++ ) {
// Icon
$wp_customize->add_setting('theme_options[featured_features_icon_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control('theme_options[featured_features_icon_'.$i.']',
array(
'label' => sprintf( __('Icon #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_features',
'settings' => 'theme_options[featured_features_icon_'.$i.']',
'active_callback' => 'water_delivery_featured_features_active',
'type' => 'text',
)
);
// Page
$wp_customize->add_setting('theme_options[featured_features_page_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_features_page_'.$i.']',
array(
'label' => sprintf( __('Page #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_features',
'settings' => 'theme_options[featured_features_page_'.$i.']',
'type' => 'dropdown-pages',
'active_callback' => 'water_delivery_featured_features_page',
)
);
// Post
$wp_customize->add_setting('theme_options[featured_features_post_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_features_post_'.$i.']',
array(
'label' => sprintf( __('Post #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_features',
'settings' => 'theme_options[featured_features_post_'.$i.']',
'type' => 'select',
'choices' => water_delivery_dropdown_posts(),
'active_callback' => 'water_delivery_featured_features_post',
)
);
}

View File

@@ -0,0 +1,174 @@
<?php
/**
* Services Section options.
*
* @package Water Delivery
*/
$default = water_delivery_get_default_theme_options();
// Services Section
$wp_customize->add_section( 'section_featured_services',
array(
'title' => __( 'Services Section', 'water-delivery' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'panel' => 'home_page_panel',
)
);
// Enable Section
$wp_customize->add_setting('theme_options[enable_featured_services_section]',
array(
'default' => $default['enable_featured_services_section'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[enable_featured_services_section]',
array(
'label' => __('Enable Section', 'water-delivery'),
'section' => 'section_featured_services',
'settings' => 'theme_options[enable_featured_services_section]',
'type' => 'checkbox',
)
);
$wp_customize->add_setting( 'theme_options[featured_services_section_title]',
array(
'capability' => 'edit_theme_options',
'default' => $default['featured_services_section_title'],
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control( 'theme_options[featured_services_section_title]',
array(
'type' => 'text',
'section' => 'section_featured_services',
'label' => __( 'Section Title', 'water-delivery'),
)
);
// Items
$wp_customize->add_setting('theme_options[number_of_featured_services_items]',
array(
'default' => $default['number_of_featured_services_items'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_number_range'
)
);
$wp_customize->add_control('theme_options[number_of_featured_services_items]',
array(
'label' => __('Items (Max: 6)', 'water-delivery'),
'section' => 'section_featured_services',
'settings' => 'theme_options[number_of_featured_services_items]',
'type' => 'number',
'active_callback' => 'water_delivery_featured_services_active',
'input_attrs' => array(
'min' => 1,
'max' => 6,
'step' => 1,
),
)
);
// Column
$wp_customize->add_setting('theme_options[featured_services_column]',
array(
'default' => $default['featured_services_column'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[featured_services_column]',
array(
'label' => __('Column', 'water-delivery'),
'section' => 'section_featured_services',
'settings' => 'theme_options[featured_services_column]',
'type' => 'radio-image',
'active_callback' => 'water_delivery_featured_services_active',
'choices' => array(
'col-1' => esc_url(get_template_directory_uri()) . '/assets/images/column-1.jpg',
'col-2' => esc_url(get_template_directory_uri()) . '/assets/images/column-2.jpg',
'col-3' => esc_url(get_template_directory_uri()) . '/assets/images/column-3.jpg',
'col-4' => esc_url(get_template_directory_uri()) . '/assets/images/column-4.jpg',
'col-5' => esc_url(get_template_directory_uri()) . '/assets/images/column-5.jpg',
'col-6' => esc_url(get_template_directory_uri()) . '/assets/images/column-6.jpg',
),
))
);
// Content Type
$wp_customize->add_setting('theme_options[featured_services_content_type]',
array(
'default' => $default['featured_services_content_type'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control('theme_options[featured_services_content_type]',
array(
'label' => __('Content Type', 'water-delivery'),
'section' => 'section_featured_services',
'settings' => 'theme_options[featured_services_content_type]',
'type' => 'select',
'active_callback' => 'water_delivery_featured_services_active',
'choices' => array(
'featured_services_page' => __('Page','water-delivery'),
'featured_services_post' => __('Post','water-delivery'),
),
)
);
$number_of_featured_services_items = water_delivery_get_option( 'number_of_featured_services_items' );
for( $i=1; $i<=$number_of_featured_services_items; $i++ ) {
// Page
$wp_customize->add_setting('theme_options[featured_services_page_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_services_page_'.$i.']',
array(
'label' => sprintf( __('Page #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_services',
'settings' => 'theme_options[featured_services_page_'.$i.']',
'type' => 'dropdown-pages',
'active_callback' => 'water_delivery_featured_services_page',
)
);
// Post
$wp_customize->add_setting('theme_options[featured_services_post_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_services_post_'.$i.']',
array(
'label' => sprintf( __('Post #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_services',
'settings' => 'theme_options[featured_services_post_'.$i.']',
'type' => 'select',
'choices' => water_delivery_dropdown_posts(),
'active_callback' => 'water_delivery_featured_services_post',
)
);
}

View File

@@ -0,0 +1,275 @@
<?php
/**
* Slider options.
*
* @package Water Delivery
*/
$default = water_delivery_get_default_theme_options();
// Slider Section
$wp_customize->add_section( 'section_featured_slider',
array(
'title' => __( 'Slider Section', 'water-delivery' ),
'priority' => 100,
'capability' => 'edit_theme_options',
'panel' => 'home_page_panel',
)
);
// Enable Section
$wp_customize->add_setting('theme_options[enable_featured_slider_section]',
array(
'default' => $default['enable_featured_slider_section'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[enable_featured_slider_section]',
array(
'label' => __('Enable Section', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[enable_featured_slider_section]',
'type' => 'checkbox',
)
);
// Items
$wp_customize->add_setting('theme_options[number_of_featured_slider_items]',
array(
'default' => $default['number_of_featured_slider_items'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_number_range'
)
);
$wp_customize->add_control('theme_options[number_of_featured_slider_items]',
array(
'label' => __('Items (Max: 6)', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[number_of_featured_slider_items]',
'type' => 'number',
'active_callback' => 'water_delivery_featured_slider_active',
'input_attrs' => array(
'min' => 1,
'max' => 6,
'step' => 1,
),
)
);
// Content Type
$wp_customize->add_setting('theme_options[featured_slider_content_type]',
array(
'default' => $default['featured_slider_content_type'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control('theme_options[featured_slider_content_type]',
array(
'label' => __('Content Type', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[featured_slider_content_type]',
'type' => 'select',
'active_callback' => 'water_delivery_featured_slider_active',
'choices' => array(
'featured_slider_page' => __('Page','water-delivery'),
'featured_slider_post' => __('Post','water-delivery'),
),
)
);
$number_of_featured_slider_items = water_delivery_get_option( 'number_of_featured_slider_items' );
for( $i=1; $i<=$number_of_featured_slider_items; $i++ ) {
// Page
$wp_customize->add_setting('theme_options[featured_slider_page_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_slider_page_'.$i.']',
array(
'label' => sprintf( __('Select Page #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_slider',
'settings' => 'theme_options[featured_slider_page_'.$i.']',
'type' => 'dropdown-pages',
'active_callback' => 'water_delivery_featured_slider_page',
)
);
// Posts
$wp_customize->add_setting('theme_options[featured_slider_post_'.$i.']',
array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_dropdown_pages'
)
);
$wp_customize->add_control('theme_options[featured_slider_post_'.$i.']',
array(
'label' => sprintf( __('Select Post #%1$s', 'water-delivery'), $i),
'section' => 'section_featured_slider',
'settings' => 'theme_options[featured_slider_post_'.$i.']',
'type' => 'select',
'choices' => water_delivery_dropdown_posts(),
'active_callback' => 'water_delivery_featured_slider_post',
)
);
}
// Slider Speed
$wp_customize->add_setting('theme_options[data_slick_speed]',
array(
'default' => $default['data_slick_speed'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_number_range'
)
);
$wp_customize->add_control('theme_options[data_slick_speed]',
array(
'label' => __('Delay Speed (Max: 5000)', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_speed]',
'type' => 'number',
'active_callback' => 'water_delivery_featured_slider_active',
'input_attrs' => array(
'min' => 0,
'max' => 5000,
'step' => 100,
),
)
);
// Slider Infinite
$wp_customize->add_setting('theme_options[data_slick_infinite]',
array(
'default' => $default['data_slick_infinite'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_infinite]',
array(
'label' => __('Infinite', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_infinite]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);
// Slider Dots
$wp_customize->add_setting('theme_options[data_slick_dots]',
array(
'default' => $default['data_slick_dots'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_dots]',
array(
'label' => __('Dots', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_dots]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);
// Slider Arrows
$wp_customize->add_setting('theme_options[data_slick_arrows]',
array(
'default' => $default['data_slick_arrows'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_arrows]',
array(
'label' => __('Arrows', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_arrows]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);
// Slider Autoplay
$wp_customize->add_setting('theme_options[data_slick_autoplay]',
array(
'default' => $default['data_slick_autoplay'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_autoplay]',
array(
'label' => __('Autoplay', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_autoplay]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);
// Slider Draggable
$wp_customize->add_setting('theme_options[data_slick_draggable]',
array(
'default' => $default['data_slick_draggable'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_draggable]',
array(
'label' => __('Draggable', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_draggable]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);
// Slider Fade
$wp_customize->add_setting('theme_options[data_slick_fade]',
array(
'default' => $default['data_slick_fade'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_checkbox'
)
);
$wp_customize->add_control('theme_options[data_slick_fade]',
array(
'label' => __('Fade', 'water-delivery'),
'section' => 'section_featured_slider',
'settings' => 'theme_options[data_slick_fade]',
'type' => 'checkbox',
'active_callback' => 'water_delivery_featured_slider_active',
)
);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
/**
* File customizer.js.
*
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
( function( $ ) {
// Site title and description.
wp.customize( 'blogname', function( value ) {
value.bind( function( to ) {
$( '.site-title a' ).text( to );
} );
} );
wp.customize( 'blogdescription', function( value ) {
value.bind( function( to ) {
$( '.site-description' ).text( to );
} );
} );
// Header text color.
wp.customize( 'header_textcolor', function( value ) {
value.bind( function( to ) {
if ( 'blank' === to ) {
$( '.site-title, .site-description' ).css( {
'clip': 'rect(1px, 1px, 1px, 1px)',
'position': 'absolute'
} );
} else {
$( '.site-title, .site-description' ).css( {
'clip': 'auto',
'position': 'relative'
} );
$( '.site-title a, .site-description' ).css( {
'color': to
} );
}
} );
} );
} )( jQuery );

View File

@@ -0,0 +1,249 @@
<?php
/**
* Sanitization functions.
*
* @package Water Delivery
*/
if ( ! function_exists( 'water_delivery_sanitize_select' ) ) :
/**
* Sanitize select.
*
* @since 1.0.0
*
*/
function water_delivery_sanitize_select( $input, $setting ) {
// Ensure input is a slug.
$input = sanitize_key( $input );
// Get list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it; otherwise, return the default.
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
endif;
if ( ! function_exists( 'water_delivery_dropdown_pages' ) ) :
function water_delivery_dropdown_pages( $page_id, $setting ) {
// Ensure $input is an absolute integer.
$page_id = absint( $page_id );
// If $page_id is an ID of a published page, return it; otherwise, return the default.
return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}
endif;
if ( ! function_exists( 'water_delivery_dropdown_posts' ) ) :
/**
* Post Dropdown.
*
* @since 1.0.0 *
*/
function water_delivery_dropdown_posts() {
$posts = get_posts( array( 'numberposts' => -1 ) );
$choices = array();
$choices[0] = esc_html__( '--Select--', 'water-delivery' );
foreach ( $posts as $post ) {
$choices[$post->ID] = $post->post_title;
}
return $choices;
}
endif;
if ( ! function_exists( 'water_delivery_sanitize_checkbox' ) ) :
/**
* Sanitize checkbox.
*
* @since 1.0.0
*
*/
function water_delivery_sanitize_checkbox( $checked ) {
return ( ( isset( $checked ) && true === $checked ) ? true : false );
}
endif;
if ( ! function_exists( 'water_delivery_sanitize_number_range' ) ) :
/**
* Sanitize number range.
*
*/
function water_delivery_sanitize_number_range( $input, $setting ) {
// Ensure input is an absolute integer.
$input = absint( $input );
// Get the input attributes associated with the setting.
$atts = $setting->manager->get_control( $setting->id )->input_attrs;
// Get min.
$min = ( isset( $atts['min'] ) ? $atts['min'] : $input );
// Get max.
$max = ( isset( $atts['max'] ) ? $atts['max'] : $input );
// Get Step.
$step = ( isset( $atts['step'] ) ? $atts['step'] : 1 );
// If the input is within the valid range, return it; otherwise, return the default.
return ( $min <= $input && $input <= $max && is_int( $input / $step ) ? $input : $setting->default );
}
endif;
if ( ! function_exists( 'water_delivery_sanitize_textarea_content' ) ) :
/**
* Sanitize textarea content.
*
* @since 1.0.0
*
*/
function water_delivery_sanitize_textarea_content( $input, $setting ) {
return ( stripslashes( wp_filter_post_kses( addslashes( $input ) ) ) );
}
endif;
if ( ! function_exists( 'water_delivery_sanitize_positive_integer' ) ) :
/**
* Sanitize positive integer.
*
* @since 1.0.0
*
* @param int $input Number to sanitize.
* @param WP_Customize_Setting $setting WP_Customize_Setting instance.
* @return int Sanitized number; otherwise, the setting default.
*/
function water_delivery_sanitize_positive_integer( $input, $setting ) {
$input = absint( $input );
// If the input is an positive integer, return it.
// otherwise, return the default.
return ( $input ? $input : $setting->default );
}
endif;
/**
* Image sanitization callback example.
*
* Checks the image's file extension and mime type against a whitelist. If they're allowed,
* send back the filename, otherwise, return the setting default.
*
* - Sanitization: image file extension
* - Control: text, WP_Customize_Image_Control
*
* @see wp_check_filetype() https://developer.wordpress.org/reference/functions/wp_check_filetype/
*
* @param string $image Image filename.
* @param WP_Customize_Setting $setting Setting instance.
* @return string The image filename if the extension is allowed; otherwise, the setting default.
*/
function water_delivery_sanitize_image( $image, $setting ) {
/*
* Array of valid image file types.
*
* The array includes image mime types that are included in wp_get_mime_types()
*/
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'bmp' => 'image/bmp',
'tif|tiff' => 'image/tiff',
'ico' => 'image/x-icon'
);
// Return an array with file extension and mime_type.
$file = wp_check_filetype( $image, $mimes );
// If $image has a valid mime_type, return it; otherwise, return the default.
return ( $file['ext'] ? $image : $setting->default );
}
/**
* Sanitize social links.
*
* @since 1.0.0
*
* @param mixed $input The value to sanitize.
* @param WP_Customize_Setting $setting WP_Customize_Setting instance.
* @return mixed Sanitized value.
*/
function water_delivery_sanitize_social_links( $input, $setting ) {
if ( empty( $input ) ) {
return '';
}
$exploded = explode( '|', $input );
$new_array = array_map( 'esc_url_raw', $exploded );
$output = implode( '|', $new_array );
return $output;
}
if ( ! function_exists( 'water_delivery_sanitize_sortable' ) ) :
/**
* Sanitizes strings in array
* @param $input entered value
* @return sanitized output
*
* @since Water Delivery 1.0
*/
function water_delivery_sanitize_sortable( $input ) {
// Ensure $input is an array.
if ( ! is_array( $input ) )
$input = explode( ',', $input );
$output = array_map( 'sanitize_text_field', $input );
return implode( ',', $output );
}
endif;
/**
* Sanitizes email
* @param $input entered value
* @return sanitized output
*
* @since Creativ Musician 1.0
*/
function water_delivery_sanitize_array_int( $input ) {
// Ensure $input is an url.
$links = array_map( 'absint', $input );
return $links;
}
if ( ! function_exists( 'water_delivery_sanitize_phone_number' ) ) :
/**
* Sanitize Phone number.
*
* @since 1.0.0
*
*/
function water_delivery_sanitize_phone_number( $phone ) {
return preg_replace( '/[^\d+]/', '', $phone );
}
endif;

View File

@@ -0,0 +1,274 @@
<?php
/**
* Theme Options.
*
* @package Water Delivery
*/
$default = water_delivery_get_default_theme_options();
// Add Panel.
$wp_customize->add_panel( 'theme_option_panel',
array(
'title' => __( 'Theme Options', 'water-delivery' ),
'priority' => 150,
'capability' => 'edit_theme_options',
)
);
// Page Title
$wp_customize->add_section('section_page_title',
array(
'title' => __('Page Title', 'water-delivery'),
'panel' => 'theme_option_panel'
)
);
// Show / Hide Page Title
$wp_customize->add_setting( 'theme_options[show_page_title]', array(
'default' => $default['show_page_title'],
'sanitize_callback' => 'water_delivery_sanitize_select',
) );
$wp_customize->add_control( 'theme_options[show_page_title]', array(
'label' => esc_html__( 'Display Page Title', 'water-delivery' ),
'section' => 'section_page_title',
'type' => 'select',
'choices' => array(
'page-title-enable' => 'Yes',
'page-title-disable' => 'No',
),
) );
// Sidebar Layout
$wp_customize->add_section('section_sidebar_layout', array(
'title' => __('Sidebar Layout', 'water-delivery'),
'panel' => 'theme_option_panel'
));
// Blog Layout
$wp_customize->add_setting('theme_options[layout_options_blog]',
array(
'default' => $default['layout_options_blog'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[layout_options_blog]',
array(
'label' => __('Blog Layout', 'water-delivery'),
'section' => 'section_sidebar_layout',
'settings' => 'theme_options[layout_options_blog]',
'type' => 'radio-image',
'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
),
))
);
// Archive Layout
$wp_customize->add_setting('theme_options[layout_options_archive]',
array(
'default' => $default['layout_options_archive'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[layout_options_archive]',
array(
'label' => __('Archive Layout', 'water-delivery'),
'section' => 'section_sidebar_layout',
'settings' => 'theme_options[layout_options_archive]',
'type' => 'radio-image',
'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
),
))
);
// Page Layout
$wp_customize->add_setting('theme_options[layout_options_page]',
array(
'default' => $default['layout_options_page'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[layout_options_page]',
array(
'label' => __('Page Layout', 'water-delivery'),
'section' => 'section_sidebar_layout',
'settings' => 'theme_options[layout_options_page]',
'type' => 'radio-image',
'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
),
))
);
// Single Post Layout
$wp_customize->add_setting('theme_options[layout_options_single]',
array(
'default' => $default['layout_options_single'],
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_select'
)
);
$wp_customize->add_control(new water_delivery_Image_Radio_Control($wp_customize, 'theme_options[layout_options_single]',
array(
'label' => __('Single Post Layout', 'water-delivery'),
'section' => 'section_sidebar_layout',
'settings' => 'theme_options[layout_options_single]',
'type' => 'radio-image',
'choices' => array(
'left-sidebar' => get_template_directory_uri() . '/assets/images/left-sidebar.png',
'right-sidebar' => get_template_directory_uri() . '/assets/images/right-sidebar.png',
'no-sidebar' => get_template_directory_uri() . '/assets/images/no-sidebar.png',
),
))
);
// Excerpt Length
$wp_customize->add_section('section_excerpt_length',
array(
'title' => __('Excerpt Length', 'water-delivery'),
'panel' => 'theme_option_panel'
)
);
$wp_customize->add_setting( 'theme_options[excerpt_length]', array(
'default' => $default['excerpt_length'],
'sanitize_callback' => 'water_delivery_sanitize_number_range',
) );
$wp_customize->add_control( 'theme_options[excerpt_length]', array(
'label' => esc_html__( 'Excerpt Length', 'water-delivery' ),
'section' => 'section_excerpt_length',
'type' => 'number',
'input_attrs' => array( 'min' => 1, 'max' => 200, 'style' => 'width: 80px;' ),
) );
// Blog Settings
$wp_customize->add_section('section_blog_setting',
array(
'title' => __('Blog / Archive Settings', 'water-delivery'),
'panel' => 'theme_option_panel'
)
);
// Blog Title
$wp_customize->add_setting( 'theme_options[your_latest_posts_title]',
array(
'default' => $default['your_latest_posts_title'],
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_textarea_content',
'transport' => 'refresh',
)
);
$wp_customize->add_control( 'theme_options[your_latest_posts_title]',
array(
'label' => __( 'Blog Title', 'water-delivery' ),
'section' => 'section_blog_setting',
'type' => 'text',
)
);
// Blog Button Label
$wp_customize->add_setting( 'theme_options[readmore_text]',
array(
'default' => $default['readmore_text'],
'capability' => 'edit_theme_options',
'sanitize_callback' => 'water_delivery_sanitize_textarea_content',
'transport' => 'refresh',
)
);
$wp_customize->add_control( 'theme_options[readmore_text]',
array(
'label' => __( 'Button Label', 'water-delivery' ),
'section' => 'section_blog_setting',
'type' => 'text',
)
);
// Footer Setting Section starts
$wp_customize->add_section('section_footer',
array(
'title' => __('Footer Setting', 'water-delivery'),
'panel' => 'theme_option_panel'
)
);
// Setting copyright_text.
$wp_customize->add_setting( 'theme_options[copyright_text]',
array(
'default' => $default['copyright_text'],
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'refresh',
)
);
$wp_customize->add_control( 'theme_options[copyright_text]',
array(
'label' => __( 'Copyright Text', 'water-delivery' ),
'section' => 'section_footer',
'type' => 'text',
'priority' => 100,
)
);
// Homepage Static setting and control.
$wp_customize->add_setting( 'theme_options[enable_frontpage_content]', array(
'default' => $default['enable_frontpage_content'],
'sanitize_callback' => 'water_delivery_sanitize_checkbox',
) );
$wp_customize->add_control( 'theme_options[enable_frontpage_content]', array(
'label' => __( 'Enable Content', 'water-delivery' ),
'description' => __( 'Click to enable content on static front page only.', 'water-delivery' ),
'section' => 'static_front_page',
'type' => 'checkbox',
) );
// Show / Hide Frontpage Content
$wp_customize->add_setting( 'theme_options[enable_frontpage_content]', array(
'default' => $default['enable_frontpage_content'],
'sanitize_callback' => 'water_delivery_sanitize_checkbox',
) );
$wp_customize->add_control( 'theme_options[enable_frontpage_content]', array(
'label' => esc_html__( 'Enable Homepage Content', 'water-delivery' ),
'description' => esc_html__( 'Enable content on A static page.', 'water-delivery' ),
'section' => 'static_front_page',
'type' => 'checkbox',
) );
// Show / Hide Header Image
$wp_customize->add_setting( 'theme_options[show_header_image]', array(
'default' => $default['show_header_image'],
'sanitize_callback' => 'water_delivery_sanitize_select',
) );
$wp_customize->add_control( 'theme_options[show_header_image]', array(
'label' => esc_html__( 'Display Header Image', 'water-delivery' ),
'section' => 'header_image',
'type' => 'select',
'choices' => array(
'header-image-enable' => 'Yes',
'header-image-disable' => 'No',
),
) );

View File

@@ -0,0 +1,154 @@
<?php
$default = water_delivery_get_default_theme_options();
/**
* Add Header Top Panel
*/
$wp_customize->add_panel( 'header_top_panel', array(
'title' => __( 'Header Top', 'water-delivery' ),
'priority' => 20,
'capability' => 'edit_theme_options',
) );
/** Header contact info section */
$wp_customize->add_section(
'header_contact_info_section',
array(
'title' => __( 'Contact Info', 'water-delivery' ),
'panel' => 'header_top_panel',
'priority' => 10,
)
);
/** Header contact info control */
$wp_customize->add_setting(
'theme_options[show_header_contact_info]',
array(
'default' => $default['show_header_contact_info'],
'sanitize_callback' => 'water_delivery_sanitize_checkbox',
)
);
$wp_customize->add_control(
'theme_options[show_header_contact_info]',
array(
'label' => __( 'Show Contact Info', 'water-delivery' ),
'section' => 'header_contact_info_section',
'type' => 'checkbox',
)
);
/** Phone */
$wp_customize->add_setting( 'theme_options[header_phone]', array(
'sanitize_callback' => 'water_delivery_sanitize_phone_number',
) );
$wp_customize->add_control(
'theme_options[header_phone]',
array(
'label' => __( 'Phone', 'water-delivery' ),
'description' => __( 'Enter phone number.', 'water-delivery' ),
'section' => 'header_contact_info_section',
'active_callback' => 'water_delivery_contact_info_ac',
)
);
/** Header social links section */
$wp_customize->add_section(
'header_social_links_section',
array(
'title' => __( 'Social Links', 'water-delivery' ),
'panel' => 'header_top_panel',
'priority' => 20,
)
);
/** Header social links control */
$wp_customize->add_setting(
'theme_options[show_header_social_links]',
array(
'default' => $default['show_header_social_links'],
'sanitize_callback' => 'water_delivery_sanitize_checkbox',
)
);
$wp_customize->add_control(
'theme_options[show_header_social_links]',
array(
'label' => __( 'Show Social Links', 'water-delivery' ),
'section' => 'header_social_links_section',
'type' => 'checkbox',
)
);
// Setting social_links.
$wp_customize->add_setting(
'theme_options[social_link_1]',
array(
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'theme_options[social_link_1]',
array(
'label' => __( 'Social Link 1', 'water-delivery' ),
'description' => __( 'Enter valid url.', 'water-delivery' ),
'section' => 'header_social_links_section',
'type' => 'url',
'active_callback' => 'water_delivery_social_links_active',
)
);
$wp_customize->add_setting(
'theme_options[social_link_2]',
array(
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'theme_options[social_link_2]',
array(
'label' => __( 'Social Link 2', 'water-delivery' ),
'description' => __( 'Enter valid url.', 'water-delivery' ),
'section' => 'header_social_links_section',
'type' => 'url',
'active_callback' => 'water_delivery_social_links_active',
)
);
$wp_customize->add_setting(
'theme_options[social_link_3]',
array(
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'theme_options[social_link_3]',
array(
'label' => __( 'Social Link 3', 'water-delivery' ),
'description' => __( 'Enter valid url.', 'water-delivery' ),
'section' => 'header_social_links_section',
'type' => 'url',
'active_callback' => 'water_delivery_social_links_active',
)
);
$wp_customize->add_setting(
'theme_options[social_link_4]',
array(
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
'theme_options[social_link_4]',
array(
'label' => __( 'Social Link 4', 'water-delivery' ),
'description' => __( 'Enter valid url.', 'water-delivery' ),
'section' => 'header_social_links_section',
'type' => 'url',
'active_callback' => 'water_delivery_social_links_active',
)
);

View File

@@ -0,0 +1,160 @@
<?php
/**
* Custom functions that act independently of the theme templates
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package Water Delivery
*/
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function water_delivery_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
if ( is_front_page() && is_home() ) {
$sidebar_layout_blog = water_delivery_get_option('layout_options_blog');
$classes[] = esc_attr( $sidebar_layout_blog );
}
if ( !is_front_page() && is_home() ) {
$sidebar_layout_blog = water_delivery_get_option('layout_options_blog');
$classes[] = esc_attr( $sidebar_layout_blog );
}
if( is_archive() || is_search() || is_404() ) {
$sidebar_layout_archive = water_delivery_get_option('layout_options_archive');
$classes[] = esc_attr( $sidebar_layout_archive );
}
if( is_page() ) {
$sidebar_layout_page = water_delivery_get_option('layout_options_page');
$classes[] = esc_attr( $sidebar_layout_page );
}
if( is_single() ) {
$sidebar_layout_single = water_delivery_get_option('layout_options_single');
$classes[] = esc_attr( $sidebar_layout_single );
}
return $classes;
}
add_filter( 'body_class', 'water_delivery_body_classes' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function water_delivery_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'water_delivery_pingback_header' );
/**
* Function to get Sections
*/
function water_delivery_get_sections() {
$sections = array( 'featured-slider', 'featured-features', 'featured-services' );
$enabled_section = array();
foreach ( $sections as $section ) {
if (false == water_delivery_get_option('disable_'.$section.'_section')){
$enabled_section[] = array(
'id' => $section,
'menu_text' => esc_html( water_delivery_get_option('' . $section . '_menu_title','') ),
);
}
}
return $enabled_section;
}
if ( ! function_exists( 'water_delivery_the_excerpt' ) ) :
/**
* Generate excerpt.
*
* @since 1.0.0
*
* @param int $length Excerpt length in words.
* @param WP_Post $post_obj WP_Post instance (Optional).
* @return string Excerpt.
*/
function water_delivery_the_excerpt( $length = 0, $post_obj = null ) {
global $post;
if ( is_null( $post_obj ) ) {
$post_obj = $post;
}
$length = absint( $length );
if ( 0 === $length ) {
return;
}
$source_content = $post_obj->post_content;
if ( ! empty( $post_obj->post_excerpt ) ) {
$source_content = $post_obj->post_excerpt;
}
$source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content );
$trimmed_content = wp_trim_words( $source_content, $length, '&hellip;' );
return $trimmed_content;
}
endif;
// Customizer Control
if (class_exists('WP_Customize_Control') && ! class_exists( 'water_delivery_Image_Radio_Control' ) ) {
/**
* Customize sidebar layout control.
*/
class water_delivery_Image_Radio_Control extends WP_Customize_Control {
public function render_content() {
if (empty($this->choices))
return;
$name = '_customize-radio-' . $this->id;
?>
<span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
<ul class="controls" id='water-delivery-img-container'>
<?php
foreach ($this->choices as $value => $label) :
$class = ($this->value() == $value) ? 'water-delivery-radio-img-selected water-delivery-radio-img-img' : 'water-delivery-radio-img-img';
?>
<li style="display: inline;">
<label>
<input <?php $this->link(); ?>style = 'display:none' type="radio" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php
$this->link();
checked($this->value(), $value);
?> />
<img src='<?php echo esc_url($label); ?>' class='<?php echo esc_attr($class); ?>' />
</label>
</li>
<?php
endforeach;
?>
</ul>
<?php
}
}
}

View File

@@ -0,0 +1,197 @@
<?php
/**
* Basic theme functions.
*
* This file contains hook functions attached to core hooks.
*
* @package Water Delivery
*/
if( ! function_exists( 'water_delivery_primary_navigation_fallback' ) ) :
/**
* Fallback for primary navigation.
*
* @since 1.0.0
*/
function water_delivery_primary_navigation_fallback() {
echo '<ul>';
echo '<li><a href="' . esc_url( home_url( '/' ) ) . '">' .esc_html__( 'Home', 'water-delivery' ). '</a></li>';
wp_list_pages( array(
'title_li' => '',
'depth' => 1,
'number' => 5,
) );
echo '</ul>';
}
endif;
if ( ! class_exists( 'WP_Customize_Control' ) )
return NULL;
/**
* Class water_delivery_Dropdown_Taxonomies_Control
*/
class water_delivery_Dropdown_Taxonomies_Control extends WP_Customize_Control {
/**
* Render the control's content.
*
* @since 3.4.0
*/
public function render_content() {
$dropdown = wp_dropdown_categories(
array(
'name' => 'water-delivery-dropdown-categories-' . $this->id,
'echo' => 0,
'show_option_none' => __( '&mdash; Select &mdash;', 'water-delivery' ),
'option_none_value' => '0',
'selected' => $this->value(),
'hide_empty' => 0,
)
);
$dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown );
printf(
'<label class="customize-control-select"><span class="customize-control-title">%s</span> %s <span class="description customize-control-description"></span>%s </label>',
esc_html($this->label),
esc_html($this->description),
$dropdown
);
}
}
/**
* Customize Control for Repeater Text.
*
* @since 1.0.0
*
* @see WP_Customize_Control
*/
class water_delivery_Repeater_Text_Control extends WP_Customize_Control {
/**
* Control type.
*
* @access public
* @var string
*/
public $type = 'repeater-text';
/**
* Render content.
*
* @since 1.0.0
*/
public function render_content() {
?>
<?php if ( ! empty( $this->label ) ) : ?>
<h3><span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span></h3>
<?php endif; ?>
<?php if ( ! empty( $this->description ) ) : ?>
<span class="description customize-control-description"><?php echo wp_kses_post( $this->description ); ?></span>
<?php endif; ?>
<label class="repeater-text-input">
<input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="repeater-text-value" <?php $this->link(); ?> />
<div class="repeater-text-fields">
<div class="set">
<input type="text" value="" class="repeater-text-single-field" />
<span class="btn-remove-field"><span class="dashicons dashicons-no-alt"></span></span>
</div>
</div>
<a href="#" class="button button-primary btn-add-field"><?php esc_html_e( 'Add New', 'water-delivery' ) ?></a>
</label><!-- .repeater-text-input -->
<?php
}
}
/**
* Customizer Controls
*
* @package Water Delivery
*/
if ( ! class_exists( 'WP_Customize_Control' ) ) :
return null;
endif;
/**
* Upsell customizer section.
*
* @since 1.0.0
* @access public
*/
class water_delivery_Customize_Section_Upsell extends WP_Customize_Section {
/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'water-delivery-upsell';
/**
* Custom button text to output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $pro_text = '';
/**
* Custom pro button URL.
*
* @since 1.0.0
* @access public
* @var string
*/
public $pro_url = '';
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
* @access public
* @return void
*/
public function json() {
$json = parent::json();
$json['pro_text'] = $this->pro_text;
$json['pro_url'] = esc_url( $this->pro_url );
return $json;
}
/**
* Outputs the Underscore.js template.
*
* @since 1.0.0
* @access public
* @return void
*/
protected function render_template() { ?>
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
{{ data.title }}
<# if ( data.pro_text && data.pro_url ) { #>
<a href="{{ data.pro_url }}" class="button button-primary alignright" target="_blank">{{ data.pro_text }}</a>
<# } #>
</h3>
</li>
<?php }
}

View File

@@ -0,0 +1,401 @@
<?php
/**
* Custom theme functions.
*
* This file contains hook functions attached to theme hooks.
*
* @package Water Delivery
*/
if( ! function_exists( 'water_delivery_site_branding' ) ) :
/**
* Site Branding
*
* @since 1.0.0
*/
function water_delivery_site_branding() { ?>
<?php
$show_contact = water_delivery_get_option( 'show_header_contact_info' );
$phone = water_delivery_get_option( 'header_phone' );
$show_social = water_delivery_get_option( 'show_header_social_links' );
?>
<?php if( $show_contact || $show_social ){ ?>
<div class="top-bar-widgets-view">
<div class="wrapper">
<div class="topbar-header">
<?php
$description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?>
<p class="site-description"><?php echo esc_html($description);?></p>
<?php endif; ?>
<?php if( ( ! empty( $phone ) ) && $show_contact ) : ?>
<div class="contact-phone">
<?php
if( ! empty( $phone ) ){
echo '<a href="' . esc_url('tel: '. esc_attr( $phone )) .'"><i class="fas fa-phone-alt"></i> <label>Get Free Delivery</label> <span>+ '. esc_html( $phone ) .'</span></a>';
}
?>
</div><!-- .widget_address_block -->
<?php endif;
if ( $show_social ){ ?>
<div class="header_social_icons">
<?php water_delivery_render_social_links(); ?>
</div><!-- .widget_social_icons -->
<?php } ?>
</div> <!-- .topbar-header -->
</div> <!-- .wrapper -->
</div> <!-- .top-bar-widgets-view -->
<?php } ?>
<div class="wrapper">
<div class="header-container">
<div class="site-branding">
<div class="site-logo">
<?php if(has_custom_logo()):?>
<?php the_custom_logo();?>
<?php endif;?>
</div><!-- .site-logo -->
<div id="site-identity">
<?php if(!has_custom_logo()):?>
<h1 class="site-title">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"> <?php bloginfo( 'name' ); ?></a>
</h1>
<?php endif;?>
</div><!-- #site-identity -->
</div> <!-- .site-branding -->
<div class="header-content">
<?php
$show_contact = water_delivery_get_option( 'show_header_contact_info' );
$phone = water_delivery_get_option( 'header_phone' );
$show_social = water_delivery_get_option( 'show_header_social_links' );
?>
<?php if( $show_contact || $show_social ){ ?>
<div class="top-bar-widgets">
<?php
$description = get_bloginfo( 'description', 'display' );
if ( $description || is_customize_preview() ) : ?>
<p class="site-description"><?php echo esc_html($description);?></p>
<?php endif; ?>
<?php if( ( ! empty( $phone ) ) && $show_contact ) : ?>
<div class="contact-phone">
<?php
if( ! empty( $phone ) ){
echo '<a href="' . esc_url('tel: '. esc_attr( $phone )) .'"><i class="fas fa-phone-alt"></i> <label>Get Free Delivery</label> <span>+ '. esc_html( $phone ) .'</span></a>';
}
?>
</div><!-- .widget_address_block -->
<?php endif;
if ( $show_social ){ ?>
<div class="header_social_icons">
<?php water_delivery_render_social_links(); ?>
</div><!-- .widget_social_icons -->
<?php } ?>
</div><!-- #top-bar -->
<?php
} ?>
<nav id="site-navigation" class="main-navigation" role="navigation" aria-label="Primary Menu">
<button type="button" class="menu-toggle">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'primary-menu',
'menu_class' => 'nav-menu',
'fallback_cb' => 'water_delivery_primary_navigation_fallback',
) );
?>
</nav><!-- #site-navigation -->
</div><!-- .header-content -->
</div><!-- .header-container -->
</div><!-- .wrapper -->
<?php }
endif;
add_action( 'water_delivery_action_header', 'water_delivery_site_branding', 10 );
if ( ! function_exists( 'water_delivery_footer_top_section' ) ) :
/**
* Top Footer
*
* @since 1.0.0
*/
function water_delivery_footer_top_section() {
$footer_sidebar_data = water_delivery_footer_sidebar_class();
$footer_sidebar = $footer_sidebar_data['active_sidebar'];
$footer_class = $footer_sidebar_data['class'];
if ( empty( $footer_sidebar ) ) {
return;
} ?>
<div class="footer-widgets-area section-gap <?php echo esc_attr( $footer_class ); ?>"> <!-- widget area starting from here -->
<div class="wrapper">
<?php
for ( $i = 1; $i <= 4 ; $i++ ) {
if ( is_active_sidebar( 'footer-' . $i ) ) {
?>
<div class="hentry">
<?php dynamic_sidebar( 'footer-' . $i ); ?>
</div>
<?php
}
}
?>
</div>
</div> <!-- widget area starting from here -->
<?php
}
endif;
add_action( 'water_delivery_action_footer', 'water_delivery_footer_top_section', 10 );
if ( ! function_exists( 'water_delivery_footer_section' ) ) :
/**
* Footer copyright
*
* @since 1.0.0
*/
function water_delivery_footer_section() { ?>
<div class="site-info">
<?php
$copyright_footer = water_delivery_get_option('copyright_text');
if ( ! empty( $copyright_footer ) ) {
$copyright_footer = wp_kses_data( $copyright_footer );
}
// Powered by content.
$powered_by_text = sprintf( __( ' Theme Water Delivery by %s', 'water-delivery' ), '<a target="_blank" rel="designer" href="'. esc_url( '#' ) .'">Rapid Themes</a>' );
?>
<div class="copy_right_block">
<div class="wrapper">
<span class="copy-right"><?php echo esc_html($copyright_footer);?><?php echo $powered_by_text;?></span>
</div><!-- .wrapper -->
</div>
</div> <!-- .site-info -->
<?php }
endif;
add_action( 'water_delivery_action_footer', 'water_delivery_footer_section', 20 );
if ( ! function_exists( 'water_delivery_footer_sidebar_class' ) ) :
/**
* Count the number of footer sidebars to enable dynamic classes for the footer
*
* @since water_delivery 0.1
*/
function water_delivery_footer_sidebar_class() {
$data = array();
$active_sidebar = array();
$count = 0;
if ( is_active_sidebar( 'footer-1' ) ) {
$active_sidebar[] = 'footer-1';
$count++;
}
if ( is_active_sidebar( 'footer-2' ) ){
$active_sidebar[] = 'footer-2';
$count++;
}
if ( is_active_sidebar( 'footer-3' ) ){
$active_sidebar[] = 'footer-3';
$count++;
}
if ( is_active_sidebar( 'footer-4' ) ){
$active_sidebar[] = 'footer-4';
$count++;
}
$class = '';
switch ( $count ) {
case '1':
$class = 'col-1';
break;
case '2':
$class = 'col-2';
break;
case '3':
$class = 'col-3';
break;
case '4':
$class = 'col-4';
break;
}
$data['active_sidebar'] = $active_sidebar;
$data['class'] = $class;
return $data;
}
endif;
if ( ! function_exists( 'water_delivery_excerpt_length' ) ) :
/**
* Implement excerpt length.
*
* @since 1.0.0
*
* @param int $length The number of words.
* @return int Excerpt length.
*/
function water_delivery_excerpt_length( $length ) {
if ( is_admin() ) {
return $length;
}
$excerpt_length = water_delivery_get_option( 'excerpt_length' );
if ( absint( $excerpt_length ) > 0 ) {
$length = absint( $excerpt_length );
}
return $length;
}
endif;
add_filter( 'excerpt_length', 'water_delivery_excerpt_length', 999 );
if( ! function_exists( 'water_delivery_banner_header' ) ) :
/**
* Page Header
*/
function water_delivery_banner_header() {
$show_header_image = water_delivery_get_option( 'show_header_image' );
$show_page_title = water_delivery_get_option( 'show_page_title' );
if ( is_front_page() && ! is_home() )
return;
$header_image = get_header_image();
if ( is_singular() ) :
$header_image = has_post_thumbnail() ? get_the_post_thumbnail_url( get_the_id(), 'full' ) : $header_image;
endif;
?>
<div id="page-site-header" class="<?php echo esc_attr($show_header_image); ?> <?php echo esc_attr($show_page_title); ?>" style="background-image: url('<?php echo esc_url( $header_image ); ?>');">
<div class="overlay"></div>
<header class='page-header'>
<div class="wrapper">
<?php water_delivery_banner_title();?>
</div><!-- .wrapper -->
</header>
</div><!-- #page-site-header -->
<?php echo '<div class= "wrapper section-gap">';
}
endif;
add_action( 'water_delivery_banner_header', 'water_delivery_banner_header', 10 );
if( ! function_exists( 'water_delivery_banner_title' ) ) :
/**
* Page Header
*/
function water_delivery_banner_title(){
if ( ( is_front_page() && is_home() ) || is_home() ){
$your_latest_posts_title = water_delivery_get_option( 'your_latest_posts_title' );?>
<h2 class="page-title"><?php echo esc_html($your_latest_posts_title); ?></h2><?php
}
if( is_singular() ) {
the_title( '<h2 class="page-title">', '</h2>' );
}
if( is_archive() ){
the_archive_description( '<div class="archive-description">', '</div>' );
the_archive_title( '<h2 class="page-title">', '</h2>' );
}
if( is_search() ){ ?>
<h2 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', 'water-delivery' ), '<span>' . get_search_query() . '</span>' ); ?></h2>
<?php }
if( is_404() ) {
echo '<h2 class="page-title">' . esc_html__( 'Error 404', 'water-delivery' ) . '</h2>';
}
}
endif;
if ( ! function_exists( 'water_delivery_posts_tags' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function water_delivery_posts_tags() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() && has_tag() ) { ?>
<div class="tags-links">
<?php /* translators: used between list items, there is a space after the comma */
$tags = get_the_tags();
if ( $tags ) {
foreach ( $tags as $tag ) {
echo '<span><a href="' . esc_url( get_tag_link( $tag->term_id ) ) .'">' . esc_html( $tag->name ) . '</a></span>'; // WPCS: XSS OK.
}
} ?>
</div><!-- .tags-links -->
<?php }
}
endif;
/**
* Render social links.
*
* @since 1.0
*/
function water_delivery_render_social_links() {
$social_link1 = water_delivery_get_option( 'social_link_1' );
$social_link2 = water_delivery_get_option( 'social_link_2' );
$social_link3 = water_delivery_get_option( 'social_link_3' );
$social_link4 = water_delivery_get_option( 'social_link_4' );
if ( empty( $social_link1 ) && empty( $social_link2 ) && empty( $social_link3 ) ) {
return;
}
echo '<div class="social-icons">';
echo '<ul>';
if ( ! empty( $social_link1 ) ) {
echo '<li><a href="' . esc_url( $social_link1 ) . '" target="_blank"></a></li>';
}
if ( ! empty( $social_link2 ) ) {
echo '<li><a href="' . esc_url( $social_link2 ) . '" target="_blank"></a></li>';
}
if ( ! empty( $social_link3 ) ) {
echo '<li><a href="' . esc_url( $social_link3 ) . '" target="_blank"></a></li>';
}
if ( ! empty( $social_link4 ) ) {
echo '<li><a href="' . esc_url( $social_link4 ) . '" target="_blank"></a></li>';
}
echo '</ul>';
echo '</div>';
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* Theme functions related to structure.
*
* This file contains structural hook functions.
*
* @package Water Delivery
*/
if ( ! function_exists( 'water_delivery_doctype' ) ) :
/**
* Doctype Declaration.
*
* @since 1.0.0
*/
function water_delivery_doctype() {
?><!DOCTYPE html> <html <?php language_attributes(); ?>><?php
}
endif;
add_action( 'water_delivery_action_doctype', 'water_delivery_doctype', 10 );
if ( ! function_exists( 'water_delivery_head' ) ) :
/**
* Header Codes.
*
* @since 1.0.0
*/
function water_delivery_head() {
?>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
<link rel="pingback" href="<?php echo esc_url( get_bloginfo( 'pingback_url' ) ); ?>">
<?php endif;
}
endif;
add_action( 'water_delivery_action_head', 'water_delivery_head', 10 );
if ( ! function_exists( 'water_delivery_page_start' ) ) :
/**
* Add Skip to content.
*
* @since 1.0.0
*/
function water_delivery_page_start() {
?><div id="page" class="site"><a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'water-delivery' ); ?></a><?php
}
endif;
add_action( 'water_delivery_action_before', 'water_delivery_page_start', 10 );
if ( ! function_exists( 'water_delivery_header_start' ) ) :
/**
* Header Start.
*
* @since 1.0.0
*/
function water_delivery_header_start() { ?>
<header id="masthead" class="site-header" role="banner"><?php
}
endif;
add_action( 'water_delivery_action_before_header', 'water_delivery_header_start' );
if ( ! function_exists( 'water_delivery_header_end' ) ) :
/**
* Header Start.
*
* @since 1.0.0
*/
function water_delivery_header_end() {
?>
</header> <!-- header ends here --><?php
}
endif;
add_action( 'water_delivery_action_header', 'water_delivery_header_end', 15 );
if ( ! function_exists( 'water_delivery_content_start' ) ) :
/**
* Header End.
*
* @since 1.0.0
*/
function water_delivery_content_start() {
?>
<div id="content-page" class="site-content">
<?php
}
endif;
add_action( 'water_delivery_action_before_content', 'water_delivery_content_start', 10 );
if ( ! function_exists( 'water_delivery_footer_start' ) ) :
/**
* Footer Start.
*
* @since 1.0.0
*/
function water_delivery_footer_start() {
if( !(is_home() || is_front_page()) ){
echo '</div>';
} ?>
</div>
<footer id="colophon" class="site-footer" role="contentinfo">
<?php
}
endif;
add_action( 'water_delivery_action_before_footer', 'water_delivery_footer_start' );
if ( ! function_exists( 'water_delivery_footer_end' ) ) :
/**
* Footer End.
*
* @since 1.0.0
*/
function water_delivery_footer_end() {?>
</footer><?php
}
endif;
add_action( 'water_delivery_action_after_footer', 'water_delivery_footer_end' );

View File

@@ -0,0 +1,38 @@
<?php
/**
* Load files.
*
* @package Water Delivery
*/
/**
* Include default theme options.
*/
require get_template_directory() . '/inc/customizer/default.php';
/**
* Load hooks.
*/
require get_template_directory() . '/inc/hook/structure.php';
require get_template_directory() . '/inc/hook/custom.php';
require get_template_directory() . '/inc/hook/basic.php';
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';

View File

@@ -0,0 +1,104 @@
<?php
/**
* Custom template tags for this theme
*
* Eventually, some of the functionality here could be replaced by core features.
*
* @package Water Delivery
*/
if ( ! function_exists( 'water_delivery_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function water_delivery_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$posted_on = sprintf(
'%s',
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
if( is_single() ){
$byline = sprintf(
esc_html_x( 'By %s', 'post author', 'water-delivery' ),
'<span class="author vcard"><a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" class="url" itemprop="url">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a></span>'
);
echo '<span class="byline">' . $byline . '</span>';
}
echo '<span class="date">' . $posted_on . '</span>'; // WPCS: XSS OK.
}
endif;
if ( ! function_exists( 'water_delivery_entry_meta' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function water_delivery_entry_meta() {
// Hide category and tag text for pages.
if ( 'post' === get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( esc_html__( ', ', 'water-delivery' ) );
if ( $categories_list && water_delivery_categorized_blog() ) {
printf( '<span class="cat-links">%1$s</span>', $categories_list ); // WPCS: XSS OK.
}
}
if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
/* translators: %s: post title */
comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'water-delivery' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) );
echo '</span>';
}
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function water_delivery_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'water_delivery_categories' ) ) ) {
// Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array(
'fields' => 'ids',
'hide_empty' => 1,
// We only need to know if there is more than one category.
'number' => 2,
) );
// Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'water_delivery_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so water_delivery_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so water_delivery_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in water_delivery_categorized_blog.
*/
function water_delivery_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'water_delivery_categories' );
}
add_action( 'edit_category', 'water_delivery_category_transient_flusher' );
add_action( 'save_post', 'water_delivery_category_transient_flusher' );