From 9c579af9ecd3f8653b7ba218da730b25781029ee Mon Sep 17 00:00:00 2001 From: dillon Date: Thu, 25 Jun 2015 10:51:16 -0700 Subject: [PATCH 1/8] edited catalog to try and fix the height issue. --- wp-content/plugins/pressbooks/includes/pb-catalog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-content/plugins/pressbooks/includes/pb-catalog.php b/wp-content/plugins/pressbooks/includes/pb-catalog.php index 8db93108..1f78e5a2 100644 --- a/wp-content/plugins/pressbooks/includes/pb-catalog.php +++ b/wp-content/plugins/pressbooks/includes/pb-catalog.php @@ -317,7 +317,7 @@ function _base_url() { }); $container.isotope({ itemSelector: '.book-data', - layoutMode: 'fitRows', + layoutMode: 'fitRows' }); function webkitTrigger( isoInstance, laidOutItems ) { $container.equalizer(); From 2cd177f67de71c604639c6ddee91401cb7cbebf2 Mon Sep 17 00:00:00 2001 From: dillon Date: Thu, 25 Jun 2015 11:27:32 -0700 Subject: [PATCH 2/8] edited catalog to try and fix the height issue. --- wp-content/plugins/pressbooks/includes/pb-catalog.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-content/plugins/pressbooks/includes/pb-catalog.php b/wp-content/plugins/pressbooks/includes/pb-catalog.php index 1f78e5a2..734a4ca7 100644 --- a/wp-content/plugins/pressbooks/includes/pb-catalog.php +++ b/wp-content/plugins/pressbooks/includes/pb-catalog.php @@ -252,7 +252,9 @@ function _base_url() { jQuery.noConflict(); jQuery(function ($) { var $container = $('#catalog-content'); - $('.filter-group-1').click( function () { + $container.equalizer({ columns: '> div.book-data', min: 350, resizeable: false }); + + $('.filter-group-1').click( function () { var filter1_id = $(this).attr( 'data-filter' ); var filter1_name = $(this).text(); if ( $('.filter-group-2.active').length !== 0 ) { @@ -322,7 +324,6 @@ function _base_url() { function webkitTrigger( isoInstance, laidOutItems ) { $container.equalizer(); } - $container.equalizer({ columns: '> div.book-data', min: 350, resizeable: false }); }); // ]]> From 7f0daf3cc80c26487b85c185ba1efb32a5607b83 Mon Sep 17 00:00:00 2001 From: dillon Date: Thu, 2 Jul 2015 13:45:57 -0700 Subject: [PATCH 3/8] added deliverance to candela-advanced theme --- .../themes/candela-advanced/functions.php | 2 + .../themes/candela-advanced/js/deliverance.js | 1356 +++++++++++++++++ .../themes/candela-advanced/js/deliveryMan.js | 37 + 3 files changed, 1395 insertions(+) create mode 100644 wp-content/plugins/candela-utility/themes/candela-advanced/js/deliverance.js create mode 100644 wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js diff --git a/wp-content/plugins/candela-utility/themes/candela-advanced/functions.php b/wp-content/plugins/candela-utility/themes/candela-advanced/functions.php index d861dad7..258fcd67 100644 --- a/wp-content/plugins/candela-utility/themes/candela-advanced/functions.php +++ b/wp-content/plugins/candela-utility/themes/candela-advanced/functions.php @@ -13,6 +13,8 @@ function fitzgerald_enqueue_styles() { function cadvanced_enqueue_scripts() { wp_enqueue_script('foundation', get_stylesheet_directory_uri() . '/js/foundation.min.js'); + wp_enqueue_script('deliverance', get_stylesheet_directory_uri() . '/js/deliverance.js', [], '', true); + wp_enqueue_script('deliveryMan', get_stylesheet_directory_uri() . '/js/deliveryMan.js', [], '', true); } add_action( 'wp_print_styles', 'fitzgerald_enqueue_styles' ); diff --git a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliverance.js b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliverance.js new file mode 100644 index 00000000..93442843 --- /dev/null +++ b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliverance.js @@ -0,0 +1,1356 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 200 && res.status < 300) { + return self.callback(err, res); + } + + var new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); + new_err.original = err; + new_err.response = res; + new_err.status = res.status; + + self.callback(err || new_err, res); + }); +} + +/** + * Mixin `Emitter`. + */ + +Emitter(Request.prototype); + +/** + * Allow for extension + */ + +Request.prototype.use = function(fn) { + fn(this); + return this; +} + +/** + * Set timeout to `ms`. + * + * @param {Number} ms + * @return {Request} for chaining + * @api public + */ + +Request.prototype.timeout = function(ms){ + this._timeout = ms; + return this; +}; + +/** + * Clear previous timeout. + * + * @return {Request} for chaining + * @api public + */ + +Request.prototype.clearTimeout = function(){ + this._timeout = 0; + clearTimeout(this._timer); + return this; +}; + +/** + * Abort the request, and clear potential timeout. + * + * @return {Request} + * @api public + */ + +Request.prototype.abort = function(){ + if (this.aborted) return; + this.aborted = true; + this.xhr.abort(); + this.clearTimeout(); + this.emit('abort'); + return this; +}; + +/** + * Set header `field` to `val`, or multiple fields with one object. + * + * Examples: + * + * req.get('/') + * .set('Accept', 'application/json') + * .set('X-API-Key', 'foobar') + * .end(callback); + * + * req.get('/') + * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) + * .end(callback); + * + * @param {String|Object} field + * @param {String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.set = function(field, val){ + if (isObject(field)) { + for (var key in field) { + this.set(key, field[key]); + } + return this; + } + this._header[field.toLowerCase()] = val; + this.header[field] = val; + return this; +}; + +/** + * Remove header `field`. + * + * Example: + * + * req.get('/') + * .unset('User-Agent') + * .end(callback); + * + * @param {String} field + * @return {Request} for chaining + * @api public + */ + +Request.prototype.unset = function(field){ + delete this._header[field.toLowerCase()]; + delete this.header[field]; + return this; +}; + +/** + * Get case-insensitive header `field` value. + * + * @param {String} field + * @return {String} + * @api private + */ + +Request.prototype.getHeader = function(field){ + return this._header[field.toLowerCase()]; +}; + +/** + * Set Content-Type to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.xml = 'application/xml'; + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('application/xml') + * .send(xmlstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + +Request.prototype.type = function(type){ + this.set('Content-Type', request.types[type] || type); + return this; +}; + +/** + * Set Accept to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + +Request.prototype.accept = function(type){ + this.set('Accept', request.types[type] || type); + return this; +}; + +/** + * Set Authorization field value with `user` and `pass`. + * + * @param {String} user + * @param {String} pass + * @return {Request} for chaining + * @api public + */ + +Request.prototype.auth = function(user, pass){ + var str = btoa(user + ':' + pass); + this.set('Authorization', 'Basic ' + str); + return this; +}; + +/** +* Add query-string `val`. +* +* Examples: +* +* request.get('/shoes') +* .query('size=10') +* .query({ color: 'blue' }) +* +* @param {Object|String} val +* @return {Request} for chaining +* @api public +*/ + +Request.prototype.query = function(val){ + if ('string' != typeof val) val = serialize(val); + if (val) this._query.push(val); + return this; +}; + +/** + * Write the field `name` and `val` for "multipart/form-data" + * request bodies. + * + * ``` js + * request.post('/upload') + * .field('foo', 'bar') + * .end(callback); + * ``` + * + * @param {String} name + * @param {String|Blob|File} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.field = function(name, val){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(name, val); + return this; +}; + +/** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `filename`. + * + * ``` js + * request.post('/upload') + * .attach(new Blob(['hey!'], { type: "text/html"})) + * .end(callback); + * ``` + * + * @param {String} field + * @param {Blob|File} file + * @param {String} filename + * @return {Request} for chaining + * @api public + */ + +Request.prototype.attach = function(field, file, filename){ + if (!this._formData) this._formData = new root.FormData(); + this._formData.append(field, file, filename); + return this; +}; + +/** + * Send `data`, defaulting the `.type()` to "json" when + * an object is given. + * + * Examples: + * + * // querystring + * request.get('/search') + * .end(callback) + * + * // multiple data "writes" + * request.get('/search') + * .send({ search: 'query' }) + * .send({ range: '1..5' }) + * .send({ order: 'desc' }) + * .end(callback) + * + * // manual json + * request.post('/user') + * .type('json') + * .send('{"name":"tj"}) + * .end(callback) + * + * // auto json + * request.post('/user') + * .send({ name: 'tj' }) + * .end(callback) + * + * // manual x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send('name=tj') + * .end(callback) + * + * // auto x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send({ name: 'tj' }) + * .end(callback) + * + * // defaults to x-www-form-urlencoded + * request.post('/user') + * .send('name=tobi') + * .send('species=ferret') + * .end(callback) + * + * @param {String|Object} data + * @return {Request} for chaining + * @api public + */ + +Request.prototype.send = function(data){ + var obj = isObject(data); + var type = this.getHeader('Content-Type'); + + // merge + if (obj && isObject(this._data)) { + for (var key in data) { + this._data[key] = data[key]; + } + } else if ('string' == typeof data) { + if (!type) this.type('form'); + type = this.getHeader('Content-Type'); + if ('application/x-www-form-urlencoded' == type) { + this._data = this._data + ? this._data + '&' + data + : data; + } else { + this._data = (this._data || '') + data; + } + } else { + this._data = data; + } + + if (!obj || isHost(data)) return this; + if (!type) this.type('json'); + return this; +}; + +/** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + +Request.prototype.callback = function(err, res){ + var fn = this._callback; + this.clearTimeout(); + fn(err, res); +}; + +/** + * Invoke callback with x-domain error. + * + * @api private + */ + +Request.prototype.crossDomainError = function(){ + var err = new Error('Origin is not allowed by Access-Control-Allow-Origin'); + err.crossDomain = true; + this.callback(err); +}; + +/** + * Invoke callback with timeout error. + * + * @api private + */ + +Request.prototype.timeoutError = function(){ + var timeout = this._timeout; + var err = new Error('timeout of ' + timeout + 'ms exceeded'); + err.timeout = timeout; + this.callback(err); +}; + +/** + * Enable transmission of cookies with x-domain requests. + * + * Note that for this to work the origin must not be + * using "Access-Control-Allow-Origin" with a wildcard, + * and also must set "Access-Control-Allow-Credentials" + * to "true". + * + * @api public + */ + +Request.prototype.withCredentials = function(){ + this._withCredentials = true; + return this; +}; + +/** + * Initiate request, invoking callback `fn(res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +Request.prototype.end = function(fn){ + var self = this; + var xhr = this.xhr = request.getXHR(); + var query = this._query.join('&'); + var timeout = this._timeout; + var data = this._formData || this._data; + + // store callback + this._callback = fn || noop; + + // state change + xhr.onreadystatechange = function(){ + if (4 != xhr.readyState) return; + + // In IE9, reads to any property (e.g. status) off of an aborted XHR will + // result in the error "Could not complete the operation due to error c00c023f" + var status; + try { status = xhr.status } catch(e) { status = 0; } + + if (0 == status) { + if (self.timedout) return self.timeoutError(); + if (self.aborted) return; + return self.crossDomainError(); + } + self.emit('end'); + }; + + // progress + var handleProgress = function(e){ + if (e.total > 0) { + e.percent = e.loaded / e.total * 100; + } + self.emit('progress', e); + }; + if (this.hasListeners('progress')) { + xhr.onprogress = handleProgress; + } + try { + if (xhr.upload && this.hasListeners('progress')) { + xhr.upload.onprogress = handleProgress; + } + } catch(e) { + // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. + // Reported here: + // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context + } + + // timeout + if (timeout && !this._timer) { + this._timer = setTimeout(function(){ + self.timedout = true; + self.abort(); + }, timeout); + } + + // querystring + if (query) { + query = request.serializeObject(query); + this.url += ~this.url.indexOf('?') + ? '&' + query + : '?' + query; + } + + // initiate request + xhr.open(this.method, this.url, true); + + // CORS + if (this._withCredentials) xhr.withCredentials = true; + + // body + if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) { + // serialize stuff + var serialize = request.serialize[this.getHeader('Content-Type')]; + if (serialize) data = serialize(data); + } + + // set header fields + for (var field in this.header) { + if (null == this.header[field]) continue; + xhr.setRequestHeader(field, this.header[field]); + } + + // send stuff + this.emit('request', this); + xhr.send(data); + return this; +}; + +/** + * Expose `Request`. + */ + +request.Request = Request; + +/** + * Issue a request: + * + * Examples: + * + * request('GET', '/users').end(callback) + * request('/users').end(callback) + * request('/users', callback) + * + * @param {String} method + * @param {String|Function} url or callback + * @return {Request} + * @api public + */ + +function request(method, url) { + // callback + if ('function' == typeof url) { + return new Request('GET', method).end(url); + } + + // url first + if (1 == arguments.length) { + return new Request('GET', method); + } + + return new Request(method, url); +} + +/** + * GET `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.get = function(url, data, fn){ + var req = request('GET', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.query(data); + if (fn) req.end(fn); + return req; +}; + +/** + * HEAD `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.head = function(url, data, fn){ + var req = request('HEAD', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * DELETE `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.del = function(url, fn){ + var req = request('DELETE', url); + if (fn) req.end(fn); + return req; +}; + +/** + * PATCH `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.patch = function(url, data, fn){ + var req = request('PATCH', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * POST `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} data + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.post = function(url, data, fn){ + var req = request('POST', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * PUT `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} data or fn + * @param {Function} fn + * @return {Request} + * @api public + */ + +request.put = function(url, data, fn){ + var req = request('PUT', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * Expose `request`. + */ + +module.exports = request; + +},{"emitter":2,"reduce":3}],2:[function(require,module,exports){ + +/** + * Expose `Emitter`. + */ + +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks[event] = this._callbacks[event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; + +},{}],3:[function(require,module,exports){ + +/** + * Reduce `arr` with `fn`. + * + * @param {Array} arr + * @param {Function} fn + * @param {Mixed} initial + * + * TODO: combatible error handling? + */ + +module.exports = function(arr, fn, initial){ + var idx = 0; + var len = arr.length; + var curr = arguments.length == 3 + ? initial + : arr[idx++]; + + while (idx < len) { + curr = fn.call(null, curr, arr[idx], ++idx, arr); + } + + return curr; +}; +},{}],4:[function(require,module,exports){ +(function (global){ +var Deliverance = function(options){ + var request = require('superagent'); + + var opt = { + jwt: options.jwt ? options.jwt : null, + endpoint: options.endpoint ? options.endpoint : "https://127.0.0.1/report" + }; + + this.setOption = function(name, value){ + opt[name] = value; + }; + + this.send = function(data, callback){ + + request + .post(opt.endpoint) + .send(data) + .withCredentials() + .set("Authorization", opt.jwt) + .set('Cache-Control', 'no-cache,no-store,must-revalidate,max-age=-1') + .end(function(err, res){ + + if(err) console.error("an HTTP request error has occured:", err); + + callback(err, res); + + }); + }; + +}; + +module.exports = Deliverance; + +global.Deliverance = Deliverance; + + +}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"superagent":1}]},{},[4]) \ No newline at end of file diff --git a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js new file mode 100644 index 00000000..5cad49b1 --- /dev/null +++ b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js @@ -0,0 +1,37 @@ + +window.onload = function() { + + console.log("<<=========>> PEW PEW <<=======>>"); + + var deliverance = new Deliverance({ + jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiQ2FuZGVsYSIsImlzcyI6IjEyNy4wLjAuMSIsImlhdCI6MTMwMDgxOTM4MCwic2NvcGUiOlsiYWRkX2V2ZW50Il19.14mdTPoTQZtlIsr93D8uWnFGc5ntUHzr7clUm3uE_Mw", + endpoint: "https://127.0.0.1:444/report" + }); + + deliverance.send({ + user_id: 4, + type: 'page_load', + guid: '113858-a211dfgh-6fg654fgh-lki1gjhk54-fre5321', + data: { + fruit: "banana", + vegetable: "Carrot", + dairy: "Cheese", + meat: "Alligator", + people: [ + "Dave", + "Sally", + "George", + "Kelly", + "Dillon", + "Sven", + "Chelsea" + ] + } + }, function (err, res) { + if (err) return console.error("Err:", err, res); + + console.log(res); + }); + +}; + From ae37aaf148bc870859e199f5cfe3a6febfd7b669 Mon Sep 17 00:00:00 2001 From: Kelly de Vries Date: Sat, 4 Jul 2015 09:40:56 -0700 Subject: [PATCH 4/8] add hidden candela_outcomes_guid and user_id data to applicable pages --- .../candela-outcomes/candela-outcomes.php | 36 ++++++++++++++----- .../themes/candela-advanced/single.php | 3 +- .../candela-utility/themes/candela/single.php | 2 ++ .../themes/washington/single.php | 3 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/wp-content/plugins/candela-outcomes/candela-outcomes.php b/wp-content/plugins/candela-outcomes/candela-outcomes.php index 2c72906f..932bed96 100644 --- a/wp-content/plugins/candela-outcomes/candela-outcomes.php +++ b/wp-content/plugins/candela-outcomes/candela-outcomes.php @@ -11,19 +11,20 @@ * GitHub Plugin URI: https://github.com/lumenlearning/candela-outcomes */ -add_action('admin_init', 'candela_on_admin_init'); +namespace Candela\Outcomes; +if( ! defined('CANDELA_OUTCOMES_GUID')){ + define('CANDELA_OUTCOMES_GUID', 'CANDELA_OUTCOMES_GUID'); +} +add_action('admin_init', '\Candela\Outcomes\candela_on_admin_init'); //Initialize function candela_on_admin_init() { - if( ! defined('CANDELA_OUTCOMES_GUID')){ - define('CANDELA_OUTCOMES_GUID', 'candela_outcomes_guid'); - } $types = array( 'back-matter', 'chapter', 'front-matter',); foreach($types as $type){ add_meta_box('outcomes', __('Course Outcomes', 'textdomain'), - 'outcomes_metabox_render', + '\Candela\Outcomes\outcomes_metabox_render', $type, 'normal', 'high' @@ -33,7 +34,7 @@ function candela_on_admin_init() { //Render fields function outcomes_metabox_render($post) { - $data = get_post_meta($post->ID, 'CANDELA_OUTCOMES_GUID', true); + $data = get_post_meta($post->ID, CANDELA_OUTCOMES_GUID, true); ?>
@@ -44,9 +45,10 @@ function outcomes_metabox_render($post) { //Update metadata when user saves post -add_action('wp_insert_post', 'candela_outcomes_save_meta_value', 10, 2); +add_action('wp_insert_post', '\Candela\Outcomes\candela_outcomes_save_meta_value', 10, 2); function candela_outcomes_save_meta_value($id) { + if(isset($_POST['my_meta_value'])) $outcomes_input = strtolower($_POST['my_meta_value']); if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) @@ -54,14 +56,30 @@ function candela_outcomes_save_meta_value($id) { if (!current_user_can('edit_posts')) return; + if(isset($outcomes_input)) $outcomes_input = preg_replace('/([^a-z0-9, :-])/', '', $outcomes_input); if (!isset($id)) $id = (int) $_REQUEST['post_ID']; if (isset($outcomes_input)) { - update_post_meta($id, 'CANDELA_OUTCOMES_GUID', $outcomes_input); + update_post_meta($id, CANDELA_OUTCOMES_GUID, $outcomes_input); } else { - delete_post_meta($id, 'CANDELA_OUTCOMES_GUID'); + delete_post_meta($id, CANDELA_OUTCOMES_GUID); + } +} + +//Display outcome html +add_action('display_outcome_html', '\Candela\Outcomes\outcome_display_html', 10, 1); + +function outcome_display_html($id){ + $user_ID = get_current_user_id(); + $dataguid = get_post_meta($id, CANDELA_OUTCOMES_GUID); + if(!empty($dataguid)){ + ?> + +
- + + ID); ?> ID ) ): ?>
diff --git a/wp-content/plugins/candela-utility/themes/candela/single.php b/wp-content/plugins/candela-utility/themes/candela/single.php index 2307446e..dbdc640e 100644 --- a/wp-content/plugins/candela-utility/themes/candela/single.php +++ b/wp-content/plugins/candela-utility/themes/candela/single.php @@ -29,6 +29,8 @@ } ?>
+ + ID); ?> ID ) ): ?>
diff --git a/wp-content/plugins/candela-utility/themes/washington/single.php b/wp-content/plugins/candela-utility/themes/washington/single.php index 15f32483..6ff56a3a 100644 --- a/wp-content/plugins/candela-utility/themes/washington/single.php +++ b/wp-content/plugins/candela-utility/themes/washington/single.php @@ -22,7 +22,8 @@ } ?> - + + ID); ?> ID ) ): ?>
From 7918c7652e4310d208a742ef4741fd73926bfab4 Mon Sep 17 00:00:00 2001 From: dillon Date: Tue, 7 Jul 2015 10:31:45 -0700 Subject: [PATCH 5/8] added the dynamic get elements to deliverance --- .../themes/candela-advanced/js/deliveryMan.js | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js index 5cad49b1..0ed3bbf2 100644 --- a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js +++ b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js @@ -1,32 +1,16 @@ window.onload = function() { - - console.log("<<=========>> PEW PEW <<=======>>"); - - var deliverance = new Deliverance({ + var outcomes = document.getElementById('outcome_description'), + deliverance = new Deliverance({ jwt: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiQ2FuZGVsYSIsImlzcyI6IjEyNy4wLjAuMSIsImlhdCI6MTMwMDgxOTM4MCwic2NvcGUiOlsiYWRkX2V2ZW50Il19.14mdTPoTQZtlIsr93D8uWnFGc5ntUHzr7clUm3uE_Mw", endpoint: "https://127.0.0.1:444/report" }); deliverance.send({ - user_id: 4, + user_id: Number(outcomes.dataset.userId), type: 'page_load', - guid: '113858-a211dfgh-6fg654fgh-lki1gjhk54-fre5321', - data: { - fruit: "banana", - vegetable: "Carrot", - dairy: "Cheese", - meat: "Alligator", - people: [ - "Dave", - "Sally", - "George", - "Kelly", - "Dillon", - "Sven", - "Chelsea" - ] - } + guid: outcomes.dataset.outcomeGuids.split(','), //creates array of guids + data: {} }, function (err, res) { if (err) return console.error("Err:", err, res); From 36e33b55a4e9da963d50007ee69b942f5c60faf3 Mon Sep 17 00:00:00 2001 From: dillon Date: Tue, 7 Jul 2015 10:42:59 -0700 Subject: [PATCH 6/8] fixed split delimiter --- .../candela-utility/themes/candela-advanced/js/deliveryMan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js index 0ed3bbf2..9d7bcde6 100644 --- a/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js +++ b/wp-content/plugins/candela-utility/themes/candela-advanced/js/deliveryMan.js @@ -9,7 +9,7 @@ window.onload = function() { deliverance.send({ user_id: Number(outcomes.dataset.userId), type: 'page_load', - guid: outcomes.dataset.outcomeGuids.split(','), //creates array of guids + guid: outcomes.dataset.outcomeGuids.split(', '), //creates array of guids data: {} }, function (err, res) { if (err) return console.error("Err:", err, res); From 2fe9af51cf0b7abe9c9c8c857e057be0c630a6d8 Mon Sep 17 00:00:00 2001 From: dillon Date: Tue, 7 Jul 2015 10:48:47 -0700 Subject: [PATCH 7/8] commit .htaccess file --- .htaccess | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.htaccess b/.htaccess index 951d4572..fb1c9b4a 100644 --- a/.htaccess +++ b/.htaccess @@ -1,12 +1,8 @@ - -# BEGIN WordPress - RewriteEngine On -# force SSL RewriteCond %{HTTPS} !=on -# + RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] -RewriteBase / +RewriteBase /candela/ RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin @@ -17,8 +13,4 @@ RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] -RewriteRule . index.php [L] - - - -# END WordPress +RewriteRule . index.php [L] \ No newline at end of file From dfa4696a90a23a46f788a8d74fb753cc4c27c101 Mon Sep 17 00:00:00 2001 From: dillon Date: Tue, 7 Jul 2015 15:13:03 -0700 Subject: [PATCH 8/8] defined clarity endpoint global created element to display enpoint in hidden HTML element modified deliveryMan.js onload function to dynamically grab necessary data. --- .../candela-outcomes/candela-outcomes.php | 13 ++++++++ .../themes/candela-advanced/js/deliveryMan.js | 31 +++++++++++-------- .../themes/candela-advanced/single.php | 6 +++- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/wp-content/plugins/candela-outcomes/candela-outcomes.php b/wp-content/plugins/candela-outcomes/candela-outcomes.php index 932bed96..f4e38b7a 100644 --- a/wp-content/plugins/candela-outcomes/candela-outcomes.php +++ b/wp-content/plugins/candela-outcomes/candela-outcomes.php @@ -83,3 +83,16 @@ function outcome_display_html($id){ + +
- ID); ?> + ID); + do_action('output_clarity_url'); + ?> + ID ) ): ?>