Skip to content

Rename the main plugin file#18

Merged
dkotter merged 2 commits intodevelopfrom
fix/12
Oct 18, 2023
Merged

Rename the main plugin file#18
dkotter merged 2 commits intodevelopfrom
fix/12

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Oct 17, 2023

Description of the Change

Renames the main plugin file from plugin.php to block-catalog.php and updates any places that referenced that.

Also updates the contributing instructions a bit.

Closes #12

How to test the Change

Verify all changes look correct in this PR and that the plugin still loads

Changelog Entry

Changed - Updated the main plugin file name. Note that this change will require the plugin to be reactivated after updating.

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dkotter dkotter self-assigned this Oct 17, 2023
@dkotter dkotter requested review from a team and dsawardekar as code owners October 17, 2023 21:25
@dkotter dkotter requested review from peterwilsoncc and removed request for a team October 17, 2023 21:25
@dkotter dkotter added this to the 1.5.1 milestone Oct 17, 2023
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The active plugins are stored in the WP database as plugin-directory/file.php so plugin.php will need to retained for sites that have block-catalog/plugin.php active.

Completely untested but I think the file can contain something like this:

function update_active_plugin() {
   $old_name = basename( __DIR__ ) . '/plugin.php';
   $new_name = basename( __DIR__ ) . '/block-catalog.php';

  $active_plugins = get_option( 'active_plugins', array() );

  foreach ( $active_plugins as $key => $active_plugin ) {
	if ( $old_name = $active_plugin ) {
		$active_plugins[$key] = $new_name;
	}
  }

  update_option( 'active_plugins', $active_plugins );
}

add_action( 'plugins_loaded', __NAMESPACE__ . '\\update_active_plugin' );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Looks good to me, @dkotter . @peterwilsoncc 's note is interesting, but I would avoid changing active_plugins. Given that this plugin is admin-only, I would just add a note to the changelog asking folks to reactivate.

dsawardekar
dsawardekar previously approved these changes Oct 18, 2023
@dkotter dkotter merged commit c84f224 into develop Oct 18, 2023
@dkotter dkotter deleted the fix/12 branch October 18, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update main plugin filename

3 participants