Skip to content

Commit

Permalink
change theme definition, theme prefix, function naming conventions, c…
Browse files Browse the repository at this point in the history
…hange license, remove unused code, add accessibility
  • Loading branch information
saidmsaif committed Dec 17, 2021
1 parent b7d83f2 commit 4b00341
Show file tree
Hide file tree
Showing 27 changed files with 172 additions and 89 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ input:focus {
padding: 0;
position: absolute !important;
width: 1px;
word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */
word-wrap: normal !important;
}

.screen-reader-text:focus {
Expand All @@ -213,18 +213,27 @@ input:focus {
z-index: 100000;
/* Above WP toolbar. */
}
#content[tabindex="-1"]:focus {
outline: 0;
}
.bypostauthor{}
.gallery-caption{}



/* Header Section */
#site-header {
z-index: 9999;
}
.navbar-brand img {
width: 120px;
}
.navbar-toggler {
border: none;
border-radius: 0;
}
.navbar-toggler:focus {
box-shadow: none;
box-shadow: 0 0 0 0.1rem;
}
.home-hero {
background: var(--secondary-color);
Expand Down
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions assets/js/craftnce-iconpicker.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
!(function (e) {
"use strict";
(wp.customizerRepeater = {
init: function () {
e(".iconpicker-items>i").on("click", function () {
var i = e(this).attr("class").slice(3),
t = e(this).parents(".iconpicker-popover").prev().find(".icp");
t.val(i), t.attr("value", i);
var n = t.next(".input-group-addon"),
c = '<i class="fa '.concat(i, '"></i>');
n.empty(), n.append(c);
var r = e(this).parent().parent().parent();
return t.trigger("change"), customizer_repeater_refresh_social_icons(r), !1;
});
},
search: function (i) {
var t = i.parent().next().find(".iconpicker-items"),
n = i.val().toLowerCase();
n.length > 0
? t.children().each(function () {
e(this).filter("[title*=".concat(n)).length > 0 || n.length < 1 ? e(this).show() : e(this).hide();
})
: t.children().show();
},
iconPickerToggle: function (e) {
e.parent().next().addClass("iconpicker-visible");
},
}),
e(document).ready(function () {
wp.customizerRepeater.init(),
e(".iconpicker-search").on("keyup", function () {
wp.customizerRepeater.search(e(this));
}),
e(".icp-auto").on("click", function () {
wp.customizerRepeater.iconPickerToggle(e(this));
}),
e(document).mouseup(function (i) {
var t = e(".iconpicker-popover");
t.is(i.target) || 0 !== t.has(i.target).length || t.removeClass("iconpicker-visible");
});
});
})(jQuery);
1 change: 0 additions & 1 deletion assets/js/fontawesome-iconpicker.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ document.addEventListener('scroll', () => {
} else if (window.scrollY < 100) {
siteHeader.classList.remove('shadow-sm');
}
})
});
17 changes: 9 additions & 8 deletions footer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<footer class="main-footer py-4">
<div class="container">
<div class="text-center text-light text-sm">
<?php
echo esc_html( get_theme_mod('craftnce_copyright_text_settings', 'Copyright @ Craftnce | All Right Reserved | 2021') );
?>
<footer class="main-footer py-4">
<div class="container">
<div class="text-center text-light text-sm">
<?php
echo esc_html( get_theme_mod('craftnce_copyright_text_settings', 'Copyright @ Craftnce | All Right Reserved | 2021') );
?>
</div>
</div>
</div>
</footer>
</footer>
</div>

<?php wp_footer(); ?>
</body>
Expand Down
6 changes: 3 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
get_template_part('inc/craftnce-functions');
get_template_part('lib/customizer/customizer');
get_template_part('lib/bootstrap5-nav-walker');
get_template_part('lib/customizer/craftnce-customizer');
get_template_part('lib/craftnce-nav-walker');

