ACF_Admin_Tool_Export::html_generate() public ACF 5.6.3
description
{} Это метод класса: ACF_Admin_Tool_Export{}
Хуков нет.
Возвращает
n/a.
Использование
$ACF_Admin_Tool_Export = new ACF_Admin_Tool_Export();
$ACF_Admin_Tool_Export->html_generate();
- (n/a) (обязательный)
Список изменений
Код ACF_Admin_Tool_Export::html_generate() ACF Admin Tool Export::html generate
ACF 5.9.1
<?php
function html_generate() {
// prevent default translation and fake __() within string
acf_update_setting('l10n_var_export', true);
// vars
$json = $this->get_selected();
$str_replace = array(
" " => "\t",
"'!!__(!!\'" => "__('",
"!!\', !!\'" => "', '",
"!!\')!!'" => "')",
"array (" => "array("
);
$preg_replace = array(
'/([\t\r\n]+?)array/' => 'array',
'/[0-9]+ => array/' => 'array'
);
?>
<p><?php _e("The following code can be used to register a local version of the selected field group(s). A local field group can provide many benefits such as faster load times, version control & dynamic fields/settings. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
<textarea id="acf-export-textarea" readonly="true"><?php
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
foreach( $json as $field_group ) {
// code
$code = var_export($field_group, true);
// change double spaces to tabs
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
// correctly formats "=> array("
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
// esc_textarea
$code = esc_textarea( $code );
// echo
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
}
echo "endif;";
?></textarea>
<p class="acf-submit">
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
</p>
<script type="text/javascript">
(function($){
// vars
var $a = $('#acf-export-copy');
var $textarea = $('#acf-export-textarea');
// remove $a if 'copy' is not supported
if( !document.queryCommandSupported('copy') ) {
return $a.remove();
}
// event
$a.on('click', function( e ){
// prevent default
e.preventDefault();
// select
$textarea.get(0).select();
// try
try {
// copy
var copy = document.execCommand('copy');
if( !copy ) return;
// tooltip
acf.newTooltip({
text: "<?php _e('Copied', 'acf' ); ?>",
timeout: 250,
target: $(this),
});
} catch (err) {
// do nothing
}
});
})(jQuery);
</script>
<?php
}