10up / plugin-scaffold Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED. Use https://github.com/10up/wp-scaffold
License: GNU General Public License v2.0
DEPRECATED. Use https://github.com/10up/wp-scaffold
License: GNU General Public License v2.0
Please make sure this PR 10up/theme-scaffold#54 makes its way into the plugin repo as well. Thanks!
There is currently an Issue open with Theme Scaffold, as well as an associated Pull Request.
All discussion and context is there, and mostly just wanted to open and assign a ticket as a reminder to get this in the Plugin Scaffold.
@dainemawer whenever you have time, just making sure the plugin and theme are in sync.
composer.lock file should be committed to our projects so that when we deploy them, we can run composer install and get a very specific set of package versions installed.
I could see maybe not wanting a composer.lock file in the scaffold repo, but we definitely want it in the repos that are generated as part of the scaffolding.
Hello,
I'm trying to use your plugin with Full Calendar JS (https://fullcalendar.io)
I'm following this guide : https://fullcalendar.io/docs/initialize-es6
For javascript part it's ok.
But for CSS, i have problem :
In admin.js, I add the following code :
import '@fullcalendar/core/main.css';
import '@fullcalendar/daygrid/main.css';
And I have this error :
ERROR in ./node_modules/@fullcalendar/core/main.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
> @charset "UTF-8";
| .fc {
| direction: ltr;
@ ./assets/js/admin/admin.js 2:0-37
ERROR in ./node_modules/@fullcalendar/daygrid/main.css 4:0
Module parse failed: Unexpected token (4:0)
You may need an appropriate loader to handle this file type.
| --------------------------------------------------------------------------------------------------*/
| /* day row structure */
> .fc-dayGridWeek-view .fc-content-skeleton,
| .fc-dayGridDay-view .fc-content-skeleton {
| /* there may be week numbers in these views, so no padding-top */
@ ./assets/js/admin/admin.js 3:0-40
Do I need to do something ? I need to add a config ?
Thanks.
It's not obvious the level of support provided for this repo, so let's add some clarification.
We are using error log to indicate when trying to load a script or style with a context that is not recognized. Usually, error_log
would be flagged in a code review as not belonging in production.
I am wondering the reasoning behind this decision and wondering if there is not another way to indicate this as this will only be used during development and only appear if adding another context or typoing the existing ones.
Understanding the above, that this won't be fired in production, I am wondering if we should wrap this in a WP_DEBUG
check with a comment for any engineers using this as a learning resource.
Noting this here for later review (i.e. so I can close this browser tab):
`( ! ) Fatal error: Uncaught Error: Call to undefined function TenUp\GeneratorTest\Core\setup() in /var/www/html/wp-content/plugins/generator-test/plugin.php on line 28
( ! ) Error: Call to undefined function TenUp\GeneratorTest\Core\setup() in /var/www/html/wp-content/plugins/generator-test/plugin.php on line 28
Call Stack
1 0.0069 481480 {main}( ) .../plugins.php:0
2 3.8195 22619264 plugin_sandbox_scrape( ) .../plugins.php:172
3 3.8238 22623408 include( '/var/www/html/wp-content/plugins/generator-test/plugin.php' ) .../plugin.php:1897
`
Provide the same change requested here - 10up/theme-scaffold#162 (comment)
PR - #112
Hi,
I noticed that in a recent commit (Port Webpack to the plugin) the path returned by the script_url()
function in the core.php
file is missing the TENUP_SCAFFOLD_URL
prefix, which will prevent the scripts from being loaded.
plugin-scaffold/includes/functions/core.php
Line 103 in 32ec736
Addind back the TENUP_SCAFFOLD_URL
prefix fixed the issue. I hope this could be helpful and that I didn't miss anything in the webpack config.
With the new webpack conversion we have a /config directory set up. Any config files, linting, processing, etc that can be moved out of the root and into the /config directory should be to clean up the root of the project.
Related theme issue: 10up/theme-scaffold#137
Per this comment on twitter:
https://twitter.com/scottjehl/status/1086287082031583232?s=11
.. we should change the style to be the following (more stable / reliable):
`@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.1s !important;
transition-duration: 0.1s !important;
}
}`
Keeping the script and style enqueue contexts inside of the helper methods used to generate the URL requires updating code in multiple places when adding a new item. This can be simplified by adding a helper function.
Sync with theme: 10up/theme-scaffold#46
The example composer.json
has
"autoload": { "psr-4": { "TenUpScaffold\\": "includes/classes/" } }
But then there is no example inside the includes/classes/ folder of how to namespace different classes, nor differet example namespaces in the composer.json file, and have them all autoloaded with psr-4.
Would it be possible to include a simple example of how to include classes under different namespaces like, eg,
TenUpScaffold\ClassOne
, TenUpScaffold\AnotherClass
, TenUpScaffold\AnotherOne\Helper
?
Would be great to see in the sample class how it is initialized, etc.
Thank you for your scaffold repos!
Is your enhancement related to a problem? Please describe.
The WordPress.org plugin headers and readme.txt standards appear to have evolved a bit and our scaffold files should likely include some additional fields.
Describe the solution you'd like
Requires PHP
, License
, License URI
to readme.txt
readme.txt
as the .org format is not intuitivereadme.txt
as the .org format is not intuitiveRequires at least
, Requires PHP
, License
, License URI
to plugin.php
Designs
n/a
Describe alternatives you've considered
Maybe we consider the fuller list of PHPDoc DoclBlock's as noted here as well?: https://developer.wordpress.org/plugins/plugin-basics/header-requirements/#header-fields
Additional context
Plugin Readmes: https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/
Header Requirements: https://developer.wordpress.org/plugins/plugin-basics/header-requirements/
@nicholasio Same deal as this PR to keep the repos in sync: 10up/theme-scaffold#35
When I run npm install, I get this message:
found 705 vulnerabilities (692 low, 13 high)
run `npm audit fix` to fix them, or `npm audit` for details
Is your enhancement related to a problem? Please describe.
Describe the solution you'd like
update packages.
Designs
Describe alternatives you've considered
Additional context
I use windows 10 pro.
nvm using node v.12.17.0
PHP is throwing a fatal error on L:227 of functions/core.php
when mce_css
filter is being run. On the post edit screen for example.
create-10up plugin my-fancy-plugin
wp plugin activate my-fancy-plugin
Edit a page in wp-admin
No php errors
I see this error:
Fatal error: Cannot redeclare Facebook\Elearning\Plugin\Core\style_url()
(previously declared in /srv/www/fbelearning/public_html/wp-content/plugins/fb-elearning/includes/functions/core.php:115)
in /srv/www/fbelearning/public_html/wp-content/plugins/fb-elearning/includes/functions/core.php
on line 261
core.php contains these two snippets:
https://github.com/10up/plugin-scaffold/blob/master/includes/functions/core.php#L98
function style_url( $stylesheet, $context ) {
if( !in_array( $context, ['admin', 'frontend', 'shared'], true) ) {
error_log('Invalid $context specfied in TenUpScaffold stylesheet loader.');
return '';
}
return ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ?
TENUP_SCAFFOLD_URL . "assets/css/${context}/{$stylesheet}.css" :
TENUP_SCAFFOLD_URL . "dist/css/${stylesheet}.min.css" ;
}
https://github.com/10up/plugin-scaffold/blob/master/includes/functions/core.php#L225
function mce_css( $stylesheets ) {
function style_url() {
return FB_ELEARNING_PLUGIN_URL . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ?
"assets/css/frontend/editor-style.css" :
"dist/css/editor-style.min.css" );
}
return $stylesheets . ',' . style_url();
}
Possibly the second instance of style_url() should be an anonymous function?
Use this: https://www.npmjs.com/package/@10up/eslint-config
Same issue is on the theme
Is your enhancement related to a problem? Please describe.
We are seeing increased usage of our GitHub Actions for deploying plugins to WordPress.org, and with the GA for Actions slated for mid-November and this being a “template” repo, I think it makes sense to go ahead and add what’s necessary for GitHub Actions to this repo so we’re ready from the jump. See 10up/action-wordpress-plugin-deploy#11 as well.
Describe the solution you'd like
Add .github/workflows/tag-deploy.yml
, .github/workflows/asset-readme-update.yml
, .distignore
, and .wordpress-org/README.md
. The last one should contain the image types, sizes, and naming that WordPress.org looks for, which I think makes more sense than bundling images that might unwittingly be deployed and avoids the empty directory in Git issue.
Designs
n/a
Describe alternatives you've considered
n/a
Additional context
I will work on a PR here within the next couple weeks unless somebody else wants to claim it first.
Describe the bug
If you modify the array that the get_enqueue_contexts
method returns, a new WP_Error
object is created and returned when performing the in_array
check in several methods. This causes a somewhat cryptic error being thrown as at that point you are attempting to enqueue a script or stylesheet with a WP_Error object as the style/script path string.
Steps to Reproduce
npm run-script start
, yarn start
, etc.admin
from return [ 'admin', 'frontend', 'shared' ];
on line 86
of core.php
Expected behavior
Display a WordPress warning/error on the back-end with the messages passed to the WP_Error constructors.
Screenshots
Catchable fatal error: Object of class WP_Error could not be converted to string in /var/www/html/wp-includes/http.php on line 681
...
Initially referenced on slack here:
https://10up.slack.com/archives/C10CPMBD2/p1547741052016500
After playing around with the plugin scaffold a little bit, and asking Darshan for some insight, it became apparent that using require_once 'vendor/autoload.php';
is detrimental to autoloading classes. This ticket may just be a lack of experience from my side, but is there any reason why the requiring of autoload.php
is not added to the plugin architecture by default?
dave@DESKTOP-BT7RIFJ /mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test (master) $ vendor/bin/phpunit
PHPUnit 6.5.7 by Sebastian Bergmann and contributors.
.R.RR 5 / 5 (100%)
Time: 3.03 seconds, Memory: 10.00MB
There were 3 risky tests:
1) TenUp\GeneratorTest\Core\Core_Tests::test_i18n
Deprecated WP Mock calls inside :
WP_Mock::wpFunction ["get_locale","Array([3] ...)"]
["load_textdomain","Array([2] ...)"]
["plugin_basename","Array([3] ...)"]
["load_plugin_textdomain","Array([2] ...)"]
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/DeprecatedListener.php:33
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:314
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:307
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/tests/phpunit/test-tools/TestCase.php:13
2) TenUp\GeneratorTest\Core\Core_Tests::test_activate
Deprecated WP Mock calls inside :
WP_Mock::wpFunction ["flush_rewrite_rules","Array([1] ...)"]
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/DeprecatedListener.php:33
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:314
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:307
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/tests/phpunit/test-tools/TestCase.php:13
3) TenUp\GeneratorTest\Core\Core_Tests::test_deactivate
This test did not perform any assertions
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:307
/mnt/c/Users/dave/Code/wp-local-docker/wordpress/wp-content/plugins/generator-test/tests/phpunit/test-tools/TestCase.php:13
OK, but incomplete, skipped, or risky tests!
Tests: 5, Assertions: 4, Risky: 3.
Upgrade Gulp version to 4 to sync with the theme repo: 10up/theme-scaffold#4
I'm probably missing something but why are we using front-end styles like normalize.css
from the plugin? For all use cases I can think of these should be in a theme only.
Is your enhancement related to a problem? Please describe.
Many problems in the PHP code could not be discovered by humans.
Describe the solution you'd like
Introduce @phpstan (as Automattic and Google already did)
Describe alternatives you've considered
There is no better static analysis then PHPStan.
Additional context
It needs a WordPress Extension.
From: 10up/theme-scaffold#114
Getting this error
Fatal error: Declaration of WP_Mock\Tools\TestCase::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp():
Describe the bug
When npm run build
is run, SVGs have their "viewbox" attribute removed which causes cropping:
This is caused in plugin-scaffold/config/webpack.config.common.js
. ImageminPlugin
can be updated to this to correct it:
// Compress images
// Must happen after CopyWebpackPlugin
new ImageminPlugin({
disable: !isProduction,
test: settings.ImageminPlugin.test,
svgo: {
plugins: [
{
removeViewBox: false,
},
],
},
}),
Steps to Reproduce
npm run build
to see the croppingnpm run watch
does not include the cropping because ImageminPlugin
is disabled on non-production environments,.Expected behavior
No cropping
Do the same linting command as in theme-scaffold.
Set up initial webpack and gulp from the theme scaffold
From: 10up/theme-scaffold#111
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.