| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Components\Compatibility; |
| 5 |
|
| 6 |
use Jet_Form_Builder\Exceptions\Repository_Exception; |
| 7 |
use JFB_Components\Module\Base_Module_Dir_It; |
| 8 |
use JFB_Components\Module\Base_Module_Url_It; |
| 9 |
|
| 10 |
// If this file is called directly, abort. |
| 11 |
if ( ! defined( 'WPINC' ) ) { |
| 12 |
die; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* @since 3.1.0 |
| 17 |
* |
| 18 |
* Class Compatibility_Tools |
| 19 |
* @package JFB_Components\Compatibility |
| 20 |
*/ |
| 21 |
class Compatibility_Tools { |
| 22 |
|
| 23 |
public static function get_url( string $module_name, string $url ): string { |
| 24 |
try { |
| 25 |
$module = jet_form_builder()->compat( $module_name ); |
| 26 |
} catch ( Repository_Exception $exception ) { |
| 27 |
return ''; |
| 28 |
} |
| 29 |
|
| 30 |
if ( ! ( $module instanceof Base_Module_Url_It ) ) { |
| 31 |
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 32 |
_doing_it_wrong( |
| 33 |
__METHOD__, |
| 34 |
get_class( $module ) . ' is not implemented ' . Base_Module_Url_It::class, |
| 35 |
'3.1.0' |
| 36 |
); |
| 37 |
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 38 |
return ''; |
| 39 |
} |
| 40 |
|
| 41 |
return $module->get_url( $url ); |
| 42 |
} |
| 43 |
|
| 44 |
public static function get_dir( string $module_name, string $path ): string { |
| 45 |
try { |
| 46 |
$module = jet_form_builder()->compat( $module_name ); |
| 47 |
} catch ( Repository_Exception $exception ) { |
| 48 |
return ''; |
| 49 |
} |
| 50 |
|
| 51 |
if ( ! ( $module instanceof Base_Module_Dir_It ) ) { |
| 52 |
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 53 |
_doing_it_wrong( |
| 54 |
__METHOD__, |
| 55 |
get_class( $module ) . ' is not implemented ' . Base_Module_Dir_It::class, |
| 56 |
'3.1.0' |
| 57 |
); |
| 58 |
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 59 |
|
| 60 |
return ''; |
| 61 |
} |
| 62 |
|
| 63 |
return $module->get_dir( $path ); |
| 64 |
} |
| 65 |
|
| 66 |
} |
| 67 |
|