....................................../////.===Hehe-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 : 159.198.67.129  /  Your IP : 216.73.216.75
Web Server : LiteSpeed
System : Linux server166.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : trooaisr ( 4033)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/softaculous/sitepad/editor/site-data/plugins/documentor/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/softaculous/sitepad/editor/site-data/plugins/documentor//documentor.php
<?php
/**
 * Plugin Name:  Documentor
 * Description:  Online Documentation Engine for WordPress
 * Version:	  1.0.0
 * Author:	   softaculous
 * Author URI:   https://softaculous.com
 * License:	  GPLv2 or later
 * License URI:  https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:  documentor
 *
 * @package documentor
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Documentor class
 *
 * @class Documentor The class that holds the entire Documentor plugin
 */
class Documentor {
	/**
	 * The single class instance.
	 *
	 * @var $instance
	 */
	private static $instance = null;

	/**
	 * Path to the plugin directory
	 *
	 * @var $plugin_path
	 */
	public $plugin_path;

	/**
	 * URL to the plugin directory
	 *
	 * @var $plugin_url
	 */
	public $plugin_url;

	/**
	 * Theme templates directory path
	 *
	 * @var $theme_dir_path
	 */
	public $theme_dir_path;

	/**
	 * Path to template folder
	 *
	 * @var $theme_dir_path
	 */
	public $template_path;

	/**
	 * Post type name for documents
	 *
	 * @var $post_type
	 */
	public $post_type = 'docs';

	/**
	 * Current Page - is Docs Archive. Will be changed from Template Loader class
	 *
	 * @var $post_type
	 */
	public $is_archive = false;

	/**
	 * Current Page - is Docs Single. Will be changed from Template Loader class
	 *
	 * @var $post_type
	 */
	public $is_single = false;

	/*
	* @var $version 
	*/
	public $version = '1.0.1';
	
