Last active
June 22, 2019 06:38
-
-
Save eto4detak/b2b4d750e9798b6491e2076b492e57fe to your computer and use it in GitHub Desktop.
wp php apply_filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$text_html = apply_filters( 'the_content', carbon_get_term_meta( $category->term_id, 'crb_mini_text_cat' ) ); | |
// для всех страниц администратора. | |
add_action('admin_head', 'yamaps_shortcode_tmpl'); | |
// срабатывают условные тэги | |
add_action('template_redirect', 'porto_add_cart_234324'); | |
// убрать кнопку и переместить ниже | |
function porto_add_cart_234324($value='') | |
{ | |
global $test_fun; | |
$test_fun = 0; | |
if(is_front_page()){ | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10000 ); | |
add_action( 'porto_woocommerce_before_shop_loop_item_title', 'proto_custom_edit_add_to_cart', 100 ); | |
} | |
// для работы плагина YaMaps на странице категории | |
add_action( 'wp_head', 'marafon_maps_api_is_category'); | |
function marafon_maps_api_is_category() | |
{ | |
if( is_category()){ | |
echo '<!-- YaMaps — Yandex Maps for WordPress plugin https://www.yhunter.ru/portfolio/dev/yamaps/ --> | |
<script src="https://api-maps.yandex.ru/2.1/?lang='.get_locale().'" type="text/javascript"></script> | |
<script> | |
var YaMapsWP = {}, YMlisteners = {}; | |
</script>'; | |
} | |
} | |
// удалить рейтинг для пост-сотрудник | |
add_action( 'transition_post_status', 'marafon_update_del_user_rating' , 10,3 ); | |
function marafon_update_del_user_rating( $new_status, $old_status, $post){ | |
if($new_status == 'publish') return; | |
$postid = $post->ID; | |
// general | |
$marafon_all_rating = get_option( 'marafon_all_rating'); | |
if(isset($marafon_all_rating[$postid])){ | |
unset($marafon_all_rating[$postid]); | |
update_option('marafon_all_rating', $marafon_all_rating, false); | |
} | |
// cat | |
$term_list = wp_get_post_terms( $postid, 'category', array('fields' => 'all') ); | |
$cat_id = 0; | |
foreach ($term_list as $key => $term) { | |
if($term->parent == 0){ | |
$cat_id = $term->term_id; | |
break; | |
} | |
} | |
$marafon_cat_rating = get_option( 'marafon_cat_rating_'.$cat_id, []); | |
if(isset($marafon_cat_rating[$postid])){ | |
unset($marafon_cat_rating[$postid]); | |
update_option('marafon_cat_rating_'.$cat_id, $marafon_cat_rating, false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment