PluginProbe
Auto Alt Text / trunk
Auto Alt Text vtrunk
3.0.3 2.8.2 1.3.1 1.3.2 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.7.0 2.8.0 2.8.1 All 28 releases
auto-alt-text / src / App / AltTextGeneratorParentPostTitle.php

AltTextGeneratorParentPostTitle.php in Auto Alt Text trunk, at src/App/AltTextGeneratorParentPostTitle.php

33 lines 649 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace AATXT\App;
3
4 class AltTextGeneratorParentPostTitle implements AltTextGeneratorInterface
5 {
6 private function __construct()
7 {
8 }
9
10 /**
11 * @return AltTextGeneratorParentPostTitle
12 */
13 public static function make(): AltTextGeneratorParentPostTitle
14 {
15 return new self();
16 }
17
18 /**
19 * Get the alt text of the image
20 * @param int $imageId
21 * @return string
22 */
23 public function altText(int $imageId): string
24 {
25 $parentPost = get_post_parent($imageId);
26
27 if (empty($parentPost)) {
28 return '';
29 }
30
31 return get_the_title($parentPost);
32 }
33 }