Changeset 2567577
- Timestamp:
- 07/19/2021 07:33:46 PM (5 years ago)
- Location:
- wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates
- Files:
-
- 7 added
- 11 edited
-
aws-lightsail-add-server.php (modified) (6 diffs)
-
aws-lightsail-add-template.php (modified) (3 diffs)
-
aws-lightsail-backup-details.php (modified) (1 diff)
-
aws-lightsail-client-details.php (modified) (2 diffs)
-
aws-lightsail-create-host-name.php (added)
-
aws-lightsail-create-ssh-key.php (added)
-
aws-lightsail-create-user-github-startup-scripts.php (added)
-
aws-lightsail-create-user-startup-scripts.php (added)
-
aws-lightsail-debug.php (modified) (2 diffs)
-
aws-lightsail-license-settings.php (modified) (2 diffs)
-
aws-lightsail-list-host-names.php (added)
-
aws-lightsail-list-ssh-keys.php (added)
-
aws-lightsail-list-user-startup-scripts.php (added)
-
aws-lightsail-logged-data.php (modified) (2 diffs)
-
aws-lightsail-server-details.php (modified) (5 diffs)
-
aws-lightsail-settings.php (modified) (4 diffs)
-
aws-lightsail-snapshot-details.php (modified) (1 diff)
-
aws-lightsail-template-details.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-add-server.php
r2478412 r2567577 11 11 */ 12 12 13 function wpcs_aws_lightsail_add_server_template ( $tabs_content) {13 function wpcs_aws_lightsail_add_server_template ( $tabs_content, $page_content, $page_id ) { 14 14 15 15 if ( 'aws-lightsail-add-server' !== $tabs_content ) { … … 34 34 settings_fields( 'wpcs_aws_lightsail_create_server' ); 35 35 wpcs_do_settings_sections( 'wpcs_aws_lightsail_create_server' ); 36 ?>37 <hr>38 <?php39 36 wpcs_submit_button( 'Create Server', 'secondary', 'create_server', null, $attributes ); 40 37 ?> … … 63 60 $server_script_name = get_option( 'wpcs_aws_lightsail_server_startup_script_name' ); 64 61 $server_backups = get_option( 'wpcs_aws_lightsail_server_enable_backups' ); 62 63 $domain_name = get_option( 'wpcs_aws_lightsail_server_variable_domain_name','' ); 64 $wp_site_title = get_option( 'wpcs_aws_lightsail_server_variable_wp_site_title','' ); 65 $wp_db_user = get_option( 'wpcs_aws_lightsail_server_variable_wp_db_user','' ); 66 $wp_database = get_option( 'wpcs_aws_lightsail_server_variable_wp_database','' ); 67 $admin_user = get_option( 'wpcs_aws_lightsail_server_variable_admin_user','' ); 68 $admin_passwd = get_option( 'wpcs_aws_lightsail_server_variable_admin_passwd','' ); 69 $admin_email = get_option( 'wpcs_aws_lightsail_server_variable_admin_email','' ); 65 70 66 71 $server_pwd = wp_generate_password( 12, false ); … … 74 79 75 80 // Use User Meta if provided in template 76 if ( 'no-startup-script' !== $server_script_name ) { 81 $startup_scripts = get_option( 'wpcs_startup_scripts' ); 82 83 if ( is_array( $startup_scripts ) && ( 'no-startup-script' !== $server_startup_script_name ) ) { 84 foreach ( $startup_scripts as $key => $script ) { 85 if ( $server_startup_script_name == $script['name'] ) { 86 $server_startup_script = $script['startup_script']; 87 $server_script_type = $script['type']; 88 $server_script_repos = ( isset( $script['github_repos'] ) ) ? $script['github_repos'] : ''; 89 $server_script_file = ( isset( $script['github_file'] ) ) ? $script['github_file'] : ''; 90 } 91 } 92 93 if ( !$server_startup_script && 'git' == $server_script_type ) { 94 95 if ( function_exists('wpcs_github_call_api_get_file') ) { 96 $server_startup_script = wpcs_github_call_api_get_file( $server_script_repos, $server_script_file ); 97 } 98 99 } 100 101 if ( $server_startup_script ) { 102 103 $placeholder = array( 104 "{{domain_name}}", 105 "{{wp_site_title}}", 106 "{{wp_db_user}}", 107 "{{wp_database}}", 108 "{{admin_user}}", 109 "{{admin_passwd}}", 110 "{{admin_email}}", 111 ); 112 113 $values = array( 114 $domain_name, 115 $wp_site_title, 116 $wp_db_user, 117 $wp_database, 118 $admin_user, 119 $admin_passwd, 120 $admin_email, 121 ); 122 123 $script = str_replace( $placeholder, $values, $server_startup_script ); 77 124 78 $startup_scripts = get_option( 'wpcs_startup_scripts' ); 125 $app_data["userData"] = $script; 126 $debug['server_script'] = $script; 127 128 update_option( 'wpcs_updated_script', $script ); 79 129 80 if ( !empty( $startup_scripts ) ) {81 foreach ( $startup_scripts as $key => $script ) {82 if ( $user_meta == $script['name'] ) {83 $server_startup_script = $script['startup_script'];84 $startup_script_name = $script['name'];85 86 $startup_script = str_replace( "{{server_name}}", $server_name, $server_startup_script );87 88 $app_data["userData"] = $startup_script;89 }90 }91 130 } 92 131 } … … 126 165 wpcs_aws_lightsail_log_event( 'AWS Lightsail', 'Success', 'New Server Created (' . $server_name . ')' ); 127 166 167 // Delete the Server API Data to Force update 168 $api_data = get_option( 'wpcs_aws_lightsail_api_data' ); 169 if ( isset( $api_data['instances'] ) ) { 170 unset( $api_data['instances'] ); 171 update_option( 'wpcs_aws_lightsail_api_data', $api_data ); 172 } 128 173 } 129 174 … … 137 182 delete_option( 'wpcs_aws_lightsail_server_enable_backups' ); 138 183 184 delete_option( 'wpcs_aws_lightsail_server_variable_domain_name' ); 185 delete_option( 'wpcs_aws_lightsail_server_variable_wp_site_title' ); 186 delete_option( 'wpcs_aws_lightsail_server_variable_wp_db_user' ); 187 delete_option( 'wpcs_aws_lightsail_server_variable_wp_database' ); 188 delete_option( 'wpcs_aws_lightsail_server_variable_admin_user' ); 189 delete_option( 'wpcs_aws_lightsail_server_variable_admin_passwd' ); 190 delete_option( 'wpcs_aws_lightsail_server_variable_admin_email' ); 191 139 192 } 140 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_add_server_template' );193 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_add_server_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-add-template.php
r2478412 r2567577 10 10 */ 11 11 12 function wpcs_aws_lightsail_add_template_template ( $tabs_content) {12 function wpcs_aws_lightsail_add_template_template ( $tabs_content, $page_content, $page_id ) { 13 13 14 14 if ( 'aws-lightsail-add-template' !== $tabs_content ) { … … 32 32 settings_fields( 'wpcs_aws_lightsail_create_template' ); 33 33 wpcs_do_settings_sections( 'wpcs_aws_lightsail_create_template' ); 34 ?>35 <hr>36 <?php37 34 wpcs_submit_button( 'Create Template', 'secondary', 'create_do_template', null, $attributes ); 38 35 ?> … … 138 135 delete_option( 'wpcs_aws_lightsail_template_enable_backups' ); 139 136 } 140 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_add_template_template' );137 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_add_template_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-backup-details.php
r2492125 r2567577 4 4 if ( ! defined( 'ABSPATH' ) ) exit; 5 5 6 function wpcs_aws_lightsail_backup_details_template ( $tabs_content ) {7 8 if ( 'aws-lightsail-backup-details' !== $tabs_content ) {9 return;10 }11 12 do_action( 'wpcs_aws_lightsail_backup_content' );13 }14 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_backup_details_template' );15 16 function wpcs_aws_lightsail_backup_upgrade() {17 ?>18 <div class="uk-overflow-auto">19 <h2 class="uk-margin-remove-top uk-heading-divider"><?php _e( 'AWS Lightsail Backups', 'wp-cloud-server' ); ?></h2>20 <div class="uk-alert-upgrade" uk-alert>21 <p>AWS Lightsail Backups are available with the AWS Lightsail Pro Module. Please <a href="#">click here</a> for more information.</p>22 </div>23 </div>24 <?php25 }26 add_action( 'wpcs_aws_lightsail_backup_content', 'wpcs_aws_lightsail_backup_upgrade' ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-client-details.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_client_details_template ( $tabs_content) {3 function wpcs_aws_lightsail_client_details_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-client-details' !== $tabs_content ) { … … 111 111 } 112 112 } 113 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_client_details_template' );113 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_client_details_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-debug.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_debug_template ( $tabs_content) {3 function wpcs_aws_lightsail_debug_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-debug' !== $tabs_content ) { … … 60 60 } 61 61 62 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_debug_template' );62 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_debug_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-license-settings.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_license_settings_template ( $tabs_content ) {3 function wpcs_aws_lightsail_license_settings_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-license-settings' !== $tabs_content ) { … … 63 63 <?php 64 64 } 65 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_license_settings_template' );65 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_license_settings_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-logged-data.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_logged_data_template ( $tabs_content) {3 function wpcs_aws_lightsail_logged_data_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-logged-data' !== $tabs_content ) { … … 48 48 } 49 49 50 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_logged_data_template' );50 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_logged_data_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-server-details.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_server_details_template ( $tabs_content ) {3 function wpcs_aws_lightsail_server_details_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-server-details' !== $tabs_content ) { 6 6 return; 7 7 } 8 9 $process_single = new AWS_Lightsail_Async_Request();10 $process_single->data( array( 'name' => 'instances' ) )->dispatch();11 8 12 $servers = get_option( 'wpcs_aws_lightsail_api_data', array());9 $servers = wpcs_aws_lightsail_api_server_list(); 13 10 $module_data = get_option( 'wpcs_module_list' ); 14 11 ?> 15 12 <div class="uk-overflow-auto"> 16 <h2 class="uk-margin-remove-top uk-heading-divider"><?php _e( 'AWS Lightsail Servers', 'wp-cloud-server' ); ?></h2>13 <h2 class="uk-margin-remove-top uk-heading-divider"><?php _e( 'AWS Lightsail Instances', 'wp-cloud-server' ); ?></h2> 17 14 <table class="uk-table uk-table-striped"> 18 15 <thead> … … 30 27 <tbody> 31 28 <?php 32 if ( !empty( $servers ['instances']) ) {33 foreach ( $servers ['instances']as $key => $servers_by_region ) {29 if ( !empty( $servers ) ) { 30 foreach ( $servers as $key => $servers_by_region ) { 34 31 foreach ( $servers_by_region as $key => $server ) { 35 32 $server_name = strtolower( str_replace( " ", "-", $server['name'] ) ); … … 62 59 63 60 <?php 64 if ( !empty( $servers ['instances']) ) {65 foreach ( $servers ['instances']as $key => $servers_by_region ) {61 if ( !empty( $servers ) ) { 62 foreach ( $servers as $key => $servers_by_region ) { 66 63 foreach ( $servers_by_region as $key => $server ) { 67 $server_name = strtolower( str_replace( " ", "-", $server['name'] ) );64 $server_name = strtolower( str_replace( " ", "-", $server['name'] ) ); 68 65 ?> 69 66 70 <div id="managed-server-modal-<?php echo $server ['name']; ?>" uk-modal>67 <div id="managed-server-modal-<?php echo $server_name; ?>" uk-modal> 71 68 <div class="server-modal uk-modal-dialog uk-modal-body"> 72 69 <button class="uk-modal-close-default" type="button" uk-close></button> … … 74 71 <hr class="clear"> 75 72 <div class="server-info uk-modal-body" uk-overflow-auto> 76 <table class="server-info uk-table uk-table-striped"> 77 <tbody> 78 <tr> 79 <td><?php esc_html_e( 'Server Name', 'wp-cloud-server' ); ?></td> 80 <td><?php echo "{$server['name']}"; ?></td> 81 </tr> 82 <tr> 83 <td><?php esc_html_e( 'Status', 'wp-cloud-server' ); ?></td> 84 <td><?php echo ucfirst($server['state']['name']); ?></td> 85 </tr> 86 <tr> 87 <td><?php esc_html_e( 'Region', 'wp-cloud-server' ); ?></td> 88 <td><?php echo wpcs_aws_lightsail_region_map( $server['location']['regionName'] ); ?></td> 89 </tr> 90 <tr> 91 <td><?php esc_html_e( 'Image/Application', 'wp-cloud-server' ); ?></td> 92 <td><?php echo $server['blueprintName']; ?></td> 93 </tr> 94 <tr> 95 <td><?php esc_html_e( 'VCPUs', 'wp-cloud-server' ); ?></td> 96 <td><?php echo $server['hardware']['cpuCount']; ?></td> 97 </tr> 98 <tr> 99 <td><?php esc_html_e( 'Memory', 'wp-cloud-server' ); ?></td> 100 <td><?php echo "{$server['hardware']['ramSizeInGb']}GB" ?></td> 101 </tr> 102 <tr> 103 <td><?php esc_html_e( 'SSD', 'wp-cloud-server' ); ?></td> 104 <td><?php echo "{$server['hardware']['disks'][0]['sizeInGb']}GB"; ?></td> 105 </tr> 106 <tr> 107 <td><?php esc_html_e( 'IP Address', 'wp-cloud-server' ); ?></td> 108 <td><?php echo isset($server['publicIpAddress']) ? $server['publicIpAddress'] : 'Not Available'; ?></td> 109 </tr> 110 <tr> 111 <td><?php esc_html_e( 'SSH Key', 'wp-cloud-server' ); ?></td> 112 <td><?php echo ( "LightsailDefaultKeyPair" !== $server['sshKeyName'] ) ? $server['sshKeyName'] : 'No SSH Key'; ?></td> 113 </tr> 114 <tr> 115 <td><?php esc_html_e( 'Date Created', 'wp-cloud-server' ); ?></td> 116 <td><?php echo gmdate("Y-m-d", $server['createdAt']) ; ?></td> 117 </tr> 118 </tbody> 119 </table> 120 </div> 73 <div style="background-color: #f9f9f9; border: 1px solid #e8e8e8; margin-bottom: 10px; padding: 25px 10px;" class="uk-border-rounded"> 74 <div uk-grid> 75 <div class="uk-width-1-5@m"> 76 <ul class="uk-tab-left" data-uk-tab="connect: #comp-tab-left-<?php echo $server_name; ?>;"> 77 <?php 78 foreach ( $page_content[ $page_id ]['content'] as $menus => $menu ) { 79 if ( isset($menu['modal_menu_items']) ) { 80 foreach ( $menu['modal_menu_items'] as $menu_id => $menu_item ) { 81 if ( 'true' == $menu['modal_menu_active'][$menu_id]) { 82 ?> 83 <li><a href="#"><?php echo $menu_item; ?></a></li> 84 <?php 85 } 86 } 87 } 88 } 89 ?> 90 </ul> 91 </div> 92 <div class="uk-width-4-5@m"> 93 <ul id="comp-tab-left-<?php echo $server_name; ?>" class="uk-switcher"> 94 <?php 95 foreach ( $page_content[ $page_id ]['content'] as $menus => $menu ) { 96 if ( isset($menu['modal_menu_items']) ) { 97 foreach ( $menu['modal_menu_items'] as $menu_id => $menu_item ) { 98 if ( 'true' == $menu['modal_menu_active'][$menu_id]) { 99 ?> 100 <li><div style="height:600px;" class="uk-overflow-auto"><?php do_action( "wpcs_aws_lightsail_{$menu['modal_menu_action'][$menu_id]}_content", $server ); ?></div></li> 101 <?php 102 } 103 } 104 } 105 } 106 ?> 107 </ul> 108 </div> 109 </div> 110 </div> 111 </div> 121 112 <hr> 122 113 <div class="uk-margin-right-small uk-align-right uk-margin-remove-bottom"> … … 186 177 } 187 178 } 188 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_server_details_template' );179 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_server_details_template',10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-settings.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_settings_template ( $tabs_content) {3 function wpcs_aws_lightsail_settings_template ( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-settings' !== $tabs_content ) { … … 15 15 delete_option( 'wpcs_aws_lightsail_api_secret_key' ); 16 16 delete_option( 'wpcs_dismissed_aws_lightsail_api_notice' ); 17 18 // Delete the API Health Transient so API Health is rechecked 19 delete_transient( 'wpcs_aws_lightsail_api_health' ); 20 17 21 echo '<script type="text/javascript"> window.location.href = window.location.href.split("&")[0]; </script>'; 18 22 } … … 24 28 wpcs_settings_fields( 'wpcs_aws_lightsail_admin_menu', 'aws_lightsail' ); 25 29 wpcs_do_settings_sections( 'wpcs_aws_lightsail_admin_menu' ); 26 ?><hr><?php27 30 wpcs_submit_button( 'Save Settings', 'secondary', 'create_aws_lightsail_api' ); 28 31 ?> … … 36 39 } 37 40 38 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_settings_template' );41 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_settings_template', 10, 3 ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-snapshot-details.php
r2492125 r2567577 4 4 if ( ! defined( 'ABSPATH' ) ) exit; 5 5 6 function wpcs_aws_lightsail_snapshot_details_template( $tabs_content ) {7 8 if ( 'aws-lightsail-snapshot-details' !== $tabs_content ) {9 return;10 }11 12 do_action( 'wpcs_aws_lightsail_snapshot_content' );13 }14 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_snapshot_details_template' );15 16 function wpcs_aws_lightsail_snapshot_upgrade() {17 ?>18 <div class="uk-overflow-auto">19 <h2 class="uk-margin-remove-top uk-heading-divider"><?php _e( 'AWS Lightsail Snapshots', 'wp-cloud-server' ); ?></h2>20 <div class="uk-alert-upgrade" uk-alert>21 <p>AWS Lightsail Snapshots are available with the AWS Lightsail Pro Module. Please <a href="#">click here</a> for more information.</p>22 </div>23 </div>24 <?php25 }26 add_action( 'wpcs_aws_lightsail_snapshot_content', 'wpcs_aws_lightsail_snapshot_upgrade' ); -
wp-cloud-server/trunk/modules/amazon-lightsail/includes/config/templates/aws-lightsail-template-details.php
r2478412 r2567577 1 1 <?php 2 2 3 function wpcs_aws_lightsail_template_details_template( $tabs_content ) {3 function wpcs_aws_lightsail_template_details_template( $tabs_content, $page_content, $page_id ) { 4 4 5 5 if ( 'aws-lightsail-template-details' !== $tabs_content ) { … … 175 175 } 176 176 } 177 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_template_details_template' );177 add_action( 'wpcs_control_panel_tab_content', 'wpcs_aws_lightsail_template_details_template', 10, 3 );
Note: See TracChangeset
for help on using the changeset viewer.