Example #1
0
function telegram_metabox_save($postid)
{
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (empty($postid)) {
        return;
    }
    if (isset($_POST['telegram_m_send'])) {
        $text = $_POST['telegram_m_send_content'];
        $text = str_replace('%TITLE%', get_the_title($postid), $text);
        $text = str_replace('%LINK%', get_permalink($postid), $text);
        $content = apply_filters('the_content', get_post($postid)->post_content);
        $text = str_replace('%EXCERPT%', wp_trim_words($content, $num_words = 50, $more = '...'), $text);
        telegram_sendmessagetoall($text);
    }
}
Example #2
0
<?php

$json = file_get_contents('php://input');
if (!$json) {
    return;
}
$data = (array) json_decode($json, TRUE);
telegram_log('------>', 'ZAPIER', json_encode((array) file_get_contents("php://input")));
telegram_sendmessagetoall($data['hook']);
Example #3
0
<?php

echo '<div class="wrap"><h2>' . __('New message', 'telegram-bot') . '</h2>';
if (isset($_POST["telegram_new_message"])) {
    telegram_sendmessagetoall($_POST["telegram_new_message"]);
    echo '<div class="updated">
        <p>Your message have been sent to <b>' . $count . '</b> subscribers!</p>
        </div>';
} else {
    echo '<form method="post" id="telegram_new_message">
        <textarea name="telegram_new_message" cols="40" rows="5"></textarea>';
    submit_button(__('Send Now', 'telegram-bot'), 'primary');
    echo '<small>' . __('Users and groups who blocked the bot will be automatically deactivated.', 'telegram-bot') . '</small>';
    echo '<br><small>' . __('Your message will be sent to users, groups and your channel.', 'telegram-bot') . '</small>';
    echo '</form>';
}
echo '</div>';