Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Oct 18, 2019
1 parent f037c38 commit 6ade6f6
Show file tree
Hide file tree
Showing 21 changed files with 9,810 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
webpack.config.js
20 changes: 20 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": [
"plugin:@wordpress/eslint-plugin/recommended"
],
"env": {
"browser": true,
"es6": true
},
"rules": {
"comma-dangle": [2, "never"]
},
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"sourceType": "module"
}
}
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Exclude from release archives.

/.editorconfig export-ignore
/.git export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/CHANGELOG.md export-ignore
/composer.lock export-ignore
/contributing.md export-ignore
/LICENSE export-ignore
/package.json export-ignore
/webpack.config.js export-ignore
/.babelrc export-ignore
/src/*.js export-ignore
/composer.json export-ignore
/package-lock.json export-ignore
/README.md export-ignore

# Handle line endings.
# See https://help.github.com/articles/dealing-with-line-endings/

* text eol=lf
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0 - 2019-09-07

Initial Release.
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Example:

```php
new \WPLemon\Field\WCAGTextColor( [
'settings' => 'my_setting',
'label' => esc_html__( 'My Color Control', 'textdomain' ),
'description' => esc_html__( 'A description here.', 'textdomain' ),
'section' => 'my_section',
'default' => '',
'transport' => 'postMessage',
'choices' => [
'formComponent' => 'ChromePicker',
'backgroundColor' => 'test_accessible_textcolor_control_background', // setting-name or hardcoded color.
'textColor' => 'test_accessible_textcolor_control', // setting-name or hardcoded color.
'show' => [
'auto' => false,
'recommended' => false,
'custom' => true,
],
],
'sanitize_callback' => 'sanitize_text_field',
] );
```
80 changes: 80 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* Bootstrap the control.
*
* Addon control for the Kirki Toolkit for WordPress.
* Adds a new colorpicker control to the WordPress Customizer,
* allowing developers to build colorpickers that automatically suggest accessible link colors
* depending on the value of a background color and the surrounding-text.
*
* @package wcag-linkcolor
* @category Addon
* @author Ari Stathopoulos
* @copyright Copyright (c) 2019, Ari Stathopoulos
* @license https://opensource.org/licenses/MIT
* @since 2.0
*/

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

add_filter(
'kirki_control_types',

/**
* Registers the control with Kirki.
*
* @since 1.0
* @param array $controls An array of controls registered with the Kirki Framework.
* @return array
*/
function( $controls ) {
require_once __DIR__ . '/src/Control/WCAGTextColor.php';
$controls['kirki-wcag-tc'] = '\WPLemon\Control\WCAGTextColor';
return $controls;
}
);

add_action(
'customize_register',

/**
* Registers the control type and make it eligible for
* JS templating in the Customizer.
*
* @since 1.0
* @param WP_Customize $wp_customize The Customizer object.
* @return void
*/
function( $wp_customize ) {
require_once __DIR__ . '/src/Control/WCAGTextColor.php';
$wp_customize->register_control_type( '\WPLemon\Control\WCAGTextColor' );

// Add class aliases for backwards compatibility.
class_alias( '\WPLemon\Control\WCAGTextColor', 'Kirki_WCAG_Text_Color' );
},
0
);

/**
* Autoload Field for the Kirki v4.0 API.
*
* @since 2.0
*/
spl_autoload_register(
/**
* Autoload the class.
*
* @param string $class The class-name.
*/
function( $class ) {
if ( 'WPLemon\Field\WCAGTextColor' === $class || '\WPLemon\Field\WCAGTextColor' === $class ) {
require_once __DIR__ . '/src/Field/WCAGTextColor.php';
}
if ( 'WPLemon\Control\WCAGTextColor' === $class || '\WPLemon\Control\WCAGTextColor' === $class ) {
require_once __DIR__ . '/src/Control/WCAGTextColor.php';
}
}, false, true
);
28 changes: 28 additions & 0 deletions composer copy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "wplemon/control-wcag-linkcolor",
"type": "library",
"description": "Color control for the Kirki Customizer framework using react-color.",
"keywords": ["wordpress","customizer","framework"],
"homepage": "https://aristath.github.io/kirki",
"license": "MIT",
"authors": [
{
"name": "Ari Stathopoulos",
"email": "[email protected]",
"homepage": "http://aristath.github.io",
"role": "Developer"
}
],
"require": {
"php": ">=5.6",
"kirki-framework/control-base": "dev-master",
"kirki-framework/field": "dev-master",
"kirki-framework/url-getter": "*"
},
"autoload": {
"psr-4": {
"WPLemon\\Control\\": "src/Control",
"WPLemon\\Field\\": "src/Field"
}
}
}
Loading

0 comments on commit 6ade6f6

Please sign in to comment.