| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || die(); |
| 4 |
/** |
| 5 |
* Tag Base. |
| 6 |
* |
| 7 |
* @since 1.1.0 |
| 8 |
*/ |
| 9 |
abstract class Tag_Base { |
| 10 |
|
| 11 |
/** |
| 12 |
* Order data. |
| 13 |
* |
| 14 |
* @var object |
| 15 |
* @since 1.1.0 |
| 16 |
*/ |
| 17 |
public static $order = null; |
| 18 |
|
| 19 |
/** |
| 20 |
* Get order data. |
| 21 |
* |
| 22 |
* @since 1.1.0 |
| 23 |
*/ |
| 24 |
public function get_keyword_content() { |
| 25 |
return $this->render_content(); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Get shortcode default data. |
| 30 |
* |
| 31 |
* @since 1.1.0 |
| 32 |
* @param array $atts shortcode attributes. |
| 33 |
*/ |
| 34 |
public function shortcode_content( $atts ) { |
| 35 |
$atts = shortcode_atts( [ |
| 36 |
'fallback' => '', |
| 37 |
], $atts ); |
| 38 |
|
| 39 |
return $atts['fallback']; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Get shortcode default data. |
| 44 |
* |
| 45 |
* @since 1.1.0 |
| 46 |
*/ |
| 47 |
public function get_data() { |
| 48 |
if ( ! empty( $this::$order ) ) { |
| 49 |
return $this::$order; |
| 50 |
} |
| 51 |
|
| 52 |
$order_key = ! empty( sellkit_htmlspecialchars( INPUT_GET, 'order-key' ) ) ? sellkit_htmlspecialchars( INPUT_GET, 'order-key' ) : sellkit_htmlspecialchars( INPUT_GET, 'key' ); |
| 53 |
|
| 54 |
if ( empty( $order_key ) ) { |
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
$order_id = wc_get_order_id_by_order_key( $order_key ); |
| 59 |
|
| 60 |
$this::$order = wc_get_order( $order_id ); |
| 61 |
|
| 62 |
return $this::$order; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Get Keywords type. |
| 67 |
* |
| 68 |
* @since 1.1.0 |
| 69 |
*/ |
| 70 |
public static function get_keywords_type() { |
| 71 |
return 'order_keyword'; |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Get keyword id. |
| 76 |
* |
| 77 |
* @since 1.1.0 |
| 78 |
* @access public |
| 79 |
* @abstract |
| 80 |
* |
| 81 |
* @return string |
| 82 |
*/ |
| 83 |
abstract public function get_id(); |
| 84 |
|
| 85 |
/** |
| 86 |
* Get keyword title. |
| 87 |
* |
| 88 |
* @since 1.1.0 |
| 89 |
* @access public |
| 90 |
* @abstract |
| 91 |
* |
| 92 |
* @return string |
| 93 |
*/ |
| 94 |
abstract public function get_title(); |
| 95 |
|
| 96 |
/** |
| 97 |
* Render content. |
| 98 |
* |
| 99 |
* @since 1.1.0 |
| 100 |
* @access public |
| 101 |
* @param array $atts array of shortcode arguments. |
| 102 |
* @abstract |
| 103 |
* |
| 104 |
* @return string |
| 105 |
*/ |
| 106 |
abstract public function render_content( $atts ); |
| 107 |
} |
| 108 |
|