Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
node_modules/

# Build output (committed for distribution)
# build/

# OS files
.DS_Store
Thumbs.db

# Logs
*.log
npm-debug.log*
pnpm-debug.log*

# IDE
.idea/
.vscode/
*.swp
*.swo
13 changes: 13 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"phpVersion": "8.2",
"plugins": [
".",
"https://downloads.wordpress.org/plugin/press-this.zip"
],
"config": {
"WP_DEBUG": true,
"SCRIPT_DEBUG": true
}
}
43 changes: 43 additions & 0 deletions build/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Main entry point for auto-generated asset registration.
* Do not edit this file manually.
*
* @package press_this_extended
*/

// Load version constant.
$version_file = __DIR__ . '/version.php';
if ( file_exists( $version_file ) ) {
require_once $version_file;
}

// Load script module registration.
$modules_file = __DIR__ . '/modules.php';
if ( file_exists( $modules_file ) ) {
require_once $modules_file;
}

// Load script registration.
$scripts_file = __DIR__ . '/scripts.php';
if ( file_exists( $scripts_file ) ) {
require_once $scripts_file;
}

// Load style registration.
$styles_file = __DIR__ . '/styles.php';
if ( file_exists( $styles_file ) ) {
require_once $styles_file;
}

// Load routes registration.
$routes_file = __DIR__ . '/routes.php';
if ( file_exists( $routes_file ) ) {
require_once $routes_file;
}

// Load pages registration.
$pages_file = __DIR__ . '/pages.php';
if ( file_exists( $pages_file ) ) {
require_once $pages_file;
}
44 changes: 44 additions & 0 deletions build/modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Script module registration - Auto-generated by build process.
* Do not edit this file manually.
*
* @package press_this_extended
*/

if ( ! function_exists( 'press_this_extended_register_script_modules' ) ) {
/**
* Register all script modules.
*/
function press_this_extended_register_script_modules() {
$modules_dir = __DIR__ . '/modules';
$modules_file = $modules_dir . '/index.php';

if ( ! file_exists( $modules_file ) ) {
return;
}

$modules = require $modules_file;
$base_url = plugins_url( 'build/modules/', dirname( __FILE__ ) );
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';

foreach ( $modules as $module ) {
$asset_path = $modules_dir . '/' . $module['asset'];
$asset = file_exists( $asset_path ) ? require $asset_path : array();

wp_register_script_module(
$module['id'],
$base_url . $module['path'] . $extension,
$asset['module_dependencies'] ?? array(),
$asset['version'] ?? false,
array(
'fetchpriority' => 'low',
'in_footer' => true,
)
);
}
}

add_action( 'wp_default_scripts', 'press_this_extended_register_script_modules' );
remove_action( 'wp_default_scripts', 'wp_default_script_modules' );
}
11 changes: 11 additions & 0 deletions build/modules/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Script module registry - Auto-generated by build process.
* Do not edit this file manually.
*
* @package press_this_extended
*/

return array(

);
87 changes: 87 additions & 0 deletions build/scripts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* Script registration - Auto-generated by build process.
* Do not edit this file manually.
*
* @package press_this_extended
*/

if ( ! function_exists( 'press_this_extended_override_script' ) ) {
/**
* Registers a script according to `wp_register_script`. Honors this request by
* reassigning internal dependency properties of any script handle already
* registered by that name. It does not deregister the original script, to
* avoid losing inline scripts which may have been attached.
*
* @param WP_Scripts $scripts WP_Scripts instance.
* @param string $handle Name of the script. Should be unique.
* @param string $src Full URL of the script, or path of the script relative to the WordPress root directory.
* @param array $deps Optional. An array of registered script handles this script depends on. Default empty array.
* @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL
* as a query string for cache busting purposes. If version is set to false, a version
* number is automatically added equal to current installed WordPress version.
* If set to null, no version is added.
* @param bool $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
* Default 'false'.
*/
function press_this_extended_override_script( $scripts, $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
$script = $scripts->query( $handle, 'registered' );
if ( $script ) {
/*
* In many ways, this is a reimplementation of `wp_register_script` but
* bypassing consideration of whether a script by the given handle had
* already been registered.
*/

// See: `_WP_Dependency::__construct` .
$script->src = $src;
$script->deps = $deps;
$script->ver = $ver;
$script->args = $in_footer ? 1 : null;
} else {
$scripts->add( $handle, $src, $deps, $ver, ( $in_footer ? 1 : null ) );
}

if ( in_array( 'wp-i18n', $deps, true ) ) {
$scripts->set_translations( $handle );
}
}
}

if ( ! function_exists( 'press_this_extended_register_package_scripts' ) ) {
/**
* Register all package scripts.
*/
function press_this_extended_register_package_scripts( $scripts ) {
$default_version = defined( 'PRESS_THIS_EXTENDED_VERSION' ) && ! SCRIPT_DEBUG ? PRESS_THIS_EXTENDED_VERSION : time();
$extension = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';

$scripts_dir = __DIR__ . '/scripts';
$scripts_file = $scripts_dir . '/index.php';

if ( ! file_exists( $scripts_file ) ) {
return;
}

$scripts_data = require $scripts_file;
$plugin_dir = dirname( __FILE__ );

foreach ( $scripts_data as $script_data ) {
$asset_file = $scripts_dir . '/' . $script_data['asset'];
$asset = file_exists( $asset_file ) ? require $asset_file : array();
$dependencies = $asset['dependencies'] ?? array();
$version = $asset['version'] ?? $default_version;

press_this_extended_override_script(
$scripts,
$script_data['handle'],
plugins_url( 'build/scripts/' . $script_data['path'] . $extension, $plugin_dir ),
$dependencies,
$version,
true
);
}
}

add_action( 'wp_default_scripts', 'press_this_extended_register_package_scripts' );
}
15 changes: 15 additions & 0 deletions build/scripts/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Script registry - Auto-generated by build process.
* Do not edit this file manually.
*
* @package press_this_extended
*/

return array(
array(
'handle' => 'pte-settings',
'path' => 'settings/index',
'asset' => 'settings/index.min.asset.php',
),
);
Loading