Advertisement
DedsecID

costum func age theme

Mar 9th, 2022
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.74 KB | None | 0 0
  1. <?php
  2. $themename = "Layout";
  3. $shortname = "cstudio";
  4.  
  5. $options = array (
  6.     array(  "name" => "Themes:",
  7.             "type" => "title"),        
  8.     array(  "type" => "open"), 
  9.     array(  "name" => "Layout Settings",
  10.             "desc" => "list.php untuk tampilan default , gridmode.php untuk tampilan grid",
  11.             "id" => $shortname."_post",
  12.             "type" => "select",
  13.         "options" => array("list.php" => "list.php","gridmode" => "gridmode.php"),
  14.             "std" => "list.php",),
  15.            
  16.     array(  "type" => "close")
  17.    
  18. );
  19.  
  20. function mytheme_add_admin() {
  21.     global $themename, $shortname, $options;
  22.     if ( $_GET['page'] == basename(__FILE__) ) {
  23.    
  24.         if ( 'save' == $_REQUEST['action'] ) {
  25.                 foreach ($options as $value) {
  26.                     update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  27.                 foreach ($options as $value) {
  28.                     if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
  29.                 header("Location: themes.php?page=custom-functions.php&saved=true");
  30.                 die;
  31.         } else if( 'reset' == $_REQUEST['action'] ) {
  32.             foreach ($options as $value) {
  33.                 delete_option( $value['id'] ); }
  34.             header("Location: themes.php?page=functions.php&reset=true");
  35.             die;
  36.         }
  37.     }
  38.  
  39.     add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  40.  
  41. }
  42.  
  43. function mytheme_admin() {
  44.  
  45.     global $themename, $shortname, $options;
  46.  
  47.     if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' saved.</strong></p></div>';
  48.  
  49.    
  50. ?>
  51. <div class="wrap">
  52.  
  53.  
  54. <form method="post">
  55.  
  56.  
  57.  
  58. <?php foreach ($options as $value) {
  59.    
  60.     switch ( $value['type'] ) {
  61.    
  62.         case "open":
  63.         ?>
  64.         <table width="100%" style="background-color: #FFFFFF; padding:5px 10px;border: 1px solid #DDD;border-top: 0;margin-bottom: 10px;">
  65.        
  66.        
  67.        
  68.         <?php break;
  69.        
  70.         case "close":
  71.         ?>
  72.        
  73.         </table><br />
  74.        
  75.        
  76.         <?php break;
  77.        
  78.         case "title":
  79.         ?>
  80.         <table width="100%" style="background-color: #198ef3;color: #FFF;padding: 0 10px;font-size: 17px;"><tr>
  81.             <td colspan="2"><h3 style="font-weight: bold;color: #FFF;"><?php echo $value['name']; ?></h3></td>
  82.         </tr>
  83.                
  84.        
  85.        
  86.  
  87.         <?php
  88.         break;
  89.        
  90.         case 'select':
  91.         ?>
  92.         <tr>
  93.             <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  94.             <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
  95.        </tr>
  96.                
  97.        <tr>
  98.             <td><small><?php echo $value['desc']; ?></small></td>
  99.        </tr><tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  100.  
  101.         <?php
  102.         break;
  103.            
  104.         case "checkbox":
  105.         ?>
  106.             <tr>
  107.             <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
  108.                 <td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
  109.                         <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  110.                         </td>
  111.             </tr>
  112.                        
  113.             <tr>
  114.                 <td><small><?php echo $value['desc']; ?></small></td>
  115.            </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;">&nbsp;</td></tr><tr><td colspan="2">&nbsp;</td></tr>
  116.            
  117.         <?php       break;
  118.    
  119.  
  120. }
  121. }
  122. ?>
  123.  
  124. <!--</table>-->
  125. <p class="submit">
  126. <input name="save" type="submit" value="Save changes" />    
  127. <input type="hidden" name="action" value="save" />
  128. </p>
  129.  
  130. </form>
  131.  
  132.  
  133. <?php
  134. }
  135.  
  136. add_action('admin_menu', 'mytheme_add_admin'); ?>
  137. <?php
  138. global $options;
  139. foreach ($options as $value) {
  140.     if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
  141. }
  142. ?>
  143. <?php
  144. function CukStudio_MyAnimeList_API(){
  145.     wp_enqueue_script("myanimelist", get_template_directory_uri(). "/js/myanimelist.js", null, null, true);
  146. }
  147. function CukStudio_Meta_Box( $meta_boxes ) {
  148.     $prefix = "smoke-";
  149.  
  150.     $meta_boxes[] = array(
  151.         "id" => "cstudio_meta_box",
  152.         "title" => esc_html__( "Information Anime", "cstudio" ),
  153.         "post_types" => array( "anime" ),
  154.         "context" => "advanced",
  155.         "priority" => "high",
  156.         "autosave" => true,
  157.         "fields" => array(
  158.             array(
  159.                 "id" => "alternative-titles",
  160.                 "type" => "heading",
  161.                 "name" => esc_html__( "Alternative Titles", "cstudio" ),
  162.             ),
  163.             array(
  164.                 "id" => $prefix . "english",
  165.                 "type" => "text",
  166.                 "name" => esc_html__( "English", "cstudio" ),
  167.             ),
  168.             array(
  169.                 "id" => $prefix . "japanese",
  170.                 "type" => "text",
  171.                 "name" => esc_html__( "Japanese", "cstudio" ),
  172.             ),
  173.             array(
  174.                 "id" => $prefix . "synonyms",
  175.                 "type" => "text",
  176.                 "name" => esc_html__( "Synonyms", "shirozare" ),
  177.             ),
  178.             array(
  179.                 "id" => "information",
  180.                 "type" => "heading",
  181.                 "name" => esc_html__( "Information", "cstudio" ),
  182.             ),
  183.             array(
  184.                 "id" => $prefix . "episodes",
  185.                 "type" => "text",
  186.                 "name" => esc_html__( "Episodes", "cstudio" ),
  187.             ),
  188.             array(
  189.                 "id" => $prefix . "status",
  190.                 "type" => "text",
  191.                 "name" => esc_html__( "Status", "cstudio" ),
  192.             ),
  193.             array(
  194.                 "id" => $prefix . "aired",
  195.                 "type" => "text",
  196.                 "name" => esc_html__( "Aired", "cstudio" ),
  197.             ),
  198.             array(
  199.                 "id" => $prefix . "broadcast",
  200.                 "type" => "text",
  201.                 "name" => esc_html__( "Broadcast", "cstudio" ),
  202.             ),
  203.             array(
  204.                 "id" => $prefix . "licensors",
  205.                 "type" => "text",
  206.                 "name" => esc_html__( "Licensors", "cstudio" ),
  207.             ),
  208.             array(
  209.                 "id" => $prefix . "studios",
  210.                 "type" => "text",
  211.                 "name" => esc_html__( "Studios", "cstudio" ),
  212.             ),
  213.             array(
  214.                 "id" => $prefix . "source",
  215.                 "type" => "text",
  216.                 "name" => esc_html__( "Source", "cstudio" ),
  217.             ),
  218.             array(
  219.                 "id" => $prefix . "duration",
  220.                 "type" => "text",
  221.                 "name" => esc_html__( "Duration", "cstudio" ),
  222.             ),
  223.             array(
  224.                 "id" => $prefix . "rating",
  225.                 "type" => "text",
  226.                 "name" => esc_html__( "Rating", "cstudio" ),
  227.             ),
  228.             array(
  229.                 "id" => "statistics",
  230.                 "type" => "heading",
  231.                 "name" => esc_html__( "Statistics", "cstudio" ),
  232.             ),
  233.             array(
  234.                 "id" => $prefix . "score",
  235.                 "type" => "text",
  236.                 "name" => esc_html__( "Score", "cstudio" ),
  237.             ),
  238.             array(
  239.                 "id" => $prefix . "ranked",
  240.                 "type" => "text",
  241.                 "name" => esc_html__( "Ranked", "cstudio" ),
  242.             ),
  243.             array(
  244.                 "id" => $prefix . "popularity",
  245.                 "type" => "text",
  246.                 "name" => esc_html__( "Popularity", "cstudio" ),
  247.             ),
  248.             array(
  249.                 "id" => $prefix . "download",
  250.                 "name" => esc_html__( "Download", "cstudio" ),
  251.                 "type" => "wysiwyg",
  252.             ),
  253.         ),
  254.     );
  255.  
  256.     return $meta_boxes;
  257. }
  258. function MyAnimeList_API_Meta_Box($post){
  259. ?>
  260. <div class="rwmb-meta-box">
  261.     <div class="rwmb-field rwmb-text-wrapper">
  262.         <div class="rwmb-label">
  263.             <label for="smoke-myanimelist-api">MyAnimeList API</label>     
  264.         </div>
  265.         <div class="rwmb-input ui-shortable">
  266.             <div class="rwmb-clone rwmb-text-clone">
  267.                 <input size="30" type="text" id="smoke-myanimelist-api" class="rwmb-text " name="smoke-myanimelist-api"/>
  268.             </div>
  269.             <a class="button-primary" id="smoke-myanimelist-api-generate">Generate</a>
  270.         </div>
  271.     </div>
  272. </div>
  273. <?php
  274. }
  275.  
  276. function CukStudio_Setup(){
  277.     add_filter("rwmb_meta_boxes", "CukStudio_Meta_Box");
  278.     add_action("add_meta_boxes", "MyAnimeList_API_Add_Meta_Box");
  279.     add_action("admin_enqueue_scripts", "CukStudio_MyAnimeList_API");
  280.     add_theme_support("post-thumbnails");
  281.     add_theme_support("title-tag");
  282.     register_taxonomy("genre", "anime", array(
  283.         "labels"             => array(
  284.             "name"                       => "Genre",
  285.             "singular_name"              => "Genre",
  286.             "menu_name"                  => "Genre",
  287.             "all_items"                  => "Semua Genre",
  288.             "edit_item"                  => "Ubah Genre",
  289.             "view_item"                  => "Lihat Genre",
  290.             "update_item"                => "Perbarui Genre",
  291.             "add_new_item"               => "Tambah Genre Baru",
  292.             "new_item_name"              => "Nama Genre Baru",
  293.             "parent_item"                => "Induk Genre",
  294.             "parent_item_colon"          => "Induk Genre:",
  295.             "search_items"               => "Cari Genre",
  296.             "popular_items"              => "Genre Populer",
  297.             "separate_items_with_commas" => "Batasi Genre dengan Koma",
  298.             "add_or_remove_items"        => "Tambah atau Hapus Genre",
  299.             "choose_from_most_used"      => "Pilih dari yang paling sering digunakan",
  300.             "not_found"                  => "Tidak ada"
  301.         ),
  302.         "public"             => true,
  303.         "publicly_queryable" => true,
  304.         "show_ui"            => true,
  305.         "show_in_menu"       => true,
  306.         "show_in_nav_menus"  => true,
  307.         "show_tagcloud"      => true,
  308.         "show_in_quick_edit" => true,
  309.         "show_admin_column"  => false,
  310.         "hierarchical"       => false,
  311.         "query_var"          => true,
  312.         "sort"               => true
  313.     ));
  314.     register_taxonomy("type", "anime", array(
  315.         "labels"             => array(
  316.             "name"                       => "Type",
  317.             "singular_name"              => "Type",
  318.             "menu_name"                  => "Type",
  319.             "all_items"                  => "Semua Type",
  320.             "edit_item"                  => "Ubah Type",
  321.             "view_item"                  => "Lihat Type",
  322.             "update_item"                => "Perbarui Type",
  323.             "add_new_item"               => "Tambah Type Baru",
  324.             "new_item_name"              => "Nama Type Baru",
  325.             "parent_item"                => "Induk Type",
  326.             "parent_item_colon"          => "Induk Type:",
  327.             "search_items"               => "Cari Type",
  328.             "popular_items"              => "Type Populer",
  329.             "separate_items_with_commas" => "Batasi Type dengan Koma",
  330.             "add_or_remove_items"        => "Tambah atau Hapus Type",
  331.             "choose_from_most_used"      => "Pilih dari yang paling sering digunakan",
  332.             "not_found"                  => "Tidak ada"
  333.         ),
  334.         "public"             => true,
  335.         "publicly_queryable" => true,
  336.         "show_ui"            => true,
  337.         "show_in_menu"       => true,
  338.         "show_in_nav_menus"  => true,
  339.         "show_tagcloud"      => true,
  340.         "show_in_quick_edit" => true,
  341.         "show_admin_column"  => false,
  342.         "hierarchical"       => false,
  343.         "query_var"          => true,
  344.         "sort"               => true
  345.     ));
  346.     register_taxonomy("season", "anime", array(
  347.         "labels"             => array(
  348.             "name"                       => "Season",
  349.             "singular_name"              => "Season",
  350.             "menu_name"                  => "Season",
  351.             "all_items"                  => "Semua Season",
  352.             "edit_item"                  => "Ubah Season",
  353.             "view_item"                  => "Lihat Season",
  354.             "update_item"                => "Perbarui Season",
  355.             "add_new_item"               => "Tambah Season Baru",
  356.             "new_item_name"              => "Nama Season Baru",
  357.             "parent_item"                => "Induk Season",
  358.             "parent_item_colon"          => "Induk Season:",
  359.             "search_items"               => "Cari Season",
  360.             "popular_items"              => "Season Populer",
  361.             "separate_items_with_commas" => "Batasi Season dengan Koma",
  362.             "add_or_remove_items"        => "Tambah atau Hapus Season",
  363.             "choose_from_most_used"      => "Pilih dari yang paling sering digunakan",
  364.             "not_found"                  => "Tidak ada"
  365.         ),
  366.         "public"             => true,
  367.         "publicly_queryable" => true,
  368.         "show_ui"            => true,
  369.         "show_in_menu"       => true,
  370.         "show_in_nav_menus"  => true,
  371.         "show_tagcloud"      => true,
  372.         "show_in_quick_edit" => true,
  373.         "show_admin_column"  => false,
  374.         "hierarchical"       => false,
  375.         "query_var"          => true,
  376.         "sort"               => true
  377.     ));
  378.     register_taxonomy("producer", "anime", array(
  379.         "labels"             => array(
  380.             "name"                       => "Producer",
  381.             "singular_name"              => "Producer",
  382.             "menu_name"                  => "Producer",
  383.             "all_items"                  => "Semua Producer",
  384.             "edit_item"                  => "Ubah Producer",
  385.             "view_item"                  => "Lihat Producer",
  386.             "update_item"                => "Perbarui Producer",
  387.             "add_new_item"               => "Tambah Producer Baru",
  388.             "new_item_name"              => "Nama Producer Baru",
  389.             "parent_item"                => "Induk Producer",
  390.             "parent_item_colon"          => "Induk Producer:",
  391.             "search_items"               => "Cari Producer",
  392.             "popular_items"              => "Producer Populer",
  393.             "separate_items_with_commas" => "Batasi Producer dengan Koma",
  394.             "add_or_remove_items"        => "Tambah atau Hapus Producer",
  395.             "choose_from_most_used"      => "Pilih dari yang paling sering digunakan",
  396.             "not_found"                  => "Tidak ada"
  397.         ),
  398.         "public"             => true,
  399.         "publicly_queryable" => true,
  400.         "show_ui"            => true,
  401.         "show_in_menu"       => true,
  402.         "show_in_nav_menus"  => true,
  403.         "show_tagcloud"      => true,
  404.         "show_in_quick_edit" => true,
  405.         "show_admin_column"  => false,
  406.         "hierarchical"       => false,
  407.         "query_var"          => true,
  408.         "sort"               => true
  409.     ));
  410. }
  411. add_action("after_setup_theme", "CukStudio_Setup");
  412. function MyAnimeList_API_Add_Meta_Box(){
  413.     add_meta_box(
  414.         "MyAnimeList-API",
  415.         __("MyAnimeList API", "cstudio"),
  416.         "MyAnimeList_API_Meta_Box",
  417.         "anime",
  418.         "normal",
  419.         "default"
  420.     );
  421. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement