user-journey-date-column.php
1 year ago
user-journey-duration-column.php
1 year ago
user-journey-query-column.php
1 year ago
user-journey-title-column.php
1 year ago
user-journey-url-column.php
1 year ago
user-journey-url-column.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace JFB_Modules\User_Journey\Admin\View_Columns; |
| 5 | |
| 6 | use Jet_Form_Builder\Admin\Table_Views\Column_Advanced_Base; |
| 7 | use JFB_Modules\User_Journey\Tools; |
| 8 | // If this file is called directly, abort. |
| 9 | if ( ! defined( 'WPINC' ) ) { |
| 10 | die; |
| 11 | } |
| 12 | |
| 13 | class User_Journey_Url_Column extends Column_Advanced_Base { |
| 14 | |
| 15 | protected $column = 'journey_url'; |
| 16 | protected $type = self::LINK; |
| 17 | |
| 18 | public function get_label(): string { |
| 19 | return __( 'URL', 'jet-form-builder' ); |
| 20 | } |
| 21 | |
| 22 | public function get_value( array $record = array() ) { |
| 23 | $journey_url = isset( $record['journey_url'] ) ? $record['journey_url'] : ''; |
| 24 | |
| 25 | $wp_page_data = Tools::get_wp_page_data_by_url( $journey_url ); |
| 26 | |
| 27 | if ( '/' === $journey_url ) { |
| 28 | $journey_url = $journey_url . ' (' . __( 'Home Page', 'jet-form-builder' ) . ')'; |
| 29 | } |
| 30 | |
| 31 | if ( $wp_page_data ) { |
| 32 | |
| 33 | return array( |
| 34 | 'text' => $journey_url, |
| 35 | 'href' => $wp_page_data['permalink'], |
| 36 | 'target' => '_blank', |
| 37 | 'type' => 'external', |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | return ''; |
| 42 | } |
| 43 | } |
| 44 |