Changeset 2836004
- Timestamp:
- 12/19/2022 11:19:42 AM (3 years ago)
- Location:
- kama-thumbnail
- Files:
-
- 20 added
- 20 deleted
- 9 edited
- 1 copied
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
assets/screenshot-1.png (modified) (1 prop) (previous)
-
tags/3.5.0 (copied) (copied from kama-thumbnail/trunk)
-
tags/3.5.0/classes/CLI_Command.php (added)
-
tags/3.5.0/classes/Cache.php (added)
-
tags/3.5.0/classes/Helpers.php (added)
-
tags/3.5.0/classes/Kama_Make_Thumb.php (deleted)
-
tags/3.5.0/classes/Kama_Make_Thumb__Creators.php (deleted)
-
tags/3.5.0/classes/Kama_Make_Thumb__Helpers.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_CLI_Command.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_Cache.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_Helpers.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_Integration.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_Options.php (deleted)
-
tags/3.5.0/classes/Kama_Thumbnail_Options_Page.php (deleted)
-
tags/3.5.0/classes/Make_Thumb.php (added)
-
tags/3.5.0/classes/Make_Thumb__Creators.php (added)
-
tags/3.5.0/classes/Make_Thumb__Helpers.php (added)
-
tags/3.5.0/classes/Options.php (added)
-
tags/3.5.0/classes/Options_Page.php (added)
-
tags/3.5.0/classes/Plugin.php (added)
-
tags/3.5.0/classes/WP_Integration.php (added)
-
tags/3.5.0/functions.php (modified) (4 diffs)
-
tags/3.5.0/kama_thumbnail.php (modified) (5 diffs)
-
tags/3.5.0/readme.txt (modified) (2 diffs)
-
trunk/classes/CLI_Command.php (added)
-
trunk/classes/Cache.php (added)
-
trunk/classes/Helpers.php (added)
-
trunk/classes/Kama_Make_Thumb.php (deleted)
-
trunk/classes/Kama_Make_Thumb__Creators.php (deleted)
-
trunk/classes/Kama_Make_Thumb__Helpers.php (deleted)
-
trunk/classes/Kama_Thumbnail.php (deleted)
-
trunk/classes/Kama_Thumbnail_CLI_Command.php (deleted)
-
trunk/classes/Kama_Thumbnail_Cache.php (deleted)
-
trunk/classes/Kama_Thumbnail_Helpers.php (deleted)
-
trunk/classes/Kama_Thumbnail_Integration.php (deleted)
-
trunk/classes/Kama_Thumbnail_Options.php (deleted)
-
trunk/classes/Kama_Thumbnail_Options_Page.php (deleted)
-
trunk/classes/Make_Thumb.php (added)
-
trunk/classes/Make_Thumb__Creators.php (added)
-
trunk/classes/Make_Thumb__Helpers.php (added)
-
trunk/classes/Options.php (added)
-
trunk/classes/Options_Page.php (added)
-
trunk/classes/Plugin.php (added)
-
trunk/classes/WP_Integration.php (added)
-
trunk/functions.php (modified) (4 diffs)
-
trunk/kama_thumbnail.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kama-thumbnail/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
kama-thumbnail/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
kama-thumbnail/assets/screenshot-1.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
kama-thumbnail/tags/3.5.0/functions.php
r2810486 r2836004 1 1 <?php 2 2 3 use Kama_Thumbnail\Cache; 4 use Kama_Thumbnail\Plugin; 5 use Kama_Thumbnail\Options; 6 use Kama_Thumbnail\Make_Thumb; 7 3 8 /** 4 * Use following code instead of same-named functions where you want to show thumbnail :9 * Use following code instead of same-named functions where you want to show thumbnails: 5 10 * 11 * ```php 6 12 * echo apply_filters( 'kama_thumb_src', '', $args, $src ); 7 13 * echo apply_filters( 'kama_thumb_img', '', $args, $src ); 8 14 * echo apply_filters( 'kama_thumb_a_img', '', $args, $src ); 15 * ``` 16 * 17 * NOTE: The first empty parameter is needed so that if we remove the plugin, 18 * the hook will return an empty string, not what is defined in $args. 9 19 */ 10 20 add_filter( 'kama_thumb_src', 'kama_thumb_hook_cb', 0, 3 ); … … 53 63 * Make thumbnail and gets it URL. 54 64 * 55 * @param array $args 56 * @param string $src 57 * 58 * @return string 65 * @param array|string $args 66 * @param string|int $src Image URL or attachment ID. 59 67 */ 60 function kama_thumb_src( $args = [], $src = 'notset' ) {68 function kama_thumb_src( $args = [], $src = 'notset' ): string { 61 69 62 return ( new Kama_Make_Thumb( $args, $src ) )->src();70 return ( new Make_Thumb( $args, $src ) )->src(); 63 71 } 64 72 … … 66 74 * Make thumbnail and gets it IMG tag. 67 75 * 68 * @param array $args 69 * @param string $src 70 * 71 * @return string 76 * @param array|string $args 77 * @param string|int $src Image URL or attachment ID. 72 78 */ 73 function kama_thumb_img( $args = [], $src = 'notset' ) {79 function kama_thumb_img( $args = [], $src = 'notset' ): string { 74 80 75 return ( new Kama_Make_Thumb( $args, $src ) )->img();81 return ( new Make_Thumb( $args, $src ) )->img(); 76 82 } 77 83 … … 79 85 * Make thumbnail and gets it IMG tag wrapped with A tag. 80 86 * 81 * @param array $args 82 * @param string $src 83 * 84 * @return mixed|string|void 87 * @param array|string $args 88 * @param string|int $src Image URL or attachment ID. 85 89 */ 86 function kama_thumb_a_img( $args = [], $src = 'notset' ) {90 function kama_thumb_a_img( $args = [], $src = 'notset' ): string { 87 91 88 return ( new Kama_Make_Thumb( $args, $src ) )->a_img();92 return ( new Make_Thumb( $args, $src ) )->a_img(); 89 93 } 90 94 91 95 /** 92 * Reference to the last Kama_Make_Thumb instance to read some properties: height, width, or other...96 * Reference to the last Make_Thumb instance to read some properties: height, width, or other... 93 97 * 94 * @param string $deprecated 98 * @param string $deprecated Make_Thumb Property name. 95 99 * 96 * @return mixed|Kama_Make_Thumb|null The value of specified property or 97 * `Kama_Make_Thumb` object if no property is specified. 100 * @return Make_Thumb `Make_Thumb` object. Deprecated: the value of specified property of the object. 98 101 */ 99 102 function kama_thumb( $deprecated = '' ) { 100 103 101 $instance = Kama_Make_Thumb::$last_instance;104 $instance = Make_Thumb::$last_instance; 102 105 103 106 if( $deprecated ){ 104 107 _deprecated_argument( __FUNCTION__, '3.4.12', '`$optname` parameter is deprecated use returned object properties instead.' ); 108 109 if( property_exists( $instance, $deprecated ) ){ 110 return $instance->$deprecated; 111 } 112 113 return null; 105 114 } 106 115 107 if( ! $deprecated ){ 108 return $instance; 109 } 110 111 if( property_exists( $instance, $deprecated ) ){ 112 return $instance->$deprecated; 113 } 114 115 return null; 116 return $instance; 116 117 } 117 118 118 119 /** 119 * Gets instance of Kama_Thumbnail class. 120 * 121 * @return Kama_Thumbnail 120 * Gets instance of the Plugin main class. 122 121 */ 123 function kama_thumbnail() {124 return Kama_Thumbnail::instance();122 function kama_thumbnail(): Plugin { 123 return Plugin::instance(); 125 124 } 126 125 127 126 /** 128 * @return Kama_Thumbnail_Options127 * Gets instance of the Plugin options object. 129 128 */ 130 function kthumb_opt() {131 return Kama_Thumbnail::$opt;129 function kthumb_opt(): Options { 130 return Plugin::$opt; 132 131 } 133 132 134 133 /** 135 * @return Kama_Thumbnail_Cache134 * Gets instance of the Plugin cache object. 136 135 */ 137 function kthumb_cache() {138 return Kama_Thumbnail::$cache;136 function kthumb_cache(): Cache { 137 return Plugin::$cache; 139 138 } 140 139 140 141 function _kama_thumb_check_php_version( array $data ): bool { 142 143 if( version_compare( PHP_VERSION, $data['req_php'], '>=' ) ){ 144 return true; 145 } 146 147 $message = sprintf( '%s requires PHP %s+, but current one is %s.', 148 $data['plug_name'], 149 $data['req_php'], 150 PHP_VERSION 151 ); 152 153 if( defined( 'WP_CLI' ) ){ 154 \WP_CLI::error( $message ); 155 } 156 else { 157 add_action( 'admin_notices', static function() use ( $message ){ 158 echo '<div id="message" class="notice notice-error"><p>' . $message . '</p></div>'; 159 } ); 160 } 161 162 return false; 163 } -
kama-thumbnail/tags/3.5.0/kama_thumbnail.php
r2810486 r2836004 12 12 * Author URI: https://wp-kama.ru/ 13 13 * 14 * Requires PHP: 7. 214 * Requires PHP: 7.1 15 15 * Requires at least: 4.7 16 16 * 17 * Version: 3. 4.217 * Version: 3.5.0 18 18 */ 19 19 20 $ktdata = (object) get_file_data( __FILE__, [ 20 defined( 'ABSPATH' ) || exit; 21 22 $ktdata = get_file_data( __FILE__, [ 21 23 'ver' => 'Version', 22 24 'req_php' => 'Requires PHP', … … 24 26 ] ); 25 27 26 // check is php compatible 27 if( ! version_compare( phpversion(), $ktdata->req_php, '>=' ) ){ 28 define( 'KTHUMB_DIR', realpath( wp_normalize_path( __DIR__ ) ) ); 29 define( 'KTHUMB_VER', $ktdata['ver'] ); 28 30 29 $message = sprintf( '%s requires PHP %s+, but current one is %s.', 30 $ktdata->plug_name, 31 $ktdata->req_php, 32 phpversion() 33 ); 31 // load files 34 32 35 if( defined( 'WP_CLI' ) ){ 36 WP_CLI::error( $message ); 33 spl_autoload_register( static function( $class ){ 34 35 if( false !== strpos( $class, 'Kama_Thumbnail\\' ) ){ 36 $relpath = explode( '\\', $class, 2 )[1]; 37 require KTHUMB_DIR . "/classes/{$relpath}.php"; 37 38 } 38 else { 39 add_action( 'admin_notices', static function() use ( $message ){ 40 echo '<div id="message" class="notice notice-error"><p>' . $message . '</p></div>'; 41 } ); 42 } 39 } ); 43 40 41 require_once KTHUMB_DIR . '/functions.php'; 42 43 if( ! _kama_thumb_check_php_version( $ktdata ) ){ 44 44 return; 45 45 } 46 46 47 define( 'KTHUMB_VER', $ktdata->ver );48 47 unset( $ktdata ); 49 48 50 define( 'KTHUMB_DIR', wp_normalize_path( __DIR__ ) ); 51 52 // as plugin 49 // Set KTHUMB_URL constant 50 // in plugin 53 51 if( 54 false !== strpos( KTHUMB_DIR, wp_normalize_path( WP_PLUGIN_DIR) )52 false !== strpos( KTHUMB_DIR, realpath( wp_normalize_path( WP_PLUGIN_DIR ) ) ) 55 53 || 56 false !== strpos( KTHUMB_DIR, wp_normalize_path( WPMU_PLUGIN_DIR) )54 false !== strpos( KTHUMB_DIR, realpath( wp_normalize_path( WPMU_PLUGIN_DIR ) ) ) 57 55 ){ 58 56 define( 'KTHUMB_URL', plugins_url( '', __FILE__ ) ); … … 60 58 // in theme 61 59 else { 62 define( 'KTHUMB_URL', strtr( KTHUMB_DIR, [ wp_normalize_path( get_template_directory() ) => get_template_directory_uri() ] ) ); 60 define( 'KTHUMB_URL', str_replace( 61 realpath( wp_normalize_path( get_stylesheet_directory() ) ), 62 get_stylesheet_directory_uri(), 63 KTHUMB_DIR 64 ) ); 63 65 } 64 66 65 67 66 // load files 68 /** 69 * INIT 70 */ 67 71 68 spl_autoload_register( static function( $name ){ 69 70 if( false !== strpos( $name, 'Kama_Make_Thumb' ) || false !== strpos( $name, 'Kama_Thumbnail' ) ){ 71 72 require KTHUMB_DIR . "/classes/$name.php"; 73 } 74 } ); 75 76 require KTHUMB_DIR . '/functions.php'; 77 78 79 // stop if this file loads from uninstall.php file 72 // Don't INIT if loads from uninstall.php 80 73 if( defined( 'WP_UNINSTALL_PLUGIN' ) ){ 81 74 return; … … 83 76 84 77 85 // init86 87 78 if( defined( 'WP_CLI' ) ){ 88 79 89 WP_CLI::add_command( 'kthumb', 'Kama_Thumbnail_CLI_Command', [80 WP_CLI::add_command( 'kthumb', \Kama_Thumbnail\CLI_Command::class, [ 90 81 'shortdesc' => 'Kama Thumbnail Plugin CLI Commands', 91 82 ] ); … … 93 84 94 85 95 /** 96 * Initialize the plugin later, so that we can use some hooks from the theme. 97 */ 86 // Initialize later to allow use hooks from theme. 98 87 add_action( 'init', 'kama_thumbnail_init' ); 99 88 -
kama-thumbnail/tags/3.5.0/readme.txt
r2810486 r2836004 1 1 === Plugin Name === 2 2 Stable tag: trunk 3 Tested up to: 6.1 3 Tested up to: 6.1.1 4 4 5 5 License: GPLv2 or later … … 312 312 == Changelog == 313 313 314 = 3.5.0 = 315 - CHG: !IMPORTANT All core classes moved under `Kama_Thumbnail` namespace. So if you use such classes as `Kama_Thumbnail` or `Kama_Make_Thumb` directly - You need to update your code to use namespase. Example: `Kama_Thumbnail_Helpers::parse_main_dom()` >>> `\Kama_Thumbnail\Helpers::parse_main_dom()` OR `new Kama_Make_Thumb()` >>> `new \Kama_Thumbnail\Make_Thumb()`. 316 - CHG: CHMOD Options moved: `Kama_Make_Thumb::$CHMOD_DIR` >>> `kthumb_opt()->CHMOD_DIR` and `Kama_Make_Thumb::$CHMOD_FILE` >>> `kthumb_opt()->CHMOD_FILE` 317 - NEW: `$src` parameter now understand Attachment ID|Attachment Object|WP_Post. 318 - NEW: `no_photo_url` option now supports attachment ID as a value. 319 - NEW: Delete cached thumbnails of deleted attachment. 320 - IMP: Unit test improvements. 321 - IMP: `src` value moved to `srcset` and `src` now contains the original URL. 322 - IMP: `decoding="async"` by default for kama_thumb_img(). 323 - IMP: Checks the cache_dir path before deleting all files. This is to avoid accidentally deleting files in another directory. Now cache folder must contain one of substring `cache` or `thumb`. 324 - BUG: Type hint in get_src_from_text() method. 325 - BUG: `kama_thumb__img_attrs` hook support `srcset` attribute bugfix. 326 - BUG: stub need to be created when url with not allowed domain was passed. But the stub was created in the path of the normal image. 327 - BUG: Bug fix with symbolic links in WP_PLUGIN_DIR|WPMU_PLUGIN_DIR paths. 328 314 329 = 3.4.2 = 315 330 - NEW: Option to delete single IMG cache by image/thumb URL or attachment ID. -
kama-thumbnail/trunk/functions.php
r2810486 r2836004 1 1 <?php 2 2 3 use Kama_Thumbnail\Cache; 4 use Kama_Thumbnail\Plugin; 5 use Kama_Thumbnail\Options; 6 use Kama_Thumbnail\Make_Thumb; 7 3 8 /** 4 * Use following code instead of same-named functions where you want to show thumbnail :9 * Use following code instead of same-named functions where you want to show thumbnails: 5 10 * 11 * ```php 6 12 * echo apply_filters( 'kama_thumb_src', '', $args, $src ); 7 13 * echo apply_filters( 'kama_thumb_img', '', $args, $src ); 8 14 * echo apply_filters( 'kama_thumb_a_img', '', $args, $src ); 15 * ``` 16 * 17 * NOTE: The first empty parameter is needed so that if we remove the plugin, 18 * the hook will return an empty string, not what is defined in $args. 9 19 */ 10 20 add_filter( 'kama_thumb_src', 'kama_thumb_hook_cb', 0, 3 ); … … 53 63 * Make thumbnail and gets it URL. 54 64 * 55 * @param array $args 56 * @param string $src 57 * 58 * @return string 65 * @param array|string $args 66 * @param string|int $src Image URL or attachment ID. 59 67 */ 60 function kama_thumb_src( $args = [], $src = 'notset' ) {68 function kama_thumb_src( $args = [], $src = 'notset' ): string { 61 69 62 return ( new Kama_Make_Thumb( $args, $src ) )->src();70 return ( new Make_Thumb( $args, $src ) )->src(); 63 71 } 64 72 … … 66 74 * Make thumbnail and gets it IMG tag. 67 75 * 68 * @param array $args 69 * @param string $src 70 * 71 * @return string 76 * @param array|string $args 77 * @param string|int $src Image URL or attachment ID. 72 78 */ 73 function kama_thumb_img( $args = [], $src = 'notset' ) {79 function kama_thumb_img( $args = [], $src = 'notset' ): string { 74 80 75 return ( new Kama_Make_Thumb( $args, $src ) )->img();81 return ( new Make_Thumb( $args, $src ) )->img(); 76 82 } 77 83 … … 79 85 * Make thumbnail and gets it IMG tag wrapped with A tag. 80 86 * 81 * @param array $args 82 * @param string $src 83 * 84 * @return mixed|string|void 87 * @param array|string $args 88 * @param string|int $src Image URL or attachment ID. 85 89 */ 86 function kama_thumb_a_img( $args = [], $src = 'notset' ) {90 function kama_thumb_a_img( $args = [], $src = 'notset' ): string { 87 91 88 return ( new Kama_Make_Thumb( $args, $src ) )->a_img();92 return ( new Make_Thumb( $args, $src ) )->a_img(); 89 93 } 90 94 91 95 /** 92 * Reference to the last Kama_Make_Thumb instance to read some properties: height, width, or other...96 * Reference to the last Make_Thumb instance to read some properties: height, width, or other... 93 97 * 94 * @param string $deprecated 98 * @param string $deprecated Make_Thumb Property name. 95 99 * 96 * @return mixed|Kama_Make_Thumb|null The value of specified property or 97 * `Kama_Make_Thumb` object if no property is specified. 100 * @return Make_Thumb `Make_Thumb` object. Deprecated: the value of specified property of the object. 98 101 */ 99 102 function kama_thumb( $deprecated = '' ) { 100 103 101 $instance = Kama_Make_Thumb::$last_instance;104 $instance = Make_Thumb::$last_instance; 102 105 103 106 if( $deprecated ){ 104 107 _deprecated_argument( __FUNCTION__, '3.4.12', '`$optname` parameter is deprecated use returned object properties instead.' ); 108 109 if( property_exists( $instance, $deprecated ) ){ 110 return $instance->$deprecated; 111 } 112 113 return null; 105 114 } 106 115 107 if( ! $deprecated ){ 108 return $instance; 109 } 110 111 if( property_exists( $instance, $deprecated ) ){ 112 return $instance->$deprecated; 113 } 114 115 return null; 116 return $instance; 116 117 } 117 118 118 119 /** 119 * Gets instance of Kama_Thumbnail class. 120 * 121 * @return Kama_Thumbnail 120 * Gets instance of the Plugin main class. 122 121 */ 123 function kama_thumbnail() {124 return Kama_Thumbnail::instance();122 function kama_thumbnail(): Plugin { 123 return Plugin::instance(); 125 124 } 126 125 127 126 /** 128 * @return Kama_Thumbnail_Options127 * Gets instance of the Plugin options object. 129 128 */ 130 function kthumb_opt() {131 return Kama_Thumbnail::$opt;129 function kthumb_opt(): Options { 130 return Plugin::$opt; 132 131 } 133 132 134 133 /** 135 * @return Kama_Thumbnail_Cache134 * Gets instance of the Plugin cache object. 136 135 */ 137 function kthumb_cache() {138 return Kama_Thumbnail::$cache;136 function kthumb_cache(): Cache { 137 return Plugin::$cache; 139 138 } 140 139 140 141 function _kama_thumb_check_php_version( array $data ): bool { 142 143 if( version_compare( PHP_VERSION, $data['req_php'], '>=' ) ){ 144 return true; 145 } 146 147 $message = sprintf( '%s requires PHP %s+, but current one is %s.', 148 $data['plug_name'], 149 $data['req_php'], 150 PHP_VERSION 151 ); 152 153 if( defined( 'WP_CLI' ) ){ 154 \WP_CLI::error( $message ); 155 } 156 else { 157 add_action( 'admin_notices', static function() use ( $message ){ 158 echo '<div id="message" class="notice notice-error"><p>' . $message . '</p></div>'; 159 } ); 160 } 161 162 return false; 163 } -
kama-thumbnail/trunk/kama_thumbnail.php
r2810486 r2836004 12 12 * Author URI: https://wp-kama.ru/ 13 13 * 14 * Requires PHP: 7. 214 * Requires PHP: 7.1 15 15 * Requires at least: 4.7 16 16 * 17 * Version: 3. 4.217 * Version: 3.5.0 18 18 */ 19 19 20 $ktdata = (object) get_file_data( __FILE__, [ 20 defined( 'ABSPATH' ) || exit; 21 22 $ktdata = get_file_data( __FILE__, [ 21 23 'ver' => 'Version', 22 24 'req_php' => 'Requires PHP', … … 24 26 ] ); 25 27 26 // check is php compatible 27 if( ! version_compare( phpversion(), $ktdata->req_php, '>=' ) ){ 28 define( 'KTHUMB_DIR', realpath( wp_normalize_path( __DIR__ ) ) ); 29 define( 'KTHUMB_VER', $ktdata['ver'] ); 28 30 29 $message = sprintf( '%s requires PHP %s+, but current one is %s.', 30 $ktdata->plug_name, 31 $ktdata->req_php, 32 phpversion() 33 ); 31 // load files 34 32 35 if( defined( 'WP_CLI' ) ){ 36 WP_CLI::error( $message ); 33 spl_autoload_register( static function( $class ){ 34 35 if( false !== strpos( $class, 'Kama_Thumbnail\\' ) ){ 36 $relpath = explode( '\\', $class, 2 )[1]; 37 require KTHUMB_DIR . "/classes/{$relpath}.php"; 37 38 } 38 else { 39 add_action( 'admin_notices', static function() use ( $message ){ 40 echo '<div id="message" class="notice notice-error"><p>' . $message . '</p></div>'; 41 } ); 42 } 39 } ); 43 40 41 require_once KTHUMB_DIR . '/functions.php'; 42 43 if( ! _kama_thumb_check_php_version( $ktdata ) ){ 44 44 return; 45 45 } 46 46 47 define( 'KTHUMB_VER', $ktdata->ver );48 47 unset( $ktdata ); 49 48 50 define( 'KTHUMB_DIR', wp_normalize_path( __DIR__ ) ); 51 52 // as plugin 49 // Set KTHUMB_URL constant 50 // in plugin 53 51 if( 54 false !== strpos( KTHUMB_DIR, wp_normalize_path( WP_PLUGIN_DIR) )52 false !== strpos( KTHUMB_DIR, realpath( wp_normalize_path( WP_PLUGIN_DIR ) ) ) 55 53 || 56 false !== strpos( KTHUMB_DIR, wp_normalize_path( WPMU_PLUGIN_DIR) )54 false !== strpos( KTHUMB_DIR, realpath( wp_normalize_path( WPMU_PLUGIN_DIR ) ) ) 57 55 ){ 58 56 define( 'KTHUMB_URL', plugins_url( '', __FILE__ ) ); … … 60 58 // in theme 61 59 else { 62 define( 'KTHUMB_URL', strtr( KTHUMB_DIR, [ wp_normalize_path( get_template_directory() ) => get_template_directory_uri() ] ) ); 60 define( 'KTHUMB_URL', str_replace( 61 realpath( wp_normalize_path( get_stylesheet_directory() ) ), 62 get_stylesheet_directory_uri(), 63 KTHUMB_DIR 64 ) ); 63 65 } 64 66 65 67 66 // load files 68 /** 69 * INIT 70 */ 67 71 68 spl_autoload_register( static function( $name ){ 69 70 if( false !== strpos( $name, 'Kama_Make_Thumb' ) || false !== strpos( $name, 'Kama_Thumbnail' ) ){ 71 72 require KTHUMB_DIR . "/classes/$name.php"; 73 } 74 } ); 75 76 require KTHUMB_DIR . '/functions.php'; 77 78 79 // stop if this file loads from uninstall.php file 72 // Don't INIT if loads from uninstall.php 80 73 if( defined( 'WP_UNINSTALL_PLUGIN' ) ){ 81 74 return; … … 83 76 84 77 85 // init86 87 78 if( defined( 'WP_CLI' ) ){ 88 79 89 WP_CLI::add_command( 'kthumb', 'Kama_Thumbnail_CLI_Command', [80 WP_CLI::add_command( 'kthumb', \Kama_Thumbnail\CLI_Command::class, [ 90 81 'shortdesc' => 'Kama Thumbnail Plugin CLI Commands', 91 82 ] ); … … 93 84 94 85 95 /** 96 * Initialize the plugin later, so that we can use some hooks from the theme. 97 */ 86 // Initialize later to allow use hooks from theme. 98 87 add_action( 'init', 'kama_thumbnail_init' ); 99 88 -
kama-thumbnail/trunk/readme.txt
r2810486 r2836004 1 1 === Plugin Name === 2 2 Stable tag: trunk 3 Tested up to: 6.1 3 Tested up to: 6.1.1 4 4 5 5 License: GPLv2 or later … … 312 312 == Changelog == 313 313 314 = 3.5.0 = 315 - CHG: !IMPORTANT All core classes moved under `Kama_Thumbnail` namespace. So if you use such classes as `Kama_Thumbnail` or `Kama_Make_Thumb` directly - You need to update your code to use namespase. Example: `Kama_Thumbnail_Helpers::parse_main_dom()` >>> `\Kama_Thumbnail\Helpers::parse_main_dom()` OR `new Kama_Make_Thumb()` >>> `new \Kama_Thumbnail\Make_Thumb()`. 316 - CHG: CHMOD Options moved: `Kama_Make_Thumb::$CHMOD_DIR` >>> `kthumb_opt()->CHMOD_DIR` and `Kama_Make_Thumb::$CHMOD_FILE` >>> `kthumb_opt()->CHMOD_FILE` 317 - NEW: `$src` parameter now understand Attachment ID|Attachment Object|WP_Post. 318 - NEW: `no_photo_url` option now supports attachment ID as a value. 319 - NEW: Delete cached thumbnails of deleted attachment. 320 - IMP: Unit test improvements. 321 - IMP: `src` value moved to `srcset` and `src` now contains the original URL. 322 - IMP: `decoding="async"` by default for kama_thumb_img(). 323 - IMP: Checks the cache_dir path before deleting all files. This is to avoid accidentally deleting files in another directory. Now cache folder must contain one of substring `cache` or `thumb`. 324 - BUG: Type hint in get_src_from_text() method. 325 - BUG: `kama_thumb__img_attrs` hook support `srcset` attribute bugfix. 326 - BUG: stub need to be created when url with not allowed domain was passed. But the stub was created in the path of the normal image. 327 - BUG: Bug fix with symbolic links in WP_PLUGIN_DIR|WPMU_PLUGIN_DIR paths. 328 314 329 = 3.4.2 = 315 330 - NEW: Option to delete single IMG cache by image/thumb URL or attachment ID.
Note: See TracChangeset
for help on using the changeset viewer.