Completed
Push — master ( ba1cd7...836330 )
by Jamie
02:56
created

formidable.php ➔ frm_forms_autoloader()   C

Complexity

Conditions 7
Paths 17

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 18
nc 17
nop 1
dl 0
loc 28
rs 6.7272
c 0
b 0
f 0
1
<?php
2
/*
3
Plugin Name: Formidable Forms
4
Description: Quickly and easily create drag-and-drop forms
5
Version: 2.03.11a1
6
Plugin URI: https://formidableforms.com/
7
Author URI: https://formidableforms.com/
8
Author: Strategy11
9
Text Domain: formidable
10
*/
11
12
/*  Copyright 2010  Formidable Forms
13
14
    This program is free software; you can redistribute it and/or modify
15
    it under the terms of the GNU General Public License, version 2, as
16
    published by the Free Software Foundation.
17
18
    This program is distributed in the hope that it will be useful,
19
    but WITHOUT ANY WARRANTY; without even the implied warranty of
20
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
    GNU General Public License for more details.
22
*/
23
24
global $frm_vars;
25
$frm_vars = array(
26
    'load_css' => false, 'forms_loaded' => array(),
27
    'created_entries'   => array(),
28
    'pro_is_authorized' => false,
29
);
30
31
function frm_forms_autoloader( $class_name ) {
32
    // Only load Frm classes here
33
	if ( ! preg_match( '/^Frm.+$/', $class_name ) ) {
34
        return;
35
    }
36
37
    $filepath = dirname(__FILE__);
38
	if ( preg_match( '/^FrmPro.+$/', $class_name ) ) {
39
        $filepath .= '/pro';
40
    }
41
    $filepath .= '/classes';
42
43
	if ( preg_match( '/^.+Helper$/', $class_name ) ) {
44
        $filepath .= '/helpers/';
45
	} else if ( preg_match( '/^.+Controller$/', $class_name ) ) {
46
        $filepath .= '/controllers/';
47
	} else if ( preg_match( '/^.+Factory$/', $class_name ) ) {
48
		$filepath .= '/factories/';
49
    } else {
50
        $filepath .= '/models/';
51
    }
52
53
	$filepath .= $class_name . '.php';
54
55
    if ( file_exists($filepath) ) {
56
        include($filepath);
57
    }
58
}
59
60
// if __autoload is active, put it on the spl_autoload stack
61
if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) {
62
    spl_autoload_register('__autoload');
63
}
64
65
// Add the autoloader
66
spl_autoload_register('frm_forms_autoloader');
67
68
$frm_path = dirname(__FILE__);
69
if ( file_exists($frm_path . '/pro/formidable-pro.php') ) {
70
	include( $frm_path . '/pro/formidable-pro.php' );
71
}
72
73
FrmHooksController::trigger_load_hook();
74
75
include_once( $frm_path . '/deprecated.php' );
76
unset($frm_path);
77