	/**
	 * Main Instance
	 * Ensures only one instance of this class exists in memory at any one time.
	 */
	public static function instance() {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self();
			self::$instance->plugin_init();
		}
		return self::$instance;
	}

	/**
	 * Plugin init.
	 */
	public function plugin_init() {
		$this->plugin_path	= plugin_dir_path( __FILE__ );
		$this->plugin_url	 = plugin_dir_url( __FILE__ );
		$this->theme_dir_path = 'documentor/';
		$this->template_path  = $this->plugin_path . '/templates/';

		$this->include_dependencies();

		$this->maybe_setup();

		$this->add_image_sizes();
		
		// Update checker
		add_action('plugins_loaded', array( $this, 'update_check'));
		
		// load textdomain.
		load_plugin_textdomain( 'documentor', false, basename( dirname( __FILE__ ) ) . '/languages' );

		// custom post type register.
		add_action( 'init', array( $this, 'register_post_type' ) );

		// Loads frontend scripts and styles.
		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

		register_deactivation_hook( __FILE__, array( $this, 'deactivation_hook' ) );
		register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
	}

	/**
	 * Activation hook.
	 */
	public function activation_hook() {
		$author = get_role( 'author' );
		$admin  = get_role( 'administrator' );

		/* Add documentor manager role */
		$documentor_manager = add_role( 'documentor_manager', __( 'Documentor Manager', 'documentor' ), $author->capabilities );

		$full_cap = array(
			'read_doc',
			'read_private_doc',
			'read_private_docs',
			'edit_doc',
			'edit_docs',
			'edit_others_docs',
			'edit_private_docs',
			'edit_published_docs',
			'delete_doc',
			'delete_docs',
			'delete_others_docs',
			'delete_private_docs',
			'delete_published_docs',
			'publish_docs',
		);

		/**
		 * Add full capacities to admin and docs manager roles
		 */
		foreach ( $full_cap as $cap ) {
			if ( null !== $admin ) {
				$admin->add_cap( $cap );
			}
			if ( null !== $documentor_manager ) {
				$documentor_manager->add_cap( $cap );
			}
		}

		// Create Docs page if not created.
		$settings = get_option( 'documentor_settings', array() );
		if ( ! $settings || ! $settings['docs_page_id'] ) {
			$documentor_page = wp_insert_post(
				array(
					'post_title'  => 'Docs',
					'post_type'   => 'page',
					'post_author' => get_current_user_id(),
					'post_status' => 'publish',
					'post_name'   => 'docs',
				)
			);

			if ( ! is_wp_error( $documentor_page ) ) {
				$settings['docs_page_id'] = $documentor_page;

				update_option( 'documentor_settings', $settings );
			}
		}

		// need to flush rules to reset permalinks.
		add_option( 'documentor_setup', 'pending' );
		
		// Enable for pagelayer as well
		$pl = get_option('pl_support_ept');
		
		if(empty($pl)){
			$pl = ['post', 'page'];
		}
		
		if(defined('PAGELAYER_VERSION') && !in_array($this->post_type, $pl)){
			$pl[] = $this->post_type;
			update_option('pl_support_ept', $pl);
		}
		
		include_once documentor()->plugin_path.'includes/template.php';
		
		documentor_import_template_content( json_decode(documentor_get_conf(),true), documentor_get_content());

	}

	/**
	 * Deactivation hook.
	 */
	public function deactivation_hook() {
		/* Deactivation actions */
	}

	/**
	 * Update checker hook.
	 */
	public function update_check() {
		/* Update checker hook */

		$current_version = get_option('documentor_version');
		$version = (int) str_replace('.', '', $current_version);

		// No update required
		if($current_version == $this->version){
			return true;
		}
		
		if($version < 101){
			
			$args = array(
				'post_type' => 'pagelayer-template',
				'post_status' => array('publish'),
				'meta_query' => array(
					array(
						'key' => 'documentor_imported_content',
					)
				)
			);
			
			$query = new WP_Query($args);

			if(empty($query->posts)){
				include_once documentor()->plugin_path.'includes/template.php';
				documentor_import_template_content( json_decode(documentor_get_conf(),true), documentor_get_content());
			}
		}
		
		// Save the new Version
		update_option('documentor_version', $this->version);
	}

	/**
	 * Maybe run setup code and rewrite rules.
	 */
	public function maybe_setup() {
		$documentor_archive_id = documentor()->get_option( 'docs_page_id', 'documentor_settings', false );
		$docs_page			= $documentor_archive_id ? get_post( $documentor_archive_id ) : false;
		$slug				 = $docs_page ? get_post_field( 'post_name', $docs_page ) : 'docs';

		if (
			get_option( 'documentor_setup', false ) === 'pending' ||
			get_option( 'documentor_current_slug', 'docs' ) !== $slug
		) {
			add_action( 'init', 'flush_rewrite_rules', 11, 0 );
			add_action( 'admin_init', 'flush_rewrite_rules', 11, 0 );

			delete_option( 'documentor_setup' );
			update_option( 'documentor_current_slug', $slug );
		}
	}

	/**
	 * Add image sizes.
	 */
	public function add_image_sizes() {
		// custom image sizes.
		add_image_size( 'documentor_archive_sm', 20, 20, true );
		add_image_size( 'documentor_archive', 40, 40, true );
		add_filter( 'image_size_names_choose', array( $this, 'image_size_names_choose' ) );
	}

	/**
	 * Custom image sizes
	 *
	 * @param array $sizes - registered image sizes.
	 *
	 * @return array
	 */
	public function image_size_names_choose( $sizes ) {
		return array_merge(
			$sizes,
			array(
				'documentor_archive_sm' => esc_html__( 'Archive Thumbnail Small (Documentor)', 'documentor' ),
				'documentor_archive'	=> esc_html__( 'Archive Thumbnail (Documentor)', 'documentor' ),
			)
		);
	}

	/**
	 * Include dependencies
	 */
	public function include_dependencies() {
		include_once documentor()->plugin_path . 'includes/class-template-loader.php';
		include_once documentor()->plugin_path . 'includes/class-walker-docs.php';
		include_once documentor()->plugin_path . 'includes/class-suggestion.php';

		if ( is_admin() ) {
			include_once documentor()->plugin_path . 'includes/admin/class-admin.php';
		}

		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			include_once documentor()->plugin_path . 'includes/class-ajax.php';
		}
	}

	/**
	 * Enqueue admin scripts
	 *
	 * Allows plugin assets to be loaded.
	 *
	 * @uses wp_enqueue_script()
	 * @uses wp_localize_script()
	 * @uses wp_enqueue_style
	 */
	public function enqueue_scripts() {
		
		$deps = array( 'jquery' );
		wp_register_style( 'documentor', documentor()->plugin_url . 'assets/css/style.min.css', array(), $this->version );
	
		if( documentor()->get_option( 'show_anchor_links', 'documentor_single', true ) ) {
			wp_register_script( 'anchor-js', documentor()->plugin_url . 'assets/vendor/anchor/anchor.min.js', array(),  $this->version, true );
			$deps[] = 'anchor-js';
		}
		
		wp_register_script( 'documentor', documentor()->plugin_url . 'assets/js/script.min.js', $deps, $this->version, true );
	
		if ( ! ( $this->is_archive || $this->is_single ) ) {
			return;
		}

		wp_enqueue_style( 'documentor');
		wp_style_add_data( 'documentor', 'rtl', 'replace' );
		wp_style_add_data( 'documentor', 'suffix', '.min' );

		if ( documentor()->get_option( 'show_anchor_links', 'documentor_single', true ) ) {
			wp_enqueue_script( 'anchor-js');
		}
		wp_enqueue_script( 'documentor' );
		wp_localize_script(
			'documentor',
			'documentor_vars',
			array(
				'ajaxurl' => admin_url( 'admin-ajax.php' ),
				'nonce'   => wp_create_nonce( 'documentor-ajax' ),
			)
		);

		// Custom script for AJAX.
		$ajax	  = documentor()->get_option( 'ajax', 'documentor_single', true );
		$custom_js = documentor()->get_option( 'ajax_custom_js', 'documentor_single', '' );
		if ( $ajax && $custom_js ) {
			wp_add_inline_script(
				'documentor',
				'
				(function ($) {
					$(document).on("documentor_ajax_loaded", function (event, new_page) {
						' . $custom_js . '
					});
				}(jQuery));
			'
			);
		}

		if ( $ajax && $this->is_single) {
			wp_add_inline_script('documentor', 'jQuery(".pagelayer-content").addClass("documentor-single-ajax");');
		}
	}

	/**
	 * Register the post type
	 *
	 * @return void
	 */
	public function register_post_type() {
		$documentor_archive_id = documentor()->get_option( 'docs_page_id', 'documentor_settings', false );
		$docs_page			= $documentor_archive_id ? get_post( $documentor_archive_id ) : false;

		$labels = array(
			'name'			   => $docs_page ? get_the_title( $docs_page ) : _x( 'Documentor', 'Post Type General Name', 'documentor' ),
			'singular_name'	  => _x( 'Doc', 'Post Type Singular Name', 'documentor' ),
			'menu_name'		  => __( 'Documentation', 'documentor' ),
			'parent_item_colon'  => __( 'Parent Doc', 'documentor' ),
			'all_items'		  => __( 'All Documentations', 'documentor' ),
			'view_item'		  => __( 'View Documentation', 'documentor' ),
			'add_new_item'	   => __( 'Add Documentation', 'documentor' ),
			'add_new'			=> __( 'Add New', 'documentor' ),
			'edit_item'		  => __( 'Edit Documentation', 'documentor' ),
			'update_item'		=> __( 'Update Documentation', 'documentor' ),
			'search_items'	   => __( 'Search Documentation', 'documentor' ),
			'not_found'		  => __( 'Not documentation found', 'documentor' ),
			'not_found_in_trash' => __( 'Not found in Trash', 'documentor' ),
		);

		$rewrite = array(
			'slug'	   => $docs_page ? get_post_field( 'post_name', $docs_page ) : 'docs',
			'with_front' => false,
			'pages'	  => true,
			'feeds'	  => true,
		);

		$args = array(
			'labels'			  => $labels,
			'supports'			=> array( 'title', 'editor', 'thumbnail', 'revisions', 'page-attributes', 'comments' ),
			'hierarchical'		=> true,
			'public'			  => true,
			'show_ui'			 => true,
			'show_in_menu'		=> false,
			'show_in_nav_menus'   => true,
			'show_in_admin_bar'   => true,
			'menu_position'	   => 5,
			'menu_icon'		   => 'dashicons-media-document',
			'can_export'		  => true,
			'has_archive'		 => $docs_page ? urldecode( get_page_uri( $documentor_archive_id ) ) : 'docs',
			'exclude_from_search' => false,
			'publicly_queryable'  => true,
			'show_in_rest'		=> true,
			'rewrite'			 => $rewrite,
			'map_meta_cap'		=> true,
			'capability_type'	 => array( 'doc', 'docs' ),
		);

		register_post_type( $this->post_type, $args );

		register_taxonomy(
			'docs_category',
			$this->post_type,
			array(
				'label'			  => esc_html__( 'Docs Categories', 'documentor' ),
				'labels'			 => array(
					'menu_name' => esc_html__( 'Categories', 'documentor' ),
				),
				'rewrite'			=> array(
					'slug' => 'docs-category',
				),
				'hierarchical'	   => false,
				'publicly_queryable' => false,
				'show_in_nav_menus'  => false,
				'show_in_rest'	   => true,
				'show_admin_column'  => true,
			)
		);
	}

	/**
	 * Get the value of a settings field
	 *
	 * @param string $option settings field name.
	 * @param string $section the section name this field belongs to.
	 * @param string $default default text if it's not found.
	 *
	 * @return mixed
	 */
	public function get_option( $option, $section, $default = '' ) {

		$options = get_option( $section );

		if ( isset( $options[ $option ] ) ) {
			return 'off' === $options[ $option ] ? false : ( 'on' === $options[ $option ] ? true : $options[ $option ] );
		}

		return $default;
	}

	/**
	 * Get template part or docs templates
	 * Looks at the theme directory first
	 *
	 * @param string $name template file name.
	 * @param string $data template data.
	 */
	public function get_template_part( $name, $data = array() ) {
		$name = (string) $name;

		// lookup at documentor/name.php.
		$template = locate_template(
			array(
				documentor()->theme_dir_path . "{$name}.php",
			)
		);

		// fallback to plugin default template.
		if ( ! $template && $name && file_exists( documentor()->template_path . "{$name}.php" ) ) {
			$template = documentor()->template_path . "{$name}.php";
		}

		if ( $template ) {
			$this->load_template( $template, $data );
		}
	}

	/**
	 * Load template with additional data.
	 *
	 * @param string $template_path - template path.
	 * @param array  $template_data - template data array.
	 */
	public function load_template( $template_path, $template_data ) {
		if ( isset( $template_data ) && is_array( $template_data ) ) {
			// phpcs:ignore
			extract( $template_data );
		}

		if ( file_exists( $template_path ) ) {
			include $template_path;
		}
	}

	/**
	 * Is Archive
	 *
	 * @return bool
	 */
	public function is_archive() {
		return $this->is_archive;
	}

	/**
	 * Is Single
	 *
	 * @return bool
	 */
	public function is_single() {
		return $this->is_single;
	}

	/**
	 * Get current document ID
	 *
	 * @return int
	 */
	public function get_current_doc_id() {
		global $post;

		if ( $post->post_parent ) {
			$ancestors = get_post_ancestors( $post->ID );
			$root	  = count( $ancestors ) - 1;
			$parent	= $ancestors[ $root ];
		} else {
			$parent = $post->ID;
		}

		return apply_filters( 'documentor_current_doc_id', $parent );
	}

	/**
	 * Get document page title
	 *
	 * @return string
	 */
	public function get_docs_page_title() {
		$title		= esc_html__( 'Documentation', 'documentor' );
		$docs_page_id = documentor()->get_option( 'docs_page_id', 'documentor_settings' );

		if ( $docs_page_id ) {
			$title = get_the_title( $docs_page_id );
		}

		return apply_filters( 'documentor_page_title', $title );
	}

	/**
	 * Get document page content
	 *
	 * @return string
	 */
	public function get_docs_page_content() {
		$content	  = '';
		$docs_page_id = documentor()->get_option( 'docs_page_id', 'documentor_settings' );

		if ( $docs_page_id ) {
			$content = get_post_field( 'post_content', $docs_page_id );
		}

		return apply_filters( 'documentor_page_content', $content );
	}

	/**
	 * Get breadcrumbs array
	 *
	 * @return array
	 */
	public function get_breadcrumbs_array() {
		global $post;

		$result	   = array();
		$docs_page_id = documentor()->get_option( 'docs_page_id', 'documentor_settings' );

		$result[] = array(
			'label'	=> __( 'Home', 'documentor' ),
			'url'	  => home_url( '/' ),
		);

		if ( $docs_page_id ) {
			$result[] = array(
				'label' => get_the_title( $docs_page_id ) ? get_the_title( $docs_page_id ) : __( 'Docs', 'documentor' ),
				'url'   => get_permalink( $docs_page_id ),
			);
		}

		if ( 'docs' === $post->post_type && $post->post_parent ) {
			$parent_id   = $post->post_parent;
			$temp_crumbs = array();

			while ( $parent_id ) {
				$page		  = get_post( $parent_id );
				$temp_crumbs[] = array(
					'label'	=> get_the_title( $page->ID ),
					'url'	  => get_permalink( $page->ID ),
				);
				$parent_id	 = $page->post_parent;
			}

			$temp_crumbs = array_reverse( $temp_crumbs );
			
			// Add current post
			$temp_crumbs[] = array(
				'label'	=> get_the_title( $post->ID ),
			);
			
			foreach ( $temp_crumbs as $crumb ) {
				$result[] = $crumb;
			}
		}

		return apply_filters( 'documentor_breadcrumbs_array', $result );
	}

	/**
	 * Next doc ID for the current doc page
	 *
	 * @return int
	 */
	public function get_next_adjacent_doc_id() {
		global $post, $wpdb;

		$parent = pagelayer_is_live() || wp_doing_ajax('adjacent_links') ? '0' : $post->post_parent;
		$menu_order = pagelayer_is_live() || wp_doing_ajax('adjacent_links') ? 1 : $post->menu_order;

		$next_query = "SELECT ID FROM $wpdb->posts
		WHERE post_parent = $parent and post_type = 'docs' and post_status = 'publish' and menu_order > $menu_order
		ORDER BY menu_order ASC
		LIMIT 0, 1";

		// phpcs:ignore
		return (int) $wpdb->get_var( $next_query );
	}

	/**
	 * Previous doc ID for the current doc page
	 *
	 * @return int
	 */
	public function get_previous_adjacent_doc_id() {
		global $post, $wpdb;

		$parent = pagelayer_is_live()  || wp_doing_ajax('adjacent_links') ? '0' : $post->post_parent;
		$menu_order = pagelayer_is_live() || wp_doing_ajax('adjacent_links') ? 1 : $post->menu_order;

		$prev_query = "SELECT ID FROM $wpdb->posts
		WHERE post_parent = $parent and post_type = 'docs' and post_status = 'publish' and menu_order < $menu_order
		ORDER BY menu_order DESC
		LIMIT 0, 1";

		// phpcs:ignore
		return (int) $wpdb->get_var( $prev_query );
	}

} // Documentor

/**
 * Initialize the plugin
 *
 * @return \Documentor
 */
function documentor() {
	return Documentor::instance();
}
documentor();
	
// To find posts when we submit /docs/space/arctile-name instead of /docs/space/category/arctile-name
add_filter('request', 'documentor_query_vars');
function documentor_query_vars($vars){// Handle direct links
	//print_r($vars);die();
	
	$doc = documentor();
	
	// Must be docs
	if(empty($vars['post_type']) || $vars['post_type'] != documentor()->post_type || empty($vars['name'])){
		return $vars;
	}
	
	if(!empty($_GET['debug'])){
		//print_r($vars);die();
	}
	
	$docs_archive_id = documentor()->get_option( 'docs_page_id', 'documentor_settings', false );
	$permalink = get_permalink($docs_archive_id);
	
	$docs = explode('/', $vars['docs']);
	
	// Find the post
	$args = array(
		'name'		=> $vars['name'],
		'post_type'   => 'docs',
		'post_status' => 'publish',
		'numberposts' => 10
	);
	
	$posts = get_posts($args);	
	//print_r($post);
	
	// Did we get it ?
	if(empty($posts)){
		
		// Ok lets try to see if we get with another method
		$tmp = explode('/', str_replace('_', '-', $vars['name']));
		$args['name'] = $tmp[count($tmp)-1];
		$posts = get_posts($args);	
		
		// If we still didnt get it, then lets return original vars
		if(empty($posts)){
			return $vars;
		}
		
	}
	
	$post = $posts[0];
	
	// If we have 2 parts, then find the closest as well
	if(count($docs) > 1){
		
		// If we found more than 1 results
		foreach($posts as $p){
			
			$url = get_permalink($p);			
			$_section = trim(str_replace($permalink, '', $url), '/');
			$parts = explode('/', $_section);
			
			if($parts[0] == $docs[0]){
				$post = $p;
				break;
			}
			
		}
		
	}
			
	if(!empty($_GET['debug'])){
		//print_r($post);die();
	}
	
	$url = get_permalink($post);
	$_section = trim(str_replace($permalink, '', $url), '/');
	//echo $url."\n";
	//echo $_section.' - '.$vars['name']."\n";die();
	
	// If the LINK is not same as the original, then redirect
	if($_section != trim($vars['name'], '/')){
		//die('redirecting !');
		wp_redirect($url.(!empty($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : ''));
		die();
	}
	
	$section = get_page_uri($post);
	//echo $section."\n";
	
	$vars['name'] = $vars['docs'] = trim($section, '/');
	//print_r($vars);
	//die($section);
	
	return $vars;
}

// No pagelayer content template should render
add_action( 'template_redirect', 'documentor_no_pagelayer_content', 101);
function documentor_no_pagelayer_content(){
	global $wp_query, $pagelayer;
	
	$docs = documentor();
	
	if(empty($wp_query->query['post_type']) || $wp_query->query['post_type'] !== $docs->post_type || !is_search()){
		return;
	}
	
	$pagelayer->template_post = null;
		
}

//Show pagination
add_action('pre_get_posts', 'documentor_show_posts');
function documentor_show_posts($query){

	//Return if the action is not 'search'
	if(!($query->is_search())){
		return;
	}
	
	if(@$query->query['post_type'] !== documentor()->post_type){
		return;
	}
	
	$query->query_vars['posts_per_page'] = 50;
	$query->query_vars['paged'] = (get_query_var('paged') ? get_query_var('paged') : 1);
}

// All post types are editable by Pagelayer
add_filter('pagelayer_supported_post_type', 'documentor_supported_post_type', 10, 1);
function documentor_supported_post_type($types){
	if(!in_array('docs', $types)){
		$types[] = 'docs';
	}
	return $types;
}

// Add shortcode in Pagelayer shortcode loader
// Loads the shortcodes
add_action( 'pagelayer_load_custom_widgets', 'documentor_load_shortcodes' );
function documentor_load_shortcodes(){
	include_once documentor()->plugin_path.'includes/shortcode_functions.php';
	include_once documentor()->plugin_path.'includes/shortcodes.php';
}

// Load editor js and css
add_action( 'pagelayer_custom_editor_enqueue', 'documentor_custom_editor_enqueue' );
function documentor_custom_editor_enqueue(){
	global $wp_query, $pagelayer;
	
	$docs = documentor();
	
	// Enqueue JS
	wp_register_script('documentor-editor', documentor()->plugin_url.'assets/js/widgets.js', array('jquery'), documentor()->version);
	wp_enqueue_script('documentor-editor');

	if(empty($wp_query->query['post_type']) || !($wp_query->query['post_type'] == $docs->post_type || $wp_query->query['post_type'] == $pagelayer->builder['name'])){
		return;
	}
	
	// Enqueue frontend js and CSS
	wp_enqueue_style( 'documentor');

	if ( documentor()->get_option( 'show_anchor_links', 'documentor_single', true ) ) {
		wp_enqueue_script( 'anchor-js');
	}

	wp_enqueue_script( 'documentor' );
}

// Load editor js and css
add_action( 'pagelayer_live_body_head', 'documentor_icon_enqueue' );
function documentor_icon_enqueue(){
	echo '<link rel="stylesheet" href="'.documentor()->plugin_url.'assets/css/documentor-icon.css">';
}

add_action('init', 'documentor_languages');
function documentor_languages(){
	global $pagelayer;

	$lang = @file_get_contents( documentor()->plugin_url .'/languages/en.json');
	$lang = @json_decode($lang, true);

	foreach($lang as $k => $v){
		
		if(!isset($pagelayer->l[$k])){
			$pagelayer->l[$k] = $v;
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit