| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Registers the WpStream custom post types and their taxonomies. |
| 5 |
* |
| 6 |
* Defines the Free-To-View Live Channel, Free-To-View VOD, and Video |
| 7 |
* Collection post types together with the wpstream_actors / wpstream_category / |
| 8 |
* wpstream_movie_rating taxonomies, wires custom capabilities, renders the |
| 9 |
* taxonomy term meta fields (page id, featured image, tagline), and maintains |
| 10 |
* cached term-value lists used by shortcodes. |
| 11 |
* |
| 12 |
* @author cretu |
| 13 |
* |
| 14 |
* @package Wpstream |
| 15 |
* @subpackage Wpstream/includes |
| 16 |
*/ |
| 17 |
|
| 18 |
// Exit if accessed directly. |
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
class Wpstream_Product { |
| 24 |
|
| 25 |
/** |
| 26 |
* Hook term add/edit/delete to cache rebuilds and adjust the product list columns. |
| 27 |
*/ |
| 28 |
public function __construct() { |
| 29 |
// Any term create/edit/delete invalidates and rebuilds the cached term lists. |
| 30 |
add_action( 'create_term', array($this,'wpstream_redo_transient') ); |
| 31 |
add_action( 'edit_term', array($this,'wpstream_redo_transient') ); |
| 32 |
add_action( 'delete_term', array($this,'wpstream_redo_transient') ); |
| 33 |
// Hide the WpStream taxonomy columns from the WooCommerce products table. |
| 34 |
add_filter('manage_edit-product_columns', array($this,'remove_wpstream_category_column') ) ; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
/** |
| 39 |
* Flush the cached taxonomy value transients and regenerate them. |
| 40 |
*/ |
| 41 |
public function wpstream_redo_transient(){ |
| 42 |
// Drop the stale cached term-value lists. |
| 43 |
delete_transient('wpstream_woo_movie_category_values'); |
| 44 |
delete_transient('wpstream_woo_actors_category_values'); |
| 45 |
delete_transient('wpstream_woo_product_cat'); |
| 46 |
delete_transient('wpstream_woo_movie_rating_category_values'); |
| 47 |
// Rebuild each list so subsequent reads hit a warm cache. |
| 48 |
$this->wpstream_generate_woo_movie_category_values_shortcode(); |
| 49 |
$this->wpstream_generate_actors_category_values_shortcode(); |
| 50 |
$this->wpstream_generate_woo_product_tax_values_shortcode(); |
| 51 |
$this->wpstream_generate_movie_rating_category_values_shortcode(); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* Register custom post type |
| 58 |
* |
| 59 |
* @link https://codex.wordpress.org/Function_Reference/register_post_type |
| 60 |
* |
| 61 |
* @param array $fields Post type definition (slug, singular/plural labels, supports, caps, taxonomies, ...). |
| 62 |
*/ |
| 63 |
private function register_single_post_type( $fields ) { |
| 64 |
|
| 65 |
// Build the full labels array from the singular/plural names supplied in $fields. |
| 66 |
$labels = array( |
| 67 |
'name' => $fields['plural'], |
| 68 |
'singular_name' => $fields['singular'], |
| 69 |
'menu_name' => $fields['menu_name'], |
| 70 |
'new_item' => sprintf( __( 'New %s', 'wpstream' ), $fields['singular'] ), |
| 71 |
'add_new_item' => sprintf( __( 'Add new %s', 'wpstream' ), $fields['singular'] ), |
| 72 |
'edit_item' => sprintf( __( 'Edit %s', 'wpstream' ), $fields['singular'] ), |
| 73 |
'view_item' => sprintf( __( 'View %s', 'wpstream' ), $fields['singular'] ), |
| 74 |
'view_items' => sprintf( __( 'View %s', 'wpstream' ), $fields['plural'] ), |
| 75 |
'search_items' => sprintf( __( 'Search %s', 'wpstream' ), $fields['plural'] ), |
| 76 |
'not_found' => sprintf( __( 'No %s found', 'wpstream' ), strtolower( $fields['plural'] ) ), |
| 77 |
'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'wpstream' ), strtolower( $fields['plural'] ) ), |
| 78 |
'all_items' => sprintf( __( 'All %s', 'wpstream' ), $fields['plural'] ), |
| 79 |
'archives' => sprintf( __( '%s Archives', 'wpstream' ), $fields['singular'] ), |
| 80 |
'attributes' => sprintf( __( '%s Attributes', 'wpstream' ), $fields['singular'] ), |
| 81 |
'insert_into_item' => sprintf( __( 'Insert into %s', 'wpstream' ), strtolower( $fields['singular'] ) ), |
| 82 |
'uploaded_to_this_item' => sprintf( __( 'Uploaded to this %s', 'wpstream' ), strtolower( $fields['singular'] ) ), |
| 83 |
|
| 84 |
/* Labels for hierarchical post types only. */ |
| 85 |
'parent_item' => sprintf( __( 'Parent %s', 'wpstream' ), $fields['singular'] ), |
| 86 |
'parent_item_colon' => sprintf( __( 'Parent %s:', 'wpstream' ), $fields['singular'] ), |
| 87 |
|
| 88 |
/* Custom archive label. Must filter 'post_type_archive_title' to use. */ |
| 89 |
'archive_title' => $fields['plural'], |
| 90 |
); |
| 91 |
|
| 92 |
// Assemble register_post_type() args, falling back to sensible defaults for anything not in $fields. |
| 93 |
$args = array( |
| 94 |
'labels' => $labels, |
| 95 |
'description' => ( isset( $fields['description'] ) ) ? $fields['description'] : '', |
| 96 |
'public' => ( isset( $fields['public'] ) ) ? $fields['public'] : true, |
| 97 |
'publicly_queryable' => ( isset( $fields['publicly_queryable'] ) ) ? $fields['publicly_queryable'] : true, |
| 98 |
'exclude_from_search'=> ( isset( $fields['exclude_from_search'] ) ) ? $fields['exclude_from_search'] : false, |
| 99 |
'show_ui' => ( isset( $fields['show_ui'] ) ) ? $fields['show_ui'] : true, |
| 100 |
'show_in_menu' => ( isset( $fields['show_in_menu'] ) ) ? $fields['show_in_menu'] : true, |
| 101 |
'query_var' => ( isset( $fields['query_var'] ) ) ? $fields['query_var'] : true, |
| 102 |
'show_in_admin_bar' => ( isset( $fields['show_in_admin_bar'] ) ) ? $fields['show_in_admin_bar'] : true, |
| 103 |
'capability_type' => ( isset( $fields['capability_type'] ) ) ? $fields['capability_type'] : 'post', |
| 104 |
'has_archive' => ( isset( $fields['has_archive'] ) ) ? $fields['has_archive'] : true, |
| 105 |
'hierarchical' => ( isset( $fields['hierarchical'] ) ) ? $fields['hierarchical'] : true, |
| 106 |
'supports' => ( isset( $fields['supports'] ) ) ? $fields['supports'] : array( |
| 107 |
'title', |
| 108 |
'editor', |
| 109 |
'excerpt', |
| 110 |
'author', |
| 111 |
'thumbnail', |
| 112 |
'comments', |
| 113 |
'trackbacks', |
| 114 |
'custom-fields', |
| 115 |
'revisions', |
| 116 |
'page-attributes', |
| 117 |
'post-formats', |
| 118 |
), |
| 119 |
'menu_position' => ( isset( $fields['menu_position'] ) ) ? $fields['menu_position'] : 21, |
| 120 |
'menu_icon' => ( isset( $fields['menu_icon'] ) ) ? $fields['menu_icon']: 'dashicons-admin-generic', |
| 121 |
'show_in_nav_menus' => ( isset( $fields['show_in_nav_menus'] ) ) ? $fields['show_in_nav_menus'] : true, |
| 122 |
// REST exposure is opt-in per post type. Core's post controller |
| 123 |
// supplies the permission callbacks, so an anonymous caller only |
| 124 |
// ever sees published posts; drafts and private posts require the |
| 125 |
// matching read capability. |
| 126 |
'show_in_rest' => ( isset( $fields['show_in_rest'] ) ) ? $fields['show_in_rest'] : false, |
| 127 |
'taxonomies' => array( 'category','post_tag' ), |
| 128 |
); |
| 129 |
|
| 130 |
// Apply a custom permalink rewrite rule when the definition provides one. |
| 131 |
if ( isset( $fields['rewrite'] ) ) { |
| 132 |
|
| 133 |
/** |
| 134 |
* Add $this->plugin_name as translatable in the permalink structure, |
| 135 |
* to avoid conflicts with other plugins which may use customers as well. |
| 136 |
*/ |
| 137 |
$args['rewrite'] = $fields['rewrite']; |
| 138 |
} |
| 139 |
|
| 140 |
// When custom capabilities are requested, map meta caps and assign them to roles. |
| 141 |
if ( $fields['custom_caps'] ) { |
| 142 |
|
| 143 |
/** |
| 144 |
* Provides more precise control over the capabilities than the defaults. By default, WordPress |
| 145 |
* will use the 'capability_type' argument to build these capabilities. More often than not, |
| 146 |
* this results in many extra capabilities that you probably don't need. The following is how |
| 147 |
* I set up capabilities for many post types, which only uses three basic capabilities you need |
| 148 |
* to assign to roles: 'manage_examples', 'edit_examples', 'create_examples'. Each post type |
| 149 |
* is unique though, so you'll want to adjust it to fit your needs. |
| 150 |
* |
| 151 |
* @link https://gist.github.com/creativembers/6577149 |
| 152 |
* @link http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types |
| 153 |
*/ |
| 154 |
// Explicit capability map keyed off the singular/plural names. |
| 155 |
$args['capabilities'] = array( |
| 156 |
|
| 157 |
// Meta capabilities |
| 158 |
'edit_post' => 'edit_' . strtolower( $fields['singular'] ), |
| 159 |
'read_post' => 'read_' . strtolower( $fields['singular'] ), |
| 160 |
'delete_post' => 'delete_' . strtolower( $fields['singular'] ), |
| 161 |
|
| 162 |
// Primitive capabilities used outside of map_meta_cap(): |
| 163 |
'edit_posts' => 'edit_' . strtolower( $fields['plural'] ), |
| 164 |
'edit_others_posts' => 'edit_others_' . strtolower( $fields['plural'] ), |
| 165 |
'publish_posts' => 'publish_' . strtolower( $fields['plural'] ), |
| 166 |
'read_private_posts' => 'read_private_' . strtolower( $fields['plural'] ), |
| 167 |
|
| 168 |
// Primitive capabilities used within map_meta_cap(): |
| 169 |
'delete_posts' => 'delete_' . strtolower( $fields['plural'] ), |
| 170 |
'delete_private_posts' => 'delete_private_' . strtolower( $fields['plural'] ), |
| 171 |
'delete_published_posts' => 'delete_published_' . strtolower( $fields['plural'] ), |
| 172 |
'delete_others_posts' => 'delete_others_' . strtolower( $fields['plural'] ), |
| 173 |
'edit_private_posts' => 'edit_private_' . strtolower( $fields['plural'] ), |
| 174 |
'edit_published_posts' => 'edit_published_' . strtolower( $fields['plural'] ), |
| 175 |
'create_posts' => 'edit_' . strtolower( $fields['plural'] ) |
| 176 |
|
| 177 |
); |
| 178 |
|
| 179 |
/** |
| 180 |
* Adding map_meta_cap will map the meta correctly. |
| 181 |
* @link https://wordpress.stackexchange.com/questions/108338/capabilities-and-custom-post-types/108375#108375 |
| 182 |
*/ |
| 183 |
$args['map_meta_cap'] = true; |
| 184 |
|
| 185 |
/** |
| 186 |
* Assign capabilities to users |
| 187 |
* Without this, users - also admins - can not see post type. |
| 188 |
*/ |
| 189 |
// Grant the mapped capabilities to the configured roles. |
| 190 |
$this->assign_capabilities( $args['capabilities'], $fields['custom_caps_users'] ); |
| 191 |
} |
| 192 |
|
| 193 |
/** |
| 194 |
* Filter the registration arguments of one plugin post type. |
| 195 |
* |
| 196 |
* Runs after the capability map is built and granted, so `capabilities` |
| 197 |
* changes here affect registration only. Typical use: `show_in_rest`, |
| 198 |
* `supports`, `rewrite` for headless or themed sites. |
| 199 |
* |
| 200 |
* @since 4.14.0 |
| 201 |
* |
| 202 |
* @param array $args register_post_type() arguments. |
| 203 |
* @param string $slug Post type slug (`wpstream_product`, `wpstream_product_vod`, `wpstream_bundles`). |
| 204 |
*/ |
| 205 |
$args = apply_filters( 'wpstream_post_type_args', $args, $fields['slug'] ); |
| 206 |
|
| 207 |
// Register the post type itself with WordPress. |
| 208 |
register_post_type( $fields['slug'], $args ); |
| 209 |
|
| 210 |
/** |
| 211 |
* Register Taxnonmies if any |
| 212 |
* @link https://codex.wordpress.org/Function_Reference/register_taxonomy |
| 213 |
*/ |
| 214 |
// Register each associated taxonomy declared for this post type. |
| 215 |
if ( isset( $fields['taxonomies'] ) && is_array( $fields['taxonomies'] ) ) { |
| 216 |
|
| 217 |
foreach ( $fields['taxonomies'] as $taxonomy ) { |
| 218 |
|
| 219 |
$this->register_single_post_type_taxnonomy( $taxonomy ); |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
} |
| 224 |
|
| 225 |
// Warm the cached term-value lists now that the taxonomies exist. |
| 226 |
$this->wpstream_generate_woo_movie_category_values_shortcode(); |
| 227 |
$this->wpstream_generate_actors_category_values_shortcode(); |
| 228 |
$this->wpstream_generate_woo_product_tax_values_shortcode(); |
| 229 |
$this->wpstream_generate_movie_rating_category_values_shortcode(); |
| 230 |
|
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
/** |
| 237 |
* Build (and cache for 4 hours) a taxonomy's term list for shortcode selects. |
| 238 |
* |
| 239 |
* Stores two transients: `$transient_key` holding the label/value list and |
| 240 |
* `{$transient_key}_label` holding the parallel term_id => name map. |
| 241 |
* |
| 242 |
* @param string $taxonomy Taxonomy to enumerate (empty terms included). |
| 243 |
* @param string $transient_key Transient key for the cached value list. |
| 244 |
* @return array List of ['label' => name, 'value' => term_id] entries. |
| 245 |
*/ |
| 246 |
public function generate_term_options( $taxonomy, $transient_key ) { |
| 247 |
|
| 248 |
// Serve from cache when available; a false result means the cache is cold. |
| 249 |
$term_options = get_transient( $transient_key ); |
| 250 |
if ( false !== $term_options ) { |
| 251 |
return $term_options; |
| 252 |
} |
| 253 |
|
| 254 |
// Cold cache: rebuild both the value list and the id=>name label map. |
| 255 |
$term_options = array(); |
| 256 |
$all_tax_labels = array(); |
| 257 |
$terms = get_terms( array( |
| 258 |
'taxonomy' => $taxonomy, |
| 259 |
'hide_empty' => false, |
| 260 |
) ); |
| 261 |
|
| 262 |
if ( is_array( $terms ) ) { |
| 263 |
// Convert each term into a label/value pair for the shortcode select. |
| 264 |
foreach ( $terms as $term ) { |
| 265 |
$term_options[] = array( |
| 266 |
'label' => $term->name, |
| 267 |
'value' => $term->term_id, |
| 268 |
); |
| 269 |
$all_tax_labels[ $term->term_id ] = $term->name; |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
// Cache both the id=>name labels and the value list for 4 hours. |
| 274 |
set_transient( $transient_key . '_label', $all_tax_labels, 60 * 60 * 4 ); |
| 275 |
set_transient( $transient_key, $term_options, 60 * 60 * 4 ); |
| 276 |
|
| 277 |
return $term_options; |
| 278 |
} |
| 279 |
|
| 280 |
/** |
| 281 |
* Build (and cache for 4 hours) the wpstream_category term list for shortcodes. |
| 282 |
* |
| 283 |
* @return array List of ['label' => name, 'value' => term_id] entries. |
| 284 |
*/ |
| 285 |
public function wpstream_generate_woo_movie_category_values_shortcode(){ |
| 286 |
return $this->generate_term_options( 'wpstream_category', 'wpstream_woo_movie_category_values' ); |
| 287 |
} |
| 288 |
|
| 289 |
/** |
| 290 |
* Build (and cache for 4 hours) the wpstream_actors term list for shortcodes. |
| 291 |
* |
| 292 |
* @return array List of ['label' => name, 'value' => term_id] entries. |
| 293 |
*/ |
| 294 |
public function wpstream_generate_actors_category_values_shortcode(){ |
| 295 |
return $this->generate_term_options( 'wpstream_actors', 'wpstream_woo_actors_category_values' ); |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
/** |
| 300 |
* Build (and cache for 4 hours) the WooCommerce product_cat term list for shortcodes. |
| 301 |
* |
| 302 |
* @return array List of ['label' => name, 'value' => term_id] entries. |
| 303 |
*/ |
| 304 |
public function wpstream_generate_woo_product_tax_values_shortcode(){ |
| 305 |
return $this->generate_term_options( 'product_cat', 'wpstream_woo_product_cat' ); |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
/** |
| 310 |
* Build (and cache for 4 hours) the wpstream_movie_rating term list for shortcodes. |
| 311 |
* |
| 312 |
* @return array List of ['label' => name, 'value' => term_id] entries. |
| 313 |
*/ |
| 314 |
public function wpstream_generate_movie_rating_category_values_shortcode(){ |
| 315 |
return $this->generate_term_options( 'wpstream_movie_rating', 'wpstream_woo_movie_rating_category_values' ); |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
/** |
| 322 |
* Register taxonomy custom post type |
| 323 |
* |
| 324 |
* @link https://codex.wordpress.org/Function_Reference/register_taxonomy |
| 325 |
* |
| 326 |
* @param array $tax_fields Taxonomy definition (taxonomy, single/plural, post_types, rewrite, ...). |
| 327 |
*/ |
| 328 |
|
| 329 |
private function register_single_post_type_taxnonomy( $tax_fields ) { |
| 330 |
|
| 331 |
// Build the taxonomy admin labels from its single/plural names. |
| 332 |
$labels = array( |
| 333 |
'name' => $tax_fields['plural'], |
| 334 |
'singular_name' => $tax_fields['single'], |
| 335 |
'menu_name' => $tax_fields['plural'], |
| 336 |
'all_items' => sprintf( __( 'All %s' , 'wpstream' ), $tax_fields['plural'] ), |
| 337 |
'edit_item' => sprintf( __( 'Edit %s' , 'wpstream' ), $tax_fields['single'] ), |
| 338 |
'view_item' => sprintf( __( 'View %s' , 'wpstream' ), $tax_fields['single'] ), |
| 339 |
'update_item' => sprintf( __( 'Update %s' , 'wpstream' ), $tax_fields['single'] ), |
| 340 |
'add_new_item' => sprintf( __( 'Add New %s' , 'wpstream' ), $tax_fields['single'] ), |
| 341 |
'new_item_name' => sprintf( __( 'New %s Name' , 'wpstream' ), $tax_fields['single'] ), |
| 342 |
'parent_item' => sprintf( __( 'Parent %s' , 'wpstream' ), $tax_fields['single'] ), |
| 343 |
'parent_item_colon' => sprintf( __( 'Parent %s:' , 'wpstream' ), $tax_fields['single'] ), |
| 344 |
'search_items' => sprintf( __( 'Search %s' , 'wpstream' ), $tax_fields['plural'] ), |
| 345 |
'popular_items' => sprintf( __( 'Popular %s' , 'wpstream' ), $tax_fields['plural'] ), |
| 346 |
'separate_items_with_commas' => sprintf( __( 'Separate %s with commas' , 'wpstream' ), $tax_fields['plural'] ), |
| 347 |
'add_or_remove_items' => sprintf( __( 'Add or remove %s' , 'wpstream' ), $tax_fields['plural'] ), |
| 348 |
'choose_from_most_used' => sprintf( __( 'Choose from the most used %s' , 'wpstream' ), $tax_fields['plural'] ), |
| 349 |
'not_found' => sprintf( __( 'No %s found' , 'wpstream' ), $tax_fields['plural'] ), |
| 350 |
); |
| 351 |
|
| 352 |
// Assemble register_taxonomy() args, defaulting anything the definition omits. |
| 353 |
$args = array( |
| 354 |
'label' => $tax_fields['plural'], |
| 355 |
'labels' => $labels, |
| 356 |
'hierarchical' => ( isset( $tax_fields['hierarchical'] ) ) ? $tax_fields['hierarchical'] : true, |
| 357 |
'public' => ( isset( $tax_fields['public'] ) ) ? $tax_fields['public'] : true, |
| 358 |
'show_ui' => ( isset( $tax_fields['show_ui'] ) ) ? $tax_fields['show_ui'] : true, |
| 359 |
'show_in_nav_menus' => ( isset( $tax_fields['show_in_nav_menus'] ) ) ? $tax_fields['show_in_nav_menus'] : true, |
| 360 |
'show_tagcloud' => ( isset( $tax_fields['show_tagcloud'] ) ) ? $tax_fields['show_tagcloud'] : true, |
| 361 |
'meta_box_cb' => ( isset( $tax_fields['meta_box_cb'] ) ) ? $tax_fields['meta_box_cb'] : null, |
| 362 |
'show_admin_column' => ( isset( $tax_fields['show_admin_column'] ) ) ? $tax_fields['show_admin_column'] : true, |
| 363 |
'show_in_quick_edit' => ( isset( $tax_fields['show_in_quick_edit'] ) ) ? $tax_fields['show_in_quick_edit'] : true, |
| 364 |
'update_count_callback' => ( isset( $tax_fields['update_count_callback'] ) ) ? $tax_fields['update_count_callback'] : '', |
| 365 |
'show_in_rest' => ( isset( $tax_fields['show_in_rest'] ) ) ? $tax_fields['show_in_rest'] : true, |
| 366 |
'rest_base' => $tax_fields['taxonomy'], |
| 367 |
'rest_controller_class' => ( isset( $tax_fields['rest_controller_class'] ) ) ? $tax_fields['rest_controller_class'] : 'WP_REST_Terms_Controller', |
| 368 |
'query_var' => $tax_fields['taxonomy'], |
| 369 |
'rewrite' => ( isset( $tax_fields['rewrite'] ) ) ? $tax_fields['rewrite'] : true, |
| 370 |
'sort' => ( isset( $tax_fields['sort'] ) ) ? $tax_fields['sort'] : '', |
| 371 |
); |
| 372 |
|
| 373 |
// Let integrators tweak the args via a per-taxonomy filter before registration. |
| 374 |
$args = apply_filters( $tax_fields['taxonomy'] . '_args', $args ); |
| 375 |
|
| 376 |
/** |
| 377 |
* Filter the registration arguments of one plugin taxonomy. |
| 378 |
* |
| 379 |
* The static counterpart of the dynamic `{$taxonomy}_args` filter above. |
| 380 |
* |
| 381 |
* @since 4.14.0 |
| 382 |
* |
| 383 |
* @param array $args register_taxonomy() arguments. |
| 384 |
* @param string $taxonomy Taxonomy slug (`wpstream_category`, `wpstream_actors`, `wpstream_movie_rating`). |
| 385 |
* @param string[] $post_types Post types it is attached to. |
| 386 |
*/ |
| 387 |
$args = apply_filters( 'wpstream_taxonomy_args', $args, $tax_fields['taxonomy'], (array) $tax_fields['post_types'] ); |
| 388 |
|
| 389 |
// Register the taxonomy against its target post types. |
| 390 |
register_taxonomy( $tax_fields['taxonomy'], $tax_fields['post_types'], $args ); |
| 391 |
|
| 392 |
} |
| 393 |
|
| 394 |
/** |
| 395 |
* Assign capabilities to users |
| 396 |
* |
| 397 |
* @link https://codex.wordpress.org/Function_Reference/register_post_type |
| 398 |
* @link https://typerocket.com/ultimate-guide-to-custom-post-types-in-wordpress/ |
| 399 |
* |
| 400 |
* @param array $caps_map Map of WordPress cap key => custom capability string. |
| 401 |
* @param array $users Role slugs to receive the custom capabilities. |
| 402 |
*/ |
| 403 |
public function assign_capabilities( $caps_map, $users ) { |
| 404 |
|
| 405 |
// Walk each target role. |
| 406 |
foreach ( $users as $user ) { |
| 407 |
|
| 408 |
// Resolve the WP_Role object for this role slug; unknown roles are skipped. |
| 409 |
$user_role = get_role( $user ); |
| 410 |
if ( ! $user_role ) { |
| 411 |
continue; |
| 412 |
} |
| 413 |
|
| 414 |
// Add every mapped custom capability to that role. |
| 415 |
foreach ( $caps_map as $cap_map_key => $capability ) { |
| 416 |
|
| 417 |
$user_role->add_cap( $capability ); |
| 418 |
|
| 419 |
} |
| 420 |
|
| 421 |
} |
| 422 |
|
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* Render the extra term-meta fields on the Edit Term screen. |
| 427 |
* |
| 428 |
* CUSTOMIZE CUSTOM POST TYPE AS YOU WISH. |
| 429 |
* |
| 430 |
* @param object|string $tag Term object being edited (or a string on add screens). |
| 431 |
* @param string $taxonomy Taxonomy slug the term belongs to. |
| 432 |
*/ |
| 433 |
public function wpstream_category_callback_function($tag, $taxonomy){ |
| 434 |
// Editing an existing term: load its saved meta values. |
| 435 |
if(is_object ($tag)){ |
| 436 |
$t_id = $tag->term_id; |
| 437 |
$term_meta = get_option( "taxonomy_$t_id"); |
| 438 |
$pagetax = $term_meta['pagetax'] ? $term_meta['pagetax'] : ''; |
| 439 |
$category_featured_image = $term_meta['category_featured_image'] ? $term_meta['category_featured_image'] : ''; |
| 440 |
$category_tagline = $term_meta['category_tagline'] ? $term_meta['category_tagline'] : ''; |
| 441 |
$category_tagline = stripslashes($category_tagline); |
| 442 |
$category_attach_id = $term_meta['category_attach_id'] ? $term_meta['category_attach_id'] : ''; |
| 443 |
}else{ |
| 444 |
// No term object: start with empty defaults. |
| 445 |
$pagetax = ''; |
| 446 |
$category_featured_image = ''; |
| 447 |
$category_tagline = ''; |
| 448 |
$category_attach_id = ''; |
| 449 |
} |
| 450 |
|
| 451 |
// Output the edit-screen form rows pre-filled with the values above. |
| 452 |
print' |
| 453 |
<table class="form-table"> |
| 454 |
<tbody> |
| 455 |
<tr class="form-field"> |
| 456 |
<th scope="row" valign="top"><label for="term_meta[pagetax]">'.esc_html__( 'Display the content for page id for this term','wpstream').'</label></th> |
| 457 |
<td> |
| 458 |
<input type="text" name="term_meta[pagetax]" class="postform" value="'.$pagetax.'"> |
| 459 |
<p class="description">'.esc_html__( 'Display the content for page id for this term','wpstream').'</p> |
| 460 |
</td> |
| 461 |
|
| 462 |
<tr valign="top"> |
| 463 |
<th scope="row"><label for="category_featured_image">'.esc_html__( 'Featured Image','wpstream').'</label></th> |
| 464 |
<td> |
| 465 |
<input id="category_featured_image" type="text" class="postform wpstream_landing_upload" size="36" name="term_meta[category_featured_image]" value="'.$category_featured_image.'" /> |
| 466 |
<input id="category_featured_image_button" type="button" class="upload_button button category_featured_image_button" value="'.esc_html__( 'Upload Image','wpstream').'" /> |
| 467 |
<input id="category_attach_id" class="wpstream_landing_upload_id" type="hidden" size="36" name="term_meta[category_attach_id]" value="'.$category_attach_id.'" /> |
| 468 |
</td> |
| 469 |
</tr> |
| 470 |
|
| 471 |
<tr valign="top"> |
| 472 |
<th scope="row"><label for="term_meta[category_tagline]">'. esc_html__( 'Category Tagline','wpstream').'</label></th> |
| 473 |
<td> |
| 474 |
<input id="category_tagline" type="text" size="36" name="term_meta[category_tagline]" value="'.$category_tagline.'" /> |
| 475 |
</td> |
| 476 |
</tr> |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
<input id="category_tax" type="hidden" size="36" name="term_meta[category_tax]" value="'.$taxonomy.'" /> |
| 481 |
|
| 482 |
|
| 483 |
</tr> |
| 484 |
</tbody> |
| 485 |
</table>'; |
| 486 |
} |
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
/** |
| 494 |
* Render the extra term-meta fields on the Add New Term screen. |
| 495 |
* |
| 496 |
* CUSTOMIZE CUSTOM POST TYPE AS YOU WISH. |
| 497 |
* |
| 498 |
* @param object|string $tag Term object, or (on the add screen) the taxonomy string. |
| 499 |
*/ |
| 500 |
public function wpstream_category_callback_add_function($tag){ |
| 501 |
// Editing an existing term: load its saved meta values. |
| 502 |
if(is_object ($tag)){ |
| 503 |
$t_id = $tag->term_id; |
| 504 |
$term_meta = get_option( "taxonomy_$t_id"); |
| 505 |
$pagetax = $term_meta['pagetax'] ? $term_meta['pagetax'] : ''; |
| 506 |
$category_featured_image = $term_meta['category_featured_image'] ? $term_meta['category_featured_image'] : ''; |
| 507 |
$category_tagline = $term_meta['category_tagline'] ? $term_meta['category_tagline'] : ''; |
| 508 |
$category_attach_id = $term_meta['category_attach_id'] ? $term_meta['category_attach_id'] : ''; |
| 509 |
}else{ |
| 510 |
// Add screen (no term yet): start with empty defaults. |
| 511 |
$pagetax = ''; |
| 512 |
$category_featured_image = ''; |
| 513 |
$category_tagline = ''; |
| 514 |
$category_attach_id = ''; |
| 515 |
|
| 516 |
} |
| 517 |
|
| 518 |
// Output the add-screen form fields pre-filled with the values above. |
| 519 |
print' |
| 520 |
<div class="form-field"> |
| 521 |
<label for="term_meta[pagetax]">'. esc_html__( 'Page id for this term','wpstream').'</label> |
| 522 |
<input type="text" name="term_meta[pagetax]" class="postform" value="'.$pagetax.'"> |
| 523 |
</div> |
| 524 |
|
| 525 |
<div class="form-field"> |
| 526 |
<label for="term_meta[pagetax]">'. esc_html__( 'Featured Image','wpstream').'</label> |
| 527 |
<input id="category_featured_image" class="wpstream_landing_upload" type="text" size="36" name="term_meta[category_featured_image]" value="'.$category_featured_image.'" /> |
| 528 |
<input id="category_featured_image_button" type="button" class="upload_button button category_featured_image_button" value="'.esc_html__( 'Upload Image','wpstream').'" /> |
| 529 |
<input id="category_attach_id" type="hidden" class="wpstream_landing_upload_id" size="36" name="term_meta[category_attach_id]" value="'.$category_attach_id.'" /> |
| 530 |
|
| 531 |
</div> |
| 532 |
|
| 533 |
<div class="form-field"> |
| 534 |
<label for="term_meta[category_tagline]">'. esc_html__( 'Category Tagline','wpstream').'</label> |
| 535 |
<input id="category_tagline" type="text" size="36" name="term_meta[category_tagline]" value="'.$category_tagline.'" /> |
| 536 |
</div> |
| 537 |
<input id="category_tax" type="hidden" size="36" name="term_meta[category_tax]" value="'.$tag.'" /> |
| 538 |
'; |
| 539 |
} |
| 540 |
|
| 541 |
/** |
| 542 |
* Persist the extra term-meta fields when a term is created or updated. |
| 543 |
* |
| 544 |
* CUSTOMIZE CUSTOM POST TYPE AS YOU WISH. |
| 545 |
* |
| 546 |
* @param int $term_id ID of the term being saved. |
| 547 |
*/ |
| 548 |
function wpstream_category_save_extra_fields_callback($term_id ){ |
| 549 |
// Only act when the edit/add form actually submitted term_meta data. |
| 550 |
if ( isset( $_POST['term_meta'] ) ) { |
| 551 |
// Load any existing meta so unsubmitted keys are preserved. |
| 552 |
$t_id = $term_id; |
| 553 |
$term_meta = get_option( "taxonomy_$t_id"); |
| 554 |
$cat_keys = array_keys($_POST['term_meta']); |
| 555 |
// Empty allowed-HTML list: values are stripped of all markup. |
| 556 |
$allowed_html = array(); |
| 557 |
// Sanitize each submitted key/value before storing it. |
| 558 |
foreach ($cat_keys as $key){ |
| 559 |
$key=sanitize_key($key); |
| 560 |
if (isset($_POST['term_meta'][$key])){ |
| 561 |
$term_meta[$key] = wp_kses( $_POST['term_meta'][$key],$allowed_html); |
| 562 |
} |
| 563 |
} |
| 564 |
//save the option array |
| 565 |
update_option( "taxonomy_$t_id", $term_meta ); |
| 566 |
} |
| 567 |
} |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
/** |
| 575 |
* Create post types |
| 576 |
*/ |
| 577 |
public function create_custom_post_type() { |
| 578 |
|
| 579 |
/** |
| 580 |
* This is not all the fields, only what I find important. Feel free to change this function ;) |
| 581 |
* |
| 582 |
* @link https://codex.wordpress.org/Function_Reference/register_post_type |
| 583 |
* |
| 584 |
* For more info on fields: |
| 585 |
* @link https://github.com/JoeSz/WordPress-Plugin-Boilerplate-Tutorial/blob/9fb56794bc1f8aebfe04e99b15881db0c4bc61bd/wpstream/includes/class-wpstream-post_types.php#L230 |
| 586 |
*/ |
| 587 |
|
| 588 |
|
| 589 |
// Live-channel permalink base: admin-configured slug, or 'wpstream' when unset. |
| 590 |
$custom_slug = esc_html( get_option('wpstream_free_media_slug','') ); |
| 591 |
if($custom_slug==''){ |
| 592 |
$custom_slug='wpstream'; |
| 593 |
} |
| 594 |
|
| 595 |
// VOD permalink base: admin-configured slug, or 'wpstream_vod' when unset. |
| 596 |
$custom_slug_vod = esc_html( get_option('wpstream_free_media_slug_vod','') ); |
| 597 |
if($custom_slug_vod==''){ |
| 598 |
$custom_slug_vod='wpstream_vod'; |
| 599 |
} |
| 600 |
|
| 601 |
|
| 602 |
// First post type: Free-To-View Live Channel, with its three shared taxonomies. |
| 603 |
$post_types_fields = array( |
| 604 |
array( |
| 605 |
'slug' => 'wpstream_product', |
| 606 |
'singular' => __( 'Free-To-View Live Channel','wpstream'), |
| 607 |
'plural' => __( 'Free-To-View Live Channels','wpstream'), |
| 608 |
'menu_name' => __( 'Free-To-View Live Channels','wpstream'), |
| 609 |
'description' => __( 'Free-To-View Live Channels','wpstream'), |
| 610 |
'has_archive' => true, |
| 611 |
'hierarchical' => false, |
| 612 |
'menu_icon' => WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png', |
| 613 |
'rewrite' => array( |
| 614 |
'slug' => $custom_slug, |
| 615 |
'with_front' => true, |
| 616 |
'pages' => true, |
| 617 |
'feeds' => true, |
| 618 |
'ep_mask' => EP_PERMALINK, |
| 619 |
), |
| 620 |
'menu_position' => 20, |
| 621 |
'public' => true, |
| 622 |
'publicly_queryable' => true, |
| 623 |
'show_in_rest' => true, |
| 624 |
'exclude_from_search' => false, |
| 625 |
'show_ui' => true, |
| 626 |
'show_in_menu' => true, |
| 627 |
'query_var' => true, |
| 628 |
'show_in_admin_bar' => true, |
| 629 |
'show_in_nav_menus' => true, |
| 630 |
'supports' => array( |
| 631 |
'title', |
| 632 |
'editor', |
| 633 |
'excerpt', |
| 634 |
'thumbnail', |
| 635 |
'comments', |
| 636 |
|
| 637 |
), |
| 638 |
'custom_caps' => true, |
| 639 |
'custom_caps_users' => array( |
| 640 |
'administrator', |
| 641 |
), |
| 642 |
'taxonomies' => array( |
| 643 |
|
| 644 |
|
| 645 |
array( |
| 646 |
'taxonomy' => 'wpstream_actors', |
| 647 |
'plural' => esc_html__('Actors','wpstream'), |
| 648 |
'single' => esc_html__('Actor','wpstream'), |
| 649 |
'post_types' => array('wpstream_product','product','wpstream_product_vod','wpstream_bundles'), |
| 650 |
'hierarchical' => true, |
| 651 |
'query_var' => true, |
| 652 |
'rewrite' => array( 'slug' => 'actors' ) |
| 653 |
), |
| 654 |
|
| 655 |
array( |
| 656 |
'taxonomy' => 'wpstream_category', |
| 657 |
'plural' => esc_html__('Media Categories','wpstream'), |
| 658 |
'single' => esc_html__('Media Category','wpstream'), |
| 659 |
'post_types' => array('wpstream_product','product','wpstream_product_vod','wpstream_bundles'), |
| 660 |
'hierarchical' => true, |
| 661 |
'query_var' => true, |
| 662 |
'rewrite' => array( 'slug' => 'media_category' ) |
| 663 |
), |
| 664 |
|
| 665 |
array( |
| 666 |
'taxonomy' => 'wpstream_movie_rating', |
| 667 |
'plural' => esc_html__('Movie Ratings','wpstream'), |
| 668 |
'single' => esc_html__('Movie Rating','wpstream'), |
| 669 |
'post_types' => array('wpstream_product','product','wpstream_product_vod','wpstream_bundles'), |
| 670 |
'hierarchical' => true, |
| 671 |
'query_var' => true, |
| 672 |
'rewrite' => array( 'slug' => 'rating' ) |
| 673 |
), |
| 674 |
|
| 675 |
), |
| 676 |
), |
| 677 |
); |
| 678 |
|
| 679 |
|
| 680 |
// Second post type: Free-To-View VOD (reuses the taxonomies registered above). |
| 681 |
$post_types_fields[] = array( |
| 682 |
|
| 683 |
'slug' => 'wpstream_product_vod', |
| 684 |
'singular' => __( 'Free-To-View VOD','wpstream'), |
| 685 |
'plural' => __( 'Free-To-View VODs','wpstream'), |
| 686 |
'menu_name' => __( 'Free-To-View VODs','wpstream'), |
| 687 |
'description' => __( 'Free-To-View VODs','wpstream'), |
| 688 |
'has_archive' => true, |
| 689 |
'hierarchical' => false, |
| 690 |
'menu_icon' => WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png', |
| 691 |
'rewrite' => array( |
| 692 |
'slug' => $custom_slug_vod, |
| 693 |
'with_front' => true, |
| 694 |
'pages' => true, |
| 695 |
'feeds' => true, |
| 696 |
'ep_mask' => EP_PERMALINK, |
| 697 |
), |
| 698 |
'menu_position' => 20, |
| 699 |
'public' => true, |
| 700 |
'publicly_queryable' => true, |
| 701 |
'show_in_rest' => true, |
| 702 |
'exclude_from_search' => false, |
| 703 |
'show_ui' => true, |
| 704 |
'show_in_menu' => true, |
| 705 |
'query_var' => true, |
| 706 |
'show_in_admin_bar' => true, |
| 707 |
'show_in_nav_menus' => true, |
| 708 |
'supports' => array( |
| 709 |
'title', |
| 710 |
'editor', |
| 711 |
'excerpt', |
| 712 |
'thumbnail', |
| 713 |
'comments', |
| 714 |
|
| 715 |
), |
| 716 |
'custom_caps' => true, |
| 717 |
'custom_caps_users' => array( |
| 718 |
'administrator', |
| 719 |
), |
| 720 |
|
| 721 |
); |
| 722 |
|
| 723 |
// Third post type: Video Collection (bundles) — only when the theme customizer helper is present. |
| 724 |
if( function_exists('wpstream_custom_theme_customizer')){ |
| 725 |
$post_types_fields[] = array( |
| 726 |
|
| 727 |
'slug' => 'wpstream_bundles', |
| 728 |
'singular' => __( 'Video Collection','wpstream'), |
| 729 |
'plural' => __( 'Video Collections','wpstream'), |
| 730 |
'menu_name' => __( 'Video Collections','wpstream'), |
| 731 |
'description' => __( 'Video Collections','wpstream'), |
| 732 |
|
| 733 |
'labels' => array( |
| 734 |
'name' => esc_html__( 'Video Collections', 'wpstream' ), |
| 735 |
'singular_name' => esc_html__( 'Video Collection', 'wpstream' ), |
| 736 |
'add_new' => esc_html__( 'Add New Video Collection', 'wpstream' ), |
| 737 |
'add_new_item' => esc_html__( 'Add Video Collection', 'wpstream' ), |
| 738 |
'edit' => esc_html__( 'Edit', 'wpstream' ), |
| 739 |
'edit_item' => esc_html__( 'Edit Video Collection', 'wpstream' ), |
| 740 |
'new_item' => esc_html__( 'New Video Collection', 'wpstream' ), |
| 741 |
'view' => esc_html__( 'View', 'wpstream' ), |
| 742 |
'view_item' => esc_html__( 'View Video Collection', 'wpstream' ), |
| 743 |
'search_items' => esc_html__( 'Search Video Collection By Name or ID', 'wpstream' ), |
| 744 |
'not_found' => esc_html__( 'No Video Collection found', 'wpstream' ), |
| 745 |
'not_found_in_trash' => esc_html__( 'No Video Collection found in Trash', 'wpstream' ), |
| 746 |
'parent' => esc_html__( 'Parent Video Collection', 'wpstream' ), |
| 747 |
'featured_image' => esc_html__( 'Featured Image', 'wpstream' ), |
| 748 |
'set_featured_image' => esc_html__( 'Set Featured Image', 'wpstream' ), |
| 749 |
'remove_featured_image' => esc_html__( 'Remove Featured Image', 'wpstream' ), |
| 750 |
'use_featured_image' => esc_html__( 'Use Featured Image', 'wpstream' ), |
| 751 |
), |
| 752 |
|
| 753 |
'has_archive' => true, |
| 754 |
'hierarchical' => false, |
| 755 |
'menu_icon' => WPSTREAM_PLUGIN_DIR_URL.'img/wpstream-icon-menu_2.png', |
| 756 |
'rewrite' => array( 'slug' => 'wpstream_bundles' ), |
| 757 |
'menu_position' => 20, |
| 758 |
'public' => true, |
| 759 |
'publicly_queryable' => true, |
| 760 |
'show_in_rest' => true, |
| 761 |
'exclude_from_search' => false, |
| 762 |
'show_ui' => true, |
| 763 |
'show_in_menu' => true, |
| 764 |
'query_var' => true, |
| 765 |
'show_in_admin_bar' => true, |
| 766 |
'show_in_nav_menus' => true, |
| 767 |
'supports' => array( |
| 768 |
'title', |
| 769 |
'editor', |
| 770 |
'excerpt', |
| 771 |
'thumbnail', |
| 772 |
'comments', |
| 773 |
|
| 774 |
), |
| 775 |
'custom_caps' => true, |
| 776 |
'custom_caps_users' => array( |
| 777 |
'administrator', |
| 778 |
), |
| 779 |
|
| 780 |
); |
| 781 |
} |
| 782 |
|
| 783 |
|
| 784 |
/** |
| 785 |
* Filter the list of post type definitions the plugin registers. |
| 786 |
* |
| 787 |
* Each definition needs `slug`, `singular`, `plural` and `menu_name`; |
| 788 |
* every other key is optional and defaults as in register_single_post_type(). |
| 789 |
* Adding a definition registers it through the same path (labels, |
| 790 |
* capabilities, taxonomies). |
| 791 |
* |
| 792 |
* @since 4.14.0 |
| 793 |
* |
| 794 |
* @param array[] $definitions Post type definitions. |
| 795 |
*/ |
| 796 |
$post_types_fields = (array) apply_filters( 'wpstream_post_type_definitions', $post_types_fields ); |
| 797 |
|
| 798 |
// loop torugh custom post type array and register |
| 799 |
foreach ( $post_types_fields as $fields ) { |
| 800 |
if ( ! isset( $fields['slug'], $fields['singular'], $fields['plural'], $fields['menu_name'] ) ) { |
| 801 |
continue; |
| 802 |
} |
| 803 |
$this->register_single_post_type( $fields ); |
| 804 |
} |
| 805 |
|
| 806 |
// One-time 5.0 data migration: run once until the flag option is set. |
| 807 |
if( get_option('wpstream_updated_50')!=='yes' ){ |
| 808 |
$this->wpstream_50_post_update(); |
| 809 |
} |
| 810 |
|
| 811 |
|
| 812 |
} |
| 813 |
|
| 814 |
|
| 815 |
/** |
| 816 |
* One-time 5.0 migration: move VOD-typed legacy posts to the wpstream_product_vod type. |
| 817 |
*/ |
| 818 |
public function wpstream_50_post_update(){ |
| 819 |
// Query every legacy wpstream_product post regardless of status. |
| 820 |
$arg=array( |
| 821 |
'post_type' =>'wpstream_product', |
| 822 |
'post_status' => 'any', |
| 823 |
'posts_per_page'=> -1 |
| 824 |
); |
| 825 |
|
| 826 |
|
| 827 |
$the_query = new WP_Query($arg); |
| 828 |
|
| 829 |
if($the_query->have_posts()){ |
| 830 |
// Inspect each post's stored product type. |
| 831 |
while ( $the_query->have_posts() ) { |
| 832 |
$the_query->the_post(); |
| 833 |
$post_id=get_the_ID(); |
| 834 |
$wpstream_product_type = esc_html(get_post_meta($post_id, 'wpstream_product_type', true)); |
| 835 |
|
| 836 |
// Types 2 and 3 were VOD entries: convert them to the dedicated VOD post type. |
| 837 |
if($wpstream_product_type==2 || $wpstream_product_type==3){ |
| 838 |
// print 'will update '.$post_id.' - '.get_the_title($post_id).'</br>'.PHP_EOL; |
| 839 |
set_post_type( $post_id, 'wpstream_product_vod' ); |
| 840 |
} |
| 841 |
|
| 842 |
} |
| 843 |
// Rewrite rules changed with the moved posts, so flush them. |
| 844 |
global $wp_rewrite; |
| 845 |
$wp_rewrite->flush_rules( true ); |
| 846 |
} |
| 847 |
|
| 848 |
// Mark the migration complete so it never runs again — even when the |
| 849 |
// site had no legacy posts, otherwise the query re-runs on every request. |
| 850 |
update_option('wpstream_updated_50','yes'); |
| 851 |
} |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
/* |
| 857 |
*Remove the custom taxonomy column from the WooCommerce product list |
| 858 |
*/ |
| 859 |
/** |
| 860 |
* Drop the WpStream taxonomy columns from the WooCommerce products admin table. |
| 861 |
* |
| 862 |
* @param array $columns Existing column id => label map. |
| 863 |
* @return array Filtered columns without the WpStream taxonomy columns. |
| 864 |
*/ |
| 865 |
function remove_wpstream_category_column($columns) { |
| 866 |
// Only strip them when the media-category column is present (WooCommerce product list). |
| 867 |
if (isset($columns['taxonomy-wpstream_category'])) { |
| 868 |
unset($columns['taxonomy-wpstream_category']); |
| 869 |
unset($columns['taxonomy-wpstream_actors']); |
| 870 |
unset($columns['taxonomy-wpstream_movie_rating']); |
| 871 |
} |
| 872 |
return $columns; |
| 873 |
} |
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
} |
| 879 |
|