| @@ -7,34 +7,36 @@ | ||
| 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; | |
| 36 | +use SRFM\Inc\Single_Form_Settings\Compliance_Settings; | |
| 37 | +use SRFM\Inc\Smart_Tags; | |
| 38 | +use SRFM\Inc\Updater; | |
| 37 | 39 | |
| 38 | 40 | if ( ! defined( 'ABSPATH' ) ) { |
| 39 | 41 | exit; // Exit if accessed directly. |
| 40 | 42 | } |
| @@ -44,9 +46,8 @@ | ||
| 44 | 46 | * |
| 45 | 47 | * @since 0.0.1 |
| 46 | 48 | */ |
| 47 | 49 | class Plugin_Loader { |
| 48 | - | |
| 49 | 50 | /** |
| 50 | 51 | * Instance |
| 51 | 52 | * |
| 52 | 53 | * @access private |
| @@ -55,61 +56,8 @@ | ||
| 55 | 56 | */ |
| 56 | 57 | private static $instance = null; |
| 57 | 58 | |
| 58 | 59 | /** |
| 59 | - * Initiator | |
| 60 | - * | |
| 61 | - * @since 0.0.1 | |
| 62 | - * @return object initialized object of class. | |
| 63 | - */ | |
| 64 | - public static function get_instance() { | |
| 65 | - if ( null === self::$instance ) { | |
| 66 | - self::$instance = new self(); | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * SureForms loaded. | |
| 70 | - * | |
| 71 | - * Fires when SureForms was fully loaded and instantiated. | |
| 72 | - * | |
| 73 | - * @since 0.0.1 | |
| 74 | - */ | |
| 75 | - do_action( 'srfm_core_loaded' ); | |
| 76 | - } | |
| 77 | - return self::$instance; | |
| 78 | - } | |
| 79 | - | |
| 80 | - /** | |
| 81 | - * Autoload classes. | |
| 82 | - * | |
| 83 | - * @param string $class class name. | |
| 84 | - * @return void | |
| 85 | - */ | |
| 86 | - public function autoload( $class ) { | |
| 87 | - if ( 0 !== strpos( $class, __NAMESPACE__ ) ) { | |
| 88 | - return; | |
| 89 | - } | |
| 90 | - | |
| 91 | - $filename = preg_replace( | |
| 92 | - [ '/^' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ], | |
| 93 | - [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ], | |
| 94 | - $class | |
| 95 | - ); | |
| 96 | - | |
| 97 | - if ( is_string( $filename ) ) { | |
| 98 | - | |
| 99 | - $filename = strtolower( $filename ); | |
| 100 | - | |
| 101 | - $file = SRFM_DIR . $filename . '.php'; | |
| 102 | - | |
| 103 | - // if the file is readable, include it. | |
| 104 | - if ( is_readable( $file ) ) { | |
| 105 | - require_once $file; | |
| 106 | - } | |
| 107 | - } | |
| 108 | - | |
| 109 | - } | |
| 110 | - | |
| 111 | - /** | |
| 112 | 60 | * Constructor |
| 113 | 61 | * |
| 114 | 62 | * @since 0.0.1 |
| 115 | 63 | */ |
| @@ -147,15 +95,18 @@ | ||
| 147 | 95 | Page_Builders::get_instance(); |
| 148 | 96 | Rest_Api::get_instance(); |
| 149 | 97 | AI_Helper::get_instance(); |
| 150 | 98 | AI_Auth::get_instance(); |
| 99 | + Updater::get_instance(); | |
| 151 | 100 | |
| 101 | + DatabaseRegister::init(); | |
| 102 | + | |
| 152 | 103 | /** |
| 153 | 104 | * The code that runs during plugin activation |
| 154 | 105 | */ |
| 155 | 106 | register_activation_hook( |
| 156 | 107 | SRFM_FILE, |
| 157 | - function () { | |
| 108 | + static function () { | |
| 158 | 109 | Activator::activate(); |
| 159 | 110 | } |
| 160 | 111 | ); |
| 161 | 112 | |
| @@ -160,9 +111,9 @@ | ||
| 160 | 111 | ); |
| 161 | 112 | |
| 162 | 113 | register_deactivation_hook( |
| 163 | 114 | SRFM_FILE, |
| 164 | - function () { | |
| 115 | + static function () { | |
| 165 | 116 | update_option( '__sureforms_do_redirect', false ); |
| 166 | 117 | Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' ); |
| 167 | 118 | Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' ); |
| 168 | 119 | } |
| @@ -169,8 +120,60 @@ | ||
| 169 | 120 | ); |
| 170 | 121 | } |
| 171 | 122 | |
| 172 | 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 | + /** | |
| 173 | 176 | * Activation Reset |
| 174 | 177 | * |
| 175 | 178 | * @return void |
| 176 | 179 | * @since 0.0.1 |
| @@ -192,9 +195,9 @@ | ||
| 192 | 195 | ], |
| 193 | 196 | admin_url( 'admin.php' ) |
| 194 | 197 | ) |
| 195 | 198 | ); |
| 196 | - exit(); | |
| 199 | + exit; | |
| 197 | 200 | } |
| 198 | 201 | } |
| 199 | 202 | } |
| 200 | 203 | |
| @@ -241,9 +244,8 @@ | ||
| 241 | 244 | |
| 242 | 245 | /** |
| 243 | 246 | * Language Locale for plugin |
| 244 | 247 | * |
| 245 | - * @var string $get_locale The locale to use. | |
| 246 | 248 | * Uses get_user_locale()` in WordPress 4.7 or greater, |
| 247 | 249 | * otherwise uses `get_locale()`. |
| 248 | 250 | */ |
| 249 | 251 | $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook |
| @@ -264,9 +266,8 @@ | ||
| 264 | 266 | load_plugin_textdomain( 'sureforms', false, $lang_dir ); |
| 265 | 267 | } |
| 266 | 268 | } |
| 267 | 269 | |
| 268 | - | |
| 269 | 270 | /** |
| 270 | 271 | * Loads plugin files. |
| 271 | 272 | * |
| 272 | 273 | * @since 0.0.1 |
| @@ -287,10 +288,8 @@ | ||
| 287 | 288 | public function load_core_files() { |
| 288 | 289 | include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php'; |
| 289 | 290 | } |
| 290 | 291 | } |
| 291 | - | |
| 292 | - | |
| 293 | 292 | |
| 294 | 293 | /** |
| 295 | 294 | * Kicking this off by calling 'get_instance()' method |
| 296 | 295 | */ |