-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopengraph.php
More file actions
114 lines (100 loc) · 2.68 KB
/
opengraph.php
File metadata and controls
114 lines (100 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// Typ stránky
function yoast_change_opengraph_type($type) {
global $wp_query;
if (isset($wp_query->query_vars['objekt']) || isset($wp_query->query_vars['autor'])) {
return 'article';
}
return $type;
}
add_filter('wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );
// Nadpis stránky
function yoast_change_opengraph_title($title) {
global $wp_query;
// objekt
if (isset($wp_query->query_vars['objekt'])) {
$obj = kv_object_info();
if ($obj != null) {
return $obj->nazev." » ".$title;
}
}
// autor
if (isset($wp_query->query_vars['autor'])) {
$au = kv_author_info();
if ($au != null) {
return $au->jmeno." ".$au->prijmeni." » ".$title;
}
}
// soubor děl
if (isset($wp_query->query_vars['soubor'])) {
$so = kv_collection_info();
if ($so != null) {
return $so->nazev." » ".$title;
}
}
return $title;
}
add_filter('wpseo_opengraph_title', 'yoast_change_opengraph_title', 10, 1 );
// Popis stránky
function yoast_change_opengraph_description($description) {
global $wp_query;
// objekt
if (isset($wp_query->query_vars['objekt'])) {
$obj = kv_object_info();
if ($obj != null) {
return $obj->popis;
}
}
// autor
if (isset($wp_query->query_vars['autor'])) {
return "Informace o autorovi děl.";
}
// soubor děl
if (isset($wp_query->query_vars['soubor'])) {
$so = kv_collection_info();
if ($so != null) {
return $so->popis;
}
}
return $description;
}
add_filter('wpseo_opengraph_description', 'yoast_change_opengraph_description', 10, 1 );
add_filter('wpseo_metadesc', 'yoast_change_opengraph_description', 10, 1 );
// Fotka
function yoast_change_opengraph_image($image) {
global $wp_query;
// objekt
if (isset($wp_query->query_vars['objekt'])) {
$obj = kv_object_info();
if ($obj != null) {
if ($obj->fotografiePrim != null && $obj->fotografiePrim->img_512 != null) {
$upload_dir = wp_upload_dir();
return $upload_dir['baseurl'].$obj->fotografiePrim->img_512;
}
}
}
// autor
if (isset($wp_query->query_vars['autor'])) {
$au = kv_author_info();
if ($au != null && $au->img_512 != null) {
$upload_dir = wp_upload_dir();
return $upload_dir['baseurl'].$au->img_512;
}
}
// soubor děl
if (isset($wp_query->query_vars['soubor'])) {
$so = kv_collection_info();
if ($so != null) {
$upload_dir = wp_upload_dir();
return $upload_dir['baseurl'].$so->img_512;
}
}
return $image;
}
add_filter('wpseo_opengraph_image', 'yoast_change_opengraph_image', 10, 1 );
// URL
function yoast_change_opengraph_url($url) {
global $wp_query;
return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
add_filter('wpseo_opengraph_url', 'yoast_change_opengraph_url', 10, 1 );