/**
* Nella tabella del frontend: Nell'HTML dove è stato messo lo shortcode [adfo_list id=xx] inserisco un html personalizzato ''
*/
function load_in_custom_box($custom_link, $list_id, $primary_values, $col_value, $col_key) {
return ''
.strip_tags($col_value).'';
}
add_filter('adfo_frontend_build_custom_link', 'load_in_custom_box', 10, 5);
/**
* Nella tabella del frontend: Mostra un testo alternativo nel totale degli elementi mostrati di una tabella
*/
function dbp_total_items( $total_items_text, $list_id, $total_items, $limit, $curr_page, $pages) {
$min = (($curr_page -1) * $limit) + 1;
$max = (($curr_page) * $limit);
return sprintf( "Showing %s to %s of %s entries", $min, $max, $total_items);
}
add_filter('adfo_frontend_total_items', 'dbp_total_items', 10, 6);
/**
* Nascondo l'header
*/
function dbp_total_items($header_text, $list_id, $array_thead) {
return '';
}
add_filter('adfo_frontend_table_thead', 'dbp_hide_thead', 10, 3);
/**
* impedisco la modifica della tabella post
*/
function dbp_lock_post_table($status, $table) {
global $wpdb;
// $status = DRAFT|PUBLISH|CLOSE
if ($table == $wpdb->prefix."posts") {
$status = 'CLOSE';
}
return $status;
}
add_filter('adfo_table_status', 'dbp_lock_post_table', 10, 2);
/**
* Salvo un post e ne modifico il titolo dal filtro
*/
function test_dbp($status, $table) {
$list_id = '[number_of_list_id]'; // è una lista che carica i dati dei post;
$row = new StdClass();
$row->post_title = "new record";
$ris = admin_form\ADFO::save_data($dbpid, $row);
}
add_action( 'init', 'test_dbp' );
function dbp_action_in_save_data($query_to_execute, $list_id, $where) {
// cambio il titolo
$query_to_execute[0]['sql_to_save']['post_title'] = "Change the title";
return $query_to_execute;
}
add_filter('adfo_save_data', 'dbp_action_in_save_data', 10, 3);
/**
* change search form example
*/
function dbp_frontend_field_search_fn($field_name, $input_field_name, $list_id) {
if ($field_name == "search") {
?>
<div class="dbp-search-row">
<label><span class="dbp-search-label">Search Field</span>
<?php admin_form\ADFO_fn::html_select(['0'=>'No','1'=>'Yes'], true, 'class="dbp-search-input js-dbp-search-input" name="'. esc_attr($input_field_name).'"', @$_REQUEST[$input_field_name]); ?>
</label>
<div class="dbp-search-button dbp-search-button-blue" onclick="dbp_submit_simple_search(this)"><?php _e('Search', 'admin_form'); ?></div>
</div>
<?php
// to prevent input printing
return '';
} else {
// print the search field normally
return $field_name;
}
}
add_filter('adfo_frontend_search', 'dbp_frontend_field_search_fn', 10, 3);
function my_custom_list($render_data, $list_id) {
if ($list_id != 6) return ''; // 6 is an example
ob_start();
$list = admin_form\ADFO::render($list_id, 'ajax');
$list->table();
$list->pagination();
$list->end(); // Required!
return ob_get_clean();
}
add_filter('adfo_frontend_get_list', 'my_custom_list', 10, 2);
I parametri accettati sono: $param, $gvalue, $count_for
add_filter('pinacode_attribute_tmpl', 'bold_pinacode_attribute_tmpl', 10, 3 );
function bold_pinacode_attribute_tmpl( $param, $gvalue, $count_for ) {
if ($param == "bold") {
$item = PinaCode::get_var('item');
$html = [];
foreach ($item as $k=>$v) {
$html[] = "".$k."";
}
$param = implode("", $html);
}
return $param;
}
add_action( 'adfo_items_add_action', 'fn_adfo_items_add_action', 10, 3 );
function fn_adfo_items_add_action($btns, $dbp_id, $count_unique_id) {
if ( $dbp_id == 'xxx') {
$alert = "alert('ids: '+JSON.stringify(dbp_tb_id[".$count_unique_id."]))";
$btns[] = '<span class="dbp-submit-style-link" onclick="'.$alert.'">Alert</span>';
}
return $btns;
}
add_action( 'adfo_admin_page_list_after_title', function($dbp_id, $count_items) {echo 'adfo_admin_page_list_after_title ID:'.$dbp_id.' total_items: '.$count_items.'';}, 10, 2 );
add_action( 'adfo_list_admin_controller', function($section) {
if ($section != 'custom-section') return;
echo "Here custom section"; };
} );
add_action( 'adfo_list_admin_controller', function($bool, $section) {
return ($section == 'custom-section') ? false : $bool;
} );