<?php
$pub_date = strtotime(get_the_date("Y-m-d H:i:s")) + 30*24*60*60;
$cur_date = strtotime(date("Y-m-d H:i:s")); ?>
<span class="time <?php if($pub_date >= $cur_date ){ echo 'shownew';}?>"><?php the_time('Y.m.d'); ?></span>
嵌入视频静音方法
在地址后面添加 &mute=1
<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&autoplay=1&mute=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>
slick 同步幻灯片 自动播放的方法
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
autoplay:true,
//trigger after the slide appears
// i is current slide index
onAfterChange:function(slickSlider,i){
//remove all active class
$('.slider-nav .slick-slide').removeClass('slick-active');
//set active class for current slide
$('.slider-nav .slick-slide').eq(i).addClass('slick-active');
}
});
//set active class to first slide
$('.slider-nav .slick-slide').eq(0).addClass('slick-active');
Ajax
https://api.jquery.com/jQuery.ajax/
/*enqueue localize*/
wp_enqueue_script('script-js', get_template_directory_uri() . '/js/script.js', array('jquery'), '1.0.0', false);
//ajax
wp_localize_script( 'script-js', 'frontend_ajax_object',
array(
'home' => get_option('home'),
)
);
/*script pkb*/
var $obj_id = $('.single-salon-collection .num').attr('id');
$.ajax({
url: frontend_ajax_object.home + '/salon-collection/',
context: document.body
}).done(function(data) {
var $number = $(data).find('#' + $obj_id).find('.order').html();
$('.single-salon-collection .num').html($number);
});
Mange users columns
Add columns:
function new_modify_user_table( $column ) {
$column['phone'] = 'Phone';
$column['xyz'] = 'XYZ';
return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );
function new_modify_user_table_row( $val, $column_name, $user_id ) {
switch ($column_name) {
case 'phone' :
return get_the_author_meta( 'phone', $user_id );
case 'xyz' :
return '';
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
Remove columns:
$c = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘username’ => __( ‘Username’ ), ‘name’ => __( ‘Name’ ), ’email’ => __( ‘E-mail’ ), ‘role’ => __( ‘Role’ ), ‘posts’ => __( ‘Posts’ ) ); |
If for example you need to remove E-mail column you should unset a column with ’email’ ID. Let’s go to the final step:
add_filter('manage_users_columns','remove_users_columns');
function remove_users_columns($column_headers) {
if (current_user_can('moderator')) {
unset($column_headers['email']);
}
return $column_headers;
}
We use manage_users_columns
filter to achieve this purpose. This code removes ‘E-mail’ folder for users with ‘moderator’ role. Replace it with your own one.
In order to remove other column replace ’email’ column ID to that column ID: role, posts, etc.
Other variant for the list of roles:
add_filter('manage_users_columns','remove_users_columns');
function remove_users_columns($column_headers) {
$roles = array('moderator', 'users-list-viewer');
foreach($roles as $role) {
if (current_user_can($role)) {
unset($column_headers['email']);
break;
}
}
return $column_headers;
}
Another variant for the list of users ID:
add_filter('manage_users_columns','remove_users_columns');
function remove_users_columns($column_headers) {
global $current_user;
$users = array(27, 70530, 70531, 70532);
if (in_array($current_user->ID, $users)) {
unset($column_headers['email']);
}
return $column_headers;
}