forked from 7studio/acf-color-palette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acf-color-palette.php
81 lines (67 loc) · 2.04 KB
/
acf-color-palette.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/*
Plugin Name: Advanced Custom Fields: Color Palette
Plugin URI: https://github.com/7studio/acf-color-palette
Description: Add a new ACF field type: "Color Palette" which allows you to use the color picker with a defined color palette only.
Version: 1.0.0
Author: Xavier Zalawa
Author URI: http://www.7studio.fr
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: swp-acf-cp
Domain Path: /lang
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die( 'Something went wrong.' );
}
define( 'SWP_ACF_COLOR_PALETTE_VERSION', '1.0.0' );
define( 'SWP_ACF_COLOR_PALETTE_FILE', __FILE__ );
define( 'SWP_ACF_COLOR_PALETTE_URL', plugin_dir_url( SWP_ACF_COLOR_PALETTE_FILE ) );
define( 'SWP_ACF_COLOR_PALETTE_DIR', plugin_dir_path( SWP_ACF_COLOR_PALETTE_FILE ) );
if ( ! class_exists( 'swp_acf_plugin_color_palette' ) ) {
class swp_acf_plugin_color_palette {
// vars
var $settings;
/**
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 17/02/2016
* @since 1.0.0
*
* @param void
* @return void
*/
function __construct() {
$this->settings = array(
'version' => SWP_ACF_COLOR_PALETTE_VERSION,
'url' => SWP_ACF_COLOR_PALETTE_URL,
'path' => SWP_ACF_COLOR_PALETTE_DIR
);
// include field
add_action( 'acf/include_field_types', array( $this, 'include_field' ) ); // v5
add_action( 'acf/register_fields', array( $this, 'include_field' ) ); // v4
}
/**
* include_field
*
* This function will include the field type class and load textdomain
*
* @type function
* @date 17/02/2016
* @since 1.0.0
*
* @param $version (int) major ACF version. Defaults to 4
* @return void
*/
function include_field( $version = 4 ) {
// load textdomain
load_plugin_textdomain( 'swp-acf-cp', false, plugin_basename( SWP_ACF_COLOR_PALETTE_DIR ) . '/lang' );
include_once( "fields/class-swp-acf-color-palette-v{$version}.php" );
}
}
new swp_acf_plugin_color_palette();
}