| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* @since 2.04 |
| 8 |
*/ |
| 9 |
class FrmEntryFactory { |
| 10 |
|
| 11 |
/** |
| 12 |
* Create an instance of the FrmEntryFormatter class |
| 13 |
* |
| 14 |
* @since 2.04 |
| 15 |
* |
| 16 |
* @param array $atts |
| 17 |
* |
| 18 |
* @return FrmEntryFormatter|FrmProEntryFormatter |
| 19 |
*/ |
| 20 |
public static function entry_formatter_instance( $atts ) { |
| 21 |
$formatter_class = 'FrmEntryFormatter'; |
| 22 |
|
| 23 |
if ( FrmAppHelper::pro_is_installed() ) { |
| 24 |
$formatter_class = 'FrmProEntryFormatter'; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Allows changing entry formatter class name. |
| 29 |
* |
| 30 |
* @since 5.0.16 |
| 31 |
* |
| 32 |
* @param string $formatter_class Entry formatter class name. |
| 33 |
* @param array $atts See {@see FrmEntriesController::show_entry_shortcode()}. |
| 34 |
*/ |
| 35 |
$formatter_class = apply_filters( 'frm_entry_formatter_class', $formatter_class, $atts ); |
| 36 |
|
| 37 |
return new $formatter_class( $atts ); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Create an intsance of the FrmEntryShortcodeFormatter class |
| 42 |
* |
| 43 |
* @since 2.04 |
| 44 |
* |
| 45 |
* @param int|string $form_id |
| 46 |
* @param array $atts |
| 47 |
* |
| 48 |
* @return FrmEntryShortcodeFormatter|FrmProEntryShortcodeFormatter |
| 49 |
*/ |
| 50 |
public static function entry_shortcode_formatter_instance( $form_id, $atts ) { |
| 51 |
if ( FrmAppHelper::pro_is_installed() ) { |
| 52 |
$shortcode_formatter = new FrmProEntryShortcodeFormatter( $form_id, $atts ); |
| 53 |
} else { |
| 54 |
$shortcode_formatter = new FrmEntryShortcodeFormatter( $form_id, $atts ); |
| 55 |
} |
| 56 |
|
| 57 |
return $shortcode_formatter; |
| 58 |
} |
| 59 |
} |
| 60 |
|