Skip to content

Commit

Permalink
Coding Standard Fixes (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobd91 authored Nov 29, 2024
1 parent 09cf64c commit 9ed2e12
Show file tree
Hide file tree
Showing 58 changed files with 3,633 additions and 1,963 deletions.
18 changes: 18 additions & 0 deletions Base_Page_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Base_Page_Settings {

/**
* Constructor.
*
* @return void
*/
public function __construct() {
$this->_config = Dispatcher::config();
Expand All @@ -66,13 +68,17 @@ public function __construct() {

/**
* Render header.
*
* @return void
*/
public function options() {
$this->view();
}

/**
* Render footer.
*
* @return void
*/
public function render_footer() {
include W3TC_INC_OPTIONS_DIR . '/common/footer.php';
Expand Down Expand Up @@ -106,6 +112,8 @@ protected function is_master() {
* @param string $class_prefix Class prefix.
* @param bool $label Label.
* @param bool $force_value Override value.
*
* @return void
*/
protected function checkbox( $option_id, $disabled = false, $class_prefix = '', $label = true, $force_value = null ) {
$disabled = $disabled || $this->_config->is_sealed( $option_id );
Expand Down Expand Up @@ -149,6 +157,8 @@ protected function checkbox( $option_id, $disabled = false, $class_prefix = '',
* @param unknown $value Value.
* @param bool $disabled Disabled flag.
* @param string $class_prefix Class prefix.
*
* @return void
*/
protected function radio( $option_id, $value, $disabled = false, $class_prefix = '' ) {
if ( is_bool( $value ) ) {
Expand Down Expand Up @@ -176,6 +186,8 @@ protected function radio( $option_id, $value, $disabled = false, $class_prefix =
* Prints checkbox for debug option.
*
* @param string $option_id Option ID.
*
* @return void
*/
protected function checkbox_debug( $option_id ) {
if ( is_array( $option_id ) ) {
Expand Down Expand Up @@ -211,6 +223,8 @@ protected function checkbox_debug( $option_id ) {
* @param string $option_id Option ID.
* @param unknown $label Label.
* @param unknown $label_pro Pro label.
*
* @return void
*/
protected function checkbox_debug_pro( $option_id, $label, $label_pro ) {
if ( is_array( $option_id ) ) {
Expand Down Expand Up @@ -263,6 +277,8 @@ protected function checkbox_debug_pro( $option_id, $label, $label_pro ) {
* @param string $option_id Option ID.
* @param bool $disabled Disabled flag.
* @param unknown $value_when_disabled Override value when disabled.
*
* @return void
*/
protected function value_with_disabled( $option_id, $disabled, $value_when_disabled ) {
if ( $disabled ) {
Expand All @@ -274,6 +290,8 @@ protected function value_with_disabled( $option_id, $disabled, $value_when_disab

/**
* Render header.
*
* @return void
*/
protected function view() {
include W3TC_INC_DIR . '/options/common/header.php';
Expand Down
209 changes: 114 additions & 95 deletions BrowserCache_ConfigLabels.php

Large diffs are not rendered by default.

64 changes: 45 additions & 19 deletions BrowserCache_Core.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
<?php
/**
* File: BrowserCache_Core.php
*
* @package W3TC
*/

namespace W3TC;

/**
* Browsercache core
* Class BrowserCache_Core
*
* phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
* phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
*/
class BrowserCache_Core {
/**
* Returns replace extensions
*
* @param Config $config Config.
*
* @return array
*/
public function get_replace_extensions( $config ) {
$types = array();
$types = array();
$extensions = array();

if ( $config->get_boolean( 'browsercache.cssjs.replace' ) ) {
Expand All @@ -33,42 +44,61 @@ public function get_replace_extensions( $config ) {
return $extensions;
}



/**
* Returns replace extensions
*
* @param Config $config Config.
*
* @return array
*/
public function get_replace_querystring_extensions( $config ) {
$extensions = array();

if ( $config->get_boolean( 'browsercache.cssjs.replace' ) )
if ( $config->get_boolean( 'browsercache.cssjs.replace' ) ) {
$this->_fill_extensions( $extensions, $this->_get_cssjs_types(), 'replace' );
if ( $config->get_boolean( 'browsercache.html.replace' ) )
}

if ( $config->get_boolean( 'browsercache.html.replace' ) ) {
$this->_fill_extensions( $extensions, $this->_get_html_types(), 'replace' );
if ( $config->get_boolean( 'browsercache.other.replace' ) )
}

if ( $config->get_boolean( 'browsercache.other.replace' ) ) {
$this->_fill_extensions( $extensions, $this->_get_other_types(), 'replace' );
}

if ( $config->get_boolean( 'browsercache.cssjs.querystring' ) )
if ( $config->get_boolean( 'browsercache.cssjs.querystring' ) ) {
$this->_fill_extensions( $extensions, $this->_get_cssjs_types(), 'querystring' );
if ( $config->get_boolean( 'browsercache.html.querystring' ) )
}

if ( $config->get_boolean( 'browsercache.html.querystring' ) ) {
$this->_fill_extensions( $extensions, $this->_get_html_types(), 'querystring' );
if ( $config->get_boolean( 'browsercache.other.querystring' ) )
}

if ( $config->get_boolean( 'browsercache.other.querystring' ) ) {
$this->_fill_extensions( $extensions, $this->_get_other_types(), 'querystring' );
}

return $extensions;
}



/**
* Returns replace extensions
*
* @param array $extensions Extensions.
* @param array $types Types.
* @param string $operation Operation.
*
* @return void
*/
private function _fill_extensions( &$extensions, $types, $operation ) {
foreach ( array_keys( $types ) as $type ) {
$type_extensions = explode( '|', $type );
foreach ( $type_extensions as $ext ) {
if ( !isset( $extensions[$ext] ) )
$extensions[$ext] = array();
$extensions[$ext][$operation] = true;
if ( ! isset( $extensions[ $ext ] ) ) {
$extensions[ $ext ] = array();
}

$extensions[ $ext ][ $operation ] = true;
}
}
}
Expand All @@ -83,8 +113,6 @@ private function _get_cssjs_types() {
return $mime_types;
}



/**
* Returns HTML mime types
*
Expand All @@ -95,8 +123,6 @@ private function _get_html_types() {
return $mime_types;
}



/**
* Returns other mime types
*
Expand Down
Loading

0 comments on commit 9ed2e12

Please sign in to comment.