PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/adapter/application/document.php +50 -9 1.6.9 → 1.8.16 View file →
@@ -66,27 +66,68 @@
66 66 * @param mixed $content Value of the meta HTML tag as array or string.
67 67 * @param string $attribute Attribute to use in the meta HTML tag.
68 68 *
69 69 * @return self This object to support chaining.
70 + *
71 + * @since 10.1.66 Robots are now treated differently.
70 72 *
71 73 * @uses attachToHead()
72 74 */
73 75 public function setMetaData($name, $content, $attribute = 'name')
74 76 {
75 - $attribute = empty($attribute) || !is_string($attribute) ? 'name' : $attribute;
77 + if ($name === 'robots')
78 + {
79 + add_filter('wp_robots', function($robots) use ($content) {
80 + if (!$content)
81 + {
82 + return $robots;
83 + }
76 84
77 - if (is_scalar($content))
85 + $robots = [];
86 +
87 + // obtain all the directives from the content (separated by a comma)
88 + $directives = preg_split("/\s*,\s*/", $content);
89 +
90 + foreach ($directives as $directive)
91 + {
92 + // obtain key-val pairs (separated by a colon)
93 + $directive = preg_split("/\s*:\s*/", $directive);
94 +
95 + $key = strtolower(array_shift($directive));
96 +
97 + if (count($directive) == 0)
98 + {
99 + // attribute only, use true as value
100 + $val = true;
101 + }
102 + else
103 + {
104 + $val = implode(':', $directive);
105 + }
106 +
107 + $robots[$key] = $val;
108 + }
109 +
110 + return $robots;
111 + });
112 + }
113 + else
78 114 {
79 - $content = array($content);
80 - }
115 + $attribute = empty($attribute) || !is_string($attribute) ? 'name' : $attribute;
81 116
82 - $this->attachToHead(function() use ($name, $content, $attribute)
83 - {
84 - foreach ($content as $cont)
117 + if (is_scalar($content))
85 118 {
86 - echo "<meta {$attribute}=\"{$name}\" content=\"" . esc_attr($cont) . "\" />\n";
119 + $content = array($content);
87 120 }
88 - }, true);
121 +
122 + $this->attachToHead(function() use ($name, $content, $attribute)
123 + {
124 + foreach ($content as $cont)
125 + {
126 + echo "<meta {$attribute}=\"{$name}\" content=\"" . esc_attr($cont) . "\" />\n";
127 + }
128 + }, true);
129 + }
89 130
90 131 $this->data[$name] = $content;
91 132
92 133 return $this;