| 1 |
<?php |
| 2 |
/** |
| 3 |
* Factory Forms |
| 4 |
* |
| 5 |
* @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 6 |
* @since 1.0.1 |
| 7 |
* @package factory-forms |
| 8 |
* @copyright (c) 2018, Webcraftic Ltd |
| 9 |
* |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly |
| 13 |
if( !defined('ABSPATH') ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
// the module provides function for the admin area only |
| 18 |
|
| 19 |
if( !is_admin() ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
// checks if the module is already loaded in order to |
| 24 |
// prevent loading the same version of the module twice. |
| 25 |
if( defined('FACTORY_FORMS_430_LOADED') ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
define('FACTORY_FORMS_430_LOADED', true); |
| 30 |
|
| 31 |
define('FACTORY_FORMS_430_VERSION', '4.3.0'); |
| 32 |
|
| 33 |
// absolute path and URL to the files and resources of the module. |
| 34 |
define('FACTORY_FORMS_430_DIR', dirname(__FILE__)); |
| 35 |
define('FACTORY_FORMS_430_URL', plugins_url(null, __FILE__)); |
| 36 |
|
| 37 |
#comp merge |
| 38 |
require_once(FACTORY_FORMS_430_DIR . '/includes/providers/value-provider.interface.php'); |
| 39 |
require_once(FACTORY_FORMS_430_DIR . '/includes/providers/meta-value-provider.class.php'); |
| 40 |
require_once(FACTORY_FORMS_430_DIR . '/includes/providers/options-value-provider.class.php'); |
| 41 |
|
| 42 |
require_once(FACTORY_FORMS_430_DIR . '/includes/form.class.php'); |
| 43 |
#endcomp |
| 44 |
|
| 45 |
load_plugin_textdomain('wbcr_factory_forms_430', false, dirname(plugin_basename(__FILE__)) . '/langs'); |
| 46 |
|
| 47 |
/** |
| 48 |
* We add this code into the hook because all these controls quite heavy. So in order to get better perfomance, |
| 49 |
* we load the form controls only on pages where the forms are created. |
| 50 |
* |
| 51 |
* @since 3.0.7 |
| 52 |
* @see the 'wbcr_factory_forms_430_register_controls' hook |
| 53 |
* |
| 54 |
*/ |
| 55 |
if( !function_exists('wbcr_factory_forms_430_register_default_controls') ) { |
| 56 |
|
| 57 |
/** |
| 58 |
* @param Wbcr_Factory432_Plugin $plugin |
| 59 |
* |
| 60 |
* @throws Exception |
| 61 |
*/ |
| 62 |
function wbcr_factory_forms_430_register_default_controls(Wbcr_Factory432_Plugin $plugin) |
| 63 |
{ |
| 64 |
|
| 65 |
if( $plugin && !isset($plugin->forms) ) { |
| 66 |
throw new Exception("The module Factory Forms is not loaded for the plugin '{$plugin->getPluginName()}'."); |
| 67 |
} |
| 68 |
|
| 69 |
require_once(FACTORY_FORMS_430_DIR . '/includes/html-builder.class.php'); |
| 70 |
require_once(FACTORY_FORMS_430_DIR . '/includes/form-element.class.php'); |
| 71 |
require_once(FACTORY_FORMS_430_DIR . '/includes/control.class.php'); |
| 72 |
require_once(FACTORY_FORMS_430_DIR . '/includes/complex-control.class.php'); |
| 73 |
require_once(FACTORY_FORMS_430_DIR . '/includes/holder.class.php'); |
| 74 |
require_once(FACTORY_FORMS_430_DIR . '/includes/control-holder.class.php'); |
| 75 |
require_once(FACTORY_FORMS_430_DIR . '/includes/custom-element.class.php'); |
| 76 |
require_once(FACTORY_FORMS_430_DIR . '/includes/form-layout.class.php'); |
| 77 |
|
| 78 |
// registration of controls |
| 79 |
$plugin->forms->registerControls([ |
| 80 |
[ |
| 81 |
'type' => 'checkbox', |
| 82 |
'class' => 'Wbcr_FactoryForms430_CheckboxControl', |
| 83 |
'include' => FACTORY_FORMS_430_DIR . '/controls/checkbox.php' |
| 84 |
], |
| 85 |
[ |
| 86 |
'type' => 'list', |
| 87 |
'class' => 'Wbcr_FactoryForms430_ListControl', |
| 88 |
'include' => FACTORY_FORMS_430_DIR . '/controls/list.php' |
| 89 |
], |
| 90 |
[ |
| 91 |
'type' => 'dropdown', |
| 92 |
'class' => 'Wbcr_FactoryForms430_DropdownControl', |
| 93 |
'include' => FACTORY_FORMS_430_DIR . '/controls/dropdown.php' |
| 94 |
], |
| 95 |
[ |
| 96 |
'type' => 'dropdown-and-colors', |
| 97 |
'class' => 'Wbcr_FactoryForms430_DropdownAndColorsControl', |
| 98 |
'include' => FACTORY_FORMS_430_DIR . '/controls/dropdown-and-colors.php' |
| 99 |
], |
| 100 |
[ |
| 101 |
'type' => 'hidden', |
| 102 |
'class' => 'Wbcr_FactoryForms430_HiddenControl', |
| 103 |
'include' => FACTORY_FORMS_430_DIR . '/controls/hidden.php' |
| 104 |
], |
| 105 |
[ |
| 106 |
'type' => 'hidden', |
| 107 |
'class' => 'Wbcr_FactoryForms430_HiddenControl', |
| 108 |
'include' => FACTORY_FORMS_430_DIR . '/controls/hidden.php' |
| 109 |
], |
| 110 |
[ |
| 111 |
'type' => 'radio', |
| 112 |
'class' => 'Wbcr_FactoryForms430_RadioControl', |
| 113 |
'include' => FACTORY_FORMS_430_DIR . '/controls/radio.php' |
| 114 |
], |
| 115 |
[ |
| 116 |
'type' => 'radio-colors', |
| 117 |
'class' => 'Wbcr_FactoryForms430_RadioColorsControl', |
| 118 |
'include' => FACTORY_FORMS_430_DIR . '/controls/radio-colors.php' |
| 119 |
], |
| 120 |
[ |
| 121 |
'type' => 'textarea', |
| 122 |
'class' => 'Wbcr_FactoryForms430_TextareaControl', |
| 123 |
'include' => FACTORY_FORMS_430_DIR . '/controls/textarea.php' |
| 124 |
], |
| 125 |
[ |
| 126 |
'type' => 'textbox', |
| 127 |
'class' => 'Wbcr_FactoryForms430_TextboxControl', |
| 128 |
'include' => FACTORY_FORMS_430_DIR . '/controls/textbox.php' |
| 129 |
], |
| 130 |
[ |
| 131 |
'type' => 'multiple-textbox', |
| 132 |
'class' => 'Wbcr_FactoryForms430_MultipleTextboxControl', |
| 133 |
'include' => FACTORY_FORMS_430_DIR . '/controls/multiple-textbox.php' |
| 134 |
], |
| 135 |
[ |
| 136 |
'type' => 'datetimepicker-range', |
| 137 |
'class' => 'Wbcr_FactoryForms430_DatepickerRangeControl', |
| 138 |
'include' => FACTORY_FORMS_430_DIR . '/controls/datepicker-range.php' |
| 139 |
], |
| 140 |
[ |
| 141 |
'type' => 'url', |
| 142 |
'class' => 'Wbcr_FactoryForms430_UrlControl', |
| 143 |
'include' => FACTORY_FORMS_430_DIR . '/controls/url.php' |
| 144 |
], |
| 145 |
[ |
| 146 |
'type' => 'wp-editor', |
| 147 |
'class' => 'Wbcr_FactoryForms430_WpEditorControl', |
| 148 |
'include' => FACTORY_FORMS_430_DIR . '/controls/wp-editor.php' |
| 149 |
], |
| 150 |
[ |
| 151 |
'type' => 'color', |
| 152 |
'class' => 'Wbcr_FactoryForms430_ColorControl', |
| 153 |
'include' => FACTORY_FORMS_430_DIR . '/controls/color.php' |
| 154 |
], |
| 155 |
[ |
| 156 |
'type' => 'color-and-opacity', |
| 157 |
'class' => 'Wbcr_FactoryForms430_ColorAndOpacityControl', |
| 158 |
'include' => FACTORY_FORMS_430_DIR . '/controls/color-and-opacity.php' |
| 159 |
], |
| 160 |
[ |
| 161 |
'type' => 'gradient', |
| 162 |
'class' => 'Wbcr_FactoryForms430_GradientControl', |
| 163 |
'include' => FACTORY_FORMS_430_DIR . '/controls/gradient.php' |
| 164 |
], |
| 165 |
[ |
| 166 |
'type' => 'font', |
| 167 |
'class' => 'Wbcr_FactoryForms430_FontControl', |
| 168 |
'include' => FACTORY_FORMS_430_DIR . '/controls/font.php' |
| 169 |
], |
| 170 |
[ |
| 171 |
'type' => 'google-font', |
| 172 |
'class' => 'Wbcr_FactoryForms430_GoogleFontControl', |
| 173 |
'include' => FACTORY_FORMS_430_DIR . '/controls/google-font.php' |
| 174 |
], |
| 175 |
[ |
| 176 |
'type' => 'pattern', |
| 177 |
'class' => 'Wbcr_FactoryForms430_PatternControl', |
| 178 |
'include' => FACTORY_FORMS_430_DIR . '/controls/pattern.php' |
| 179 |
], |
| 180 |
[ |
| 181 |
'type' => 'integer', |
| 182 |
'class' => 'Wbcr_FactoryForms430_IntegerControl', |
| 183 |
'include' => FACTORY_FORMS_430_DIR . '/controls/integer.php' |
| 184 |
], |
| 185 |
[ |
| 186 |
'type' => 'control-group', |
| 187 |
'class' => 'Wbcr_FactoryForms430_ControlGroupHolder', |
| 188 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/control-group.php' |
| 189 |
], |
| 190 |
[ |
| 191 |
'type' => 'paddings-editor', |
| 192 |
'class' => 'Wbcr_FactoryForms430_PaddingsEditorControl', |
| 193 |
'include' => FACTORY_FORMS_430_DIR . '/controls/paddings-editor.php' |
| 194 |
], |
| 195 |
]); |
| 196 |
|
| 197 |
// registration of control holders |
| 198 |
$plugin->forms->registerHolders([ |
| 199 |
[ |
| 200 |
'type' => 'tab', |
| 201 |
'class' => 'Wbcr_FactoryForms430_TabHolder', |
| 202 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/tab.php' |
| 203 |
], |
| 204 |
[ |
| 205 |
'type' => 'tab-item', |
| 206 |
'class' => 'Wbcr_FactoryForms430_TabItemHolder', |
| 207 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/tab-item.php' |
| 208 |
], |
| 209 |
[ |
| 210 |
'type' => 'accordion', |
| 211 |
'class' => 'Wbcr_FactoryForms430_AccordionHolder', |
| 212 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/accordion.php' |
| 213 |
], |
| 214 |
[ |
| 215 |
'type' => 'accordion-item', |
| 216 |
'class' => 'Wbcr_FactoryForms430_AccordionItemHolder', |
| 217 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/accordion-item.php' |
| 218 |
], |
| 219 |
[ |
| 220 |
'type' => 'control-group', |
| 221 |
'class' => 'Wbcr_FactoryForms430_ControlGroupHolder', |
| 222 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/control-group.php' |
| 223 |
], |
| 224 |
[ |
| 225 |
'type' => 'control-group-item', |
| 226 |
'class' => 'Wbcr_FactoryForms430_ControlGroupItem', |
| 227 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/control-group-item.php' |
| 228 |
], |
| 229 |
[ |
| 230 |
'type' => 'form-group', |
| 231 |
'class' => 'Wbcr_FactoryForms430_FormGroupHolder', |
| 232 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/form-group.php' |
| 233 |
], |
| 234 |
[ |
| 235 |
'type' => 'more-link', |
| 236 |
'class' => 'Wbcr_FactoryForms430_MoreLinkHolder', |
| 237 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/more-link.php' |
| 238 |
], |
| 239 |
[ |
| 240 |
'type' => 'div', |
| 241 |
'class' => 'Wbcr_FactoryForms430_DivHolder', |
| 242 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/div.php' |
| 243 |
], |
| 244 |
[ |
| 245 |
'type' => 'columns', |
| 246 |
'class' => 'Wbcr_FactoryForms430_ColumnsHolder', |
| 247 |
'include' => FACTORY_FORMS_430_DIR . '/controls/holders/columns.php' |
| 248 |
] |
| 249 |
]); |
| 250 |
|
| 251 |
// registration custom form elements |
| 252 |
$plugin->forms->registerCustomElements([ |
| 253 |
[ |
| 254 |
'type' => 'html', |
| 255 |
'class' => 'Wbcr_FactoryForms430_Html', |
| 256 |
'include' => FACTORY_FORMS_430_DIR . '/controls/customs/html.php', |
| 257 |
], |
| 258 |
[ |
| 259 |
'type' => 'separator', |
| 260 |
'class' => 'Wbcr_FactoryForms430_Separator', |
| 261 |
'include' => FACTORY_FORMS_430_DIR . '/controls/customs/separator.php', |
| 262 |
], |
| 263 |
]); |
| 264 |
|
| 265 |
// registration of form layouts |
| 266 |
$plugin->forms->registerFormLayout([ |
| 267 |
'name' => 'bootstrap-3', |
| 268 |
'class' => 'Wbcr_FactoryForms430_Bootstrap3FormLayout', |
| 269 |
'include' => FACTORY_FORMS_430_DIR . '/layouts/bootstrap-3/bootstrap-3.php' |
| 270 |
]); |
| 271 |
} |
| 272 |
|
| 273 |
add_action('wbcr_factory_forms_430_register_controls', 'wbcr_factory_forms_430_register_default_controls'); |
| 274 |
} |