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

updating packages #99

Merged
merged 24 commits into from
Sep 20, 2018
Merged

updating packages #99

merged 24 commits into from
Sep 20, 2018

Conversation

iruzevic
Copy link
Member

@iruzevic iruzevic commented Aug 1, 2018

I have refactored a lot of stuff. Before you check this PR we should discus what I did and why also I will check rename script because there were a lot of changes in code.

@iruzevic iruzevic requested a review from dingo-d August 1, 2018 12:55
@iruzevic iruzevic closed this Aug 2, 2018
@iruzevic iruzevic reopened this Aug 2, 2018
@iruzevic
Copy link
Member Author

iruzevic commented Aug 4, 2018

I have also updated readme file with all details how to use and run boilerplate


We are using [Infinum coding standards for WordPress](https://github.com/infinum/coding-standards-wp) to check php files.
```bash
npm run precommit
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we setup githooks here instead of manually running scripts? Githooks

Copy link
Member Author

Choose a reason for hiding this comment

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

sure we can add that after we test it out. lets set this for version 3.1?

README.md Outdated

* Add this aliases to you bash config:
3. **Linting PHP** - If you have composer installed add this aliases to you bash config and reload terminal:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should rephrase this to be: you can add these aliases to your bash/zsh config for easier usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

README.md Outdated
bash bin/build.sh
```

3. When rsyncing to server use `ci-exclude.txt` to exclude unnecesery folders and files on server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a phrase: 'For deployment, we are using rsync in ore continuous deployment setup', and maybe add a sample example.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

…edia, and replacing normalize.css with sass version for lighter output, and fixed all terminal warnings
@iruzevic
Copy link
Member Author

iruzevic commented Sep 1, 2018

packages updated, fixed creation of source maps, minor bug in class-media, and replacing normalize.css with sass version for lighter output, and fixed all terminal warnings

please check end merge this. so we can release version 3 tnx @dingo-d

@iruzevic
Copy link
Member Author

iruzevic commented Sep 1, 2018

updating composer and fixing all linting errors and warnings


If you are using VVV clone it in the `public_html` folder
```bash
Copy link
Contributor

Choose a reason for hiding this comment

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

rename should be done either with shell script or using node script. In order for node script to work, npm install should be ran and then npm run rename iirc. This should be added to the readme.

Copy link
Member Author

@iruzevic iruzevic Sep 2, 2018

Choose a reason for hiding this comment

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

you run sh bin/rename.sh and that runs

npm install
npm run rename

this shell script should run on windows and osx. my idea is to run one command and you are done not 2 or more :D

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll try this out on Windows 👍

README.md Outdated
```bash
alias phpcs='vendor/bin/phpcs';
alias phpcbf='vendor/bin/phpcbf';
alias wpcs='phpcs --standard=vendor/infinum/coding-standards-wp/Infinum';
Copy link
Contributor

Choose a reason for hiding this comment

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

In the case where phpcs is run using the vendor version, the standard isn't necessary since it will pick up the phpcs.xml.dist as the configuration. In that file we have specified the Infinum's coding standard as a default. So the last two aliases are not really needed 😉

Copy link
Member Author

@iruzevic iruzevic Sep 2, 2018

Choose a reason for hiding this comment

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

ok I will remove it then, great work

bin/rename.js Outdated
console.error('Error occurred:', error);
}
};


