Browse Source

version bump and remove obsolete CDN

tags/8.1.3^2
Chris Wiegman 1 year ago
parent
commit
e223d01619
No known key found for this signature in database GPG Key ID: A5661B2D2B235FE7
4 changed files with 2 additions and 184 deletions
  1. +1
    -9
      functions.php
  2. +0
    -172
      includes/classes/features/class-cdn.php
  3. +0
    -2
      includes/functions/core.php
  4. +1
    -1
      style.css

+ 1
- 9
functions.php View File

@@ -13,7 +13,7 @@ use CW\Theme\Post_Types;
use \CW\Theme\Features;

// Useful global constants.
define( 'CW_THEME_VERSION', '8.1.2' );
define( 'CW_THEME_VERSION', '8.1.3' );
define( 'CW_THEME_PATH', get_template_directory() . '/' );
define( 'CW_THEME_URL', get_stylesheet_directory_uri() );
define( 'CW_THEME_INCLUDES', CW_THEME_PATH . 'includes/' );
@@ -21,12 +21,4 @@ define( 'CW_THEME_INCLUDES', CW_THEME_PATH . 'includes/' );
require CW_THEME_INCLUDES . 'functions/core.php';
require CW_THEME_INCLUDES . 'functions/template-tags.php';

// Use a CDN if properly defined.
if ( defined( 'CW_USE_CDN' ) && true === CW_USE_CDN ) {

require CW_THEME_INCLUDES . 'classes/features/class-cdn.php';
new Features\CDN();

}

CW\Theme\Functions\Core\init();

+ 0
- 172
includes/classes/features/class-cdn.php View File

@@ -1,172 +0,0 @@
<?php
/**
* Add KeyCDN
*
* Adds MaxCDN to asset URLs where appropriate.
*
* @package chriswiegman
*
* @since 7.4
*
* @author Chris Wiegman <info@chriswiegman.com>
*/

namespace CW\Theme\Features;

/**
* Class CDN
*/
class CDN {

/**
* Setup CDN
*
* Sets up various CDN information.
*
* @since 7.4
*/
public function __construct() {

add_filter( 'the_content', array( $this, 'replace_content_urls' ) );
add_filter( 'script_loader_src', array( $this, 'replace_script_urls' ) );
add_filter( 'style_loader_src', array( $this, 'replace_style_urls' ) );
add_filter( 'post_thumbnail_html', array( $this, 'post_thumbnail_html' ) );

}

/**
* Get CDN domain
*
* Returns the CDN domain for the current site.
*
* @since 2.2.0* @since 7.4
*
* @return string The CDN domain.
*/
private function get_cdn_url() {

$cdn_url = 'cdn1.chriswiegman.com';

return $cdn_url;

}

/**
* Filters HTML
*
* Filters various HTML items to insert the CDN domain.
*
* @since 7.4
*
* @param string $html The HTML to filter.
*
* @return string the filtered HTML
*/
public function post_thumbnail_html( $html ) {

if ( ! is_user_logged_in() ) {

$rep = $this->get_cdn_url();

$html = str_replace( '=/wp-content/uploads', '=https://' . $rep . '/wp-content/uploads', $html );
$html = str_replace(
array(
'https://www.chriswiegman.com/content/uploads',
'https://www.chriswiegman.com/content/uploads',
),
'https://' . $rep . '/content/uploads', $html
);

}

return $html;

}

/**
* Filters post content
*
* Filters post content items to insert the CDN domain.
*
* @since 7.4
*
* @param string $content The content to filter.
*
* @return string the filtered content
*/
public function replace_content_urls( $content ) {

if ( ! is_user_logged_in() ) {

$rep = $this->get_cdn_url();

$content = str_replace( '=/content/uploads', '=https://' . $rep . '/content/uploads', $content );
$content = str_replace(
array(
'https://www.chriswiegman.com/content/uploads',
'https://www.chriswiegman.com/content/uploads',
),
'https://' . $rep . '/content/uploads', $content
);

}

return $content;
}

/**
* Filters JavaScript sources
*
* Filters various JavaScript source URLs to insert the CDN domain.
*
* @since 7.4
*
* @param string $src The url to filter.
*
* @return string the filtered url
*/
public function replace_script_urls( $src ) {

if ( ! is_user_logged_in() ) {

$cdn_domain = $this->get_cdn_url();

$src = str_replace( 'www.chriswiegman.com', $cdn_domain, $src );

}

return $src;

}

/**
* Filters CSS sources
*
* Filters various CSS source URLs to insert the CDN domain.
*
* @since 7.4
*
* @param string $src The url to filter.
*
* @return string the filtered url
*/
public function replace_style_urls( $src ) {

if ( ! is_user_logged_in() ) {

$cdn_domain = $this->get_cdn_url();

$src = str_replace(
array(
'http://www.chriswiegman.com',
'https://www.chriswiegman.com',
),
'https://' . $cdn_domain, $src
);

}

return $src;

}
}

+ 0
- 2
includes/functions/core.php View File

@@ -92,8 +92,6 @@ function action_widgets_init() {
)
);

register_widget( 'CW\Theme\Widgets\Latest_Tweets' );

}

/**


+ 1
- 1
style.css View File

@@ -4,7 +4,7 @@ Theme URI: http://underscores.me/
Author: Chris Wiegman
Author URI: https://chriswiegman.com/
Description: Theme for ChrisWiegman.com
Version: 8.1.2
Version: 8.1.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: chriswiegman