Completed
Push — master ( fa3192...c4c6a2 )
by Stephanie
21s queued 11s
created

formidable.php ➔ frm_maybe_install()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 5
rs 10
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: 4.09.05
6
Plugin URI: https://formidableforms.com/
7
Author URI: https://formidableforms.com/
8
Author: Strategy11
9
Text Domain: formidable
10
*/
11
12
/*
13
	Copyright 2010  Formidable Forms
14
15
	This program is free software; you can redistribute it and/or modify
16
	it under the terms of the GNU General Public License, version 2, as
17
	published by the Free Software Foundation.
18
19
	This program is distributed in the hope that it will be useful,
20
	but WITHOUT ANY WARRANTY; without even the implied warranty of
21
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
	GNU General Public License for more details.
23
*/
24
25
if ( ! defined( 'ABSPATH' ) ) {
26
	die( 'You are not allowed to call this page directly.' );
27
}
28
29
add_action( 'plugins_loaded', 'load_formidable_forms', 0 );
30
function load_formidable_forms() {
31
	global $frm_vars;
32
	$frm_vars = array(
33
		'load_css'          => false,
34
		'forms_loaded'      => array(),
35
		'created_entries'   => array(),
36
		'pro_is_authorized' => false,
37
	);
38
39
	// For reverse compatibility. Load Pro if it's still nested.
40
	$frm_path = dirname( __FILE__ );
41
	if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) {
42
		include( $frm_path . '/pro/formidable-pro.php' );
43
	}
44
45
	FrmHooksController::trigger_load_hook();
46
}
47
48
// if __autoload is active, put it on the spl_autoload stack
49
if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) {
50
	spl_autoload_register( '__autoload' );
51
}
52
53
// Add the autoloader
54
spl_autoload_register( 'frm_forms_autoloader' );
55
56
function frm_forms_autoloader( $class_name ) {
57
	// Only load Frm classes here
58
	if ( ! preg_match( '/^Frm.+$/', $class_name ) || preg_match( '/^FrmPro.+$/', $class_name ) ) {
59
		return;
60
	}
61
62
	frm_class_autoloader( $class_name, dirname( __FILE__ ) );
63
}
64
65
/**
66
 * Autoload the Formidable and Pro classes
67
 *
68
 * @since 3.0
69
 */
70
function frm_class_autoloader( $class_name, $filepath ) {
71
	$deprecated    = array( 'FrmEntryFormat', 'FrmPointers', 'FrmEDD_SL_Plugin_Updater' );
72
	$is_deprecated = in_array( $class_name, $deprecated ) || preg_match( '/^.+Deprecate/', $class_name );
73
74
	if ( $is_deprecated ) {
75
		$filepath .= '/deprecated/';
76
	} else {
77
		$filepath .= '/classes/';
78
		if ( preg_match( '/^.+Helper$/', $class_name ) ) {
79
			$filepath .= 'helpers/';
80
		} else if ( preg_match( '/^.+Controller$/', $class_name ) ) {
81
			$filepath .= 'controllers/';
82
		} else if ( preg_match( '/^.+Factory$/', $class_name ) ) {
83
			$filepath .= 'factories/';
84
		} else {
85
			$filepath .= 'models/';
86
			if ( strpos( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) {
87
				$filepath .= 'fields/';
88
			}
89
		}
90
	}
91
92
	$filepath .= $class_name . '.php';
93
94
	if ( file_exists( $filepath ) ) {
95
		require( $filepath );
96
	}
97
}
98
99
add_action( 'activate_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'frm_maybe_install' );
100
function frm_maybe_install() {
101
	if ( get_transient( FrmWelcomeController::$option_name ) !== 'no' ) {
102
		set_transient( FrmWelcomeController::$option_name, FrmWelcomeController::$menu_slug, 60 );
103
	}
104
}
105