Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2
jobs:
php_lint:
working_directory: ~/likecoin-wordpress
working_directory: ~/nftpress
docker:
- image: composer:2.8.9
steps:
- checkout
- restore_cache:
key: likecoin-wordpress-{{ .Environment.CACHE_UUID }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
key: nftpress-{{ .Environment.CACHE_UUID }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
- run:
name: Install phpcs
command: composer install
Expand All @@ -18,30 +18,30 @@ jobs:
name: Complete Lint Test
command: ./vendor/bin/phpcs likecoin --standard=WordPress --extensions=php --ignore=*/assets/js/*,*/assets/blocks/*
- save_cache:
key: likecoin-wordpress-{{ .Environment.CACHE_UUID }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
key: nftpress-{{ .Environment.CACHE_UUID }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
paths:
- ./vendor
- ./wpcs
eslint:
working_directory: ~/likecoin-wordpress
working_directory: ~/nftpress
docker:
- image: node:14
steps:
- checkout
- restore_cache:
key: likecoin-wordpress-{{ .Environment.CACHE_UUID }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: nftpress-{{ .Environment.CACHE_UUID }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- run:
name: Dependencies
command: npm install
- run:
name: Lint Test
command: npm run lint
- save_cache:
key: likecoin-wordpress-{{ .Environment.CACHE_UUID }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: nftpress-{{ .Environment.CACHE_UUID }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
build_zip:
working_directory: ~/likecoin-wordpress
working_directory: ~/nftpress
docker:
- image: alpine:3.8
steps:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feel free to open up an issue in case you have any doubt, or before you start wo

## Development Setup

We use docker-based development workflow, please refer to [setup](https://github.com/likecoin/likecoin-wordpress#development-setup) section of [README.md](https://github.com/likecoin/likecoin-wordpress/blob/master/README.md).
We use docker-based development workflow, please refer to [setup](https://github.com/nftpress/nftpress#development-setup) section of [README.md](https://github.com/likecoin/nftpress/blob/master/README.md).

## Issues / Bug reports

Expand All @@ -22,6 +22,6 @@ We use docker-based development workflow, please refer to [setup](https://github

- [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) for php, [airbnb](https://github.com/airbnb/javascript) for javascript.

- It must pass all [tests](https://github.com/likecoin/likecoin-wordpress#test)
- It must pass all [tests](https://github.com/likecoin/nftpress#test)

- We try our best to review PRs as soon as possible, be patient in case there is a hold up.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Web3Press WordPress Plugin By LikeCoin
# NFTPress WordPress Plugin By BROWN

[![WordPress plugin downloads](https://img.shields.io/wordpress/plugin/dt/likecoin.svg)](https://wordpress.org/plugins/likecoin/)
[![WordPress plugin downloads](https://img.shields.io/wordpress/plugin/dt/likecoin.svg)](https://wordpress.org/plugins/nftpress/)
[![WordPress plugin rating](https://img.shields.io/wordpress/plugin/r/likecoin.svg)](https://wordpress.org/plugins/likecoin/)
[![WordPress plugin version](https://img.shields.io/wordpress/plugin/v/likecoin.svg)](https://wordpress.org/plugins/likecoin/)
[![WordPress version tested](https://img.shields.io/wordpress/v/likecoin.svg)](https://wordpress.org/plugins/likecoin/)
[![CircleCI](https://circleci.com/gh/likecoin/likecoin-wordpress.svg?style=svg)](https://circleci.com/gh/likecoin/likecoin-wordpress)
[![Greenkeeper badge](https://badges.greenkeeper.io/likecoin/likecoin-wordpress.svg)](https://greenkeeper.io/)
[![WordPress plugin version](https://img.shields.io/wordpress/plugin/v/likecoin.svg)](https://wordpress.org/plugins/nftpress/)
[![WordPress version tested](https://img.shields.io/wordpress/v/likecoin.svg)](https://wordpress.org/plugins/nftpress/)

Integrates Liker ID functionality into your own WordPress site.

Expand Down
2 changes: 1 addition & 1 deletion likecoin/assets/js/admin-settings/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'b3c1d1535c55c0294675');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '00097e1ab2fe756e82de');
2 changes: 1 addition & 1 deletion likecoin/assets/js/admin-settings/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion likecoin/assets/js/sidebar/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-i18n', 'wp-plugins', 'wp-wordcount'), 'version' => '1fd3f1d416cd96f87f5a');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-i18n', 'wp-plugins', 'wp-wordcount'), 'version' => 'bc80d532cd8e3c163fef');
2 changes: 1 addition & 1 deletion likecoin/assets/js/sidebar/index.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions likecoin/js/admin-settings/src/store/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const ACTION_TYPES = {
SITE_PUBLISH: {
GET_OPTIONS: 'GET_SITE_PUBLISH_OPTIONS',
SET_OPTIONS: 'SET_SITE_PUBLISH_OPTIONS',
POST_OPTIONS_TO_DB: 'POST_SITE_PUBLISH_OPTIONS_TO_DB',
CHANGE_GLOBAL_STATE: 'CHANGE_SITE_PUBLISH_OPTIONS_GLOBAL_STATE',
},

OTHER_SETTINGS: {
SET_PAYMENT_POINTER: 'SET_PAYMENT_POINTER',
GET_PAYMENT_POINTER: 'GET_PAYMENT_POINTER',
POST_PAYMENT_POINTER: 'POST_PAYMENT_POINTER',
CHANGE_PAYMENT_POINTER_GLOBAL_STATE: 'CHANGE_PAYMENT_POINTER_GLOBAL_STATE',
},

COMMON: {
SET_ERROR_MESSAGE: 'SET_ERROR_MESSAGE',
},
};

export const API_ENDPOINTS = {
SITE_PUBLISH: '/likecoin/v1/option/publish',
WEB_MONETIZATION: '/likecoin/v1/option/web-monetization',
};

export const STORE_NAMES = {
SITE_PUBLISH: 'likecoin/site_publish',
OTHER_SETTINGS: 'likecoin/other_settings',
SITE_LIKER_INFO: 'likecoin/site_liker_info',
USER_LIKER_INFO: 'likecoin/user_liker_info',
};
30 changes: 30 additions & 0 deletions likecoin/js/admin-settings/src/store/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// eslint-disable-next-line arrow-body-style
export const createReducer = (actionHandlers, initialState) => {
// eslint-disable-next-line default-param-last
return (state = initialState || {}, action) => {
const handler = actionHandlers[action.type];
return handler ? handler(state, action) : state;
};
};
export const createAsyncActions = (domain, actionTypes) => ({
[`get${domain}`]: (path) => ({ type: actionTypes.GET, path }),
[`set${domain}`]: (data) => ({ type: actionTypes.SET, data }),
* [`post${domain}`](data) {
yield { type: actionTypes.POST_TO_DB, data };
yield { type: actionTypes.CHANGE_GLOBAL_STATE, data };
},
});

export const createErrorAction = (errorMsg) => ({
type: 'SET_ERROR_MESSAGE',
errorMsg,
});

export const createApiControl = (endpoint) => ({
GET: (action) => window.wp.apiFetch({ path: action.path || endpoint }),
POST: (action) => window.wp.apiFetch({
method: 'POST',
path: endpoint,
data: action.data,
}),
});
3 changes: 3 additions & 0 deletions likecoin/js/admin-settings/src/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { createAndRegisterReduxStore } from './util';
export * from './constants';
export * from './helpers';
48 changes: 20 additions & 28 deletions likecoin/js/admin-settings/src/store/other-setting-store.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
import apiFetch from '@wordpress/api-fetch';
import { createAndRegisterReduxStore } from './util';
import {
createAndRegisterReduxStore, ACTION_TYPES, API_ENDPOINTS, STORE_NAMES, createReducer,
} from './index';

// eslint-disable-next-line import/prefer-default-export
export const OTHER_SETTING_STORE_NAME = 'likecoin/other_settings';
export const OTHER_SETTING_STORE_NAME = STORE_NAMES.OTHER_SETTINGS;

const webMonetizationEndpoint = '/likecoin/v1/option/web-monetization';
const webMonetizationEndpoint = API_ENDPOINTS.WEB_MONETIZATION;
const INITIAL_STATE = {
DBPaymentPointer: '',
};
const actions = {
setPaymentPointer(paymentPointer) {
return {
type: 'SET_PAYMENT_POINTER',
type: ACTION_TYPES.OTHER_SETTINGS.SET_PAYMENT_POINTER,
paymentPointer,
};
},
getPaymentPointer() {
return {
type: 'GET_PAYMENT_POINTER',
type: ACTION_TYPES.OTHER_SETTINGS.GET_PAYMENT_POINTER,
};
},
setHTTPErrors(errorMsg) {
return {
type: 'SET_ERROR_MESSAGE',
type: ACTION_TYPES.COMMON.SET_ERROR_MESSAGE,
errorMsg,
};
},
* postPaymentPointer(paymentPointer) {
yield { type: 'POST_PAYMENT_POINTER', paymentPointer }; // change DB
yield { type: 'CHANGE_PAYMENT_POINTER_GLOBAL_STATE', paymentPointer }; // change global state
yield { type: ACTION_TYPES.OTHER_SETTINGS.POST_PAYMENT_POINTER, paymentPointer };
yield { type: ACTION_TYPES.OTHER_SETTINGS.CHANGE_PAYMENT_POINTER_GLOBAL_STATE, paymentPointer };
},
};

Expand All @@ -37,10 +39,10 @@ const selectors = {
};

const controls = {
GET_PAYMENT_POINTER() {
[ACTION_TYPES.OTHER_SETTINGS.GET_PAYMENT_POINTER]() {
return apiFetch({ path: webMonetizationEndpoint });
},
POST_PAYMENT_POINTER(action) {
[ACTION_TYPES.OTHER_SETTINGS.POST_PAYMENT_POINTER](action) {
return apiFetch({
method: 'POST',
path: webMonetizationEndpoint,
Expand All @@ -60,24 +62,14 @@ const resolvers = {
}
},
};
// eslint-disable-next-line default-param-last
const reducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case 'SET_PAYMENT_POINTER': {
return {
DBPaymentPointer: action.paymentPointer,
};
}
case 'CHANGE_PAYMENT_POINTER_GLOBAL_STATE': {
return {
DBPaymentPointer: action.paymentPointer,
};
}
default: {
return state;
}
}
};
const reducer = createReducer({
[ACTION_TYPES.OTHER_SETTINGS.SET_PAYMENT_POINTER]: (state, action) => ({
DBPaymentPointer: action.paymentPointer,
}),
[ACTION_TYPES.OTHER_SETTINGS.CHANGE_PAYMENT_POINTER_GLOBAL_STATE]: (state, action) => ({
DBPaymentPointer: action.paymentPointer,
}),
}, INITIAL_STATE);
const storeConfig = {
reducer,
controls,
Expand Down
70 changes: 32 additions & 38 deletions likecoin/js/admin-settings/src/store/site-publish-store.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import apiFetch from '@wordpress/api-fetch';
import { createAndRegisterReduxStore } from './util';
import {
createAndRegisterReduxStore, ACTION_TYPES, API_ENDPOINTS, STORE_NAMES, createReducer,
} from './index';

// eslint-disable-next-line import/prefer-default-export
export const SITE_PUBLISH_STORE_NAME = 'likecoin/site_publish';
export const SITE_PUBLISH_STORE_NAME = STORE_NAMES.SITE_PUBLISH;

const getPublishOptionEndpoint = '/likecoin/v1/option/publish';
const postPublishOptionsEndpoint = '/likecoin/v1/option/publish';
const getPublishOptionEndpoint = API_ENDPOINTS.SITE_PUBLISH;
const postPublishOptionsEndpoint = API_ENDPOINTS.SITE_PUBLISH;

const INITIAL_STATE = {
DBSiteInternetArchiveEnabled: false,
Expand All @@ -16,25 +18,25 @@ const INITIAL_STATE = {
const actions = {
getSitePublishOptions(path) {
return {
type: 'GET_SITE_PUBLISH_OPTIONS',
type: ACTION_TYPES.SITE_PUBLISH.GET_OPTIONS,
path,
};
},
setSitePublishOptions(options) {
return {
type: 'SET_SITE_PUBLISH_OPTIONS',
type: ACTION_TYPES.SITE_PUBLISH.SET_OPTIONS,
options,
};
},
setHTTPErrors(errorMsg) {
return {
type: 'SET_ERROR_MESSAGE',
type: ACTION_TYPES.COMMON.SET_ERROR_MESSAGE,
errorMsg,
};
},
* postSitePublishOptions(options) {
yield { type: 'POST_SITE_PUBLISH_OPTIONS_TO_DB', data: options };
yield { type: 'CHANGE_SITE_PUBLISH_OPTIONS_GLOBAL_STATE', data: options };
yield { type: ACTION_TYPES.SITE_PUBLISH.POST_OPTIONS_TO_DB, data: options };
yield { type: ACTION_TYPES.SITE_PUBLISH.CHANGE_GLOBAL_STATE, data: options };
},
};

Expand All @@ -43,10 +45,10 @@ const selectors = {
};

const controls = {
GET_SITE_PUBLISH_OPTIONS(action) {
[ACTION_TYPES.SITE_PUBLISH.GET_OPTIONS](action) {
return apiFetch({ path: action.path });
},
POST_SITE_PUBLISH_OPTIONS_TO_DB(action) {
[ACTION_TYPES.SITE_PUBLISH.POST_OPTIONS_TO_DB](action) {
return apiFetch({
method: 'POST',
path: postPublishOptionsEndpoint,
Expand All @@ -70,33 +72,25 @@ const resolvers = {
},
};

// eslint-disable-next-line default-param-last
const reducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case 'SET_SITE_PUBLISH_OPTIONS': {
return {
DBSiteInternetArchiveEnabled: action.options.lc_internet_archive_enabled,
DBSiteInternetArchiveAccessKey: action.options.lc_internet_archive_access_key,
DBISCNBadgeStyleOption: action.options.iscn_badge_style_option,
};
}
case 'CHANGE_SITE_PUBLISH_OPTIONS_GLOBAL_STATE': {
// HACK: remove all undefined data to prevent unneeded overwrite
const updateObject = JSON.parse(JSON.stringify({
DBSiteInternetArchiveEnabled: action.data.siteInternetArchiveEnabled,
DBSiteInternetArchiveAccessKey: action.data.siteInternetArchiveAccessKey,
DBISCNBadgeStyleOption: action.data.ISCNBadgeStyleOption,
}));
return {
...state,
...updateObject,
};
}
default: {
return state;
}
}
};
const reducer = createReducer({
[ACTION_TYPES.SITE_PUBLISH.SET_OPTIONS]: (state, action) => ({
DBSiteInternetArchiveEnabled: action.options.lc_internet_archive_enabled,
DBSiteInternetArchiveAccessKey: action.options.lc_internet_archive_access_key,
DBISCNBadgeStyleOption: action.options.iscn_badge_style_option,
}),
[ACTION_TYPES.SITE_PUBLISH.CHANGE_GLOBAL_STATE]: (state, action) => {
// HACK: remove all undefined data to prevent unneeded overwrite
const updateObject = JSON.parse(JSON.stringify({
DBSiteInternetArchiveEnabled: action.data.siteInternetArchiveEnabled,
DBSiteInternetArchiveAccessKey: action.data.siteInternetArchiveAccessKey,
DBISCNBadgeStyleOption: action.data.ISCNBadgeStyleOption,
}));
return {
...state,
...updateObject,
};
},
}, INITIAL_STATE);

const storeConfig = {
reducer,
Expand Down
8 changes: 2 additions & 6 deletions likecoin/js/sidebar/src/components/LicensePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ function LicensePicker({ onSelect, disabled, defaultLicense }) {
return (
<>
<StatusTitle title={__('License:', 'likecoin')} />
<select name="license" onChange={handleSelect} disabled={disabled ? true : null}>
<select name="license" onChange={handleSelect} disabled={disabled} value={defaultLicense}>
{OPTIONS.map((o) => (
<option
key={o.value}
selected={o.value === defaultLicense ? true : null}
value={o.value}
>
<option key={o.value} value={o.value}>
{o.name}
</option>
))}
Expand Down
Loading