| @@ -1,0 +1,233 @@ | ||
| 1 | + | |
| 2 | +<p>The <code>$mod</code> variable is defined early in the load process (in <code>WpssoHead->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 =& 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->page->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->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 =& Wpsso::get_instance(); | |
| 20 | + | |
| 21 | +// Get information for comment ID 123. | |
| 22 | +$mod = $wpsso->comment->get_mod( $comment_id = 123 ); | |
| 23 | + | |
| 24 | +// Get information for post ID 123. | |
| 25 | +$mod = $wpsso->post->get_mod( $post_id = 123 ); | |
| 26 | + | |
| 27 | +// Get information for term ID 123. | |
| 28 | +$mod = $wpsso->term->get_mod( $term_id = 123 ); | |
| 29 | + | |
| 30 | +// Get information for user ID 123. | |
| 31 | +$mod = $wpsso->user->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] => 123 | |
| 57 | + [name] => post | |
| 58 | + [name_transl] => post | |
| 59 | + [obj] => object WpssoPost | |
| 60 | + [wp_obj] => object WP_Post | |
| 61 | + [query_vars] => Array () | |
| 62 | + [posts_args] => Array () | |
| 63 | + [paged] => false | |
| 64 | + [paged_total] => 1 | |
| 65 | + [is_404] => false | |
| 66 | + [is_archive] => false | |
| 67 | + [is_attachment] => false | |
| 68 | + [is_comment] => false | |
| 69 | + [is_date] => false | |
| 70 | + [is_day] => false | |
| 71 | + [is_home] => false | |
| 72 | + [is_home_page] => false | |
| 73 | + [is_home_posts] => false | |
| 74 | + [is_month] => false | |
| 75 | + [is_post] => true | |
| 76 | + [is_post_type_archive] => false | |
| 77 | + [is_public] => false | |
| 78 | + [is_search] => false | |
| 79 | + [is_term] => false | |
| 80 | + [is_user] => false | |
| 81 | + [is_year] => false | |
| 82 | + [comment_author] => false | |
| 83 | + [comment_author_name] => false | |
| 84 | + [comment_author_url] => false | |
| 85 | + [comment_paged] => false | |
| 86 | + [comment_parent] => false | |
| 87 | + [comment_rating] => false | |
| 88 | + [comment_time] => false | |
| 89 | + [use_post] => false | |
| 90 | + [post_slug] => the-post-slug | |
| 91 | + [post_type] => post | |
| 92 | + [post_type_label_plural] => Posts | |
| 93 | + [post_type_label_single] => Post | |
| 94 | + [post_mime_type] => '' | |
| 95 | + [post_mime_group] => '' | |
| 96 | + [post_mime_subgroup] => '' | |
| 97 | + [post_status] => publish | |
| 98 | + [post_author] => 123 | |
| 99 | + [post_coauthors] => Array () | |
| 100 | + [post_time] => 2013-03-15T22:23:27+00:00 | |
| 101 | + [post_timestamp] => 1363386207 | |
| 102 | + [post_modified_time] => 2021-01-31T00:16:46+00:00 | |
| 103 | + [post_modified_timestamp] => 1612052206 | |
| 104 | + [post_parent] => false | |
| 105 | + [tax_slug] => '' | |
| 106 | + [tax_label_plural] => false | |
| 107 | + [tax_label_single] => false | |
| 108 | + [user_name] => '' | |
| 109 | + [wpml_code] => '' | |
| 110 | +)</pre> | |
| 111 | + | |
| 112 | +<p>Here is an example <code>$mod</code> array for a WooCommerce product:</p> | |
| 113 | + | |
| 114 | +<pre>Array ( | |
| 115 | + [id] => 4567 | |
| 116 | + [name] => post | |
| 117 | + [name_transl] => post | |
| 118 | + [obj] => object WpssoPost | |
| 119 | + [wp_obj] => object WP_Post | |
| 120 | + [query_vars] => Array () | |
| 121 | + [posts_args] => Array () | |
| 122 | + [paged] => false | |
| 123 | + [paged_total] => 1 | |
| 124 | + [is_404] => false | |
| 125 | + [is_archive] => false | |
| 126 | + [is_attachment] => false | |
| 127 | + [is_comment] => false | |
| 128 | + [is_date] => false | |
| 129 | + [is_day] => false | |
| 130 | + [is_feed] => false | |
| 131 | + [is_home] => false | |
| 132 | + [is_home_page] => false | |
| 133 | + [is_home_posts] => false | |
| 134 | + [is_month] => false | |
| 135 | + [is_post] => true | |
| 136 | + [is_post_type_archive] => false | |
| 137 | + [is_public] => true | |
| 138 | + [is_search] => false | |
| 139 | + [is_term] => false | |
| 140 | + [is_user] => false | |
| 141 | + [is_year] => false | |
| 142 | + [comment_author] => false | |
| 143 | + [comment_author_name] => false | |
| 144 | + [comment_author_url] => false | |
| 145 | + [comment_paged] => false | |
| 146 | + [comment_parent] => false | |
| 147 | + [comment_rating] => false | |
| 148 | + [comment_time] => false | |
| 149 | + [use_post] => false | |
| 150 | + [post_slug] => hoodie | |
| 151 | + [post_type] => product | |
| 152 | + [post_type_label_plural] => Products | |
| 153 | + [post_type_label_single] => Product | |
| 154 | + [post_mime_type] => '' | |
| 155 | + [post_mime_group] => false | |
| 156 | + [post_mime_subgroup] => false | |
| 157 | + [post_status] => publish | |
| 158 | + [post_author] => 123 | |
| 159 | + [post_coauthors] => Array () | |
| 160 | + [post_time] => 2023-02-16T12:34:11+00:00 | |
| 161 | + [post_timestamp] => 1676550851 | |
| 162 | + [post_modified_time] => 2023-07-04T00:54:41+00:00 | |
| 163 | + [post_modified_timestamp] => 1688432081 | |
| 164 | + [post_parent] => false | |
| 165 | + [term_tax_id] => false | |
| 166 | + [tax_slug] => '' | |
| 167 | + [tax_label_plural] => false | |
| 168 | + [tax_label_single] => false | |
| 169 | + [user_name] => '' | |
| 170 | + [wpml_code] => '' | |
| 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] => 890 | |
| 177 | + [name] => term | |
| 178 | + [name_transl] => term | |
| 179 | + [obj] => object WpssoTerm | |
| 180 | + [wp_obj] => object WP_Term | |
| 181 | + [query_vars] => Array () | |
| 182 | + [posts_args] => Array () | |
| 183 | + [paged] => false | |
| 184 | + [paged_total] => false | |
| 185 | + [is_404] => false | |
| 186 | + [is_archive] => true | |
| 187 | + [is_attachment] => false | |
| 188 | + [is_comment] => false | |
| 189 | + [is_date] => false | |
| 190 | + [is_day] => false | |
| 191 | + [is_feed] => false | |
| 192 | + [is_home] => false | |
| 193 | + [is_home_page] => false | |
| 194 | + [is_home_posts] => false | |
| 195 | + [is_month] => false | |
| 196 | + [is_post] => false | |
| 197 | + [is_post_type_archive] => false | |
| 198 | + [is_public] => true | |
| 199 | + [is_search] => false | |
| 200 | + [is_term] => true | |
| 201 | + [is_user] => false | |
| 202 | + [is_year] => false | |
| 203 | + [comment_author] => false | |
| 204 | + [comment_author_name] => false | |
| 205 | + [comment_author_url] => false | |
| 206 | + [comment_paged] => false | |
| 207 | + [comment_parent] => false | |
| 208 | + [comment_rating] => false | |
| 209 | + [comment_time] => false | |
| 210 | + [use_post] => false | |
| 211 | + [post_slug] => false | |
| 212 | + [post_type] => false | |
| 213 | + [post_type_label_plural] => false | |
| 214 | + [post_type_label_single] => false | |
| 215 | + [post_mime_type] => false | |
| 216 | + [post_mime_group] => false | |
| 217 | + [post_mime_subgroup] => false | |
| 218 | + [post_status] => false | |
| 219 | + [post_author] => false | |
| 220 | + [post_coauthors] => Array () | |
| 221 | + [post_time] => false | |
| 222 | + [post_timestamp] => false | |
| 223 | + [post_modified_time] => false | |
| 224 | + [post_modified_timestamp] => false | |
| 225 | + [post_parent] => false | |
| 226 | + [term_tax_id] => 761 | |
| 227 | + [tax_slug] => product_cat | |
| 228 | + [tax_label_plural] => Product categories | |
| 229 | + [tax_label_single] => Category | |
| 230 | + [user_name] => '' | |
| 231 | + [wpml_code] => '' | |
| 232 | +)</pre> | |
| 233 | + | |