You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$this->assertSame( 8, has_filter( 'content_save_pre', 'wp_strip_custom_css_from_blocks' ), 'content_save_pre filter should be added at priority 8 for users without edit_css.' );
147
+
$this->assertSame( 8, has_filter( 'content_filtered_save_pre', 'wp_strip_custom_css_from_blocks' ), 'content_filtered_save_pre filter should be added at priority 8 for users without edit_css.' );
148
+
149
+
wp_set_current_user( 0 );
150
+
wp_custom_css_remove_filters();
151
+
}
152
+
153
+
/**
154
+
* Tests that the content_save_pre filter is not added for a user with edit_css.
$this->assertFalse( has_filter( 'content_save_pre', 'wp_strip_custom_css_from_blocks' ), 'content_save_pre filter should not be added for users with edit_css.' );
167
+
$this->assertFalse( has_filter( 'content_filtered_save_pre', 'wp_strip_custom_css_from_blocks' ), 'content_filtered_save_pre filter should not be added for users with edit_css.' );
168
+
169
+
wp_set_current_user( 0 );
170
+
}
171
+
172
+
/**
173
+
* Tests that switching to a user with edit_css removes the filter via the set_current_user action.
174
+
*
175
+
* wp_custom_css_kses_init() is hooked to set_current_user, so wp_set_current_user()
176
+
* alone should update the filter state without a manual call.
$this->assertNotFalse( has_filter( 'content_save_pre', 'wp_strip_custom_css_from_blocks' ), 'Filter should be active for user without edit_css.' );
188
+
189
+
wp_set_current_user( $admin_id );
190
+
$this->assertFalse( has_filter( 'content_save_pre', 'wp_strip_custom_css_from_blocks' ), 'Filter should be removed after switching to a user with edit_css.' );
191
+
192
+
wp_set_current_user( 0 );
193
+
}
194
+
195
+
/**
196
+
* Tests that the filter is enabled during import regardless of user capability.
$this->assertNotFalse( has_filter( 'content_save_pre', 'wp_strip_custom_css_from_blocks' ), 'Filter should be enabled during import regardless of user capability.' );
0 commit comments