RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð ....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 104.225.223.251  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux agtdemo03 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/web/dev.agtindia.co.in/acsen/wp-content/plugins/types/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/web/dev.agtindia.co.in/acsen/wp-content/plugins/types/application/controllers/admin_menu.php
<?php

use OTGS\Toolset\Types\Controller\Page\DatabaseMigration\DatabaseUpgradePage;
use OTGS\Toolset\Types\Controller\Page\PageControllerInterface;
use OTGS\Toolset\Types\Post\Import\Association\View\Page;

/**
 * Admin menu controller for Types.
 *
 * All Types pages, menus, submenus and whatnot need to be registered here. One of the main goals is to avoid
 * loading specific page controllers unless their page is actually being loaded. All page slugs in Types *must*
 * be defined here as constants PAGE_NAME_*.
 *
 * For adding a new persistent page (that displays in the menu at all times), go to get_persistent_pages().
 * For pages that display only under certain circumstances, check out maybe_add_ondemand_submenu().
 *
 * @since 2.0
 */
class Types_Admin_Menu {

	/** Temporary slug compatible with the legacy code. */
	const MENU_SLUG = 'wpcf';


	// All (non-legacy) page slugs.
	const PAGE_NAME_FIELD_CONTROL = 'types-field-control';

	const PAGE_NAME_HELPER = 'types-helper'; // hidden page

	const PAGE_NAME_DASHBOARD = Types_Page_Dashboard::PAGE_SLUG;

	const PAGE_NAME_RELATIONSHIPS = 'types-relationships';

	const PAGE_NAME_FIELD_GROUP_EDIT_POST = 'wpcf-edit';

	const PAGE_NAME_FIELD_GROUP_EDIT_USER = 'wpcf-edit-usermeta';

	const PAGE_NAME_FIELD_GROUP_EDIT_TERM = 'wpcf-termmeta-edit';

	const PAGE_NAME_CUSTOM_FIELDS = 'types-custom-fields'; // Custom fields page name

	const PAGE_NAME_DATABASE_UPGRADE = 'types-database-upgrade';

	// Legacy page slugs
	const LEGACY_PAGE_CUSTOM_POST_FIELDS = 'wpcf-cf';

	const LEGACY_PAGE_CUSTOM_USER_FIELDS = 'wpcf-um';

	const LEGACY_PAGE_CUSTOM_TERM_FIELDS = 'wpcf-termmeta-listing';

	const LEGACY_PAGE_EDIT_POST_FIELD_GROUP = 'wpcf-edit';

	const LEGACY_PAGE_EDIT_POST_TYPE = 'wpcf-edit-type';


	/**
	 * Legacy pages.
	 *
	 * Contains a list of new pages and its legacy pages.
	 * Used for Custom Fields.
	 *
	 * array[                        List of actual pages that had different names.
	 *        legacy => [                Legacy page name.
	 *            actual,                Actual page name.
	 *            array[params]        Array of extra params key=>value
	 *        ]
	 * ]
	 *
	 * @since 2.3
	 * @link https://onthegosystems.myjetbrains.com/youtrack/issue/types-890
	 * @see redirect_legacy_pages
	 * @var array
	 */
	private $legacy_pages = array(
		self::LEGACY_PAGE_CUSTOM_POST_FIELDS => array(
			self::PAGE_NAME_CUSTOM_FIELDS,
			array( 'domain' => 'posts' ),
		),
		self::LEGACY_PAGE_CUSTOM_USER_FIELDS => array(
			self::PAGE_NAME_CUSTOM_FIELDS,
			array( 'domain' => 'users' ),
		),
		self::LEGACY_PAGE_CUSTOM_TERM_FIELDS => array(
			self::PAGE_NAME_CUSTOM_FIELDS,
			array( 'domain' => 'terms' ),
		),
	);

	private static $instance;


	/** @var Types_Page_Router */
	private $page_router;

