| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || die(); |
| 3 |
|
| 4 |
/** |
| 5 |
* Class Funnel_Redirect. |
| 6 |
* Handle funnel step base url. |
| 7 |
* |
| 8 |
* @since 1.8.1 |
| 9 |
*/ |
| 10 |
class Funnel_Redirect { |
| 11 |
/** |
| 12 |
* The funnel step url. |
| 13 |
* |
| 14 |
* @since 1.8.1 |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
public static $step_base = 'sellkit_step'; |
| 18 |
|
| 19 |
/** |
| 20 |
* Funnel_Redirect constructor. |
| 21 |
* |
| 22 |
* @since 1.8.1 |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
self::$step_base = get_option( 'sellkit_funnel_permalink_base', 'sellkit_step' ); |
| 26 |
|
| 27 |
if ( 'sellkit_step' === self::$step_base ) { |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
add_filter( 'register_post_type_args', [ $this, 'replace_sellkit_step_slug' ], 10, 2 ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Change sellkit_step slug in url. |
| 36 |
* |
| 37 |
* @param array $args Post type arguments. |
| 38 |
* @param string $post_type Post type slug. |
| 39 |
* @since 1.8.1 |
| 40 |
* @return array |
| 41 |
*/ |
| 42 |
public function replace_sellkit_step_slug( $args, $post_type ) { |
| 43 |
if ( 'sellkit_step' === $post_type ) { |
| 44 |
$args['rewrite']['slug'] = self::$step_base; |
| 45 |
} |
| 46 |
|
| 47 |
return $args; |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
new Funnel_Redirect(); |
| 52 |
|
| 53 |
|