https://wordpress.org/plugins/organic/
- Install poetry
- Make sure poetry will use your currently active Python
$ poetry config virtualenvs.prefer-active-python true
- Install poetry plugins
$ poetry self add poetry-dotenv-plugin
$ poetry self add poetry-pre-commit-plugin
- Before setting up project you may want to install pyenv and use it to configure the latest Python. This step is optional, but highly recommended!
$ pyenv install 3.11
$ pyenv local 3.11
- Install deps
$ poetry install
- Create
.env
file
$ cp .env.template .env
- Don't forget to update
TODO
vars in your.env
file! - Make sure your
/etc/hosts
file contains the entry127.0.0.1 wpplugin.lcl.organic.ly
(you can copy and paste this into the file). Alternatively, if you have access to the organic-dev project, you can run the following:
$ organic dev update-hosts
- Build the dev environment
$ poetry run ./dev.py up
- Lint files
$ poetry run ./dev.py lint
- Shutdown dev environment
$ poetry run ./dev.py down
For more commands and helpful flags check the help
$ poetry run ./dev.py --help
$ poetry run ./dev.py up --help
$ poetry run ./dev.py down --help
$ poetry run ./dev.py lint --help
$ poetry run ./dev.py build-zip --help
The Wordpress Plugin includes the following Affiliate App features:
- Insert Product Card: implemented as a Gutenberg Block
- Insert Product Carousel: implemented as a Gutenberg Block
- Insert Affiliate Link: implemented as a Custom Format
These blocks are automatically built on every file change after ./dev.py up
- see docker compose logs -f --tail 20 nodejs
for logs
The build-zip
command builds a zipped and unzipped versions
of the production build of the plugin in wordpress-plugin/build/.
If ou need to confirm that production build of the plugin works as expected:
- Build the plugin
$ poetry run ./dev.py build-zip
- Install the plugin by copying the
build/organic
dir into yours WP plugins folder or by installing thebuild/organic.zip
. Or use docker volume mappings similar to this
If you are working on internal Organic projects.
By default, plugin will connect to the staging version of the Platform.
If you work with local version of the Platform make sure that
Organic WP plugin will be able to connect to the api.lcl.organic.ly
- copy
the example file or edit your override file in similar way inside this repo:
$ cp docker-compose.override.yml.example docker-compose.override.yml
If you are working on internal Organic projects and want to work with your local version - add
these to your docker-compose.override.yml
inside of your organic-dev
repo:
services:
solutions-wordpress:
volumes:
- ./wordpress-plugin/src:/var/www/html/web/app/mu-plugins/wordpress-plugin:ro
Or for testing with result of ./dev.py build-zip
services:
solutions-wordpress:
volumes:
- ./wordpress-plugin/build/organic:/var/www/html/web/app/mu-plugins/wordpress-plugin:ro
If you set the environment variable ORGANIC_ENVIRONMENT to an explicit value, you can control what kind of debug data gets exposed. Valid values are:
- PRODUCTION = normal operation in production
- TEST = used in unit and integration testing
organic_ads_txt_changed
- called after the ads.txt content has changed from syncing with Organic Platform. No args.
These filters allow integrators to use non-standard attributes on Post objects to fulfill the needs of the Synchronization to Organic Platform.
organic_post_id
- accepts default Post ID attribute, response registered as External ID in Organicorganic_post_title
- accepts default $post->ID and $post->title, response registered as Title in Organicorganic_post_url
- accepts default $post->ID and post Permalink (from get_permalink)organic_post_content
- transform the body of the postorganic_post_publish_date
- transform the publish date of the postorganic_post_modified_date
- transform the modified date of the postorganic_post_authors
- accepts array with one author info based on $post->post_author data and $post->ID; expects an array of dicts with 'externalId' and 'name' keysorganic_eligible_for_ads
- enable or disable ads injection, overlapping plugin settingsorganic_eligible_for_affiliate
- enable or disable affiliate injection, overlapping plugin settings
Example Filter Implementations:
function get_custom_post_id($id) {
$ext_id = get_post_meta($id, 'custom_post_id', true);
return $ext_id ?: $id;
}
add_filter( 'organic_post_id', 'get_custom_post_id', 10, 1);
function get_custom_post_title($title, $id) {
$title = 'Our Brand | ' . $title;
return $title;
}
add_filter( 'organic_post_title', 'get_custom_post_title', 10, 2);