Skip to content

beporter/slc-code-challenge

Repository files navigation

bp-diffbot-products

Code challenge for SLC application. Provides a WP-Admin interface for adding custom Product posts based on information retrieved from the DiffBot API.

Requirements

  • PHP 5.6
  • WordPress 4.4 or later (maybe earlier, not tested).

Features

  • Provides a new custom post type bpdiff-products that includes custom fields for regular_price, offer_price, source_url.
  • Presents a settings page for saving your DiffBot API token.
  • Presents an Import from URL page for creating a new Product post using a public URL from Amazon.com, Target.com and practically any other online storefront.

Installation

Plugin manager from your wp-admin

Download the latest release and upload it in the WordPress admin from Plugins > Add New > Upload Plugin.

Composer

Packagist

@TODO: These instructions require the project being public and published on Packagist. They have not been tested.

composer require beporter/bp-diffbot-products ~0.0.1

or

"require": {
  "php": ">=5.5.0",
  "wordpress": "~4.4.0",
  "beporter/bp-diffbot-products": "~0.0.1"
}

Wordpress Packagist

@TODO: These instructions require the project being public and published in the Plugins Directory (and mirrored to WordPress Packagist). They have not been tested.

If you're using Composer to manage WordPress, add this plugin to your project's dependencies. Run:

First, ensure your composer.json includes the Wordpress Packagist repository:

    "repositories":[
        {
            "type":"composer",
            "url":"http://wpackagist.org"
        }
    ]

Then, inject the plugin into your config:

composer require wpackagist-plugin/bp-diffbot-products ~0.0.1

Or manually add it to your composer.json:

"require": {
  "php": ">=5.5.0",
  "wordpress": "~4.4.0",
  "wpackagist-plugin/bp-diffbot-products": "~0.0.1"
}

Finally, from your WP Admin panel, activate the plugin.

Usage

The plugin will create a new section in your admin interface titled Products, as well as a new Settings pane for manaing your DiffBot API key.

You will not be able to generate new Product posts until you have entered a valid DiffBot API token in Settings > Product Posts.

To import a new product page:

  • Browse the web and locate the product page you wish to import. For example:
  • Copy the URL from your address bar.
  • Log into your WP Admin portal.
  • Navigate to Products > Import from URL.
  • Paste the URL and submit the form.
  • If the process is successful, you'll be redirected to the newly-created Product post to review it.

Contributing

This plugin is not intended for public use. I humbly discourage you from contributing, since it would likely be a waste of your time. However, in the interest of thoroughness...

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct, based on the Contributor Covenant. By participating in this project you agree to abide by its terms.

Reporting Issues

Please use GitHub Isuses for reporting any defects or issues.

Development

When developing this plugin, please fork this repo and issue a PR from a topic branch for any new development.

You should have at least git, php v5.6, composer and a text editor of your choosing installed in order to work on this plugin.

Environment

This plugin was developed using VVV. It's best to start there if you don't already have a WordPress installation available to tinker with. This will in turn require Vagrant and VirtualBox. Yep, it's turtles all the way down.

# (Get VirtualBox installed.)

# (Then get Vagrant installed.)

# Then install VVV:
$ cd some/project/dir/
$ git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant-local
$ cd vagrant-local
$ vagrant up
# (Go get some coffee or something, this will take a while.)

# Once this is complete, you should have a `www/wordpress-default/` folder.

# Clone this plugin into the appropriate working folder:
$ cd www/wordpress-default/wp-content/plugins/
$ git clone git@github.com:beporter/slc-code-challenge.git bp-diffbot-products
$ cd bp-diffbot-products/
$ composer install

Unit Tests

To prepare for running the unit tests, install WP-CLI locally:

$ cd path/to/wp-content/plugins/bp-diffbot-products/

# Run this once from the plugin root folder:
$ composer create-project wp-cli/wp-cli --prefer-source

# Run this whenever you want to run your tests.
$ wp-cli/vendor/bin/phpunit

@TODO: Actually write the test suite.

Code Style Standard

This project uses the WordPress Coding Standard. To test the code against the standard, run the following commands:

$ cd path/to/wp-content/plugins/bp-diffbot-products/

# Run this once:
$ composer create-project wp-coding-standards/wpcs:dev-master --no-dev

# Run this whenever you want to check your code.
$ wpcs/vendor/bin/phpcs -ps --colors --standard=phpcs.xml

Fix any warnings or errors produced from this.

Credits:

A list of the sources I used to complete this project. In no particular order and including some notes:

License

MIT

Copyright

© 2016 Brian Porter

About

Code challenge for SLC.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published