forked from mujahidi/acf-typography
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acf-typography.php
116 lines (84 loc) · 2.94 KB
/
acf-typography.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/*
Plugin Name: Advanced Custom Fields: Typography Field
Plugin URI: https://wordpress.org/plugins/acf-typography-field
Description: A Typography Add-on for the Advanced Custom Fields Plugin.
Version: 3.3.0
Author: Mujahid Ishtiaq
Author URI: https://github.com/mujahidi
Text Domain: acf-typography
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// exit if accessed directly
if( ! defined( 'ABSPATH' ) ) exit;
$acft_options = get_option( 'acft_settings' );
if( $acft_options && $acft_options['google_key'] )
define('YOUR_API_KEY', $acft_options['google_key']);
if( $acft_options && isset($acft_options['files_source']) )
define('FONT_FILE_SOURCE', $acft_options['files_source']);
// load translation files for textdomain
function acft_load_textdomain() {
load_plugin_textdomain( 'acf-typography', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'acft_load_textdomain' );
// check if class already exists
if( !class_exists('acf_plugin_Typography') ) :
class acf_plugin_Typography {
/*
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 17/02/2016
* @since 1.0.0
*
* @param n/a
* @return n/a
*/
function __construct() {
// vars
$this->settings = array(
'version' => '3.3.0',
'url' => plugin_dir_url( __FILE__ ),
'path' => plugin_dir_path( __FILE__ )
);
// include files
require plugin_dir_path( __FILE__ ) . 'includes/admin_settings.php';
require plugin_dir_path( __FILE__ ) . 'includes/api-template.php';
require plugin_dir_path( __FILE__ ) . 'includes/functions.php';
if (class_exists('ACF')) {
// include field
add_action('acf/include_field_types', array($this, 'include_field_types')); // v5, v6
add_action('acf/register_fields', array($this, 'include_field_types')); // v4
add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'));
}
}
/*
* include_field_types
*
* This function will include the field type class
*
* @type function
* @date 17/02/2016
* @since 1.0.0
*
* @param $version (int) major ACF version. Defaults to false
* @return n/a
*/
function include_field_types( $version = false ) {
// support empty $version
if( !$version ) $version = 4;
// include
include_once('fields/acf-Typography-v' . $version . '.php');
}
function field_group_admin_enqueue_scripts(){
wp_enqueue_script( 'acf-typography-fieldgroup-script', plugin_dir_url( __FILE__ ) . 'assets/js/admin-field-group.js', array(), $this->settings['version'] );
}
}
// initialize
new acf_plugin_Typography();
// class_exists check
endif;
?>