comment wordpress changes
This commit is contained in:
parent
eeab4c167b
commit
6171bb0f85
@ -71,3 +71,40 @@ remove_action('authenticate', 'wp_authenticate_username_password', 20);
|
||||
|
||||
add_filter( 'authenticate', 'rot_auth', 10, 3 );
|
||||
```
|
||||
|
||||
|
||||
# Wordpress notify rowt on newly published article
|
||||
|
||||
Add the following code to `wp-content/themes/bravada/functions.php`:
|
||||
|
||||
```
|
||||
function send_article_url_on_publish($new_status, $old_status, $post) {
|
||||
// Check if the post is transitioning to 'publish' status
|
||||
if ($new_status == 'publish' && $old_status != 'publish' && $post->post_type == 'post') {
|
||||
// Get the URL of the newly published article
|
||||
$article_url = get_permalink($post->ID);
|
||||
|
||||
// URL to send the GET request to
|
||||
$api_url = 'https://staging.rudernlinz.at/new-blogpost';
|
||||
|
||||
// Add the article URL as a query parameter
|
||||
$request_url = add_query_arg(array(
|
||||
'article_url' => urlencode($article_url),
|
||||
'pw' => "pw-as-specified-in-rockettoml"
|
||||
), $api_url);
|
||||
|
||||
// Send the GET request
|
||||
$response = wp_remote_post($request_url);
|
||||
|
||||
// Optional: Check if the request was successful
|
||||
if (is_wp_error($response)) {
|
||||
error_log('Failed to send GET request: ' . $response->get_error_message());
|
||||
} else {
|
||||
error_log('GET request sent successfully with article URL: ' . $article_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hook the function to the 'transition_post_status' action
|
||||
add_action('transition_post_status', 'send_article_url_on_publish', 10, 3);
|
||||
```
|
Loading…
Reference in New Issue
Block a user