This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_constrain_dimensions', 'mcoc_constrain_dimensions', 11, 5 ); | |
function mcoc_constrain_dimensions( $dimensions, $current_width, $current_height, $max_width, $max_height ) { | |
// Stop if desired size is not post thumbnail | |
if ( ( $max_width != get_option( 'thumbnail_size_w' ) ) || ( $max_height != get_option( 'thumbnail_size_h' ) ) ) return $dimensions; | |
// Ensure cropped width is at least post thumbnail width | |
if ( $dimensions[0] >= $max_width ) return $dimensions; | |
if ( $current_height > $max_height ) { | |
return [ | |
$max_width, | |
$max_width * $current_height / $current_width |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Redirect to Canonical | |
Description: Redirect posts to canonical URL when accessed via secondary category URL slugs. | |
Version: 1.0 | |
Author: Greg Perham | |
License: GPL2 | |
*/ | |
defined( 'ABSPATH' ) || exit; |
OlderNewer