// Main script
consoleOutput(fgGreen, 'The script will uniquely set up your theme.');
consoleOutput(fgGreen, 'Welcome to Boilerplate readme script. The script will uniquely set up your theme.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Welcome to Boilerplate readme script

You meant Welcome to Boilerplate rename script ? 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe :D

$main_style = $this->general_helper->get_manifest_assets_data( 'applicationAdmin.css' );
wp_register_style( static::THEME_NAME . '-style', $main_style );
$main_style = General_Helper::get_manifest_assets_data( 'applicationAdmin.css' );
wp_register_style( static::THEME_NAME . '-style', $main_style, array(), static::THEME_VERSION );
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't static::THEME_VERSION affect cache busting we are doing using manifest.json?

I know that there is an error that happens because theme version isn't specified, but there is an upstream issue opened at WPCS about this (they neglected the fact that hashing can be used).

You can either disable these lines with an inline comment

// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion

Or by adding this in the phpcs.xml.dist ruleset and disabling it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tested this and we are ok, assets manifest changes the name of the output file every time something changes so, everytime we hit build name of the file will change and cache busting will be done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, I thought that specifying version would suppress it. 👍

$main_script = $this->general_helper->get_manifest_assets_data( 'applicationAdmin.js' );
wp_register_script( static::THEME_NAME . '-scripts', $main_script );
$main_script = General_Helper::get_manifest_assets_data( 'applicationAdmin.js' );
wp_register_script( static::THEME_NAME . '-scripts', $main_script, array(), static::THEME_VERSION ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't we loading the scripts in the footer? I thought that it's better to load them all in the footer.

Copy link
Member Author

Choose a reason for hiding this comment

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

because this is up to the developer to decide when to load scripts we can load them in the footer in the boilerplate.

@@ -71,7 +49,7 @@ public function enqueue_scripts() {
* @param string $color_scheme Color scheme string.
* @return string Modified color scheme.
*
* @since 2.1.0
* @since 1.0.0
*/
public function set_admin_color_based_on_env( $color_scheme ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we have this in the wiki, but it should be added, explaining what it does and why.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have a lot of stuff in wiki, I will update this at some point

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe @IvanGrginovInf can, since he has the gift of really writing things out in detail 😄😛

seeWhatIDidThere xD

Copy link
Contributor

Choose a reason for hiding this comment

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

#Downgrading. @dingo-d I'd love to update the wiki a bit tho I haven't used half of these things. Maybe once I start actually contributing. ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's never too late to contribute :D

*/
public function add_custom_image_sizes() {
add_image_size( 'full_width', 9999, 9999, false );
add_image_size( 'full-width', 1440, 9999, false );
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this limit the width to 1440px on full-width images? What if someone wants to put 2000px image in the background or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it will but 9999, 9999 was put there I don't know how.
Let's say 1440 is optimal width for full width. A developer should change this if needed

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we should encourage optimization, but limiting this could cause issues opened with: why is my image not full size? :D Setting it to 9999 basically means, it will be whatever you put it (unless you put 30k px image xD)

Copy link
Member Author

Choose a reason for hiding this comment

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

if this is an issue then I will remove it because this actually does nothing. if you upload the image it will resize it to its max size which is its uploaded size. It is the same as full.

the_post_thumbnail( 'full' ); // Full resolution (original size uploaded)

@@ -92,7 +68,7 @@ public function enable_svg_library_preview( $response, $attachment, $meta ) {
$svg_content = file_get_contents( $path );
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a check

if ( ini_get( 'allow_url_fopen' ) ) {...}

Before using file_get_contents(), just as a precaution. And try to find alternative (wp_remote_get or cURL).

*/
public function enqueue_scripts() {
// jQuery.
wp_deregister_script( 'jquery-migrate' );
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . '/skin/public/scripts/vendors/jquery.min.js', array(), '3.3.1' );
wp_register_script( 'jquery', get_template_directory_uri() . '/skin/public/scripts/vendors/jquery.min.js', array(), '3.3.1' ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise about not being in the footer.

Copy link
Member Author

Choose a reason for hiding this comment

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

in all WP themes, Jquery is never loaded in the footer so we shouldn't neither.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just because they do it, doesn't mean it7s the right way to do it 😄 They are still using bundled jQuery (1.2) xD

I think we should put our scripts in footer, and make them dependent on the bundled vendor jquery. This way we are not blocking down the HTML parsing on the page (which will happen if the script is in the header).

If we put them in the header, we should investigate in adding async and defer attributes on our scripts.

Reference

Copy link
Member Author

@iruzevic iruzevic Sep 2, 2018

Choose a reason for hiding this comment

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

I agree with you 100%, but we can't guarantee that plugin developers will hook their scripts to the footer or dependent on jQuery, and if the script is loaded in header and jQuery is in the footer it won't work.

let's leave this to the developers?, we can add an not in the readme?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding it as an option? Radio button with "Load in header, load in header async, load in footer?"

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a bad idea, but I think that it would be better to leave that to the users, and just present the minimal working version of the developers to use and enhance :)

@infinum infinum deleted a comment from iruzevic Sep 2, 2018
@iruzevic
Copy link
Member Author

iruzevic commented Sep 19, 2018

  • fixing merge conflicts with develop branch
  • removing file_get_content
  • creating new helper class Object_Helper that is going to be used as a Trait

@dingo-d please check.

and can we merge this into develop so it is easier to maintain with smaller changes before main release


if ( ! $this->general_helper->is_valid_xml( $svg_content ) ) {
if ( ! static::is_valid_xml( $svg_content ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace static:: with $this-> since it's not a static method.

@iruzevic iruzevic merged commit 9af0f78 into development Sep 20, 2018
@iruzevic iruzevic deleted the feature/refactoring branch September 20, 2018 07:53
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.

3 participants