Last active
May 6, 2020 21:44
-
-
Save mikeschinkel/faaee3fc8ccc2371c7200f3d634289c4 to your computer and use it in GitHub Desktop.
Examples showing a huge array literal vs. many small array literals
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 | |
class MembershipForm { | |
static function form() { | |
return array( | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'License Type ID' ), | |
'param_name' => 'license_type', | |
'description' => esc_attr__( 'Enter License Type ID', 'wds-vc-elements' ), | |
), | |
array( | |
'type' => 'dropdown', | |
'heading' => __( 'Card Type' ), | |
'param_name' => 'card_type', | |
'value' => array( | |
'Select a card type' => '', | |
'Appraisal' => 'Appraisal', | |
'Real Estate' => 'Real Estate', | |
), | |
), | |
array( | |
'type' => 'dropdown', | |
'heading' => __( 'Education Type' ), | |
'param_name' => 'edu_type', | |
'value' => array( | |
'Select an education type' => '', | |
'Continuing Education' => 'CE', | |
'Qualifying Education' => 'QE', | |
), | |
), | |
array( | |
'type' => 'dropdown', | |
'heading' => __( 'Visual Style' ), | |
'param_name' => 'visual_style', | |
'value' => array( | |
'Select a card visual style' => '', | |
'Minimalist' => 'minimalist-card', | |
'Modern' => 'modern-card', | |
), | |
), | |
array( | |
'type' => 'checkbox', | |
'heading' => __( 'Overlapping the header?', 'wds-vc-elements' ), | |
'param_name' => 'header_overlap', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Cards Title', 'wds-vc-elements' ), | |
'param_name' => 'cards_title', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Title Color', 'wds-vc-elements' ), | |
'param_name' => 'cards_title_color', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Cards Sub Heading', 'wds-vc-elements' ), | |
'param_name' => 'cards_sub_heading', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Sub Heading Color', 'wds-vc-elements' ), | |
'param_name' => 'cards_subhead_color', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( "<hr><h2 style='text-align:center;'>Dynamic Card Setting</h2>Cards Title Text Color" ), | |
'param_name' => 'card_color', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Title Background Color', 'wds-vc-elements' ), | |
'param_name' => 'card_bgcolor', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Background Color', 'wds-vc-elements' ), | |
'param_name' => 'card_bg', | |
), | |
array( | |
'type' => 'textarea', | |
'heading' => __( 'Cards Description', 'wds-vc-elements' ), | |
'param_name' => 'cards_desc', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Dynamic', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_dynamic', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'No membership option text', 'wds-vc-elements' ), | |
'param_name' => 'no_membership', | |
), | |
array( | |
'type' => 'param_group', | |
'value' => '', | |
'param_name' => 'cards_group', | |
'group' => 'Dynamic Card items', | |
'params' => array( | |
array( | |
'type' => 'textarea', | |
'heading' => __( 'Text to display for this offering (html tags are supported)', 'wds-vc-elements' ), | |
'param_name' => 'offering_text', | |
), | |
), | |
), | |
array( | |
'type' => 'param_group', | |
'value' => '', | |
'param_name' => 'default_cards_group', | |
'group' => 'Static Cards (no state selected)', | |
'params' => array( | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Title', 'wds-vc-elements' ), | |
'param_name' => 'card_title', | |
), | |
array( | |
'type' => 'checkbox', | |
'heading' => __( 'Is Multi-State', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Check only if this membership applies to all states.', 'wds-vc-elements' ), | |
'param_name' => 'is_multi', | |
), | |
array( | |
'type' => 'checkbox', | |
'heading' => __( 'Is Dual CTA', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'The license type must contain two individual memberships as returned by StudentAPI.', 'wds-vc-elements' ), | |
'param_name' => 'is_dualcta', | |
), | |
array( | |
'type' => 'checkbox', | |
'heading' => __( 'Has Static Header and Description', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Override the dynamic header and description with the static fields below.', 'wds-vc-elements' ), | |
'param_name' => 'is_static', | |
), | |
array( | |
'type' => 'checkbox', | |
'heading' => __( 'Comparison Card', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Adds an informational card next to the purchase card.', 'wds-vc-elements' ), | |
'param_name' => 'is_comparison', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Title Color', 'wds-vc-elements' ), | |
'param_name' => 'card_title_color', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Title Background Color' ), | |
'param_name' => 'card_title_bg_color', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Section Background Color' ), | |
'param_name' => 'card_section_bg_color', | |
), | |
array( | |
'type' => 'textarea', | |
'heading' => __( 'Card Points Intro', 'wds-vc-elements' ), | |
'param_name' => 'card_points_intro', | |
), | |
array( | |
'type' => 'textarea', | |
'heading' => __( 'Card Points (Use html list for each line)', 'wds-vc-elements' ), | |
'param_name' => 'card_points', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Savings Ribbon', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the card.', 'wds-vc-elements' ), | |
'param_name' => 'card_savings_ribbon', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price', 'wds-vc-elements' ), | |
'param_name' => 'card_price', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Suffix', 'wds-vc-elements' ), | |
'param_name' => 'card_price_suffix', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Savings Ribbon', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the first year selector.', 'wds-vc-elements' ), | |
'param_name' => 'card_price_savings_ribbon', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'card_price_2', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Suffix (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'card_price_suffix_2', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Savings Ribbon (2nd year)', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the second year selector.', 'wds-vc-elements' ), | |
'param_name' => 'card_price_savings_ribbon_2', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Line', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_line', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Line (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_line_2', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Button Title Select', 'wds-vc-elements' ), | |
'param_name' => 'button_title_select', | |
), | |
array( | |
'type' => 'textfield', | |
'heading' => __( 'Button Title Checkout', 'wds-vc-elements' ), | |
'param_name' => 'button_title_checkout', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Button Title Color', 'wds-vc-elements' ), | |
'param_name' => 'button_title_color', | |
), | |
array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Button Background Color', 'wds-vc-elements' ), | |
'param_name' => 'button_bg_color', | |
), | |
), | |
), | |
); | |
} | |
} |
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 | |
abstract class Form { | |
private $_fields = array(); | |
function add_field( array $field ) { | |
self::$_fields[] = $field; | |
} | |
function fields(): array { | |
return $this->_fields; | |
} | |
} | |
class MembershipForm extends Form { | |
static function form() { | |
$form = new static(); | |
$form->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'License Type ID' ), | |
'param_name' => 'license_type', | |
'description' => esc_attr__( 'Enter License Type ID', 'wds-vc-elements' ), | |
) ); | |
$form->add_field( array( | |
'type' => 'dropdown', | |
'heading' => __( 'Card Type' ), | |
'param_name' => 'card_type', | |
'value' => array( | |
'Select a card type' => '', | |
'Appraisal' => 'Appraisal', | |
'Real Estate' => 'Real Estate', | |
), | |
) ); | |
$form->add_field( array( | |
'type' => 'dropdown', | |
'heading' => __( 'Education Type' ), | |
'param_name' => 'edu_type', | |
'value' => array( | |
'Select an education type' => '', | |
'Continuing Education' => 'CE', | |
'Qualifying Education' => 'QE', | |
), | |
) ); | |
$form->add_field( array( | |
'type' => 'dropdown', | |
'heading' => __( 'Visual Style' ), | |
'param_name' => 'visual_style', | |
'value' => array( | |
'Select a card visual style' => '', | |
'Minimalist' => 'minimalist-card', | |
'Modern' => 'modern-card', | |
), | |
) ); | |
$form->add_field( array( | |
'type' => 'checkbox', | |
'heading' => __( 'Overlapping the header?', 'wds-vc-elements' ), | |
'param_name' => 'header_overlap', | |
) ); | |
$form->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Cards Title', 'wds-vc-elements' ), | |
'param_name' => 'cards_title', | |
) ); | |
$form->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Title Color', 'wds-vc-elements' ), | |
'param_name' => 'cards_title_color', | |
) ); | |
$form->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Cards Sub Heading', 'wds-vc-elements' ), | |
'param_name' => 'cards_sub_heading', | |
) ); | |
$form->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Sub Heading Color', 'wds-vc-elements' ), | |
'param_name' => 'cards_subhead_color', | |
) ); | |
$form->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( "<hr><h2 style='text-align:center;'>Dynamic Card Setting</h2>Cards Title Text Color" ), | |
'param_name' => 'card_color', | |
) ); | |
$form->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Title Background Color', 'wds-vc-elements' ), | |
'param_name' => 'card_bgcolor', | |
) ); | |
$form->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Cards Background Color', 'wds-vc-elements' ), | |
'param_name' => 'card_bg', | |
) ); | |
$form->add_field( array( | |
'type' => 'textarea', | |
'heading' => __( 'Cards Description', 'wds-vc-elements' ), | |
'param_name' => 'cards_desc', | |
) ); | |
$form->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Dynamic', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_dynamic', | |
) ); | |
$form->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'No membership option text', 'wds-vc-elements' ), | |
'param_name' => 'no_membership', | |
) ); | |
$form->add_field( array( | |
'type' => 'param_group', | |
'value' => '', | |
'param_name' => 'cards_group', | |
'group' => 'Dynamic Card items', | |
'params' => array( | |
array( | |
'type' => 'textarea', | |
'heading' => __( 'Text to display for this offering (html tags are supported)', 'wds-vc-elements' ), | |
'param_name' => 'offering_text', | |
), | |
), | |
) ); | |
$subform = new static(); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Title', 'wds-vc-elements' ), | |
'param_name' => 'card_title', | |
) ); | |
$subform->add_field( array( | |
'type' => 'checkbox', | |
'heading' => __( 'Is Multi-State', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Check only if this membership applies to all states.', 'wds-vc-elements' ), | |
'param_name' => 'is_multi', | |
) ); | |
$subform->add_field( array( | |
'type' => 'checkbox', | |
'heading' => __( 'Is Dual CTA', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'The license type must contain two individual memberships as returned by StudentAPI.', 'wds-vc-elements' ), | |
'param_name' => 'is_dualcta', | |
) ); | |
$subform->add_field( array( | |
'type' => 'checkbox', | |
'heading' => __( 'Has Static Header and Description', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Override the dynamic header and description with the static fields below.', 'wds-vc-elements' ), | |
'param_name' => 'is_static', | |
) ); | |
$subform->add_field( array( | |
'type' => 'checkbox', | |
'heading' => __( 'Comparison Card', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'Adds an informational card next to the purchase card.', 'wds-vc-elements' ), | |
'param_name' => 'is_comparison', | |
) ); | |
$subform->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Title Color', 'wds-vc-elements' ), | |
'param_name' => 'card_title_color', | |
) ); | |
$subform->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Title Background Color' ), | |
'param_name' => 'card_title_bg_color', | |
) ); | |
$subform->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Card Section Background Color' ), | |
'param_name' => 'card_section_bg_color', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textarea', | |
'heading' => __( 'Card Points Intro', 'wds-vc-elements' ), | |
'param_name' => 'card_points_intro', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textarea', | |
'heading' => __( 'Card Points (Use html list for each line)', 'wds-vc-elements' ), | |
'param_name' => 'card_points', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Savings Ribbon', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the card.', 'wds-vc-elements' ), | |
'param_name' => 'card_savings_ribbon', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price', 'wds-vc-elements' ), | |
'param_name' => 'card_price', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Suffix', 'wds-vc-elements' ), | |
'param_name' => 'card_price_suffix', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Savings Ribbon', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the first year selector.', 'wds-vc-elements' ), | |
'param_name' => 'card_price_savings_ribbon', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'card_price_2', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Suffix (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'card_price_suffix_2', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Card Price Savings Ribbon (2nd year)', 'wds-vc-elements' ), | |
'description' => esc_attr__( 'This savings ribbon appears at the top of the second year selector.', 'wds-vc-elements' ), | |
'param_name' => 'card_price_savings_ribbon_2', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Line', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_line', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Price Tag Line (2nd year)', 'wds-vc-elements' ), | |
'param_name' => 'price_tag_line_2', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Button Title Select', 'wds-vc-elements' ), | |
'param_name' => 'button_title_select', | |
) ); | |
$subform->add_field( array( | |
'type' => 'textfield', | |
'heading' => __( 'Button Title Checkout', 'wds-vc-elements' ), | |
'param_name' => 'button_title_checkout', | |
) ); | |
$subform->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Button Title Color', 'wds-vc-elements' ), | |
'param_name' => 'button_title_color', | |
) ); | |
$subform->add_field( array( | |
'type' => 'hex_color_picker', | |
'heading' => __( 'Button Background Color', 'wds-vc-elements' ), | |
'param_name' => 'button_bg_color', | |
) ); | |
$form->add_field( array( | |
'type' => 'param_group', | |
'value' => '', | |
'param_name' => 'default_cards_group', | |
'group' => 'Static Cards (no state selected)', | |
'params' => $subform->fields(), | |
) ); | |
return $form->fields(); | |
} | |
} xxxxx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment