array( // WPCS: XSS ok.
'base' => $base,
'format' => $format,
'add_args' => false,
//'current' => max( 1, $current ),
// 'current' => max( 1, get_query_var( 'paged' ) ),
'current' => $current,
'total' => $total,
'prev_text' => '←',
'next_text' => '→',
'type' => 'list',
'end_size' => 3,
'mid_size' => 3,
)
<?php
// Store cart weight in the database
add_action('woocommerce_checkout_update_order_meta', 'woo_add_cart_weight');
function woo_add_cart_weight( $order_id ) {
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
update_post_meta( $order_id, '_cart_weight', $weight );
}
// Add order new column in administration
add_filter( 'manage_edit-shop_order_columns', 'woo_order_weight_column', 20 );
function woo_order_weight_column( $columns ) {
$offset = 8;
$updated_columns = array_slice( $columns, 0, $offset, true) +
array( 'total_weight' => esc_html__( 'Weight', 'woocommerce' ) ) +
array_slice($columns, $offset, NULL, true);
return $updated_columns;
}
// Populate weight column
add_action( 'manage_shop_order_posts_custom_column', 'woo_custom_order_weight_column', 2 );
function woo_custom_order_weight_column( $column ) {
global $post;
if ( $column == 'total_weight' ) {
$weight = get_post_meta( $post->ID, '_cart_weight', true );
if ( $weight > 0 )
print $weight . ' ' . esc_attr( get_option('woocommerce_weight_unit' ) );
else print 'N/A';
}
}
$answer = [
1 => [2,3,4,5,52],
2 => [7,8,9,52],
3 => [10,11,12,25],
];
$bd = [
[
'id' => 2,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 3,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 4,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 5,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 7,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 8,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 9,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 10,
'id_question' => 3,
'correct_answer' => 1,
],
[
'id' => 11,
'id_question' => 3,
'correct_answer' => 1,
],
[
'id' => 12,
'id_question' => 3,
'correct_answer' => 1,
],
[
'id' => 13,
'id_question' => 4,
'correct_answer' => 1,
],
[
'id' => 14,
'id_question' => 4,
'correct_answer' => 1,
],
[
'id' => 15,
'id_question' => 4,
'correct_answer' => 1,
],
];
$quests = [];
foreach ($bd as $bd_element) {
$quests[$bd_element['id_question']][] = $bd_element['id'];
}
$a = 0;
foreach ($quests as $id_quest => $ans) {
$is = true;
echo '<br><br>Вопрос: №'.$id_quest.'<br>';
foreach ($ans as $an) {
if (array_search($an, $answer[$id_quest]) === false) $is = false;
echo 'Правильные ответы: '.$an.'<br>';
}
foreach ($answer[$id_quest] as $answer_give) {
if (array_search($answer_give, $ans) === false) $is = false;
echo 'Дан ответ: '.$answer_give.'<br>';
}
if ($is) $a++;
}
echo '<br><br>Правильных ответов: '.$a.'<br>';
$quests = [];
foreach ($bd as $bd_element) {
$quests[$bd_element['id_question']][] = $bd_element['id'];
}
$a = 0;
foreach ($quests as $id_quest => $ans) {
$is = true;
echo '<br><br>Вопрос: №'.$id_quest.'<br>';
foreach ($ans as $an) {
if (array_search($an, $answer[$id_quest]) === false) $is = false;
echo 'Правильные ответы: '.$an.' - '.$is.'<br>';
}
foreach ($answer[$id_quest] as $answer_NEW) {
if (array_search($answer_NEW, $ans) === false) $is = false;
echo 'Дан ответ: '.$answer_NEW.' - '.$is.'<br>';
}
if ($is) $a++;
}
if ($test) {
$answer = [
1 => [2,3,4,5,20],
2 => [7,8,9,24],
3 => [10,11,12],
];
$bd = [
[
'id' => 2,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 3,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 4,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 5,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 7,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 8,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 9,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 10,
'id_question' => 3,
'correct_answer' => 1,
],
[
'id' => 11,
'id_question' => 3,
'correct_answer' => 1,
],
[
'id' => 12,
'id_question' => 3,
'correct_answer' => 1,
],
];
$quests = [];
foreach ($bd as $bd_element) {
$quests[$bd_element['id_question']][] = $bd_element['id'];
}
$a = 0;
foreach ($quests as $id_quest => $ans) {
$is = true;
echo '<br><br>Вопрос: №'.$id_quest.'<br>';
foreach ($ans as $an) {
if (array_search($an, $answer[$id_quest]) === false) $is = false;
echo 'Правильные ответы: '.$an.' - '.$is.'<br>';
}
foreach ($answer[$id_quest] as $answer) {
if (array_search($answer, $ans) === false) $is = false;
echo 'Дан ответ: '.$answer.' - '.$is.'<br>';
}
if ($is) $a++;
}
//echo 'Правильных ответов: '.$a.'<br>';
exit;
}
if ($test) {
$answer = [
1 => [2,3,4,5,12], // считает правильно, т.е. учитывает неправильные ответы
2 => [7,8,9,15,20], // при любом значении в массиве, считает как правильный ответ. Т.е всегда показывает Правильных ответов: 1
];
$bd = [
[
'id' => 2,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 3,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 4,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 5,
'id_question' => 1,
'correct_answer' => 1,
],
[
'id' => 7,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 8,
'id_question' => 2,
'correct_answer' => 1,
],
[
'id' => 9,
'id_question' => 2,
'correct_answer' => 1,
],
];
$quests = [];
foreach ($bd as $bd_element) {
$quests[$bd_element['id_question']][] = $bd_element['id'];
}
$a = 0;
foreach ($quests as $id_quest => $ans) {
$is = true;
foreach ($ans as $an) {
if (array_search($an, $answer[$id_quest]) === false) $is = false;
}
foreach ($answer[$id_quest] as $answer) {
if (array_search($answer, $ans) === false) $is = false;
}
if ($is) $a++;
}
echo 'Правильных ответов: '.$a.'<br>';
exit;
}
Когда я столкнулся с TTFB, мне помогла только смена хостера.
Успехов!