Skip to content

Commit

Permalink
Merge pull request #243 from studiopress/develop
Browse files Browse the repository at this point in the history
Genesis Sample 2.10.0
  • Loading branch information
dreamwhisper authored May 1, 2019
2 parents 33777ed + 5a04576 commit ad63d66
Show file tree
Hide file tree
Showing 25 changed files with 642 additions and 167 deletions.
14 changes: 0 additions & 14 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,3 @@
*.ttf binary
*.woff binary
*.woff2 binary

# Omit during export.
.editorconfig export-ignore
.eslintignore export-ignore
.eslintrc.js export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.github/ export-ignore
.scripts/ export-ignore
.stylelintrc.json export-ignore
composer.json export-ignore
phpcs.xml.dist export-ignore
package-lock.json export-ignore
package.json export-ignore
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
labels: bug
assignees: ''

---
Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ assignees: ''

**Check standards**
- [ ] Lint PHP (`composer install` then `composer phpcs`)
- [ ] Lint CSS (`npm install` then `npm run lint:css`)
- [ ] Lint JS (`npm install` then `npm run lint:js`)
- [ ] Lint CSS (`npm install` then `npm run lint:css`)
- [ ] Autoprefix CSS `npm run autoprefixer`

**Final release**
- [ ] PR to merge Develop to Master
Expand Down
4 changes: 1 addition & 3 deletions .scripts/makepot.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ wpi18n.makepot(
potHeaders: {
'poedit': true,
'x-poedit-basepath': '..',
'report-msgid-bugs-to': 'StudioPress <[email protected]>',
'last-translator': 'StudioPress <[email protected]>',
'language-team': 'StudioPress <[email protected]>'
'report-msgid-bugs-to': 'StudioPress <[email protected]>'
}
}
).then(
Expand Down
128 changes: 128 additions & 0 deletions .scripts/makezip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env node

// Creates a zip file for distribution, excluding development and system files.
// Using this instead of `git archive` for greater control, and to avoid an
// issue with some applications (such as Path Finder) incorrectly decompressing
// archives created by git archive with the `--prefix` flag.
//
// Also renames some .md files to .txt to reduce support requests.

const fs = require("fs");
const path = require("path");

const chalk = require("chalk");
const archiver = require("archiver");
const recursive = require("recursive-readdir");
const prettyBytes = require("pretty-bytes");

const excludes = [
".DS_Store",
".editorconfig",
".eslintignore",
".eslintrc.js",
".git",
".gitattributes",
".github",
".gitignore",
".scripts",
".stylelintrc.json",
"*.zip",
"composer.json",
"composer.lock",
"node_modules",
"package-lock.json",
"package.json",
"phpcs.xml.dist",
"vendor"
];

// Creates a file to stream archive data to.
// Uses the name in package.json, such as 'child-theme.zip'.
let output = fs.createWriteStream(`${process.env.npm_package_name}.zip`);

let archive = archiver("zip", {
zlib: { level: 9 } // Best compression.
});

/**
* Sets up the file output stream and archive.
*/
const setupZipArchive = function() {
// Listens for all archive data to be written.
// Report the zip name and size, and rename *.txt files back to *.md again.
output.on("close", function() {
let fileSize = prettyBytes(archive.pointer());
console.log(
chalk`{cyan Created ${process.env.npm_package_name}.zip, ${fileSize}}`
);

renameTxtFilesToMarkdown();
});

// Displays warnings during archiving.
archive.on("warning", function(err) {
if (err.code === "ENOENT") {
console.log(err);
} else {
throw err;
}
});

// Catches errors during archiving.
archive.on("error", function(err) {
throw err;
});

// Pipes archive data to the file.
archive.pipe(output);
};

/**
* Rename files from *.md to *.txt.
* Returns a promise so zip can be done once rename is complete.
*/
const renameMarkdownFilesToTxt = new Promise(function(resolve, reject) {
console.log(chalk`{cyan Renaming .md files to .txt}`);
["CHANGELOG.md", "README.md", "CONTRIBUTING.md"].forEach(function(file) {
if (fs.existsSync(file)) {
fs.renameSync(file, file.replace(".md", ".txt"));
}
});
resolve("Success");
});

/**
* Loops through theme directory, omitting files in the `exclude` array.
* Adds each file to the zip archive.
*/
const zipFiles = function() {
recursive(process.cwd(), excludes, function(err, files) {
let relativePath;

console.log(chalk`{cyan Making zip file}`);
files.forEach(function(filePath) {
relativePath = path.relative(process.cwd(), filePath);
archive.file(filePath, {
name: `${process.env.npm_package_name}/${relativePath}`
});
});

archive.finalize();
});
};

/**
* Renames txt file to markdown.
* Executed in the output stream close event.
*/
const renameTxtFilesToMarkdown = function() {
console.log(chalk`{cyan Renaming .txt files to .md}`);
["CHANGELOG.txt", "README.txt", "CONTRIBUTING.txt"].forEach(function(file) {
if (fs.existsSync(file)) {
fs.renameSync(file, file.replace(".txt", ".md"));
}
});
};

setupZipArchive();
renameMarkdownFilesToTxt.then(zipFiles);
35 changes: 0 additions & 35 deletions .scripts/md-to-txt.js

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Genesis Sample Theme Changelog

## [2.10.0] - 2019-05-01
Requires Genesis 2.10.0+.

* Added: create a WPForms form during one-click theme setup and insert a WPForms block on the sample contact page.
* Added: remove link in hidden title when custom logo is in use for better accessibility.
* Changed: set full-width page layout for the Block Examples and About pages during one-click theme setup.
* Changed: improve styling of tables.
* Changed: improve editor button block styling.
* Changed: clarify wording of Customizer color labels.
* Changed: remove matchHeight script and use CSS flex instead to match heights of WooCommerce product lists.
* Fixed: WooCommmerce shop pages now use the selected page layout instead of the default site layout on sites using object caching.
* Fixed: update the `npm run zip` script to prevent an issue with zip decompression for apps such as Path Finder. (npm scripts are available in the version of Genesis Sample on GitHub: https://github.com/studiopress/genesis-sample/).

## [2.9.1] - 2019-03-19
* Added: Contributing guidelines.
* Added: Tooling to lint JavaScript to WordPress coding standards (`npm run lint:js` and `npm run fix:js`).
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ You can then type any of these commands:
- `npm run lint:css` to generate a report of style violations for `style.css`.
- `npm run lint:js` to generate a report of style violations for JavaScript files.
- `npm run fix:js` to fix any JavaScript style violations that can be corrected automatically.
- `npm run zip` to create a genesis-sample.zip of the current branch. Excludes files marked export-ignore in `.gitattributes`.
- `npm run zip` to create a genesis-sample.zip. Files in the `excludes` array in `scripts/makezip.js` are omitted.

### Packaging for distribution

1. Follow the install instructions for npm scripts above.
2. Switch to the git branch you plan to distribute.
3. Bump version numbers manually and commit those changes.
4. Type `npm run zip` to create `genesis-sample.zip`. Files marked export-ignore in `.gitattributes` are excluded from the zip.

The `zip` command is an alias for `git archive -o genesis-sample.zip --prefix=genesis-sample/ HEAD`. The `zip` command also includes a script to rename certain Markdown files to `.txt` files within the created zip file.
4. Type `npm run zip` to create `genesis-sample.zip`. Files in the `excludes` array in `scripts/makezip.js` are omitted from the zip. `filename.md` files will be renamed to `filename.txt`.
12 changes: 2 additions & 10 deletions config/import/content/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
$genesis_sample_about_image_url = CHILD_URL . '/config/import/images/about.jpg';

return <<<CONTENT
<!-- wp:atomic-blocks/ab-spacer {"spacerHeight":70} -->
<div style="color:#ddd" class="wp-block-atomic-blocks-ab-spacer ab-block-spacer ab-divider-solid ab-divider-size-1"><hr style="height:70px"/></div>
<!-- /wp:atomic-blocks/ab-spacer -->
<!-- wp:image {"id":2141,"align":"center"} -->
<div class="wp-block-image"><figure class="aligncenter"><img src="$genesis_sample_about_image_url" alt="" class="wp-image-2141"/></figure></div>
<!-- /wp:image -->
Expand All @@ -30,11 +26,7 @@
<!-- wp:columns -->
<div class="wp-block-columns has-2-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:heading {"level":1} -->
<h1>About Us</h1>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<div class="wp-block-column"><!-- wp:paragraph -->
<p>Hello! We are StudioPress, and we build themes with an emphasis on typography, white space, and mobile-optimized design to make your website look absolutely breathtaking. </p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->
Expand All @@ -50,7 +42,7 @@
<!-- wp:paragraph {"align":"right"} -->
<p style="text-align:right">
1234 Block Blvd.<br>San Francisco, CA 94120
1234 Block Blvd.<br>San Francisco, CA 94120
</p>
<!-- /wp:paragraph --></div>
Expand Down
8 changes: 0 additions & 8 deletions config/import/content/block-examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
*/

return <<<CONTENT
<!-- wp:atomic-blocks/ab-spacer {"spacerHeight":70} -->
<div style="color:#ddd" class="wp-block-atomic-blocks-ab-spacer ab-block-spacer ab-divider-solid ab-divider-size-1"><hr style="height:70px"/></div>
<!-- /wp:atomic-blocks/ab-spacer -->
<!-- wp:heading {"level":1} -->
<h1>Block Content Examples</h1>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>Below are examples of column classes that are available in the block editor.</p>
<!-- /wp:paragraph -->
Expand Down
9 changes: 8 additions & 1 deletion config/import/content/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Genesis Sample.
*
* Contact page content optionally installed after theme activation.
* Will create a form with WPForms and embed on the page as a WPForms block.
*
* Visit `/wp-admin/admin.php?page=genesis-getting-started` to trigger import.
*
Expand All @@ -12,8 +13,14 @@
* @link https://www.studiopress.com/
*/

// Requires helper WPForms function to create a new form.
require_once get_stylesheet_directory() . '/lib/wpforms.php';

// Swaps the default content below with a WPForms contact form block if the WPForms plugin is active.
add_action( 'genesis_onboarding_after_import_content', 'studiopress_insert_contact_form', 10, 2 );

return <<<CONTENT
<!-- wp:paragraph -->
<p>Add a contact form to this page with the pre-installed WPForms Lite plugin (Third Party). Learn <a href="https://my.studiopress.com/documentation/wpforms/plugin-usage/create-contact-forms-with-wpforms/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">how to create a form using WPForms</a>.</p>
<p>Add a contact form to this page with the WPForms Lite plugin (Third Party). Learn <a href="https://my.studiopress.com/documentation/wpforms/plugin-usage/create-contact-forms-with-wpforms/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">how to create a form using WPForms</a>.</p>
<!-- /wp:paragraph -->
CONTENT;
2 changes: 1 addition & 1 deletion config/import/content/homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<!-- wp:column -->
<div class="wp-block-column"><!-- wp:button {"customTextColor":"#f5f5f5","align":"right","className":"is-style-outline"} -->
<div class="wp-block-button alignright is-style-outline"><a class="wp-block-button__link has-text-color" href="#" style="color:#f5f5f5">Get in touch</a></div>
<div class="wp-block-button alignright is-style-outline home-contact"><a class="wp-block-button__link has-text-color" href="#" style="color:#f5f5f5">Get in touch</a></div>
<!-- /wp:button --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div></div></div>
Expand Down
4 changes: 2 additions & 2 deletions config/onboarding.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@
'post_content' => require dirname( __FILE__ ) . '/import/content/block-examples.php',
'post_type' => 'page',
'post_status' => 'publish',
'page_template' => 'page-templates/blocks.php',
'comment_status' => 'closed',
'ping_status' => 'closed',
'meta_input' => array( '_genesis_layout' => 'full-width-content' ),
),
'about' => array(
'post_title' => 'About Us',
'post_content' => require dirname( __FILE__ ) . '/import/content/about.php',
'post_type' => 'page',
'post_status' => 'publish',
'page_template' => 'page-templates/blocks.php',
'featured_image' => CHILD_URL . '/config/import/images/about.jpg',
'comment_status' => 'closed',
'ping_status' => 'closed',
'meta_input' => array( '_genesis_layout' => 'full-width-content' ),
),
'contact' => array(
'post_title' => 'Contact Us',
Expand Down
24 changes: 24 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,30 @@ function genesis_sample_responsive_menu_settings() {
// Adds custom logo in Customizer > Site Identity.
add_theme_support( 'custom-logo', genesis_get_config( 'custom-logo' ) );

add_filter( 'genesis_seo_title', 'genesis_sample_header_title', 10, 3 );
/**
* Removes the link from the hidden site title if a custom logo is in use.
*
* Without this filter, the site title is hidden with CSS when a custom logo
* is in use, but the link it contains is still accessible by keyboard.
*
* @since 1.2.0
*
* @param string $title The full title.
* @param string $inside The content inside the title element.
* @param string $wrap The wrapping element name, such as h1.
* @return string The site title with anchor removed if a custom logo is active.
*/
function genesis_sample_header_title( $title, $inside, $wrap ) {

if ( has_custom_logo() ) {
$inside = get_bloginfo( 'name' );
}

return sprintf( '<%1$s class="site-title">%2$s</%1$s>', $wrap, $inside );

}

// Renames primary and secondary navigation menus.
add_theme_support( 'genesis-menus', genesis_get_config( 'menus' ) );

Expand Down
Loading

0 comments on commit ad63d66

Please sign in to comment.