|
| 1 | +<?php |
| 2 | +/* |
| 3 | + Plugin Name: Netlify Status |
| 4 | + Plugin URI: https://www.seowings.org/netlify-status-plugin/ |
| 5 | + Description: This plugin displays the status of any website deployed on Netlify. |
| 6 | + Version: 1.0 |
| 7 | + Author: Faisal Shahzad |
| 8 | + Author URI: https://www.seowings.org/ |
| 9 | +*/ |
| 10 | + |
| 11 | +function admin_bar_netlify_status_callback() { |
| 12 | + global $wp_admin_bar; |
| 13 | + $wp_admin_bar->add_node(array( |
| 14 | + 'id' => 'netlify-status-topbar', |
| 15 | + 'title' => get_option( 'netlify_status_website_id' ) != '' ? '<div id="netlify-badge"><img src="https://api.netlify.com/api/v1/badges/'. get_option( 'netlify_status_website_id' ) .'/deploy-status"></div>': '<div id="netlify-badge">Netlify Badge Not Set</div>', |
| 16 | + 'href' => admin_url( 'options-general.php?page=netlify-status%2Fswtopbar.php' ) |
| 17 | + )); |
| 18 | +} |
| 19 | +add_action( 'wp_before_admin_bar_render', 'admin_bar_netlify_status_callback' ); |
| 20 | + |
| 21 | + |
| 22 | +add_action( 'admin_menu', 'netlify_status_create_menu' ); |
| 23 | +function netlify_status_create_menu() { |
| 24 | + add_submenu_page( 'options-general.php', 'Netlify Status', 'Netlify Status', 'manage_options', 'netlify-status/swtopbar.php', 'netlify_status_settings_page' ); |
| 25 | + add_action( 'admin_init', 'netlify_status_register_settings' ); |
| 26 | +} |
| 27 | + |
| 28 | +function netlify_status_register_settings() { |
| 29 | + register_setting( 'netlify-status-settings-group', 'netlify_status_website_id', $netlify_website_id ); |
| 30 | +} |
| 31 | + |
| 32 | +function netlify_status_settings_page() { ?> |
| 33 | + <div class="wrap"> |
| 34 | + <h2>Netlify Badge</h2> |
| 35 | + <div id="main-container"> |
| 36 | + <form method="post" action="options.php"> |
| 37 | + <?php settings_fields( 'netlify-status-settings-group' ); ?> |
| 38 | + <table class="form-table"> |
| 39 | + <tr valign="top"> |
| 40 | + <th scope="row"> |
| 41 | + Netlify Site ID |
| 42 | + </th> |
| 43 | + <td> |
| 44 | + <label for="netlify_status_website_id"> |
| 45 | + <input type="text" id="netlify_status_website_id" size="40" name="netlify_status_website_id" value="<?php echo get_option( 'netlify_status_website_id' ); ?>" /> |
| 46 | + </label> |
| 47 | + </td> |
| 48 | + </tr> |
| 49 | + </table> |
| 50 | + <p class="submit"> |
| 51 | + <input type="submit" class="button-primary" value='Save Changes'/> |
| 52 | + </p> |
| 53 | + </form> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | +<?php }; ?> |
0 commit comments