assets
3 years ago
controls
1 year ago
includes
1 year ago
langs
1 year ago
layouts
1 year ago
boot.php
1 year ago
index.php
3 years ago
boot.php
268 lines
| 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 | // checks if the module is already loaded in order to |
| 18 | // prevent loading the same version of the module twice. |
| 19 | if ( defined( 'FACTORY_FORMS_480_LOADED' ) ) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | define( 'FACTORY_FORMS_480_LOADED', true ); |
| 24 | define( 'FACTORY_FORMS_480_VERSION', '4.8.0' ); |
| 25 | |
| 26 | // absolute path and URL to the files and resources of the module. |
| 27 | define( 'FACTORY_FORMS_480_DIR', dirname( __FILE__ ) ); |
| 28 | define( 'FACTORY_FORMS_480_URL', plugins_url( '', __FILE__ ) ); |
| 29 | |
| 30 | #comp merge |
| 31 | require_once( FACTORY_FORMS_480_DIR . '/includes/providers/value-provider.interface.php' ); |
| 32 | require_once( FACTORY_FORMS_480_DIR . '/includes/providers/meta-value-provider.class.php' ); |
| 33 | require_once( FACTORY_FORMS_480_DIR . '/includes/providers/options-value-provider.class.php' ); |
| 34 | |
| 35 | require_once( FACTORY_FORMS_480_DIR . '/includes/form.class.php' ); |
| 36 | #endcomp |
| 37 | |
| 38 | add_action( 'init', function () { |
| 39 | load_plugin_textdomain( 'wbcr_factory_forms_480', false, dirname( plugin_basename( __FILE__ ) ) . '/langs' ); |
| 40 | } ); |
| 41 | |
| 42 | /** |
| 43 | * We add this code into the hook because all these controls quite heavy. So in order to get better perfomance, |
| 44 | * we load the form controls only on pages where the forms are created. |
| 45 | * |
| 46 | * @since 3.0.7 |
| 47 | * @see the 'wbcr_factory_forms_480_register_controls' hook |
| 48 | * |
| 49 | */ |
| 50 | if ( ! function_exists( 'wbcr_factory_forms_480_register_default_controls' ) ) { |
| 51 | |
| 52 | /** |
| 53 | * @param Wbcr_Factory480_Plugin $plugin |
| 54 | * |
| 55 | * @throws Exception |
| 56 | */ |
| 57 | function wbcr_factory_forms_480_register_default_controls( Wbcr_Factory480_Plugin $plugin ) { |
| 58 | |
| 59 | if ( $plugin && ! isset( $plugin->forms ) ) { |
| 60 | throw new Exception( "The module Factory Forms is not loaded for the plugin '{$plugin->getPluginName()}'." ); |
| 61 | } |
| 62 | |
| 63 | require_once( FACTORY_FORMS_480_DIR . '/includes/html-builder.class.php' ); |
| 64 | require_once( FACTORY_FORMS_480_DIR . '/includes/form-element.class.php' ); |
| 65 | require_once( FACTORY_FORMS_480_DIR . '/includes/control.class.php' ); |
| 66 | require_once( FACTORY_FORMS_480_DIR . '/includes/complex-control.class.php' ); |
| 67 | require_once( FACTORY_FORMS_480_DIR . '/includes/holder.class.php' ); |
| 68 | require_once( FACTORY_FORMS_480_DIR . '/includes/control-holder.class.php' ); |
| 69 | require_once( FACTORY_FORMS_480_DIR . '/includes/custom-element.class.php' ); |
| 70 | require_once( FACTORY_FORMS_480_DIR . '/includes/form-layout.class.php' ); |
| 71 | |
| 72 | // registration of controls |
| 73 | $plugin->forms->registerControls( [ |
| 74 | [ |
| 75 | 'type' => 'checkbox', |
| 76 | 'class' => 'Wbcr_FactoryForms480_CheckboxControl', |
| 77 | 'include' => FACTORY_FORMS_480_DIR . '/controls/checkbox.php' |
| 78 | ], |
| 79 | [ |
| 80 | 'type' => 'list', |
| 81 | 'class' => 'Wbcr_FactoryForms480_ListControl', |
| 82 | 'include' => FACTORY_FORMS_480_DIR . '/controls/list.php' |
| 83 | ], |
| 84 | [ |
| 85 | 'type' => 'dropdown', |
| 86 | 'class' => 'Wbcr_FactoryForms480_DropdownControl', |
| 87 | 'include' => FACTORY_FORMS_480_DIR . '/controls/dropdown.php' |
| 88 | ], |
| 89 | [ |
| 90 | 'type' => 'dropdown-and-colors', |
| 91 | 'class' => 'Wbcr_FactoryForms480_DropdownAndColorsControl', |
| 92 | 'include' => FACTORY_FORMS_480_DIR . '/controls/dropdown-and-colors.php' |
| 93 | ], |
| 94 | [ |
| 95 | 'type' => 'hidden', |
| 96 | 'class' => 'Wbcr_FactoryForms480_HiddenControl', |
| 97 | 'include' => FACTORY_FORMS_480_DIR . '/controls/hidden.php' |
| 98 | ], |
| 99 | [ |
| 100 | 'type' => 'hidden', |
| 101 | 'class' => 'Wbcr_FactoryForms480_HiddenControl', |
| 102 | 'include' => FACTORY_FORMS_480_DIR . '/controls/hidden.php' |
| 103 | ], |
| 104 | [ |
| 105 | 'type' => 'radio', |
| 106 | 'class' => 'Wbcr_FactoryForms480_RadioControl', |
| 107 | 'include' => FACTORY_FORMS_480_DIR . '/controls/radio.php' |
| 108 | ], |
| 109 | [ |
| 110 | 'type' => 'radio-colors', |
| 111 | 'class' => 'Wbcr_FactoryForms480_RadioColorsControl', |
| 112 | 'include' => FACTORY_FORMS_480_DIR . '/controls/radio-colors.php' |
| 113 | ], |
| 114 | [ |
| 115 | 'type' => 'textarea', |
| 116 | 'class' => 'Wbcr_FactoryForms480_TextareaControl', |
| 117 | 'include' => FACTORY_FORMS_480_DIR . '/controls/textarea.php' |
| 118 | ], |
| 119 | [ |
| 120 | 'type' => 'textbox', |
| 121 | 'class' => 'Wbcr_FactoryForms480_TextboxControl', |
| 122 | 'include' => FACTORY_FORMS_480_DIR . '/controls/textbox.php' |
| 123 | ], |
| 124 | [ |
| 125 | 'type' => 'multiple-textbox', |
| 126 | 'class' => 'Wbcr_FactoryForms480_MultipleTextboxControl', |
| 127 | 'include' => FACTORY_FORMS_480_DIR . '/controls/multiple-textbox.php' |
| 128 | ], |
| 129 | [ |
| 130 | 'type' => 'datetimepicker-range', |
| 131 | 'class' => 'Wbcr_FactoryForms480_DatepickerRangeControl', |
| 132 | 'include' => FACTORY_FORMS_480_DIR . '/controls/datepicker-range.php' |
| 133 | ], |
| 134 | [ |
| 135 | 'type' => 'url', |
| 136 | 'class' => 'Wbcr_FactoryForms480_UrlControl', |
| 137 | 'include' => FACTORY_FORMS_480_DIR . '/controls/url.php' |
| 138 | ], |
| 139 | [ |
| 140 | 'type' => 'wp-editor', |
| 141 | 'class' => 'Wbcr_FactoryForms480_WpEditorControl', |
| 142 | 'include' => FACTORY_FORMS_480_DIR . '/controls/wp-editor.php' |
| 143 | ], |
| 144 | [ |
| 145 | 'type' => 'color', |
| 146 | 'class' => 'Wbcr_FactoryForms480_ColorControl', |
| 147 | 'include' => FACTORY_FORMS_480_DIR . '/controls/color.php' |
| 148 | ], |
| 149 | [ |
| 150 | 'type' => 'color-and-opacity', |
| 151 | 'class' => 'Wbcr_FactoryForms480_ColorAndOpacityControl', |
| 152 | 'include' => FACTORY_FORMS_480_DIR . '/controls/color-and-opacity.php' |
| 153 | ], |
| 154 | [ |
| 155 | 'type' => 'gradient', |
| 156 | 'class' => 'Wbcr_FactoryForms480_GradientControl', |
| 157 | 'include' => FACTORY_FORMS_480_DIR . '/controls/gradient.php' |
| 158 | ], |
| 159 | [ |
| 160 | 'type' => 'font', |
| 161 | 'class' => 'Wbcr_FactoryForms480_FontControl', |
| 162 | 'include' => FACTORY_FORMS_480_DIR . '/controls/font.php' |
| 163 | ], |
| 164 | [ |
| 165 | 'type' => 'google-font', |
| 166 | 'class' => 'Wbcr_FactoryForms480_GoogleFontControl', |
| 167 | 'include' => FACTORY_FORMS_480_DIR . '/controls/google-font.php' |
| 168 | ], |
| 169 | [ |
| 170 | 'type' => 'pattern', |
| 171 | 'class' => 'Wbcr_FactoryForms480_PatternControl', |
| 172 | 'include' => FACTORY_FORMS_480_DIR . '/controls/pattern.php' |
| 173 | ], |
| 174 | [ |
| 175 | 'type' => 'integer', |
| 176 | 'class' => 'Wbcr_FactoryForms480_IntegerControl', |
| 177 | 'include' => FACTORY_FORMS_480_DIR . '/controls/integer.php' |
| 178 | ], |
| 179 | [ |
| 180 | 'type' => 'control-group', |
| 181 | 'class' => 'Wbcr_FactoryForms480_ControlGroupHolder', |
| 182 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/control-group.php' |
| 183 | ], |
| 184 | [ |
| 185 | 'type' => 'paddings-editor', |
| 186 | 'class' => 'Wbcr_FactoryForms480_PaddingsEditorControl', |
| 187 | 'include' => FACTORY_FORMS_480_DIR . '/controls/paddings-editor.php' |
| 188 | ], |
| 189 | ] ); |
| 190 | |
| 191 | // registration of control holders |
| 192 | $plugin->forms->registerHolders( [ |
| 193 | [ |
| 194 | 'type' => 'tab', |
| 195 | 'class' => 'Wbcr_FactoryForms480_TabHolder', |
| 196 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/tab.php' |
| 197 | ], |
| 198 | [ |
| 199 | 'type' => 'tab-item', |
| 200 | 'class' => 'Wbcr_FactoryForms480_TabItemHolder', |
| 201 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/tab-item.php' |
| 202 | ], |
| 203 | [ |
| 204 | 'type' => 'accordion', |
| 205 | 'class' => 'Wbcr_FactoryForms480_AccordionHolder', |
| 206 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/accordion.php' |
| 207 | ], |
| 208 | [ |
| 209 | 'type' => 'accordion-item', |
| 210 | 'class' => 'Wbcr_FactoryForms480_AccordionItemHolder', |
| 211 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/accordion-item.php' |
| 212 | ], |
| 213 | [ |
| 214 | 'type' => 'control-group', |
| 215 | 'class' => 'Wbcr_FactoryForms480_ControlGroupHolder', |
| 216 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/control-group.php' |
| 217 | ], |
| 218 | [ |
| 219 | 'type' => 'control-group-item', |
| 220 | 'class' => 'Wbcr_FactoryForms480_ControlGroupItem', |
| 221 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/control-group-item.php' |
| 222 | ], |
| 223 | [ |
| 224 | 'type' => 'form-group', |
| 225 | 'class' => 'Wbcr_FactoryForms480_FormGroupHolder', |
| 226 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/form-group.php' |
| 227 | ], |
| 228 | [ |
| 229 | 'type' => 'more-link', |
| 230 | 'class' => 'Wbcr_FactoryForms480_MoreLinkHolder', |
| 231 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/more-link.php' |
| 232 | ], |
| 233 | [ |
| 234 | 'type' => 'div', |
| 235 | 'class' => 'Wbcr_FactoryForms480_DivHolder', |
| 236 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/div.php' |
| 237 | ], |
| 238 | [ |
| 239 | 'type' => 'columns', |
| 240 | 'class' => 'Wbcr_FactoryForms480_ColumnsHolder', |
| 241 | 'include' => FACTORY_FORMS_480_DIR . '/controls/holders/columns.php' |
| 242 | ] |
| 243 | ] ); |
| 244 | |
| 245 | // registration custom form elements |
| 246 | $plugin->forms->registerCustomElements( [ |
| 247 | [ |
| 248 | 'type' => 'html', |
| 249 | 'class' => 'Wbcr_FactoryForms480_Html', |
| 250 | 'include' => FACTORY_FORMS_480_DIR . '/controls/customs/html.php', |
| 251 | ], |
| 252 | [ |
| 253 | 'type' => 'separator', |
| 254 | 'class' => 'Wbcr_FactoryForms480_Separator', |
| 255 | 'include' => FACTORY_FORMS_480_DIR . '/controls/customs/separator.php', |
| 256 | ], |
| 257 | ] ); |
| 258 | |
| 259 | // registration of form layouts |
| 260 | $plugin->forms->registerFormLayout( [ |
| 261 | 'name' => 'bootstrap-3', |
| 262 | 'class' => 'Wbcr_FactoryForms480_Bootstrap3FormLayout', |
| 263 | 'include' => FACTORY_FORMS_480_DIR . '/layouts/bootstrap-3/bootstrap-3.php' |
| 264 | ] ); |
| 265 | } |
| 266 | |
| 267 | add_action( 'wbcr_factory_forms_480_register_controls', 'wbcr_factory_forms_480_register_default_controls' ); |
| 268 | } |