Skip to content

Commit 541bb5e

Browse files
committed
Initial commit
0 parents  commit 541bb5e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# deploy-webhook-menu-button

deploy-webhook-menu-button.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/*
3+
Plugin Name: Deploy Webhook Menu Button
4+
Plugin URI:
5+
Description: Lets you send a webhook via the WordPress admin menu
6+
Version: 0.1.0
7+
Author: Luke Secomb
8+
Author URI: https://lukesecomb.digital
9+
*/
10+
11+
add_action( 'admin_menu', 'register_my_menu_item' );
12+
13+
function register_my_menu_item() {
14+
# the add_action ensures this is only run when admin pages are displayed
15+
add_menu_page( 'Build Website', 'Build Website', 'manage_options', 'query-string-parameter', 'my_menu_item');
16+
}
17+
18+
function my_menu_item() {
19+
# your new admin page contents (or behaviour go here)
20+
echo '<h1>Deploying Website</h1>';
21+
22+
$url = 'https://api.netlify.com/build_hooks/5b8f4d8073f2cf07b2c54431';
23+
24+
$response = wp_remote_post( $url, '' );
25+
26+
if ( is_wp_error( $response ) ) {
27+
$error_message = $response->get_error_message();
28+
print_r('Error', $error_message);
29+
print_r('<br><br>');
30+
} else {
31+
print_r('Site Request Successfully Sent');
32+
print_r('<br><br>');
33+
print_r('Please allow upto an hour for the website to build');
34+
}
35+
}
36+
37+
?>

0 commit comments

Comments
 (0)