Plugin Directory

Changeset 1720805


Ignore:
Timestamp:
08/28/2017 07:41:27 PM (9 years ago)
Author:
stackcommerce
Message:

Release 1.4.0

Location:
stackcommerce-connect/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • stackcommerce-connect/trunk/dist/scripts/stackcommerce-wp.min.js

    r1700548 r1720805  
    1 "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,c,a){return c&&e(t.prototype,c),a&&e(t,a),t}}();jQuery(document).ready(function(){if(document.querySelector(".stackcommerce-wp-form")){var e=new StackCommerce_WP;e.updateForm(),e.categories(),e.tags(),document.querySelector("#stackcommerce-wp-form-submit").addEventListener("click",e.notify.bind(e)),jQuery("form.stackcommerce-wp-form").keypress(e.performKeycheck.bind(e)),jQuery('input[name="stackcommerce_wp_content_integration[]"]').change(e.updateForm.bind(e))}});var StackCommerce_WP=function(){function e(){_classCallCheck(this,e),this.$endpoint=this.getValue("#stackcommerce_wp_cms_api_endpoint"),this.$form=document.querySelector("#stackcommerce-wp-form"),this.$submit_button=document.querySelector("#stackcommerce-wp-form-submit")}return _createClass(e,[{key:"notify",value:function(){var e=this,t=this.getValue("#stackcommerce_wp_account_id"),c=this.getValue("#stackcommerce_wp_secret");this.setConnectionStatus("connecting"),jQuery.ajax({method:"PUT",url:this.$endpoint+"/api/wordpress/?id="+t+"&secret="+c,processData:!1,contentType:"application/json",dataType:"json",data:JSON.stringify(this.generatePayload())}).done(function(){e.setConnectionStatus("connected"),e.$form.submit()}).fail(function(){e.setConnectionStatus("disconnected")})}},{key:"generatePayload",value:function(){return{data:{type:"partner_wordpress_settings",id:this.getValue("#stackcommerce_wp_account_id"),attributes:{installed:!0,wordpress_url:this.getValue("#stackcommerce_wp_endpoint"),author_id:this.getValue("#stackcommerce_wp_author"),post_status:this.getValue("#stackcommerce_wp_post_status"),categories:this.getSelect2Values("#stackcommerce_wp_categories",[]),tags:this.getSelect2Values("#stackcommerce_wp_tags",[]),featured_image:this.getValue("#stackcommerce_wp_featured_image")}}}}},{key:"setConnectionStatus",value:function(e){this.setValue("#stackcommerce_wp_connection_status",e),this.updateForm()}},{key:"updateForm",value:function(){var e=document.querySelector("#stackcommerce-wp-form"),t=document.querySelector("#stackcommerce-wp-form-submit"),c=this.getValue("#stackcommerce_wp_connection_status"),a=this.getValue('input[name="stackcommerce_wp_content_integration[]"]:checked');e.setAttribute("data-stackcommerce-wp-status",c),e.setAttribute("data-stackcommerce-wp-content-integration","true"==a),"connecting"===c?t.setAttribute("disabled","disabled"):t.removeAttribute("disabled")}},{key:"performKeycheck",value:function(e){if(13==e.which)return this.notify(),!1}},{key:"taxonomySearch",value:function(e){jQuery(e.selector).select2({ajax:{type:"POST",url:window.ajaxurl,dataType:"json",delay:250,data:function(t){return{action:"sc_api_search",taxonomy:e.taxonomy,q:t.term}},processResults:function(t){return{results:e.results.split(".").reduce(function(e,t){return e[t]},t)}},cache:!0},escapeMarkup:function(e){return e},minimumInputLength:3})}},{key:"categories",value:function(){var e={selector:"#stackcommerce_wp_categories",taxonomy:"categories",results:"data.categories"};this.taxonomySearch(e)}},{key:"tags",value:function(){var e={selector:"#stackcommerce_wp_tags",taxonomy:"tags",results:"data.tags"};this.taxonomySearch(e)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=document.querySelector(e).value;return c||t}},{key:"getSelect2Values",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],c=jQuery(e).select2("val");return c||t}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";document.querySelector(e).value=t}}]),e}();
     1"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var c=0;c<t.length;c++){var a=t[c];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,c,a){return c&&e(t.prototype,c),a&&e(t,a),t}}();jQuery(document).ready(function(){if(document.querySelector(".stackcommerce-wp-form")){var e=new StackCommerce_WP;e.updateForm(),e.categories(),e.tags(),document.querySelector("#stackcommerce-wp-form-submit").addEventListener("click",e.notify.bind(e)),jQuery("form.stackcommerce-wp-form").keypress(e.performKeycheck.bind(e)),jQuery('input[name="stackcommerce_wp_content_integration[]"]').change(e.updateForm.bind(e))}});var StackCommerce_WP=function(){function e(){_classCallCheck(this,e),this.$endpoint=this.getValue("#stackcommerce_wp_cms_api_endpoint"),this.$form=document.querySelector("#stackcommerce-wp-form"),this.$submit_button=document.querySelector("#stackcommerce-wp-form-submit")}return _createClass(e,[{key:"notify",value:function(){var e=this,t=this.getValue("#stackcommerce_wp_account_id"),c=this.getValue("#stackcommerce_wp_secret");this.setConnectionStatus("connecting"),jQuery.ajax({method:"PUT",url:this.$endpoint+"/api/wordpress/?id="+t+"&secret="+c,processData:!1,contentType:"application/json",dataType:"json",data:JSON.stringify(this.generatePayload())}).done(function(){e.setConnectionStatus("connected"),e.$form.submit()}).fail(function(){e.setConnectionStatus("disconnected")})}},{key:"generatePayload",value:function(){return{data:{type:"partner_wordpress_settings",id:this.getValue("#stackcommerce_wp_account_id"),attributes:{installed:!0,wordpress_url:this.getValue("#stackcommerce_wp_endpoint"),author_id:this.getValue("#stackcommerce_wp_author"),post_status:this.getValue("#stackcommerce_wp_post_status"),categories:this.getSelect2Values("#stackcommerce_wp_categories",[]),tags:this.getSelect2Values("#stackcommerce_wp_tags",[]),featured_image:this.getValue("#stackcommerce_wp_featured_image"),plugin_version:this.getValue("#stackcommerce_wp_plugin_version")}}}}},{key:"setConnectionStatus",value:function(e){this.setValue("#stackcommerce_wp_connection_status",e),this.updateForm()}},{key:"updateForm",value:function(){var e=document.querySelector("#stackcommerce-wp-form"),t=document.querySelector("#stackcommerce-wp-form-submit"),c=this.getValue("#stackcommerce_wp_connection_status"),a=this.getValue('input[name="stackcommerce_wp_content_integration[]"]:checked');e.setAttribute("data-stackcommerce-wp-status",c),e.setAttribute("data-stackcommerce-wp-content-integration","true"==a),"connecting"===c?t.setAttribute("disabled","disabled"):t.removeAttribute("disabled")}},{key:"performKeycheck",value:function(e){if(13==e.which)return this.notify(),!1}},{key:"taxonomySearch",value:function(e){jQuery(e.selector).select2({ajax:{type:"POST",url:window.ajaxurl,dataType:"json",delay:250,data:function(t){return{action:"sc_api_search",taxonomy:e.taxonomy,q:t.term}},processResults:function(t){return{results:e.results.split(".").reduce(function(e,t){return e[t]},t)}},cache:!0},escapeMarkup:function(e){return e},minimumInputLength:3})}},{key:"categories",value:function(){var e={selector:"#stackcommerce_wp_categories",taxonomy:"categories",results:"data.categories"};this.taxonomySearch(e)}},{key:"tags",value:function(){var e={selector:"#stackcommerce_wp_tags",taxonomy:"tags",results:"data.tags"};this.taxonomySearch(e)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",c=document.querySelector(e).value;return c||t}},{key:"getSelect2Values",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],c=jQuery(e).select2("val");return c||t}},{key:"setValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";document.querySelector(e).value=t}}]),e}();
    22//# sourceMappingURL=stackcommerce-wp.min.js.map
  • stackcommerce-connect/trunk/dist/scripts/stackcommerce-wp.min.js.map

    r1700548 r1720805  
    1 {"version":3,"sources":["stackcommerce-wp.js"],"names":["jQuery","document","ready","querySelector","sc_connect","StackCommerce_WP","updateForm","categories","tags","addEventListener","notify","bind","keypress","performKeycheck","change","_classCallCheck","this","$endpoint","getValue","$form","$submit_button","_createClass","key","value","_this","$account_id","$secret_key","setConnectionStatus","ajax","method","url","processData","contentType","dataType","data","JSON","stringify","generatePayload","done","submit","fail","type","id","attributes","installed","wordpress_url","author_id","post_status","getSelect2Values","featured_image","status","setValue","$connection_status","$content_integration","setAttribute","removeAttribute","e","which","options","selector","select2","window","ajaxurl","delay","params","action","taxonomy","q","term","processResults","results","split","reduce","_data","cache","escapeMarkup","markup","minimumInputLength","taxonomySearch","$selector","default_value","arguments","length","undefined"],"mappings":"6XAAAA,OAAOC,UAAUC,MAAM,WAGrB,GAFmCD,SAASE,cAAc,0BAE3B,CAC7B,IAAIC,EAAa,IAAIC,iBAErBD,EAAWE,aACXF,EAAWG,aACXH,EAAWI,OAEUP,SAASE,cAAc,iCAE7BM,iBAAiB,QAASL,EAAWM,OAAOC,KAAKP,IAEhEJ,OAAO,8BAA8BY,SAASR,EAAWS,gBAAgBF,KAAKP,IAC9EJ,OAAO,wDAAwDc,OAAOV,EAAWE,WAAWK,KAAKP,OAfrG,IAmBMC,iBAAAA,WACJ,SAAAA,IAAcU,gBAAAC,KAAAX,GACZW,KAAKC,UAAiBD,KAAKE,SAAS,sCACpCF,KAAKG,MAAiBlB,SAASE,cAAc,0BAC7Ca,KAAKI,eAAiBnB,SAASE,cAAc,iCAwJ9C,OAvJAkB,aAAAhB,IAAAiB,IAAA,SAAAC,MAAA,WAEQ,IAAAC,EAAAR,KACHS,EAAcT,KAAKE,SAAS,gCAC5BQ,EAAcV,KAAKE,SAAS,4BAEhCF,KAAKW,oBAAoB,cAEzB3B,OAAO4B,MACLC,OAAQ,MACRC,IAAKd,KAAKC,UAAY,sBAAwBQ,EAAc,WAAaC,EACzEK,aAAa,EACbC,YAAa,mBACbC,SAAU,OACVC,KAAMC,KAAKC,UAAUpB,KAAKqB,qBAE3BC,KAAK,WACJd,EAAKG,oBAAoB,aACzBH,EAAKL,MAAMoB,WAEZC,KAAK,WACJhB,EAAKG,oBAAoB,qBAE5BL,IAAA,kBAAAC,MAAA,WAWC,OACEW,MACEO,KAAM,6BACNC,GAXkB1B,KAAKE,SAAS,gCAYhCyB,YACEC,WAAW,EACXC,cAbgB7B,KAAKE,SAAS,8BAc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D,KAAK8D,eAAepB,MACrBpC,IAAA,WAAAC,MAAA,SAEQwD,GAA+B,IAApBC,EAAoBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,GAC9B1D,EAAQtB,SAASE,cAAc4E,GAAWxD,MAE9C,OAAGA,GAGMyD,KAEV1D,IAAA,mBAAAC,MAAA,SAEgBwD,GAA+B,IAApBC,EAAoBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1C1D,EAAQvB,OAAO+E,GAAWnB,QAAQ,OAEtC,OAAGrC,GAGMyD,KAEV1D,IAAA,WAAAC,MAAA,SAEQwD,GAAuB,IAAZxD,EAAY0D,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,GAC1BhF,SAASE,cAAc4E,GAAWxD,MAAQA,MAC3ClB,EA5JGA","file":"stackcommerce-wp.min.js","sourcesContent":["jQuery(document).ready(function() {\n  const isStackCommerceConnectPage = document.querySelector('.stackcommerce-wp-form');\n\n  if(isStackCommerceConnectPage) {\n    let sc_connect = new StackCommerce_WP();\n\n    sc_connect.updateForm();\n    sc_connect.categories();\n    sc_connect.tags();\n\n    let $submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n\n    $submit_button.addEventListener('click', sc_connect.notify.bind(sc_connect));\n\n    jQuery('form.stackcommerce-wp-form').keypress(sc_connect.performKeycheck.bind(sc_connect));\n    jQuery('input[name=\"stackcommerce_wp_content_integration[]\"]').change(sc_connect.updateForm.bind(sc_connect));\n  }\n});\n\nclass StackCommerce_WP {\n  constructor() {\n    this.$endpoint      = this.getValue('#stackcommerce_wp_cms_api_endpoint');\n    this.$form          = document.querySelector('#stackcommerce-wp-form');\n    this.$submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n  }\n\n  notify() {\n    let $account_id = this.getValue('#stackcommerce_wp_account_id'),\n        $secret_key = this.getValue('#stackcommerce_wp_secret');\n\n    this.setConnectionStatus('connecting');\n\n    jQuery.ajax({\n      method: 'PUT',\n      url: this.$endpoint + '/api/wordpress/?id=' + $account_id + '&secret=' + $secret_key,\n      processData: false,\n      contentType: 'application/json',\n      dataType: 'json',\n      data: JSON.stringify(this.generatePayload())\n    })\n    .done(() => {\n      this.setConnectionStatus('connected');\n      this.$form.submit();\n    })\n    .fail(() => {\n      this.setConnectionStatus('disconnected');\n    });\n  }\n\n  generatePayload() {\n    let $account_id     = this.getValue('#stackcommerce_wp_account_id'),\n        $wordpress_url  = this.getValue('#stackcommerce_wp_endpoint'),\n        $author_id      = this.getValue('#stackcommerce_wp_author'),\n        $post_status    = this.getValue('#stackcommerce_wp_post_status'),\n        $categories     = this.getSelect2Values('#stackcommerce_wp_categories', []),\n        $tags           = this.getSelect2Values('#stackcommerce_wp_tags', []),\n        $featured_image = this.getValue('#stackcommerce_wp_featured_image');\n\n    return {\n      data: {\n        type: 'partner_wordpress_settings',\n        id: $account_id,\n        attributes: {\n          installed: true,\n          wordpress_url: $wordpress_url,\n          author_id: $author_id,\n          post_status: $post_status,\n          categories: $categories,\n          tags: $tags,\n          featured_image: $featured_image\n        }\n      }\n    };\n  }\n\n  setConnectionStatus(status) {\n    this.setValue('#stackcommerce_wp_connection_status', status);\n    this.updateForm();\n  }\n\n  updateForm() {\n    let $form                = document.querySelector('#stackcommerce-wp-form'),\n        $submit_button       = document.querySelector('#stackcommerce-wp-form-submit'),\n        $connection_status   = this.getValue('#stackcommerce_wp_connection_status'),\n        $content_integration = this.getValue('input[name=\"stackcommerce_wp_content_integration[]\"]:checked');\n\n    $form.setAttribute('data-stackcommerce-wp-status', $connection_status);\n    $form.setAttribute('data-stackcommerce-wp-content-integration', ($content_integration == 'true' ? true : false));\n\n    if($connection_status === 'connecting') {\n      $submit_button.setAttribute('disabled', 'disabled');\n    } else {\n      $submit_button.removeAttribute('disabled');\n    }\n  }\n\n  performKeycheck(e) {\n    if(e.which == 13) {\n      this.notify();\n      return false;\n    }\n  }\n\n  taxonomySearch(options) {\n    jQuery(options.selector).select2({\n      ajax: {\n        type: 'POST',\n        url: window.ajaxurl,\n        dataType: 'json',\n        delay: 250,\n        data: function(params) {\n          return {\n            action: 'sc_api_search',\n            taxonomy: options.taxonomy,\n            q: params.term\n          }\n        },\n        processResults: function(data) {\n          var results = options.results.split('.').reduce(function(_data, key) {\n            return _data[key];\n          }, data);\n\n          return {\n            results: results\n          }\n        },\n        cache: true\n      },\n      escapeMarkup: function(markup) { return markup; },\n      minimumInputLength: 3\n    });\n  }\n\n  categories() {\n    var options = {\n      selector: '#stackcommerce_wp_categories',\n      taxonomy: 'categories',\n      results:  'data.categories'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  tags() {\n    var options = {\n      selector: '#stackcommerce_wp_tags',\n      taxonomy: 'tags',\n      results:  'data.tags'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  getValue($selector, default_value = '') {\n    let value = document.querySelector($selector).value;\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  getSelect2Values($selector, default_value = []) {\n    let value = jQuery($selector).select2('val');\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  setValue($selector, value = '') {\n    document.querySelector($selector).value = value;\n  }\n}\n"]}
     1{"version":3,"sources":["stackcommerce-wp.js"],"names":["jQuery","document","ready","querySelector","sc_connect","StackCommerce_WP","updateForm","categories","tags","addEventListener","notify","bind","keypress","performKeycheck","change","_classCallCheck","this","$endpoint","getValue","$form","$submit_button","_createClass","key","value","_this","$account_id","$secret_key","setConnectionStatus","ajax","method","url","processData","contentType","dataType","data","JSON","stringify","generatePayload","done","submit","fail","type","id","attributes","installed","wordpress_url","author_id","post_status","getSelect2Values","featured_image","plugin_version","status","setValue","$connection_status","$content_integration","setAttribute","removeAttribute","e","which","options","selector","select2","window","ajaxurl","delay","params","action","taxonomy","q","term","processResults","results","split","reduce","_data","cache","escapeMarkup","markup","minimumInputLength","taxonomySearch","$selector","default_value","arguments","length","undefined"],"mappings":"6XAAAA,OAAOC,UA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C,OAAGA,GAGM0D,KAEV3D,IAAA,mBAAAC,MAAA,SAEgByD,GAA+B,IAApBC,EAAoBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1C3D,EAAQvB,OAAOgF,GAAWnB,QAAQ,OAEtC,OAAGtC,GAGM0D,KAEV3D,IAAA,WAAAC,MAAA,SAEQyD,GAAuB,IAAZzD,EAAY2D,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,GAC1BjF,SAASE,cAAc6E,GAAWzD,MAAQA,MAC3ClB,EA9JGA","file":"stackcommerce-wp.min.js","sourcesContent":["jQuery(document).ready(function() {\n  const isStackCommerceConnectPage = document.querySelector('.stackcommerce-wp-form');\n\n  if(isStackCommerceConnectPage) {\n    let sc_connect = new StackCommerce_WP();\n\n    sc_connect.updateForm();\n    sc_connect.categories();\n    sc_connect.tags();\n\n    let $submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n\n    $submit_button.addEventListener('click', sc_connect.notify.bind(sc_connect));\n\n    jQuery('form.stackcommerce-wp-form').keypress(sc_connect.performKeycheck.bind(sc_connect));\n    jQuery('input[name=\"stackcommerce_wp_content_integration[]\"]').change(sc_connect.updateForm.bind(sc_connect));\n  }\n});\n\nclass StackCommerce_WP {\n  constructor() {\n    this.$endpoint      = this.getValue('#stackcommerce_wp_cms_api_endpoint');\n    this.$form          = document.querySelector('#stackcommerce-wp-form');\n    this.$submit_button = document.querySelector('#stackcommerce-wp-form-submit');\n  }\n\n  notify() {\n    let $account_id = this.getValue('#stackcommerce_wp_account_id'),\n        $secret_key = this.getValue('#stackcommerce_wp_secret');\n\n    this.setConnectionStatus('connecting');\n\n    jQuery.ajax({\n      method: 'PUT',\n      url: this.$endpoint + '/api/wordpress/?id=' + $account_id + '&secret=' + $secret_key,\n      processData: false,\n      contentType: 'application/json',\n      dataType: 'json',\n      data: JSON.stringify(this.generatePayload())\n    })\n    .done(() => {\n      this.setConnectionStatus('connected');\n      this.$form.submit();\n    })\n    .fail(() => {\n      this.setConnectionStatus('disconnected');\n    });\n  }\n\n  generatePayload() {\n    let $account_id     = this.getValue('#stackcommerce_wp_account_id'),\n        $wordpress_url  = this.getValue('#stackcommerce_wp_endpoint'),\n        $author_id      = this.getValue('#stackcommerce_wp_author'),\n        $post_status    = this.getValue('#stackcommerce_wp_post_status'),\n        $categories     = this.getSelect2Values('#stackcommerce_wp_categories', []),\n        $tags           = this.getSelect2Values('#stackcommerce_wp_tags', []),\n        $featured_image = this.getValue('#stackcommerce_wp_featured_image'),\n        $plugin_version = this.getValue('#stackcommerce_wp_plugin_version');\n\n    return {\n      data: {\n        type: 'partner_wordpress_settings',\n        id: $account_id,\n        attributes: {\n          installed: true,\n          wordpress_url: $wordpress_url,\n          author_id: $author_id,\n          post_status: $post_status,\n          categories: $categories,\n          tags: $tags,\n          featured_image: $featured_image,\n          plugin_version: $plugin_version\n        }\n      }\n    };\n  }\n\n  setConnectionStatus(status) {\n    this.setValue('#stackcommerce_wp_connection_status', status);\n    this.updateForm();\n  }\n\n  updateForm() {\n    let $form                = document.querySelector('#stackcommerce-wp-form'),\n        $submit_button       = document.querySelector('#stackcommerce-wp-form-submit'),\n        $connection_status   = this.getValue('#stackcommerce_wp_connection_status'),\n        $content_integration = this.getValue('input[name=\"stackcommerce_wp_content_integration[]\"]:checked');\n\n    $form.setAttribute('data-stackcommerce-wp-status', $connection_status);\n    $form.setAttribute('data-stackcommerce-wp-content-integration', ($content_integration == 'true' ? true : false));\n\n    if($connection_status === 'connecting') {\n      $submit_button.setAttribute('disabled', 'disabled');\n    } else {\n      $submit_button.removeAttribute('disabled');\n    }\n  }\n\n  performKeycheck(e) {\n    if(e.which == 13) {\n      this.notify();\n      return false;\n    }\n  }\n\n  taxonomySearch(options) {\n    jQuery(options.selector).select2({\n      ajax: {\n        type: 'POST',\n        url: window.ajaxurl,\n        dataType: 'json',\n        delay: 250,\n        data: function(params) {\n          return {\n            action: 'sc_api_search',\n            taxonomy: options.taxonomy,\n            q: params.term\n          }\n        },\n        processResults: function(data) {\n          var results = options.results.split('.').reduce(function(_data, key) {\n            return _data[key];\n          }, data);\n\n          return {\n            results: results\n          }\n        },\n        cache: true\n      },\n      escapeMarkup: function(markup) { return markup; },\n      minimumInputLength: 3\n    });\n  }\n\n  categories() {\n    var options = {\n      selector: '#stackcommerce_wp_categories',\n      taxonomy: 'categories',\n      results:  'data.categories'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  tags() {\n    var options = {\n      selector: '#stackcommerce_wp_tags',\n      taxonomy: 'tags',\n      results:  'data.tags'\n    }\n\n    this.taxonomySearch(options);\n  }\n\n  getValue($selector, default_value = '') {\n    let value = document.querySelector($selector).value;\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  getSelect2Values($selector, default_value = []) {\n    let value = jQuery($selector).select2('val');\n\n    if(value) {\n      return value;\n    } else {\n      return default_value;\n    }\n  }\n\n  setValue($selector, value = '') {\n    document.querySelector($selector).value = value;\n  }\n}\n"]}
  • stackcommerce-connect/trunk/includes/class-stackcommerce-wp-endpoint.php

    r1713367 r1720805  
    4343   * Performs authentication and generate a hash based on post content
    4444   *
    45    * @since    1.0.0
     45   * @since    1.4.0
    4646   */
    4747  protected function authentication( $hash, $request ) {
    48     if ( ! empty( $request ) && ! empty( $request['post_content'] ) ) {
    49       $secret = hash_hmac( 'sha256', $request['post_content'], get_option( 'stackcommerce_wp_secret' ) );
     48    if ( empty( $request ) || empty( $request['post_content'] ) ) {
     49      return $this->response( 'Request is empty or post content is missing',
     50        array(
     51          'code'        => 'stackcommerce_wp_empty_request',
     52          'status_code' => 400,
     53        )
     54      );
     55    }
    5056
    51       if ( $this->is_hash_valid( $hash, $secret ) ) {
    52         $stackcommerce_wp_article = new StackCommerce_WP_Article();
    53         $stackcommerce_wp_article->validate( $request );
    54       } else {
    55         return $this->response( 'Hash missing or invalid',
     57    $secret = '';
     58
     59    if ( isset($request['encode']) && ( true === $request['encode'] ) ) {
     60      $decoded_content = base64_decode( $request['post_content'] );
     61
     62      if ( ! $decoded_content ) {
     63        return $this->response( 'Post content decode failed',
    5664          array(
    57             'code'        => 'stackcommerce_wp_invalid_hash',
     65            'code'        => 'stackcommerce_wp_invalid_base64',
    5866            'status_code' => 400,
    5967          )
    6068        );
    6169      }
     70
     71      $request['post_content'] = $decoded_content;
     72      $secret = hash_hmac( 'sha256', $decoded_content, get_option( 'stackcommerce_wp_secret' ) );
    6273    } else {
    63       return $this->response( 'Request is empty or post content is missing',
     74      $secret = hash_hmac( 'sha256', $request['post_content'], get_option( 'stackcommerce_wp_secret' ) );
     75    }
     76
     77    if ( $this->is_hash_valid( $hash, $secret ) ) {
     78      $stackcommerce_wp_article = new StackCommerce_WP_Article();
     79      $stackcommerce_wp_article->validate( $request );
     80    } else {
     81      return $this->response( 'Hash missing or invalid',
    6482        array(
    65           'code'        => 'stackcommerce_wp_empty_request',
     83          'code'        => 'stackcommerce_wp_invalid_hash',
    6684          'status_code' => 400,
    6785        )
  • stackcommerce-connect/trunk/index.php

    r1713367 r1720805  
    55 * Plugin URI: https://wordpress.org/plugins/stackcommerce-connect/
    66 * Description: The Connect plugin by StackCommerce connects your WordPress CMS to the StackCommerce Articles repository.
    7  * Version: 1.3.0
     7 * Version: 1.4.0
    88 * Author: StackCommerce, Inc
    99 * Author URI: https://www.stackcommerce.com
     
    1919define( 'SCWP_REQUIRED_WP_VERSION',  '4.4' );
    2020define( 'SCWP_API_VERSION', '1' );
     21define( 'SCWP_PLUGIN_VERSION', '1.4.0' );
    2122define( 'CMS_API_ENDPOINT',  'https://hive.stackcommerce.net' );
    2223
  • stackcommerce-connect/trunk/readme.txt

    r1713367 r1720805  
    44Requires at least: 4.4
    55Tested up to: 4.8
    6 Stable tag: 1.3.0
     6Stable tag: 1.4.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 The Connect plugin by StackCommerce connects your WordPress CMS to the StackCommerce Articles repository.
     15The Connect plugin by StackCommerce connects your WordPress CMS to StackCommerce's content repository.
    1616
    1717Top features:
    1818
    19 * Secure, automated content creation and posting without leaving the WordPress dashboard.
    20 * No development work required. Activate the plugin and connect.
    21 * Control the status. Posts can be created as drafts, pending, or scheduled.
    22 * Choose the author you want the post to be created by.
    23 * Set categories and tags to associate with all posts.
     19* Secure, automated content creation and posting within your WordPress dashboard
     20* No development work required; simply activate the plugin and connect
     21* Customizable delivery options: posts can be delivered as drafts, pending, or scheduled
     22* Content creator options: choose your writer
     23* Categories and tags can be pre-designated for all posts
    2424
    2525
     
    5252
    5353== Changelog ==
     54
     55= 1.4.0 =
     56* Add support for encoding post request.
    5457
    5558= 1.3.0 =
  • stackcommerce-connect/trunk/version.txt

    r1713367 r1720805  
    1 1.3.0
     11.4.0
  • stackcommerce-connect/trunk/views/stackcommerce-wp-page-settings.php

    r1697716 r1720805  
    2525  <input type="hidden" id="stackcommerce_wp_cms_api_endpoint" value="<?php echo CMS_API_ENDPOINT; ?>" />
    2626
     27  <input type="hidden" id="stackcommerce_wp_plugin_version" value="<?php echo SCWP_PLUGIN_VERSION; ?>" />
     28
    2729    <form method="post" class="stackcommerce-wp-form" id="stackcommerce-wp-form" action="options.php" autocomplete="off" data-stackcommerce-wp-status data-stackcommerce-wp-content-integration>
    2830
Note: See TracChangeset for help on using the changeset viewer.