Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.38 KB | None | 0 0
  1. <?php
  2. /* BEGIN METABOXES */
  3.    $meta_boxes[] = array(
  4.       'id'       => 'service_questions',
  5.       'title'    => 'Default service content',
  6.       'pages' => array( 'service_page' ),
  7.       'visible' => array(
  8.         'when' => array(
  9.           array( 'prefix_template_select', '=', 'default_v2' ),
  10.         ),
  11.         'relation'  => 'or'
  12.       ),
  13.       'fields' => array(
  14.         array(
  15.           'type' => 'heading',
  16.           'name'  => 'Who is this service for?',
  17.         ),
  18.         array(
  19.           'id' => 'service_who',
  20.           'type'  => 'wysiwyg',
  21.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  22.         ),
  23.         array(
  24.           'type' => 'heading',
  25.           'name'  => 'What are the requirements for this service?',
  26.         ),
  27.         array(
  28.           'id' => 'service_requirements',
  29.           'type'  => 'wysiwyg',
  30.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  31.         ),
  32.         array(
  33.           'name'  => 'Add prerequisite approvals?',
  34.           'id'  => 'service_accordion_select',
  35.           'type'  => 'switch',
  36.           'on_label'  => 'Yes',
  37.           'off_label' => 'No',
  38.           'columns'   => '6'
  39.           ),
  40.         array(
  41.           'id' => 'accordion_row',
  42.           'type' => 'group',
  43.           'visible' => array(
  44.             'when' => array(
  45.               array('service_accordion_select', '=', true),
  46.             ),
  47.           ),
  48.           'fields' => array(
  49.             array(
  50.               'name' => ('Prerequisite row title'),
  51.               'id'   => 'accordion_row_title',
  52.               'type' => 'text',
  53.               'required' => true,
  54.               'class' => 'percent-100'
  55.             ),
  56.             array(
  57.               'id'   => 'accordion_group',
  58.               'type' => 'group',
  59.               'clone'  => true,
  60.               'sort_clone' => true,
  61.               'add_button' => '+ Add accordion',
  62.               'fields' => array(
  63.                 My_Prefix_Standard_Metaboxes::prefix_metabox_double_wysiwyg($section_name = 'Accordion title', $wysiwyg_desc = 'Accordion content', $columns = 12, $clone = true),
  64.               )
  65.             )
  66.           ),
  67.         ),
  68.         array(
  69.           'type' => 'heading',
  70.           'name'  => 'Where is this located and when is it availble?',
  71.         ),
  72.         array(
  73.           'id' => 'service_where_when',
  74.           'type'  => 'wysiwyg',
  75.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  76.         ),
  77.         array(
  78.           'name'  => 'Include contact information?',
  79.           'id'  => 'service_where_when_address_select',
  80.           'type'  => 'switch',
  81.           'on_label'  => 'Yes',
  82.           'off_label' => 'No'
  83.         ),
  84.         array(
  85.           'id' => 'service_where_when_std_address',
  86.           'type' => 'group',
  87.           'hidden' => array('service_where_when_address_select', false),
  88.  
  89.           'fields' => array(
  90.             My_Prefix_Standard_Metaboxes::prefix_metabox_v2_address_fields(),
  91.             array(
  92.               'id' => 'prefix_connect_general',
  93.               'type' => 'group',
  94.               // List of sub-fields
  95.               'fields' => array(
  96.                 array(
  97.                   'type' => 'heading',
  98.                   'name' => 'Email, fax, etc.',
  99.                 ),
  100.                 array(
  101.                   'name' => 'Email',
  102.                   'id'   => 'prefix_connect_email',
  103.                   'type' => 'email',
  104.                   'desc' => 'example@phila.gov',
  105.                 ),
  106.                 array(
  107.                   'name' => 'Explanation text for email',
  108.                   'id'   => 'prefix_connect_email_exp',
  109.                   'type' => 'text',
  110.                   'desc' => 'Ex. For press inquiries contact:',
  111.                 ),
  112.                 array(
  113.                   'name' => 'Fax',
  114.                   'id'   => 'prefix_connect_fax',
  115.                   'type' => 'phone',
  116.                   'desc' => '(###)-###-####',
  117.                 ),
  118.                 array(
  119.                   'id' => 'prefix_connect_social',
  120.                   'type' => 'group',
  121.                   'fields' => array(
  122.                     array(
  123.                       'type' => 'heading',
  124.                       'name' => 'Social',
  125.                     ),
  126.                     array(
  127.                       'name' => 'Facebook URL',
  128.                       'id'   => 'prefix_connect_social_facebook',
  129.                       'type' => 'url',
  130.                       'desc' => 'Example: https://www.facebook.com/',
  131.                     ),
  132.                     array(
  133.                       'name' => 'Twitter URL',
  134.                       'id'   => 'prefix_connect_social_twitter',
  135.                       'type' => 'url',
  136.                       'desc' => 'Example: https://twitter.com/PhiladelphiaGov'
  137.                     ),
  138.                     array(
  139.                       'name' => 'Instagram URL',
  140.                       'id'   => 'prefix_connect_social_instagram',
  141.                       'type' => 'url',
  142.                       'desc' => 'Example: https://www.instagram.com/'
  143.                     ),
  144.                     array(
  145.                       'name' => 'YouTube URL',
  146.                       'id'   => 'prefix_connect_social_youtube',
  147.                       'type' => 'url',
  148.                       'desc' => 'Example: https://www.youtube.com/user/'
  149.                     ),
  150.                     array(
  151.                       'name' => 'Flickr URL',
  152.                       'id'   => 'prefix_connect_social_flickr',
  153.                       'type' => 'url',
  154.                       'desc' => 'Example: https://www.flickr.com/photos/'
  155.                     ),
  156.                   ),
  157.                 )
  158.               )
  159.             )
  160.           ),
  161.       ),
  162.         array(
  163.           'type' => 'heading',
  164.           'name'  => 'Are there any costs associated with this service?',
  165.         ),
  166.         array(
  167.           'name'  => 'Add cost callout?',
  168.           'id'  => 'service_cost_callout_select',
  169.           'type'  => 'switch',
  170.           'on_label'  => 'Yes',
  171.           'off_label' => 'No'
  172.         ),
  173.         array(
  174.           'id' => 'service_cost_callout',
  175.           'type' => 'group',
  176.           'visible' => array('service_cost_callout_select', true),
  177.           'fields'  => array(
  178.             array(
  179.               'id'  => 'cost_callout',
  180.               'type'  => 'group',
  181.               'clone' => true,
  182.               'max_clone' => 3,
  183.               'fields'  => array(
  184.                 array(
  185.                   'type' => 'text',
  186.                   'id' => 'heading',
  187.                   'name' => 'Cost type',
  188.                   'desc'  => 'E.g. License cost'
  189.                 ),
  190.                 array(
  191.                   'type' => 'number',
  192.                   'id' => 'amount',
  193.                   'name' => 'Cost amount, in dollars',
  194.                   'desc'  => 'E.g. 20.00'
  195.                 ),
  196.                 array(
  197.                   'id' => 'description',
  198.                   'type'  => 'wysiwyg',
  199.                   'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  200.                 ),
  201.               )
  202.             )
  203.           )
  204.         ),
  205.         array(
  206.           'id' => 'service_cost',
  207.           'type'  => 'wysiwyg',
  208.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  209.         ),
  210.         array(
  211.           //Name/id doesn't match because reqirements we not defined before this made it to production
  212.           'name'  => 'Add modal information?',
  213.           'id'  => 'service_payment_info_select',
  214.           'type'  => 'switch',
  215.           'on_label'  => 'Yes',
  216.           'off_label' => 'No'
  217.         ),
  218.         array(
  219.           'visible' => array('service_payment_info_select', true),
  220.           'id'  => 'service_modal_info_link_text',
  221.           'name'  => 'Clickable link text',
  222.           'type'  => 'text',
  223.         ),
  224.         array(
  225.           'visible' => array('service_payment_info_select', true),
  226.           'id' => 'service_payment_info',
  227.           'type'  => 'wysiwyg',
  228.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  229.         ),
  230.         array(
  231.           'type' => 'heading',
  232.           'name'  => 'How can someone get this service?',
  233.         ),
  234.         array(
  235.           'id' => 'service_how',
  236.           'type'  => 'wysiwyg',
  237.           'name'  => 'Use this section for introduction content. Not required.',
  238.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  239.         ),
  240.         array(
  241.           'name'  => 'Add single stepped content?',
  242.           'id'  => 'service_how_stepped_select',
  243.           'type'  => 'switch',
  244.           'on_label'  => 'Yes',
  245.           'off_label' => 'No',
  246.           'columns'   => '6'
  247.         ),
  248.         array(
  249.           'name'  => 'Add mutiple stepped content groups?',
  250.           'id'  => 'service_how_stepped_select_multi',
  251.           'type'  => 'switch',
  252.           'on_label'  => 'Yes',
  253.           'off_label' => 'No',
  254.           'columns'   => '6'
  255.         ),
  256.         array(
  257.           'id' => 'service_how_stepped_content',
  258.           'type' => 'group',
  259.           'visible' => array('service_how_stepped_select', true),
  260.           'fields'  => array(
  261.             array(
  262.               'id' => 'service_how_stepped_content_intro',
  263.               'type'  => 'wysiwyg',
  264.               'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  265.             ),
  266.             My_Prefix_Standard_Metaboxes::prefix_metabox_v2_ordered_content(),
  267.           )
  268.         ),
  269.         array(
  270.           'id' => 'service_how_stepped_content_multi',
  271.           'type' => 'group',
  272.           'clone' => true,
  273.           'add_button'  => '+ Add a step group',
  274.           'visible' => array('service_how_stepped_select_multi', true),
  275.           'fields'  => array(
  276.             array(
  277.               'id' => 'service_how_stepped_content_intro',
  278.               'type'  => 'text',
  279.               'name' => 'Step group heading',
  280.               'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  281.             ),
  282.             My_Prefix_Standard_Metaboxes::prefix_metabox_v2_ordered_content(),
  283.           )
  284.         ),
  285.         array(
  286.           'id' => 'service_how_ending_content',
  287.           'type'  => 'wysiwyg',
  288.           'visible' => array(
  289.             'when' => array(
  290.               array('service_how_stepped_select', true ),
  291.               array('service_how_stepped_select_multi', true),
  292.             ),
  293.             'relation'  => 'or'
  294.           ),
  295.           'name'  => 'Display more content after all steps.',
  296.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  297.         ),
  298.         array(
  299.           'type' => 'heading',
  300.           'name'  => 'Are there renewal requirements for this service?',
  301.         ),
  302.         array(
  303.           'id' => 'service_renewal_requirements',
  304.           'type'  => 'wysiwyg',
  305.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  306.         ),
  307.       )
  308.     );
  309.   /* END METABOXES */
  310.  
  311.  
  312.  
  313. /*NEEDED CLASSES */
  314.  
  315. /* Registers discrete, reusable metaboxes */
  316.  
  317. if ( class_exists('My_Prefix_Standard_Metaboxes' ) ){
  318.   $prefix_standard_metaboxes_load = new My_Prefix_Standard_Metaboxes();
  319. }
  320.  
  321. class My_Prefix_Standard_Metaboxes {
  322.  
  323. public static function prefix_wysiwyg_options_basic( $editor_height = 200 ){
  324.  
  325.     return array(
  326.       'media_buttons' => false,
  327.       'teeny' => true,
  328.       'dfw' => false,
  329.       'tinymce' => prefix_setup_tiny_mce_basic(
  330.         array(
  331.           'format_select' => false
  332.         )
  333.       ),
  334.       'editor_height' => $editor_height,
  335.     );
  336.   }
  337.  
  338.  
  339.   public static function prefix_wysiwyg_options_basic_heading(){
  340.  
  341.     return array(
  342.       'media_buttons' => false,
  343.       'teeny' => true,
  344.       'dfw' => false,
  345.       'tinymce' => prefix_setup_tiny_mce_basic(
  346.         array(
  347.           'format_select' => true,
  348.           'heading_level' => 'h3'
  349.         )
  350.       ),
  351.       'editor_height' => 200,
  352.     );
  353.   }
  354.  
  355.   public static function prefix_metabox_v2_ordered_content(){
  356.  
  357.     //Purpose: To display content in a stepped order on the front-end
  358.   return array(
  359.       'id'  => 'prefix_ordered_content',
  360.       'type'  => 'group',
  361.       'clone' => true,
  362.       'sort_clone'  => true,
  363.       'add_button'  => '+ Add a step',
  364.  
  365.       'fields'  => array(
  366.         array(
  367.           //TODO: determine way to display step numbers in admin
  368.           'placeholder' => 'Step Heading',
  369.           'id'  => 'prefix_step_wysiwyg_heading',
  370.           'type'  => 'text',
  371.           'class' => 'percent-95'
  372.         ),
  373.         array(
  374.           'id'  => 'prefix_step_wysiwyg_content',
  375.           'type'  => 'wysiwyg',
  376.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic()
  377.         ),
  378.         array(
  379.           'name'  => 'Does this step contain an address?',
  380.           'id'  => 'prefix_address_step',
  381.           'type'  => 'switch',
  382.           'on_label'  => 'Yes',
  383.           'off_label' => 'No'
  384.         ),
  385.         array(
  386.           'id' => 'prefix_std_address',
  387.           'type' => 'group',
  388.           'visible' => array('prefix_address_step', true),
  389.  
  390.           'fields' => array(
  391.             My_Prefix_Standard_Metaboxes::prefix_metabox_v2_address_fields(),
  392.           ),
  393.         ),
  394.       )
  395.     );
  396.   }
  397.  
  398.  public static function prefix_metabox_v2_address_fields($id = 'address_group'){
  399.  
  400.     //Default address fields
  401.     return array(
  402.       'id'  =>  $id,
  403.       'type'  => 'group',
  404.       'fields'  => array(
  405.  
  406.         array(
  407.           'type' => 'heading',
  408.           'name' => 'Address',
  409.         ),
  410.         array(
  411.           'name' => 'Street Address 1',
  412.           'id'   => 'prefix_std_address_st_1',
  413.           'type' => 'text',
  414.         ),
  415.         array(
  416.           'name' => 'Street Address 2',
  417.           'id'   => 'prefix_std_address_st_2',
  418.           'type' => 'text',
  419.         ),
  420.         array(
  421.           'name' => 'City',
  422.           'id'   => 'prefix_std_address_city',
  423.           'type' => 'text',
  424.         ),
  425.         array(
  426.           'name' => 'State',
  427.           'id'   => 'prefix_std_address_state',
  428.           'type' => 'text',
  429.         ),
  430.         array(
  431.           'name' => 'Zip',
  432.           'id'   => 'prefix_std_address_zip',
  433.           'type' => 'text',
  434.         ),
  435.         array(
  436.           'name' => 'Phone number',
  437.           'id'   => 'prefix_std_address_phone',
  438.           'type' => 'phone',
  439.         ),
  440.       ),
  441.     );
  442.   }
  443.  
  444.  public static function prefix_metabox_double_wysiwyg($section_name = 'Section title', $wysiwyg_desc = '', $columns = 12){
  445.  
  446.     //WYSIWYG with Title
  447.     return array(
  448.       'id'  =>  'prefix_custom_wysiwyg',
  449.       'type'  => 'group',
  450.       'clone' => false,
  451.       'columns'=> $columns,
  452.  
  453.       'fields'  => array(
  454.         array(
  455.           'type' => 'heading',
  456.           'name' => $section_name,
  457.         ),
  458.         array(
  459.           'id'  => 'prefix_wysiwyg_title',
  460.           'type'  => 'wysiwyg',
  461.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic($editor_height = 100)
  462.         ),
  463.         array(
  464.           'id'  => 'prefix_wysiwyg_content',
  465.           'type'  => 'wysiwyg',
  466.           'desc'  => $wysiwyg_desc,
  467.           'options' => My_Prefix_Standard_Metaboxes::prefix_wysiwyg_options_basic_heading()
  468.         )
  469.       )
  470.     );
  471.   }
  472.  
  473. }/*END CLASS*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement