| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Formidable Forms |
| 4 | 4 | * Description: Quickly and easily create drag-and-drop forms |
| 5 | - * Version: 6.25 | |
| 5 | + * Version: 6.35 | |
| 6 | 6 | * Plugin URI: https://formidableforms.com/ |
| 7 | 7 | * Author URI: https://formidableforms.com/ |
| 8 | 8 | * Author: Strategy11 Form Builder Team |
| 9 | 9 | * Text Domain: formidable |
| @@ -42,8 +42,9 @@ | ||
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | // For reverse compatibility. Load Pro if it's still nested. |
| 45 | 45 | $frm_path = __DIR__; |
| 46 | + | |
| 46 | 47 | if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { |
| 47 | 48 | include $frm_path . '/pro/formidable-pro.php'; |
| 48 | 49 | } |
| 49 | 50 | |
| @@ -58,8 +59,10 @@ | ||
| 58 | 59 | // Add the autoloader. |
| 59 | 60 | spl_autoload_register( 'frm_forms_autoloader' ); |
| 60 | 61 | |
| 61 | 62 | /** |
| 63 | + * @param string $class_name Class name. | |
| 64 | + * | |
| 62 | 65 | * @return void |
| 63 | 66 | */ |
| 64 | 67 | function frm_forms_autoloader( $class_name ) { |
| 65 | 68 | // Only load Frm classes here. |
| @@ -74,32 +77,30 @@ | ||
| 74 | 77 | * Autoload the Formidable and Pro classes |
| 75 | 78 | * |
| 76 | 79 | * @since 3.0 |
| 77 | 80 | * |
| 81 | + * @param string $class_name Class name. | |
| 82 | + * @param string $filepath File path. | |
| 83 | + * | |
| 78 | 84 | * @return void |
| 79 | 85 | */ |
| 80 | 86 | function frm_class_autoloader( $class_name, $filepath ) { |
| 81 | - $deprecated = array( 'FrmEDD_SL_Plugin_Updater' ); | |
| 82 | - $is_deprecated = in_array( $class_name, $deprecated, true ) || preg_match( '/^.+Deprecate/', $class_name ); | |
| 83 | 87 | $original_filepath = $filepath; |
| 88 | + $filepath .= '/classes/'; | |
| 84 | 89 | |
| 85 | - if ( $is_deprecated ) { | |
| 86 | - $filepath .= '/deprecated/'; | |
| 90 | + if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 91 | + $filepath .= 'helpers/'; | |
| 92 | + } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 93 | + $filepath .= 'controllers/'; | |
| 94 | + } elseif ( preg_match( '/^.+Factory$/', $class_name ) ) { | |
| 95 | + $filepath .= 'factories/'; | |
| 96 | + } elseif ( preg_match( '/^.+StyleComponent$/', $class_name ) ) { | |
| 97 | + $filepath .= 'views/styles/components/'; | |
| 87 | 98 | } else { |
| 88 | - $filepath .= '/classes/'; | |
| 89 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 90 | - $filepath .= 'helpers/'; | |
| 91 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 92 | - $filepath .= 'controllers/'; | |
| 93 | - } elseif ( preg_match( '/^.+Factory$/', $class_name ) ) { | |
| 94 | - $filepath .= 'factories/'; | |
| 95 | - } elseif ( preg_match( '/^.+StyleComponent$/', $class_name ) ) { | |
| 96 | - $filepath .= 'views/styles/components/'; | |
| 97 | - } else { | |
| 98 | - $filepath .= 'models/'; | |
| 99 | - if ( strpos( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) { | |
| 100 | - $filepath .= 'fields/'; | |
| 101 | - } | |
| 99 | + $filepath .= 'models/'; | |
| 100 | + | |
| 101 | + if ( str_contains( $class_name, 'Field' ) && ! file_exists( $filepath . $class_name . '.php' ) ) { | |
| 102 | + $filepath .= 'fields/'; | |
| 102 | 103 | } |
| 103 | 104 | } |
| 104 | 105 | |
| 105 | 106 | if ( file_exists( $filepath . $class_name . '.php' ) ) { |
| @@ -106,43 +107,33 @@ | ||
| 106 | 107 | require $filepath . $class_name . '.php'; |
| 107 | 108 | return; |
| 108 | 109 | } |
| 109 | 110 | |
| 111 | + $filepath = $original_filepath; | |
| 112 | + | |
| 110 | 113 | if ( preg_match( '/^FrmStrpLite.+$/', $class_name ) || preg_match( '/^FrmTransLite.+$/', $class_name ) ) { |
| 111 | 114 | // Autoload for /stripe/ folder. |
| 112 | - $filepath = $original_filepath . '/stripe/'; | |
| 113 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 114 | - $filepath .= 'helpers/'; | |
| 115 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 116 | - $filepath .= 'controllers/'; | |
| 117 | - } else { | |
| 118 | - $filepath .= 'models/'; | |
| 119 | - } | |
| 120 | - | |
| 121 | - $filepath .= $class_name . '.php'; | |
| 122 | - | |
| 123 | - if ( file_exists( $filepath ) ) { | |
| 124 | - require $filepath; | |
| 125 | - } | |
| 126 | - | |
| 115 | + $filepath .= '/stripe/'; | |
| 116 | + } elseif ( preg_match( '/^FrmSquareLite.+$/', $class_name ) ) { | |
| 117 | + $filepath .= '/square/'; | |
| 118 | + } elseif ( preg_match( '/^FrmPayPalLite.+$/', $class_name ) ) { | |
| 119 | + $filepath .= '/paypal/'; | |
| 120 | + } else { | |
| 127 | 121 | return; |
| 128 | 122 | } |
| 129 | 123 | |
| 130 | - if ( preg_match( '/^FrmSquareLite.+$/', $class_name ) ) { | |
| 131 | - $filepath = $original_filepath . '/square/'; | |
| 132 | - if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 133 | - $filepath .= 'helpers/'; | |
| 134 | - } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 135 | - $filepath .= 'controllers/'; | |
| 136 | - } else { | |
| 137 | - $filepath .= 'models/'; | |
| 138 | - } | |
| 124 | + if ( preg_match( '/^.+Helper$/', $class_name ) ) { | |
| 125 | + $filepath .= 'helpers/'; | |
| 126 | + } elseif ( preg_match( '/^.+Controller$/', $class_name ) ) { | |
| 127 | + $filepath .= 'controllers/'; | |
| 128 | + } else { | |
| 129 | + $filepath .= 'models/'; | |
| 130 | + } | |
| 139 | 131 | |
| 140 | - $filepath .= $class_name . '.php'; | |
| 132 | + $filepath .= $class_name . '.php'; | |
| 141 | 133 | |
| 142 | - if ( file_exists( $filepath ) ) { | |
| 143 | - require $filepath; | |
| 144 | - } | |
| 134 | + if ( file_exists( $filepath ) ) { | |
| 135 | + require $filepath; | |
| 145 | 136 | } |
| 146 | 137 | } |
| 147 | 138 | |
| 148 | 139 | add_action( 'activate_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'frm_maybe_install' ); |