From e34084649b8253155b58e631159a6feed9bec817 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 8 Sep 2016 10:36:43 -0400 Subject: [PATCH 01/11] Bumps version to 2.0.0 --- css/style.css | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index 1329af0..9f92146 100644 --- a/css/style.css +++ b/css/style.css @@ -4,7 +4,7 @@ Description: A Wordpress child theme that descends from mitlibraries-parent Author: Design by Moth Design, development by MIT Libraries Template: libraries - Version: 1.5.0-@@branch-@@commit; + Version: 2.0.0-@@branch-@@commit; */ @import url("../libraries/style.css"); diff --git a/style.css b/style.css index e652638..53c03be 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Description: A Wordpress child theme that descends from mitlibraries-parent Author: Design by Moth Design, development by MIT Libraries Template: libraries - Version: 1.5.0-@@branch-@@commit; + Version: 2.0.0-@@branch-@@commit; News theme built for the MIT Libraries. From 336610eb633db939f4d591253541defe0661bd33 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 8 Sep 2016 10:47:00 -0400 Subject: [PATCH 02/11] Renames myScripts.js to mitlibnews.js --- functions.php | 4 ++-- js/mitlibnews.js | 13 +++++++++++++ js/myScripts.js | 35 ----------------------------------- 3 files changed, 15 insertions(+), 37 deletions(-) create mode 100644 js/mitlibnews.js delete mode 100644 js/myScripts.js diff --git a/functions.php b/functions.php index 464b1bb..6f44122 100644 --- a/functions.php +++ b/functions.php @@ -32,11 +32,11 @@ function add_styles() { add_action( 'wp_enqueue_scripts', 'add_styles' ); /** - * Add LazyLoad and MyScripts for all users + * Add LazyLoad and main javascript for all users */ function add_scripts() { wp_enqueue_script( 'lazyload', get_stylesheet_directory_uri() . '/js/lazyload.js', array( 'jquery' ), '', true ); - wp_enqueue_script( 'myScripts', get_stylesheet_directory_uri() . '/js/myScripts.js', array( 'lazyload' ), '', true ); + wp_enqueue_script( 'mitlibnews', get_stylesheet_directory_uri() . '/js/mitlibnews.js', array( 'lazyload' ), '', true ); } add_action( 'wp_enqueue_scripts', 'add_scripts' ); diff --git a/js/mitlibnews.js b/js/mitlibnews.js new file mode 100644 index 0000000..f4c9122 --- /dev/null +++ b/js/mitlibnews.js @@ -0,0 +1,13 @@ +(function($) { + + //lazy loading + $("img.img-responsive").lazyload({ + effect : "fadeIn", + effectspeed: 450, + failure_limit: 999999 + }); + + //category force selection of all news + $('input:checkbox[id=in-category-43]').attr('checked',true); + +})(jQuery); diff --git a/js/myScripts.js b/js/myScripts.js deleted file mode 100644 index 7d5ed16..0000000 --- a/js/myScripts.js +++ /dev/null @@ -1,35 +0,0 @@ - - -(function($) { - - //lazy loading - $("img.img-responsive").lazyload({ - effect : "fadeIn", - effectspeed: 450 , - failure_limit: 999999 - }); - - //category force selection of all news - $('input:checkbox[id=in-category-43]').attr('checked',true); - -})(jQuery); - - - - - - - - - - - - - - - - - - - - From 0abcd80ed5386742a805f46aadeaf5cade46e16d Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 8 Sep 2016 11:23:19 -0400 Subject: [PATCH 03/11] Adds uglify step; moves LazyLoad to npm control --- Gruntfile.js | 4 ++-- functions.php | 4 ++-- js/lazyload.js | 15 --------------- package.json | 2 ++ tasks/options/uglify.js | 10 ++++++++++ 5 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 js/lazyload.js create mode 100644 tasks/options/uglify.js diff --git a/Gruntfile.js b/Gruntfile.js index 32d98cd..3d91527 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,12 +33,12 @@ module.exports = function(grunt) { // There are basically three phases of building the production theme: // 1) Javascript preparation (concatenating and uglifying scripts) - // (coming soon) + grunt.registerTask('javascript', ['uglify']) // 2) Stylesheet preparation (SASS, autoprefixing, and minification) // (coming soon) // 3) Appending the most recent git commit to the theme version grunt.registerTask('release', ['gitinfo', 'replace']); // The default task performs all three phases. - grunt.registerTask('default', ['release']); + grunt.registerTask('default', ['javascript', 'release']); }; diff --git a/functions.php b/functions.php index 6f44122..d1add67 100644 --- a/functions.php +++ b/functions.php @@ -35,8 +35,8 @@ function add_styles() { * Add LazyLoad and main javascript for all users */ function add_scripts() { - wp_enqueue_script( 'lazyload', get_stylesheet_directory_uri() . '/js/lazyload.js', array( 'jquery' ), '', true ); - wp_enqueue_script( 'mitlibnews', get_stylesheet_directory_uri() . '/js/mitlibnews.js', array( 'lazyload' ), '', true ); + wp_enqueue_script( 'lazyload', get_stylesheet_directory_uri() . '/js/build/jquery.lazyload.min.js', array( 'jquery' ), '', true ); + wp_enqueue_script( 'mitlibnews', get_stylesheet_directory_uri() . '/js/build/mitlibnews.min.js', array( 'lazyload' ), '', true ); } add_action( 'wp_enqueue_scripts', 'add_scripts' ); diff --git a/js/lazyload.js b/js/lazyload.js deleted file mode 100644 index 3e4a5f4..0000000 --- a/js/lazyload.js +++ /dev/null @@ -1,15 +0,0 @@ -(function($,window,document,undefined){var $window=$(window);$.fn.lazyload=function(options){var elements=this;var $container;var settings={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:window,data_attribute:"original",skip_invisible:true,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};function update(){var counter=0;elements.each(function(){var $this=$(this);if(settings.skip_invisible&&!$this.is(":visible")){return;} -if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$this.trigger("appear");counter=0;}else{if(++counter>settings.failure_limit){return false;}}});} -if(options){if(undefined!==options.failurelimit){options.failure_limit=options.failurelimit;delete options.failurelimit;} -if(undefined!==options.effectspeed){options.effect_speed=options.effectspeed;delete options.effectspeed;} -$.extend(settings,options);} -$container=(settings.container===undefined||settings.container===window)?$window:$(settings.container);if(0===settings.event.indexOf("scroll")){$container.bind(settings.event,function(){return update();});} -this.each(function(){var self=this;var $self=$(self);self.loaded=false;if($self.attr("src")===undefined||$self.attr("src")===false){if($self.is("img")){$self.attr("src",settings.placeholder);}} -$self.one("appear",function(){if(!this.loaded){if(settings.appear){var elements_left=elements.length;settings.appear.call(self,elements_left,settings);} -$("").bind("load",function(){var original=$self.attr("data-"+settings.data_attribute);$self.hide();if($self.is("img")){$self.attr("src",original);}else{$self.css("background-image","url('"+original+"')");} -$self[settings.effect](settings.effect_speed);self.loaded=true;var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);if(settings.load){var elements_left=elements.length;settings.load.call(self,elements_left,settings);}}).attr("src",$self.attr("data-"+settings.data_attribute));}});if(0!==settings.event.indexOf("scroll")){$self.bind(settings.event,function(){if(!self.loaded){$self.trigger("appear");}});}});$window.bind("resize",function(){update();});if((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)){$window.bind("pageshow",function(event){if(event.originalEvent&&event.originalEvent.persisted){elements.each(function(){$(this).trigger("appear");});}});} -$(document).ready(function(){update();});return this;};$.belowthefold=function(element,settings){var fold;if(settings.container===undefined||settings.container===window){fold=(window.innerHeight?window.innerHeight:$window.height())+$window.scrollTop();}else{fold=$(settings.container).offset().top+$(settings.container).height();} -return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){var fold;if(settings.container===undefined||settings.container===window){fold=$window.width()+$window.scrollLeft();}else{fold=$(settings.container).offset().left+$(settings.container).width();} -return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){var fold;if(settings.container===undefined||settings.container===window){fold=$window.scrollTop();}else{fold=$(settings.container).offset().top;} -return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){var fold;if(settings.container===undefined||settings.container===window){fold=$window.scrollLeft();}else{fold=$(settings.container).offset().left;} -return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.inviewport=function(element,settings){return!$.rightoffold(element,settings)&&!$.leftofbegin(element,settings)&&!$.belowthefold(element,settings)&&!$.abovethetop(element,settings);};$.extend($.expr[":"],{"below-the-fold":function(a){return $.belowthefold(a,{threshold:0});},"above-the-top":function(a){return!$.belowthefold(a,{threshold:0});},"right-of-screen":function(a){return $.rightoffold(a,{threshold:0});},"left-of-screen":function(a){return!$.rightoffold(a,{threshold:0});},"in-viewport":function(a){return $.inviewport(a,{threshold:0});},"above-the-fold":function(a){return!$.belowthefold(a,{threshold:0});},"right-of-fold":function(a){return $.rightoffold(a,{threshold:0});},"left-of-fold":function(a){return!$.rightoffold(a,{threshold:0});}});})(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index f86127d..bd8bb36 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,12 @@ "devDependencies": { "glob": "^7.0.5", "grunt": "^1.0.1", + "grunt-contrib-uglify": "^2.0.0", "grunt-gitinfo": "^0.1.8", "grunt-replace": "^1.0.1" }, "dependencies": { + "jquery-lazyload": "^1.9.7", "load-grunt-tasks": "^3.5.0" } } diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js new file mode 100644 index 0000000..133ce61 --- /dev/null +++ b/tasks/options/uglify.js @@ -0,0 +1,10 @@ +module.exports = { + core: { + src: 'js/mitlibnews.js', + dest: 'js/build/mitlibnews.min.js' + }, + lazyLoad: { + src: 'node_modules/jquery-lazyload/jquery.lazyload.js', + dest: 'js/build/jquery.lazyload.min.js' + } +} From ccebb100819b42c432985ed5496a4cfb0709e666 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 8 Sep 2016 11:36:49 -0400 Subject: [PATCH 04/11] Adds jshint and 'test' task. Minimal adjustment to hinted files --- .jshintrc | 24 ++++++++++++++++++++++++ Gruntfile.js | 6 ++++-- js/mitlibnews.js | 2 ++ package.json | 1 + tasks/options/jshint.js | 9 +++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .jshintrc create mode 100644 tasks/options/jshint.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..aa73e00 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,24 @@ +{ + "curly" : true, + "eqeqeq" : true, + "immed" : true, + "latedef" : true, + "newcap" : true, + "noarg" : true, + "sub" : true, + "undef" : true, + "boss" : true, + "eqnull" : true, + "node" : true, + "es5" : false, + "globals" : { + "it" : false, + "xit" : false, + "describe" : false, + "xdescribe" : false, + "beforeEach" : false, + "afterEach" : false, + "expect" : false, + "spyOn" : false + } +} diff --git a/Gruntfile.js b/Gruntfile.js index 3d91527..62eacdd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -32,13 +32,15 @@ module.exports = function(grunt) { require('load-grunt-tasks')(grunt); // There are basically three phases of building the production theme: + // 0) Testing / linting + grunt.registerTask('test', ['jshint']); // 1) Javascript preparation (concatenating and uglifying scripts) - grunt.registerTask('javascript', ['uglify']) + grunt.registerTask('javascript', ['uglify']); // 2) Stylesheet preparation (SASS, autoprefixing, and minification) // (coming soon) // 3) Appending the most recent git commit to the theme version grunt.registerTask('release', ['gitinfo', 'replace']); // The default task performs all three phases. - grunt.registerTask('default', ['javascript', 'release']); + grunt.registerTask('default', ['test', 'javascript', 'release']); }; diff --git a/js/mitlibnews.js b/js/mitlibnews.js index f4c9122..a2ed51c 100644 --- a/js/mitlibnews.js +++ b/js/mitlibnews.js @@ -1,3 +1,5 @@ +var jQuery; + (function($) { //lazy loading diff --git a/package.json b/package.json index bd8bb36..41b63a9 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "devDependencies": { "glob": "^7.0.5", "grunt": "^1.0.1", + "grunt-contrib-jshint": "^1.0.0", "grunt-contrib-uglify": "^2.0.0", "grunt-gitinfo": "^0.1.8", "grunt-replace": "^1.0.1" diff --git a/tasks/options/jshint.js b/tasks/options/jshint.js new file mode 100644 index 0000000..c13a152 --- /dev/null +++ b/tasks/options/jshint.js @@ -0,0 +1,9 @@ +module.exports = { + all: [ + 'Gruntfile.js', + 'js/mitlibnews.js' + ], + options: { + jshintrc: '.jshintrc' + } +} From 12d07496198aee0fc9b9e4096b7502d8ab2788e7 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Thu, 8 Sep 2016 12:26:23 -0400 Subject: [PATCH 05/11] Adds Jasmine for unit tests --- Gruntfile.js | 4 ++-- js/src/mitlibnews.loader.js | 3 +++ js/tests/mitlibnews.loader.spec.js | 5 +++++ package.json | 5 +++-- tasks/options/jasmine.js | 6 ++++++ 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 js/src/mitlibnews.loader.js create mode 100644 js/tests/mitlibnews.loader.spec.js create mode 100644 tasks/options/jasmine.js diff --git a/Gruntfile.js b/Gruntfile.js index 62eacdd..af8eb31 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,9 +33,9 @@ module.exports = function(grunt) { // There are basically three phases of building the production theme: // 0) Testing / linting - grunt.registerTask('test', ['jshint']); + grunt.registerTask('test', ['jshint', 'jasmine']); // 1) Javascript preparation (concatenating and uglifying scripts) - grunt.registerTask('javascript', ['uglify']); + grunt.registerTask('javascript', ['uglify']); // 2) Stylesheet preparation (SASS, autoprefixing, and minification) // (coming soon) // 3) Appending the most recent git commit to the theme version diff --git a/js/src/mitlibnews.loader.js b/js/src/mitlibnews.loader.js new file mode 100644 index 0000000..b6b74af --- /dev/null +++ b/js/src/mitlibnews.loader.js @@ -0,0 +1,3 @@ +function Loader(params) { + "use strict"; +} \ No newline at end of file diff --git a/js/tests/mitlibnews.loader.spec.js b/js/tests/mitlibnews.loader.spec.js new file mode 100644 index 0000000..f104e78 --- /dev/null +++ b/js/tests/mitlibnews.loader.spec.js @@ -0,0 +1,5 @@ +describe("Loader test suite", function() { + it("expects tautologies", function() { + expect(true).toBe(true); + }); +}); \ No newline at end of file diff --git a/package.json b/package.json index 41b63a9..43f77c4 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "mitlibraries-news", - "version": "1.3.0", + "version": "2.0.0", "description": "A Wordpress child theme that descends from mitlibraries-parent", - "main": "index.js", + "main": "mitlibnews.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -22,6 +22,7 @@ "devDependencies": { "glob": "^7.0.5", "grunt": "^1.0.1", + "grunt-contrib-jasmine": "^1.0.3", "grunt-contrib-jshint": "^1.0.0", "grunt-contrib-uglify": "^2.0.0", "grunt-gitinfo": "^0.1.8", diff --git a/tasks/options/jasmine.js b/tasks/options/jasmine.js new file mode 100644 index 0000000..5c4f360 --- /dev/null +++ b/tasks/options/jasmine.js @@ -0,0 +1,6 @@ +module.exports = { + src: 'js/src/**/*.js', + options: { + specs: 'js/tests/**/*.js' + } +} From ef07874ea3559ec3cf75ea848aec56a0aa142f26 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Mon, 12 Sep 2016 13:31:37 -0400 Subject: [PATCH 06/11] Adds parameters and tests --- js/mitlibnews.js | 4 +- js/src/mitlibnews.loader.js | 72 +++++++++++++++++++++++++++++- js/tests/mitlibnews.loader.spec.js | 41 +++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/js/mitlibnews.js b/js/mitlibnews.js index a2ed51c..1318404 100644 --- a/js/mitlibnews.js +++ b/js/mitlibnews.js @@ -1,4 +1,4 @@ -var jQuery; +var jQuery, NewsLoader, Loader; (function($) { @@ -12,4 +12,6 @@ var jQuery; //category force selection of all news $('input:checkbox[id=in-category-43]').attr('checked',true); + NewsLoader = new Loader(); + })(jQuery); diff --git a/js/src/mitlibnews.loader.js b/js/src/mitlibnews.loader.js index b6b74af..7d4ee5f 100644 --- a/js/src/mitlibnews.loader.js +++ b/js/src/mitlibnews.loader.js @@ -1,3 +1,73 @@ function Loader(params) { "use strict"; -} \ No newline at end of file + + console.log('Loader here'); + + // Default parameters + // Container is the HTML element to which everything is added. + this.container = 'mitlibnews-container'; + // Page is the counter used for pagination. + this.page = 1; + // Pagesize sets how many articles are loaded in a page + this.pagesize = 9; + // Postcontent determines what type of content is loaded from the API + this.postcontent = 'all'; + + // Read param object, if passed, and set new values + if ( params ) { + if ( '' !== params.container ) { + this.setContainer( params.container ); + } + if ( '' !== params.page ) { + this.setPage( params.page ); + } + if ( '' !== params.pagesize ) { + this.setPagesize( params.pagesize ); + } + if ( '' !== params.postcontent ) { + this.setPostcontent( params.postcontent ); + } + } + + // Connect to markup, read data attributes +} + +Loader.prototype = { + constructor: Loader, + + // Container getter and setter + getContainer : function() { + return this.container; + }, + + setContainer : function(value) { + this.container = value; + }, + + // Page getter and setter + getPage : function() { + return +this.page; + }, + + setPage : function(value) { + this.page = +value; + }, + + // Pagesize getter and setter + getPagesize : function() { + return +this.pagesize; + }, + + setPagesize : function(value) { + this.pagesize = +value; + }, + + // Postcontent getter and setter + getPostcontent : function() { + return this.postcontent; + }, + + setPostcontent : function(value) { + this.postcontent = value; + } +}; \ No newline at end of file diff --git a/js/tests/mitlibnews.loader.spec.js b/js/tests/mitlibnews.loader.spec.js index f104e78..795c026 100644 --- a/js/tests/mitlibnews.loader.spec.js +++ b/js/tests/mitlibnews.loader.spec.js @@ -2,4 +2,45 @@ describe("Loader test suite", function() { it("expects tautologies", function() { expect(true).toBe(true); }); + + it("should have expected defaults", function() { + var test = new Loader(); + expect( test.container ).toEqual('mitlibnews-container'); + expect( test.page ).toEqual(1); + expect( test.pagesize ).toEqual(9); + expect( test.postcontent ).toEqual('all'); + }); + + it("should allow objects passed in definition", function() { + var test = new Loader({container: 'foo', page: 3, pagesize: 5, postcontent: 'bar'}); + expect( test.container ).toEqual('foo'); + expect( test.page ).toEqual(3); + expect( test.pagesize ).toEqual(5); + expect( test.postcontent ).toEqual('bar'); + }); + + it("should have container getter and setter methods", function() { + var test = new Loader(); + expect( test.getContainer() ).toEqual('mitlibnews-container'); + expect( test.getContainer( test.setContainer('bar') ) ).toEqual('bar'); + }); + + it("should have page getter and setter methods", function() { + var test = new Loader(); + expect( test.getPage() ).toEqual(1); + expect( test.getPage( test.setPage(2) ) ).toEqual(2); + }); + + it("should have pagesize getter and setter methods", function() { + var test = new Loader(); + expect( test.getPagesize() ).toEqual(9); + expect( test.getPagesize( test.setPagesize(12) ) ).toEqual(12); + }); + + it("should have postcontent getter and setter methods", function() { + var test = new Loader(); + expect( test.getPostcontent() ).toEqual('all'); + expect( test.getPostcontent( test.setPostcontent('baz') ) ).toEqual('baz'); + }); + }); \ No newline at end of file From eb0f4706a667eacb14adcb2d99b7a0d282d30ad5 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Mon, 12 Sep 2016 15:27:54 -0400 Subject: [PATCH 07/11] Adds initialization step --- js/src/mitlibnews.loader.js | 51 +++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/js/src/mitlibnews.loader.js b/js/src/mitlibnews.loader.js index 7d4ee5f..64ba4c2 100644 --- a/js/src/mitlibnews.loader.js +++ b/js/src/mitlibnews.loader.js @@ -1,11 +1,13 @@ +var document; + function Loader(params) { "use strict"; - console.log('Loader here'); - // Default parameters // Container is the HTML element to which everything is added. this.container = 'mitlibnews-container'; + // Postcontainer is DOM element corresponding to Container. + this.postcontainer = ''; // Page is the counter used for pagination. this.page = 1; // Pagesize sets how many articles are loaded in a page @@ -30,11 +32,56 @@ function Loader(params) { } // Connect to markup, read data attributes + this.initialize(); + } Loader.prototype = { constructor: Loader, + // Initialization + initialize : function() { + // Connect to markup + this.postcontainer = document.getElementById( this.getContainer() ); + + // If no post container is found, then we quit and do nothing further. + if( !this.postcontainer ) { + return false; + } + + // Read data attributes + this.loadAttributes(); + + // Load posts + this.loadPosts(); + }, + + // Load attributes + loadAttributes : function() { + // If the post container doesn't have data attributes, then leave the defaults + if ( !this.postcontainer || !this.postcontainer.dataset ) { + console.log('Container or data attributes not found - leaving defaults'); + return true; + } + + if ( this.postcontainer.dataset.pagesize ) { + console.log('Overriding page size'); + this.setPagesize( this.postcontainer.dataset.pagesize ); + } + + if ( this.postcontainer.dataset.postcontent ) { + console.log('Overriding post content'); + this.setPostcontent( this.postcontainer.dataset.postcontent ); + } + + return true; + }, + + // Load posts + loadPosts : function() { + console.log('Loading ' + this.getPagesize() + ' posts (page ' + this.getPage() + ')'); + }, + // Container getter and setter getContainer : function() { return this.container; From ad6a21febedc41024cb036b661586afefbe140c4 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Mon, 12 Sep 2016 16:09:07 -0400 Subject: [PATCH 08/11] Applies module to author page --- author.php | 2 +- functions.php | 5 ++- js/src/mitlibnews.loader.js | 60 +++++++++++++++++++++++++++--- js/tests/mitlibnews.loader.spec.js | 10 +++++ tasks/options/uglify.js | 4 ++ 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/author.php b/author.php index 2b746a8..1c87abe 100644 --- a/author.php +++ b/author.php @@ -65,7 +65,7 @@ -
+
diff --git a/functions.php b/functions.php index d1add67..f47f934 100644 --- a/functions.php +++ b/functions.php @@ -32,11 +32,12 @@ function add_styles() { add_action( 'wp_enqueue_scripts', 'add_styles' ); /** - * Add LazyLoad and main javascript for all users + * Add LazyLoad, loader, and main javascript for all users */ function add_scripts() { wp_enqueue_script( 'lazyload', get_stylesheet_directory_uri() . '/js/build/jquery.lazyload.min.js', array( 'jquery' ), '', true ); - wp_enqueue_script( 'mitlibnews', get_stylesheet_directory_uri() . '/js/build/mitlibnews.min.js', array( 'lazyload' ), '', true ); + wp_enqueue_script( 'loader', get_stylesheet_directory_uri() . '/js/build/mitlibnews.loader.min.js', '', '', true ); + wp_enqueue_script( 'mitlibnews', get_stylesheet_directory_uri() . '/js/build/mitlibnews.min.js', array( 'lazyload', 'loader' ), '', true ); } add_action( 'wp_enqueue_scripts', 'add_scripts' ); diff --git a/js/src/mitlibnews.loader.js b/js/src/mitlibnews.loader.js index 64ba4c2..897f431 100644 --- a/js/src/mitlibnews.loader.js +++ b/js/src/mitlibnews.loader.js @@ -1,4 +1,4 @@ -var document; +var document, jQuery; function Loader(params) { "use strict"; @@ -41,7 +41,7 @@ Loader.prototype = { // Initialization initialize : function() { - // Connect to markup + // Look up specified post container in DOM this.postcontainer = document.getElementById( this.getContainer() ); // If no post container is found, then we quit and do nothing further. @@ -56,30 +56,78 @@ Loader.prototype = { this.loadPosts(); }, + /** + * Build query + * + * This builds a JSON object that will be fed to the API in order to return posts + */ + buildQuery : function() { + var query = { + 'page': this.getPage(), + }; + var filter = { + 'posts_per_page': this.getPagesize(), + }; + // Context-specific values + if ( this.getPostcontent() === 'author' ) { + filter.author = this.postcontainer.dataset.postauthor; + } + // Assemble pieces into query object + query.filter = filter; + return query; + }, + // Load attributes loadAttributes : function() { // If the post container doesn't have data attributes, then leave the defaults if ( !this.postcontainer || !this.postcontainer.dataset ) { - console.log('Container or data attributes not found - leaving defaults'); return true; } if ( this.postcontainer.dataset.pagesize ) { - console.log('Overriding page size'); this.setPagesize( this.postcontainer.dataset.pagesize ); } if ( this.postcontainer.dataset.postcontent ) { - console.log('Overriding post content'); this.setPostcontent( this.postcontainer.dataset.postcontent ); } + // At this point, the status of values like this.postcontent are set. + return true; }, // Load posts loadPosts : function() { - console.log('Loading ' + this.getPagesize() + ' posts (page ' + this.getPage() + ')'); + + // Assemble query object + var query = this.buildQuery(); + + console.log('Query object:'); + console.log(query); + + // Query the API + jQuery.ajax({ + url: '/news/wp-json/posts', + data: query, + dataType: 'json', + type: 'GET', + success: function(data) { + jQuery.each(data, function( index, value ) { + console.log(value); + }); + }, + error: function() { + console.log('Error'); + } + }); + }, + + // Render a JSON object into HTML + renderCard: function(index, post) { + console.log(index); + console.log(post); + jQuery( this.postContainer ).append( post ); }, // Container getter and setter diff --git a/js/tests/mitlibnews.loader.spec.js b/js/tests/mitlibnews.loader.spec.js index 795c026..4ad55f3 100644 --- a/js/tests/mitlibnews.loader.spec.js +++ b/js/tests/mitlibnews.loader.spec.js @@ -43,4 +43,14 @@ describe("Loader test suite", function() { expect( test.getPostcontent( test.setPostcontent('baz') ) ).toEqual('baz'); }); + it("should build a query object", function() { + var test = new Loader(); + defaultQuery = { + page: 1, + filter: { + posts_per_page: 9, + } + } + expect( test.buildQuery() ).toEqual(defaultQuery); + }); }); \ No newline at end of file diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js index 133ce61..d87ea2b 100644 --- a/tasks/options/uglify.js +++ b/tasks/options/uglify.js @@ -6,5 +6,9 @@ module.exports = { lazyLoad: { src: 'node_modules/jquery-lazyload/jquery.lazyload.js', dest: 'js/build/jquery.lazyload.min.js' + }, + loader: { + src: 'js/src/mitlibnews.loader.js', + dest: 'js/build/mitlibnews.loader.min.js' } } From 347570a8a51a94a55645166e8bbeda0bb3141395 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Tue, 13 Sep 2016 15:53:38 -0400 Subject: [PATCH 09/11] Adds newer PHP and Wordpress releases to Travis linting --- .travis.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95d75ab..206d836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,12 @@ language: php # Declare versions of PHP to use. Use one decimal max. php: + # aliased to a recent 7.0.x version + - "7.0" + # aliased to a recent 5.6.x version + - "5.6" # aliased to a recent 5.5.x version - # "5.5" + - "5.5" # aliased to a recent 5.4.x version - "5.4" # aliased to a recent 5.3.x version @@ -26,6 +30,10 @@ env: # @link https://github.com/WordPress/WordPress # WP_VERSION=master WP_MULTISITE=0 # WP_VERSION=master WP_MULTISITE=1 + # WordPress 4.6 + # @link https://github.com/WordPress/WordPress/tree/4.6-branch + # WP_VERSION=4.6 WP_MULTISITE=0 + - WP_VERSION=4.6 WP_MULTISITE=1 # WordPress 4.5 # @link https://github.com/WordPress/WordPress/tree/4.5-branch # WP_VERSION=4.5 WP_MULTISITE=0 @@ -41,7 +49,11 @@ env: matrix: allow_failures: - php: "5.4" - - env: WP_VERSION=4.5 WP_MULTISITE=1 + - php: "5.5" + - php: "5.6" + - php: "7.0" + - env: "WP_VERSION=4.5 WP_MULTISITE=1" + - env: "WP_VERSION=4.6 WP_MULTISITE=1" fast_finish: true # Use this to prepare the system to install prerequisites or dependencies. From 2e045c7b8b86a3cc602c638198058f5017e24f43 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Tue, 13 Sep 2016 16:15:49 -0400 Subject: [PATCH 10/11] Updates inline comments per Squiz.Commenting.LongConditionClosingComment --- additionalPosts-biblio.php | 2 +- additionalPosts-cat.php | 4 ++-- additionalPosts-search.php | 2 +- category.php | 2 +- functions.php | 2 +- inc/events.php | 2 +- index.php | 2 +- page-biblio-archive.php | 2 +- page-bibliotech.php | 2 +- single.php | 2 +- test-template.php | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/additionalPosts-biblio.php b/additionalPosts-biblio.php index de5feb2..9968347 100644 --- a/additionalPosts-biblio.php +++ b/additionalPosts-biblio.php @@ -62,7 +62,7 @@ - + diff --git a/additionalPosts-cat.php b/additionalPosts-cat.php index bffe643..45669c8 100644 --- a/additionalPosts-cat.php +++ b/additionalPosts-cat.php @@ -69,7 +69,7 @@ $("#another").hide(); have_posts() ) : ?> @@ -86,7 +86,7 @@ - + diff --git a/additionalPosts-search.php b/additionalPosts-search.php index 884bb97..72a094c 100644 --- a/additionalPosts-search.php +++ b/additionalPosts-search.php @@ -55,7 +55,7 @@ function set_search( $q ) { if ( 'search' == $query_split[0] ) { $search_args['s'] = urldecode( $query_split[1] ); } -} // foreach +} // End foreach(). $the_query = new WP_Query( $search_args ); // The set_search() function is defined above. diff --git a/category.php b/category.php index 1a5b3c7..6feb2ff 100644 --- a/category.php +++ b/category.php @@ -33,7 +33,7 @@ - + diff --git a/functions.php b/functions.php index f47f934..56fc46b 100644 --- a/functions.php +++ b/functions.php @@ -366,7 +366,7 @@ function biblio_taxonomy() { // Hook into the 'init' action. add_action( 'init', 'biblio_taxonomy', 0 ); -} +} // End if(). /** * Registers news sidebar diff --git a/inc/events.php b/inc/events.php index 1e3bb75..b30dff7 100644 --- a/inc/events.php +++ b/inc/events.php @@ -48,5 +48,5 @@
- + diff --git a/index.php b/index.php index 535a6b0..954a63b 100644 --- a/index.php +++ b/index.php @@ -133,7 +133,7 @@ 6 ) { get_template_part( 'inc/more-posts' ); -} //$i > 6 +} // End if(). ?>
diff --git a/page-biblio-archive.php b/page-biblio-archive.php index 7223c4e..2acb03b 100644 --- a/page-biblio-archive.php +++ b/page-biblio-archive.php @@ -59,7 +59,7 @@ ?>

diff --git a/page-bibliotech.php b/page-bibliotech.php index a0b44ab..a101bd7 100644 --- a/page-bibliotech.php +++ b/page-bibliotech.php @@ -50,7 +50,7 @@ - + diff --git a/single.php b/single.php index 2c41d9c..bfb51f0 100644 --- a/single.php +++ b/single.php @@ -109,7 +109,7 @@ - + diff --git a/test-template.php b/test-template.php index 166b814..5502c79 100644 --- a/test-template.php +++ b/test-template.php @@ -82,7 +82,7 @@ - + @@ -261,7 +261,7 @@

- +
From d6e7589d6c4ce469264c5883a435bcbac53e6350 Mon Sep 17 00:00:00 2001 From: Matt Bernhardt Date: Tue, 13 Sep 2016 17:03:49 -0400 Subject: [PATCH 11/11] Adds markup for API loading to all pages, builds custom V2 endpoint. This PR ends with logging loaded posts to the browser console. Pagination, and card rendering, are next. Signed-off-by: Matt Bernhardt --- additionalPosts-biblio.php | 2 +- additionalPosts-cat.php | 6 +- additionalPosts-search.php | 2 +- archive.php | 13 +- category.php | 6 +- codesniffer.ruleset.xml | 2 + functions.php | 189 ++++++++++++++++++++++++++++- inc/events.php | 2 +- index.php | 4 +- js/src/mitlibnews.loader.js | 48 +++++++- js/tests/mitlibnews.loader.spec.js | 3 +- page-biblio-archive.php | 2 +- page-bibliotech.php | 4 +- page-events.php | 8 +- page-news.php | 2 +- search.php | 4 +- single.php | 11 +- test-template.php | 4 +- 18 files changed, 270 insertions(+), 42 deletions(-) diff --git a/additionalPosts-biblio.php b/additionalPosts-biblio.php index 9968347..aedbd75 100644 --- a/additionalPosts-biblio.php +++ b/additionalPosts-biblio.php @@ -62,7 +62,7 @@ - + diff --git a/additionalPosts-cat.php b/additionalPosts-cat.php index 45669c8..ae96224 100644 --- a/additionalPosts-cat.php +++ b/additionalPosts-cat.php @@ -68,9 +68,7 @@ - + have_posts() ) : ?> @@ -86,7 +84,7 @@ - + diff --git a/additionalPosts-search.php b/additionalPosts-search.php index 72a094c..f6fc065 100644 --- a/additionalPosts-search.php +++ b/additionalPosts-search.php @@ -55,7 +55,7 @@ function set_search( $q ) { if ( 'search' == $query_split[0] ) { $search_args['s'] = urldecode( $query_split[1] ); } -} // End foreach(). +} $the_query = new WP_Query( $search_args ); // The set_search() function is defined above. diff --git a/archive.php b/archive.php index 813809b..140ce50 100644 --- a/archive.php +++ b/archive.php @@ -20,15 +20,12 @@ get_header(); $date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) ); +get_template_part( 'inc/sub-header' ); +if ( (get_post_type( get_the_ID() ) === 'bibliotech') || (cat_is_ancestor_of( 73, $cat ) or is_category( 73 )) ) { + get_template_part( 'inc/bib-header' ); +} ?> - - - - - -
@@ -36,7 +33,7 @@
-
+
@@ -18,7 +16,7 @@
-
+
' . 'Category: ' . '' . single_cat_title( '', false ) . '' . '' ); @@ -33,7 +31,7 @@ - + diff --git a/codesniffer.ruleset.xml b/codesniffer.ruleset.xml index b05691f..83ab96f 100644 --- a/codesniffer.ruleset.xml +++ b/codesniffer.ruleset.xml @@ -13,6 +13,8 @@ + + diff --git a/functions.php b/functions.php index 56fc46b..abef27d 100644 --- a/functions.php +++ b/functions.php @@ -113,6 +113,7 @@ function mitlibnews_register_news_posts() { 'labels' => $labelsFeatures, 'public' => true, 'menu_position' => 5, + 'show_in_rest' => true, 'supports' => array( 'title' ), 'taxonomies' => array( 'category' ), @@ -157,6 +158,7 @@ function theme_apto_object_taxonomies( $object_taxonomies, $post_type ) { 'labels' => $labelsFeatures, 'public' => true, 'menu_position' => 5, + 'show_in_rest' => true, 'supports' => $supports_default, 'taxonomies' => array( 'category' ), ); @@ -357,6 +359,7 @@ function biblio_taxonomy() { 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, + 'show_in_rest' => true, 'show_tagcloud' => true, ); register_taxonomy( 'bibliotech_issues', array( 'bibliotech' ), $args ); @@ -366,7 +369,7 @@ function biblio_taxonomy() { // Hook into the 'init' action. add_action( 'init', 'biblio_taxonomy', 0 ); -} // End if(). +} // End bibliotechs custom taxonomy. /** * Registers news sidebar @@ -398,3 +401,187 @@ function SearchFilter( $query ) { return $query; } add_filter( 'pre_get_posts','SearchFilter' ); + + +/** + * Custom API endpoints + * + * @param WP_REST_Request $request Full data about the request. + */ +function mitlibnews_cards( WP_REST_Request $request ) { + + $args = array(); + $response = array(); + + // Get passed parameters for building the right query. + $params = $request->get_params(); + + // Build query type. + $categories = $params['categories']; + + // Posts per page needs to be an integer. + $args['posts_per_page'] = mitlibnews_cardargs_postsperpage( $params['filter']['posts_per_page'] ); + + // Only certain post types are recognized. + $args['post_type'] = mitlibnews_cardargs_posttype( $params['type'] ); + + // If requested, filter by author. + $args['author'] = mitlibnews_cardargs_author( $params['filter'] ); + + // If requested, filter by a single category. + if ( array_key_exists( 'categories', $params ) && is_array( $categories ) && is_int( (int) $params['categories'][0] ) ) { + $args['cat'] = (int) $params['categories'][0]; + } + + // If requested, filter by a single tag. + if ( array_key_exists( 'issue', $params ) ) { + $args['bibliotech_issues'] = (string) $params['issue']; + } + + // If requested, filter by a single tag. + if ( array_key_exists( 's', $params ) ) { + $args['s'] = (string) $params['s']; + } + + // If requested, change sort order. + $args['orderby'] = mitlibnews_cardargs_orderby( $params['filter'] ); + + // If requested, filter by custom field. + if ( array_key_exists( 'meta_query', $params['filter'] ) ) { + $args['meta_query'] = mitlibnews_cardargs_metaquery( $params['filter']['meta_query'] ); + } + + // Build the query. + $args['order'] = 'DESC'; + + // Execute the query. + $posts = new WP_Query( $args ); + + // Assemble the response. + $controller = new WP_REST_Posts_Controller( 'post' ); + if ( $posts->have_posts() ) { + while ( $posts->have_posts() ) { + $posts->the_post(); + $post = $posts->post; + $data = $controller->prepare_item_for_response( $post, $request ); + $response[] = $controller->prepare_response_for_collection( $data ); + } + wp_reset_postdata(); + } + + // Return the response. + return new WP_REST_Response( $response, 200 ); + +} +add_action( 'rest_api_init', function() { + register_rest_route( 'mitlibnews/v1', '/cards', array( + 'methods' => 'GET', + 'callback' => 'mitlibnews_cards', + )); +}); + +/** + * Assemble API query: author + * + * @param array $input Contents of $params['filter']. + */ +function mitlibnews_cardargs_author( $input ) { + if ( array_key_exists( 'author', $input ) && is_int( (int) $input['author'] ) ) { + return (int) $input['author']; + } + return ''; +} + +/** + * Assemble API query: orderby + * + * @param array $input Contents of $params['filter']. + */ +function mitlibnews_cardargs_orderby( $input ) { + $orderby = 'post_date'; + if ( array_key_exists( 'orderby', $input ) ) { + $orderby = (string) $input['orderby']; + } + return $orderby; +} + + +/** + * Assemble API query: posts_per_page + * + * @param int $input Contents of $params['filter']['posts_per_page']. + */ +function mitlibnews_cardargs_postsperpage( $input ) { + $posts_per_page = 9; + if ( is_int( (int) $input ) ) { + $posts_per_page = (int) $input; + } + return $posts_per_page; +} + +/** + * Assemble API query: post_type + * + * Only three values are accepted for post_type queries + * + * @param int $input Contents of $params['type']. + */ +function mitlibnews_cardargs_posttype( $input ) { + $post_type = array(); + if ( is_array( $input ) ) { + if ( in_array( 'bibliotech', $input, true ) ) { + $post_type[] = 'bibliotech'; + } + if ( in_array( 'post', $input, true ) ) { + $post_type[] = 'post'; + } + if ( in_array( 'spotlights', $input, true ) ) { + $post_type[] = 'spotlights'; + } + } + return $post_type; +} + +/** + * Assemble API query: meta_query array + * + * @param int $input Contents of $params['filter']. + */ +function mitlibnews_cardargs_metaquery( $input ) { + $meta_query = array(); + if ( 'is_event' === $input[0]['key'] ) { + // We currently only support meta_queries based on the is_event custom field. + if ( 'false' === $input[0]['value'] ) { + // The query is for items which aren't events. + $meta_query[] = mitlibnews_cardargs_metaquery_item( 'is_event', '!=', '1', 'NUMERIC' ); + } elseif ( 'true' === $input[0]['value'] ) { + // The query is for events, but past or future? + $meta_query[] = mitlibnews_cardargs_metaquery_item( 'is_event', '=', '1', 'NUMERIC' ); + if ( 'future' === $input[0]['type'] ) { + // Query for future events. + $meta_query[] = mitlibnews_cardargs_metaquery_item( 'event_date', '>=', date( 'Y-m-d' ), 'DATE' ); + } elseif ( 'past' === $input[0]['type'] ) { + // Query for past events. + $meta_query[] = mitlibnews_cardargs_metaquery_item( 'event_date', '<', date( 'Y-m-d' ), 'DATE' ); + } + } + } + return $meta_query; +} + +/** + * Assemble API query: meta_query item + * + * @param string $key The variable being tested. + * @param string $compare The comparision being performed. + * @param string $value The value being tested for. + * @param string $type The type of comparison being performed. + */ +function mitlibnews_cardargs_metaquery_item( $key, $compare, $value, $type ) { + return array( + 'key' => $key, + 'value' => $value, + 'compare' => $compare, + 'type' => $type, + ); +} diff --git a/inc/events.php b/inc/events.php index b30dff7..c76f902 100644 --- a/inc/events.php +++ b/inc/events.php @@ -48,5 +48,5 @@
- + diff --git a/index.php b/index.php index 954a63b..3eaa9e5 100644 --- a/index.php +++ b/index.php @@ -89,7 +89,7 @@
-
+
6 ) { get_template_part( 'inc/more-posts' ); -} // End if(). +} ?>
diff --git a/js/src/mitlibnews.loader.js b/js/src/mitlibnews.loader.js index 897f431..c55c8af 100644 --- a/js/src/mitlibnews.loader.js +++ b/js/src/mitlibnews.loader.js @@ -42,11 +42,15 @@ Loader.prototype = { // Initialization initialize : function() { // Look up specified post container in DOM + console.log('Looking for ' + this.getContainer() ); this.postcontainer = document.getElementById( this.getContainer() ); // If no post container is found, then we quit and do nothing further. if( !this.postcontainer ) { + console.log('Post container not found...'); return false; + } else { + console.log('Post container found. Continuing...'); } // Read data attributes @@ -68,12 +72,53 @@ Loader.prototype = { var filter = { 'posts_per_page': this.getPagesize(), }; + var type = ['post', 'bibliotech', 'spotlights']; // Context-specific values if ( this.getPostcontent() === 'author' ) { filter.author = this.postcontainer.dataset.postauthor; + // Author indexes don't show Spotlights + type = ['post', 'bibliotech']; + } else if ( this.getPostcontent() === 'bibliotech' ) { + // Only return bibliotech content + type = ['bibliotech']; + } else if ( this.getPostcontent() === 'category' ) { + query.categories = [this.postcontainer.dataset.postcategory]; + } else if ( this.getPostcontent() === 'futureevents' ) { + // Only return post content + type = ['post']; + filter.meta_query = [{ + 'key': 'is_event', + 'value': true, + 'type': 'future', + }]; + } else if ( this.getPostcontent() === 'issue' ) { + query.issue = this.postcontainer.dataset.postissue; + type = ['bibliotech']; + } else if ( this.getPostcontent() === 'news' ) { + // Only return post content + type = ['post']; + filter.meta_query = [{ + 'key': 'is_event', + 'value': false, + }]; + } else if ( this.getPostcontent() === 'pastevents' ) { + // Only return post content + type = ['post']; + filter.meta_query = [{ + 'key': 'is_event', + 'value': true, + 'type': 'past', + }]; + } else if ( this.getPostcontent() === 'related' ) { + // Related queries are sorted randomly + filter.orderby = 'rand'; + query.categories = [this.postcontainer.dataset.postcategory]; + } else if ( this.getPostcontent() === 'search' ) { + query.search = this.postcontainer.dataset.search; } // Assemble pieces into query object query.filter = filter; + query.type = type; return query; }, @@ -108,12 +153,13 @@ Loader.prototype = { // Query the API jQuery.ajax({ - url: '/news/wp-json/posts', + url: '/news/wp-json/mitlibnews/v1/cards', data: query, dataType: 'json', type: 'GET', success: function(data) { jQuery.each(data, function( index, value ) { + console.log('\n' + value.type + '\n' + value.title.rendered ); console.log(value); }); }, diff --git a/js/tests/mitlibnews.loader.spec.js b/js/tests/mitlibnews.loader.spec.js index 4ad55f3..6fb5bee 100644 --- a/js/tests/mitlibnews.loader.spec.js +++ b/js/tests/mitlibnews.loader.spec.js @@ -49,7 +49,8 @@ describe("Loader test suite", function() { page: 1, filter: { posts_per_page: 9, - } + }, + type: ['post', 'bibliotech', 'spotlights'] } expect( test.buildQuery() ).toEqual(defaultQuery); }); diff --git a/page-biblio-archive.php b/page-biblio-archive.php index 2acb03b..9c8f6ea 100644 --- a/page-biblio-archive.php +++ b/page-biblio-archive.php @@ -59,7 +59,7 @@ ?>

diff --git a/page-bibliotech.php b/page-bibliotech.php index a101bd7..f428b2d 100644 --- a/page-bibliotech.php +++ b/page-bibliotech.php @@ -50,7 +50,7 @@ - + @@ -58,7 +58,7 @@
-
+
posts; ?> -

Upcoming classes & events

+
0 ) { $i = -1; @@ -123,7 +123,7 @@

Past classes & events

-
+
0 ) { $i = -1; @@ -146,9 +146,8 @@ - diff --git a/page-news.php b/page-news.php index 4ef8412..b69a313 100644 --- a/page-news.php +++ b/page-news.php @@ -22,7 +22,7 @@
-
+

News

diff --git a/search.php b/search.php index ed4ea60..6c2aa59 100644 --- a/search.php +++ b/search.php @@ -15,9 +15,9 @@
-
+ +
- diff --git a/single.php b/single.php index bfb51f0..bb472a1 100644 --- a/single.php +++ b/single.php @@ -109,7 +109,7 @@
- + @@ -171,20 +171,21 @@ $currentPost = get_the_ID(); -$myCatId = $category[ $r ]->cat_ID; + $category_id = $category[ $r ]->cat_ID; $args = array( 'post_type' => array( 'post', 'bibliotech', 'spotlights' ), - 'cat' => $myCatId, + 'cat' => $category_id, 'posts_per_page' => '3', 'order' => 'DESC', 'orderby' => 'date', 'post__not_in' => array( $currentPost ), ); - ?> + +?> -
+
- + @@ -261,7 +261,7 @@

- +