Skip to content

Instantly share code, notes, and snippets.

View XanderCalvert's full-sized avatar
💭
probably coding PHP

Matt Calvert XanderCalvert

💭
probably coding PHP
View GitHub Profile
@XanderCalvert
XanderCalvert / gulpfile.js
Last active January 5, 2022 22:51
Header text for gulpfile.js
// Initialize modules
// Importing specific gulp API functions lets us write them below as series() instead of gulp.series()
const { src, dest, watch, series, parallel } = require('gulp');
// Importing all the Gulp-related packages we want to use
const sass = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const replace = require('gulp-replace');
@XanderCalvert
XanderCalvert / gulpfile.js
Created January 5, 2022 22:55
The files we need to run through gulp
const files = {
scssPath: [
'sass/*.scss',
'sass/*/*.scss',
'node_modules/datatables.net-bs4/css/dataTables.bootstrap4.css',
'src/fontawesome/css/all.css'
],
jsPaths: [
'js/framework.js',
'js/modal.js',
function move_fonts(){
return src( [ 'src/fontawesome/webfonts/*.{ttf,woff,woff2,eot,eof,svg}' ] )
.pipe(dest('webfonts')
);
}
function create_bootstrap(){
return src( [
'node_modules/popper.js/dist/umd/popper.min.js',
'node_modules/bootstrap/js/dist/util.js',
'node_modules/bootstrap/js/dist/modal.js',
'node_modules/bootstrap/js/dist/dropdown.js',
'node_modules/bootstrap/js/dist/collapse.js',
'node_modules/bootbox/bootbox.js',
'node_modules/datatables.net/js/jquery.dataTables.min.js',
'node_modules/datatables.net-bs4/js/dataTables.bootstrap4.js'
@XanderCalvert
XanderCalvert / gulpfile.js
Created January 5, 2022 23:02
create minified files
function scssTask(){
return src( files.scssPath )
.pipe(sass()) // compile SCSS to CSS
.pipe( replace('../webfonts/fa-', 'webfonts/fa-') )
.pipe(concat('style.css'))
.pipe(dest('./'))
}
function jsTask(){
return src( files.jsPaths )
@XanderCalvert
XanderCalvert / gulpfile.js
Created January 5, 2022 23:06
Watch task for gulpfile.js
// Watch task: watch SCSS and JS files for changes
function watchTask(){
    watch(files.scssPath,
        {interval: 1000, usePolling: true}, //Makes docker work
        series(
            parallel( scssTask )
        )
    );      
    watch(files.jsPaths,
@XanderCalvert
XanderCalvert / gulpfile.js
Created January 5, 2022 23:08
gulpfile.js exports
// Export the default Gulp task so it can be run
exports.default = series(
create_bootstrap,
scssTask,
IETask,
jsTask,
move_fonts,
watchTask,
);
@XanderCalvert
XanderCalvert / gulpfile.js
Created January 5, 2022 23:11
complete gulpfile
// Initialize modules
// Importing specific gulp API functions lets us write them below as series() instead of gulp.series()
const { src, dest, watch, series, parallel } = require('gulp');
// Importing all the Gulp-related packages we want to use
const sass = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const replace = require('gulp-replace');
const files = { 
@XanderCalvert
XanderCalvert / 1.php
Created April 11, 2022 22:10
Function adjusting main query in Wordpress
public function podcast_adjust_queries($query){
if ( ! is_admin() && is_post_type_archive( 'podcast' ) && $query->is_main_query() ) {
// if options to exclude
$inc_articles = get_option( 'options_include_audio_articles_in_podcast_archive' );
if ( $inc_articles ) {
$query->set( 'post_type', array( 'podcast', 'articles' ) );
$query->set( 'posts_per_page', 1 );
$query->set( 'is_podcast_archive', 1 );
$query->set( 'meta_query', array(
array( //meta_key for the articles which I am searching for
@XanderCalvert
XanderCalvert / plugin.php
Created April 11, 2022 22:16
filters for wordpress query
private function define_public_hooks() {
//Query modification
$this->loader->add_filter( 'pre_get_posts', $plugin_public, 'podcast_adjust_queries' );
$this->loader->add_filter( 'template_include', $plugin_public, 'podcast_adjust_archive' );
}