Commit 6ca0b130 authored by Michael Iseard's avatar Michael Iseard
Browse files

Add demo template

parent b068acd2
<?php
use Carbon_Fields\Block;
use Carbon_Fields\Carbon_Fields;
use Carbon_Fields\Container;
use Carbon_Fields\Field;
add_action( 'carbon_fields_register_fields', 'we_theme_options' );
function we_theme_options() {
add_action( 'carbon_fields_register_fields', function () {
Container::make_post_meta('demo_template_options', __('Demo Options', 'kudos-website'))
->set_context('side')
->where('post_type', '=', 'page')
->where('post_template', '=', 'views/template-demo.blade.php')
->add_fields([
Field::make( 'checkbox', 'overlay', __( 'Disable Overlay', 'kudos-website' ) )
->set_default_value( false ),
Field::make( 'checkbox', 'border', __( 'Add Border', 'kudos-website' ) )
->set_default_value( false ),
Field::make( 'color', 'border_color', __( 'Border Color' ) )
->set_default_value( '#2EC4B6' )
->set_conditional_logic( [
[
'field' => 'border',
'value' => true,
],
] ),
Field::make( 'text', 'border_width', __( 'Border Width' ) )
->set_attribute( 'type', 'number' )
->set_default_value( '2' )
->set_conditional_logic( [
[
'field' => 'border',
'value' => true,
],
] ),
])
;
Container::make_post_meta( 'review_rating', __( 'Rating', 'kudos-website' ) )
->set_context( 'side' )
......@@ -27,115 +54,114 @@ function we_theme_options() {
// Add second options page under 'Basic Options'
Container::make( 'theme_options', __( 'Site Options' ) )
->add_tab( __( 'Homepage', 'kudos-website' ),
->add_tab( __( 'Homepage', 'kudos-website' ),
[
Field::make( 'image', 'intro_image', __( 'Image', 'kudos-website' ) ),
Field::make( 'rich_text', 'intro_text', __( 'Intro Text', 'kudos-website' ) ),
Field::make( 'complex', 'intro_variables', __( 'Intro Variables', 'kudos-website' ) )
->add_fields( 'household_number',
[
Field::make( 'text', 'title' )
->set_width( 50 ),
] ),
] )
->add_tab( __( 'Site news', 'kudos-website' ),
[
Field::make( 'checkbox', 'show_site_news', __( 'Show Site News', 'kudos-website' ) )
->set_default_value( false )
->set_help_text( __( 'Shows a custom notification at the top of the home page',
'kudos-website' ) ),
Field::make( 'checkbox', 'site_news_all_pages', __( 'Show on all pages', 'kudos-website' ) )
->set_default_value( false )
->set_help_text( __( 'When disabled only shows on home page', 'kudos-website' ) ),
Field::make( 'rich_text', 'site_news', __( 'Site News', 'kudos-website' ) ),
] )
// Email tab
->add_tab( 'Email',
[
Field::make( 'checkbox', 'we_use_smtp', __( 'Enable SMTP', 'kudos-website' ) )
->set_help_text( 'Enable use of external SMTP server.' )
->set_option_value( 'yes' ),
Field::make( 'text', 'we_smtp_host', __( 'SMTP host', 'kudos-website' ) )
->set_conditional_logic( [
[
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_width( '50%' )
->set_required(),
Field::make( 'text', 'we_smtp_port', __( 'Port number', 'kudos-website' ) )
->set_conditional_logic( [
[
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_width( '50%' )
->set_attribute( 'type', 'number' )
->set_required(),
Field::make( 'radio', 'we_security_protocol', __( 'Security protocol', 'kudos-website' ) )
->set_conditional_logic( [
[
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_help_text( 'Select whether to use posts or pages as the sections' )
->add_options( [
'ssl' => 'SSL',
'tls' => 'TLS',
] ),
Field::make( 'text', 'we_smtp_user', __( 'SMTP username', 'kudos-website' ) )
->set_conditional_logic( [
[
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_help_text( 'The username to login to your mail server.' )
->set_required(),
Field::make( 'text', 'we_smtp_password', __( 'SMTP password', 'kudos-website' ) )
->set_conditional_logic( [
[
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_attribute( 'type', 'password' )
->set_help_text( 'The password to login to your mail server.' )
->set_required(),
Field::make( 'text', 'we_from_email', __( 'From email', 'kudos-website' ) )
->set_conditional_logic( [
[
Field::make( 'image', 'intro_image', __( 'Image', 'kudos-website' ) ),
Field::make( 'rich_text', 'intro_text', __( 'Intro Text', 'kudos-website' ) ),
Field::make( 'complex', 'intro_variables', __( 'Intro Variables', 'kudos-website' ) )
->add_fields( 'household_number',
[
Field::make( 'text', 'title' )
->set_width( 50 ),
] ),
] )
->add_tab( __( 'Site news', 'kudos-website' ),
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_help_text( 'Email address that messages will appear from.' )
->set_required(),
Field::make( 'text', 'we_from_name', __( 'From name', 'kudos-website' ) )
->set_conditional_logic( [
[
Field::make( 'checkbox', 'show_site_news', __( 'Show Site News', 'kudos-website' ) )
->set_default_value( false )
->set_help_text( __( 'Shows a custom notification at the top of the home page',
'kudos-website' ) ),
Field::make( 'checkbox', 'site_news_all_pages', __( 'Show on all pages', 'kudos-website' ) )
->set_default_value( false )
->set_help_text( __( 'When disabled only shows on home page', 'kudos-website' ) ),
Field::make( 'rich_text', 'site_news', __( 'Site News', 'kudos-website' ) ),
] )
// Email tab
->add_tab( 'Email',
array(
Field::make( 'checkbox', 'we_use_smtp', __( 'Enable SMTP', 'kudos-website' ) )
->set_help_text( 'Enable use of external SMTP server.' )
->set_option_value( 'yes' ),
Field::make( 'text', 'we_smtp_host', __( 'SMTP host', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_width( '50%' )
->set_required(),
Field::make( 'text', 'we_smtp_port', __( 'Port number', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_width( '50%' )
->set_attribute( 'type', 'number' )
->set_required(),
Field::make( 'radio', 'we_security_protocol', __( 'Security protocol', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_help_text( 'Select whether to use posts or pages as the sections' )
->add_options( array(
'ssl' => 'SSL',
'tls' => 'TLS',
) ),
Field::make( 'text', 'we_smtp_user', __( 'SMTP username', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_help_text( 'The username to login to your mail server.' )
->set_required(),
Field::make( 'text', 'we_smtp_password', __( 'SMTP password', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_attribute( 'type', 'password' )
->set_help_text( 'The password to login to your mail server.' )
->set_required(),
Field::make( 'text', 'we_from_email', __( 'From email', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_help_text( 'Email address that messages will appear from.' )
->set_required(),
Field::make( 'text', 'we_from_name', __( 'From name', 'kudos-website' ) )
->set_conditional_logic( array(
array(
'field' => 'we_use_smtp',
'value' => true,
),
) )
->set_help_text( 'This text will be used in the \'FROM\' field.' ),
) )
'field' => 'we_use_smtp',
'value' => true,
],
] )
->set_help_text( 'This text will be used in the \'FROM\' field.' ),
] )
// CTA tab
->add_tab( 'CTA',
[
Field::make( 'text', 'cta_label', __( 'CTA Label', 'kudos-website' ) )
->set_required(),
Field::make( 'text', 'cta_link', __( 'CTA Link', 'kudos-website' ) )
->set_required(),
] );
// CTA tab
->add_tab( 'CTA',
[
Field::make( 'text', 'cta_label', __( 'CTA Label', 'kudos-website' ) )
->set_required(),
Field::make( 'text', 'cta_link', __( 'CTA Link', 'kudos-website' ) )
->set_required(),
] );
}
});
add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
add_action( 'after_setup_theme', function () {
Carbon_Fields::boot();
}
});
......@@ -310,4 +310,5 @@ add_action( 'wp_head',
--kudos-page-theme: $color;
}
</style>";
} );
}
);
{{--
Template Name: Demo Page
--}}
@php
$class[] = 'h-100';
$class[] = carbon_get_post_meta( get_the_ID(), 'overlay' ) ? 'overlay-none' : '';
$class[] = carbon_get_post_meta( get_the_ID(), 'border' ) ? 'border-on' : '';
$borderColor = carbon_get_post_meta( get_the_ID(), 'border_color' );
$borderWidth = carbon_get_post_meta( get_the_ID(), 'border_width' );
@endphp
<!doctype html>
<html {!! get_language_attributes() !!}>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
html, body {
height: 100%;
background-color: transparent;
}
body.overlay-none .kudos_modal .kd-bg-modal {
background-color: transparent !important;
}
body.border-on .kudos_modal .kudos_modal_container {
border: {{$borderWidth}}px solid {{$borderColor}};
}
</style>
@php wp_head() @endphp
</head>
<body @php body_class(implode(' ', $class)) @endphp>
@php do_action('get_header') @endphp
<div class="d-flex h-100 justify-content-center align-items-center" role="document">
@php the_content() @endphp
</div>
@php do_action('get_footer') @endphp
@php wp_footer() @endphp
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment