function wtf_this(){
foreach ( debug_backtrace() as $called_file ) {
foreach ( $called_file as $index ) {
if ( !is_array($index[0]) AND strstr($index[0],'/themes/') AND !strstr($index[0],'footer.php') ) {
$template_file = $index[0] ;
}
}
}
$template_contents = file_get_contents($template_file) ;
preg_match_all("see:(.*)\n)siU",$template_contents,$template_name);
$template_name = trim($template_name[1][0]);
if ( !$template_name ) { $template_name = '(default)' ; }
$template_file = array_pop(explode('/themes/', basename($template_file)));
echo $template_file . ' -> '. $template_name ;
}
// обычно цепляю сюда
add_action('get_header','wtf_this',200);
function custom_shortcode_scripts() {
global $post;
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'custom-shortcode') ) {
wp_enqueue_script( 'custom-script');
}
}
add_action( 'wp_enqueue_scripts', 'custom_shortcode_scripts');
jQuery(function($){
$(document).ready(function(){
function test(){
if( ! $( ".office-accordion" ).length ) return false;
$( ".office-accordion" ).accordion({heightStyle: "content"});
}
test();
});
});
$thumb_ID = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
function new_weather () {
// Выдача из транзитного кэша
$cached = get_transient( 'weather_cache' );
if ( $cached !== false )
return $cached;
$result = simplexml_load_file( 'http://export.yandex.ru/weather-ng/forecasts/27612.xml' );
$temperature = $result->fact->temperature;
// Запись в транзитный кэш на 1 час
set_transient( 'weather_cache', $temperature, 1 * HOUR_IN_SECONDS );
return $temperature;
}
$('.modal-post').click(function(){
var data={
action: 'modal_post_action',
security : CrAjax.security,
id: $(this).data('post')
}
$.post(CrAjax.ajaxurl, data, function(response) {
$('#modal-2 .modal-content').html(response);
});
})
function modal_post_action_callback() {
check_ajax_referer( 'cr-special-ajax', 'security' );
$id = (int) $_POST['id'];
$array = array(
'post_type' => 'collection',
'post__in' => array($id)
);
$query = new WP_Query($array); // можно через get_post();
global $withcomments; // если хотите добавить форму комментариев
$withcomments =1; // для того же
while ( $query->have_posts() ) {
$query->the_post();
// тут цикл
die();
}
add_action( 'wp_ajax_modal_post_action', 'modal_post_action_callback' );
add_action( 'wp_ajax_nopriv_modal_post_action', 'modal_post_action_callback' );
wpcf7_mail_sent,
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$formdata = $submission->get_posted_data();
$email = $formdata['your-email'];
// бла бла бла
}
<?php global $redux_demo;
$logo = $redux_demo['logo-upload']['url'];
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<?php if( ! empty($logo) ) {
bloginfo( 'name' ); ?>
</a>
<?php bloginfo( 'description' );
} else { ?>
<img src="<?php echo $logo; ?>"/>
</a>
<?php } ?>
$term = get_term_by('slug', $post_port, 'portfolio_category');
echo term_description($term->term_id, 'portfolio_category');
function my_styles() {
wp_enqueue_style( 'my-style', get_stylesheet_uri() . '/css/style.css');
}
add_action( 'wp_enqueue_scripts', 'my_styles' );
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
//удаляем то что есть
unset($fields['order']['order_comments']);
// добавляем своих
$fields['order']['my_fied'] = array(
'label' => __('Мое поле', 'woocommerce'), // заголовок
'placeholder' => _x('Мое поле', 'placeholder', 'woocommerce'), //подсказка
'required' => false, // обязательное или нет
'type' => 'textarea', //тип
'class' => array('form-row-wide'),
'clear' => true
);
$fields['order']['my_fied2'] = array(
'label' => __('Мое поле2', 'woocommerce'),
'placeholder' => _x('Мое поле2', 'placeholder', 'woocommerce'),
'required' => false,
'type' => 'text',
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}