add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
function my_scripts_method() {
// отменяем зарегистрированный jQuery
// вместо "jquery-core", можно вписать "jquery", тогда будет отменен еще и jquery-migrate
wp_deregister_script( 'jquery-core' );
wp_register_script( 'jquery-core', '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
do_shortcode( );
<?php echo do_shortcode("[wpsm_comparison_table id='4' ]"); ?>
Перемещаем блоки при помощи jquery
// .div1 // куда перемещаем
// .div2// что перемещаем
$('.div1').append($('.div2'));
/* monitors and laptops */
@media screen and (min-width: 1240px) {}
/* tablet */
@media screen and (min-width: 1024px) and (max-width: 1240px) {}
@media screen and (min-width: 768px) and (max-width: 1024px) {}
/* mobile */
@media screen and (max-width: 768px) {}
/* iPad in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {}
/* iPad in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {}
/* iPad in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {}
/* Retina iPad in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 2) {}
/* Retina iPad in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) {}
/* Retina iPad in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 2) {}
/* iPad 1 & 2 in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 1){}
/* iPad 1 & 2 in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio: 1) {}
/* iPad 1 & 2 in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 1) {}
/* iPad mini in portrait & landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (-webkit-min-device-pixel-ratio: 1) {}
/* iPad mini in landscape */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio: 1) {}
/* iPad mini in portrait */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio: 1) {}
/* iPhone 5 in portrait & landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) {}
/* iPhone 5 in landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : landscape) {}
/* iPhone 5 in portrait */
@media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : portrait) {}
/* iPhone 2G-4S in portrait & landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {}
/* iPhone 2G-4S in landscape */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) {}
/* iPhone 2G-4S in portrait */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) {}
Ширина блока
var widhfix = $('#main').width();
$(".fixtop").css("width",widhfix);
$(window).resize(function(){
var widhfix = $('#main').width();
$(".fixtop-action").css("width",widhfix);
});
Замена id
это сработает только для первого встреченного элемента с id "old_id", // остальные элементы с таким id будут проигнорированы. $('#old_id').attr('id, 'new_id');
add_action( 'woocommerce_before_add_to_cart_form', 'art_get_text_field_before_add_card' );
function art_get_text_field_before_add_card() {
global $post;
echo get_post_meta($post->ID, 'catalog_turbin_automobil', true);
}
RewriteRule (.+)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
if ( $_SERVER['REQUEST_URI'] != strtolower( $_SERVER['REQUEST_URI']) ) {
header('Location: http://'.$_SERVER['HTTP_HOST'] .
strtolower($_SERVER['REQUEST_URI']), true, 301);
exit();
}
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attachment ){
// Get post parent
$parent = get_post_field( 'post_parent', $attachment);
// Get post type to check if it's product
$type = get_post_field( 'post_type', $parent);
if( $type != 'product' ){
return $attr;
}
/// Get title
$title = get_post_field( 'post_title', $parent);
$attr['alt'] = $title;
$attr['title'] = $title;
return $attr;
}
$field_key = "field_5b79806a93e16"; $field = get_field_object($field_key); if( $field ) {
echo '<select class="mo_select2" name="house_type"> <option value="any" selected="selected">Any</option>';
foreach( $field['choices'] as $k => $v ) { echo '<option value="' . $k . '">' . $v . '</option>'; }
echo '</select>'; }
function castom_cf7_func() {
//code
return 'ура все получилось!':
}
wpcf7_add_form_tag('castom_function', 'castom_cf7_func');
//castom_cf7_func - название функции
//castom_function - название шорткода [castom_function]
.class {
width: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
max-height: 100%;
max-width: 100%;
}
add_filter('user_trailingslashit', 'no_page_slash', 70, 2);
function no_page_slash( $string, $type ){
global $wp_rewrite;
if( $type == 'page' && $wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes )
$string = untrailingslashit($string);
return $string;
}
function castom_type_header_metadata() {
return '<meta name="robots" content="noindex, nofollow" />';
}
add_action( 'wp_head', 'castom_type_header_metadata' );
/*
simple -Простой товар
grouped - Сгруппированный товар
external - Внешний/Партнерский товар
variable - Вариативный
*/
$_product = wc_get_product( get_the_ID() );
if( $_product->is_type( 'variable' ) ) {
} else {
// do stuff for everything else
}
Вывод произвольных полей таксономии acf
$term = get_queried_object(); // Сюда попадет текущая таксономия
// vars
$image = get_field('image', $term);
$color = get_field('color', $term);
?>
<style type="text/css">
.entry-title a {
color: <?php echo $color; ?>;
}
<?php if( $image ): ?>
.site-header {
background-image: url(<?php echo $image['url']; ?>);
}
<?php endif; ?>
</style>
<div class="wrap">
<?php // Remaining template removed from example ?
//отключаем теги для wc
function unregister_taxonomy_post_tag(){
register_taxonomy('product-tag', array());
}
add_action('init', 'unregister_taxonomy_post_tag');
// Заменяем теги strong
add_filter( 'the_content', 'filter_function_name_11' ); // в овновном контенте
add_filter( 'the_excerpt', 'filter_function_name_11' ); // в кратком описании контента
add_filter('woocommerce_short_description', 'filter_function_name_11', 10, 1); // в кратком описании товара
function filter_function_name_11( $content ) {
// preg_replace('/<strong(.*)>(.*)<\/strong>/', '<span>$2</span>', $content)
return preg_replace('/<strong(.*)>(.*)<\/strong>/', '<span class="strong">$2</span>', $content) ;
}
Изменяет цену в woocomerce
add_filter('woocommerce_product_get_price', 'change_price', 99, 2 );
add_filter('woocommerce_product_get_regular_price', 'change_price', 99, 2 );
add_filter( 'woocommerce_price_filter_widget_min_amount', 'change_price', 99, 2);
add_filter( 'woocommerce_price_filter_widget_max_amount', 'change_price', 99, 2);
// Variable
add_filter('woocommerce_product_variation_get_regular_price', 'change_price', 99, 2 );
add_filter('woocommerce_product_variation_get_price', 'change_price', 99, 2 );
// Variations
add_filter('woocommerce_variation_prices_price', 'change_price', 99, 3 );
add_filter('woocommerce_variation_prices_regular_price', 'change_price', 99, 3 );
add_filter( 'woocommerce_variation_prices_sale_price', 'change_price', 99, 3 );
Добавить кнопки ± для товара в категории WC
/**
* Override loop template and show quantities next to add to cart buttons
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
}
return $html;
}
Отключить canonical rel prev next wordpress wpseo
add_action( 'wp', function(){
if (!is_product()) {
add_filter( 'wpseo_next_rel_link', '__return_false' );
add_filter( 'wpseo_prev_rel_link', '__return_false' );
add_filter( 'wpseo_canonical', '__return_false' );
}
});
Регулярка для укр номеров телефонов ( inputMask)
^\+38\(0[2-9]\d{1}\)\d{3}-\d{2}-\d{2}
Оставить несколько знаков после запятой
function truncate_number( $number, $precision = 2) {
// Zero causes issues, and no need to truncate
if ( 0 == (int)$number ) {
return $number;
}
$negative = $number / abs($number);
$number = abs($number);
$precision = pow(10, $precision);
return floor( $number * $precision ) / $precision * $negative;
}
# BEGIN WP Hide & Security Enhancer
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#WriteCheckString:1602091627_41738
RewriteRule .* - [E=HTTP_MOD_REWRITE:On]
RewriteRule ^eptyxept/(.+) /wp-content/themes/{ваша тема}d/$1 [L,QSA]
RewriteRule ^ashoaxoo/(.+) /wp-content/plugins/$1 [L,QSA]
RewriteRule ^oortoagy/(.+) /wp-includes/$1 [L,QSA]
RewriteRule ^ejoanset/(.+) /wp-content/uploads/$1 [L,QSA]
RewriteRule ^hoarykoa.php /wp-comments-post.php [L,QSA]
RewriteRule ^igatoaks/(.+) /wp-content/$1 [L,QSA]
</IfModule>
# END WP Hide & Security Enhancer
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Закрепить шапку
fixedHeader = ()=>{
this.fix =()=>{
// if(window.innerWidth < 768){ // только на моб устройствах
window.onscroll = function() {myFunction()};
var header = document.querySelector(".page__hgroup"); // .page__hgroup - класс шапки
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
document.querySelector('body').classList.add("sticky")
document.body.style.marginTop = header.offsetHeight + 'px'
} else {
header.classList.remove("sticky");
document.querySelector('body').classList.remove("sticky")
document.body.style.marginTop = '';
}
}
// }
}
this.fix()
}
fixedHeader()
Csv to Array php
$csv = 'https://docs.google.com/spreadsheets/d/e/b/pub?output=csv';
$data = array_map('str_getcsv', file($csv));
$keys = array_shift($data);
$newArray = array_map(function($values) use ($keys){
return array_combine($keys, $values);
}, $data);
$newArray // - результат
Вы должны авторизоваться, чтобы оставлять комментарии.
коммент.