add_filter( 'nav_menu_css_class', function ( $classes, $item, $args, $depth ) {
if ( $args->theme_location === 'header-blog' ) {
if (in_array('menu-item-has-children', $classes)) {
$classes = [ 'nav-item', 'dropdown' ];
} else {
$classes = [ 'nav-item' ];
}
} else {
$classes = [];
}
return $classes;
}, 10, 4 );
Подскажите пожалуйста, как реализовать такую штуку?
While checking against particular roles in place of a capability is supported in part, this practice is discouraged as it may produce unreliable results.
post_gallery
.<?php
function my_post_gallery( $output, $attr, $instance ) {
$_attachments = get_posts( array('include' => $attr['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => $attr['orderby']) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
if ( empty( $attachments ) ) {
return '';
}
ob_start();
?>
<div class="gallery">
<?php
foreach ( $attachments as $i => $image ) :
$url = wp_get_attachment_url( $image->ID );
?>
<a href="<?php echo $url; ?>" class="gallery-item">
<?php echo wp_get_attachment_image( $image->ID, 'thumbnail' ); ?>
</a>
<?php endforeach; ?>
</div>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_filter( 'post_gallery', 'my_post_gallery', 10, 3 );
add_action( 'pre_get_posts', 'tax_filter' );
function tax_filter( $query ){
if( ! is_admin() && $query->is_main_query() ){
if( $query->is_tax( 'object' ) ){
$query->set( 'posts_per_page', '3' );
}
}
}
function foo_theme_customize_register( WP_Customize_Manager $wp_customize ) {
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'container_inclusive' => false,
'render_callback' => function() {
bloginfo( 'description' );
},
) );
}
add_action( 'customize_register', 'foo_theme_customize_register' );
add_action('customize_register', 'dco_customize_register');
function dco_customize_register($wp_customize) {
//FOOTER
$wp_customize->add_section('footer', array(
'title' => 'Подвал',
'priority' => 1,
));
//footer text
$setting_name = 'footer_text';
$wp_customize->add_setting($setting_name, array(
'default' => '',
'sanitize_callback' => 'sanitize_textarea_field',
'transport' => 'postMessage'
));
$wp_customize->add_control($setting_name, array(
'section' => 'footer',
'type' => 'textarea',
'label' => 'Текст в подвале',
));
$wp_customize->selective_refresh->add_partial($setting_name, array(
'selector' => '.footer-desc',
'render_callback' => function() use ($setting_name) {
return nl2br(get_theme_mod($setting_name));
}
));
}
<div class="footer-desc"><?php echo nl2br(get_theme_mod('footer_text')); ?></div>
if(!empty($vid_oblojki) && mb_substr($vid_oblojki,'глянцевая')) :
// код
endif;
if ( ! empty( $vid_oblojki ) && mb_substr( implode( '', $vid_oblojki ), 'Глянцевая' ) ) :
endif;
<select name="cover_type" id="cover_type">
<options value="">Выберите вид обложки</options>
<options value="1">Мягкая</options>
<options value="2">Глянцевая</options>
</select>
if(!empty($vid_oblojki) && 2 === (int)$vid_oblojki) :
// код
endif;
$('.all-blocks.color-blocks .block').attr('id', function(i, id) {
return $(this).hasClass(id) ? `${id}_2` : id;
});
document.querySelectorAll('.all-blocks.color-blocks .block').forEach(n => {
n.id += n.classList.contains(n.id) ? '_2' : '';
});
<script src="/path/to/js.cookie.js"></script>
$(document).ready(function(){
if (!getCookie('cook_banner')) {
window.setTimeout(function () {
$('.banner').css('display', 'block');
$('.banner_close').click(function () {
$('.banner').css('display', 'none');
setCookie('cook_banner', true, 1);
});
}, 3000);
}
});
pointer-events: none;
, чтобы клики проходили сквозь картинку и добирались до самого iframe.