Skip to content

Commit 1455fac

Browse files
committed
Removing unique slug URI functionality.
1 parent d0fda91 commit 1455fac

File tree

8 files changed

+1
-209
lines changed

8 files changed

+1
-209
lines changed

plugins/hwp-previews/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Post statuses are `publish`, `future`, `draft`, `pending`, `private`, `auto-draf
6464
Navigate in WP Admin to **Settings › HWP Previews**. For each public post type, configure:
6565

6666
* **Enable HWP Previews** – Master switch
67-
* **Unique Post Slugs** – Force unique slugs for all post statuses in the post status config.
6867
* **Allow All Statuses as Parent** – (Hierarchical types only)
6968
* **Preview URL Template** – Custom URL with tokens like `{ID}`, `{slug}`
7069
* **Load Previews in Iframe** – Toggle iframe-based preview rendering

plugins/hwp-previews/src/Admin/Settings/Contracts/Post_Types_Settings_Interface.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,11 @@ public function post_types_enabled( array $default_value = [] ): array;
2323
public function url_template( string $post_type, string $default_value = '' ): string;
2424

2525
/**
26-
* If the post type post statuses should have unique slug for the post type.
26+
* It the specified post statuses should be allowed to be used as parent post statuses.
2727
*
2828
* @param string $post_type Post type slug.
2929
* @param bool $default_value Default value.
3030
*/
31-
public function unique_post_slugs( string $post_type, bool $default_value = false ): bool;
32-
33-
/**
34-
* It the specified post statuses should be allowed to be used as parent post statuses.
35-
*
36-
* @param string $post_type Post type slug.
37-
* @param bool $default_value Default value.
38-
*/
3931
public function post_statuses_as_parent( string $post_type, bool $default_value = false ): bool;
4032

4133
/**

plugins/hwp-previews/src/Admin/Settings/Helper/Settings_Group.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ public function get_settings_key_enabled(): string {
6565
return 'enabled';
6666
}
6767

68-
/**
69-
* Setting key for unique post slugs.
70-
*/
71-
public function get_settings_key_unique_post_slugs(): string {
72-
return 'unique_post_slugs';
73-
}
74-
7568
/**
7669
* Setting key for post-statuses as parent.
7770
*/
@@ -101,7 +94,6 @@ public function get_settings_key_in_iframe(): string {
10194
public function get_settings_config(): array {
10295
return apply_filters( 'hwp_previews_settings_group_settings_config', [
10396
$this->get_settings_key_enabled() => 'bool',
104-
$this->get_settings_key_unique_post_slugs() => 'bool',
10597
$this->get_settings_key_post_statuses_as_parent() => 'bool',
10698
$this->get_settings_key_preview_url() => 'string',
10799
$this->get_settings_key_in_iframe() => 'bool',

plugins/hwp-previews/src/Admin/Settings/Helper/Settings_Helper.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ public function post_types_enabled( array $default_value = [] ): array {
7878
return $default_value;
7979
}
8080

81-
/**
82-
* Get Unique Post Slugs setting value for the given post type.
83-
*
84-
* @param string $post_type The post type to get the setting for.
85-
* @param bool $default_value The default value to return if the setting is not set.
86-
*/
87-
public function unique_post_slugs( string $post_type, bool $default_value = false ): bool {
88-
89-
$key = $this->settings_group->get_settings_key_unique_post_slugs();
90-
91-
return $this->settings_group->get_post_type_boolean_value( $key, $post_type, $default_value );
92-
}
93-
9481
/**
9582
* Get Post Statuses as Parent setting value for the given post type.
9683
*

plugins/hwp-previews/src/Admin/Settings_Page.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ public static function create_settings_fields( string $post_type, string $label,
180180
sprintf( __( 'Enable HWP Previews for %s', 'hwp-previews' ), $label ),
181181
__( 'Turn preview functionality on or off for this public post type.', 'hwp-previews' )
182182
);
183-
$fields[] = new Checkbox_Field(
184-
'unique_post_slugs',
185-
__( 'Enable unique post slugs for all post statuses', 'hwp-previews' ),
186-
__( 'By default WordPress adds unique post slugs to the published posts. This option enforces unique slugs for all post statuses.', 'hwp-previews' )
187-
);
188183

189184
if ( $is_hierarchical ) {
190185
$fields[] = new Checkbox_Field(

plugins/hwp-previews/src/Hooks/Preview_Hooks.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
namespace HWP\Previews\Hooks;
66

77
use HWP\Previews\Admin\Settings\Helper\Settings_Helper;
8-
use HWP\Previews\Post\Data\Post_Data_Model;
98
use HWP\Previews\Post\Parent\Post_Parent_Manager;
10-
use HWP\Previews\Post\Slug\Post_Slug_Manager;
11-
use HWP\Previews\Post\Slug\Post_Slug_Repository;
129
use HWP\Previews\Post\Status\Contracts\Post_Statuses_Config_Interface;
1310
use HWP\Previews\Post\Status\Post_Statuses_Config;
1411
use HWP\Previews\Post\Type\Contracts\Post_Types_Config_Interface;
@@ -65,9 +62,6 @@ public static function add_hook_actions(): void {
6562
return;
6663
}
6764

68-
// Enable the unique post slug functionality.
69-
add_filter( 'wp_insert_post_data', [ self::class, 'enable_unique_post_slug' ], 10, 2 );
70-
7165
// Enable post statuses as parent for the post types specified in the post-types config.
7266
add_filter( 'page_attributes_dropdown_pages_args', [ self::class, 'enable_post_statuses_as_parent' ], 10, 1 );
7367
add_filter( 'quick_edit_dropdown_pages_args', [ self::class, 'enable_post_statuses_as_parent' ], 10, 1 );
@@ -145,41 +139,6 @@ public static function get_post_statuses(): array {
145139
return apply_filters( 'hwp_previews_hooks_post_statuses', $post_statuses );
146140
}
147141

148-
/**
149-
* @TODO Remove as part of https://github.com/wpengine/hwptoolkit/issues/226
150-
*
151-
* @link https://developer.wordpress.org/reference/hooks/wp_insert_post_data/
152-
*
153-
* @param array<mixed> $data
154-
* @param array<mixed> $postarr
155-
*
156-
* @return array<mixed>
157-
*/
158-
public static function enable_unique_post_slug( array $data, array $postarr ): array {
159-
$post = new WP_Post( new Post_Data_Model( $data, (int) ( $postarr['ID'] ?? 0 ) ) );
160-
161-
if ( null === self::$settings_helper || null === self::$types_config || null === self::$statuses_config ) {
162-
return $data;
163-
}
164-
165-
// Check if the correspondent setting is enabled.
166-
if ( ! self::$settings_helper->unique_post_slugs( $post->post_type ) ) {
167-
return $data;
168-
}
169-
170-
$post_slug = ( new Post_Slug_Manager(
171-
self::$types_config,
172-
self::$statuses_config,
173-
new Post_Slug_Repository()
174-
) )->force_unique_post_slug( $post );
175-
176-
if ( ! empty( $post_slug ) ) {
177-
$data['post_name'] = $post_slug;
178-
}
179-
180-
return $data;
181-
}
182-
183142
/**
184143
* Enable post statuses as parent for the post types specified in the post types config.
185144
*

plugins/hwp-previews/src/Post/Slug/Contracts/Post_Slug_Manager_Interface.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

plugins/hwp-previews/src/Post/Slug/Post_Slug_Manager.php

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)