wptelegram_add_custom_fields filter
-
How am I expected to use the filter wptelegram_add_custom_fields?
What I need is to place in the telegram message the urlencoded url of the post.
I solved putting in my theme function.php this code:add_filter( 'wptelegram_add_custom_fields', 'handle_telegram_encoded_url', 10, 2); function handle_telegram_encoded_url(string $value, WP_Post $post){ return urlencode(get_permalink($post->ID)); }
and my Telegram template is something such
.... something {custom_fields} something else...
which with my code correctly results in
.... something http%3A%2F%2FMySiteDomain%2my-post2F something else...
so result is correct, but I feel that I’m not using your wptelegram_add_custom_fields in the way is meant to be.
Ideally, I would put {customTag1} and {customTagWhatever} in my template and expect to handle them with a filter.
by the way, this line in your code (class-wptelegram-post-handler.php, line 432):
$wp_tags = array( '{ID}', '{title}', '{excerpt}', '{content}', '{author}', '{short_url}', '{full_url}', '{tags}', '{categories}', '{custom_fields}', '{custom_fields}');
is the duplicate {custom_fields} at the end of the array a typo? (which actually seems to result in no error)
- The topic ‘wptelegram_add_custom_fields filter’ is closed to new replies.