@@ -12,16 +12,13 @@ import PreferenceSettings from './AssistantWidgetPanels/PreferencePanel';
1212import SocialShareSettings from './SocialShareSettings' ;
1313import Badge from './common/Badge' ;
1414
15- const isProLoaded = wp . hooks . applyFilters (
16- 'wedocs_pro_loaded' ,
17- false
18- ) ;
19-
20- if ( ! isProLoaded ) {
21- wp . hooks . addFilter (
22- 'wedocs_settings_menu' ,
23- 'settings_menu_override' ,
24- function ( menus ) {
15+ wp . hooks . addFilter (
16+ 'wedocs_settings_menu' ,
17+ 'wedocs_free_settings_menu_preview' ,
18+ function ( menus ) {
19+ // Check if Pro is loaded dynamically
20+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
21+ if ( isProLoaded ) return menus ;
2522 menus . permission = {
2623 pro : true ,
2724 text : __ ( 'Permission Management' , 'wedocs' ) ,
@@ -168,14 +165,19 @@ if ( !isProLoaded ) {
168165 } ;
169166
170167 return menus ;
171- }
168+ } ,
169+ 5
172170 ) ;
173171
174- wp . hooks . addFilter (
175- 'wedocs_settings_page_templates' ,
176- 'wedocs_settings_page_templates_callback' ,
177- function ( templates , docSettings , setDocSettings , index ) {
178- const assistantWidgetSubPanels = [
172+ wp . hooks . addFilter (
173+ 'wedocs_settings_page_templates' ,
174+ 'wedocs_free_settings_page_templates_preview' ,
175+ function ( templates , docSettings , setDocSettings , index ) {
176+ // Check if Pro is loaded dynamically
177+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
178+ if ( isProLoaded ) return templates ;
179+
180+ const assistantWidgetSubPanels = [
179181 < AiChatBotSettings key = { index } /> ,
180182 < ExploreSettings key = { index } /> ,
181183 < MessageSettings key = { index } /> ,
@@ -202,23 +204,29 @@ if ( !isProLoaded ) {
202204 setSettings = { setDocSettings }
203205 /> ,
204206 ] ;
205- }
207+ } ,
208+ 5
206209 ) ;
207210
208- wp . hooks . addFilter (
209- 'wedocs_admin_article_restriction_action' ,
210- 'wedocs_admin_article_restriction_action_callback' ,
211- function ( componentsArray , id , type ) {
212- return (
211+ wp . hooks . addFilter (
212+ 'wedocs_admin_article_restriction_action' ,
213+ 'wedocs_free_article_restriction_preview' ,
214+ function ( componentsArray , id , type ) {
215+ // Check if Pro is loaded dynamically
216+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
217+ if ( isProLoaded ) return componentsArray ;
218+
219+ return (
213220 < >
214221 { userIsAdmin ( ) && (
215222 < >
216223 { type === 'doc' && (
217- < a href = { `${ weDocsAdminVars . weDocsUrl } permission_settings` } className = "group flex items-center py-2 px-4 text-sm font-medium text-gray-700 hover:bg-indigo-700 hover:text-white !shadow-none" >
218- < span > { __ ( 'Permission Management' , 'wedocs' ) } </ span >
219- < span className = { `crown cursor-pointer relative text-white text-[10px] py-[3px] px-[5px] leading-none ml-2.5` } >
224+ < UpgradePopup >
225+ < span className = "group flex items-center py-2 px-4 text-sm font-medium text-gray-700 hover:bg-indigo-700 hover:text-white !shadow-none cursor-pointer" >
226+ < span > { __ ( 'Permission Management' , 'wedocs' ) } </ span >
227+ < Badge classes = "opacity-0 group-hover:opacity-100 transition-opacity ml-2" />
220228 </ span >
221- </ a >
229+ </ UpgradePopup >
222230 ) }
223231 { type === 'article' && (
224232
@@ -233,39 +241,57 @@ if ( !isProLoaded ) {
233241 ) }
234242 </ >
235243 ) ;
236- }
244+ } ,
245+ 5
237246 ) ;
238247
239- wp . hooks . addFilter (
240- 'wedocs_documentation_contributors' ,
241- 'wedocs_documentation_contributors_callback' ,
242- function ( ) {
243- if ( ! userIsAdmin ( ) ) return ;
244- if ( ! isProLoaded ) return ;
245-
246- return < Contributors /> ;
247- }
248- ) ;
248+ wp . hooks . addFilter (
249+ 'wedocs_documentation_contributors' ,
250+ 'wedocs_free_documentation_contributors_preview' ,
251+ function ( ) {
252+ // Check if Pro is loaded dynamically
253+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
254+ if ( isProLoaded ) return ;
255+ if ( ! userIsAdmin ( ) ) return ;
249256
250- wp . hooks . addFilter (
251- 'wedocs_article_contributors' ,
252- 'wedocs_article_contributors_callback' ,
253- function ( ) {
254- if ( ! userIsAdmin ( ) ) return ;
255- if ( ! isProLoaded ) return ;
257+ return < Contributors /> ;
258+ } ,
259+ 5
260+ ) ;
256261
257- return < Contributors /> ;
258- }
259- ) ;
262+ wp . hooks . addFilter (
263+ 'wedocs_article_contributors' ,
264+ 'wedocs_free_article_contributors_preview' ,
265+ function ( ) {
266+ // Check if Pro is loaded dynamically
267+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
268+ if ( isProLoaded ) return ;
269+ if ( ! userIsAdmin ( ) ) return ;
260270
271+ return < Contributors /> ;
272+ } ,
273+ 5
274+ ) ;
261275
262276wp . hooks . addFilter (
263- 'wedocs_register_menu_routes' ,
264- 'wedocs_register_menu_routes_callback' ,
265- function ( routes ) {
266- const { weDocsSettingsPage : SettingsPage } = window ;
267- routes ?. push ( { path : 'settings/:panel' , component : SettingsPage } ) ;
268- return routes ;
269- }
277+ 'wedocs_article_restriction_menu' ,
278+ 'wedocs_free_article_restriction_menu_preview' ,
279+ function ( menu ) {
280+ // Check if Pro is loaded dynamically
281+ const isProLoaded = wp . hooks . applyFilters ( 'wedocs_pro_loaded' , false ) ;
282+ if ( isProLoaded ) return menu ;
283+
284+ // Return PRO preview menu when Pro is not loaded
285+ return (
286+ < UpgradePopup >
287+ < a
288+ href = "#"
289+ className = "group flex items-center py-2 px-4 text-sm font-medium text-gray-700 hover:bg-indigo-700 hover:text-white !shadow-none"
290+ >
291+ < span > { __ ( 'Permission Management' , 'wedocs' ) } </ span >
292+ </ a >
293+ </ UpgradePopup >
294+ ) ;
295+ } ,
296+ 5
270297) ;
271- }
0 commit comments