Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Subscriptions settigs added. Transport method changed. API methods added: gwptb_get_post_teaser, gwptb_notify_subscribers
- Loading branch information
1 parent
9b3558c
commit e72b594
Showing
7 changed files
with
129 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
# subscription | ||
function gwptb_get_post_teaser($post) { | ||
# get teaser from post content and excerpt | ||
$short = $post->post_excerpt; | ||
if(!$short) { | ||
if( preg_match( '/<!--more(.*?)?-->/', $post->post_content, $matches ) ) { | ||
$parts = explode( $matches[0], $post->post_content, 2 ); | ||
$short = $parts[0]; | ||
} | ||
else { | ||
$short = wp_trim_words($post->post_content); | ||
} | ||
} | ||
$short = apply_filters( 'get_the_excerpt', $short ); | ||
$short = preg_replace("/&#?[a-z0-9]+;/i", "", $short); | ||
|
||
return $short; | ||
} | ||
|
||
function gwptb_notify_subscribers($subscription_name, $message) { | ||
global $wpdb; | ||
|
||
$table_name = Gwptb_Core::get_chat_subscriptions_tablename(); | ||
$subscribed_chat_list = $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$table_name} WHERE name = %s ", $subscription_name)); | ||
|
||
$telebot = Gwptb_Self::get_instance(); | ||
foreach($subscribed_chat_list as $chat) { | ||
$telebot->send_notification(array('chat_id' => $chat->chat_id, 'text' => $message, 'parse_mode' => 'HTML')); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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