$files = $_FILES[ "photo" ];
$_ids = $_errors = [];
foreach ( $files[ 'name' ] as $key => $value ) {
if ( $files[ 'name' ][ $key ] ) {
$file = array (
'name' => $files[ 'name' ][ $key ],
'type' => $files[ 'type' ][ $key ],
'tmp_name' => $files[ 'tmp_name' ][ $key ],
'error' => $files[ 'error' ][ $key ],
'size' => $files[ 'size' ][ $key ]
);
$_FILES = array ( "rev_foto" => $file );
$attachment_id2 = media_handle_upload( "rev_foto", 0 );
if ( is_wp_error( $attachment_id2 ) ) {
$_errors[] = $attachment_id2->get_error_message();
} else {
$_ids[] = $attachment_id2;
}
}
}
if ( ! empty( $_ids ) ) {
update_field( 'rev_foto', $_ids, $post_id );
}
if ( ! empty( $_errors ) ) {
sprintf( 'А вот, что пошло не так: %s', implode( ' ,', $_errors ) );
}
$_flag = []; // онтрольный массив
if ( have_posts() ) : while ( have_posts() ) : the_post();
$first = mb_substr( get_the_title(), 0, 1 );
if ( ! in_array( $first, $_flag ) ) { //проверка на наличие первой буквы в массиве
// если ее там нет, выводим букву и добавляем в контрольный мавссив
printf( '<h3>%s</h3>', $first );
$_flag[] = $first;
}
/**
* тут выод записи
*/
endwhile;
else :
endif;
add_filter( 'wpcf7_form_elements', 'wpcf7_remove_span_wrapper' );
function wpcf7_remove_span_wrapper( $content ) {
$str_pos = strpos( $content, 'target-class' );
if ( $str_pos !== false ) {
$content = preg_replace( '/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content );
$content = str_replace( '<br />', '', $content );
}
return $content;
}
'order' => 'DESC',
'orderby' => 'meta_value_num',
'meta_query' => [
[
'relation' => 'OR',
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
],
[
'key' => '_thumbnail_id',
'compare' => '!NOT EXISTS'
]
]
$out = '';
$html = <<<HTML
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--%s">
<th class="woocommerce-product-attributes-item__label">%s</th>
<td class="woocommerce-product-attributes-item__value">%s</td>
</tr>
HTML;
$i = 1;
foreach ( $product_attributes as $attribute ):
$attribute_data = $attribute->get_data();
if ( $i !== 3 ) {
$out .= sprintf( $html, esc_attr( $attribute_data['name'] ), wc_attribute_label( $attribute_data['name'], $product->get_attribute( $attribute_data['name'] ) ) );
} else {
printf( $html, esc_attr( $attribute_data['name'] ), wc_attribute_label( $attribute_data['name'], $product->get_attribute( $attribute_data['name'] ) ) );
}
$i ++;
endforeach;
echo $out;