| @@ -1,14 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | -/* | |
| 3 | -Plugin Name: Formidable Forms | |
| 4 | -Description: Quickly and easily create drag-and-drop forms | |
| 5 | -Version: 6.3 | |
| 6 | -Plugin URI: https://formidableforms.com/ | |
| 7 | -Author URI: https://formidableforms.com/ | |
| 8 | -Author: Strategy11 Form Builder Team | |
| 9 | -Text Domain: formidable | |
| 10 | -*/ | |
| 2 | +/** | |
| 3 | + * Plugin Name: Formidable Forms | |
| 4 | + * Description: Quickly and easily create drag-and-drop forms | |
| 5 | + * Version: 6.15 | |
| 6 | + * Plugin URI: https://formidableforms.com/ | |
| 7 | + * Author URI: https://formidableforms.com/ | |
| 8 | + * Author: Strategy11 Form Builder Team | |
| 9 | + * Text Domain: formidable | |
| 10 | + * | |
| 11 | + * @package Formidable | |
| 12 | + */ | |
| 11 | 13 | |
| 12 | 14 | /* |
| 13 | 15 | Copyright 2010 Formidable Forms |
| 14 | 16 | |
| @@ -39,22 +41,22 @@ | ||
| 39 | 41 | 'pro_is_authorized' => false, |
| 40 | 42 | ); |
| 41 | 43 | |
| 42 | 44 | // For reverse compatibility. Load Pro if it's still nested. |
| 43 | - $frm_path = dirname( __FILE__ ); | |
| 45 | + $frm_path = __DIR__; | |
| 44 | 46 | if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { |
| 45 | - include( $frm_path . '/pro/formidable-pro.php' ); | |
| 47 | + include $frm_path . '/pro/formidable-pro.php'; | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | FrmHooksController::trigger_load_hook(); |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | -// if __autoload is active, put it on the spl_autoload stack | |
| 52 | -if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) { | |
| 53 | +// If __autoload is active, put it on the spl_autoload stack. | |
| 54 | +if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions(), true ) ) { | |
| 53 | 55 | spl_autoload_register( '__autoload' ); |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | -// Add the autoloader | |
| 58 | +// Add the autoloader. | |
| 57 | 59 | spl_autoload_register( 'frm_forms_autoloader' ); |
| 58 | 60 | |
| 59 | 61 | /** |
| 60 | 62 | * @return void |
| @@ -59,14 +61,14 @@ | ||
| 59 | 61 | /** |
| 60 | 62 | * @return void |
| 61 | 63 | */ |
| 62 | 64 | function frm_forms_autoloader( $class_name ) { |
| 63 | - // Only load Frm classes here | |
| 65 | + // Only load Frm classes here. | |
| 64 | 66 | if ( ! preg_match( '/^Frm.+$/', $class_name ) || preg_match( '/^FrmPro.+$/', $class_name ) ) { |
| 65 | 67 | return; |
| 66 | 68 | } |
| 67 | 69 | |
| 68 | - frm_class_autoloader( $class_name, dirname( __FILE__ ) ); | |
| 70 | + frm_class_autoloader( $class_name, __DIR__ ); | |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | /** |
| 72 | 74 | * Autoload the Formidable and Pro classes |
| @@ -75,10 +77,11 @@ | ||
| 75 | 77 | * |
| 76 | 78 | * @return void |
| 77 | 79 | */ |
| 78 | 80 | function frm_class_autoloader( $class_name, $filepath ) { |
| 79 | - $deprecated = array( 'FrmEntryFormat', 'FrmPointers', 'FrmEDD_SL_Plugin_Updater' ); | |
| 80 | - $is_deprecated = in_array( $class_name, $deprecated ) || preg_match( '/^.+Deprecate/', $class_name ); | |
| 81 | + $deprecated = array( 'FrmEDD_SL_Plugin_Updater' ); | |
| 82 | + $is_deprecated = in_array( $class_name, $deprecated, true ) || preg_match( '/^.+Deprecate/', $class_name ); | |
| 83 | + $original_filepath = $filepath; | |
| 81 | 84 | |
| 82 | 85 | if ( $is_deprecated ) { |
| 83 | 86 | $filepath .= '/deprecated/'; |
| 84 | 87 | } else { |
| @@ -84,12 +87,14 @@ | ||
| 84 | 87 | } else { |
| 85 | 88 | $filepath .= '/classes/'; |
| 86 | 89 | if ( preg_match( '/^.+Helper$/', $class_name ) ) { |
| 87 | 90 | $filepath .= 'helpers/'; |
| 88 | - } else if ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 91 | + } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 89 | 92 | $filepath .= 'controllers/'; |
| 90 | - } else if ( preg_match( '/^.+Factory$/', $class_name ) ) { | |
| 93 | + } elseif ( preg_match( '/^.+Factory$/', $class_name ) ) { | |
| 91 | 94 | $filepath .= 'factories/'; |
| 95 | + } elseif ( preg_match( '/^.+StyleComponent$/', $class_name ) ) { | |
| 96 | + $filepath .= 'views/styles/components/'; | |
| 92 | 97 | } else { |
| 93 | 98 | $filepath .= 'models/'; |
| 94 | 99 | if ( strpos( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) { |
| 95 | 100 | $filepath .= 'fields/'; |
| @@ -96,20 +101,60 @@ | ||
| 96 | 101 | } |
| 97 | 102 | } |
| 98 | 103 | } |
| 99 | 104 | |
| 105 | + if ( file_exists( $filepath . $class_name . '.php' ) ) { | |
| 106 | + require $filepath . $class_name . '.php'; | |
| 107 | + return; | |
| 108 | + } | |
| 109 | + | |
| 110 | + if ( ! preg_match( '/^FrmStrpLite.+$/', $class_name ) && ! preg_match( '/^FrmTransLite.+$/', $class_name ) ) { | |
| 111 | + // Exit early if the class does not match the Stripe Lite prefix. | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + | |
| 115 | + // Autoload for /stripe/ folder. | |
| 116 | + $filepath = $original_filepath . '/stripe/'; | |
| 117 | + if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 118 | + $filepath .= 'helpers/'; | |
| 119 | + } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 120 | + $filepath .= 'controllers/'; | |
| 121 | + } else { | |
| 122 | + $filepath .= 'models/'; | |
| 123 | + } | |
| 124 | + | |
| 100 | 125 | $filepath .= $class_name . '.php'; |
| 101 | 126 | |
| 102 | 127 | if ( file_exists( $filepath ) ) { |
| 103 | - require( $filepath ); | |
| 128 | + require $filepath; | |
| 104 | 129 | } |
| 105 | 130 | } |
| 106 | 131 | |
| 107 | 132 | add_action( 'activate_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'frm_maybe_install' ); |
| 133 | + | |
| 108 | 134 | /** |
| 135 | + * This function is triggered when Formidable is activated. | |
| 136 | + * | |
| 109 | 137 | * @return void |
| 110 | 138 | */ |
| 111 | 139 | function frm_maybe_install() { |
| 112 | - if ( get_transient( FrmWelcomeController::$option_name ) !== 'no' ) { | |
| 113 | - set_transient( FrmWelcomeController::$option_name, FrmWelcomeController::$menu_slug, 60 ); | |
| 140 | + if ( get_transient( FrmOnboardingWizardController::TRANSIENT_NAME ) !== 'no' ) { | |
| 141 | + set_transient( | |
| 142 | + FrmOnboardingWizardController::TRANSIENT_NAME, | |
| 143 | + FrmOnboardingWizardController::TRANSIENT_VALUE, | |
| 144 | + 60 | |
| 145 | + ); | |
| 114 | 146 | } |
| 147 | + | |
| 148 | + FrmAppController::handle_activation(); | |
| 115 | 149 | } |
| 150 | + | |
| 151 | +register_deactivation_hook( | |
| 152 | + __FILE__, | |
| 153 | + function () { | |
| 154 | + if ( ! class_exists( 'FrmCronController', false ) ) { | |
| 155 | + require_once __DIR__ . '/classes/controllers/FrmCronController.php'; | |
| 156 | + } | |
| 157 | + | |
| 158 | + FrmCronController::remove_crons(); | |
| 159 | + } | |
| 160 | +); | |