Skip to content

Commit

Permalink
Implemented chages to build Method v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelwatt committed Mar 23, 2021
1 parent aa9e35a commit 2148f82
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 50 deletions.
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
## 1.2.0


This release includes several additions and bugfixes. Now, functions.php is broken out into several files in the /lib folder to support a more streamlined workflow.

New Globals:
* require_cmb2_mapbox - (default: false) If true, the theme will require the CMB2 Mapbox fieldtype plugins.
* js_use_matchheight - (default: true) If true, the path to the matchheight library will be added to the array of scripts to combine via the scripts gulp task.
* js_use_jarallax - (default: true) If true, the path to the jarallax library will be added to the array of scripts to combine via the scripts gulp task.
* localdev_url - (default: method.test:8080) The local developement URL to set as the proxy for browsersync.

Removed Globals:
* social_options

Other Changes:
* ( build/ ) Updated to v1.2.0
* ( njk/assets/gulpfile.js ) Method's gulpfile is now compiled by build/rebuild tasks, implementing support for the new js_use_matchheight, js_use_jarallax, and localdev_url globals
* ( njk/assets/lib/class-theme-layout.php ) Removed the build_social_icons() method, which is now located in the Method_Layout class.
* ( njk/assets/lib/cmb2-options-loader.php ) Added a $prefix variable, which is the name of the current options template, but with hypens instead of underscores.
* ( njk/assets/lib/helper-functions.php ) The returned classes for 'full_width_outer_col' now includes the 'full-width-outer-col' class.
* ( njk/assets/lib/helper-functions.php ) For both the method_get_post_array() and method_get_term_array() functions, the $none argument now defaults to being an empty string, with the function ignoring it if empty. If a non-empty string is provided, a "none" item will be added to the returned array as the first array value, with an empty key.
* ( njk/assets/lib/helper-functions.php ) The method_get_content() function was removed. Instead, use: `method_filter_content( get_the_content( null, false, $post->ID ) )` (if outside the layout class) or `$this->filter_content( get_the_content( null, false, $this->id ) )` (if inside the layout class)
* ( njk/assets/lib/theme-customization.php ) In the repeatable options group for social media accounts, the service is now picked via a select element and not radio buttons. Additionally, an option for _None_ was added, and is now the default.
* ( njk/assets/lib/theme-support.php ) Added array for CMB2 Mapbox to potential required plugin arrays.

---

Expand Down
73 changes: 73 additions & 0 deletions njk/assets/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% import '_globals.html' as globals %}{% extends "_barebones.html" %}{% block content %}var gulp = require('gulp'),
sass = require('gulp-dart-sass'),
autoprefixer = require('gulp-autoprefixer'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
browserSync = require('browser-sync').create(),
del = require('del'),
watchSass = require("gulp-watch-sass"),
cleanCSS = require('gulp-clean-css');

gulp.task('process-styles', function () {
var postcss = require('gulp-postcss');
var assets = require('postcss-assets');

return gulp.src(['./theme.css','theme.min.css'])
.pipe(postcss([assets({
loadPaths: ['inc/bootstrap-icons/','assets/images/']
})]))
.pipe(gulp.dest('.'));
});

gulp.task('compile-styles', function() {
return gulp.src('./theme.scss')
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('.'))
.pipe(rename({suffix: '.min'}))
.pipe(cleanCSS('level: 2'))
.pipe(gulp.dest('.'))
.pipe(browserSync.stream())
.pipe(notify({ message: 'Styles task complete' }));
});

gulp.task('styles', gulp.series('compile-styles', 'process-styles'));

gulp.task('serve', function() {

browserSync.init({
proxy: "{{globals.localdev_url}}"
});

// Watch .scss files
gulp.watch(['./**/*.scss', '!./node_modules/', '!./.git/'], gulp.series('compile-styles', 'process-styles'));

gulp.watch(['./**/*.*', '!./node_modules/', '!./.git/']).on('change', browserSync.reload);

});

gulp.task('scripts', function() {
return gulp.src(['inc/bootstrap/js/bootstrap.bundle.js'{% if globals.js_use_matchheight %},'inc/matchHeight/jquery.matchHeight.js'{% endif %}{% if globals.js_use_jarallax %},'inc/jarallax/jarallax.js'{% endif %}])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('assets/js/scripts.js'))
.pipe(gulp.dest('.'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('.'))
.pipe(notify({ message: 'Scripts task complete' }));
});


gulp.task('watch', function() {

// Watch .scss files
gulp.watch(['./**/*.scss', '!./node_modules/', '!./.git/'], gulp.series('compile-styles', 'process-styles'));

});
{% endblock %}
30 changes: 0 additions & 30 deletions njk/assets/lib/class-theme-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,6 @@ protected function build_components() {
return;
}

protected function build_social_icons() {
$output = '';

$social_links = $this->get_option( 'social_accounts' );
if ( ! empty( $social_links ) ) {
if ( is_array( $social_links ) ) {
$output .= '<ul class="s-ics">';

foreach ( $social_links as $link ) {
$service = ( isset( $link['service'] ) ? ( ! empty( $link['service'] ) ? $link['service'] : 'facebook' ) : 'facebook' );

switch ( $service ) {
{% for item in globals.social_options %}case '{{item.id}}':
$fa = '{{item.fa}}';
break;
{% endfor %}default:
$fa = 'fab fa-facebook-f';
break;
}

$output .= ' <li>' . ( isset( $link['url'] ) ? ( ! empty( $link['url'] ) ? '<a href="' . $link['url'] . '">' : '' ) : '' ) . '<i class="' . $fa . '"></i><span class="sr-only sr-only-focusable"> ' . ucwords( $service ) . '</span>' . ( isset( $link['url'] ) ? ( ! empty( $link['url'] ) ? '</a>' : '' ) : '' ) . '</li>';
}

$output .= '</ul>';
}
}

return $output;
}

