PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / trunk
WPSSO Core – Complete Schema Markup and Meta Tags vtrunk
22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / html / mod-variable.html

mod-variable.html in WPSSO Core – Complete Schema Markup and Meta Tags trunk, at html/mod-variable.html

234 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 <p>The <code>$mod</code> variable is defined early in the load process (in <code>WpssoHead-&gt;show_head()</code>, which is hooked to the 'wp_head' action) and is passed to most WPSSO methods and filters.</p>
3
4 <pre>
5 $wpsso =&amp; Wpsso::get_instance();
6
7 // In case we prefer using the global $post object.
8 $use_post = apply_filters( 'wpsso_use_post', in_the_loop() ? true : false );
9
10 // Get information about the current webpage.
11 $mod = $wpsso-&gt;page-&gt;get_mod( $use_post );
12 </pre>
13
14 <p>The <code>$mod</code> variable name stands for <em>module</em> and defines important reference values for the current WPSSO object type. The WPSSO object type can be a comment, post, term, or user object. An archive does not have an object type since an archive page is a collection of objects. For example, a monthly archive is a collection of posts for that month. In this case, <code>$mod[ 'obj' ]</code> would be false and other properties like <code>$mod[ 'is_archive' ]</code>, <code>$mod[ 'is_date' ]</code>, and <code>$mod[ 'is_month' ]</code> would be true.</p>
15
16 <p>The <code>WpssoPage-&gt;get_mod()</code> method can be used to determine the current webpage module. If you need to setup a <code>$mod</code> variable for a specific comment, post, term, or user, you can call the <code>get_mod()</code> method from those class objects.</p>
17
18 <pre>
19 $wpsso =&amp; Wpsso::get_instance();
20
21 // Get information for comment ID 123.
22 $mod = $wpsso-&gt;comment-&gt;get_mod( $comment_id = 123 );
23
24 // Get information for post ID 123.
25 $mod = $wpsso-&gt;post-&gt;get_mod( $post_id = 123 );
26
27 // Get information for term ID 123.
28 $mod = $wpsso-&gt;term-&gt;get_mod( $term_id = 123 );
29
30 // Get information for user ID 123.
31 $mod = $wpsso-&gt;user-&gt;get_mod( $user_id = 123 );
32 </pre>
33
34 <p>Functions to get the <code>$mod</code> array are also available:</p>
35
36 <pre>
37 // Get information about the current webpage (post, term, user, archive page, etc.).
38 $mod = wpsso_get_page_mod();
39
40 // Get information for comment ID 123.
41 $mod = wpsso_get_comment_mod( $comment_id = 123 );
42
43 // Get information for post ID 123.
44 $mod = wpsso_get_post_mod( $post_id = 123 );
45
46 // Get information for term ID 123.
47 $mod = wpsso_get_term_mod( $term_id = 123 );
48
49 // Get information for user ID 123.
50 $mod = wpsso_get_user_mod( $user_id = 123 );
51 </pre>
52
53 <p>Here is an example <code>$mod</code> array for a post:</p>
54
55 <pre>Array (
56 [id] =&gt; 123
57 [name] =&gt; post
58 [name_transl] =&gt; post
59 [obj] =&gt; object WpssoPost
60 [wp_obj] =&gt; object WP_Post
61 [query_vars] =&gt; Array ()
62 [posts_args] =&gt; Array ()
63 [paged] =&gt; false
64 [paged_total] =&gt; 1
65 [is_404] =&gt; false
66 [is_archive] =&gt; false
67 [is_attachment] =&gt; false
68 [is_comment] =&gt; false
69 [is_date] =&gt; false
70 [is_day] =&gt; false
71 [is_home] =&gt; false
72 [is_home_page] =&gt; false
73 [is_home_posts] =&gt; false
74 [is_month] =&gt; false
75 [is_post] =&gt; true
76 [is_post_type_archive] =&gt; false
77 [is_public] =&gt; false
78 [is_search] =&gt; false
79 [is_term] =&gt; false
80 [is_user] =&gt; false
81 [is_year] =&gt; false
82 [comment_author] =&gt; false
83 [comment_author_name] =&gt; false
84 [comment_author_url] =&gt; false
85 [comment_paged] =&gt; false
86 [comment_parent] =&gt; false
87 [comment_rating] =&gt; false
88 [comment_time] =&gt; false
89 [use_post] =&gt; false
90 [post_slug] =&gt; the-post-slug
91 [post_type] =&gt; post
92 [post_type_label_plural] =&gt; Posts
93 [post_type_label_single] =&gt; Post
94 [post_mime_type] =&gt; ''
95 [post_mime_group] =&gt; ''
96 [post_mime_subgroup] =&gt; ''
97 [post_status] =&gt; publish
98 [post_author] =&gt; 123
99 [post_coauthors] =&gt; Array ()
100 [post_time] =&gt; 2013-03-15T22:23:27+00:00
101 [post_timestamp] =&gt; 1363386207
102 [post_modified_time] =&gt; 2021-01-31T00:16:46+00:00
103 [post_modified_timestamp] =&gt; 1612052206
104 [post_parent] =&gt; false
105 [tax_slug] =&gt; ''
106 [tax_label_plural] =&gt; false
107 [tax_label_single] =&gt; false
108 [user_name] =&gt; ''
109 [wpml_code] =&gt; ''
110 )</pre>
111
112 <p>Here is an example <code>$mod</code> array for a WooCommerce product:</p>
113
114 <pre>Array (
115 [id] =&gt; 4567
116 [name] =&gt; post
117 [name_transl] =&gt; post
118 [obj] =&gt; object WpssoPost
119 [wp_obj] =&gt; object WP_Post
120 [query_vars] =&gt; Array ()
121 [posts_args] =&gt; Array ()
122 [paged] =&gt; false
123 [paged_total] =&gt; 1
124 [is_404] =&gt; false
125 [is_archive] =&gt; false
126 [is_attachment] =&gt; false
127 [is_comment] =&gt; false
128 [is_date] =&gt; false
129 [is_day] =&gt; false
130 [is_feed] =&gt; false
131 [is_home] =&gt; false
132 [is_home_page] =&gt; false
133 [is_home_posts] =&gt; false
134 [is_month] =&gt; false
135 [is_post] =&gt; true
136 [is_post_type_archive] =&gt; false
137 [is_public] =&gt; true
138 [is_search] =&gt; false
139 [is_term] =&gt; false
140 [is_user] =&gt; false
141 [is_year] =&gt; false
142 [comment_author] =&gt; false
143 [comment_author_name] =&gt; false
144 [comment_author_url] =&gt; false
145 [comment_paged] =&gt; false
146 [comment_parent] =&gt; false
147 [comment_rating] =&gt; false
148 [comment_time] =&gt; false
149 [use_post] =&gt; false
150 [post_slug] =&gt; hoodie
151 [post_type] =&gt; product
152 [post_type_label_plural] =&gt; Products
153 [post_type_label_single] =&gt; Product
154 [post_mime_type] =&gt; ''
155 [post_mime_group] =&gt; false
156 [post_mime_subgroup] =&gt; false
157 [post_status] =&gt; publish
158 [post_author] =&gt; 123
159 [post_coauthors] =&gt; Array ()
160 [post_time] =&gt; 2023-02-16T12:34:11+00:00
161 [post_timestamp] =&gt; 1676550851
162 [post_modified_time] =&gt; 2023-07-04T00:54:41+00:00
163 [post_modified_timestamp] =&gt; 1688432081
164 [post_parent] =&gt; false
165 [term_tax_id] =&gt; false
166 [tax_slug] =&gt; ''
167 [tax_label_plural] =&gt; false
168 [tax_label_single] =&gt; false
169 [user_name] =&gt; ''
170 [wpml_code] =&gt; ''
171 )</pre>
172
173 <p>Here is an example <code>$mod</code> array for a WooCommerce product category term:</p>
174
175 <pre>Array (
176 [id] =&gt; 890
177 [name] =&gt; term
178 [name_transl] =&gt; term
179 [obj] =&gt; object WpssoTerm
180 [wp_obj] =&gt; object WP_Term
181 [query_vars] =&gt; Array ()
182 [posts_args] =&gt; Array ()
183 [paged] =&gt; false
184 [paged_total] =&gt; false
185 [is_404] =&gt; false
186 [is_archive] =&gt; true
187 [is_attachment] =&gt; false
188 [is_comment] =&gt; false
189 [is_date] =&gt; false
190 [is_day] =&gt; false
191 [is_feed] =&gt; false
192 [is_home] =&gt; false
193 [is_home_page] =&gt; false
194 [is_home_posts] =&gt; false
195 [is_month] =&gt; false
196 [is_post] =&gt; false
197 [is_post_type_archive] =&gt; false
198 [is_public] =&gt; true
199 [is_search] =&gt; false
200 [is_term] =&gt; true
201 [is_user] =&gt; false
202 [is_year] =&gt; false
203 [comment_author] =&gt; false
204 [comment_author_name] =&gt; false
205 [comment_author_url] =&gt; false
206 [comment_paged] =&gt; false
207 [comment_parent] =&gt; false
208 [comment_rating] =&gt; false
209 [comment_time] =&gt; false
210 [use_post] =&gt; false
211 [post_slug] =&gt; false
212 [post_type] =&gt; false
213 [post_type_label_plural] =&gt; false
214 [post_type_label_single] =&gt; false
215 [post_mime_type] =&gt; false
216 [post_mime_group] =&gt; false
217 [post_mime_subgroup] =&gt; false
218 [post_status] =&gt; false
219 [post_author] =&gt; false
220 [post_coauthors] =&gt; Array ()
221 [post_time] =&gt; false
222 [post_timestamp] =&gt; false
223 [post_modified_time] =&gt; false
224 [post_modified_timestamp] =&gt; false
225 [post_parent] =&gt; false
226 [term_tax_id] =&gt; 761
227 [tax_slug] =&gt; product_cat
228 [tax_label_plural] =&gt; Product categories
229 [tax_label_single] =&gt; Category
230 [user_name] =&gt; ''
231 [wpml_code] =&gt; ''
232 )</pre>
233
234