Skip to content

Commit

Permalink
Remove Headstart and apply a few fixes (#182)
Browse files Browse the repository at this point in the history
* remove headstart

it's too old to be useful

* minor fixes

h/t KK

* use PHP 8.2 for docker

* fix pagination in admin site list

h/t KK
  • Loading branch information
jhnstn authored Aug 20, 2024
1 parent e858ad2 commit c035349
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 295 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
MYSQL_ROOT_PASSWORD: somewordpress

wordpress:
image: wordpress:latest
image: wordpress:php8.2
volumes:
- wp_data:/var/www/html
- ./plugin:/var/www/html/wp-content/plugins/wpcloud-station
Expand Down
12 changes: 8 additions & 4 deletions plugin/admin/includes/class-wpcloud-site-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public function prepare_items( array $options = array() ) {
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$paged = absint( $_GET['paged'] ?? 1 );
$per_page = 20;

$defaults = array(
'posts_per_page' => 20,
'posts_per_page' => $per_page,
'paged' => $paged,
'post_type' => 'wpcloud_site',
'post_status' => 'any',
'orderby' => 'id',
Expand All @@ -52,9 +55,10 @@ public function prepare_items( array $options = array() ) {
$this->_column_headers = array( $columns, $hidden, $sortable );
$results = new WP_Query( $options );

if ( is_wp_error( $results ) ) {
error_log( $results->get_error_message() ); // phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_error_log
}
$this->set_pagination_args( array(
'total_items' => $results->found_posts,
'per_page' => $per_page,
) );

$this->items = $results->posts;
}
Expand Down
242 changes: 0 additions & 242 deletions plugin/admin/includes/wpcloud-headstart.php

This file was deleted.

23 changes: 0 additions & 23 deletions plugin/admin/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

declare( strict_types = 1 );

require_once plugin_dir_path( __FILE__ ) . 'includes/wpcloud-headstart.php';

/**
* Get the available themes.
*
Expand Down Expand Up @@ -194,27 +192,6 @@ function wpcloud_settings_init(): void {
'checked' => get_option( 'wpcloud_settings', array() )['client_cache'] ?? false,
)
);

// Only allow headstart if no settings have been saved yet
// headstart is might make unwanted changes if there are existing settings.
// It can be forced to run via the cli command `wp wpcloud client headstart`.
$allow_headstart = empty( get_option( 'wpcloud_settings' ) );
add_settings_field(
'wpcloud_field_headstart',
__( 'Headstart Set Up', 'wpcloud' ),
'wpcloud_field_input_cb',
'wpcloud',
'wpcloud_section_settings',
array(
'label_for' => 'wpcloud_headstart',
'class' => 'wpcloud_row',
'type' => 'checkbox',
'wpcloud_custom_data' => 'custom',
'description' => __( 'Run the headstart script to setup the demo site. This can only be ran when saving WP Cloud setting for the first time.' ),
'checked' => $allow_headstart,
'disabled' => ! $allow_headstart,
)
);
}
add_action( 'admin_init', 'wpcloud_settings_init' );

Expand Down
18 changes: 1 addition & 17 deletions plugin/includes/class-wpcloud-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound

require_once __DIR__ . '/wpcloud-client.php';
require_once __DIR__ . '/../admin/includes/wpcloud-headstart.php';

/**
* WP Cloud CLI
Expand Down Expand Up @@ -399,7 +398,7 @@ protected function set_site_id( $args ) {
$this->site_id = get_post_meta( $site_cpt->ID, 'wpcloud_site_id', true );

if ( ! $this->site_id ) {
WP_CLI::error( sprintf( 'Local site %s is missing a wp cloud site id' . $site_cpt->post_title ) );
WP_CLI::error( sprintf( 'Local site %s is missing a wp cloud site id', $site_cpt->post_title ) );
}
return;
}
Expand Down Expand Up @@ -743,21 +742,6 @@ public function available() {
self::log( '%GData centers:' );
self::log_result( wpcloud_client_data_centers_available() );
}

/**
* Get the client meta.
*
* @param array $args The arguments.
* @param array $switches The switches.
*/
public function headstart( $args, $switches ) {
$client = $switches['client'] ?? '';
$key = $switches['key'] ?? '';
$force = $switches['force'] ?? false;

$result = wpcloud_headstart( $client, $key, $force, new WPCloud_CLI_Skin() );
WP_CLI::success( 'Headstart installed' );
}
}

/**
Expand Down
14 changes: 7 additions & 7 deletions plugin/includes/class-wpcloud-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ public static function get_detail( int|WP_Post $post, string $key, ): mixed {
* @return true|WP_Error
*/
public static function update_detail( array $data ): true|WP_Error {
error_log(print_r($data, true));
error_log( print_r( $data, true ) );
$site_id = (int) ( $data['site_id'] ?? 0 );
if ( ! $site_id ) {
return new WP_Error( 'invalid_site_id', __( 'Invalid site ID.', 'wpcloud' ) );
Expand Down Expand Up @@ -659,12 +659,12 @@ function ( $value, $key ) use ( $mutable_fields ) {
return true;
}

/**
* Check if a site detail should be refreshed.
*
* @param string $key The detail key.
* @return bool True if the detail should be refreshed.
*/
/**
* Check if a site detail should be refreshed.
*
* @param string $key The detail key.
* @return bool True if the detail should be refreshed.
*/
public static function should_refresh_detail( string $key ): bool {
$refresh_keys = array(
'phpmyadmin_url',
Expand Down
2 changes: 1 addition & 1 deletion plugin/includes/wpcloud-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
declare( strict_types = 1 );

// Cache singleton for common client requests.
$wpcloud_client_cache = new stdClass();
$GLOBALS['wpcloud_client_cache'] = new stdClass();

/**
* Get WP Cloud Client Name from settings.
Expand Down

0 comments on commit c035349

Please sign in to comment.