/*
Usage for archive pages:
get_header();
Expand Down
1 change: 1 addition & 0 deletions njk/assets/lib/cmb2-options-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

function {{globals.code_prefix}}load_cmb2_options( &$obj, $temps ) {
foreach ( $temps as $temp ) {
$prefix = str_replace( '-', '_', $temp );
switch ( $temp ) {
case 'example':
$obj->add_field(
Expand Down
4 changes: 2 additions & 2 deletions njk/assets/lib/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function array_key_first( array $arr ) {
// Get an array of post IDs and titles
//-----------------------------------------------------

function {{globals.code_prefix}}get_post_array( $type, $none = false ) {
function {{globals.code_prefix}}get_post_array( $type, $none = '' ) {
//lets create an array of boroughs to loop through
if ( ! empty( $none ) ) {
$output[0] = $none;
Expand All @@ -98,7 +98,7 @@ function {{globals.code_prefix}}get_post_array( $type, $none = false ) {
// Get an array of term ids and names
//-----------------------------------------------------

function {{globals.code_prefix}}get_term_array( $tax, $none = false ) {
function {{globals.code_prefix}}get_term_array( $tax, $none = '' ) {
//lets create an array of boroughs to loop through
if ( ! empty( $none ) ) {
$output[0] = $none;
Expand Down
14 changes: 10 additions & 4 deletions njk/assets/lib/theme-customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,17 @@ function {{globals.code_prefix}}register_theme_options_metabox() {
array(
'name' => 'Service',
'id' => 'service',
'type' => 'radio',
'default' => 'facebook',
'type' => 'select',
'show_option_none' => true,
'default' => '',
'desc' => __( 'Which service are you adding a link for?', '{{globals.code_textdomain}}' ),
'options' => array({% for item in globals.social_options %}
'{{item.id}}' => esc_attr__( '{{item.label}}', '{{globals.code_textdomain}}' ),{% endfor %}
'options' => array(
'facebook' => esc_attr__( 'Facebook', '{{globals.code_textdomain}}' ),
'twitter' => esc_attr__( 'Twitter', '{{globals.code_textdomain}}' ),
'linkedin' => esc_attr__( 'LinkedIn', '{{globals.code_textdomain}}' ),
'instagram' => esc_attr__( 'Instagram', '{{globals.code_textdomain}}' ),
'pinterest' => esc_attr__( 'Pinterest', '{{globals.code_textdomain}}' ),
'youtube' => esc_attr__( 'YouTube', '{{globals.code_textdomain}}' ),
),
)
);
Expand Down
6 changes: 6 additions & 0 deletions njk/assets/lib/theme-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ function {{globals.code_prefix}}register_required_plugins() {
'slug' => 'cmb2-roadway-segments',
'source' => 'https://github.com/pixelwatt/cmb2-roadway-segments/archive/master.zip',
'required' => true,
),{% endif %}{% if globals.require_cmb2_mapbox %}
array(
'name' => 'CMB2 Mapbox',
'slug' => 'cmb2-mapbox',
'source' => 'https://github.com/pixelwatt/cmb2-mapbox/archive/master.zip',
'required' => true,
),{% endif %}

);
Expand Down
26 changes: 14 additions & 12 deletions njk/templates/_globals-defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
{% set require_classic_editor = false %}
{% set require_github_updater = false %}
{% set require_cmb2_roadway_segments = false %}
{% set require_cmb2_mapbox = false %}


{# ---------------------------------------------------------------- #}
Expand All @@ -63,37 +64,38 @@
{% set code_layoutclass = "MethodThemeLayout" %}


{# ---------------------------------------------------------------- #}
{# Javascript Libraries #}
{# ---------------------------------------------------------------- #}

{% set js_use_matchheight = true %}
{% set js_use_jarallax = true %}


{# ---------------------------------------------------------------- #}
{# Common CSS Classes #}
{# ---------------------------------------------------------------- #}

{% set css_classes = [
{ id: "full_width_outer_col", class: "col-12 col-sm-11" },
{ id: "full_width_outer_col", class: "full-width-outer-col col-12 col-sm-11" },
{ id: "full_width_container", class: "full-width-container" }
] %}


{# ---------------------------------------------------------------- #}
{# Social Media Link Support #}
{# Local Development #}
{# ---------------------------------------------------------------- #}

{% set social_options = [
{ id: "facebook", label: "Facebook", fa: "fab fa-facebook-f" },
{ id: "twitter", label: "Twitter", fa: "fab fa-twitter" },
{ id: "linkedin", label: "LinkedIn", fa: "fab fa-linkedin-in" },
{ id: "instagram", label: "Instagram", fa: "fab fa-instagram" },
{ id: "pinterest", label: "Pinterest", fa: "fab fa-pinterest" },
{ id: "youtube", label: "YouTube", fa: "fab fa-youtube" }
] %}
{% set localdev_url = "method.test:8080" %}


{# ---------------------------------------------------------------- #}
{# Other #}
{# ---------------------------------------------------------------- #}

{% set jquery_version = "3.5.1" %}
{% set jquery_version = "" %}
{% set googlefonts_css_url = "" %}
{% set fontawesome_kit_url = "" %}
{% set fontawesome_kit_url = "" %} {# Not recommended, but available #)


{# ---------------------------------------------------------------- #}
Expand Down

0 comments on commit 2148f82

Please sign in to comment.