Skip to content

Commit

Permalink
Removed php-scoper in favor of jetpack-autoloader.
Browse files Browse the repository at this point in the history
  • Loading branch information
claygriffiths committed Jun 21, 2024
1 parent 7e052dd commit 498e099
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 1,581 deletions.
27 changes: 3 additions & 24 deletions class-gwiz-gf-code-chest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class GWiz_GF_Code_Chest extends GFFeedAddOn {
/**
* @var GWiz_GF_Code_Chest\Dependencies\Inc2734\WP_GitHub_Plugin_Updater\Bootstrap The updater instance.
* @var Inc2734\WP_GitHub_Plugin_Updater\Bootstrap The updater instance.
*/
public $updater;

Expand Down Expand Up @@ -114,7 +114,6 @@ public function minimum_requirements() {
public function pre_init() {
parent::pre_init();

$this->setup_autoload();
$this->init_auto_updater();

/**
Expand All @@ -124,26 +123,6 @@ public function pre_init() {
add_action( 'gform_forms_post_import', array( $this, 'import_feeds_with_form' ) );
}

/**
* @credit https://github.com/google/site-kit-wp
*/
public function setup_autoload() {
$class_map = array_merge(
include plugin_dir_path( __FILE__ ) . 'third-party/vendor/composer/autoload_classmap.php'
);

spl_autoload_register(
function ( $class ) use ( $class_map ) {
$namespace = 'GWiz_GF_Code_Chest\\Dependencies';
if ( isset( $class_map[ $class ] ) && substr( $class, 0, strlen( $namespace ) ) === $namespace ) {
require_once $class_map[ $class ];
}
},
true,
true
);
}

/**
* Initialize the auto-updater.
*/
Expand All @@ -154,7 +133,7 @@ public function init_auto_updater() {
array( $this, 'filter_auto_updater_response' ), 10, 2
);

$this->updater = new GWiz_GF_Code_Chest\Dependencies\Inc2734\WP_GitHub_Plugin_Updater\Bootstrap(
$this->updater = new Inc2734\WP_GitHub_Plugin_Updater\Bootstrap(
plugin_basename( plugin_dir_path( __FILE__ ) . 'gf-code-chest.php' ),
'gravitywiz',
'gf-code-chest',
Expand Down Expand Up @@ -202,7 +181,7 @@ public function filter_auto_updater_response( $obj, $response ) {
$obj->homepage = 'https://gravitywiz.com/gf-code-chest/';
$obj->author = '<a href="https://gravitywiz.com/" target="_blank">Gravity Wiz</a>';

$parsedown = new GWiz_GF_Code_Chest\Dependencies\Parsedown();
$parsedown = new Parsedown();
$changelog = trim( $obj->sections['changelog'] );

// Remove the "Changelog" h1.
Expand Down
37 changes: 9 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,22 @@
"phpcompatibility/php-compatibility": "*"
},
"require": {
"inc2734/wp-github-plugin-updater": "^3.1"
"inc2734/wp-github-plugin-updater": "^3.1",
"automattic/jetpack-autoloader": "^3.0"
},
"scripts": {
"lint": "phpcs",
"lint:fix": "phpcbf",
"post-install-cmd": [
"@prefix-dependencies",
"@remove-vendor"
],
"post-update-cmd": [
"@prefix-dependencies",
"@remove-vendor"
],
"credit-for-these-php-scoper-scripts": "https://github.com/google/site-kit-wp",
"prefix-dependencies": [
"@composer --working-dir=php-scoper install",
"rm -rf third-party",
"./php-scoper/vendor/bin/php-scoper add --output-dir=./third-party --force --quiet",
"@autoload-third-party",
"@composer dump-autoload"
],
"autoload-third-party": [
"echo '{ \"autoload\": { \"classmap\": [\"\"] } }' > third-party/composer.json",
"@composer --working-dir=third-party dump-autoload --classmap-authoritative --no-interaction || true",
"cp third-party/vendor/composer/autoload_classmap.php third-party/",
"rm -rf third-party/vendor && rm third-party/composer.json",
"mkdir -p third-party/vendor/composer && mv third-party/autoload_classmap.php third-party/vendor/composer/"
],
"remove-vendor": [
"rm -rf vendor"
"lint:fix": "phpcbf"
},
"autoload": {
"classmap": [
"class-gwiz-gf-code-chest.php"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"automattic/jetpack-autoloader": true
}
}
}
76 changes: 70 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions gf-code-chest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

defined( 'ABSPATH' ) || die();

require plugin_dir_path( __FILE__ ) . 'vendor/autoload_packages.php';

add_action( 'gform_loaded', function() {
if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) {
return;
Expand Down
11 changes: 0 additions & 11 deletions php-scoper/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions php-scoper/composer.json

This file was deleted.

Loading

0 comments on commit 498e099

Please sign in to comment.