Funciones

Showing posts in calendar view based on start of the day

add_shortcode('ts_day_week_start', function($atts){
    $atts = shortcode_atts( array(
        'day' => 'Monday',
    ), $atts);
    $res = strtotime('last ' . $atts['day']);
    if(date('l') == $atts['day']){
        $res = strtotime('this ' . $atts['day']);
    }
    return $res;
});
 
 
add_shortcode('ts_day_week_end', function($atts){
    $atts = shortcode_atts( array(
        'day' => 'Monday',
    ), $atts);
    $res = strtotime('last ' . $atts['day']);
    if(date('l') == $atts['day']){
        $res = strtotime('this ' . $atts['day']);
    }
    $res = strtotime("tomorrow", $res) - 1;
    return $res;
});
[wpv-view name="schedule-view" cached="off" tsstart="[ts_day_week_start day='Friday']" tsend="[ts_day_week_end day='Friday']"]

Visto en Toolset

Mostrar campos de usuario en la columna del administrador

function new_modify_user_table( $column ) {
    $column['test-1'] = 'test 1';
    $column['test-2'] = 'test 2';
    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 'test-1' :
            return get_user_meta($user_id, 'wpcf-test-1', true);
        case 'test-2' :
            return get_user_meta($user_id, 'wpcf-test-2', true);
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

Visto en toolset

Función para obtener y utilizar la url del tema en un shortcode

Shortcode para ahorrarnos poner ruta absoluta a la hora d eir a buscar recursos al directorio del tema. La imagen se encontrará dentro del tema utilizado:a función la insertamos dentro de functions.php

function theme_url_shortcode( $attrs = array (), $content = '' ) {
    $theme = ( is_child_theme() ? get_stylesheet_directory_uri() : get_template_directory_uri() );
    return $theme;  
}
add_shortcode('theme', 'theme_url_shortcode' );

Ejemplo de uso

<img src="[theme]/images/image-name.jpg" width="250" height="250" alt="This is an image" />

Visto en TheWebTaylor

Ir arriba

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.