	/** @var array Cache for get_persistent_pages() */
	private $persistent_pages;


	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self( new Types_Page_Router() );
		}

		return self::$instance;
	}


	public static function initialize() {
		self::get_instance();
	}


	/**
	 * Types_Admin_Menu constructor.
	 *
	 * @param Types_Page_Router $page_router_di
	 *
	 * @since m2m
	 */
	public function __construct( Types_Page_Router $page_router_di ) {
		$this->page_router = $page_router_di;

		$this->add_hooks();

		// Load Dashboard
		Types_Page_Dashboard::get_instance();

		// Load Associations Import Page (will be placed on Toolset Import/Export)
		if ( apply_filters( 'toolset_is_m2m_enabled', false ) ) {
			add_action( 'load-toolset_page_toolset-export-import', static function () {
				new Page(
					new Types_Helper_Twig()
				);
			} );
		}
	}


	public function add_hooks() {

		// Priority is hardcoded by filter documentation.
		add_filter( 'toolset_filter_register_menu_pages', array( $this, 'on_admin_menu' ), 10 );

		// Redirects legacy pages.
		add_action( 'admin_page_access_denied', array( $this, 'redirect_legacy_pages' ) );
	}


	/**
	 * Add all Types submenus and jumpstart a specific page controller if needed.
	 *
	 * Toolset shared menu usage is described here:
	 *
	 * @link https://git.onthegosystems.com/toolset/toolset-common/wikis/toolset-shared-menu
	 *
	 * @param array $pages Array of menu item definitions.
	 *
	 * @return array Updated item definition array.
	 * @since 2.0
	 */
	public function on_admin_menu( $pages ) {
		$pages = wpcf_admin_toolset_register_menu_pages( $pages );

		// Unset some legacy pages because they are handled with Types_Admin_Menu.
		$pages = $this->remove_some_legacy_pages( $pages );

		// For non-legacy pages, also add routes
		$persistent_pages = $this->get_persistent_pages();
		$this->add_routes( $persistent_pages );

		$pages = array_merge( $pages, $persistent_pages );

		$page_name = sanitize_text_field( toolset_getget( 'page' ) );
		if ( ! empty( $page_name ) ) {
			$pages = $this->maybe_add_ondemand_submenu( $pages, $page_name );
		}

		return $pages;
	}


	/**
	 * Register routes for all pages with the router.
	 *
	 * @param array[] $pages
	 */
	private function add_routes( $pages ) {

		foreach ( $pages as $page ) {

			$controller_class_to_instantiate = toolset_getarr( $page, 'controller_class_name', null );

			// We can assume this because all page controllers inherit from Types_Page_Persistent
			$attributes = array(
				'title' => toolset_getarr( $page, 'menu_title' ),

				// Some times menu title and page title are different.
				'menu_title' => toolset_getarr( $page, 'menu_title' ),
				'page_title' => toolset_getarr( $page, 'page_title' ),
				'page_name' => toolset_getarr( $page, 'slug' ),
				'required_capability' => toolset_getarr( $page, 'capability', 'manage_options' ),
			);

			// add route for page preparation and for rendering
			$page_controller_factory = toolset_getarr( $page, 'factory', 'Types_Page_Factory_Passthrough' );

			// extract method name from the callable
			$load_callback_name = $this->get_callback_name( toolset_getarr( $page, 'load_hook' ) );
			$this->page_router->add_route( $load_callback_name, $controller_class_to_instantiate, 'prepare', $attributes, $page_controller_factory );

			$render_callback_name = $this->get_callback_name( toolset_getarr( $page, 'callback' ) );
			$this->page_router->add_route( $render_callback_name, $controller_class_to_instantiate, 'render_page', $attributes, $page_controller_factory );
		}
	}


	/**
	 * Get the name of the callback method from a callable.
	 *
	 * @param callable $callable A callable in the form of array( $page_router, 'callback_name' ).
	 *
	 * @return string The callback name.
	 * @throws InvalidArgumentException
	 */
	private function get_callback_name( $callable ) {
		if ( is_array( $callable ) && count( $callable ) === 2 && is_string( $callable[1] ) ) {
			return $callable[1];
		}

		throw new InvalidArgumentException( 'Invalid admin menu route callback' );
	}


	/**
	 * Check if an on-demand submenu should be added, and jumpstart it's controller if needed.
	 *
	 * On-demand submenu means that the submenu isn't displayed normally, it appears only when its page is loaded.
	 *
	 * Note: All page controllers should inherit from Types_Page_Abstract.
	 *
	 * @param array $pages Array of menu item definitions.
	 * @param string $page_name
	 *
	 * @return array Updated item definition array.
	 * @since 2.0
	 * @noinspection PhpDocMissingThrowsInspection
	 */
	private function maybe_add_ondemand_submenu( $pages, $page_name ) {
		$page = null;
		$dic = toolset_dic();
		switch ( $page_name ) {
			case self::PAGE_NAME_FIELD_CONTROL:
				$page = Types_Page_Field_Control::get_instance();
				break;
			case self::PAGE_NAME_HELPER:
				Types_Page_Hidden_Helper::get_instance();
				break;
			case self::PAGE_NAME_FIELD_GROUP_EDIT_POST:
			case self::PAGE_NAME_FIELD_GROUP_EDIT_USER:
			case self::PAGE_NAME_FIELD_GROUP_EDIT_TERM:
				new Types_Page_Field_Group_Edit();
				break;
			case self::PAGE_NAME_DATABASE_UPGRADE:
				/** @noinspection PhpUnhandledExceptionInspection */
				$page = $dic->make( DatabaseUpgradePage::class );
				break;
		}

		if ( $page instanceof PageControllerInterface ) {
			// Jumpstart the page controller.
			try {
				$page->prepare();
			} catch ( Exception $e ) {
				wp_die( $e->getMessage() );
			}

			$pages[ $page_name ] = array(
				'slug' => $page_name,
				'menu_title' => $page->get_title(),
				'page_title' => $page->get_title(),
				'callback' => $page->get_render_callback(),
				'load_hook' => $page->get_load_callback(),
				'required_capability' => $page->get_required_capability(),
				'contextual_help_hook' => array( Types_Asset_Help_Tab_Loader::get_instance(), 'add_help_tab' ),
			);

			// todo we might need to handle adding URL parameters to submenu URLs in some standard way, it's common scenario for ondemand submenus
		}

		return $pages;
	}


	/**
	 * Get arguments for registering persistent admin pages.
	 *
	 * Each element is an array of arguments for a page that will appear in Toolset submenu at all times.
	 *
	 * The arguments are described here:
	 *
	 * @link https://git.onthegosystems.com/toolset/toolset-common/wikis/toolset-shared-menu
	 *
	 * Besides that, the following is assumed:
	 *
	 * - element key is a page identifier that can be used as a part of the function name,
	 * - there's a 'controller_class_name' argument whose value is the name of the page controller,
	 * - all page controllers inherit from Types_Page_Persistent,
	 * - callbacks are generated via get_callback() using the correct page identifier.
	 *
	 * @return array
	 * @since m2m
	 */
	private function get_persistent_pages() {

		if ( null === $this->persistent_pages ) {
			$persistent_pages = array(

				self::PAGE_NAME_CUSTOM_FIELDS => array(
					'slug' => self::PAGE_NAME_CUSTOM_FIELDS,
					'menu_title' => __( 'Custom Fields', 'wpcf' ),
					'page_title' => __( 'Custom Fields Group', 'wpcf' ),
					'load_hook' => $this->get_callback( 'custom_fields', 'load' ),
					'callback' => $this->get_callback( 'custom_fields', 'render' ),
					'required_capability' => 'manage_options',
					'controller_class_name' => 'Types_Page_Custom_Fields',
					'contextual_help_hook' => array(
						Types_Asset_Help_Tab_Loader::get_instance(),
						'add_multiple_help_tabs',
					),
				),

				self::PAGE_NAME_RELATIONSHIPS => array(
					'slug' => self::PAGE_NAME_RELATIONSHIPS,
					'menu_title' => __( 'Relationships', 'wpcf' ),
					'page_title' => __( 'Relationships', 'wpcf' ),
					'load_hook' => $this->get_callback( 'relationships', 'load' ),
					'callback' => $this->get_callback( 'relationships', 'render' ),
					'capability' => 'manage_options',
					'controller_class_name' => 'Types_Page_Relationships',
					'factory' => 'Types_Page_Factory_Relationships',
				),

			);

			$this->persistent_pages = $persistent_pages;
		}

		return $this->persistent_pages;
	}


	/**
	 * Generate a callback for a page.
	 *
	 * @param string $page_identifier Page identifier from get_persistent_pages().
	 * @param string $action self::LOAD_CALL|self::RENDER_CALL
	 *
	 * @return callable
	 * @since m2m
	 */
	private function get_callback( $page_identifier, $action ) {
		return array( $this->page_router, $action . '_' . $page_identifier );
	}


	/**
	 * Redirect legacy pages
	 *
	 * Custom Fields groups three legacy pages: custom posts, users, terms.
	 * This action will redirect theses pages to the new one.
	 *
	 * @since 2.3
	 */
	public function redirect_legacy_pages() {
		$page_name = sanitize_text_field( toolset_getget( 'page' ) );
		if ( $page_name ) {
			foreach ( $this->legacy_pages as $legacy => $actual ) {
				// $actual contains [0] => actual page, [1] => extra params.
				if ( $page_name === $legacy ) {
					wp_redirect( esc_url_raw( add_query_arg(
							array( 'page' => $actual[0] ) + $actual[1],
							admin_url( 'admin.php' )
					) ) );
					exit();
				}
			}
		}
	}


	/**
	 * Remove some legacy pages.
	 *
	 * Because some pages are declared in /vendor and Types is being refactoring,
	 * it is necessary to remove this legacy pages from the initial setup.
	 *
	 * @param array $pages Inicial pages declared in /vendor.
	 *
	 * @return array
	 * @since 2.3
	 * @see wpcf_admin_toolset_register_menu_pages
	 */
	private function remove_some_legacy_pages( $pages ) {
		foreach ( array_keys( $this->legacy_pages ) as $legacy ) {
			unset( $pages[ $legacy ] );
		}

		return $pages;
	}


	/**
	 * Central point to safely obtain URLs of Toolset pages.
	 *
	 * Note: Doesn't work for most legacy pages. If you need it, you can adjust the code below,
	 * but in any case, this method should be used.
	 *
	 * @param string $page_slug Page slug (usually a constant from Types_Admin_Menu)
	 *
	 * @return null|string URL of the page or null if the page isn't recognized.
	 */
	public function get_page_url( $page_slug ) {
		$persistent_pages = $this->get_persistent_pages();

		if ( ! array_key_exists( $page_slug, $persistent_pages ) ) {
			// Check a set of legacy pages
			$legacy_pages = array(
				self::LEGACY_PAGE_EDIT_POST_FIELD_GROUP,
				self::LEGACY_PAGE_EDIT_POST_TYPE,
			);
			if ( ! in_array( $page_slug, $legacy_pages ) ) {
				return null;
			}
		}

		return add_query_arg(
			array( 'page' => $page_slug ),
			admin_url( 'admin.php' )
		);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit