Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the main plugin file #18

Merged
merged 2 commits into from
Oct 18, 2023
Merged

Rename the main plugin file #18

merged 2 commits into from
Oct 18, 2023

Conversation

dkotter
Copy link
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 dsawardekar and a team 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
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
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
3 checks passed
@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