Advertisement
downloadtaky

functions/cpanelfunction.php

Mar 22nd, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.70 KB | None | 0 0
  1. <!-- This is to show a live preview of modification -- Da qui si lavora per attivare una preview in tempo reale delle modifiche -->
  2. <?php
  3. function appaqua_get_site_preview() {
  4.   check_ajax_referer("site_preview"); ?>
  5.   <iframe id="themepreview" name="themepreview" src="<?php echo get_option('appaqua_pama'); ?>/?preview=1"></iframe>
  6.   <?php die();
  7. };?>
  8. <?php add_action('wp_ajax_site_preview', 'appaqua_get_site_preview');?>
  9. <?php $nonce = wp_create_nonce('site_preview'); ?>
  10. <script type="text/javascript">
  11.     jQuery(document).ready(function () {
  12.         jQuery("#$appaqua_zona1y").change(function() {// if a user changed the y-Axis
  13.             check_preview_refresh();
  14.             }
  15.         );
  16.         jQuery("#$appaqua_zona1x").change(function() {// if a user changed the x-Axis
  17.             check_preview_refresh();
  18.             }
  19.         );
  20.     });
  21.  
  22.     function check_preview_refresh(){
  23.         if (jQuery("#zona1y").val() != '' && jQuery("#zona1x").val() != '' ){
  24.             jQuery.ajax({
  25.                 type: "post",url: "admin-ajax.php",data: { action: 'site_preview', _ajax_nonce: '<?php echo $nonce; ?>' },
  26.                 success: function(html){
  27.                     jQuery("#themepreview").html(html);
  28.                     jQuery("#themepreview").show();
  29.                 }
  30.             });
  31.         }
  32.     }
  33. </script>
  34. <!-- Fine della zona per la preview -- End of Preview Script -->
  35. <?php
  36. // Pannello di controllo inizio
  37. $themename = "Pannello Appartamenti Acquario";  
  38. $shortname = "appaqua";
  39. $categories = get_categories('hide_empty=0&orderby=name');  
  40. $wp_cats = array();  
  41. foreach ($categories as $category_list ) {  
  42.        $wp_cats[$category_list->cat_ID] = $category_list->cat_name;  
  43. }  
  44. array_unshift($wp_cats, "Scegli una categoria");
  45. $options = array (
  46. array( "name" => $themename." Options",
  47.     "type" => "title"),
  48. array( "name" => "Prima di cominciare",
  49.     "type" => "section"),
  50. array( "type" => "open"),
  51. array( "name" => "Link pagina mappa",
  52.     "desc" => "Inserisci il link alla pagina della mappa",
  53.     "id" => $shortname."_pama",
  54.     "type" => "text",
  55.     "std" => "Inserisci il link qui"),
  56. array( "type" => "close"),
  57. array( "name" => "General",
  58.     "type" => "section"),
  59. array( "type" => "open"),
  60. array( "name" => "Logo URL",
  61.     "desc" => "Inserisci il link all'immagine del tuo logo",
  62.     "id" => $shortname."_logo",
  63.     "type" => "text",
  64.     "std" => ""),  
  65. array( "type" => "close"),
  66. array( "name" => "Homepage",
  67.     "type" => "section"),
  68. array( "type" => "open"),
  69. array( "name" => "Homepage Immagine Slide 1",
  70.     "desc" => "Inserisci il link alla prima immagine degli slide",
  71.     "id" => $shortname."_header_img",
  72.     "type" => "text",
  73.     "std" => "http://nextube.info/images/ImmijQuery/image-1.jpg"),
  74. array( "name" => "Homepage Immagine Slide 2",
  75.     "desc" => "Inserisci il link alla seconda immagine degli slide",
  76.     "id" => $shortname."_header_img2",
  77.     "type" => "text",
  78.     "std" => "http://nextube.info/images/ImmijQuery/image-2.jpg"),
  79. array( "name" => "Homepage Immagine Slide 3",
  80.     "desc" => "Inserisci il link alla terza immagine degli slide",
  81.     "id" => $shortname."_header_img3",
  82.     "type" => "text",
  83.     "std" => "http://nextube.info/images/ImmijQuery/image-3.jpg"),
  84. array( "name" => "Homepage Immagine Slide 4",
  85.     "desc" => "Inserisci il link alla quarta immagine degli slide",
  86.     "id" => $shortname."_header_img4",
  87.     "type" => "text",
  88.     "std" => "http://nextube.info/images/ImmijQuery/image-4.jpg"),
  89. array( "name" => "Homepage Immagine Slide 5",
  90.     "desc" => "Inserisci il link alla quinta immagine degli slide",
  91.     "id" => $shortname."_header_img5",
  92.     "type" => "text",
  93.     "std" => "http://nextube.info/images/ImmijQuery/image-5.jpg"),
  94. array( "name" => "Homepage Immagine Slide 6",
  95.     "desc" => "Inserisci il link alla sesta immagine degli slide",
  96.     "id" => $shortname."_header_img6",
  97.     "type" => "text",
  98.     "std" => "http://nextube.info/images/ImmijQuery/image-6.jpg"),
  99. array( "type" => "close"),
  100. array( "name" => "Footer",
  101.     "type" => "section"),
  102. array( "type" => "open"),
  103. array( "name" => "Google Analytics Code",
  104.     "desc" => "Inserisci il tuo codice Google Analytics per tracciare le visite che ricevi.",
  105.     "id" => $shortname."_ga_code",
  106.     "type" => "textarea",
  107.     "std" => ""),
  108. array( "type" => "close"),
  109. array( "name" => "Social",
  110.     "type" => "section"),
  111. array( "type" => "open"),
  112. array( "name" => "Indirizzo Feed",
  113.     "desc" => "Feedburner รจ un sistema fornito da Google per ottimizzare la distribuzione dei tuoi feed, inserisci qui il link al tuo feed",
  114.     "id" => $shortname."_feedburner",
  115.     "type" => "text",
  116.     "std" => get_bloginfo('rss2_url')),
  117. array( "name" => "Facebook URL",
  118.     "desc" => "Inserisci il link alla tua pagina Facebook",
  119.     "id" => $shortname."_facebook",
  120.     "type" => "text",
  121.     "std" => "http://facebook.com/pages/Downloadtaky/325661998362"),
  122. array( "name" => "Twitter URL",
  123.     "desc" => "Inserisci il link al tuo account Twitter",
  124.     "id" => $shortname."_twitter",
  125.     "type" => "text",
  126.     "std" => "http://twitter.com/downloadtaky"),
  127. array( "type" => "close"),
  128. array( "name" => "Punti sulla mappa",
  129.     "type" => "section"),
  130. array( "type" => "open"),
  131. /** Copia da qui per aggiungere un nuovo punti - start copy to add a new point on the map **/
  132. array( "name" => "Zona 1",
  133.     "type" => "section"),
  134. array( "type" => "open"),
  135. array(  "name" => "Attivare zona 1?",
  136.         "desc" => "Seleziona se vuoi il primo fermaposto",
  137.         "id" => $shortname."_zona1c",
  138.         "type" => "checkbox",
  139.         "std" => "false"),
  140. array( "name" => "Zona 1 Asse x",
  141.     "desc" => "Scegli dove posizionare il primo punto, se attivato asse x",
  142.     "id" => $shortname."_zona1x",
  143.     "type" => "text",
  144.     "std" => "Left:???"),
  145. array( "name" => "Zona 1 Asse y",
  146.     "desc" => "Scegli dove posizionare il primo punto, se attivato asse y",
  147.     "id" => $shortname."_zona1y",
  148.     "type" => "text",
  149.     "std" => "Top:???"),
  150.     array( "name" => "Zona 1 URL",
  151.     "desc" => "Inserisci il link al post della zona 1",
  152.     "id" => $shortname."_zona1l",
  153.     "type" => "text",
  154.     "std" => "Indirizzo del post qui"),
  155. array( "type" => "close"),
  156. /** Copia fino a qui e rinomina progressivamente in zona2, zona3, zona4 ecc -- Copy from here to add a new zone like zone3, zone 4 and so on**/
  157. array( "name" => "Zona 2",
  158.     "type" => "section"),
  159. array( "type" => "open"),
  160. array(  "name" => "Attivare zona 2?",
  161.         "desc" => "Seleziona se vuoi il primo fermaposto",
  162.         "id" => $shortname."_zona1c",
  163.         "type" => "checkbox",
  164.         "std" => "false"),
  165. array( "name" => "Zona 2 Asse x",
  166.     "desc" => "Scegli dove posizionare il primo punto, se attivato asse x",
  167.     "id" => $shortname."_zona2x",
  168.     "type" => "text",
  169.     "std" => "Left:???"),
  170. array( "name" => "Zona 2 Asse y",
  171.     "desc" => "Scegli dove posizionare il primo punto, se attivato asse y",
  172.     "id" => $shortname."_zona2y",
  173.     "type" => "text",
  174.     "std" => "Top:???"),
  175.     array( "name" => "Zona 2 URL",
  176.     "desc" => "Inserisci il link al post della zona 2",
  177.     "id" => $shortname."_zona2l",
  178.     "type" => "text",
  179.     "std" => "Indirizzo del post qui"),
  180. array( "type" => "close"),
  181. array( "type" => "close"),
  182. );
  183. function mytheme_add_admin() {
  184. global $themename, $shortname, $options;
  185. if ( $_GET['page'] == basename(__FILE__) ) {
  186.     if ( 'save' == $_REQUEST['action'] ) {
  187.         foreach ($options as $value) {
  188.         update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  189. foreach ($options as $value) {
  190.     if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
  191.     header("Location: admin.php?page=/functions/cpanelfunction.php&saved=true");
  192. die;
  193. }
  194. else if( 'reset' == $_REQUEST['action'] ) {
  195.     foreach ($options as $value) {
  196.         delete_option( $value['id'] ); }
  197.     header("Location: admin.php?page=/functions/cpanelfunction.php&reset=true");
  198. die;
  199. }
  200. }
  201. add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
  202. }
  203. function mytheme_add_init() {
  204. $file_dir=get_bloginfo('template_directory');
  205. wp_enqueue_style("functions",$file_dir."/functions/functions.css", false, "1.0", "all");
  206. wp_enqueue_script("rm_script",$file_dir."/functions/rm_script.js", false, "1.0");
  207. }
  208. function mytheme_admin() {
  209. global $themename, $shortname, $options;
  210. $i=0;
  211. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  212. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';?>
  213. <div class="wrap rm_wrap">
  214. <h2><?php echo $themename; ?> Settings</h2>
  215. <div class="rm_opts">
  216. <form method="post">
  217. <?php foreach ($options as $value) {
  218. switch ( $value['type'] ) {
  219. case "open":
  220. ?>
  221. <?php break;
  222. case "close":
  223. ?>
  224. </div>
  225. </div>
  226. <br />
  227. <?php break;
  228. case "title":
  229. ?>
  230. <p>Per usare facilmente il <?php echo $themename;?> , puoi usare il menu qui sotto.</p>
  231. <?php break;
  232. case 'text':
  233. ?>
  234. <div class="rm_input rm_text">
  235.     <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  236.     <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
  237.  <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  238.  </div>
  239. <?php
  240. break;
  241. case 'textarea':
  242. ?>
  243. <div class="rm_input rm_textarea">
  244.     <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  245.     <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
  246.  <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  247.  </div>
  248. <?php
  249. break;
  250. case 'select':
  251. ?>
  252. <div class="rm_input rm_select">
  253.     <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  254. <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  255. <?php foreach ($value['options'] as $option) { ?>
  256.         <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
  257. </select>
  258.     <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  259. </div>
  260. <?php
  261. break;
  262. case "checkbox":
  263. ?>
  264. <div class="rm_input rm_checkbox">
  265.     <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  266. <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
  267. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  268.     <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  269.  </div>
  270. <?php break;
  271. case "section":
  272. $i++;
  273. ?>
  274. <div class="rm_section">
  275. <div class="rm_title"><h3><img src="<?php bloginfo('template_directory')?>/functions/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Salva modifiche" />
  276. </span><div class="clearfix"></div></div>
  277. <div class="rm_options">
  278. <?php break;
  279. }
  280. }
  281. ?>
  282. <input type="hidden" name="action" value="save" />
  283. </form>
  284. <form method="post">
  285. <p class="submit">
  286. <input name="reset" type="submit" value="Reset" />
  287. <input type="hidden" name="action" value="reset" />
  288. </p>
  289. </form>
  290. <div style="font-size:9px; margin-bottom:10px;">Icons: <a href="http://taytel.deviantart.com/">TayTel</a></div>
  291.  </div>
  292.  <h2>Ecco una preview delle modifiche fatte</h2>
  293.  <iframe src="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_option('appacqua_pama')))); ?>" width="100%" height="600" ></iframe>
  294. <?php
  295. }
  296. ?>
  297. <?php
  298. add_action('admin_init', 'mytheme_add_init');
  299. add_action('admin_menu', 'mytheme_add_admin');
  300. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement