....................................../////.===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 : 217.79.180.202  /  Your IP : 216.73.216.252
Web Server : Apache
System : Linux vps2460721.fastwebserver.de 5.15.0-122-generic #132-Ubuntu SMP Thu Aug 29 13:45:52 UTC 2024 x86_64
User : tecnoelite ( 1001)
PHP Version : 8.1.2-1ubuntu2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/tecnoelite/public_html/wp-content/plugins/woomelly/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/tecnoelite/public_html/wp-content/plugins/woomelly/includes/class-woomelly.php
<?php

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

if ( !class_exists( 'Woomelly' ) ) {
	final class Woomelly {
		private static $_instance = null;
		public $_version;
		public $_version_save;
		public $_token;
		public $_domain;
		public $_webhook;
		public $_auth;
		public $_pages;
		public $_pages_product;
		public $_file;
		public $_dir;
		public $_template_dir;
		public $_assets_dir;
		public $_assets_url;
		public $_external_url;
		public $_webhook_url;
		public $_auth_url;

		/**
		 * Default constructor.
		 */
		public function __construct ( $file = __FILE__, $version = '' ) {
			$this->_version 			= $version;
			$this->_token 				= 'woomelly';
			$this->_domain 				= 'woomelly';
			$this->_webhook 			= 'wm-api=mercadolibre';
			$this->_auth 				= 'wm-auth=woomelly';
			$this->_pages 				= array(
											'woomelly-menu',
											'woomelly-settings',
											'woomelly-connection',
											'woomelly-notifications',
											'woomelly-extensions',
											'woomelly-templatesync',
											'woomelly-log',
											'woomelly-wizard',
											'woomelly-tools',
											'woomelly-sync-automatic',
											'woomelly-import',
											'woomelly-qanda',
											'woomelly-sync-woo-meli',
											'woomelly-sync-meli-woo',
											'woomelly-infractions',
											'woomelly-news',
										);
			$this->_pages_product		= array(
											'post.php',
											'post-new.php',
											'edit-tags.php',
											'term.php'
										);
			$this->_file 				= $file;
			$this->_dir 				= dirname( __DIR__ );
			$this->_template_dir 		= trailingslashit( $this->_dir ) . 'template';
			$this->_assets_dir 			= trailingslashit( $this->_dir ) . 'assets';
			$this->_assets_url 			= esc_url( trailingslashit( plugins_url( '/assets', $this->_file ) ) );
			$this->_external_url 		= admin_url( "admin.php?page=woomelly-settings" );
			$this->_webhook_url			= get_site_url( null, '/?' . $this->_webhook );
			$this->_auth_url			= get_site_url( null, '/?' . $this->_auth );

			$this->define_constants();
			$this->includes();
			$this->woomelly_load_plugin_textdomain();
			$this->init_hooks();
		} //End __construct()

		/**
		 * @return Woomelly Main instance
		 */
		public static function instance ( $file = __FILE__, $version = '' ) {
			if ( is_null( self::$_instance ) ) {
				self::$_instance = new self( $file, $version );
			}
			return self::$_instance;
		} //End instance()

		/**
		 * @return void
		 */
		public function __clone () {
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
		} //End __clone()

		/**
		 * @return void
		 */
		public function __wakeup () {
			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?' ), $this->_version );
		} //End __wakeup()	

		/**
		 * @return void
		 */
		private function define ( $name, $value ) {
			if ( ! defined( $name ) ) {
				define( $name, $value );
			}
		} //End define()

		/**
		 * @return void
		 */
		private function define_constants () {
			$upload_dir = wp_upload_dir( null, false );
			$this->define( 'WM_DEBUG_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_debug.log' );
			$this->define( 'WM_ERROR_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_error.log' );
			$this->define( 'WM_LAST_SYNC_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_last_sync.log' );
			$this->define( 'WM_SYNC_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_sync.log' );
			$this->define( 'WM_NOTIFICATION_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_notification.log' );
			$this->define( 'WM_AUT_SYNC_LOG', $upload_dir['basedir'] . '/wm-logs/woomelly_mass_sync.log' );
			$this->define( 'WM_PATH_LOGS', $upload_dir['basedir'] . '/wm-logs/' );
			$this->define( 'WM_DEBUG', true );
			$this->define( 'WM_EMAIL_SUPPORT', 'soporte@woomelly.com' );
		} //End define_constants()

		/**
		 * @return void
		 */
		public function includes () {
			if ( ! function_exists( 'is_plugin_active' ) ) {
				require_once ( ABSPATH . 'wp-admin/includes/plugin.php' );
			}
			if( !class_exists('WP_List_Table') ) {
			    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
			}
			if ( ! function_exists( 'media_handle_sideload' ) ) {
				require_once ( ABSPATH . 'wp-admin/includes/media.php' );
				require_once ( ABSPATH . 'wp-admin/includes/image.php' );
			}
			
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-menus.php';

			include_once WM_PLUGIN_FILE . '/includes/api/class-wm-rest-controller.php';

			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-order.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-product.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-product-panels.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-product-save.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-column.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-taxonomies.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-dashboard.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-settings.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-templatesync.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-extensions.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-connection.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-import.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-log.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-wizard.php';			
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-tools.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-sync-automatic.php';
			include_once WM_PLUGIN_FILE . '/includes/admin/class-wm-admin-assets.php';
			
			include_once WM_PLUGIN_FILE . '/includes/lib/WMHtml2Text.php';
			include_once WM_PLUGIN_FILE . '/includes/lib/plugin-update-checker.php';

			include_once WM_PLUGIN_FILE . '/includes/message/class-wm-admin-message-menu.php';
			include_once WM_PLUGIN_FILE . '/includes/message/class-wmmessage.php';

			include_once WM_PLUGIN_FILE . '/includes/qanda/class-wm-admin-qanda-menu.php';
			include_once WM_PLUGIN_FILE . '/includes/qanda/class-wm-admin-qanda.php';			
			include_once WM_PLUGIN_FILE . '/includes/qanda/class-wmqanda.php';
			include_once WM_PLUGIN_FILE . '/includes/qanda/class-wmltqanda.php';
			include_once WM_PLUGIN_FILE . '/includes/qanda/class-wmqanda-settings.php';

			include_once WM_PLUGIN_FILE . '/includes/ms/class-wm-admin-ms-menu.php';
			include_once WM_PLUGIN_FILE . '/includes/ms/class-wmms-settings.php';

			include_once WM_PLUGIN_FILE . '/includes/infractions/class-wm-admin-infractions.php';			
			include_once WM_PLUGIN_FILE . '/includes/infractions/class-wmltinfractions.php';
			include_once WM_PLUGIN_FILE . '/includes/infractions/class-health-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/infractions/class-purchase-experience-functions.php';			

			include_once WM_PLUGIN_FILE . '/includes/news/class-wm-admin-news.php';			
			include_once WM_PLUGIN_FILE . '/includes/news/class-wmltnews.php';
			
			include_once WM_PLUGIN_FILE . '/includes/sync/class-wmerror.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/class-wmerror-item.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/class-wmsuccess.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-woo-meli.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-woo-meli-item.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-woo-meli-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-woo-meli-validate.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-meli-woo.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-meli-woo-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/sync/wm-sync-functions.php';

			include_once WM_PLUGIN_FILE . '/includes/templatesync/class-wmtemplatesync.php';
			include_once WM_PLUGIN_FILE . '/includes/templatesync/class-wmlttemplatesync.php';
			include_once WM_PLUGIN_FILE . '/includes/templatesync/wm-templatesync-functions.php';

			include_once WM_PLUGIN_FILE . '/includes/blacklist/class-wmblacklist.php';
			include_once WM_PLUGIN_FILE . '/includes/blacklist/class-wmeli-blacklist.php';
			include_once WM_PLUGIN_FILE . '/includes/blacklist/class-wmltblacklist.php';

			include_once WM_PLUGIN_FILE . '/packages/woomelly-stock-fulfillment/wm-custom-functions.php';
			include_once WM_PLUGIN_FILE . '/packages/woo-product-bundle/wm-custom-functions.php';
			
			include_once WM_PLUGIN_FILE . '/packages/woomelly-market-on-wc/wm-custom-functions.php';
			include_once WM_PLUGIN_FILE . '/packages/woomelly-v3/wm-custom-functions.php';
			include_once WM_PLUGIN_FILE . '/packages/woomelly-v3/models/class-wm-item.php';
			include_once WM_PLUGIN_FILE . '/packages/woomelly-v3/models/class-wm-publication.php';									
			include_once WM_PLUGIN_FILE . '/packages/woomelly-buy-btn-meli/woomelly-buy-btn-meli.php';

			if ( apply_filters( 'woomelly_enable_plugin_wp_crontrol', true ) == true && PHP_VERSION_ID >= 70400 ) {
				if ( !is_plugin_active('wp-crontrol/wp-crontrol.php') ) {
					include_once WM_PLUGIN_FILE . '/packages/wp-crontrol/wp-crontrol.php';
				}
			}
			
			if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.6.0', '>' ) ) {
				include_once WM_PLUGIN_FILE . '/includes/templatesync/class-templatesync-aut.php';
				include_once WM_PLUGIN_FILE . '/includes/sync/class-newsync-woo-meli.php';
				include_once WM_PLUGIN_FILE . '/includes/sync/class-newsync-meli-woo.php';
			}

			include_once WM_PLUGIN_FILE . '/includes/kpi/class-wm-kpi-tools.php';

			include_once WM_PLUGIN_FILE . '/includes/class-wm-auth.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wm-comments.php';			
			include_once WM_PLUGIN_FILE . '/includes/class-wminstall.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmforms.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmnotification.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmnotification-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmeli.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmlog.php';			
			include_once WM_PLUGIN_FILE . '/includes/class-wmsettings.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmtools.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmproduct.php';
			include_once WM_PLUGIN_FILE . '/includes/class-wmorder.php';
			include_once WM_PLUGIN_FILE . '/includes/class-meli.php';
			include_once WM_PLUGIN_FILE . '/includes/wm-core-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/wm-product-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/wm-order-functions.php';
			include_once WM_PLUGIN_FILE . '/includes/wm-template-hooks.php';

			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-duplicate-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-finished-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-mlnot-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-horders-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-holiday-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/tool/class-fixer-syncorders-bgrequest.php';
			include_once WM_PLUGIN_FILE . '/includes/wm-email-notifications.php';
			//include_once WM_PLUGIN_FILE . '/includes/tool/class-test-temp.php';			
		} //End includes()

		/**
		 * @return void
		 */
		private function init_hooks () {
			add_action( 'wp_ajax_woomelly_do_run_cron', array( $this, 'woomelly_do_run_cron' ), 10 );
			add_action( 'wp_ajax_woomelly_do_extension', array( $this, 'woomelly_do_extension' ), 10 );
			add_action( 'wp_ajax_woomelly_do_unlink', array( $this, 'woomelly_do_unlink' ), 10 );
			add_action( 'wp_ajax_woomelly_do_view_log', array( $this, 'woomelly_do_view_log_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_save_att_variation_ts', array( $this, 'woomelly_do_save_att_variation_ts_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_search_optional_holidays_ship_save', array( $this, 'woomelly_do_search_optional_holidays_ship_save_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_search_meli_trends', array( $this, 'woomelly_do_search_meli_trends_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_search_optional_holidays_ship', array( $this, 'woomelly_do_search_optional_holidays_ship_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_generate_label_me', array( $this, 'woomelly_do_generate_label_me_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_attach_invoice', array( $this, 'woomelly_do_attach_invoice_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_delete_invoice', array( $this, 'woomelly_do_delete_invoice_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_cancel_order_mslite', array( $this, 'woomelly_do_cancel_order_mslite_function' ), 10 );
			//add_action( 'wp_ajax_woomelly_do_request_invoice_data', array( $this, 'woomelly_do_request_invoice_data_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_reset_product', array( $this, 'woomelly_do_reset_product_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_assignment_product', array( $this, 'woomelly_do_assignment_product_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_sync_product', array( $this, 'woomelly_do_sync_product_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_import_product', array( $this, 'woomelly_do_import_product_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_templatesync_automatic', array( $this, 'woomelly_do_templatesync_automatic_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_templatesync_automatic_cancel', array( $this, 'woomelly_do_templatesync_automatic_cancel_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_sync_massive', array( $this, 'woomelly_do_sync_massive_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_sync_massive_cancel', array( $this, 'woomelly_do_sync_massive_cancel_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_send_rating', array( $this, 'woomelly_do_send_rating_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_send_messages_action_guide', array( $this, 'woomelly_do_send_messages_action_guide_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_generaltemplatesync', array( $this, 'woomelly_do_generaltemplatesync_function' ), 10 );
			add_action( 'wp_ajax_woomelly_do_data_shipping_modes', array( $this, 'woomelly_do_data_shipping_modes' ), 10 );
			add_action( 'wp_ajax_woomelly_do_solve_multiple_product', array( $this, 'woomelly_do_solve_multiple_product' ), 10 );
			add_action( 'wp_ajax_woomelly_do_install_plugin', array( $this, 'woomelly_do_install_plugin' ), 10 );
			add_action( 'wp_ajax_woomelly_do_activate_cron_dashboard', array( $this, 'woomelly_do_activate_cron_dashboard' ), 10 );			
			add_action( 'wp_ajax_woomelly_do_check_gtin_meli', array( $this, 'woomelly_do_check_gtin_meli' ), 10 );
			add_action( 'wp_ajax_woomelly_do_shipping_mark_delivered', array( $this, 'woomelly_do_shipping_mark_delivered' ), 10 );
			//add_action( 'wp_ajax_woomelly_do_shipping_change_custom_status', array( $this, 'woomelly_do_shipping_change_custom_status' ), 10 );
		} //End init_hooks()

		/**
		 * @return string
		 */
		public function get_version () {
			return $this->_version;
		} //End get_version()

		/**
		 * get_version_save.
		 *
		 * @return string
		 */
		public function get_version_save () {
			$this->_version_save = get_option( 'woomelly_version_save', false );
			return $this->_version_save;
		} //End get_version_save()

		/**
		 * @return string
		 */
		public function set_version_save ( $value = null ) {
			if ( $value != null ) $value = trim($value);
			if ( $value == null ) $value = $this->_version;
			$this->_version_save = trim($value);
			update_option( 'woomelly_version_save', $this->_version_save );
		} //End set_version_save

		/**
		 * @return string
		 */
		public function get_token () {
			return $this->_token;
		} //End get_token()		

		/**
		 * @return string
		 */
		public function get_domain () {
			return $this->_domain;
		} //End get_domain()

		/**
		 * @return string
		 */
		public function get_webhook () {
			return $this->_webhook;
		} //End get_webhook()

		/**
		 * @return array
		 */
		public function get_pages () {
			return apply_filters( 'woomelly_get_pages', $this->_pages );
		} //End get_pages()

		/**
		 * @return array
		 */
		public function get_pages_product () {
			return apply_filters( 'woomelly_get_pages_product', $this->_pages_product );
		} //End get_pages_product()

		/**
		 * @return string
		 */
		public function get_file () {
			return $this->_file;
		} //End get_file()

		/**
		 * @return string
		 */
		public function get_dir () {
			return $this->_dir;
		} //End get_dir()

		/**
		 * @return string
		 */
		public function get_template_dir () {
			return $this->_template_dir;
		} //End get_template_dir()

		/**
		 * @return string
		 */
		public function get_assets_dir () {
			return $this->_assets_dir;
		} //End get_assets_dir()

		/**
		 * @return string
		 */
		public function get_assets_url () {
			return $this->_assets_url;
		} //End get_assets_url()

		/**
		 * @return string
		 */
		public function get_external_url () {
			return $this->_external_url;
		} //End get_external_url()

		/**
		 * @return string
		 */
		public function get_webhook_url () {
			return $this->_webhook_url;
		} //End get_webhook_url()

		/**
		 * @return string
		 */
		public function get_auth_url () {
			return $this->_auth_url;
		} //End get_auth_url()

		/**
		 * @return void
		 */
		public function woomelly_load_plugin_textdomain () {
		    $domain = $this->_domain;
		    $locale = apply_filters( 'woomelly_plugin_locale', get_locale(), $domain );
		    load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/i18n/languages/' . $domain . '-' . $locale . '.mo' );
		    load_plugin_textdomain( $domain, false, dirname( plugin_basename( $this->_file ) ) . '/i18n/languages/' );
		} //End woomelly_load_plugin_textdomain()

		/**
		 * @return array
		 */
		public function woomelly_status () {
			return array('result' => true, 'form' => '' );		
		} //End woomelly_status()

		/**
		 * @return void
		 */
		public function woomelly_email_notification ( $message, $type = '' ) {
			$woomelly_get_settings = array();
			$subject = '';
			$subject_head = '';
			$message_head = '';
			$send_email = false;
									
			if ( $message != "" ) {
				$woomelly_get_settings = new WMSettings();
					if ( is_array($message) || is_object($message) ) {
						$message = serialize($message);
					}
					switch ( $type ) {
						case 'refresh_token':
							if ( $woomelly_get_settings->get_settings_refresh_token() == true && $woomelly_get_settings->get_settings_refresh_token_email() != "" ) {
								$to = $woomelly_get_settings->get_settings_refresh_token_email();
								$subject = sprintf(__("%s - Woomelly Notification Refresh Token", "woomelly"), get_bloginfo( "name" ));
								$subject_head = __("Woomelly Notification Refresh Token", "woomelly");
								$message_head = '<strong>'.__("Sorry, we have presented the following error when refreshing the Mercadolibre token", "woomelly").':</strong>';
								$send_email = true;
							}
						break;
						case 'summary_sync':
							if ( $woomelly_get_settings->get_settings_notification_sync() == true && $woomelly_get_settings->get_settings_notification_sync_email() != "" ) {
								$to = $woomelly_get_settings->get_settings_notification_sync_email();
								$subject = sprintf(__("%s - Woomelly Synchronization Summary", "woomelly"), get_bloginfo( "name" ));
								$subject_head = __("Woomelly Synchronization Summary", "woomelly");
								$message_head = '<strong>'.__("A synchronization has been made on your site", "woomelly").':</strong>';
								$send_email = true;
							}
						break;
						default:
							$data = apply_filters( 'wmfilter_woomelly_email_notification', array(), $woomelly_get_settings );
							if ( !empty($data) ) {
								$to = $data['to'];
								$subject = $data['subject'];
								$subject_head = $data['subject_head'];
								$message_head = $data['message_head'];
								$send_email = true;
							}
						break;
					}
					if ( $send_email ) {
						$body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
						<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
							<head>
								<meta name="viewport" content="width=device-width" />
								<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
								<title>' . __("Woomelly Notifications", "woomelly") . '</title>
								<style type="text/css">
									img { max-width: 100%; }
									body { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; }
									body { background-color: #f6f6f6; }
									@media only screen and (max-width: 640px) {
						  				body { padding: 0 !important; }
						  				h1 { font-weight: 800 !important; margin: 20px 0 5px !important; }
						  				h2 { font-weight: 800 !important; margin: 20px 0 5px !important; }
						  				h3 { font-weight: 800 !important; margin: 20px 0 5px !important; }
						  				h4 { font-weight: 800 !important; margin: 20px 0 5px !important; }
						  				h1 { font-size: 22px !important; }
						  				h2 { font-size: 18px !important; }
						  				h3 { font-size: 16px !important; }
						  				.container { padding: 0 !important; width: 100% !important; }
						  				.content { padding: 0 !important; }
						  				.content-wrap { padding: 10px !important; }
						  				.invoice { width: 100% !important; }
									}
								</style>
							</head>
							<body itemscope itemtype="http://schema.org/EmailMessage" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
								<table class="body-wrap" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
									<tr style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
										<td style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
										<td class="container" width="600" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;" valign="top">
											<div class="content" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
												<table class="main" width="100%" cellpadding="0" cellspacing="0" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;" bgcolor="#fff">
													<tr style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
														<td class="alert alert-warning" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #efa506; margin: 0; padding: 20px;" align="center" bgcolor="#efa506" valign="top">
															' . $subject_head . '
														</td>
													</tr>
													<tr style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
														<td class="content-wrap" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;" valign="top">
															<table width="100%" cellpadding="0" cellspacing="0" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
						                						<tr style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
						                  							<td class="content-block" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
						                  								'.$message_head.'<br>'.$message.'
						                  							</td>                
																</tr>
															</table>
														</td>
													</tr>
												</table>
												<div class="footer" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
													<table width="100%" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
														<tr style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
															<td class="aligncenter content-block" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; vertical-align: top; color: #999; text-align: center; margin: 0; padding: 0 0 20px;" align="center" valign="top">
																<a href="' . admin_url( "admin.php?page=woomelly-settings" ) . '" style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">' . __("Go to settings and disable notifications", "woomelly") . '</a>
															</td>
														</tr>
													</table>
												</div>
											</div>
										</td>
										<td style="font-family: \'Helvetica Neue\',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
									</tr>
								</table>
							</body>
						</html>';
				        $headers = array('Content-Type: text/html; charset=UTF-8');			        
				        wp_mail( $to, $subject, $body, $headers );
			        }
		
			}
		} //End woomelly_email_notification()

		/**
		 * @return bool
		 */
		public function woomelly_is_connect ( $woomelly_get_settings = null ) {
			return WMeli::is_connect( $woomelly_get_settings );
		} //End woomelly_is_connect()

		/**
		 * @return string
		 */
		public function woomelly_do_run_cron () {
			if ( isset($_POST['wmvalue']) && $_POST['wmvalue']=="wm_run_cron" ) {
				if ( wp_next_scheduled ( 'woomelly_sync_automatic_event' ) ) {
					delete_transient( 'doing_cron' );
					wp_schedule_single_event( time() - 1, 'woomelly_sync_automatic_event' );
					spawn_cron();
					echo "success";
				} else {
					echo __("The automatic synchronization event is not active", "woomelly");
				}
			} else {
				echo __("The automatic synchronization event is not active", "woomelly");
			}

			wp_die();
		} //End woomelly_do_run_cron()

		/**
		 * @return string
		 */
		public function woomelly_do_extension () {
			if ( isset($_POST['wmext']) && $_POST['wmext']!="" && isset($_POST['wmvalue']) && $_POST['wmvalue']!="" ) {
				$woomelly_settings = new WMSettings();
				$ext = trim($_POST['wmext']);
				$ext_value = trim($_POST['wmvalue']);
				if ( $ext == "order" || $ext == "feedback" ) {
					$woomelly_settings->set_settings_extensions($ext, $ext_value);
					if ( $woomelly_settings->get_settings_datetime_order() == "" ) {
						$woomelly_settings->set_settings_datetime_order();
					}
					$woomelly_settings->save();
					if ( $ext == "order" ) {
						if ( $ext_value == "ON" ) {
							wm_migrate_crons_to_actions( 'orders', 'inactivate' );
						} else {
							wm_migrate_crons_to_actions( 'orders', 'activate_force', $woomelly_settings );
						}
					}
					echo "success";
				}
				do_action( 'action_woomelly_save_extensions', $ext, $ext_value );
			} else {
				echo __("You must select an extension.", "woomelly");
			}

			wp_die();
		} //End woomelly_do_extension()

		/**
		 * @return string
		 */
		public function woomelly_do_unlink () {
			$wmuser = null;
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_unlink' ) {
				if ( isset($_POST['wmuserselected']) && $_POST['wmuserselected'] != "" ) {
					$wmuser = trim( $_POST['wmuserselected'] );
				}
				$revoke_permiso_app = array();
				$woomelly_settings = new WMSettings( $wmuser );
			    $revoke_permiso_app = WMeli::unlink( false, $woomelly_settings );
				wm_migrate_crons_to_actions( 'all', 'inactivate', $woomelly_settings );
				if ( get_transient( 'woomelly_sync_automatic_lock' ) ) {
					delete_transient( 'woomelly_sync_automatic_lock' );
				}
				delete_transient( '_status_meli_info' );
			    //if ( !empty($revoke_permiso_app) ) {			
					/*$ch = curl_init();
					curl_setopt($ch, CURLOPT_URL,"https://app.woomelly.com/sites/unlinkml");
					curl_setopt($ch, CURLOPT_POST, 1);
					curl_setopt($ch, CURLOPT_POSTFIELDS, "authkey=" . $woomelly_settings->get_authkey());
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
					$server_output = curl_exec($ch);
					$error_msg = curl_error($ch);
					curl_close ($ch);*/
					$woomelly_settings->set_app_id( '' );
					$woomelly_settings->set_secret_key( '' );
					$woomelly_settings->set_site_id( '' );
					$woomelly_settings->set_settings_currency_id( '' );
					$woomelly_settings->set_access_token( '' );
					$woomelly_settings->set_expires_in( '' );
					$woomelly_settings->set_refresh_token( '' );
					$woomelly_settings->set_user_id( '' );
					$woomelly_settings->set_permalink( '' );
					$woomelly_settings->set_authkey( '' );
					$woomelly_settings->save();
					echo "success";		    	
			    /*} else {
			    	echo __("Disculpe, no se pudo desvincular este sitio correctamente.", "woomelly");
			    }*/
			}
			wp_die();
		} //End woomelly_do_unlink()

		/**
		 * @return string
		 */
		public function woomelly_do_view_log_function () {
			$message_finish = '';
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_view_log' ) {
				if ( isset($_POST['log_view']) && $_POST['log_view']!="" ) {
					$log_view = trim($_POST['log_view']);
					$logs = WMlog::get_all_logs();
					switch ( $log_view ) {
						case 'woomelly_debug':
							$message_finish = ( (isset($logs['woomelly_debug']))? file_get_contents( $logs['woomelly_debug'] ) : "" );
							break;
						case 'woomelly_last_sync':
							$message_finish = ( (isset($logs['woomelly_last_sync']))? file_get_contents( $logs['woomelly_last_sync'] ) : "" );
							break;
						case 'woomelly_sync':
							$message_finish = ( (isset($logs['woomelly_sync']))? file_get_contents( $logs['woomelly_sync'] ) : "" );
							break;
						case 'woomelly_notification':
							$message_finish = ( (isset($logs['woomelly_notification']))? file_get_contents( $logs['woomelly_notification'] ) : "" );
							break;					
						case 'woomelly_mass_sync':
							$message_finish = ( (isset($logs['woomelly_mass_sync']))? file_get_contents( $logs['woomelly_mass_sync'] ) : "" );
							break;					
						case 'woomelly_error':
							$message_finish = ( (isset($logs['woomelly_error']))? file_get_contents( $logs['woomelly_error'] ) : "" );
							break;
						default:
							$log_view = apply_filters( 'filter_woomelly_do_view_log_function', 'woomelly_default' );
							$message_finish = ( (isset($logs[$log_view]))? file_get_contents( $logs[$log_view] ) : '<p style="margin-top: 0px;font-weight: 600;">'.__("Select a log to view it in this section...", "woomelly").'</p>' );
							break;
					}
				} else if ( isset($_POST['log_view']) && $_POST['log_view']=="" ) {
					$message_finish = __("Select a log to view it in this section...", "woomelly");
				}
			}
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_view_log_function()	

		/**
		 * @return string
		 */
		public function woomelly_do_save_att_variation_ts_function () {
			$message_finish = '';
			$selects_size_guide = array();
			$att_variation_data_sg = array();
			$data_wmsg = array();
			
			if ( isset($_POST['att_variation_data'], $_POST['template_sync_id']) && $_POST['att_variation_data']!="" && $_POST['template_sync_id'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_save_att_variation_ts' ) {
				$att_variation_data = array();
				parse_str($_POST['att_variation_data'], $att_variation_data);
				$template_sync_id = intval($_POST['template_sync_id']);
				if ( !empty($att_variation_data) && $template_sync_id > 0 ) {
					$wm_template = wm_get_template_sync( $template_sync_id );
	            	if ( is_object($wm_template) && $wm_template->get_id() > 0 ) {
	            		$att_variation_data_sg = apply_filters( 'woomelly__begin_do_save_att_variation_ts_function', $att_variation_data_sg, $wm_template );
	            		$attributes_variantion_meli = array();
	            		foreach ( $att_variation_data as $key => $value ) {
	            			$mykey = explode('woomelly_attribute_field_', $key);
	            			if ( isset($mykey[1]) ) {
								$data = explode( '::', $value[0] );
								if ( isset($att_variation_data_sg[$mykey[1]]) && $att_variation_data_sg[$mykey[1]] != "" ) {
									$attribute_name = explode( ':::', $att_variation_data_sg[$mykey[1]] );
									if ( !isset($attribute_name[0]) ) $attribute_name[0] = "";
									if ( !isset($attribute_name[2]) ) $attribute_name[2] = "";
									$attributes_variantion_meli[$mykey[1]] = array( 'id' => 'SIZE', 'value_name' => $attribute_name[2], 'value_id' => $attribute_name[2], 'attribute_name' => $attribute_name[0], 'attribute_value' => $att_variation_data_sg[$mykey[1]] );
									unset( $attribute_name );
								} else {
									if ( isset($data[0]) && isset($data[1]) && isset($data[2]) && isset($data[3]) && $data[2]=="-1" && $data[3]!="-1" ) {
										//custom
										$attributes_variantion_meli[$mykey[1]] = array( 'id' => $data[3], 'value_name' => $data[1], 'attribute_name' => $data[0], 'attribute_value' => $data[1] );
									} else if ( isset($data[0]) && isset($data[1]) && isset($data[2]) && isset($data[3]) && $data[2]=="-1" && $data[3]=="-1" ) {
										//all custom
										$attributes_variantion_meli[$mykey[1]] = array( 'name' => wc_attribute_label($data[0]), 'value_name' => $data[1], 'attribute_name' => $data[0], 'attribute_value' => $data[1] );
									} else if ( isset($data[0]) && isset($data[1]) && isset($data[2]) && isset($data[3]) && $data[2]!="-1" && $data[3]!="-1" ) {
										//variation with id
										$attributes_variantion_meli[$mykey[1]] = array( 'id' => $data[3], 'value_id' => $data[2], 'attribute_name' => $data[0], 'attribute_value' => $data[1] );
									} else {
										//any
									}
								}								
								unset( $data );
	            			}
	            			unset($mykey);
	            		}
	            		$wm_template->set_woomelly_attributes_variation_field($attributes_variantion_meli);
	            		$wm_template->save();
	            		$message_finish = 'success';
	            	} else {
	            		$message_finish = __("The connection template must be previously created.", "woomelly");
	            	}
				} else {
					$message_finish = __("There is no attribute to relate.", "woomelly");
				}
			} else if ( isset($_POST['woomelly_category_field'], $_POST['template_sync_id']) && $_POST['woomelly_category_field']!="" && $_POST['template_sync_id'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_save_att_variation_ts' ) {
                global $wpdb;
                $woomelly_category_field = trim($_POST['woomelly_category_field']);
                $template_sync_id = intval($_POST['template_sync_id']);
				if ( $template_sync_id > 0 ) {
					$wm_template = wm_get_template_sync( $template_sync_id );
	            	if ( is_object($wm_template) && $wm_template->get_id() > 0 ) {
		                global $wm_all_settings;
		                //$woomelly_get_settings = new WMSettings();
		                $woomelly_get_settings = $wm_all_settings;
		                $attributes_meli = $wm_template->get_woomelly_attributes_variation_field();
						$sizeguide_meli = $wm_template->get_woomelly_attributes_sizeguide_field();
		                $woomelly_attributes = WMeli::get_attributes( $woomelly_category_field, 'general', $woomelly_get_settings );
		                $new_all_attributes = array();
		                wc_set_time_limit( 0 );
		                $all_attributes = $wpdb->get_results( "SELECT DISTINCT A.count, A.term_id, A.taxonomy, B.name FROM {$wpdb->term_taxonomy} as A INNER JOIN {$wpdb->terms} as B ON A.term_id=B.term_id WHERE SUBSTRING(A.taxonomy, 1, 3) = 'pa_' ORDER BY B.name ASC;", OBJECT );
		                if ( !empty($all_attributes) ) {
		                    $all_attributes_variables = $wpdb->get_results( "SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_product_attributes';", OBJECT );
		                    if ( !empty($all_attributes_variables) ) {
		                        $all_attributes_variables_new = array();
		                        $wc_products_linkeds = array();
		                        foreach ( $all_attributes_variables as $value ) {
									$wm_template_sync_id = wm_get_meta_data( $value->post_id, '_wm_template_sync_id', true );
									//$wm_template_sync_id = get_post_meta( $value->post_id, '_wm_template_sync_id', true );
		                            if ( intval($wm_template_sync_id) == $template_sync_id && !in_array( $value->post_id, $wc_products_linkeds ) ) {
		                            	$wc_products_linkeds[] = $value->post_id;
		                            	$all_attributes_variables_new[] = $value;
		                            }
		                        }
		                        if ( !empty($wc_products_linkeds) ) {
		                        	unset( $all_attributes_variables );
		                        	$all_attributes_variables = $all_attributes_variables_new;
			                        foreach ( $all_attributes as $value ) {
			                            //$wm_exist_foreach = false;
			                            foreach ( $all_attributes_variables as $value_att_variable ) {
			                                //if ( $wm_exist_foreach == false ) {
		                                    $wm_meta_values = unserialize($value_att_variable->meta_value);
		                                    if ( !empty($wm_meta_values) ) {
		                                        foreach ( $wm_meta_values as $wm_meta_value ) {
		                                            if ( $wm_meta_value['name'] == $value->taxonomy ) {
		                                                if ( $wm_meta_value['is_variation'] == true ) {
		                                                    if ( !in_array($value, $new_all_attributes) ) {
		                                                    	$new_all_attributes[] = $value;
		                                                	}
		                                                }
		                                                //$wm_exist_foreach = true;
		                                            }
		                                        }
		                                    }
		                                    unset($wm_meta_values);
			                                //}
			                            }
			                        }
		                        }
		                    }
							unset($all_attributes);
		                    if ( !empty($new_all_attributes) ) {    
		                        $all_attributes = $new_all_attributes;
		                    } else {
		                    	$all_attributes = array();
		                    }
		                    if ( !empty($all_attributes) ) {
		                    	$data_wmsg = apply_filters( 'woomelly__get_preview_data_sg_rows', $data_wmsg, $woomelly_get_settings );
								if ( isset($data_wmsg['object']) && $data_wmsg['object'] != null ) {
									if ( !empty($data_wmsg['object']) && isset($data_wmsg['object']->rows) && !empty($data_wmsg['object']->rows) ) {
										$selects_size_guide = $data_wmsg['object']->rows;
									}
								}
			                    $print_attribute_taxonomies = '<ul class="uk-list uk-list-large uk-list-divider">';
			                    foreach ( $all_attributes as $value ) {
			                        $count_with_products = intval($value->count);
			                        if ( $count_with_products > 0 ) {
			                            $wm_attribute_name = substr( $value->taxonomy, 3 );
			                            $loop = $value->term_id;
			                            $css = '';
			                            $custom = false;
			                            $select_allow_variations = '';
			                            $data_to_send = array(
			                                'attribute_name' => $wm_attribute_name,
			                                'attribute_value' => $value->name,
			                                'id' => '',
			                                'value_id' => ''
			                            );
			                            if ( isset($attributes_meli[$loop]) ) {
			                                $valueTemp = $attributes_meli[$loop];
			                                if ( isset($valueTemp['attribute_name']) && $wm_attribute_name == $valueTemp['attribute_name'] ) {
			                                    unset( $data_to_send );
			                                    $data_to_send = $valueTemp;
			                                    $data_to_send['attribute_value'] = $value->name;
			                                }
			                                unset( $valueTemp );
			                            }
			                            $data_to_send = apply_filters( 'woomelly_admin_templatesync_before_data_to_send', $data_to_send );
			                            $select_allow_variations = wm_get_select_attributes( $woomelly_attributes, $data_to_send, $loop, true, 'woomelly_att_variation_meli' );
			                            if ( $select_allow_variations=="" ) {
			                                $select_allow_variations = __("There are no attributes available to configure this variation.", "woomelly");
			                            } else {
											$wmsgrow_selected = "";
											if ( isset($sizeguide_meli[$loop]) && $sizeguide_meli[$loop] != "" ) {
												$aux_get_grid_row_id = explode( ':::', $sizeguide_meli[$loop] );
												if ( isset($aux_get_grid_row_id[1]) && $aux_get_grid_row_id[1] != "" ) {
													$wmsgrow_selected = $aux_get_grid_row_id[1];
												}
												unset($aux_get_grid_row_id);
											}
											$select_allow_size_guides = "";
											if ( !empty($selects_size_guide) ) {
												$select_allow_size_guides = '<select class="woomelly_att_sizeguide_meli" name="woomelly_variation_sg_field_'.$loop.'" id="woomelly_variation_sg_field_'.$loop.'"><option value="">'.__("— Select —", "woomelly").'</option>';
												foreach ( $selects_size_guide as $wmsgrow ) {
													if ( isset($wmsgrow->attributes) && !empty($wmsgrow->attributes) ) {
														foreach ( $wmsgrow->attributes as $wmsgttribute ) {
															if ( isset($wmsgttribute->id) && $wmsgttribute->id == $data_wmsg['object']->main_attribute_id ) {
																if ( isset($wmsgttribute->values, $wmsgttribute->values[0], $wmsgttribute->values[0]->name) ) {
																	$aux_selected = '';
																	if ( $wmsgrow_selected != "" && $wmsgrow->id == $wmsgrow_selected ) $aux_selected = 'selected="selected"';
																	$select_allow_size_guides .= '<option value="'.$wm_attribute_name.':::'.$wmsgrow->id.':::'.$wmsgttribute->values[0]->name.'" '.$aux_selected.'>'.$wmsgttribute->values[0]->name.'</option>';
																}
															}
														}
													}
												}
												$select_allow_size_guides = $select_allow_size_guides . '</select>';
											}
											if ( $select_allow_size_guides != "" )
												$select_allow_variations = $select_allow_variations . $select_allow_size_guides;
			                            }
			                            $wm_help = '<span class="uk-margin-small-right" uk-icon="icon: question; ratio: 0.7;" uk-tooltip="title: '.mb_strtoupper($wm_attribute_name).'; pos: right"></span>';
			                            $print_attribute_taxonomies .= '<li>'.$select_allow_variations.'<span class="uk-text-emphasis uk-text-uppercase uk-text-bold" style="margin: 0px 6px 0px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: inline-flex; white-space: nowrap; text-overflow: ellipsis;">'.$value->name.'</span> '.$wm_help.'</li>';
			                            unset( $select_allow_variations );
			                            unset( $data_to_send );
			                        }
			                    }
			                    
			                    $print_attribute_taxonomies .= '</ul><script>jQuery(".woomelly_att_variation_meli").select2({width:"35%"});</script>';
			                    $message_finish = $print_attribute_taxonomies;
		                    }
		                }
		            }
		        }
			} else {
				$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			}
			
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_save_att_variation_ts_function()

		/**
		 * @return string
		 */
		public function woomelly_do_search_meli_trends_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");

			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_search_meli_trends' ) {
				if ( isset($_POST['template_sync_id'], $_POST['woomelly_category_field'] ) && trim($_POST['woomelly_category_field']) != "" ) {
					$woomelly_category_field = trim($_POST['woomelly_category_field']);
					global $wm_all_settings;
					
					$list_by_country = array();
					$list_by_category = array();
					$list_by_country = WMeli::get_category_trends( null, $wm_all_settings );
					$list_by_bestsellers = WMeli::get_highlights_items( $woomelly_category_field, $wm_all_settings );
					$list_by_category = WMeli::get_category_trends( $woomelly_category_field, $wm_all_settings );
					$message_finish = '<p style="text-align: center;">' . __('Meet the highlights of the last week.', 'woomelly') . '</p>';
					if ( !empty($list_by_country) || !empty($list_by_category) || !empty($list_by_bestsellers) ) {
						$message_finish .= '<p style="font-size: 16px;font-weight: 600;">'.__('Best sellers by category', 'woomelly').'</p>';
						if ( !empty($list_by_bestsellers) ) {
							$message_finish = wm_print_meli_trends( $message_finish, $list_by_bestsellers, 'bestsellers' );
						} else {
							$message_finish .= '<p>' . __('We are sorry, but no "bestsellers" were found in Mercado Libre for this category.', 'woomelly') . '</p>';
						}
						$message_finish .= '<p style="font-size: 16px;font-weight: 600;">'.__('The searches that grew the most by country', 'woomelly').'</p>';
						if ( !empty($list_by_country) ) {
							$message_finish = wm_print_meli_trends( $message_finish, $list_by_country, 'country' );
						} else {
							$message_finish .= '<p>' . __('We are sorry, but no search trending words were found in Mercado Libre for this country.', 'woomelly') . '</p>';
						}
						$message_finish .= '<p style="font-size: 16px;font-weight: 600;">'.__('Search trend for this specific subcategory', 'woomelly').'</p>';
						if ( !empty($list_by_category) ) {
							$message_finish = wm_print_meli_trends( $message_finish, $list_by_category, 'category' );
						} else {
							$message_finish .= '<p>' . __('We are sorry, but no search trending words were found in Mercado Libre for this category.', 'woomelly') . '</p>';
						}							
					} else {
						$message_finish = "";
					}
				}
			}

			echo $message_finish;
			wp_die();	
		}

		/**
		 * @return string
		 */
		public function woomelly_do_search_optional_holidays_ship_function () {
			$message_finish = "error";
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_search_optional_holidays_ship' ) {
				global $wm_all_settings;
				if ( wm_is_active_in( $wm_all_settings->get_site_id(), 'me2') == true ) {
					$list_holidays = WMeli::get_optional_holidays_ship( $wm_all_settings );
					if ( is_object($list_holidays) && isset($list_holidays->dates) && !empty($list_holidays->dates) ) {
						$message_finish = '<p>' . __('Choose which days you do not want to ship so that Mercado Libre can calculate the delivery date of your publications and take care of your reputation. During these days you will continue to receive sales.', 'woomelly') . '</p>';
						$message_finish .= '<ul class="uk-list uk-list-large uk-list-divider">';
						$dates_okey = 0;
						$color_strong = "";
						foreach ( $list_holidays->dates as $value ) {
							if ( isset($value->closed) && $value->closed == true ) continue;
							if ( isset($value->finalized) && $value->finalized == true ) continue;
							if ( isset($value->enabled) && $value->enabled == false ) continue;
							if ( wm_diff_time( $value->date, date('Y-m-d'), true, '+48 hours' ) > 0 ) {
								if ( isset($value->checked) ) {
									$message_finish .= '<li><select name="woomelly_days_holidays_ship[]" class="woomelly_att_holidays_ship" style="margin-right: 10px;">';
									$dates_okey++;
									if ( $value->checked == false ) {
										$color_strong = "color: #1e87f0;";
										$message_finish .= '<option value="'.$value->description.':::'.$value->date.':::no" selected="selected">'.__("Yes, yes I work", "woomelly").'</option><option value="'.$value->description.':::'.$value->date.':::yes">'.__("No, I do not work", "woomelly").'</option>';
									} else {
										$color_strong = "color: red;";
										$message_finish .= '<option value="'.$value->description.':::'.$value->date.':::no">'.__("Yes, yes I work", "woomelly").'</option><option value="'.$value->description.':::'.$value->date.':::yes" selected="selected">'.__("No, I do not work", "woomelly").'</option>';
									}
									$message_finish .= '</select><strong class="woomelly_att_holidays_ship_strong" style="'.$color_strong.'">' . wm_print_date( $value->date, 'j M, Y' ) . '</strong> (' . $value->description . ')</li>';
								}
							}
						}
						$message_finish .= '</ul>';
						if ( $dates_okey <= 0 ) {
							$message_finish = "";	
						} else {
							$message_finish = $message_finish . '<script>jQuery( ".woomelly_att_holidays_ship" ).change( function() {
								var result = jQuery( this ).val().split(":::");
								if ( result[2] == "yes" ) {
            						jQuery( this ).next().css({"color": "red"});
        						} else {
            						jQuery( this ).next().css({"color": "#1e87f0"});
        						}
							});';
						}
					} else {
						$message_finish = "";
					}
				}
			}
			echo $message_finish;
			wp_die();	
		}

		/**
		 * @return string
		 */
		public function woomelly_do_search_optional_holidays_ship_save_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			if ( isset($_POST['att_holidays_ship']) && $_POST['att_holidays_ship']!="" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_search_optional_holidays_ship_save' ) {
				$att_holidays_ship = array();
				parse_str($_POST['att_holidays_ship'], $att_holidays_ship);
				if ( !empty($att_holidays_ship) ) {
            		$new_dates = array();
            		foreach ( $att_holidays_ship as $att_holidays_ship_value ) {
            			foreach ( $att_holidays_ship_value as $value ) {
	            			$mykey = explode( ':::', $value );
	            			if ( isset($mykey[0], $mykey[1], $mykey[2]) && $mykey[0] != "" && $mykey[1] != "" && $mykey[2] != "" ) {
	            				$new_dates[] = array(
	            					'checked' => wc_string_to_bool( $mykey[2] ),
	            					'description' => trim($mykey[0]),
	            					'date' => trim($mykey[1])
	            				);
	            			}
	            			unset($mykey);
	            		}
            		}
            		if ( !empty($new_dates) ) {
						global $wm_all_settings;
						$list_holidays = WMeli::put_working_day_middleend( $new_dates, true, true, $wm_all_settings );
						if ( !is_array($list_holidays) && $list_holidays === 'SUCCESS' ) {
							$message_finish = 'success';	
						}
            		}
				} else {
					$message_finish = __("There are no dates to relate. Try again!", "woomelly");
				}
			}
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_save_att_variation_ts_function()

		/*public function woomelly_do_generate_label_me_function () {
			$message_finish = 'error';
			if ( isset($_POST['shipping_id']) && $_POST['shipping_id']!="" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_generate_label_me' ) {
				$wm_shipping_id = trim($_POST['shipping_id']);
				$shipment_labels = WMeli::get_shipment_labels( $wm_shipping_id );
				if ( !empty($shipment_labels) && isset($shipment_labels['body']) ) {
					$message_finish = $shipment_labels['body'];
				}
			}
			echo $message_finish;
			wp_die();			
		}*/	

		/**
		 * @return string
		 */
		public function woomelly_do_attach_invoice_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			if ( isset($_POST['file_pdf_path'], $_POST['wm_order']) && $_POST['wm_order'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_attach_invoice' ) {
				$wm_file_pdf_path = trim($_POST['file_pdf_path']);
				$wm_file_xml_path = "";
				if ( isset($_POST['file_xml_path']) ) {
					$wm_file_xml_path = trim($_POST['file_xml_path']);
				}
				$wm_order = trim($_POST['wm_order']);
				$invoice_files = array();
				if ( $wm_file_pdf_path != "" || $wm_file_xml_path != "" ) {
					if ( $wm_file_pdf_path != "" ) {
						$invoice_files[] = get_attached_file( $wm_file_pdf_path );
					}
					if ( $wm_file_xml_path != "" ) {
						$invoice_files[] = get_attached_file( $wm_file_xml_path );
					}
					$result = WMeli::post_file( $wm_order, $invoice_files, true );
					if ( !empty($result) && is_object($result) && isset($result->ids) && !empty($result->ids) ) {
						$message_finish = 'success';
					} else if ( isset($result['body']) && isset($result['body']->message) && $result['body']->message != "" ) {
						$message_finish = $result['body']->message;
					}
				}
			}
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_attach_invoice_function()	

		/**
		 * @return string
		 */
		public function woomelly_do_delete_invoice_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			if ( isset($_POST['wm_order']) && $_POST['wm_order'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_delete_invoice' ) {
				$wm_order = trim($_POST['wm_order']);
				$result = WMeli::get_delete_fiscal_documents( $wm_order );
				if ( empty($result) ) {
					$message_finish = 'success';
				} else if ( isset($result['body']) && isset($result['body']->message) && $result['body']->message != "" ) {
					$message_finish = $result['body']->message;
				}
			}
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_delete_invoice_function()	

		/**
		 * @return string
		 */
		public function woomelly_do_cancel_order_mslite_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			if ( isset($_POST['wm_order']) && $_POST['wm_order'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_cancel_order_mslite' ) {
				$wm_order = trim($_POST['wm_order']);
				global $wm_all_settings;
				//$result_order = WMeli::get_orders( $wm_order, '', $wm_all_settings );
				$result = WMeli::payments_refunds( $wm_order, $wm_all_settings );
				if ( is_object($result) ) {
					$message_finish = 'success';
				} else {
					$message_finish = __("The refund of this sale could not be carried out successfully in Mercado Libre. Contact Woomelly technical support for more details.", "woomelly");
				}
			}
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_cancel_order_mslite_function()	

		/*public function woomelly_do_request_invoice_data_function () {
			$message_finish = __("The data will not be sent correctly. Try again!", "woomelly");
			if ( isset($_POST['wm_order'], $_POST['wm_data'], $_POST['wm_order_id']) && $_POST['wm_order'] != "" && $_POST['wm_data'] != "" && $_POST['wm_order_id'] != "" && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_request_invoice_data' ) {
				$wm_order = trim($_POST['wm_order']);
				$wm_order_id = trim($_POST['wm_order_id']);
				$wm_data = trim($_POST['wm_data']);
				$wm_data = strip_tags( $wm_data );
				$wm_data = str_replace('\"', '"', $wm_data);
				$result = WMeli::post_request_buyer_info( $wm_order, $wm_data );
				if ( is_object($result) ) {
					$message_finish = 'success';
					update_post_meta( $wm_order_id, '_wm_request_billing_info', 'yes' );
				} else if ( isset($result['body']) && isset($result['body']->message) && $result['body']->message != "" ) {
					$message_finish = $result['body']->message;
				}
			}
			echo $message_finish;
			wp_die();			
		}*/

		/**
		 * @return string
		 */
		public function woomelly_do_reset_product_function () {
			$wm_id = 0;
			$message_finish = '';
			if ( isset($_POST['wm_id']) && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_reset_product' ) {
				$wm_id = intval($_POST['wm_id']);
				if ( $wm_id > 0 ) {
					$reset_type = "reset";
					if ( isset($_POST['reset_type']) && $_POST['reset_type'] != "" ) {
						$reset_type = sanitize_text_field( wp_unslash( trim($_POST['reset_type']) ) );
					}
					if ( $reset_type == "reset" ) {
						wm_product_reset( $wm_id );
					} else {
						$wm_product = new WMProduct( $wm_id );
						if ( $wm_product->get_id() > 0 ) {
							$wm_product->delete_meli();
						}
					}
					$message_finish = 'ok:::' . __("Product successfully unlinked.", "woomelly");
				} else {
					$message_finish = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("Problems when obtaining the product data.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
				}
			}
			
			echo $message_finish;
			wp_die();			
		} //End woomelly_do_reset_product_function()

		/**
		 * @return array
		 */
		public function woomelly_do_assignment_product_function () {
			$wm_id = 0;
			$result = "";
			$info_result = "";
			if ( isset($_POST['wm_id']) && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_assignment_product' ) {
				$wm_id = intval($_POST['wm_id']);
				$result_temp = wm_product_categorization( $wm_id, null, true );
                switch ( $result_temp ) {
                    case 'success':
						$info_result = '<strong style="color: #205237;">' . __("Product categorized successfully", "woomelly") . '.</strong>';
                    break;
                    case 'okcategorized':
                    	$info_result = '<strong style="color: #005f94;">' . __("The product is already categorized successfully", "woomelly") . '.</strong>';
                    break;
                    case 'notokcategorized':
                    	$info_result = '<strong style="color: #665000;">' . __("The product is already categorized, but not with the category recommended by Mercado Libre", "woomelly") . '.</strong>';
                    break;
                    case 'error':
                    	$info_result = '<strong style="color: #912741;">' . __("There was an error in the process. Please try again in a few minutes", "woomelly") . '.</strong>';
                    break;
                    case 'errorsis':
                    	$info_result = '<strong style="color: #912741;">' . __("There was an error in the process. Please try again in a few minutes", "woomelly") . '.</strong>';
                    break;
                    case 'notcategorized':
                    	$info_result = '<strong style="color: #665000;">' . __("The product could not be categorized since Mercado Libre could not associate it to a category", "woomelly") . '.</strong>';
                    break;
                    default:
                    	$info_result = '<strong style="color: #912741;">' . __("There was an error in the process. Please try again in a few minutes", "woomelly") . '.</strong>';
                    break;
                }
				$result .= '<dt><a href="'.admin_url( "post.php?post=".$wm_id."&action=edit" ).'" target="_blank">' . sprintf( __("Product #%s", "woomelly"), $wm_id ) . '</a></dt><dd>' . $info_result . '</dd>';
			}		
			echo $result;
			wp_die();
		} //End woomelly_do_assignment_product_function()

		/**
		 * @return array
		 */
		public function woomelly_do_sync_product_function () {
			$wm_id = 0;
			$continue_sync = true;
			$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("Sorry, but there is no possibility of obtaining the product code.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
			if ( isset($_POST['wm_id']) && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_sync_product' ) {
				$wm_omit_pictures = ( (isset($_POST['wm_omit_pictures'])&&$_POST['wm_omit_pictures']=='omit')? true : false );
				$wm_resync_pictures = ( (isset($_POST['wm_omit_pictures'])&&$_POST['wm_omit_pictures']=='resync')? true : false );
				$wm_id = intval($_POST['wm_id']);
				$wm_params = array(
					'wm_omit_pictures' => $wm_omit_pictures,
					'wm_resync_pictures' => $wm_resync_pictures,
				);
				$wm_type = ( (isset($_POST['wm_type']) && $_POST['wm_type']!="")? trim($_POST['wm_type']) : 'woomelly_automatic' );
				if ( isset($_POST['wm_omit_pictures']) ) {
					$action_temp = trim($_POST['wm_omit_pictures']);
					if ( in_array($action_temp, array('wm_active', 'wm_paused', 'wm_finish', 'wm_reclosed', 'wm_delete', 'wm_categorization', 'wm_recategorization')) ) {
						$res_success = 0;
						$res_error = 0;
						$message_finish = __( "Sorry, The product could not be synced. Try again.", "woomelly" );
						$continue_sync = false;		
						wm_change_status_quickly( $action_temp, array( $wm_id ), $res_success, $res_error, $message_finish );
						$total = $res_success + $res_error;
						if ( $res_success > 0 && $res_success == $total ) {
							$result = 'ok:::<span>'.__("SUCCESSFUL SYNCHRONIZATION.", "woomelly").'<span class="dashicons dashicons-yes" style="color: green; vertical-align: middle;"></span></span>';
						} else {
							$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">' . $message_finish . ' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
						}
					}
				}
				if ( $continue_sync == true ) {
					if ( $wm_id > 0 ) {
						$woomelly_get_settings = new WMSettings();
						if ( isset($GLOBALS['wm_all_settings']) )
							unset($GLOBALS['wm_all_settings']);
						$GLOBALS['wm_all_settings'] = $woomelly_get_settings;
				        try {
							if ( defined( 'WOOMELLY_OMNI_IMMA' ) ) {
								if ( wm_get_product_data($wm_id, '_wm_item') != "" ) {
									$result = apply_filters( 'woomelly_sync_item_to_meli_function', $wm_id, $wm_type, $wm_params );
								} else {
									$result = apply_filters( 'woomelly_sync_product_to_meli_function', $wm_id, $wm_type, $wm_params );
								}
							} else {
								$result = apply_filters( 'woomelly_sync_product_to_meli_function', $wm_id, $wm_type, $wm_params );
							}
				        } catch ( Exception $e ) {
							$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("UNEXPECTED STORE ERROR. Please check the store's WP_DEBUG and contact support for assistance.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
				        }
					}
				}
			}
			echo $result;
			wp_die();
		} //End woomelly_do_sync_product_function()

		/**
		 * @return array
		 */
		public function woomelly_do_import_product_function () {
			$wm_id = 0;
			$continue_sync = true;
			$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("Sorry, but there is no possibility of obtaining the product code.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
			if ( isset($_POST['wm_id']) && isset($_POST['action']) && $_POST['action'] == 'woomelly_do_import_product' ) {
				if ( isset($_POST['wm_omit_pictures']) ) {
					$action_temp = trim($_POST['wm_omit_pictures']);
					if ( in_array($action_temp, array('wm_active', 'wm_paused', 'wm_finish', 'wm_reclosed', 'wm_delete', 'wm_categorization', 'wm_recategorization')) ) {
						$continue_sync = false;		
						$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("Sorry, but you selected an action that only applies for WooCommerce to Mercado Libre synchronizations.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
					}
				}
				if ( $continue_sync == true ) {
					$wm_omit_pictures = ( (isset($_POST['wm_omit_pictures'])&&$_POST['wm_omit_pictures']=='omit')? true : false );
					$wm_resync_pictures = ( (isset($_POST['wm_omit_pictures'])&&$_POST['wm_omit_pictures']=='resync')? true : false );
					$wm_params = array(
						'wm_omit_pictures' => $wm_omit_pictures,
						'wm_resync_pictures' => $wm_resync_pictures,
					);
					$wm_id = trim($_POST['wm_id']);
					$wm_type = ( (isset($_POST['wm_type']) && $_POST['wm_type']!="")? trim($_POST['wm_type']) : 'woomelly_automatic' );
					if ( $wm_id != "" ) {
						$woomelly_get_settings = new WMSettings();
						if ( isset($GLOBALS['wm_all_settings']) )
							unset($GLOBALS['wm_all_settings']);
						$GLOBALS['wm_all_settings'] = $woomelly_get_settings;
				        try {
							$result = apply_filters( 'woomelly_sync_publication_to_woo_function', $wm_id, $wm_type, $wm_params );
				        } catch ( Exception $e ) {
							$result = 'nook:::<span style="background: #fef4f6; color: #f0506e;">'.__("UNEXPECTED STORE ERROR. Please check the store's WP_DEBUG and contact support for assistance.", "woomelly").' <span class="dashicons dashicons-no-alt" style="color: red; vertical-align: middle;"></span></span>';
				        }
					}
				}
			}		
			echo $result;
			wp_die();
		} //End woomelly_do_import_product_function()

		/**
		 * @return array
		 */
		public function woomelly_do_sync_automatic_product_function( $product_id, $type = 'woo_to_meli', $wm_type = 'woomelly_automatic', $params = array() ) {
			$result = 'error';
			if ( $type == 'woo_to_meli' ) {
				if ( intval($product_id) > 0 ) {
					if ( defined( 'WOOMELLY_OMNI_IMMA' ) ) {
						if ( wm_get_product_data($product_id, '_wm_item') != "" ) {
							$result = apply_filters( 'woomelly_sync_item_to_meli_function', $product_id, $wm_type, $params );
						} else {
							$result = apply_filters( 'woomelly_sync_product_to_meli_function', $product_id, $wm_type, $params );
						}
					} else {
						$result = apply_filters( 'woomelly_sync_product_to_meli_function', $product_id, $wm_type, $params );
					}
				}
			} else if ( $type == 'meli_to_woo' ) {
				if ( $product_id != "" ) {
					$result = apply_filters( 'woomelly_sync_publication_to_woo_function', $product_id, $wm_type, $params );
				}
			}
			return $result;
		} //End woomelly_do_sync_automatic_product_function()		

		/**
		 * @return array
		 */
		public function woomelly_do_templatesync_automatic_function () {
			$wm_id = 0;
			$result = 'nook:::0';
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_templatesync_automatic' ) {
				$is_begin = ( (isset($_POST['begin']) && $_POST['begin'] == 'true') ? true : false );
				$is_pending = WM_TemplateSyncAutomatic::is_pending();
				$is_running = WM_TemplateSyncAutomatic::is_running();
				if ( $is_running == true || $is_pending > 0 ) {
					if ( $is_running == false ) {
						WM_TemplateSyncAutomatic::do_handle();
					}
		            $settings                       = WM_TemplateSyncAutomatic::get_settings();
		            $total_products_tsyncaut        = $settings['total'];
		            $progress 						= 0;
		            if ( $total_products_tsyncaut > 0 ) {
		            	$progress = round( ( ($total_products_tsyncaut-$is_pending) * 100 ) / $total_products_tsyncaut, 0, PHP_ROUND_HALF_DOWN );
		            }
					$result = 'nook:::' . $progress;
				} else if ( $is_begin == true ) {
					WM_TemplateSyncAutomatic::queue();
				} else {
					if ( $is_running == false ) {
						WM_TemplateSyncAutomatic::do_handle();
					}
					$settings = WM_TemplateSyncAutomatic::get_settings();
			        if ( $settings['complete'] == true ) {
						$resume =
						'<div class="uk-child-width-1-4@s uk-grid-match" uk-grid>
		        		<div>
				            <div class="uk-card uk-card-hover badge-success-light uk-card-body" style="padding: 15px 15px;">
				                <h1 class="uk-card-title" style="font-size: 15px; color: #205237;">'.__("Successful assignment", "woomelly").'</h1>
				                <h1 style="font-size: 36px; font-weight: 900; color: #205237;">'.$settings["success"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
				            </div>
		        		</div>
		        		<div>
		        			<a style="text-decoration: none;" href="'.admin_url( "edit.php?s&post_type=product&action=-1&woomelly_filter_template_sync=wm_filter_without_template" ).'" target="_blank">
				            <div class="uk-card uk-card-hover badge-danger-light uk-card-body" style="padding: 15px 15px;">
				                <h1 class="uk-card-title" style="font-size: 15px; color: #912741;">'.__("Wrong assignment", "woomelly").'</h1>
				                <h1 style="font-size: 36px; font-weight: 900; color: #912741;">'.$settings["error"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
				            </div>
		        			</a>
		        		</div>
		        		<div>
				            <div class="uk-card uk-card-hover badge-primary-light uk-card-body" style="padding: 15px 15px;">
				                <h1 class="uk-card-title" style="font-size: 15px; color: #005f94;">'.__("Categories matches (ML)", "woomelly").'</h1>
				                <h1 style="font-size: 36px; font-weight: 900; color: #005f94;">'.$settings["okcategorized"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
				            </div>
		        		</div>
		        		<div>
							<a style="text-decoration: none;" href="'.admin_url( "edit.php?s&post_type=product&action=-1&woomelly_filter_tags=wrong_categorization" ).'" target="_blank">
				            <div class="uk-card uk-card-hover badge-warning-light uk-card-body" style="padding: 15px 15px;">
				                <h1 class="uk-card-title" style="font-size: 15px; color: #665000;">'.__("Categories do not match (ML)", "woomelly").'</h1>
				                <h1 style="font-size: 36px; font-weight: 900; color: #665000;">'.$settings["notokcategorized"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
				            </div>
				            </a>
		        		</div>
		        		</div>';
			        	$result = 'ok:::'.$resume;
			        }
				}
			}		
			echo $result;
			wp_die();
		} //End woomelly_do_templatesync_automatic_function()		

		/**
		 * @return array
		 */
		public function woomelly_do_sync_massive_function () {
			$wm_id = 0;
			$result = 'nook:::0';
			$type = "woo_meli";
			if ( isset($_POST['type']) && $_POST['type'] == "meli_woo" ) {
				$type = "meli_woo";
			}
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_sync_massive' ) {
				if ( $type == "woo_meli" ) {
					$is_begin = ( (isset($_POST['begin']) && $_POST['begin'] == 'true') ? true : false );
					$is_pending = WM_NewSync_Woo_ML::is_pending();
					$is_running = WM_NewSync_Woo_ML::is_running();
					if ( $is_running || $is_pending > 0 ) {
						if ( $is_running == false ) {
							WM_NewSync_Woo_ML::do_handle();
						}
			            $settings                       = WM_NewSync_Woo_ML::get_settings();
			            $total_products_tsyncaut        = $settings['total'];
			            $progress 						= 0;
			            if ( $total_products_tsyncaut > 0 ) {
			            	$progress = round( ( ($total_products_tsyncaut-$is_pending) * 100 ) / $total_products_tsyncaut, 0, PHP_ROUND_HALF_DOWN );
			            }
						$result = 'nook:::' . $progress;
					} else if ( $is_begin == true ) {					
						WM_NewSync_Woo_ML::queue();						
					} else {
						if ( $is_running == false ) {
							WM_NewSync_Woo_ML::do_handle();
						}
						$settings = WM_NewSync_Woo_ML::get_settings();
				        if ( $settings['complete'] == true ) {
							$resume =
							'<div class="uk-child-width-1-2@s uk-grid-match" uk-grid>
					            <div>
						            <div class="uk-card uk-card-hover badge-success-light uk-card-body" style="padding: 15px 15px;">
						                <h1 class="uk-card-title" style="font-size: 15px; color: #205237;">'.__("Successful sync", "woomelly").'</h1>
						                <h1 style="font-size: 36px; font-weight: 900; color: #205237;">'.$settings["success"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
						            </div>
					            </div>
					            <div>
					            	<a style="text-decoration: none;" href="'.admin_url( "edit.php?s&post_type=product&action=-1&woomelly_filter_status=wm_filter_syncproblem_connect" ).'" target="_blank">
						            <div class="uk-card uk-card-hover badge-danger-light uk-card-body" style="padding: 15px 15px;">
						                <h1 class="uk-card-title" style="font-size: 15px; color: #912741;">'.__("Error sync", "woomelly").'</h1>
						                <h1 style="font-size: 36px; font-weight: 900; color: #912741;">'.$settings["error"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
						            </div>
							        </a>
						        </div>
			        		</div>';
				        	$result = 'ok:::'.$resume;
				        }
					}
				} else {
					$is_begin = ( (isset($_POST['begin']) && $_POST['begin'] == 'true') ? true : false );
					$is_pending = WM_NewSync_ML_Woo::is_pending();
					$is_running = WM_NewSync_ML_Woo::is_running();
					if ( $is_running || $is_pending > 0 ) {
						if ( $is_running == false ) {
							WM_NewSync_ML_Woo::do_handle();
						}
			            $settings                       = WM_NewSync_ML_Woo::get_settings();
			            $total_products_tsyncaut        = $settings['total'];
			            $progress 						= 0;
			            if ( $total_products_tsyncaut > 0 ) {
			            	$progress = round( ( ($total_products_tsyncaut-$is_pending) * 100 ) / $total_products_tsyncaut, 0, PHP_ROUND_HALF_DOWN );
			            }
						$result = 'nook:::' . $progress;
					} else if ( $is_begin == true ) {
						WM_NewSync_ML_Woo::queue();
					} else {
						if ( $is_running == false ) {
							WM_NewSync_ML_Woo::do_handle();
						}
						$settings = WM_NewSync_ML_Woo::get_settings();
				        if ( $settings['complete'] == true ) {
							$resume =
							'<div class="uk-child-width-1-2@s uk-grid-match" uk-grid>
					            <div>
						            <div class="uk-card uk-card-hover badge-success-light uk-card-body" style="padding: 15px 15px;">
						                <h1 class="uk-card-title" style="font-size: 15px; color: #205237;">'.__("Successful sync", "woomelly").'</h1>
						                <h1 style="font-size: 36px; font-weight: 900; color: #205237;">'.$settings["success"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
						            </div>
					            </div>
					            <div>
					            	<a style="text-decoration: none;" href="'.admin_url( "edit.php?s&post_type=product&action=-1&woomelly_filter_status=wm_filter_syncproblem_connect" ).'" target="_blank">
						            <div class="uk-card uk-card-hover badge-danger-light uk-card-body" style="padding: 15px 15px;">
						                <h1 class="uk-card-title" style="font-size: 15px; color: #912741;">'.__("Error sync", "woomelly").'</h1>
						                <h1 style="font-size: 36px; font-weight: 900; color: #912741;">'.$settings["error"].'<span class="uk-text-small"> '.__("products", "woomelly").'</span></h1>
						            </div>
							        </a>
						        </div>
			        		</div>';
				        	$result = 'ok:::'.$resume;
				        }
					}					
				}
			}		
			echo $result;
			wp_die();
		} //End woomelly_do_sync_massive_function()		

		/**
		 * @return array
		 */
		public function woomelly_do_templatesync_automatic_cancel_function () {
			$result = 'error';
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_templatesync_automatic_cancel' ) {
	            WM_TemplateSyncAutomatic::set_kill(true);
	            WM_TemplateSyncAutomatic::set_kill(true);
	            WM_TemplateSyncAutomatic::set_kill(true);
				$result = 'success';
			}
			echo $result;
			wp_die();
		} //End woomelly_do_templatesync_automatic_cancel_function()

		/**
		 * @return array
		 */
		public function woomelly_do_sync_massive_cancel_function () {
			$result = 'error';
			$type = "woo_meli";
			if ( isset($_POST['type']) && $_POST['type'] == "meli_woo" ) {
				$type = "meli_woo";
			}
			if ( isset($_POST['action']) && $_POST['action'] == 'woomelly_do_sync_massive_cancel' ) {
	            $is_running_locked = false;
	            if ( isset($_POST['is_running_locked']) && trim($_POST['is_running_locked']) != "" ) {
	            	$is_running_locked = true;
	            }
	            if ( $type == "woo_meli" ) {
		            WM_NewSync_Woo_ML::set_kill(true);
		            WM_NewSync_Woo_ML::set_kill(true);
		            WM_NewSync_Woo_ML::set_kill(true);
	            } else {
		            WM_NewSync_ML_Woo::set_kill(true);
		            WM_NewSync_ML_Woo::set_kill(true);
		            WM_NewSync_ML_Woo::set_kill(true);	            	
	            }
				if ( $is_running_locked == false ) {
					$result = 'success';
				} else {
					$result = 'locationreload';
				}
			}
			echo $result;
			wp_die();
		} //End woomelly_do_sync_massive_cancel_function()

		/**
		 * @return string
		 */
		public function woomelly_do_send_rating_function () {
			$wm_meli_fulfilled = '';
			$wm_meli_rating = '';
			$wm_meli_reason = '';
			$wm_meli_restock = '';
			$message_finish = 'error';
			$data = array();
			if ( isset($_POST['action'],$_POST['order_id']) && $_POST['action'] == 'woomelly_do_send_rating' && $_POST['order_id'] != "" ) {
				if ( isset($_POST['meli_fulfilled'], $_POST['meli_rating']) && $_POST['meli_fulfilled'] != "" && $_POST['meli_rating'] != "" ) {
					$code = trim($_POST['order_id']);
					$wm_meli_fulfilled = wc_string_to_bool(trim($_POST['meli_fulfilled']));
					if ( $wm_meli_fulfilled == true ) {
						$wm_meli_rating = 'positive';
						$data['fulfilled'] = $wm_meli_fulfilled;
						$data['rating'] = $wm_meli_rating;
						$data['message'] = ( (isset($_POST['meli_message'])&&$_POST['meli_message']!="")? trim($_POST['meli_message']) : 'Ok' );
					} else {
						$wm_meli_rating = trim($_POST['meli_rating']);
						if ( $wm_meli_rating != 'neutral' && $wm_meli_rating != 'negative' ) {
							$wm_meli_rating = 'neutral';
						}
						$wm_meli_reason = ( (isset($_POST['meli_reason'])&&$_POST['meli_reason']!="")? trim($_POST['meli_reason']) : 'SELLER_OUT_OF_STOCK' );
						$wm_meli_restock = ( (isset($_POST['meli_restock'])&&$_POST['meli_restock']!="")? wc_string_to_bool(trim($_POST['meli_restock'])) : false );
						$data['fulfilled'] = $wm_meli_fulfilled;
						$data['rating'] = $wm_meli_rating;
						$data['message'] = ( (isset($_POST['meli_message'])&&$_POST['meli_message']!="")? trim($_POST['meli_message']) : 'Ok' );
						$data['reason'] = $wm_meli_reason;
						$data['restock_item'] = $wm_meli_restock;
					}
					$result = WMeli::post_feedback($code,$data);
					if ( !empty($result) ) {
						$message_finish = 'success';
					}
				}
			}
			echo $message_finish;
			wp_die();
		} //End woomelly_do_send_rating_function()

		/**
		 * @return string
		 */
		public function woomelly_do_send_messages_action_guide_function () {
			global $wm_all_settings;
			$message_finish = '';
			$wm_send_action_guide = true;
			$vars = array();
			if ( isset($_POST['action'], $_POST['option_id'], $_POST['text'], $_POST['pack'], $_POST['type'] ) && $_POST['action'] == 'woomelly_do_send_messages_action_guide' && $_POST['option_id'] != "" && $_POST['text'] != "" && $_POST['pack'] != "" && $_POST['type'] != "" ) {
				$code 		= trim($_POST['pack']);
				$option_id 	= trim($_POST['option_id']);
				$text 		= trim($_POST['text']);
				$type 		= trim($_POST['type']);
				if ( $option_id == 'DELIVERY_PROMISE' ) {
					$wm_send_action_guide = false;
					if ( isset($_POST['TEMPLATE___DELIVERY_PROMISE_INIT'], $_POST['TEMPLATE___DELIVERY_PROMISE_LIMIT']) ) {
						$dp_init = trim($_POST['TEMPLATE___DELIVERY_PROMISE_INIT']);
						$dp_limit = trim($_POST['TEMPLATE___DELIVERY_PROMISE_LIMIT']);
						if ( $dp_init != "" && $dp_limit != "" ) {
							$vars[] = array( 'id' => 'TEMPLATE___DELIVERY_PROMISE___1___VAR___INIT', 'value' => intval($dp_init) );
							$vars[] = array( 'id' => 'TEMPLATE___DELIVERY_PROMISE___1___VAR___LIMIT', 'value' => intval($dp_limit) );
							$wm_send_action_guide = true;
						}
					}
				} else if ( $option_id == 'OTHER' ) {
					$text = stripslashes($text);
					$text = strip_tags( $text, '<a>' );
					$text = str_replace('\"', '"', $text);
				}
				$has_limit_caracters = false;
				$normalized_text = str_replace("\r\n", "\n", $text);
				if ( mb_strlen($normalized_text) > 350 ) $has_limit_caracters = true;
				if ( $text != "" && $wm_send_action_guide == true && $has_limit_caracters == false ) {
					$result = WMeli::post_messages_action_guide( $code, $option_id, $text, $vars, $type, $wm_all_settings );
					if ( !empty($result) ) {
						//$message_finish = '<span style="margin: 15px 15px 15px 0px; color: red;">'.__("There was an error updating the data. Please reload the page.", "woomelly").'</span>';
						$data_messages_action_guide = WMeli::get_messages_action_guide( $code, $wm_all_settings );
						if ( !empty($data_messages_action_guide) && isset($data_messages_action_guide->options) && !empty($data_messages_action_guide->options) ) {
							foreach ( $data_messages_action_guide->options as $action_guide ) {
								if ( $action_guide->id == $option_id ) {
									$woomelly_msg_status = ( ($action_guide->enabled==true&&$action_guide->cap_available>0)? true : false );
									$woomelly_msg_status_text = "";
									if ( $woomelly_msg_status == true ) {
										$woomelly_msg_status_text = '<span style="margin: 15px 15px 15px 0px; color: green;vertical-align: middle;">'.sprintf( __("enabled (%s)", "woomelly"), $action_guide->cap_available ).'</span>';
									} else {
										$woomelly_msg_status_text = '<span style="margin: 15px 15px 15px 0px; color: red;vertical-align: middle;">'.sprintf( __("disabled (%s)", "woomelly"), $action_guide->cap_available ).'</span>';
									}
									switch ( $action_guide->id ) {
										case 'REQUEST_BILLING_INFO':
											$woomelly_msg_options = '<option value=""></option>';
											if ( !empty($action_guide->templates) ) {
												$woomelly_msg_options = "";
												foreach ( $action_guide->templates as $templates_options ) {
													$woomelly_msg_options .= '<option value="'.$templates_options->id.'">'.$templates_options->id.'</option>';
												}
											} else {
												$woomelly_msg_status = false;
											}
											$woomelly_msg_status_disabled = ( ($woomelly_msg_status==true)? "" : "disabled='disabled'" );
											$message_finish = '
												<label style="margin: 15px 15px 15px 0px;"><strong>'.__("Request billing info", "woomelly").'</strong></label><br>
												'.$woomelly_msg_status_text.'
												<select style="margin: 15px 15px 15px 0px; width: 50%;vertical-align: middle;" name="TEXT_'.$action_guide->id.'" id="TEXT_'.$action_guide->id.'" '.$woomelly_msg_status_disabled.'>'.$woomelly_msg_options.'</select>
												<button style="margin: 15px 15px 15px 0px;vertical-align: middle;" class="button button-primary" name="SEND_'.$action_guide->id.'" id="SEND_'.$action_guide->id.'" value="'.__("Send", "woomelly").'" '.$woomelly_msg_status_disabled.'>'.__("Send", "woomelly").'</button>';
										break;
										case 'REQUEST_VARIANTS':
											$woomelly_msg_options = '<option value=""></option>';
											if ( !empty($action_guide->templates) ) {
												$woomelly_msg_options = "";
												foreach ( $action_guide->templates as $templates_options ) {
													$woomelly_msg_options .= '<option value="'.$templates_options->id.'">'.$templates_options->id.'</option>';
												}
											} else {
												$woomelly_msg_status = false;
											}
											$woomelly_msg_status_disabled = ( ($woomelly_msg_status==true)? "" : "disabled='disabled'" );
											$message_finish = '
												<label style="margin: 15px 15px 15px 0px;"><strong>'.__("Request variants info", "woomelly").'</strong></label><br>
												'.$woomelly_msg_status_text.'
												<select style="margin: 15px 15px 15px 0px; width: 50%;vertical-align: middle;" name="TEXT_'.$action_guide->id.'" id="TEXT_'.$action_guide->id.'" '.$woomelly_msg_status_disabled.'>'.$woomelly_msg_options.'</select>
												<button style="margin: 15px 15px 15px 0px;vertical-align: middle;" class="button button-primary" name="SEND_'.$action_guide->id.'" id="SEND_'.$action_guide->id.'" value="'.__("Send", "woomelly").'" '.$woomelly_msg_status_disabled.'>'.__("Send", "woomelly").'</button>';
										break;
										case 'SEND_INVOICE_LINK':
											if ( $action_guide->char_limit <=0 ) {
												$woomelly_msg_status = false;
											}
											$woomelly_msg_status_disabled = ( ($woomelly_msg_status==true)? "" : "disabled='disabled'" );
											$message_finish = '
												<label style="margin: 15px 15px 15px 0px;"><strong>'.__("Send invoice link", "woomelly").'</strong></label><br>
												'.$woomelly_msg_status_text.'
												<textarea style="margin: 15px 15px 15px 0px; width: 50%;vertical-align: middle;" name="TEXT_'.$action_guide->id.'" id="TEXT_'.$action_guide->id.'" rows="1" maxlength="'.$action_guide->char_limit.'" '.$woomelly_msg_status_disabled.'></textarea>
												<button style="margin: 15px 15px 15px 0px;vertical-align: middle;" class="button button-primary" name="SEND_'.$action_guide->id.'" id="SEND_'.$action_guide->id.'" value="'.__("Send", "woomelly").'" '.$woomelly_msg_status_disabled.'>'.__("Send", "woomelly").'</button>';
										break;
										case 'OTHER':
											$woomelly_msg_status_disabled = ( ($woomelly_msg_status==true)? "" : "disabled='disabled'" );
											$message_finish = '
												<label style="margin: 15px 15px 15px 0px;"><strong>'.__("Other reason", "woomelly").'</strong></label><br>
												'.$woomelly_msg_status_text.'
												<textarea style="margin: 15px 15px 15px 0px; width: 50%;vertical-align: middle;" name="TEXT_'.$action_guide->id.'" id="TEXT_'.$action_guide->id.'" rows="1" maxlength="'.$action_guide->char_limit.'" '.$woomelly_msg_status_disabled.'></textarea>
												<button style="margin: 15px 15px 15px 0px;vertical-align: middle;" class="button button-primary" name="SEND_'.$action_guide->id.'" id="SEND_'.$action_guide->id.'" value="'.__("Send", "woomelly").'" '.$woomelly_msg_status_disabled.'>'.__("Send", "woomelly").'</button>';
										break;
										case 'DELIVERY_PROMISE':
											$woomelly_msg_options = '<option value=""></option>';
											$woomelly_msg_options_after = '';
											if ( !empty($action_guide->templates) ) {
												$woomelly_msg_options = "";
												foreach ( $action_guide->templates as $templates_options ) {
													$woomelly_msg_options .= '<option value="'.$templates_options->id.'">'.$templates_options->id.'</option>';
												}
											} else {
												$woomelly_msg_status = false;
											}
											$woomelly_msg_status_disabled = ( ($woomelly_msg_status==true)? "" : "disabled='disabled'" );
											$woomelly_msg_options_after = '<select style="margin: 15px 15px 15px 0px; width: 13%;vertical-align: middle;" name="TEMPLATE___DELIVERY_PROMISE_INIT" id="TEMPLATE___DELIVERY_PROMISE_INIT" '.$woomelly_msg_status_disabled.'>';
											for ($vv=0; $vv<=22 ; $vv++) { 
												$woomelly_msg_options_after .= '<option value="'.$vv.'">'.$vv.'h</option>';	
											}
											$woomelly_msg_options_after .= '</select>';
											$woomelly_msg_options_after .= '<select style="margin: 15px 15px 15px 0px; width: 13%;vertical-align: middle;" name="TEMPLATE___DELIVERY_PROMISE_LIMIT" id="TEMPLATE___DELIVERY_PROMISE_LIMIT" '.$woomelly_msg_status_disabled.'>';
											for ($vv=1; $vv<=23 ; $vv++) { 
												$woomelly_msg_options_after .= '<option value="'.$vv.'">'.$vv.'h</option>';	
											}
											$woomelly_msg_options_after .= '</select>';
											$message_finish = '
												<div id="DIV_'.$action_guide->id.'">
													<label style="margin: 15px 15px 15px 0px;"><strong>'.__("Delivery promise", "woomelly").'</strong></label><br>
													'.$woomelly_msg_status_text.'
													<select style="margin: 15px 15px 15px 0px; width: 20%;vertical-align: middle;" name="TEXT_'.$action_guide->id.'" id="TEXT_'.$action_guide->id.'" '.$woomelly_msg_status_disabled.'>'.$woomelly_msg_options.'</select>
													'.$woomelly_msg_options_after.'
													<button style="margin: 15px 15px 15px 0px;vertical-align: middle;" class="button button-primary" name="SEND_'.$action_guide->id.'" id="SEND_'.$action_guide->id.'" value="'.__("Send", "woomelly").'" '.$woomelly_msg_status_disabled.'>'.__("Send", "woomelly").'</button>
												</div>';
										break;
									}
									break;
								}
							}
						}
					}
				}
			}
			echo $message_finish;
			wp_die();
		} //End woomelly_do_send_messages_action_guide_function()

		/**
		 * @return array
		 */
		public function woomelly_do_generaltemplatesync_function () {
			$result = 'error';

			if ( isset($_POST['action'], $_POST['status_field'], $_POST['listing_type_id'], $_POST['condition']) ) {
			if ( isset($_POST['free_shipping'], $_POST['free_from_shipping'], $_POST['factory_warranty_1']) ) {
			if ( isset($_POST['seller_warranty_1'], $_POST['seller_warranty_2'], $_POST['warranty'], $_POST['price_one']) ) {
			if ( isset($_POST['price_two'], $_POST['price_three'], $_POST['price_four'], $_POST['price_five']) ) {
			if ( isset($_POST['stock_one'], $_POST['stock_two'], $_POST['stock_three'], $_POST['factory_warranty_2']) ) {
			if ( isset($_POST['video_id'], $_POST['local_pick_up'], $_POST['aut_technical_spec']) ) {
			if ( $_POST['action'] === "woomelly_do_generaltemplatesync" ) {

				$wm_status_field = wc_clean( wp_unslash( $_POST['status_field'] ) );
				$wm_listing_type_id = wc_clean( wp_unslash( $_POST['listing_type_id'] ) );
				$wm_condition = wc_clean( wp_unslash( $_POST['condition'] ) );
				$wm_local_pick_up = wc_clean( wp_unslash( $_POST['local_pick_up'] ) );
				$wm_free_shipping = wc_clean( wp_unslash( $_POST['free_shipping'] ) );
				$wm_free_from_shipping = wc_clean( wp_unslash( $_POST['free_from_shipping'] ) );
				$wm_free_shipping_ms = "no";
				if ( isset($_POST['free_shipping_ms']) && $_POST['free_shipping_ms'] != "" ) {
					$wm_free_shipping_ms = wc_clean( wp_unslash( $_POST['free_shipping_ms'] ) );
				}
				$wm_free_from_shipping_ms = "";
				if ( isset($_POST['free_from_shipping_ms']) && $_POST['free_from_shipping_ms'] != "" ) {
					$wm_free_from_shipping_ms = wc_clean( wp_unslash( $_POST['free_from_shipping_ms'] ) );
				}
				$wm_flex_shipping = "";
				if ( isset($_POST['flex_shipping']) && $_POST['flex_shipping'] != "" ) {
					$wm_flex_shipping = wc_clean( wp_unslash( $_POST['flex_shipping'] ) );
				}
				$wm_factory_warranty_1 = wc_clean( wp_unslash( $_POST['factory_warranty_1'] ) );
				$wm_factory_warranty_2 = wc_clean( wp_unslash( $_POST['factory_warranty_2'] ) );
				if ( $wm_factory_warranty_1 == "" || $wm_factory_warranty_2 == "" ) {
					$wm_factory_warranty_1 = "";
					$wm_factory_warranty_2 = "";
				}
				$wm_seller_warranty_1 = wc_clean( wp_unslash( $_POST['seller_warranty_1'] ) );
				$wm_seller_warranty_2 = wc_clean( wp_unslash( $_POST['seller_warranty_2'] ) );
				if ( $wm_seller_warranty_1 == "" || $wm_seller_warranty_2 == "" ) {
					$wm_seller_warranty_1 = "";
					$wm_seller_warranty_2 = "";
				}
				$wm_warranty = wc_clean( wp_unslash( $_POST['warranty'] ) );
				$wm_price_one = wc_clean( wp_unslash( $_POST['price_one'] ) );
				$wm_price_two = wc_clean( wp_unslash( $_POST['price_two'] ) );
				$wm_price_three = wc_clean( wp_unslash( $_POST['price_three'] ) );
				$wm_price_four = wc_clean( wp_unslash( $_POST['price_four'] ) );
				$wm_price_five = wc_clean( wp_unslash( $_POST['price_five'] ) );
                if ( $wm_price_one == "" ) {
                    $wm_price_two = "";
                    $wm_price_three = "";
                    $wm_price_four = "";
                    $wm_price_five = "";
                }
                if ( $wm_price_four == "" ) {
                	$wm_price_five = "";
                }
				$wm_stock_one = wc_clean( wp_unslash( $_POST['stock_one'] ) );
				$wm_stock_two = wc_clean( wp_unslash( $_POST['stock_two'] ) );
				$wm_stock_three = wc_clean( wp_unslash( $_POST['stock_three'] ) );
                if ( $wm_stock_one == "" ) {
                    $wm_stock_two = "";
                    $wm_stock_three = "";
                }
				$wm_manufacturing_time = "";
				if ( isset($_POST['manufacturing_time']) && $_POST['manufacturing_time'] != "" ) {
					$wm_manufacturing_time = wc_clean( wp_unslash( $_POST['manufacturing_time'] ) );
				}
				$wm_limit_per_sales = "";
				if ( isset($_POST['limit_per_sales']) && $_POST['limit_per_sales'] != "" ) {
					$wm_limit_per_sales = intval( wc_clean( wp_unslash( $_POST['limit_per_sales'] ) ) );
					if ( $wm_limit_per_sales <= 0 ) {
						$wm_limit_per_sales = "";
					}
				}
				$wm_video_id = wc_clean( wp_unslash( $_POST['video_id'] ) );
				$wm_channels = "";
				if ( isset($_POST['channels']) && $_POST['channels'] != "" ) {
					$wm_channels = wc_clean( wp_unslash( $_POST['channels'] ) );
				}
				$wm_separate_variations = "";
				if ( isset($_POST['separate_variations']) && $_POST['separate_variations'] != "" ) {
					$wm_separate_variations = wc_clean( wp_unslash( $_POST['separate_variations'] ) );
				}
				$wm_aut_technical_spec = wc_clean( wp_unslash( $_POST['aut_technical_spec'] ) );
	            $save = array(
	                'status_field' => $wm_status_field,
	                'listing_type_id' => $wm_listing_type_id,
	                'condition' => $wm_condition,
	                'local_pick_up' => $wm_local_pick_up,
	                'free_shipping' => wc_bool_to_string( $wm_free_shipping ),
	                'free_from_shipping' => $wm_free_from_shipping,
	                'free_shipping_ms' => wc_bool_to_string( $wm_free_shipping_ms ),
	                'free_from_shipping_ms' => $wm_free_from_shipping_ms,
	                'flex_shipping' => $wm_flex_shipping,
	                'factory_warranty_1' => $wm_factory_warranty_1,
	                'factory_warranty_2' => $wm_factory_warranty_2,
	                'seller_warranty_1' => $wm_seller_warranty_1,
	                'seller_warranty_2' => $wm_seller_warranty_2,
	                'warranty' => $wm_warranty,
	                'price_1' => $wm_price_one,
	                'price_2' => $wm_price_two,
	                'price_3' => $wm_price_three,
	                'price_4' => $wm_price_four,
	                'price_5' => $wm_price_five,
	                'stock_1' => $wm_stock_one,
	                'stock_2' => $wm_stock_two,
	                'stock_3' => $wm_stock_three,
	                'manufacturing_time' => $wm_manufacturing_time,
	                'limit_per_sales' => $wm_limit_per_sales,
	                'video' => $wm_video_id,
	                'separate_variations' => $wm_separate_variations,
	                'channels' => $wm_channels,
	                'aut_technical_spec' => $wm_aut_technical_spec
	            );
	            $woomelly_get_settings = new WMSettings();
			    $woomelly_get_settings->set_settings_generaltsync( $save );
			    $woomelly_get_settings->save();
				$result = 'success';
			} } } } } } }
			echo $result;
			wp_die();
		} //End woomelly_do_generaltemplatesync_function()

		public function woomelly_do_data_shipping_modes () {
			$result = "";
			if ( isset($_POST['action'], $_POST['category_id'], $_POST['shipping_mode'] ) && "woomelly_do_data_shipping_modes" == $_POST['action'] ) {
				$only_shipping_mode = false;
				if ( isset($_POST['only_shipping_mode']) && $_POST['only_shipping_mode'] == "true" ) {
					$only_shipping_mode = true;
				}
				$category_id = trim( $_POST['category_id'] );
				$woomelly_shipping_mode_field = trim( $_POST['shipping_mode'] );
				if ( $category_id != "" && ( $woomelly_shipping_mode_field != "" || $only_shipping_mode == true ) ) {
	                $wm_settings = new WMSettings();
					$shipping_modes_id_array = WMeli::get_shipping_modes( $category_id, $wm_settings );
	                if ( !empty($shipping_modes_id_array) ) {
	                    if ( $only_shipping_mode == false ) {
		                    /*foreach ( $shipping_modes_id_array as $value_master ) {
		                        if ( $value_master->mode == $woomelly_shipping_mode_field ) {
		                            $shipping_modes_id = $value_master->shipping_attributes->free->accepted_methods;
		                            if ( !empty($shipping_modes_id) ) {
		                                $time_max = "";
		                                foreach ( $shipping_modes_id as $value ) {
		                                    $shipping_methods = WMeli::get_shipping_methods( $value, $wm_settings );
		                                    if ( !empty($shipping_methods) ) {
		                                        if ( $shipping_methods->status == 'active' ) {
													if ( $shipping_methods->min_time != null || $shipping_methods->max_time != null ) {
														$time_max = "min min_timeh - max max_timeh";
														$time_max = str_replace("min_time", $shipping_methods->min_time, $time_max);
														$time_max = str_replace("max_time", $shipping_methods->max_time, $time_max);
														$time_max = str_replace("null", "0", $time_max);
		                                            }
		                                            if ( $shipping_methods->company_name != null ) {
		                                            	$result .= '<option value="'.$shipping_methods->id.'">'.$shipping_methods->name.' ( '.$shipping_methods->company_name.' ) '.$time_max.'</option>';
		                                            } else {
		                                            	$result .= '<option value="'.$shipping_methods->id.'">'.$shipping_methods->name.' '.$time_max.'</option>';
		                                            }
		                                        }
		                                    }
		                                    unset( $shipping_methods );
		                                }
		                            }
		                        }
		                    }*/
	                    } else {
	                  		foreach ( $shipping_modes_id_array as $value_master ) {
								switch ($value_master->mode) {
									case "custom":
										$result .= '<option value="'.$value_master->mode.'">' . __("Custom", "woomelly") . '</option>';
									break;
									case "me1":
										$result .= '<option value="'.$value_master->mode.'">' . __("Mercado Envios Type 1", "woomelly") . '</option>';
									break;
									case "me2":
										$result .= '<option value="'.$value_master->mode.'">' . __("Mercado Envios", "woomelly") . '</option>';
									break;
									case "not_specified":
										$result .= '<option value="'.$value_master->mode.'">' . __("Without Shipping", "woomelly") . '</option>';
									break;
									default:
										$result .= '<option value="'.$value_master->mode.'">'.$value_master->mode.'</option>';
									break;
								}
	                  		}
	                    }
	                }
				}
			}			
			echo $result;
			wp_die();
		} //End woomelly_do_data_shipping_modes()

		public function woomelly_do_solve_multiple_product () {
			$result = "";
			if ( isset($_POST['action'], $_POST['wm_id']) && "woomelly_do_solve_multiple_product" == $_POST['action'] ) {
				$wm_id = trim( $_POST['wm_id'] );
				if ( $wm_id != "" ) {
					update_post_meta( $wm_id, '_wm_is_multiple', false );
				}
			}			
			echo $result;
			wp_die();
		} //End woomelly_do_solve_multiple_product()

		public function woomelly_do_install_plugin () {
			$result = array(
				'button' => '',
				'message' => __("There was an unknown error. Please try again or contact technical support.", "woomelly"),
				'code' => 500
			);
			if ( isset($_POST['action'], $_POST['download_url'], $_POST['the_action'], $_POST['the_path']) && "woomelly_do_install_plugin" == $_POST['action'] && $_POST['download_url'] != "" && $_POST['the_action'] != "" && $_POST['the_path'] != "" ) {
				$download_url = trim($_POST['download_url']);
				$action = trim($_POST['the_action']);
				$plugin_path = trim($_POST['the_path']);
				$all_plugin_path = $plugin_path.'/'.$plugin_path.'.php';
				require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
				require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
				require_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php';
				$plugin_url = $download_url;
				$skin = new Automatic_Upgrader_Skin();
				$upgrader = new Plugin_Upgrader($skin);
				if ( $action == 'install' ) {
					if ( !is_plugin_active($all_plugin_path) ) {
						$install_plugin = $upgrader->install($plugin_url);
						if ( is_wp_error($install_plugin) ) {
							$result['message'] = $install_plugin->get_error_message();
						} else {
							$result['code'] = 200;
							$result['message'] = __( 'Plugin installed successfully!', 'woomelly' );
							$result['button'] = '<button type="button" class="button woomelly-install-plugin" data-wmslugplugin="'.$plugin_path.'" data-wmdownloadplugin="'.$download_url.'" data-wmactionplugin="activate">'.__("Activate now", "woomelly").'</button>';
						}
					} else {
						$result['code'] = 200;
						$result['message'] = __( 'Plugin installed successfully!', 'woomelly' );
						$result['button'] = '<button type="button" class="button woomelly-install-plugin" data-wmslugplugin="'.$plugin_path.'" data-wmdownloadplugin="'.$download_url.'" data-wmactionplugin="activate">'.__("Activate now", "woomelly").'</button>';
					}
				} else if ( $action == 'upgrade' ) {
					$upgrade_plugin = $upgrader->upgrade($all_plugin_path);
					if ( is_wp_error($upgrade_plugin) ) {
						$result['message'] = $upgrade_plugin->get_error_message();
					} else {
					    $activate_plugin = activate_plugin($all_plugin_path);
						if ( is_wp_error($activate_plugin ) ) {
							$result['message'] = $activate_plugin->get_error_message();
						} else {
							$result['code'] = 200;
							$result['message'] = __( 'Plugin updated successfully!', 'woomelly' );
							$result['button'] = '<button type="button" class="button button-disabled" disabled="disabled">'.__("Activated", "woomelly").'</button>';
						}
					}				
				} else if ( $action == 'activate' ) {
					if ( !is_plugin_active($all_plugin_path) ) {
					    $activate_plugin = activate_plugin($all_plugin_path);
						if ( is_wp_error($activate_plugin ) ) {
							$result['message'] = $activate_plugin->get_error_message();
						} else {
							$result['code'] = 200;
							$result['message'] = __( 'Plugin activated successfully!', 'woomelly' );
							$result['button'] = '<button type="button" class="button button-disabled" disabled="disabled">'.__("Activated", "woomelly").'</button>';
						}
					} else {
						$result['code'] = 200;
						$result['message'] = __( 'Plugin activated successfully!', 'woomelly' );
						$result['button'] = '<button type="button" class="button button-disabled" disabled="disabled">'.__("Activated", "woomelly").'</button>';						
					}
				}
			}
			wp_send_json( $result );
		} //End woomelly_do_install_plugin()		

		public function woomelly_do_activate_cron_dashboard () {
			$result = array(
				'message' => __("There was an unknown error. Please try again or contact technical support", "woomelly"),
				'code' => 500
			);
			if ( isset($_POST['action'], $_POST['cron_task']) && "woomelly_do_activate_cron_dashboard" == $_POST['action'] ) {
				$cron_task = trim( $_POST['cron_task'] );
				if ( $cron_task != "" && in_array($cron_task, array('cleanup_logs', 'refresh_token', 'meli_without_woo', 'woo_without_meli', 'remove_link_trash')) ) {
					if ( in_array($cron_task, array('meli_without_woo', 'woo_without_meli', 'remove_link_trash')) ) {
						if ( isset($_POST['checked_status']) && $_POST['checked_status'] != "" ) {
							$aux_checked_status = trim($_POST['checked_status']);
							$checked_status = 'desactivate';
							$checked_status_bool = false;
							if ( $aux_checked_status == 'yes' ) {
								$checked_status = 'activate_force';
								$checked_status_bool = true;
								$result['message'] = __( 'Scheduled task activated successfully. This runs once a day', 'woomelly' );
							} else {
								$result['message'] = __( 'Scheduled task disabled successfully. This runs once a day', 'woomelly' );								
							}
							$woomelly_get_tools = new WMTools();
							$woomelly_get_tools->set_crons_tools6_key( $cron_task, $checked_status_bool );
							$woomelly_get_tools->save();
							wm_migrate_crons_to_actions( $cron_task, $checked_status );
							$result['code'] = 200;
						}
					} else {
						wm_migrate_crons_to_actions( $cron_task, 'activate_force' );
						$result['message'] = __( 'Scheduled task activated successfully. Wait a few minutes', 'woomelly' );
						$result['code'] = 200;
					}
				}
			}		
			wp_send_json( $result );
		} //End woomelly_do_activate_cron_dashboard()

		public function woomelly_do_check_gtin_meli () {
			$result = array(
				'message' => __("There was an unknown error. Please try again or contact technical support", "woomelly"),
				'code' => 500
			);
			if ( isset($_POST['action'], $_POST['meli_gtin']) && "woomelly_do_check_gtin_meli" == $_POST['action'] ) {
				$meli_gtin = trim( $_POST['meli_gtin'] );
				if ( $meli_gtin != "" ) {
					$new_array_meli_gtin = array_map('trim', explode(',', $meli_gtin));
					if ( !empty($new_array_meli_gtin) ) {
						$html = "<table style='margin-top: 16px;' class='widefat'><tbody>";
						foreach( $new_array_meli_gtin as $value ) {
							$html = $html . "<tr><td><strong>".$value."</strong></td>";
							$url = 'https://api.mercadolibre.com/product-identifier/validator?product_identifier=' . $value;
							$response = wp_remote_get( $url );
							$validator = json_decode( wp_remote_retrieve_body($response), true );
							if ( is_array($validator) && isset($validator['valid']) && $validator['valid'] == true ) {
								$html = $html . '<td><span style="color: green;">'.__("This code is valid in Mercado Libre", "woomelly").'</span></td>';
							} else {
								$html = $html . '<td><span style="color: red;">'.__("This code is invalid in Mercado Libre. It must be registered internationally in GS1. If you can't find another one, you can contact the manufacturer or distributor.", "woomelly").'</span></td>';
							}
							$html = $html . "</tr>";
						}
						$html = $html . "</tbody></table>";
						$result['code'] = 200;
						$result['message'] = $html;
					} else {
						$result['message'] = __( 'Please enter a unique code so we can verify it', 'woomelly' );
					}
				} else {
					$result['message'] = __( 'Please enter a unique code so we can verify it', 'woomelly' );					
				}
			}		
			wp_send_json( $result );
		} //End woomelly_do_check_gtin_meli()

		public function woomelly_do_shipping_mark_delivered () {
			$result = array(
				'message' => __("There was an unknown error. Please try again or contact technical support", "woomelly"),
				'code' => 500
			);
			if ( isset($_POST['action'], $_POST['id_order']) && "woomelly_do_shipping_mark_delivered" == $_POST['action'] ) {
				$id_order = trim( $_POST['id_order'] );
				if ( $id_order != "" ) {
					$data = array(
						'fulfilled' => true,
						'rating' => 'positive',
					);
					$rs = WMeli::post_feedback( $id_order, $data );
					if ( is_object($rs) && isset($rs->fulfilled) && $rs->fulfilled == true ) {
						global $wm_all_settings;
						$result['code'] = 200;
						$result['message'] = __("Brilliant! The order was marked as completed on Mercado Libre successfully.", "woomelly");
						do_action( 'woomelly_notification_orders', '/orders/' . $id_order, null, $wm_all_settings, true );
					} else {
						$result['message'] = __("Oops! There was an error in Mercado Libre. Perhaps the order is already marked as completed. Please check and try again.", "woomelly");						
					}
				} else {
					$result['message'] = __( 'You need the Mercado Libre order ID', 'woomelly' );					
				}
			}		
			wp_send_json( $result );
		} //End woomelly_do_shipping_mark_delivered()

		public function woomelly_do_shipping_change_custom_status () {
			$result = array(
				'message' => __("There was an unknown error. Please try again or contact technical support", "woomelly"),
				'code' => 500
			);
			if ( isset($_POST['action'], $_POST['id_order'], $_POST['wc_id_order']) && "woomelly_do_shipping_change_custom_status" == $_POST['action'] ) {
				$id_order = trim( $_POST['id_order'] );
				$wc_id_order = trim( $_POST['wc_id_order'] );				
				$shipment_id = ( (isset($_POST['wm_shipment_id']))? trim($_POST['wm_shipment_id']) : "" );
				$meli_status = ( (isset($_POST['wm_meli_status']))? trim($_POST['wm_meli_status']) : "" );
				$receiver_id = ( (isset($_POST['wm_receiver_id']))? trim($_POST['wm_receiver_id']) : "" );
				$shipping_status = ( (isset($_POST['wm_shipping_status']))? trim($_POST['wm_shipping_status']) : "" );
				$shipping_observations = ( (isset($_POST['wm_shipping_observations']))? trim($_POST['wm_shipping_observations']) : "" );
				$shipping_tracking_number = ( (isset($_POST['wm_shipping_tracking_number']))? trim($_POST['wm_shipping_tracking_number']) : "" );
				$shipping_days = ( (isset($_POST['wm_shipping_days']))? trim($_POST['wm_shipping_days']) : "" );
				if ( $id_order != "" && $wc_id_order != "" && $shipment_id != "" && $receiver_id != "" ) {
					if ( in_array($meli_status, ['pending', 'shipped', 'delivered', 'cancelled']) ) {
						if ( $meli_status == "cancelled" ) {
							$result['message'] = __( 'Oops! The order is already canceled, so you cannot modify it to a new status.', 'woomelly' );
						} else if ( $meli_status == "delivered" ) {
							$result['message'] = __( 'Oops! The order has already been delivered, so you cannot modify it to a new status.', 'woomelly' );
						} else if ( $meli_status == "shipped" ) {
							if ( !in_array($shipping_status, ['delivered', 'cancelled', 'modify_delivery_time']) ) {
								$result['message'] = __( 'Oops! You can only change to one of these statuses: Delivered or Cancelled. Try again!', 'woomelly' );
							} else {
								if ( $shipping_status == "modify_delivery_time" ) {
									if ( $shipping_tracking_number == "" ) {
										$result['message'] = __( 'Oops! It is mandatory to set a tracking number to be able to change the Mercado Libre order to shipped. Try again!', 'woomelly' );
									} else if ( mb_strlen($shipping_tracking_number) > 120 ) {
										$result['message'] = __( 'Oops! Only 120 characters are allowed in the tracking code. Try again!', 'woomelly' );
									} else {
										$data_mark_order = array("receiver_id" => $receiver_id, 'tracking_number' => $shipping_tracking_number);
										if ( $shipping_observations != "" ) {
											if ( mb_strlen($shipping_observations) > 120 ) {
												$shipping_observations = mb_substr($shipping_observations, 0, 120);
											}
											$data_mark_order['comments'] = $shipping_observations;
										}
										if ( intval($shipping_days)>0 ) {
											$data_mark_order['speed'] = intval($shipping_days) * 24;
										}
										$rs = WMeli::put_shipments( $shipment_id, $data_mark_order );
										if ( is_object($rs) && isset($rs->status) && $rs->status == "shipped" ) {
											$result['code'] = 200;
											$result['message'] = __("Brilliant! The shipment delivery time has been successfully modified.", "woomelly");
											global $wm_all_settings;
											do_action( 'woomelly_notification_orders', '/orders/' . $id_order, null, $wm_all_settings, true );
										} else {
											$result['message'] = __("Oops! There was an unknown error with Mercado Libre. Please try again or contact technical support", "woomelly");
										}
									}
								} else {
									$data_mark_order = array("status" => $shipping_status, "receiver_id" => $receiver_id);
									$rs = WMeli::put_shipments( $shipment_id, $data_mark_order );
									if ( is_object($rs) ) {
										$status_marked = ( ($shipping_status=='delivered')? __('delivered', 'woomelly') : __('cancelled', 'woomelly') );
										$result['code'] = 200;
										$result['message'] = sprintf(__("Brilliant! The order was marked as %s on Mercado Libre successfully.", "woomelly"), $status_marked);
										if ( $shipping_status == 'cancelled' ) {
											$wc_order = wc_get_order( $wc_id_order );
											if ( $wc_order ) {
												$wc_order->update_status( apply_filters('wm_filter_wc_status_cancelled', 'cancelled') );
											}
										} else {
											global $wm_all_settings;
											do_action( 'woomelly_notification_orders', '/orders/' . $id_order, null, $wm_all_settings, true );
										}
									} else {
										$result['message'] = __("Oops! There was an unknown error with Mercado Libre. Please try again or contact technical support", "woomelly");
									}
								}
							}
						} else {
							if ( !in_array($shipping_status, ['shipped', 'delivered', 'cancelled']) ) {
								$result['message'] = __( 'Oops! You can only change to one of these statuses: Shipped, Delivered or Cancelled. Try again!', 'woomelly' );
							} else {
								if ( in_array($shipping_status, ['delivered', 'cancelled']) ) {
									$data_mark_order = array("status" => $shipping_status, "receiver_id" => $receiver_id);
									$rs = WMeli::put_shipments( $shipment_id, $data_mark_order );
									if ( is_object($rs) ) {
										$status_marked = ( ($shipping_status=='delivered')? __('delivered', 'woomelly') : __('cancelled', 'woomelly') );
										$result['code'] = 200;
										$result['message'] = sprintf(__("Brilliant! The order was marked as %s on Mercado Libre successfully.", "woomelly"), $status_marked);
										if ( $shipping_status == 'cancelled' ) {
											$wc_order = wc_get_order( $wc_id_order );
											if ( $wc_order ) {
												$wc_order->update_status( apply_filters('wm_filter_wc_status_cancelled', 'cancelled') );
											}
										} else {
											global $wm_all_settings;
											do_action( 'woomelly_notification_orders', '/orders/' . $id_order, null, $wm_all_settings, true );
										}
									} else {
										$result['message'] = __("Oops! There was an unknown error with Mercado Libre. Please try again or contact technical support", "woomelly");
									}
								} else {
									if ( $shipping_tracking_number == "" ) {
										$result['message'] = __( 'Oops! It is mandatory to set a tracking number to be able to change the Mercado Libre order to shipped. Try again!', 'woomelly' );
									} else if ( mb_strlen($shipping_tracking_number) > 120 ) {
										$result['message'] = __( 'Oops! Only 120 characters are allowed in the tracking code. Try again!', 'woomelly' );
									} else {
										$data_mark_order = array("status" => $shipping_status, "receiver_id" => $receiver_id, 'tracking_number' => $shipping_tracking_number);
										if ( $shipping_observations != "" ) {
											if ( mb_strlen($shipping_observations) > 120 ) {
												$shipping_observations = mb_substr($shipping_observations, 0, 120);
											}
											$data_mark_order['comments'] = $shipping_observations;
										}
										if ( intval($shipping_days)>0 ) {
											$data_mark_order['speed'] = intval($shipping_days) * 24;
										}
										$rs = WMeli::put_shipments( $shipment_id, $data_mark_order );
										if ( is_object($rs) && isset($rs->status) && $rs->status == "shipped" ) {
											$result['code'] = 200;
											$status_marked = __('shipped', 'woomelly');
											$result['message'] = sprintf(__("Brilliant! The order was marked as %s on Mercado Libre successfully.", "woomelly"), $status_marked);
											global $wm_all_settings;
											do_action( 'woomelly_notification_orders', '/orders/' . $id_order, null, $wm_all_settings, true );
										} else {
											$result['message'] = __("Oops! There was an unknown error with Mercado Libre. Please try again or contact technical support", "woomelly");
										}
									}
								}
							}
						}
					} else {
						$result['message'] = __( 'Oops! The allowed states are: Pending, Shipped, Delivered and Cancelled. Try again and if the problem persists, contact technical support.', 'woomelly' );
					}
				} else {
					$result['message'] = __( 'Oops! You need the Mercado Libre order ID and shipment ID and customer ID. Try again!', 'woomelly' );					
				}
			}		
			wp_send_json( $result );
		} //End woomelly_do_shipping_change_custom_status()
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit