' . "\n"; echo $agenli_custom . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo '' . "\n"; } } private static function output_json_ld( $agenli_data ) { if ( empty( $agenli_data ) ) return; echo '' . "\n"; } private static function build_organisation() { $agenli_schema = array( '@context' => 'https://schema.org', '@type' => agenli_get_option( 'schema_org_type', 'Organization' ), 'name' => agenli_get_option( 'schema_org_name', get_bloginfo( 'name' ) ), 'url' => home_url( '/' ), ); $agenli_logo = agenli_get_option( 'schema_org_logo' ); $agenli_phone = agenli_get_option( 'schema_org_phone' ); $agenli_email = agenli_get_option( 'schema_org_email' ); $agenli_address = agenli_get_option( 'schema_org_address' ); if ( $agenli_logo ) $agenli_schema['logo'] = array( '@type' => 'ImageObject', 'url' => $agenli_logo ); if ( $agenli_phone ) $agenli_schema['telephone'] = $agenli_phone; if ( $agenli_email ) $agenli_schema['email'] = $agenli_email; if ( $agenli_address ) $agenli_schema['address'] = $agenli_address; return $agenli_schema; } private static function build_website() { return array( '@context' => 'https://schema.org', '@type' => 'WebSite', 'name' => get_bloginfo( 'name' ), 'url' => home_url( '/' ), 'potentialAction' => array( '@type' => 'SearchAction', 'target' => array( '@type' => 'EntryPoint', 'urlTemplate' => home_url( '/?s={search_term_string}' ), ), 'query-input' => 'required name=search_term_string', ), ); } private static function build_article( $agenli_post_id ) { $agenli_post = get_post( $agenli_post_id ); if ( ! $agenli_post ) return array(); $agenli_desc = agenli_get_post_meta( $agenli_post_id, 'seo_desc' ); if ( ! $agenli_desc ) { $agenli_desc = wp_trim_words( wp_strip_all_tags( $agenli_post->post_content ), 30, '...' ); } $agenli_schema = array( '@context' => 'https://schema.org', '@type' => 'Article', 'headline' => get_the_title( $agenli_post_id ), 'description' => $agenli_desc, 'url' => get_permalink( $agenli_post_id ), 'datePublished' => gmdate( 'c', strtotime( $agenli_post->post_date_gmt ) ), 'dateModified' => gmdate( 'c', strtotime( $agenli_post->post_modified_gmt ) ), 'author' => array( '@type' => 'Person', 'name' => get_the_author_meta( 'display_name', $agenli_post->post_author ), ), 'publisher' => array( '@type' => 'Organization', 'name' => get_bloginfo( 'name' ), ), ); $agenli_thumb = get_the_post_thumbnail_url( $agenli_post_id, 'large' ); if ( $agenli_thumb ) $agenli_schema['image'] = $agenli_thumb; return $agenli_schema; } private static function build_breadcrumb( $agenli_post_id ) { $agenli_items = array(); $agenli_items[] = array( '@type' => 'ListItem', 'position' => 1, 'name' => get_bloginfo( 'name' ), 'item' => home_url( '/' ), ); $agenli_pos = 2; if ( is_single() ) { $agenli_cats = get_the_category( $agenli_post_id ); if ( $agenli_cats ) { $agenli_items[] = array( '@type' => 'ListItem', 'position' => $agenli_pos++, 'name' => $agenli_cats[0]->name, 'item' => get_category_link( $agenli_cats[0]->term_id ), ); } $agenli_items[] = array( '@type' => 'ListItem', 'position' => $agenli_pos, 'name' => get_the_title( $agenli_post_id ), 'item' => get_permalink( $agenli_post_id ), ); } elseif ( is_page() ) { $agenli_ancestors = array_reverse( get_post_ancestors( $agenli_post_id ) ); foreach ( $agenli_ancestors as $agenli_anc ) { $agenli_items[] = array( '@type' => 'ListItem', 'position' => $agenli_pos++, 'name' => get_the_title( $agenli_anc ), 'item' => get_permalink( $agenli_anc ), ); } $agenli_items[] = array( '@type' => 'ListItem', 'position' => $agenli_pos, 'name' => get_the_title( $agenli_post_id ), 'item' => get_permalink( $agenli_post_id ), ); } else { return array(); } return array( '@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => $agenli_items, ); } }