if(!function_exists('craftnce_theme_setup')) {
function craftnce_theme_setup() {
Expand Down Expand Up @@ -48,7 +48,7 @@ function craftnce_assets_enqueue() {
wp_enqueue_style('craftnce-slick-css', '//cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css');
wp_enqueue_style('craftnce-main-style', get_template_directory_uri().'/assets/css/style.css');
wp_enqueue_style('craftnce-responsive-style', get_template_directory_uri().'/assets/css/responsive.css');
wp_enqueue_style('theme-default-css', get_stylesheet_uri());
wp_enqueue_style('craftnce-theme-default-css', get_stylesheet_uri());

// JS Enqueue
wp_enqueue_script( 'comment-reply' );
Expand Down
105 changes: 55 additions & 50 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,64 @@
</head>
<body class="<?php body_class(); ?>">
<?php wp_body_open(); ?>
<!-- Header Navigation -->
<header id="site-header" class="sticky-top bg-light shadow-sm">
<nav class="navbar navbar-expand-lg navbar-light py-2">
<div class="container">
<a class="navbar-brand text-primary fw-bolder" href="<?php echo esc_url(home_url()); ?>">
<?php
if(current_theme_supports('custom-logo')) {
$craftnce_custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $craftnce_custom_logo_id , 'full' );
<div id="page" class="craftnce_site">
<a class="skip-link screen-reader-text" href="#content">
<?php _e( 'Skip to Content', 'craftnce' ); ?>
</a>

if($logo) {
?>
<img src="<?php echo esc_url($logo[0]); ?>" class="img-fluid" alt="">
<?php
<!-- Header Navigation -->
<header id="site-header" class="sticky-top bg-light shadow-sm">
<nav class="navbar navbar-expand-lg navbar-light py-2">
<div class="container">
<a class="navbar-brand text-primary fw-bolder" href="<?php echo esc_url(home_url()); ?>">
<?php
if(current_theme_supports('custom-logo')) {
$craftnce_custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $craftnce_custom_logo_id , 'full' );

if($logo) {
?>
<img src="<?php echo esc_url($logo[0]); ?>" class="img-fluid" alt="">
<?php
} else {
?>
<h4 class="mb-0"><?php bloginfo('title-tag'); ?></h4>
<?php
}
}
?>
</a>

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="<?php esc_attr_e('Toggle navigation', 'craftnce'); ?>">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse flex-grow-0" id="navbarSupportedContent">
<?php
if(has_nav_menu('primary-menu')) {
wp_nav_menu(array(
'theme_location' => 'primary-menu',
'menu_class' => '',
'menu-container' => 'false',
'fallback_cb' => '__return_false',
'items_wrap' => '<ul id="%1$s" class="navbar-nav ms-auto mb-2 mb-lg-0 text-sm %2$s">%3$s</ul>',
'depth' => 2,
'walker' => new craftnce_wp_nav_menu_walker(),
));
} else {
?>
<h4 class="mb-0"><?php bloginfo('title-tag'); ?></h4>
<?php
echo '<a class="text-primary text-sm nav-menu-create-notice" href="'.home_url('/wp-admin/nav-menus.php').'">Create nav menu first</a>';
}
}
?>
</a>

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse flex-grow-0" id="navbarSupportedContent">
<?php
if(has_nav_menu('primary-menu')) {
wp_nav_menu(array(
'theme_location' => 'primary-menu',
'menu_class' => '',
'menu-container' => 'false',
'fallback_cb' => '__return_false',
'items_wrap' => '<ul id="%1$s" class="navbar-nav ms-auto mb-2 mb-lg-0 text-sm %2$s">%3$s</ul>',
'depth' => 2,
'walker' => new bootstrap_5_wp_nav_menu_walker(),
));
} else {
echo '<a class="text-primary text-sm nav-menu-create-notice" href="'.home_url('/wp-admin/nav-menus.php').'">Create nav menu first</a>';
}
?>
<?php
if(get_theme_mod('craftnce_header_menu_show_last_button_label_settings')) :
?>
<a href="<?php echo esc_url(get_theme_mod('craftnce_header_menu_last_button_link_settings', 1)); ?>" class="btn btn-primary rounded-pill text-sm">
?>
<?php
echo esc_html( get_theme_mod('craftnce_header_menu_last_button_label_settings', 'contact us') );
if(get_theme_mod('craftnce_header_menu_show_last_button_label_settings')) :
?>
</a>
<?php endif; ?>
<a href="<?php echo esc_url(get_theme_mod('craftnce_header_menu_last_button_link_settings', 1)); ?>" class="btn btn-primary rounded-pill text-sm">
<?php
echo esc_html( get_theme_mod('craftnce_header_menu_last_button_label_settings', 'contact us') );
?>
</a>
<?php endif; ?>
</div>
</div>
</div>
</nav>
</header>
</nav>
</header>
4 changes: 2 additions & 2 deletions home.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
?>
<div class="row text-center pb-5">
<div class="col-md-7 mx-auto">
<h6 class="fw-bold fs-6 text-uppercase text-primary"><?php echo _e(get_theme_mod('craftnce_blog_page_sub_heading_settings')); ?></h6>
<h2 class="fs-48 fw-900 text-uppercase"><?php echo _e(get_theme_mod('craftnce_blog_page_heading_setting')); ?></h2>
<h6 class="fw-bold fs-6 text-uppercase text-primary"><?php echo esc_html( get_theme_mod('craftnce_blog_page_sub_heading_settings') ); ?></h6>
<h2 class="fs-48 fw-900 text-uppercase"><?php echo esc_html( get_theme_mod('craftnce_blog_page_heading_setting') ); ?></h2>
</div>
</div>
<?php
Expand Down
20 changes: 19 additions & 1 deletion inc/craftnce-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,22 @@ function craftnce_comment_text_before($arg) {
return $arg;
}

add_filter('comment_form_defaults', 'craftnce_comment_text_before');
add_filter('comment_form_defaults', 'craftnce_comment_text_before');

/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* @link https://git.io/vWdr2
*/
function craftnce_skip_link_focus_fix() {
// The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
?>
<script>
/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
</script>
<?php
}
add_action( 'wp_print_footer_scripts', 'craftnce_skip_link_focus_fix' );
4 changes: 2 additions & 2 deletions inc/option-panel/customizer/customizer-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public function json() {

// Enqueue our scripts and styles
function pe_customize_controls_scripts() {
wp_enqueue_script( 'pe-customize-controls', get_theme_file_uri( '/assets/js/pe-customize-controls.js' ), array(), '1.0', true );
wp_enqueue_script( 'pe-customize-controls', get_theme_file_uri( '/assets/js/craftnce-customize-controls.js' ), array(), '1.0', true );
}
add_action( 'customize_controls_enqueue_scripts', 'pe_customize_controls_scripts' );

function pe_customize_controls_styles() {
wp_enqueue_style( 'pe-customize-controls', get_theme_file_uri( '/assets/css/pe-customize-controls.css' ), array(), '1.0' );
wp_enqueue_style( 'pe-customize-controls', get_theme_file_uri( '/assets/css/craftnce-customize-controls.css' ), array(), '1.0' );
}
add_action( 'customize_controls_print_styles', 'pe_customize_controls_styles' );
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
?>

<!-- Post -->
<section class="pb-5">
<section class="pb-5" id="content">
<div class="container py-5">
<div class="row text-center pb-5">
<div class="col-md-7 mx-auto">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class bootstrap_5_wp_nav_menu_walker extends Walker_Nav_menu {
class craftnce_wp_nav_menu_walker extends Walker_Nav_menu {
private $current_item;
private $dropdown_menu_alignment_values = [
'dropdown-menu-start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if ( ! class_exists( 'WP_Customize_Control' ) ) {
return null;
}
define( 'CUSTOMIZER_REPEATER_VERSION', '1.1.0' );
define( 'craftnce_CUSTOMIZER_REPEATER_VERSION', '1.1.0' );

class Customizer_Repeater extends WP_Customize_Control {

Expand Down Expand Up @@ -112,13 +112,12 @@ public function __construct( $manager, $id, $args = array() ) {

/*Enqueue resources for the control*/
public function enqueue() {
wp_enqueue_style( 'font-awesome', '//use.fontawesome.com/releases/v5.15.4/css/all.css', array(), CUSTOMIZER_REPEATER_VERSION );
wp_enqueue_style( 'customizer-repeater-admin-stylesheet', get_template_directory_uri().'/assets/css/customize-repeater.css', array(), CUSTOMIZER_REPEATER_VERSION );
wp_enqueue_style( 'craftnce-font-awesome', '//use.fontawesome.com/releases/v5.15.4/css/all.css', array(), craftnce_CUSTOMIZER_REPEATER_VERSION );
wp_enqueue_style( 'craftnce-customizer-repeater-admin-stylesheet', get_template_directory_uri().'/assets/css/craftnce-customize-repeater.css', array(), craftnce_CUSTOMIZER_REPEATER_VERSION );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'customizer-repeater-fontawesome-iconpicker', get_template_directory_uri() . '/assets/css/fontawesome-iconpicker.min.css', array(), CUSTOMIZER_REPEATER_VERSION );
wp_enqueue_style( 'craftnce-customizer-repeater-fontawesome-iconpicker', get_template_directory_uri() . '/assets/css/craftnce-iconpicker.min.css', array(), craftnce_CUSTOMIZER_REPEATER_VERSION );

wp_enqueue_script( 'customizer-repeater-script', get_template_directory_uri() . '/assets/js/customizer-repeater.js', array('jquery', 'jquery-ui-draggable', 'wp-color-picker' ), CUSTOMIZER_REPEATER_VERSION, true );
// wp_enqueue_script( 'customizer-repeater-fontawesome-iconpicker-script', get_template_directory_uri() . '/assets/js/fontawesome-iconpicker.min.js', array( 'jquery' ), CUSTOMIZER_REPEATER_VERSION, true );
wp_enqueue_script( 'craftnce-customizer-repeater-script', get_template_directory_uri() . '/assets/js/craftnce-customizer-repeater.js', array('jquery', 'jquery-ui-draggable', 'wp-color-picker' ), craftnce_CUSTOMIZER_REPEATER_VERSION, true );
}

public function render_content() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function customizer_repeater_sanitize($input){
$wp_customize->add_panel( $homePagePanel );

// Customizer Repeater Class
require_once get_theme_file_path('/lib/customizer/customizer-repeater.php');
require_once get_theme_file_path('/lib/customizer/craftnce-customizer-repeater.php');

// Home page hero options
require_once get_theme_file_path('/inc/option-panel/customizer/options/home-hero.php');
Expand Down
2 changes: 1 addition & 1 deletion page-templates/home-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
if(get_theme_mod('craftnce_show_home_info_section_setting', 1)) :
?>
<!-- Info Section -->
<section class="home-info">
<section id="content" class="home-info">
<div class="container">
<div class="row hero-h align-items-center py-5 py-lg-0">
<div class="col-lg-5">
Expand Down
2 changes: 1 addition & 1 deletion page-templates/left-sidebar-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
?>

<div class="container <?php echo esc_attr(get_theme_mod('craftnce_page_top_bottom_container_padding_setting') ? 'py-4' : ''); ?>">
<div id="content" class="container <?php echo esc_attr(get_theme_mod('craftnce_page_top_bottom_container_padding_setting') ? 'py-4' : ''); ?>">
<div class="row">
<?php
get_sidebar();
Expand Down
2 changes: 1 addition & 1 deletion page-templates/right-sidebar-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
?>

<div class="container <?php echo esc_attr(get_theme_mod('craftnce_page_top_bottom_container_padding_setting') ? 'py-4' : ''); ?>">
<div id="content" class="container <?php echo esc_attr(get_theme_mod('craftnce_page_top_bottom_container_padding_setting') ? 'py-4' : ''); ?>">
<div class="row">
<div class="col-xl-8">
<div class="row">
Expand Down
Loading

0 comments on commit 4b00341

Please sign in to comment.