Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions concat-utils.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php

if ( ! defined( 'VIP_CONCAT_MAX' ) ) {
define( 'VIP_CONCAT_MAX', 150 );
}

Comment thread
rinatkhaziev marked this conversation as resolved.
Outdated
class WPCOM_Concat_Utils {

public static function get_concat_max() {
// no less than 10, no more than 150
return min( max( intval( VIP_CONCAT_MAX ), 10 ), 150 );
}

public static function is_internal_url( $test_url, $site_url ) {
$test_url_parsed = parse_url( is_string( $test_url ) ? $test_url : '' );
$site_url_parsed = parse_url( $site_url );
Expand Down
4 changes: 4 additions & 0 deletions cssconcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function do_items( $handles = false, $group = false ) {
$stylesheets[ $stylesheet_group_index ] = array();

$stylesheets[ $stylesheet_group_index ][ $media ][ $handle ] = $css_url_parsed['path'];

if ( count( $stylesheets[ $stylesheet_group_index ][ $media ] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
$stylesheet_group_index++;
}
$this->done[] = $handle;
} else {
$stylesheet_group_index++;
Expand Down
4 changes: 4 additions & 0 deletions jsconcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function do_items( $handles = false, $group = false ) {
$javascripts[$level]['paths'][] = $js_url_parsed['path'];
$javascripts[$level]['handles'][] = $handle;

if ( count( $javascripts[$level]['paths'] ) >= WPCOM_Concat_Utils::get_concat_max() ) {
$level++;
}

} else {
$level++;
$javascripts[$level]['type'] = 'do_item';
Expand Down
3 changes: 1 addition & 2 deletions ngx-http-concat.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
require_once( __DIR__ . '/concat-utils.php' );

/* Config */
$concat_max_files = 150;
$concat_unique = true;
$concat_types = array(
'css' => 'text/css',
Expand Down Expand Up @@ -114,7 +113,7 @@ function concat_get_path( $uri ) {
concat_http_status_exit( 400 );

// array( '/foo/bar.css', '/foo1/bar/baz.css' )
if ( 0 == count( $args ) || count( $args ) > $concat_max_files )
if ( 0 == count( $args ) || count( $args ) > WPCOM_Concat_Utils::get_concat_max() )
concat_http_status_exit( 400 );

// If we're in a subdirectory context, use that as the root.
Expand Down