-
Notifications
You must be signed in to change notification settings - Fork 0
/
acf-repeater.php
139 lines (105 loc) · 2.42 KB
/
acf-repeater.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/*
Plugin Name: Advanced Custom Fields: Repeater Field
Plugin Slug: acf-repeater
Plugin URI: http://www.advancedcustomfields.com/
Description: This premium Add-on adds a repeater field type for the Advanced Custom Fields plugin
Version: 2.1.0
Author: Elliot Condon
Author URI: http://www.elliotcondon.com/
License: GPL
Copyright: Elliot Condon
*/
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( !class_exists('acf_plugin_repeater') ):
class acf_plugin_repeater {
// vars
var $settings;
/*
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function __construct() {
// vars
$this->settings = array(
// basic
'name' => __('Advanced Custom Fields: Repeater Field', 'acf'),
'version' => '2.1.0',
// urls
'slug' => dirname(plugin_basename( __FILE__ )),
'basename' => plugin_basename( __FILE__ ),
'path' => plugin_dir_path( __FILE__ ),
'dir' => plugin_dir_url( __FILE__ ),
);
// include v5 field
add_action('acf/include_field_types', array($this, 'include_field_types'));
// include v4 field
add_action('acf/register_fields', array($this, 'include_field_types'));
// include updates
if( is_admin() ) {
$this->include_file('acf-repeater-update.php');
}
}
/*
* include_file
*
* This function will check if a file exists before including it
*
* @type function
* @date 22/2/17
* @since 5.5.8
*
* @param $file (string)
* @return n/a
*/
function include_file( $file = '' ) {
$file = dirname(__FILE__) . '/'. $file;
if( file_exists($file) ) include_once( $file );
}
/*
* include_field_types
*
* This function will include the v5 field type
*
* @type function
* @date 12/06/2015
* @since 5.2.3
*
* @param n/a
* @return n/a
*/
function include_field_types() {
// vars
$version = '';
// version 5
if( defined('ACF_VERSION') ) {
// version 5.7+
if( version_compare(ACF_VERSION, '5.7.0', '>=') ) {
$version = '5-7';
// version 5.0
} else {
$version = '5-0';
}
// version 4
} else {
$version = '4-0';
}
// include
$this->include_file( "includes/$version/acf-repeater-field.php" );
}
}
// globals
global $acf_plugin_repeater;
// instantiate
$acf_plugin_repeater = new acf_plugin_repeater();
// end class
endif;
?>