admin
1 year ago
emails
1 year ago
fields
1 year ago
functions
1 year ago
providers
1 year ago
templates
1 year ago
class-db.php
1 year ago
class-fields.php
1 year ago
class-form.php
1 year ago
class-install.php
1 year ago
class-process.php
1 year ago
class-providers.php
1 year ago
class-templates.php
1 year ago
class-widget.php
1 year ago
compat.php
1 year ago
deprecated.php
1 year ago
functions-list.php
1 year ago
functions.php
1 year ago
integrations.php
1 year ago
deprecated.php
407 lines
| 1 | <?php |
| 2 | |
| 3 | // phpcs:ignoreFile Generic.Files.OneObjectStructurePerFile.MultipleFound |
| 4 | |
| 5 | namespace WPForms { |
| 6 | /** |
| 7 | * The removed class helps prevent fatal errors for clients |
| 8 | * that use some of the classes we are about to remove. |
| 9 | * Use the class extending instead of class_alias function. |
| 10 | * |
| 11 | * @since 1.8.0 |
| 12 | */ |
| 13 | class Removed { |
| 14 | |
| 15 | /** |
| 16 | * List of removed classes in the next format: |
| 17 | * Fully-Qualified Class Name => version. |
| 18 | * |
| 19 | * @since 1.8.0 |
| 20 | */ |
| 21 | const CLASSES = [ |
| 22 | 'WPForms\Pro\Admin\Entries\DefaultScreen' => '1.8.2' |
| 23 | ]; |
| 24 | |
| 25 | /** |
| 26 | * Inform clients that the class is removed. |
| 27 | * |
| 28 | * @since 1.8.0 |
| 29 | */ |
| 30 | public function __construct() { |
| 31 | |
| 32 | self::trigger_error(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Inform clients that the class is removed. |
| 37 | * |
| 38 | * @since 1.8.0 |
| 39 | * |
| 40 | * @param string $name Property name. |
| 41 | */ |
| 42 | public function __get( $name ) { |
| 43 | |
| 44 | self::trigger_error( $name ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Inform clients that the class is removed. |
| 49 | * |
| 50 | * @since 1.8.0 |
| 51 | * |
| 52 | * @param string $name Property name. |
| 53 | * @param mixed $value Property value. |
| 54 | */ |
| 55 | public function __set( $name, $value ) { |
| 56 | |
| 57 | self::trigger_error( $name ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Inform clients that the class is removed. |
| 62 | * |
| 63 | * @since 1.8.0 |
| 64 | * |
| 65 | * @param string $name Property name. |
| 66 | */ |
| 67 | public function __isset( $name ) { |
| 68 | |
| 69 | self::trigger_error( $name ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * Inform clients that the class is removed. |
| 75 | * |
| 76 | * @since 1.8.0 |
| 77 | * |
| 78 | * @param string $name Method name. |
| 79 | * @param array $arguments List of arguments. |
| 80 | */ |
| 81 | public function __call( $name, $arguments ) { |
| 82 | |
| 83 | self::trigger_error( $name ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Inform clients that the class is removed. |
| 88 | * |
| 89 | * @since 1.8.0 |
| 90 | * |
| 91 | * @param string $name Method name. |
| 92 | * @param array $arguments List of arguments. |
| 93 | */ |
| 94 | public static function __callStatic( $name, $arguments ) { |
| 95 | |
| 96 | self::trigger_error( $name ); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Inform clients that the class is removed. |
| 101 | * |
| 102 | * @since 1.8.0 |
| 103 | * |
| 104 | * @param string $element_name Property or method name. |
| 105 | */ |
| 106 | private static function trigger_error( $element_name = '' ) { |
| 107 | |
| 108 | $current_class = static::class; |
| 109 | $removed_element = $current_class; |
| 110 | |
| 111 | if ( $element_name ) { |
| 112 | $removed_element .= '::' . $element_name; |
| 113 | } |
| 114 | |
| 115 | $version = ! empty( self::CLASSES[ $current_class ] ) ? self::CLASSES[ $current_class ] : WPFORMS_VERSION; |
| 116 | |
| 117 | trigger_error( |
| 118 | sprintf( |
| 119 | '%1$s has been removed in %2$s of the WPForms plugin', |
| 120 | esc_html( $removed_element ), |
| 121 | esc_html( $version ) |
| 122 | ), |
| 123 | E_USER_WARNING |
| 124 | ); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | namespace WPForms\Forms { |
| 130 | |
| 131 | use WPForms\Removed; |
| 132 | |
| 133 | class Loader extends Removed {} |
| 134 | } |
| 135 | |
| 136 | namespace { |
| 137 | /** |
| 138 | * To be compatible with both WP 4.9 (that can run on PHP 5.2+) and WP 5.3+ (PHP 5.6+) |
| 139 | * we need to rewrite some core WP classes and tweak our own skins to not use PHP 5.6 splat operator (...$args) |
| 140 | * that were introduced in WP 5.3 in \WP_Upgrader_Skin::feedback(). |
| 141 | * This alias is a safeguard to those developers who decided to use our internal class WPForms_Install_Silent_Skin, |
| 142 | * which we deleted. |
| 143 | * |
| 144 | * @since 1.5.6.1 |
| 145 | */ |
| 146 | class_alias( 'WPForms\Helpers\PluginSilentUpgraderSkin', 'WPForms_Install_Silent_Skin' ); |
| 147 | |
| 148 | /** |
| 149 | * Legacy `WPForms_Addons` class was refactored and moved to the new `WPForms\Pro\Admin\Pages\Addons` class. |
| 150 | * This alias is a safeguard to those developers who use our internal class WPForms_Addons, |
| 151 | * which we deleted. |
| 152 | * |
| 153 | * @since 1.6.7 |
| 154 | */ |
| 155 | class_alias( wpforms()->is_pro() ? 'WPForms\Pro\Admin\Pages\Addons' : 'WPForms\Lite\Admin\Pages\Addons', 'WPForms_Addons' ); |
| 156 | |
| 157 | /** |
| 158 | * This alias is a safeguard to those developers who decided to use our internal class WPForms_Smart_Tags, |
| 159 | * which we deleted. |
| 160 | * |
| 161 | * @since 1.6.7 |
| 162 | */ |
| 163 | class_alias( wpforms()->is_pro() ? 'WPForms\Pro\SmartTags\SmartTags' : 'WPForms\SmartTags\SmartTags', 'WPForms_Smart_Tags' ); |
| 164 | |
| 165 | /** |
| 166 | * This alias is a safeguard to those developers who decided to use our internal class \WPForms\Providers\Loader, |
| 167 | * which we deleted. |
| 168 | * |
| 169 | * @since 1.7.3 |
| 170 | */ |
| 171 | class_alias( '\WPForms\Providers\Providers', '\WPForms\Providers\Loader' ); |
| 172 | |
| 173 | /** |
| 174 | * Legacy `\WPForms\Admin\Notifications` class was refactored and moved to the new `\WPForms\Admin\Notifications\Notifications` class. |
| 175 | * This alias is a safeguard to those developers who use our internal class \WPForms\Admin\Notifications, |
| 176 | * which we deleted. |
| 177 | * |
| 178 | * @since 1.7.5 |
| 179 | */ |
| 180 | class_alias( '\WPForms\Admin\Notifications\Notifications', '\WPForms\Admin\Notifications' ); |
| 181 | |
| 182 | /** |
| 183 | * Legacy `\WPForms_Field_Payment_Checkbox` class was refactored and moved to the new `\WPForms\Forms\Fields\PaymentCheckbox\Field` class. |
| 184 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Payment_Checkbox, |
| 185 | * which we deleted. |
| 186 | * |
| 187 | * @since 1.8.2 |
| 188 | */ |
| 189 | class_alias( '\WPForms\Forms\Fields\PaymentCheckbox\Field', '\WPForms_Field_Payment_Checkbox' ); |
| 190 | |
| 191 | /** |
| 192 | * Legacy `\WPForms_Field_Payment_Multiple` class was refactored and moved to the new `\WPForms\Forms\Fields\PaymentMultiple\Field` class. |
| 193 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Payment_Multiple, |
| 194 | * which we deleted. |
| 195 | * |
| 196 | * @since 1.8.2 |
| 197 | */ |
| 198 | class_alias( '\WPForms\Forms\Fields\PaymentMultiple\Field', '\WPForms_Field_Payment_Multiple' ); |
| 199 | |
| 200 | /** |
| 201 | * Legacy `\WPForms_Field_Payment_Single` class was refactored and moved to the new `\WPForms\Forms\Fields\PaymentSingle\Field` class. |
| 202 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Payment_Single, |
| 203 | * which we deleted. |
| 204 | * |
| 205 | * @since 1.8.2 |
| 206 | */ |
| 207 | class_alias( '\WPForms\Forms\Fields\PaymentSingle\Field', '\WPForms_Field_Payment_Single' ); |
| 208 | |
| 209 | /** |
| 210 | * Legacy `\WPForms_Field_Payment_Total` class was refactored and moved to the new `\WPForms\Forms\Fields\PaymentTotal\Field` class. |
| 211 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Payment_Total, |
| 212 | * which we deleted. |
| 213 | * |
| 214 | * @since 1.8.2 |
| 215 | */ |
| 216 | class_alias( '\WPForms\Forms\Fields\PaymentTotal\Field', '\WPForms_Field_Payment_Total' ); |
| 217 | |
| 218 | /** |
| 219 | * Legacy `\WPForms_Field_Payment_Select` class was refactored and moved to the new `\WPForms\Forms\Fields\PaymentSelect\Field` class. |
| 220 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Payment_Select, |
| 221 | * which we deleted. |
| 222 | * |
| 223 | * @since 1.8.2 |
| 224 | */ |
| 225 | class_alias( '\WPForms\Forms\Fields\PaymentSelect\Field', '\WPForms_Field_Payment_Select' ); |
| 226 | |
| 227 | /** |
| 228 | * Legacy `\WPForms\Migrations` class was refactored and moved to the new `\WPForms\Migrations\Migrations` class. |
| 229 | * This alias is a safeguard to those developers who use our internal class \WPForms\Migrations, which we deleted. |
| 230 | * |
| 231 | * @since 1.7.5 |
| 232 | */ |
| 233 | class_alias( '\WPForms\Migrations\Migrations', '\WPForms\Migrations' ); |
| 234 | |
| 235 | if ( wpforms()->is_pro() ) { |
| 236 | /** |
| 237 | * Legacy `\WPForms\Pro\Migrations` class was refactored and moved to the new `\WPForms\Pro\Migrations\Migrations` class. |
| 238 | * This alias is a safeguard to those developers who use our internal class \WPForms\Migrations, which we deleted. |
| 239 | * |
| 240 | * @since 1.7.5 |
| 241 | */ |
| 242 | class_alias( '\WPForms\Pro\Migrations\Migrations', '\WPForms\Pro\Migrations' ); |
| 243 | |
| 244 | /** |
| 245 | * Legacy `\WPForms\Pro\Integrations\TranslationsPress\Translations` class was refactored and moved to the new |
| 246 | * `\WPForms\Pro\Integrations\Translations\Translations` class. |
| 247 | * This alias is a safeguard to those developers who use our internal class \WPForms\Pro\Integrations\TranslationsPress, which we deleted. |
| 248 | * |
| 249 | * @since 1.8.2.2 |
| 250 | */ |
| 251 | class_alias( '\WPForms\Pro\Integrations\Translations\Translations', '\WPForms\Pro\Integrations\TranslationsPress\Translations' ); |
| 252 | |
| 253 | /** |
| 254 | * This alias is a safeguard to those developers who use our internal class \WPForms_Entries_List, which we deleted. |
| 255 | * |
| 256 | * @since 1.8.6 |
| 257 | */ |
| 258 | class_alias( '\WPForms\Pro\Admin\Entries\Page', '\WPForms_Entries_List' ); |
| 259 | |
| 260 | /** |
| 261 | * This alias is a safeguard to those developers who use our internal class \WPForms_Entries_Table, which we deleted. |
| 262 | * |
| 263 | * @since 1.8.6 |
| 264 | */ |
| 265 | class_alias( '\WPForms\Pro\Admin\Entries\ListTable', '\WPForms_Entries_Table' ); |
| 266 | |
| 267 | /** |
| 268 | * This alias is a safeguard to those developers who use our internal class \WPForms_Field_Layout, which we deleted. |
| 269 | * |
| 270 | * @since 1.8.9 |
| 271 | */ |
| 272 | class_alias( '\WPForms\Pro\Forms\Fields\Layout\Field', '\WPForms_Field_Layout' ); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * Legacy `\WPForms_Frontend` class was refactored and moved to the new `\WPForms\Frontend\Frontend` class. |
| 277 | * This alias is a safeguard to those developers who use our internal class \WPForms_Frontend, which we deleted. |
| 278 | * |
| 279 | * @since 1.8.1 |
| 280 | */ |
| 281 | class_alias( '\WPForms\Frontend\Frontend', '\WPForms_Frontend' ); |
| 282 | |
| 283 | /** |
| 284 | * This alias is a safeguard to those developers who use our internal class \WPForms_Overview, which we deleted. |
| 285 | * |
| 286 | * @since 1.8.6 |
| 287 | */ |
| 288 | class_alias( '\WPForms\Admin\Forms\Page', '\WPForms_Overview' ); |
| 289 | |
| 290 | /** |
| 291 | * This alias is a safeguard to those developers who use our internal class \WPForms_Overview_Table, which we deleted. |
| 292 | * |
| 293 | * @since 1.8.6 |
| 294 | */ |
| 295 | class_alias( '\WPForms\Admin\Forms\ListTable', '\WPForms_Overview_Table' ); |
| 296 | |
| 297 | /** |
| 298 | * This adds backwards compatibility after scoping the stripe lib and using our own prefix `\WPForms\Vendor\Stripe`. |
| 299 | * This alias is a safeguard for the users who update core plugin to 1.8.5 but have older version of stripe pro addon. |
| 300 | * Fire this right before autoloading of legacy classes so that there is no conflict with other stripe libs when aliasing. |
| 301 | * |
| 302 | * @since 1.8.5 |
| 303 | */ |
| 304 | spl_autoload_register( |
| 305 | static function ( $class_name ) { |
| 306 | static $stripe_check_done = false; |
| 307 | |
| 308 | static $aliases = [ |
| 309 | '\WPForms\Vendor\Stripe\Charge' => 'Stripe\Charge', |
| 310 | '\WPForms\Vendor\Stripe\Customer' => 'Stripe\Customer', |
| 311 | '\WPForms\Vendor\Stripe\Subscription' => 'Stripe\Subscription', |
| 312 | '\WPForms\Vendor\Stripe\Invoice' => 'Stripe\Invoice', |
| 313 | '\WPForms\Vendor\Stripe\Exception\CardException' => 'Stripe\Exception\CardException', |
| 314 | '\WPForms\Vendor\Stripe\Source' => 'Stripe\Source', |
| 315 | ]; |
| 316 | |
| 317 | if ( $stripe_check_done ) { |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | // If class not for aliasing, bail. |
| 322 | if ( ! in_array( $class_name, $aliases, true ) ) { |
| 323 | return; |
| 324 | } |
| 325 | |
| 326 | $stripe_check_done = true; |
| 327 | |
| 328 | // If no Stripe Pro addon bail. |
| 329 | if ( ! defined( 'WPFORMS_STRIPE_VERSION' ) ) { |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | // Version 3.2.0 has prefixed lib. |
| 334 | // Versions 2.11.0 and below already have the lib bundled, so they don't require alias. |
| 335 | if ( |
| 336 | version_compare( WPFORMS_STRIPE_VERSION, '3.2.0', '>=' ) || |
| 337 | version_compare( WPFORMS_STRIPE_VERSION, '2.11.0', '<=' ) |
| 338 | ) { |
| 339 | return; |
| 340 | } |
| 341 | |
| 342 | // We only need to alias if we are using the legacy API version. |
| 343 | if ( ! \WPFormsStripe\Helpers::is_legacy_api_version() ) { |
| 344 | return; |
| 345 | } |
| 346 | |
| 347 | // If a lib is already loaded by a third party plugin, |
| 348 | // checking the CardException class here as a niche to make sure it is the correct library. |
| 349 | if ( class_exists( '\Stripe\Exception\CardException', false ) ) { |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | foreach ( $aliases as $prefixed => $alias ) { |
| 354 | class_alias( $prefixed, '\\' . $alias ); |
| 355 | } |
| 356 | } |
| 357 | ); |
| 358 | |
| 359 | /** |
| 360 | * Get notification state, whether it's opened or closed. |
| 361 | * |
| 362 | * @since 1.4.1 |
| 363 | * @deprecated 1.4.8 |
| 364 | * |
| 365 | * @param int $notification_id Notification ID. |
| 366 | * |
| 367 | * @param int $form_id Form ID. |
| 368 | * |
| 369 | * @return string |
| 370 | */ |
| 371 | function wpforms_builder_notification_get_state( $form_id, $notification_id ) { |
| 372 | |
| 373 | _deprecated_function( __FUNCTION__, '1.4.8 of the WPForms addon', 'wpforms_builder_settings_block_get_state()' ); |
| 374 | |
| 375 | return wpforms_builder_settings_block_get_state( $form_id, $notification_id, 'notification' ); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Convert bytes to megabytes (or in some cases KB). |
| 380 | * |
| 381 | * @since 1.0.0 |
| 382 | * @deprecated 1.6.2 |
| 383 | * |
| 384 | * @param int $bytes Bytes to convert to a readable format. |
| 385 | * |
| 386 | * @return string |
| 387 | */ |
| 388 | function wpforms_size_to_megabytes( $bytes ) { |
| 389 | |
| 390 | _deprecated_function( __FUNCTION__, '1.6.2 of the WPForms plugin', 'size_format()' ); |
| 391 | |
| 392 | return size_format( $bytes ); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | namespace WPForms\Pro\Admin\Entries { |
| 397 | |
| 398 | /** |
| 399 | * Default Entries screen showed a chart and the form entries stats. |
| 400 | * Replaced with "WPForms\Pro\Admin\Entries\Overview". |
| 401 | * |
| 402 | * @since 1.5.5 |
| 403 | * @deprecated 1.8.2 |
| 404 | */ |
| 405 | class DefaultScreen extends \WPForms\Removed {} |
| 406 | } |
| 407 |