Created
April 16, 2013 01:49
-
-
Save mshmsh5000/5392736 to your computer and use it in GitHub Desktop.
Topps_Content_Helper_Data::getCustomFieldsForPostType()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Given a post type as defined in WP (either a native type, or one | |
* defined via Pods), compute custom fields list to request from | |
* WP JSON API. | |
* | |
* @param string $post_type WP/Pods post type, either singular or plural | |
* @return array | |
* @todo Consider externalizing these assignments into a config file. | |
*/ | |
public function getCustomFieldsForPostType( $post_type ) | |
{ | |
$post_info = array(); | |
switch ( $post_type ) | |
{ | |
case 'article': | |
case 'articles': | |
$post_info[ 'fields' ] = array( | |
'css_wrapper_class' => 'raw', | |
'custom_css' => 'raw', | |
'custom_url' => 'raw', | |
'display_read_more' => 'boolean', | |
'display_title' => 'boolean', | |
'read_more_text' => 'raw', | |
'subtitle' => 'raw', | |
); | |
break; | |
case 'contest_article': | |
case 'contest_articles': | |
$post_info[ 'fields' ] = array( | |
'main_image' => 'image_file', | |
'rules_title' => 'raw', | |
'rules_subtitle' => 'raw', | |
'external_link' => 'raw', | |
'cta_text' => 'raw', | |
'additional_information_1' => 'raw', | |
'additional_information_2' => 'raw', | |
'start_date' => 'datetime', | |
'end_date' => 'datetime', | |
'background_image' => 'image_file', | |
'custom_css' => 'raw', | |
); | |
break; | |
case 'design_element': | |
case 'design_elements': | |
$post_info[ 'fields' ] = array( | |
'image_file' => 'image_file', | |
'click_url' => 'raw', | |
); | |
break; | |
case 'homepage': | |
case 'homepages': | |
$post_info[ 'fields' ] = array( | |
'article' => 'post', | |
'curated_images' => array( 'data_type' => 'post', 'post_type' => 'image' ), | |
'custom_css' => 'raw', | |
'gallery_promo' => 'raw', | |
'gallery_title' => 'raw', | |
); | |
break; | |
case 'image': | |
case 'images': | |
$post_info[ 'fields' ] = array( | |
'image_file' => 'image_file', | |
'display_image' => 'image_file', | |
'click_url' => 'raw', | |
); | |
break; | |
case 'subchannel': | |
case 'subchannels': | |
$post_info[ 'fields' ] = array( | |
'article' => 'post', | |
'css_wrapper_id' => 'file', | |
'curated_images' => array( 'data_type' => 'post', 'post_type' => 'image' ), | |
'custom_css' => 'raw', | |
'gallery_promo' => 'raw', | |
'gallery_title' => 'raw', | |
'subchannel_order' => 'int', | |
'wrapper_image' => 'post', | |
); | |
break; | |
case 'video': | |
case 'videos': | |
$post_info[ 'fields' ] = array( | |
'video' => 'raw', | |
'thumbnail' => 'image_file', | |
); | |
break; | |
case 'world': | |
case 'worlds': | |
$post_info[ 'fields' ] = array( | |
'hero' => 'image_file', | |
'image_2' => 'image_file', | |
'image_2_url' => 'raw', | |
'image_3' => 'image_file', | |
'image_3_url' => 'raw', | |
'article' => 'post', | |
'contest_article' => 'post', | |
'idea_generator_section' => 'int', | |
'idea_generator_header' => 'raw', | |
'idea_generator_subhed' => 'raw', | |
'css_file' => 'file', | |
'cta' => 'image_file', | |
); | |
break; | |
case 'wrapper_image': | |
case 'wrapper_images': | |
$post_info[ 'fields' ] = array( | |
'image_file' => 'image_file', | |
'click_url' => 'raw', | |
); | |
break; | |
} | |
if ( !empty( $post_info[ 'fields' ] ) ) | |
{ | |
$post_info[ 'stringified' ] = implode( ',', array_keys( $post_info[ 'fields' ] ) ); | |
} | |
return $post_info; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment