pustakakoran

Meta Box Bank Soal + Plugin Matematika

Jun 4th, 2017
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Add the Meta Box --->> Create a Meta Box
  2. function add_custom_meta_box() {
  3. add_meta_box(
  4. 'custom_meta_box', // $id
  5. 'Custom Meta Box', // $title
  6. 'show_custom_meta_box', // $callback
  7. 'post', // $page
  8. 'normal', // $context
  9. 'high'); // $priority
  10. }
  11. add_action('add_meta_boxes', 'add_custom_meta_box');
  12.  
  13. // Field Array -->> Create the Field Array
  14. $prefix = 'banksoal_';
  15. $custom_meta_fields = array(
  16. array(
  17. 'label'=> 'Download',
  18. 'desc' => 'A description for the field.',
  19. 'id' => $prefix.'download',
  20. 'type' => 'text'
  21. ),
  22. array(
  23. 'label'=> 'Kunci',
  24. 'desc' => 'A description for the field.',
  25. 'id' => $prefix.'kunci',
  26. 'type' => 'textarea'
  27. ),
  28.  
  29. );
  30.  
  31. // The Callback -->> Outputting the Fields
  32. function show_custom_meta_box() {
  33. global $custom_meta_fields, $post;
  34. // Use nonce for verification
  35. echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';
  36.  
  37. // Begin the field table and loop
  38. echo '<table class="form-table">';
  39. foreach ($custom_meta_fields as $field) {
  40. // get value of this field if it exists for this post
  41. $meta = get_post_meta($post->ID, $field['id'], true);
  42. // begin a table row with
  43. echo '<tr>
  44. <th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
  45. <td>';
  46. switch($field['type']) {
  47.  
  48.  
  49.  
  50.  
  51. // TEXT
  52. case 'text':
  53. echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />
  54. <br /><span class="description">'.$field['desc'].'</span>';
  55. break;
  56.  
  57. // TEXT AREA
  58. case 'textarea':
  59. echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
  60. <br /><span class="description">'.$field['desc'].'</span>';
  61. break;
  62.  
  63.  
  64. } //end switch
  65. echo '</td></tr>';
  66. } // end foreach
  67. echo '</table>'; // end table
  68. }
  69.  
  70.  
  71.  
  72. // SAVE THE DATA
  73. function save_custom_meta($post_id) {
  74. global $custom_meta_fields;
  75.  
  76. // verify nonce
  77. if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
  78. return $post_id;
  79. // check autosave
  80. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  81. return $post_id;
  82. // check permissions
  83. if ('page' == $_POST['post_type']) {
  84. if (!current_user_can('edit_page', $post_id))
  85. return $post_id;
  86. } elseif (!current_user_can('edit_post', $post_id)) {
  87. return $post_id;
  88. }
  89. // loop through fields and save the data
  90. foreach ($custom_meta_fields as $field) {
  91. $old = get_post_meta($post_id, $field['id'], true);
  92. $new = $_POST[$field['id']];
  93. if ($new && $new != $old) {
  94. update_post_meta($post_id, $field['id'], $new);
  95. } elseif ('' == $new && $old) {
  96. delete_post_meta($post_id, $field['id'], $old);
  97. }
  98. } // end foreach
  99. }
  100. add_action('save_post', 'save_custom_meta');
  101.  
  102.  
  103. ====================================
  104. MENAMPILKANNYA
  105. ====================================
  106.  
  107. <div style="text-align: center !important;">
  108.  
  109.  
  110.  
  111. <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  112. <!-- responsiv-bawah -->
  113. <ins class="adsbygoogle"
  114. style="display:block"
  115. data-ad-client="ca-pub-1162866178338695"
  116. data-ad-slot="6086448713"
  117. data-ad-format="auto"></ins>
  118. <script>
  119. (adsbygoogle = window.adsbygoogle || []).push({});
  120. </script>
  121.  
  122.  
  123.  
  124.  
  125. <div id="spoiler" style="display:none">
  126.  
  127. <?php
  128. $my_download = get_post_meta( get_the_ID(), 'banksoal_download', true);
  129. if( ! empty( $my_download ) ) {
  130. echo '<a href="' . $my_download . '" target="_blank"><b>DOWNLOAD FILE BANK SOAL INI</b></a>';
  131. }
  132. ?>
  133.  
  134.  
  135.  
  136.  
  137. <?php
  138. $my_kunci = get_post_meta( get_the_ID(), 'banksoal_kunci', true);
  139. if( ! empty( $my_kunci ) ) {
  140. echo '' . $my_kunci . '';
  141. }
  142. ?>
  143.  
  144.  
  145. </div>
  146. <button title="Click to Show/Hide Content" type="button" onclick="if(document.getElementById('spoiler') .style.display=='none') {document.getElementById('spoiler') .style.display=''}else{document.getElementById('spoiler') .style.display='none'}">Show/Hide Kunci Jawaban</button>
  147.  
  148. <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  149. <!-- responsiv-bawah -->
  150. <ins class="adsbygoogle"
  151. style="display:block"
  152. data-ad-client="ca-pub-1162866178338695"
  153. data-ad-slot="6086448713"
  154. data-ad-format="auto"></ins>
  155. <script>
  156. (adsbygoogle = window.adsbygoogle || []).push({});
  157. </script>
  158.  
  159.  
  160. </div>
  161.  
  162.  
  163.  
  164. ==================================
  165. PLUGIN MATEMATIKA
  166. =======================================
  167.  
  168. WPMathPub: http://wordpress.org/plugins/wpmathpub/
  169. Name: wpmathpub
  170. Panduan: http://www.xm1math.net/phpmathpublisher/doc/help.html (sdh mati)
  171. File demo download: https://github.com/daanforever/phpmathpublisher
  172.  
  173.  
  174. Contoh-contoh penulisan:
  175.  
  176. [pmath size=14]int{0}{2} {(x^2 } + sin x)dx = 4.08[/pmath]
  177.  
  178. [pmath size=14]delim{[}{matrix{3}{3}{5 3 0 6 7 0 1 2 8}}{]} [/pmath]
  179.  
  180. [pmath size=14]delim{[}{matrix{3}{3}{5 3 (cos 2) 6 7 0 1 -2 (sin 5)}}{]} [/pmath]
  181.  
  182. [pmath size=14]int{0}{pi /2}{(x^2 } + sin x)dx = 2.29[/pmath]
  183.  
  184. [pmath size=14]delim{[}{matrix{3}{3}{5 3 {cos 2} 6 7 0 1 {-2} {sin 5}}}{]} [/pmath]
  185.  
  186. [pmath size=12]S(f)(t)=a_{0}+sum{n=1}{+infty}{a_{n} cos(n omega t)+b_{n} sin(n omega t)}[/pmath]
  187.  
  188. [pmath size=24]delim{lbrace}{matrix{3}{1}{{3x-5y+z=0} {sqrt{2}x-7y+8z=0} {x-8y+9z=0}}}{ }[/pmath]
  189.  
  190. [pmath]delim{|}{{1/N} sum{n=1}{N}{gamma(u_n)} - 1/{2 pi} int{0}{2 pi}{gamma(t) dt}}{|} <= epsilon/3[/pmath]
RAW Paste Data