| @@ -7,35 +7,35 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace SRFM; |
| 10 | 10 | |
| 11 | -use SRFM\Inc\Post_Types; | |
| 12 | -use SRFM\Inc\Form_Submit; | |
| 13 | -use SRFM\Inc\Gutenberg_Hooks; | |
| 11 | +use SRFM\Admin\Admin; | |
| 14 | 12 | use SRFM\API\Block_Patterns; |
| 15 | -use SRFM\Inc\Forms_Data; | |
| 16 | -use SRFM\Admin\Admin; | |
| 17 | -use SRFM\Inc\Blocks\Register; | |
| 18 | -use SRFM\Inc\Frontend_Assets; | |
| 19 | -use SRFM\Inc\Helper; | |
| 20 | 13 | use SRFM\Inc\Activator; |
| 21 | 14 | use SRFM\Inc\Admin_Ajax; |
| 15 | +use SRFM\Inc\AI_Form_Builder\AI_Auth; | |
| 16 | +use SRFM\Inc\AI_Form_Builder\AI_Form_Builder; | |
| 17 | +use SRFM\Inc\AI_Form_Builder\AI_Helper; | |
| 18 | +use SRFM\Inc\AI_Form_Builder\Field_Mapping; | |
| 19 | +use SRFM\Inc\Background_Process; | |
| 20 | +use SRFM\Inc\Blocks\Register; | |
| 21 | +use SRFM\Inc\Create_New_Form; | |
| 22 | +use SRFM\Inc\Database\Register as DatabaseRegister; | |
| 23 | +use SRFM\Inc\Events_Scheduler; | |
| 22 | 24 | use SRFM\Inc\Export; |
| 23 | -use SRFM\Inc\Smart_Tags; | |
| 25 | +use SRFM\Inc\Form_Submit; | |
| 26 | +use SRFM\Inc\Forms_Data; | |
| 27 | +use SRFM\Inc\Frontend_Assets; | |
| 24 | 28 | use SRFM\Inc\Generate_Form_Markup; |
| 25 | -use SRFM\Inc\Create_New_Form; | |
| 29 | +use SRFM\Inc\Global_Settings\Email_Summary; | |
| 26 | 30 | use SRFM\Inc\Global_Settings\Global_Settings; |
| 27 | -use SRFM\Inc\Global_Settings\Email_Summary; | |
| 28 | -use SRFM\Inc\Single_Form_Settings\Compliance_Settings; | |
| 29 | -use SRFM\Inc\Events_Scheduler; | |
| 30 | -use SRFM\Inc\AI_Form_Builder\AI_Form_Builder; | |
| 31 | -use SRFM\Inc\AI_Form_Builder\Field_Mapping; | |
| 32 | -use SRFM\Inc\Background_Process; | |
| 31 | +use SRFM\Inc\Gutenberg_Hooks; | |
| 32 | +use SRFM\Inc\Helper; | |
| 33 | 33 | use SRFM\Inc\Page_Builders\Page_Builders; |
| 34 | +use SRFM\Inc\Post_Types; | |
| 34 | 35 | use SRFM\Inc\Rest_Api; |
| 35 | -use SRFM\Inc\AI_Form_Builder\AI_Helper; | |
| 36 | -use SRFM\Inc\AI_Form_Builder\AI_Auth; | |
| 37 | -use SRFM\Inc\Database\Register as DatabaseRegister; | |
| 36 | +use SRFM\Inc\Single_Form_Settings\Compliance_Settings; | |
| 37 | +use SRFM\Inc\Smart_Tags; | |
| 38 | 38 | use SRFM\Inc\Updater; |
| 39 | 39 | |
| 40 | 40 | if ( ! defined( 'ABSPATH' ) ) { |
| 41 | 41 | exit; // Exit if accessed directly. |
| @@ -46,9 +46,8 @@ | ||
| 46 | 46 | * |
| 47 | 47 | * @since 0.0.1 |
| 48 | 48 | */ |
| 49 | 49 | class Plugin_Loader { |
| 50 | - | |
| 51 | 50 | /** |
| 52 | 51 | * Instance |
| 53 | 52 | * |
| 54 | 53 | * @access private |
| @@ -57,61 +56,8 @@ | ||
| 57 | 56 | */ |
| 58 | 57 | private static $instance = null; |
| 59 | 58 | |
| 60 | 59 | /** |
| 61 | - * Initiator | |
| 62 | - * | |
| 63 | - * @since 0.0.1 | |
| 64 | - * @return object initialized object of class. | |
| 65 | - */ | |
| 66 | - public static function get_instance() { | |
| 67 | - if ( null === self::$instance ) { | |
| 68 | - self::$instance = new self(); | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * SureForms loaded. | |
| 72 | - * | |
| 73 | - * Fires when SureForms was fully loaded and instantiated. | |
| 74 | - * | |
| 75 | - * @since 0.0.1 | |
| 76 | - */ | |
| 77 | - do_action( 'srfm_core_loaded' ); | |
| 78 | - } | |
| 79 | - return self::$instance; | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Autoload classes. | |
| 84 | - * | |
| 85 | - * @param string $class class name. | |
| 86 | - * @return void | |
| 87 | - */ | |
| 88 | - public function autoload( $class ) { | |
| 89 | - if ( 0 !== strpos( $class, __NAMESPACE__ ) ) { | |
| 90 | - return; | |
| 91 | - } | |
| 92 | - | |
| 93 | - $filename = preg_replace( | |
| 94 | - [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ], | |
| 95 | - [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ], | |
| 96 | - $class | |
| 97 | - ); | |
| 98 | - | |
| 99 | - if ( is_string( $filename ) ) { | |
| 100 | - | |
| 101 | - $filename = strtolower( $filename ); | |
| 102 | - | |
| 103 | - $file = SRFM_DIR . $filename . '.php'; | |
| 104 | - | |
| 105 | - // if the file is readable, include it. | |
| 106 | - if ( is_readable( $file ) ) { | |
| 107 | - require_once $file; | |
| 108 | - } | |
| 109 | - } | |
| 110 | - | |
| 111 | - } | |
| 112 | - | |
| 113 | - /** | |
| 114 | 60 | * Constructor |
| 115 | 61 | * |
| 116 | 62 | * @since 0.0.1 |
| 117 | 63 | */ |
| @@ -158,9 +104,9 @@ | ||
| 158 | 104 | * The code that runs during plugin activation |
| 159 | 105 | */ |
| 160 | 106 | register_activation_hook( |
| 161 | 107 | SRFM_FILE, |
| 162 | - function () { | |
| 108 | + static function () { | |
| 163 | 109 | Activator::activate(); |
| 164 | 110 | } |
| 165 | 111 | ); |
| 166 | 112 | |
| @@ -165,9 +111,9 @@ | ||
| 165 | 111 | ); |
| 166 | 112 | |
| 167 | 113 | register_deactivation_hook( |
| 168 | 114 | SRFM_FILE, |
| 169 | - function () { | |
| 115 | + static function () { | |
| 170 | 116 | update_option( '__sureforms_do_redirect', false ); |
| 171 | 117 | Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' ); |
| 172 | 118 | Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' ); |
| 173 | 119 | } |
| @@ -174,8 +120,60 @@ | ||
| 174 | 120 | ); |
| 175 | 121 | } |
| 176 | 122 | |
| 177 | 123 | /** |
| 124 | + * Initiator | |
| 125 | + * | |
| 126 | + * @since 0.0.1 | |
| 127 | + * @return object initialized object of class. | |
| 128 | + */ | |
| 129 | + public static function get_instance() { | |
| 130 | + if ( null === self::$instance ) { | |
| 131 | + self::$instance = new self(); | |
| 132 | + | |
| 133 | + /** | |
| 134 | + * SureForms loaded. | |
| 135 | + * | |
| 136 | + * Fires when SureForms was fully loaded and instantiated. | |
| 137 | + * | |
| 138 | + * @since 0.0.1 | |
| 139 | + */ | |
| 140 | + do_action( 'srfm_core_loaded' ); | |
| 141 | + } | |
| 142 | + return self::$instance; | |
| 143 | + } | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * Autoload classes. | |
| 147 | + * | |
| 148 | + * @param string $class class name. | |
| 149 | + * @return void | |
| 150 | + */ | |
| 151 | + public function autoload( $class ) { | |
| 152 | + if ( 0 !== strpos( $class, __NAMESPACE__ ) ) { | |
| 153 | + return; | |
| 154 | + } | |
| 155 | + | |
| 156 | + $filename = preg_replace( | |
| 157 | + [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ], | |
| 158 | + [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ], | |
| 159 | + $class | |
| 160 | + ); | |
| 161 | + | |
| 162 | + if ( is_string( $filename ) ) { | |
| 163 | + | |
| 164 | + $filename = strtolower( $filename ); | |
| 165 | + | |
| 166 | + $file = SRFM_DIR . $filename . '.php'; | |
| 167 | + | |
| 168 | + // if the file is readable, include it. | |
| 169 | + if ( is_readable( $file ) ) { | |
| 170 | + require_once $file; | |
| 171 | + } | |
| 172 | + } | |
| 173 | + } | |
| 174 | + | |
| 175 | + /** | |
| 178 | 176 | * Activation Reset |
| 179 | 177 | * |
| 180 | 178 | * @return void |
| 181 | 179 | * @since 0.0.1 |
| @@ -197,9 +195,9 @@ | ||
| 197 | 195 | ], |
| 198 | 196 | admin_url( 'admin.php' ) |
| 199 | 197 | ) |
| 200 | 198 | ); |
| 201 | - exit(); | |
| 199 | + exit; | |
| 202 | 200 | } |
| 203 | 201 | } |
| 204 | 202 | } |
| 205 | 203 | |
| @@ -246,9 +244,8 @@ | ||
| 246 | 244 | |
| 247 | 245 | /** |
| 248 | 246 | * Language Locale for plugin |
| 249 | 247 | * |
| 250 | - * @var string $get_locale The locale to use. | |
| 251 | 248 | * Uses get_user_locale()` in WordPress 4.7 or greater, |
| 252 | 249 | * otherwise uses `get_locale()`. |
| 253 | 250 | */ |
| 254 | 251 | $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook |
| @@ -269,9 +266,8 @@ | ||
| 269 | 266 | load_plugin_textdomain( 'sureforms', false, $lang_dir ); |
| 270 | 267 | } |
| 271 | 268 | } |
| 272 | 269 | |
| 273 | - | |
| 274 | 270 | /** |
| 275 | 271 | * Loads plugin files. |
| 276 | 272 | * |
| 277 | 273 | * @since 0.0.1 |
| @@ -292,10 +288,8 @@ | ||
| 292 | 288 | public function load_core_files() { |
| 293 | 289 | include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php'; |
| 294 | 290 | } |
| 295 | 291 | } |
| 296 | - | |
| 297 | - | |
| 298 | 292 | |
| 299 | 293 | /** |
| 300 | 294 | * Kicking this off by calling 'get_instance()' method |
| 301 | 295 | */ |