Auto Post Thumbnail - Version 3.9.14

Version Description

  • FIX: Image search in the post text
Download this release

Release Info

Developer webtemyk
Plugin Icon 128x128 Auto Post Thumbnail
Version 3.9.14
Comparing to
See all releases

Code changes from version 3.9.12 to 3.9.14

auto-post-thumbnail.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Auto Featured Image (Auto Post Thumbnail)
4
  Plugin URI: https://cm-wp.com/apt
5
  Description: Automatically generate the Featured Image from the first image in post or any custom post type only if Featured Image is not set manually. Featured Image Generation From Title. Native image search for Elementor, Gutenberg, Classic Editor.
6
- Version: 3.9.12
7
  Author: Creative Motion <support@cm-wp.com>
8
  Author URI: https://cm-wp.com
9
  Text Domain: apt
3
  Plugin Name: Auto Featured Image (Auto Post Thumbnail)
4
  Plugin URI: https://cm-wp.com/apt
5
  Description: Automatically generate the Featured Image from the first image in post or any custom post type only if Featured Image is not set manually. Featured Image Generation From Title. Native image search for Elementor, Gutenberg, Classic Editor.
6
+ Version: 3.9.14
7
  Author: Creative Motion <support@cm-wp.com>
8
  Author URI: https://cm-wp.com
9
  Text Domain: apt
includes/class-apt.php CHANGED
@@ -99,6 +99,7 @@ class AutoPostThumbnails {
99
  */
100
  private function init_includes() {
101
  // require __DIR__ . '/src/class.template.php';
 
102
  }
103
 
104
  /**
@@ -438,7 +439,7 @@ class AutoPostThumbnails {
438
  * Look for this id in the IMG tag.
439
  */
440
  if ( isset( $image['tag'] ) && ! empty( $image['tag'] ) ) {
441
- preg_match( ' / wp - image - ( [ \d ] *) / i', $image['tag'], $thumb_id );
442
 
443
  if ( $thumb_id ) {
444
  $thumb_id = $thumb_id[1];
@@ -454,8 +455,7 @@ class AutoPostThumbnails {
454
  if ( isset( $image['url'] ) && ! empty( $image['url'] ) ) {
455
  $image_url = $image['url'];
456
  // если ссылка на миниатюру, то регулярка сделает ссылку на оригинал. убирает в конце названия файла -150x150
457
- $image_url = preg_replace( ' / - [ 0 - 9 ]{
458
- 1,}x[ 0 - 9 ]{1,}\./', ' . ', $image_url );
459
  $thumb_id = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid LIKE ' % " . esc_sql( $image_url ) . " % '" );
460
  }
461
  }
@@ -484,6 +484,10 @@ class AutoPostThumbnails {
484
  * @throws Exception
485
  */
486
  public function save_post( $post_id, $post = null, $update = true ) {
 
 
 
 
487
  if ( ! in_array( $post->post_type, $this->allowed_generate_post_types ) ) {
488
  $this->plugin->logger->warning( "The post type ({$post->post_type}) is not allowed for generation in settings" );
489
  } else {
99
  */
100
  private function init_includes() {
101
  // require __DIR__ . '/src/class.template.php';
102
+ require_once WAPT_PLUGIN_DIR . '/includes/class-processing.php';
103
  }
104
 
105
  /**
439
  * Look for this id in the IMG tag.
440
  */
441
  if ( isset( $image['tag'] ) && ! empty( $image['tag'] ) ) {
442
+ preg_match( '/wp-image-([\d]*)/i', $image['tag'], $thumb_id );
443
 
444
  if ( $thumb_id ) {
445
  $thumb_id = $thumb_id[1];
455
  if ( isset( $image['url'] ) && ! empty( $image['url'] ) ) {
456
  $image_url = $image['url'];
457
  // если ссылка на миниатюру, то регулярка сделает ссылку на оригинал. убирает в конце названия файла -150x150
458
+ $image_url = preg_replace( '/-[0-9]{1,}x[0-9]{1,}\./', ' . ', $image_url );
 
459
  $thumb_id = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid LIKE ' % " . esc_sql( $image_url ) . " % '" );
460
  }
461
  }
484
  * @throws Exception
485
  */
486
  public function save_post( $post_id, $post = null, $update = true ) {
487
+ if ( 'revision' === $post->post_type ) {
488
+ return;
489
+ }
490
+
491
  if ( ! in_array( $post->post_type, $this->allowed_generate_post_types ) ) {
492
  $this->plugin->logger->warning( "The post type ({$post->post_type}) is not allowed for generation in settings" );
493
  } else {
includes/class-processing.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WBCR\APT;
4
+
5
+ use WBCR\Factory_Processing_103\WP_Background_Process;
6
+
7
+ // Exit if accessed directly
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ /**
13
+ * Class for generating in the background
14
+ *
15
+ * @author Artem Prikhodko <webtemyk@yandex.ru>
16
+ * @copyright (c) 2022, CreativeMotion
17
+ * @version 1.0
18
+ */
19
+ class ProcessingBase extends WP_Background_Process {
20
+
21
+ protected function task( $item ) {
22
+ }
23
+ }
includes/class-wapt-image.php CHANGED
@@ -87,7 +87,7 @@ class Image {
87
  /**
88
  * @var array
89
  */
90
- public $params = array();
91
 
92
  /**
93
  * @return
@@ -251,13 +251,13 @@ class Image {
251
  if ( empty( $hex ) ) {
252
  $hex = $this->font_color;
253
  }
254
- list( $r, $g, $b ) = sscanf( $hex, '#%02x%02x%02x' );
255
 
256
- return array(
257
  'r' => $r,
258
  'g' => $g,
259
  'b' => $b,
260
- );
261
  }
262
 
263
  /**
@@ -277,12 +277,12 @@ class Image {
277
  $text = ! empty( $this->text ) ? $this->text : $this->reference_text;
278
  //$txt_image = $this->create( 500, 500 );
279
  $box = imagettfbbox( $this->font_size, 0, $this->font_path, $text );
280
- $width = $box[2] - $box[0];
281
  $height = $box[1] - $box[7];
282
- $result = array(
283
- 'width' => ceil( $width / strlen( $text ) ), //средняя ширина одного символа
284
- 'height' => $height, //высота одного символа
285
- );
286
 
287
  return $result;
288
  } else {
87
  /**
88
  * @var array
89
  */
90
+ public $params = [];
91
 
92
  /**
93
  * @return
251
  if ( empty( $hex ) ) {
252
  $hex = $this->font_color;
253
  }
254
+ [ $r, $g, $b ] = sscanf( $hex, '#%02x%02x%02x' );
255
 
256
+ return [
257
  'r' => $r,
258
  'g' => $g,
259
  'b' => $b,
260
+ ];
261
  }
262
 
263
  /**
277
  $text = ! empty( $this->text ) ? $this->text : $this->reference_text;
278
  //$txt_image = $this->create( 500, 500 );
279
  $box = imagettfbbox( $this->font_size, 0, $this->font_path, $text );
280
+ $width = ceil( ( $box[2] - $box[0] ) / strlen( $text ) );
281
  $height = $box[1] - $box[7];
282
+ $result = [
283
+ 'width' => $width ? $width : 1, //средняя ширина одного символа
284
+ 'height' => $height ? $height : 1, //высота одного символа
285
+ ];
286
 
287
  return $result;
288
  } else {
preview.jpg CHANGED
Binary file
readme.txt CHANGED
@@ -113,6 +113,12 @@ This section describes how to install the plugin and get it working.
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
116
  = 3.9.12 =
117
  * ADD: CRON scheduled image generation (New option in settings) - PREMIUM
118
  * FIX: Compatibility with ShortPixel plugin
113
 
114
  == Changelog ==
115
 
116
+ = 3.9.14 =
117
+ * FIX: Image search in the post text
118
+
119
+ = 3.9.13 =
120
+ * Some fixes for compatibility with premium plugin
121
+
122
  = 3.9.12 =
123
  * ADD: CRON scheduled image generation (New option in settings) - PREMIUM
124
  * FIX: Compatibility with ShortPixel plugin