PluginProbe
Parse.ly / 3.2.0
Parse.ly v3.2.0
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / Endpoints / class-metadata-endpoint.php

class-metadata-endpoint.php in Parse.ly 3.2.0, at src/Endpoints/class-metadata-endpoint.php

77 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Metadata endpoint abstract class
4 *
5 * @package Parsely\Endpoints
6 * @since 3.2.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\Endpoints;
12
13 use Parsely\Parsely;
14
15 /**
16 * Metadata endpoint classes are expected to implement the remaining functions of the class.
17 *
18 * @since 3.2.0
19 */
20 abstract class Metadata_Endpoint {
21 protected const FIELD_NAME = 'parsely';
22
23 /**
24 * Instance of Parsely class.
25 *
26 * @var Parsely
27 */
28 protected $parsely;
29
30 /**
31 * Constructor.
32 *
33 * @param Parsely $parsely Instance of Parsely class.
34 */
35 public function __construct( Parsely $parsely ) {
36 $this->parsely = $parsely;
37 }
38
39 /**
40 * Function to start up the class and enqueue necessary actions.
41 *
42 * @since 3.2.0
43 *
44 * @return void
45 */
46 abstract public function run(): void;
47
48 /**
49 * Registers the metadata fields on the appropriate resource types.
50 *
51 * @since 3.2.0
52 *
53 * @return void
54 */
55 abstract public function register_meta(): void;
56
57 /**
58 * Get the metadata in string format.
59 *
60 * @since 3.2.0
61 *
62 * @param string $meta_type `json_ld` or `repeated_metas`.
63 * @return string The metadata as HTML code.
64 */
65 public function get_rendered_meta( string $meta_type ): string {
66 ob_start();
67 $this->parsely->render_metadata( $meta_type );
68 $out = ob_get_clean();
69
70 if ( false === $out ) {
71 return '';
72 }
73
74 return trim( $out );
75 }
76 }
77