Files
profile/dirty-functions.php

122 lines
3.8 KiB
PHP
Raw Normal View History

2025-07-09 21:21:17 +03:00
<?php
add_action( 'wp', 'wp_5min_event_activation' );
function wp_5min_event_activation() {
if( ! wp_next_scheduled( 'every_5min_event' ) ) {
wp_schedule_event( time(), '5min', 'every_5min_event');
}
}
// добавляем функцию к указанному хуку
add_action( 'every_5min_event', 'check_last_tg_message' );
function check_last_tg_message() {
$start = DateTime::createFromFormat('H:i', "07:30");
$finish = DateTime::createFromFormat('H:i', "22:45");
$last_message = DateTime::createFromFormat('U', get_option('last_telegram_message'));
$now = new DateTime();
$delay = ($now->format("U") - $last_message->format("U"));
if( $now >= $start && $now <= $finish && $delay >= 40*60 ) {
if($delay >= 50*60){
$sticker = 'CAACAgIAAxkBAAEECuJiIRR4ttk1Ua-Rk-4BaXVwMstMAgAC-xUAAlVwCUn72vcvme2BSCME';
}else if($delay >= 45*60){
$sticker = 'CAACAgIAAxkBAAEECuBiIRR0kZdVOenSekeFBRNUONq28gACHhUAAkeeCEnKblTaKBupkyME';
}else{
$sticker = 'CAACAgIAAxkBAAEDyfhh-jp88G6uuN3xNTYkGOW98Nh-1wACFxIAAv8cOEvquhhQdFtIgCME';
}
$url = "https://api.telegram.org/bot5170703345:AAF21QVgYKyXEnSyrge555S0FBAoFZ9y7tU/sendSticker?chat_id=-1001375776228&sticker=".$sticker;
//$url = "https://api.telegram.org/bot1184440628:AAE5N10dnzClx3Qce4v1mBD9ax1BsHo98Rs/sendSticker?chat_id=202319661&sticker=CAACAgIAAxkBAAEDyfhh-jp88G6uuN3xNTYkGOW98Nh-1wACFxIAAv8cOEvquhhQdFtIgCME";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
}
}
add_action("wp_insert_post", function(){
if(get_current_user_id() == 1) {
error_log("\n\n\n=========================\n\n\n");
error_log(list_hooked_functions());
error_log("\n\n\n=========================\n\n\n");
}
});
function list_hooked_functions($tag=false){
ob_start();
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
}
else {
$hook=$wp_filter;
ksort($hook);
}
echo '<pre>';
foreach($hook as $tag => $priority){
echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag</strong><br />";
foreach($priority as $priority => $function){
echo $priority;
foreach($function as $name => $properties) echo "\t$name<br />";
}
}
echo '</pre>';
return ob_get_clean();
}
add_filter("posts_where", function($where){
if(is_yn() || is_feed() || is_turbo()){
$where .= " and id not in (select object_id from wp_term_relationships where term_taxonomy_id = 3394) ";
}
return $where;
});
function get_rkn_disclaimer_for_tags($arr, $name){
$text = "";
$types = [
"terr" => "физическое лицо или организация, признанная террористической и запрещенная в России",
"ex" => "физическое лицо или организация, признанная экстремистской и запрещенная в России",
"ino" => "физическое лицо или организация, выполняющие функции иноагента",
"nez" => "физическое лицо или организация, признанная нежелательной на территории России"
];
foreach($arr as $item) {
$text .= $name . " - " . $types[$item] . "<br/>";
}
$text .= "";
return $text;
}