Completed
Push — master ( 3860cc...10e837 )
by Stephanie
9s
created

formidable.php ➔ frm_forms_autoloader()   B

Complexity

Conditions 6
Paths 13

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nc 13
nop 1
dl 0
loc 26
rs 8.439
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
6
Plugin URI: https://formidableforms.com/
7
Author URI: http://strategy11.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 {
48
        $filepath .= '/models/';
49
    }
50
51
	$filepath .= $class_name . '.php';
52
53
    if ( file_exists($filepath) ) {
54
        include($filepath);
55
    }
56
}
57
58
// if __autoload is active, put it on the spl_autoload stack
59
if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) {
60
    spl_autoload_register('__autoload');
61
}
62
63
// Add the autoloader
64
spl_autoload_register('frm_forms_autoloader');
65
66
$frm_path = dirname(__FILE__);
67
if ( file_exists($frm_path . '/pro/formidable-pro.php') ) {
68
	include( $frm_path . '/pro/formidable-pro.php' );
69
}
70
71
FrmHooksController::trigger_load_hook();
72
73
include_once( $frm_path . '/deprecated.php' );
74
unset($frm_path);
75