Advertisement
longnguyenwp

Yasmine meta box

Feb 24th, 2022
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.20 KB | None | 0 0
  1. <?php
  2. add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
  3.  
  4. function your_prefix_function_name( $meta_boxes ) {
  5.     $prefix = 'academic';
  6.  
  7. $meta_boxes[] = [
  8.     'title'              => __( 'Academic: Research Summary', 'your-text-domain' ),
  9.     'id'                 => 'research-summary',
  10.     'post_types'         => ['research'],
  11.     'style'              => 'seamless',
  12.     'closed'             => true,
  13.     'tab_default_active' => 'research_details_tab',
  14.     'tabs'               => [
  15.         'academicresearch_details_tab' => [
  16.             'label' => 'Research details',
  17.             'icon'  => 'dashicons-plus',
  18.         ],
  19.         'academicaudience_tab'         => [
  20.             'label' => 'Identify the reader',
  21.             'icon'  => 'dashicons-groups',
  22.         ],
  23.         'academicmethodology_tab'      => [
  24.             'label' => 'Methodology',
  25.             'icon'  => 'dashicons-clipboard',
  26.         ],
  27.         'academicsummary_tab'          => [
  28.             'label' => 'Add Summary',
  29.             'icon'  => 'dashicons-edit',
  30.         ],
  31.     ],
  32.     'fields'             => [
  33.         [
  34.             'name'     => __( 'Research Title', 'your-text-domain' ),
  35.             'id'       => $prefix . 'post_title',
  36.             'type'     => 'text',
  37.             'required' => true,
  38.             'tab'      => 'academicresearch_details_tab',
  39.         ],
  40.         [
  41.             'name'       => __( 'Year', 'your-text-domain' ),
  42.             'id'         => $prefix . 'year',
  43.             'type'       => 'taxonomy_advanced',
  44.             'taxonomy'   => ['year_published'],
  45.             'field_type' => 'select_advanced',
  46.             'tab'        => 'academicresearch_details_tab',
  47.         ],
  48.         [
  49.             'name'       => __( 'Research output', 'your-text-domain' ),
  50.             'id'         => $prefix . 'output',
  51.             'type'       => 'taxonomy_advanced',
  52.             'taxonomy'   => ['research_category'],
  53.             'field_type' => 'radio_list',
  54.             'add_new'    => true,
  55.             'tooltip'    => [
  56.                 'icon'     => 'info',
  57.                 'position' => 'right',
  58.                 'content'  => 'What was the main output for this research?',
  59.             ],
  60.             'tab'        => 'academicresearch_details_tab',
  61.         ],
  62.         [
  63.             'name'    => __( 'Co-author(s)', 'your-text-domain' ),
  64.             'id'      => $prefix . 'co_authorYN',
  65.             'type'    => 'radio',
  66.             'options' => [
  67.                 'y' => __( 'Yes, I had co-authors', 'your-text-domain' ),
  68.                 'n' => __( 'No, I was the only author', 'your-text-domain' ),
  69.             ],
  70.             'tooltip' => [
  71.                 'icon'     => 'info',
  72.                 'position' => 'right',
  73.                 'content'  => 'Was this paper co-authored with other academics?',
  74.             ],
  75.             'tab'     => 'academicresearch_details_tab',
  76.         ],
  77.         [
  78.             'name'    => __( 'Lead author', 'your-text-domain' ),
  79.             'id'      => $prefix . 'lead_authorYN',
  80.             'type'    => 'radio',
  81.             'options' => [
  82.                 'y' => __( 'I was the lead author', 'your-text-domain' ),
  83.                 'n' => __( 'I was not the lead author', 'your-text-domain' ),
  84.             ],
  85.             'tooltip' => [
  86.                 'icon'     => 'info',
  87.                 'position' => 'right',
  88.                 'content'  => 'Were you the lead author for this research?',
  89.             ],
  90.             'visible' => [
  91.                 'when'     => [['co_authorYN', '=', 'y']],
  92.                 'relation' => 'or',
  93.             ],
  94.             'tab'     => 'academicresearch_details_tab',
  95.         ],
  96.         [
  97.             'name'    => __( 'Lead author details', 'your-text-domain' ),
  98.             'id'      => $prefix . 'lead_author_details',
  99.             'type'    => 'group',
  100.             'fields'  => [
  101.                 [
  102.                     'name' => __( 'Lead author full name', 'your-text-domain' ),
  103.                     'id'   => $prefix . 'lead_author_name',
  104.                     'type' => 'text',
  105.                 ],
  106.                 [
  107.                     'name' => __( 'Lead author email', 'your-text-domain' ),
  108.                     'id'   => $prefix . 'lead_author_email',
  109.                     'type' => 'text',
  110.                 ],
  111.             ],
  112.             'visible' => [
  113.                 'when'     => [['lead_authorYN', '=', 'n']],
  114.                 'relation' => 'or',
  115.             ],
  116.             'tab'     => 'academicresearch_details_tab',
  117.         ],
  118.         [
  119.             'name'       => __( 'Add contributor', 'your-text-domain' ),
  120.             'id'         => $prefix . 'user_contributor',
  121.             'type'       => 'user',
  122.             'desc'       => __( 'Link this research to 4 contributors', 'your-text-domain' ),
  123.             'field_type' => 'select_advanced',
  124.             'multiple'   => true,
  125.             'tooltip'    => [
  126.                 'icon'     => 'info',
  127.                 'position' => 'right',
  128.                 'content'  => ' Please note you can only add contributors who have created an Acume account. If they haven\'t then their contribution can still be seen in the reference',
  129.             ],
  130.             'visible'    => [
  131.                 'when'     => [['lead_authorYN', '=', 'y'], ['lead_author_name', 'contains', ' ']],
  132.                 'relation' => 'or',
  133.             ],
  134.             'tab'        => 'academicresearch_details_tab',
  135.         ],
  136.         [
  137.             'name'    => __( 'Funding', 'your-text-domain' ),
  138.             'id'      => $prefix . 'fundingYN',
  139.             'type'    => 'radio',
  140.             'options' => [
  141.                 'Yes' => __( 'I received external funds from outside my institution', 'your-text-domain' ),
  142.                 'No'  => __( 'This research was funded by my own institution or self-funded', 'your-text-domain' ),
  143.             ],
  144.             'tooltip' => [
  145.                 'icon'     => 'info',
  146.                 'position' => 'right',
  147.                 'content'  => 'Did you receive additional external funding to produce this research? We ask this question to allow the reader to identify external influences and make research as transparent as possible.',
  148.             ],
  149.             'inline'  => false,
  150.             'tab'     => 'academicresearch_details_tab',
  151.         ],
  152.         [
  153.             'name'     => __( 'External funding', 'your-text-domain' ),
  154.             'id'       => $prefix . 'external_funding_details',
  155.             'type'     => 'taxonomy',
  156.             'desc'     => __( 'Select or add organisation(s), funding bodies or individual(s) who financed this research', 'your-text-domain' ),
  157.             'taxonomy' => ['funding'],
  158.             'add_new'  => true,
  159.             'multiple' => true,
  160.             'visible'  => [
  161.                 'when'     => [['fundingYN', '=', 'Yes']],
  162.                 'relation' => 'or',
  163.             ],
  164.             'tab'      => 'academicresearch_details_tab',
  165.         ],
  166.         [
  167.             'name'    => __( 'Research Link', 'your-text-domain' ),
  168.             'id'      => $prefix . 'research_link',
  169.             'type'    => 'url',
  170.             'tooltip' => [
  171.                 'icon'     => 'info',
  172.                 'position' => 'right',
  173.                 'content'  => 'Share a link where readers can find the full version of your research (open-source where possible)',
  174.             ],
  175.             'tab'     => 'academicresearch_details_tab',
  176.         ],
  177.         [
  178.             'name'          => __( 'Citation', 'your-text-domain' ),
  179.             'id'            => $prefix . 'citation',
  180.             'type'          => 'wysiwyg',
  181.             'media_buttons' => false,
  182.             'textarea_rows' => 2,
  183.             'teeny'         => true,
  184.             'tab'           => 'academicresearch_details_tab',
  185.         ],
  186.         [
  187.             'name'    => __( 'DOI', 'your-text-domain' ),
  188.             'id'      => $prefix . 'doi',
  189.             'type'    => 'text',
  190.             'tooltip' => [
  191.                 'icon'     => 'info',
  192.                 'position' => 'right',
  193.                 'content'  => 'Add DOI number if applicable - otherwise leave blank',
  194.             ],
  195.             'tab'     => 'academicresearch_details_tab',
  196.         ],
  197.         [
  198.             'name'       => __( 'Academic Field', 'your-text-domain' ),
  199.             'id'         => $prefix . 'discipline_focus',
  200.             'type'       => 'taxonomy_advanced',
  201.             'taxonomy'   => ['discipline'],
  202.             'field_type' => 'select_advanced',
  203.             'tab'        => 'academicaudience_tab',
  204.         ],
  205.         [
  206.             'name'           => __( 'Research Topic', 'your-text-domain' ),
  207.             'id'             => $prefix . 'topic_focus',
  208.             'type'           => 'taxonomy_advanced',
  209.             'desc'           => __( 'Select one most research focus for this research', 'your-text-domain' ),
  210.             'taxonomy'       => ['researchtopic'],
  211.             'field_type'     => 'select_advanced',
  212.             'remove_default' => true,
  213.             'tab'            => 'academicaudience_tab',
  214.         ],
  215.         [
  216.             'name'       => __( 'Relevant Countries', 'your-text-domain' ),
  217.             'id'         => $prefix . 'country_focus',
  218.             'type'       => 'taxonomy_advanced',
  219.             'desc'       => __( 'Select a maximum of three', 'your-text-domain' ),
  220.             'taxonomy'   => ['research_country_focus'],
  221.             'field_type' => 'select_advanced',
  222.             'add_new'    => true,
  223.             'multiple'   => true,
  224.             'tooltip'    => [
  225.                 'icon'     => 'info',
  226.                 'position' => 'right',
  227.                 'content'  => 'Which countries or regions did your research examine?',
  228.             ],
  229.             'tab'        => 'academicaudience_tab',
  230.         ],
  231.         [
  232.             'name'            => __( 'SDG relevancy', 'your-text-domain' ),
  233.             'id'              => $prefix . 'sdg_focus',
  234.             'type'            => 'taxonomy_advanced',
  235.             'desc'            => __( 'Select a maximum of 3', 'your-text-domain' ),
  236.             'taxonomy'        => ['sdg'],
  237.             'field_type'      => 'select_advanced',
  238.             'remove_default'  => true,
  239.             'multiple'        => true,
  240.             'select_all_none' => true,
  241.             'tooltip'         => [
  242.                 'icon'     => 'info',
  243.                 'position' => 'right',
  244.                 'content'  => 'Select the SDG(s) this research is most relevant for',
  245.             ],
  246.             'tab'             => 'academicaudience_tab',
  247.         ],
  248.         [
  249.             'name'           => __( 'Organisation', 'your-text-domain' ),
  250.             'id'             => $prefix . 'sector_focus',
  251.             'type'           => 'taxonomy_advanced',
  252.             'taxonomy'       => ['organisations'],
  253.             'field_type'     => 'select_tree',
  254.             'add_new'        => true,
  255.             'remove_default' => true,
  256.             'tooltip'        => [
  257.                 'icon'     => 'info',
  258.                 'position' => 'right',
  259.                 'content'  => 'Add the top sector and organisation who must read this research',
  260.             ],
  261.             'tab'            => 'academicaudience_tab',
  262.         ],
  263.         [
  264.             'name'           => __( 'Professional role', 'your-text-domain' ),
  265.             'id'             => $prefix . 'professional_focus',
  266.             'type'           => 'taxonomy_advanced',
  267.             'taxonomy'       => ['professionalaudience'],
  268.             'field_type'     => 'select_advanced',
  269.             'add_new'        => true,
  270.             'remove_default' => true,
  271.             'multiple'       => true,
  272.             'tooltip'        => [
  273.                 'icon'     => 'info',
  274.                 'position' => 'right',
  275.                 'content'  => 'Which professional from the above organisations would your insights be most helpful for?',
  276.             ],
  277.             'tab'            => 'academicaudience_tab',
  278.         ],
  279.         [
  280.             'name'       => __( 'Methods', 'your-text-domain' ),
  281.             'id'         => $prefix . 'methods',
  282.             'type'       => 'taxonomy_advanced',
  283.             'taxonomy'   => ['methodology'],
  284.             'field_type' => 'select_advanced',
  285.             'tab'        => 'academicmethodology_tab',
  286.         ],
  287.         [
  288.             'name'    => __( 'Methodology statement', 'your-text-domain' ),
  289.             'id'      => $prefix . 'methodology_statement',
  290.             'type'    => 'textarea',
  291.             'rows'    => 4,
  292.             'cols'    => 1,
  293.             'tooltip' => [
  294.                 'icon'     => 'info',
  295.                 'position' => 'right',
  296.                 'content'  => 'Briefly describe the methodology used to conduct this research and how you reached your conclusions. You should include how it was research, who was researched, the number of respondents, and other information related to methods or data set.',
  297.             ],
  298.             'tab'     => 'academicmethodology_tab',
  299.         ],
  300.         [
  301.             'name'    => __( 'Limitations', 'your-text-domain' ),
  302.             'id'      => $prefix . 'limitations',
  303.             'type'    => 'textarea',
  304.             'rows'    => 4,
  305.             'tooltip' => [
  306.                 'icon'     => 'info',
  307.                 'position' => 'right',
  308.                 'content'  => 'Write a few sentences on the limitations of your research for a professionals reference (eg - can\'t be generalised as x, based on x assumptions)',
  309.             ],
  310.             'tab'     => 'academicmethodology_tab',
  311.         ],
  312.         [
  313.             'name'              => __( 'Core concepts', 'your-text-domain' ),
  314.             'id'                => $prefix . 'glossary_terms',
  315.             'type'              => 'fieldset_text',
  316.             'label_description' => __( 'Select and define up to 3 concepts from your research. ', 'your-text-domain' ),
  317.             'options'           => [
  318.                 'concept'    => 'Concept',
  319.                 'definition' => 'Concept\'s Definition',
  320.             ],
  321.             'clone'             => true,
  322.             'max_clone'         => 3,
  323.             'tooltip'           => [
  324.                 'icon'     => 'info',
  325.                 'position' => 'right',
  326.                 'content'  => 'In the future this will be also be added into a glossary',
  327.             ],
  328.             'tab'               => 'academicmethodology_tab',
  329.         ],
  330.         [
  331.             'name'       => __( 'Peer Review', 'your-text-domain' ),
  332.             'id'         => $prefix . 'peer_review',
  333.             'type'       => 'taxonomy_advanced',
  334.             'taxonomy'   => ['peerreview'],
  335.             'field_type' => 'select_advanced',
  336.             'tooltip'    => [
  337.                 'icon'     => 'info',
  338.                 'position' => 'right',
  339.                 'content'  => 'Has this research been peer-reviewed?',
  340.             ],
  341.             'tab'        => 'academicmethodology_tab',
  342.         ],
  343.         [
  344.             'name'           => __( 'Journal', 'your-text-domain' ),
  345.             'id'             => $prefix . 'journal',
  346.             'type'           => 'taxonomy_advanced',
  347.             'taxonomy'       => ['journal'],
  348.             'field_type'     => 'select_advanced',
  349.             'add_new'        => true,
  350.             'remove_default' => true,
  351.             'tooltip'        => [
  352.                 'icon'     => 'info',
  353.                 'position' => 'right',
  354.                 'content'  => 'If it was peer-reviewed by a scholarly publisher, please indicate the publisher',
  355.             ],
  356.             'visible'        => [
  357.                 'when'     => [['peer_review', '=', 'Peer Reviewed']],
  358.                 'relation' => 'or',
  359.             ],
  360.             'tab'            => 'academicmethodology_tab',
  361.         ],
  362.         [
  363.             'name'              => __( 'Case Study', 'your-text-domain' ),
  364.             'id'                => $prefix . 'case_studyYN',
  365.             'type'              => 'radio',
  366.             'label_description' => __( 'Did your research include a case study?', 'your-text-domain' ),
  367.             'options'           => [
  368.                 'yes' => __( 'Yes', 'your-text-domain' ),
  369.                 'no'  => __( 'No', 'your-text-domain' ),
  370.             ],
  371.             'std'               => 'No',
  372.             'inline'            => false,
  373.             'tab'               => 'academicsummary_tab',
  374.         ],
  375.         [
  376.             'name'          => __( 'Describe Case Study ', 'your-text-domain' ),
  377.             'id'            => $prefix . 'case_study_details',
  378.             'type'          => 'textarea',
  379.             'tooltip'       => [
  380.                 'icon'     => 'info',
  381.                 'position' => 'right',
  382.                 'content'  => 'Briefly explain the case study or studies your research looked at',
  383.             ],
  384.             'textarea_rows' => 6,
  385.             'visible'       => [
  386.                 'when'     => [['case_studyYN', '=', 'yes']],
  387.                 'relation' => 'or',
  388.             ],
  389.             'tab'           => 'academicsummary_tab',
  390.         ],
  391.         [
  392.             'name'          => __( 'Findings', 'your-text-domain' ),
  393.             'id'            => $prefix . 'post_content',
  394.             'type'          => 'wysiwyg',
  395.             'required'      => true,
  396.             'tooltip'       => [
  397.                 'icon'     => 'info',
  398.                 'position' => 'right',
  399.                 'content'  => 'What were the key empirical and theoretical findings from your research. Professionals will quote this part and so be specific. ',
  400.             ],
  401.             'textarea_rows' => 12,
  402.             'tab'           => 'academicsummary_tab',
  403.         ],
  404.         [
  405.             'name'          => __( 'Significance of Research', 'your-text-domain' ),
  406.             'id'            => $prefix . 'significance',
  407.             'type'          => 'textarea',
  408.             'rows'          => 7,
  409.             'required'      => true,
  410.             'tooltip'       => [
  411.                 'icon'     => 'info',
  412.                 'position' => 'right',
  413.                 'content'  => 'Answer the question: Why do your findings matter?',
  414.             ],
  415.             'textarea_rows' => 5,
  416.             'tab'           => 'academicsummary_tab',
  417.         ],
  418.         [
  419.             'name'    => __( 'Conclusion', 'your-text-domain' ),
  420.             'id'      => $prefix . 'conclusion',
  421.             'type'    => 'text',
  422.             'desc'    => __( 'Write your conclusion in one or two sentence(s)', 'your-text-domain' ),
  423.             'size'    => 290,
  424.             'tooltip' => [
  425.                 'icon'     => 'info',
  426.                 'position' => 'right',
  427.                 'content'  => 'Answer the question: What was the one main conclusion you found from your research? This can be the same length as a standard tweet (280 characters)',
  428.             ],
  429.             'tab'     => 'academicsummary_tab',
  430.         ],
  431.         [
  432.             'name'              => __( 'Practical Recommendations', 'your-text-domain' ),
  433.             'id'                => $prefix . 'recommendations',
  434.             'type'              => 'textarea',
  435.             'desc'              => __( 'Clearly explain the exact step a professional should take to use your findings', 'your-text-domain' ),
  436.             'placeholder'       => __( 'During programme design, WASH professionals need to identify...', 'your-text-domain' ),
  437.             'rows'              => 8,
  438.             'clone'             => true,
  439.             'clone_as_multiple' => true,
  440.             'max_clone'         => 5,
  441.             'add_button'        => __( 'Add another practical recommendation', 'your-text-domain' ),
  442.             'tooltip'           => [
  443.                 'icon'     => 'info',
  444.                 'position' => 'right',
  445.                 'content'  => 'Add a practical example on how the findings of this research can be put into practice. Be exact. Please note that this does not need to have been included in your original research. Its purpose is to give direction on how your findings could be used in practice.',
  446.             ],
  447.             'tab'               => 'academicsummary_tab',
  448.         ],
  449.         [
  450.             'name'              => __( 'Other use cases', 'your-text-domain' ),
  451.             'id'                => $prefix . 'other_use_cases',
  452.             'type'              => 'radio',
  453.             'label_description' => __( 'Are there other specific context(s), policy(s) or intervention(s) that your research could be useful for?', 'your-text-domain' ),
  454.             'options'           => [
  455.                 'yes' => __( 'Yes', 'your-text-domain' ),
  456.                 'no'  => __( 'No', 'your-text-domain' ),
  457.             ],
  458.             'tab'               => 'academicsummary_tab',
  459.         ],
  460.         [
  461.             'name'       => __( 'Application beyond your research', 'your-text-domain' ),
  462.             'id'         => $prefix . 'example_application',
  463.             'type'       => 'textarea',
  464.             'desc'       => __( 'Briefly explain up to three examples of additional use cases for your research', 'your-text-domain' ),
  465.             'clone'      => true,
  466.             'sort_clone' => true,
  467.             'max_clone'  => 3,
  468.             'add_button' => __( 'Another example', 'your-text-domain' ),
  469.             'tooltip'    => [
  470.                 'icon'     => 'info',
  471.                 'position' => 'right',
  472.                 'content'  => 'Please note that this does not need to have been included in your original research. Its purpose is to identify other possible case-studies.',
  473.             ],
  474.             'visible'    => [
  475.                 'when'     => [['other_use_cases', '=', 'yes']],
  476.                 'relation' => 'or',
  477.             ],
  478.             'tab'        => 'academicsummary_tab',
  479.         ],
  480.         [
  481.             'name'           => __( 'Tag', 'your-text-domain' ),
  482.             'id'             => $prefix . 'tags',
  483.             'type'           => 'taxonomy_advanced',
  484.             'desc'           => __( 'Select up to 5 tags to categorise your research', 'your-text-domain' ),
  485.             'taxonomy'       => ['label'],
  486.             'field_type'     => 'select_advanced',
  487.             'add_new'        => true,
  488.             'remove_default' => true,
  489.             'multiple'       => true,
  490.             'tab'            => 'academicsummary_tab',
  491.         ],
  492.     ],
  493. ];
  494.  
  495. return $meta_boxes;
  496. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement