Snippets

Joseph Dickson Scratch 1.0.3

Created by Joseph Dickson

File footer.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+/**
+ * The template for displaying the footer
+ *
+ * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
+ *
+ * @since Scratch JD 1.0.0
+ */
+?>
+		<footer id="footer">
+
+			<?php 
+			// Assign Footer Widget
+			if ( is_active_sidebar( 'footer' ) ) {
+				echo '<ul class="sidebar">';
+					dynamic_sidebar( 'footer' );
+				echo '</ul>';
+			}
+
+			// Assign Footer Menu
+			wp_nav_menu( array( 'theme_location' => 'footer-menu' ) );
+
+			// WordPress Footer Scripts
+			wp_footer();
+			?>
+
+		</footer>
+	</body>
+</html>

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+/**
+ *	@since Scratch JD 1.0.0
+ *
+ * 	Proper way to enqueue scripts and styles
+ */
+function scratch_jd_scripts() {
+
+	wp_enqueue_style( 'scratch-jd', get_stylesheet_uri() );
+}
+add_action( 'wp_enqueue_scripts', 'scratch_jd_scripts' );
+
+// Register Header and Footer Menus
+function scratch_jd_theme_setup() {
+	register_nav_menus(
+		array( 
+			'header-menu' => __( 'Header', 'scratch-jd' ),
+			'footer-menu' => __( 'Footer', 'scratch-jd' ),
+		)
+	);
+
+// Register a Sidebar
+	register_sidebar(
+		array(
+			'id'		=> 'footer',
+			'name'		=> __( 'Footer', 'textdomain' ),
+			'description'	=> __( 'Displays in the footer on the left side', 'textdomain'),
+		)
+	);
+}
+
+add_action( 'after_setup_theme', 'scratch_jd_theme_setup' );
+
+/**
+ *  Add Theme Support
+ *  WordPress features that are not available by default
+ *  but desired for this theme
+ *
+ *  Title Tag
+ *  https://codex.wordpress.org/Title_Tag
+ *  https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/
+ */
+
+function scratch_jd_add_theme_support() {
+
+	add_theme_support( 'title-tag' );
+}
+add_action( 'after_setup_theme', 'scratch_jd_add_theme_support' );

File header.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+/**
+ * The template for displaying the header
+ *
+ * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
+ *
+ * @since Scratch JD 1.0.0
+ */
+?>
+<!DOCTYPE html>
+<html <?php language_attributes(); ?>>
+
+	<head>
+		<?php
+		// WordPress Header Scripts
+		wp_head();
+
+
+		// Check if function exists for 'title-tag' which is  added in functions.php
+		if ( ! function_exists( '_wp_render_title_tag' ) ) {
+
+			function scratch_jd_render_title() {
+
+		?>
+
+				<title><?php wp_title( '-', true, 'right' ); ?></title>
+
+		<?php
+			}
+			
+			add_action( 'wp_head', 'scratch_jd_render_title' );
+
+		}
+		?>
+			<meta charset="<?php bloginfo( 'charset' ); ?>">
+
+			<meta name= "description" content="<?php bloginfo( 'description' ); ?>">
+
+			<meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+			<a class="skip-link screen-reader-text" href="#content"><?php esc_html_e( 'Skip to content', 'scratch-jd' ); ?></a>
+
+			<a class="skip-link screen-reader-text" href="#footer"><?php esc_html_e( 'Skip to footer', 'scratch-jd' ); ?></a>
+	</head>
+
+	<body <?php body_class(); ?>>
+
+
+<?php
+// Assign Header Menu
+wp_nav_menu( array( 'theme_location' => 'header-menu' ) );

File index.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+/**
+ * The Index template: the catch-all template if a more specific template is not available
+ *
+ * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
+ *
+ * @since Scratch JD 1.0.0
+ */
+
+// Get the Header
+get_header();
+?>
+
+		<div id="content">
+
+		<?php
+		// The Loop
+		if ( have_posts() ) {
+			while ( have_posts() ) {
+				the_post(); 
+
+				// Display the post title and HTML              
+				the_title();
+				
+				// Display post content
+				the_content();
+				
+			} // end while
+		} // end if
+		?>
+
+		</div><!-- #content -->
+
+<?php
+// Get the Footer
+get_footer();

File style.css Added

  • Ignore whitespace
  • Hide word diff
+/**
+ *	Theme Name:	Scratch JD
+ *	Theme URI:	https://joseph-dickson.com/scratch-jd
+ *	Author:		Joseph Dickson
+ *	Author URI:	https://joseph-dickson.com
+ *	Description:	Scratch is a no thrills theme.
+ *	Version:	1.0.3
+ *	License:	GNU General Public License v3
+ *	License URI:	https://www.gnu.org/licenses/gpl-3.0.en.html
+ *	Text Domain:	scratch-jd
+ */
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.