1. ?><?php
  2.  
  3. $themename = "WPSN";
  4. $shortname = "stylewp";
  5.  
  6. $featured = array("Select a Number:","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50");
  7.  
  8. $agi_options = array (
  9.     'welcome' => array (
  10.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Options</h2></div>",
  11.                 "type" => "heading"),
  12.  
  13.   ),
  14.  
  15.     'global' => array (
  16.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Global Options</h2></div>",
  17.                 "type" => "heading"),
  18.  
  19.                 array(  "name" => "Membership Login?",
  20.                         "desc" => "Check to <b>disable</b> the members login area<br /><b>NOTE:</b> To make use of the register & login links you must first enable registrations<br />from your admin general settings page.<br /><br />",
  21.                         "id" => $shortname."_regs",
  22.                         "std" => "true",
  23.                         "type" => "checkbox"),
  24.  
  25.                 array(  "name" => "Disable Drop-Downs?",
  26.                         "desc" => "Check to <b>disable</b> the drop-down functionality of the main menu<br /><br />",
  27.                         "id" => $shortname."_showdropdown",
  28.                         "std" => "true",
  29.                         "type" => "checkbox"),
  30.  
  31.         array(  "name" => "Custom RSS feed",
  32.                 "desc" => "Enter your custom RSS feed URL from services such as <a href=\"http://feedburner.com\" target=\"_blank\">Feedburner</a><br />(or <b>leave blank</b> to use the standard Wordpress RSS feed)<br /><br />",
  33.                 "id" => $shortname."_customrss",
  34.                 "std" => "",
  35.                 "type" => "text"),
  36.  
  37.         array(  "name" => "RSS Link Text",
  38.                 "desc" => "Enter some text to link to your RSS feed<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  39.                 "id" => $shortname."_rsstitle",
  40.                 "std" => "",
  41.                 "type" => "text"),         
  42.  
  43.                 array(  "name" => "Disable Wordpress Logo?",
  44.                         "desc" => "Check to <b>disable</b> the <a href=\"http://wordpress.org\" target=\"_blank\">Wordpress</a> logo in the theme footer<br /><br />",
  45.                         "id" => $shortname."_lovewp",
  46.                         "std" => "true",
  47.                         "type" => "checkbox"),
  48.     ),
  49.  
  50.     'frontpage' => array (
  51.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Frontpage Settings</h2></div>",
  52.                 "type" => "heading"),
  53.  
  54.         array(  "name" => "More News",
  55.                 "desc" => "Edit the 'More News' block title here<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  56.                 "id" => $shortname."_textmorenews",
  57.                 "std" => "",
  58.                 "type" => "text"),
  59.  
  60.         array(  "name" => "Google Ads (left)",
  61.                 "desc" => "Edit the 'Ads by Google' block title here (Banner #4)<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  62.                 "id" => $shortname."_textbanner4",
  63.                 "std" => "",
  64.                 "type" => "text"),
  65.  
  66.         array(  "name" => "Latest Headlines",
  67.                 "desc" => "Edit the 'Latest Headlines' block title here<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  68.                 "id" => $shortname."_textheadlines",
  69.                 "std" => "",
  70.                 "type" => "text"),
  71.  
  72.         array(  "name" => "Photo of the Day",
  73.                 "desc" => "Edit the 'Photo of the Day' block title here<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  74.                 "id" => $shortname."_textphotoday",
  75.                 "std" => "",
  76.                 "type" => "text"),
  77.  
  78.         array(  "name" => "Have You Read?",
  79.                 "desc" => "Edit the 'Have You Read?' block title here<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  80.                 "id" => $shortname."_texthaveu",
  81.                 "std" => "",
  82.                 "type" => "text"),
  83.  
  84.         array(  "name" => "Spotlight",
  85.                 "desc" => "Edit the 'Spotlight' block title here<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  86.                 "id" => $shortname."_textspotlight",
  87.                 "std" => "",
  88.                 "type" => "text"),
  89.  
  90.         array(  "name" => "Google Ads (right)",
  91.                 "desc" => "Edit the 'Ads by Google' block title here (Banner #5)<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  92.                 "id" => $shortname."_textbanner5",
  93.                 "std" => "",
  94.                 "type" => "text"),
  95.     ),
  96.  
  97.     'banner' => array (
  98.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Banner Settings</h2></div>",
  99.                 "type" => "heading"),
  100.  
  101.         array(  "name" => "Banner #1",
  102.                 "desc" => "Add your <b>728*90</b> banner code here, or leave blank to not show this banner<br /><br />",
  103.                 "id" => $shortname."_banner1",
  104.                 "std" => "",
  105.                 "type" => "textarea"),
  106.  
  107.         array(  "name" => "Banner #2",
  108.                 "desc" => "Add your <b>300*66</b> banner code here, or leave blank to not show this banner<br /><br />",
  109.                 "id" => $shortname."_banner2",
  110.                 "std" => "",
  111.                 "type" => "textarea"),
  112.         array(  "name" => "Banner #3",
  113.                 "desc" => "Add your <b>300*250</b> banner code here, or leave blank to not show this banner<br /><br />",
  114.                 "id" => $shortname."_banner3",
  115.                 "std" => "",
  116.                 "type" => "textarea"),
  117.  
  118.         array(  "name" => "Banner #4",
  119.                 "desc" => "Add your <b>336*280</b> banner code here, or leave blank to not show this banner<br /><br />",
  120.                 "id" => $shortname."_banner4",
  121.                 "std" => "",
  122.                 "type" => "textarea"),
  123.  
  124.         array(  "name" => "Banner #5",
  125.                 "desc" => "Add your <b>200*200</b> banner code here, or leave blank to not show this banner<br /><br />",
  126.                 "id" => $shortname."_banner5",
  127.                 "std" => "",
  128.                 "type" => "textarea"),
  129.  
  130.         array(  "name" => "Banner #6",
  131.                 "desc" => "Add your <b>300*250</b> banner code here, or leave blank to not show this banner<br /><br />",
  132.                 "id" => $shortname."_banner6",
  133.                 "std" => "",
  134.                 "type" => "textarea"),
  135.     ),
  136.  
  137.     'livechat' => array (
  138.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Livechat Settings</h2></div>",
  139.                 "type" => "heading"),
  140.  
  141.         array(  "name" => "Chat Code",
  142.                 "desc" => "Enter your <a href=\"http://shoutmix.com\" target=\"_blank\">ShoutMix</a> chatcode here as shown in the user guide<br />(or leave blank to disable <b>all</b> livechat functionality)<br /><br /><b>NOTE:</b> Activating the live chat feature will invalidate the code.<br /><br />",
  143.                 "id" => $shortname."_chatcode",
  144.                 "std" => "",
  145.                 "type" => "textarea"),
  146.  
  147.         array(  "name" => "Chat Link Text",
  148.                 "desc" => "Enter some text to use as the LiveChat toggle text<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  149.                 "id" => $shortname."_livechattitle",
  150.                 "std" => "",
  151.                 "type" => "text"),
  152.  
  153.                 array(  "name" => "Members Only?",
  154.                         "desc" => "Check to make the livechat a <b>members-only</b> feature<br /><br />",
  155.                         "id" => $shortname."_chatregs",
  156.                         "std" => "true",
  157.                         "type" => "checkbox"),
  158.     ),
  159.  
  160.     'video' => array (
  161.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Featured Video</h2></div>",
  162.                 "type" => "heading"),
  163.  
  164.         array(  "name" => "Video Code",
  165.                 "desc" => "Enter your video embed code here, or <b>leave blank</b> to disable<br />(Resize videos to 214* 175)<br /><br />",
  166.                 "id" => $shortname."_videofeat",
  167.                 "std" => "",
  168.                 "type" => "textarea"),
  169.  
  170.         array(  "name" => "Video Title",
  171.                 "desc" => "Enter the video block title text<br />(or <b>leave blank</b> to use the default text)<br /><br />",
  172.                 "id" => $shortname."_videotitle",
  173.                 "std" => "",
  174.                 "type" => "text"),
  175.  
  176.                 array(  "name" => "Members Only?",
  177.                         "desc" => "Check to make the featured video a <b>members-only</b> feature<br /><br />",
  178.                         "id" => $shortname."_videoregs",
  179.                         "std" => "true",
  180.                         "type" => "checkbox"),
  181.     ),
  182.  
  183.     'misc' => array (
  184.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Miscellaneous Settings</h2></div>",
  185.                 "type" => "heading"),
  186.  
  187.         array(  "name" => "META Keywords",
  188.                 "desc" => "Add some keywords that are relevant to your website<br />(seperate with comma's)<br /><br />",
  189.                 "id" => $shortname."_keywords",
  190.                 "std" => "",
  191.                 "type" => "textarea"),
  192.  
  193.         array("name" => "META Description",
  194.                 "desc" => "Enter a description of your site for the search engines<br /><br />",
  195.                 "id" => $shortname."_description",
  196.                 "std" => "",
  197.                 "type" => "textarea"),
  198.  
  199.         array(  "name" => "Google Analytics",
  200.                 "desc" => "Add your Google Analytics tracking code here<br />(or leave blank to not track your stats)<br /><br />",
  201.                 "id" => $shortname."_analytics",
  202.                 "std" => "",
  203.                 "type" => "textarea"),
  204.  
  205.         array(  "name" => "Additional Code",
  206.                 "desc" => "Here you can add code that will be positioned directly <b>after your closing body<br />tag</b> (HTML allowed)<br /><br />",
  207.                 "id" => $shortname."_afterbody",
  208.                 "std" => "",
  209.                 "type" => "textarea"),
  210.     ),
  211.  
  212.     'copyright' => array (
  213.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Copyright Information</h2></div>",
  214.                 "type" => "heading"),
  215.  
  216.         array(  "name" => "Years Protected",
  217.                 "desc" => "Edit the years of copyright<br /><b>EXAMPLE:</b> 1997 - 2009<br /><br />",
  218.                 "id" => $shortname."_crightyear",
  219.                 "std" => "",
  220.                 "type" => "text"),
  221.  
  222.         array(  "name" => "Copyright Holder",
  223.                 "desc" => "Edit the copyright holders name<br /><b>EXAMPLE:</b> Your Company Name<br /><br />",
  224.                 "id" => $shortname."_cright",
  225.                 "std" => "",
  226.                 "type" => "text"),
  227.  
  228.         array(  "name" => "Link Destination",
  229.                 "desc" => "Edit the destination of the copyright holders link<br /><b>EXAMPLE:</b> http://yourcompany.com<br /><br />",
  230.                 "id" => $shortname."_crighturl",
  231.                 "std" => "",
  232.                 "type" => "text"),
  233.  
  234.         array(  "name" => "Your Rights",
  235.                 "desc" => "Edit the rights reserved text<br /><b>EXAMPLE:</b> All rights reserved.<br /><br />",
  236.                 "id" => $shortname."_crightsub",
  237.                 "std" => "",
  238.                 "type" => "text"),
  239.     ),
  240.  
  241.  
  242.  
  243. );
  244.      
  245. function mytheme_add_admin() {
  246.  
  247.     global $themename, $shortname,$menu,$agi_options;
  248.     $arrs =array(
  249.        'mt_agi_manage_page',
  250.        'mt-agi-global-settings-page',
  251.        'mt-agi-frontpage-settings-page',
  252.        'mt-agi-banner-settings-page',
  253.        'mt-agi-livechat-settings-page',
  254.        'mt-agi-video-settings-page',
  255.        'mt-agi-misc-settings-page',
  256.        'mt-agi-copyright-settings-page',
  257.        'mt-agi-page1name-page',
  258.        'mt-agi-page2name-page',
  259.     );
  260.     if ( in_array($_REQUEST['page'],$arrs) ) {
  261.         if ( 'save' == $_REQUEST['action'] ) {
  262.           foreach ($agi_options[$_REQUEST['agi']] as $value) {
  263.                     if($value['type'] != 'multicheck'){
  264.                         update_option( $value['id'], $_REQUEST[ $value['id'] ] );
  265.                     }else{
  266.                         foreach($value['options'] as $mc_key => $mc_value){
  267.                             $up_opt = $value['id'].'_'.$mc_key;
  268.                             update_option($up_opt, $_REQUEST[$up_opt] );
  269.                         }
  270.                     }
  271.                 }
  272.  
  273.                 foreach ($agi_options as $value) {
  274.                     if($value['type'] != 'multicheck'){
  275.                         if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); }
  276.                     }else{
  277.                         foreach($value['options'] as $mc_key => $mc_value){
  278.                             $up_opt = $value['id'].'_'.$mc_key;                    
  279.                             if( isset( $_REQUEST[ $up_opt ] ) ) { update_option( $up_opt, $_REQUEST[ $up_opt ]  ); } else { delete_option( $up_opt ); }
  280.                         }
  281.                     }
  282.                 }
  283.                 //header("Location: themes.php?page=".$_REQUEST['page']."&saved=true");
  284.                // die;
  285.  
  286.         } else if( 'reset' == $_REQUEST['action'] ) {
  287.  
  288.             foreach ($agi_options as $value) {
  289.                 if($value['type'] != 'multicheck'){
  290.                     delete_option( $value['id'] );
  291.                 }else{
  292.                     foreach($value['options'] as $mc_key => $mc_value){
  293.                         $del_opt = $value['id'].'_'.$mc_key;
  294.                         delete_option($del_opt);
  295.                     }
  296.                 }
  297.             }
  298.             //header("Location: themes.php?page=".$_REQUEST['page']."&reset=true");
  299.             //die;
  300.  
  301.         }
  302.     }
  303.  
  304.  
  305.   // Add a new top-level menu (ill-advised):
  306.       add_menu_page('WPSN', 'WPSN', 10, 'mt-agi-global-settings-page', 'mt_agi_global_settings_page');
  307.       unset($menu[90][1]);
  308.       // Global Settings:
  309.       add_submenu_page('mt-agi-global-settings-page', 'Global Options', 'Global Options', 8, 'mt-agi-global-settings-page', 'mt_agi_global_settings_page');
  310.       // Frontpage Settings:
  311.       add_submenu_page('mt-agi-global-settings-page', 'Frontpage Settings', 'Frontpage Settings', 8, 'mt-agi-frontpage-settings-page', 'mt_agi_frontpage_settings_page');
  312.       // Banner Settings:
  313.       add_submenu_page('mt-agi-global-settings-page', 'Banner Settings', 'Banner Settings', 8, 'mt-agi-banner-settings-page', 'mt_agi_banner_settings_page');
  314.       // Livechat Settings:
  315.       add_submenu_page('mt-agi-global-settings-page', 'Livechat Settings', 'Livechat Settings', 8, 'mt-agi-livechat-settings-page', 'mt_agi_livechat_settings_page');
  316.       // Video Settings:
  317.       add_submenu_page('mt-agi-global-settings-page', 'Video Settings', 'Video Settings', 8, 'mt-agi-video-settings-page', 'mt_agi_video_settings_page');
  318.       // Miscellaneous Settings:
  319.       add_submenu_page('mt-agi-global-settings-page', 'Miscellaneous', 'Miscellaneous', 8, 'mt-agi-misc-settings-page', 'mt_agi_misc_settings_page');
  320.   // Copyright Settings:
  321.        add_submenu_page('mt-agi-global-settings-page', 'Copyright Info', 'Copyright Info', 8, 'mt-agi-copyright-settings-page', 'mt_agi_copyright_settings_page');
  322. }
  323.  
  324. function mytheme_admin() {
  325.  
  326.     global $themename, $shortname, $agi_options;
  327.  
  328.     if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  329.     if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  330.    
  331. }
  332.  
  333.  
  334. function mytheme_wp_head() {
  335.     $stylesheet = get_option('stylewp_alt');
  336.     if($stylesheet != ''){?>
  337.  
  338. <?php }
  339. }
  340.  
  341. add_action('wp_head', 'mytheme_wp_head');
  342. add_action('admin_menu', 'mytheme_add_admin');
  343. ?>
  344. <?php function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
  345.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  346.     $content = apply_filters('the_content', $content);
  347.     $content = str_replace(']]>', ']]>', $content);
  348.     $content = strip_tags($content);
  349.  
  350.    if (strlen($_GET['p']) > 0) {
  351.       echo "<p>";
  352.       echo $content;
  353.       echo " <a href='";
  354.       the_permalink();
  355.       echo "'>"."Read More →</a>";
  356.       echo "</p>";
  357.    }
  358.    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
  359.         $content = substr($content, 0, $espacio);
  360.         $content = $content;
  361.         echo "<p>";
  362.         echo $content;
  363.         echo "...";
  364.         echo " <a href='";
  365.  
  366.         the_permalink();
  367.         echo "'>".$more_link_text."</a>";
  368.         echo "</p>";
  369.    }
  370.    else {
  371.       echo "<p>";
  372.  
  373.       echo $content;
  374.       echo " <a href='";
  375.       the_permalink();
  376.       echo "'>"."Read More →</a>";
  377.       echo "</p>";
  378.    }
  379. }
  380.  
  381. /*
  382. function mt_agi_page1_function_callback(){
  383.   global $shortname;
  384.   echo "<script type='text/javascript' src='".get_template_directory_uri()."/main.js'></script>";
  385.  
  386.     $agi_options =  array (
  387.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Option page 1</h2></div>",
  388.                 "type" => "heading"),
  389.        
  390.       array(    "name" => "screenshot",
  391.             "id" => "screenshot",
  392.         'url'=>get_template_directory_uri()."/screenshot.png",
  393.             "type" => "screenshot"),
  394.   );
  395.     agi_template($agi_options,'welcome');
  396. }
  397. function mt_agi_page2_function_callback(){
  398.     $agi_options =  array (
  399.         array(  "name" => "<div style=\"width:100%;font-family: Georgia;\"><h2 style=\"color:#21759B;\">Option page 2</h2></div>",
  400.                 "type" => "heading")
  401.   );
  402.     agi_template($agi_options,'welcome');
  403. }
  404. */
  405.  
  406. function mt_agi_manage_page(){
  407.     global $agi_options;
  408.     agi_template($agi_options['welcome'],'welcome');
  409. }
  410. function mt_agi_global_settings_page(){
  411.     global $agi_options;
  412.     agi_template($agi_options['global'],'global');
  413. }
  414. function mt_agi_frontpage_settings_page(){
  415.     global $agi_options;
  416.     agi_template($agi_options['frontpage'],'frontpage');
  417. }
  418. function mt_agi_banner_settings_page(){
  419.     global $agi_options;
  420.     agi_template($agi_options['banner'],'banner');
  421. }
  422. function mt_agi_livechat_settings_page(){
  423.     global $agi_options;
  424.     agi_template($agi_options['livechat'],'livechat');
  425. }
  426. function mt_agi_video_settings_page(){
  427.     global $agi_options;
  428.     agi_template($agi_options['video'],'video');
  429. }
  430. function mt_agi_misc_settings_page(){
  431.     global $agi_options;
  432.     agi_template($agi_options['misc'],'misc');
  433. }
  434. function mt_agi_copyright_settings_page(){
  435.     global $agi_options;
  436.     agi_template($agi_options['copyright'],'copyright');
  437. }
  438.  
  439.  
  440. function agi_template($options=array(),$agi=''){
  441.   if(count($options)!=1){
  442.   ?><div class="wrap">
  443.  
  444.   <form method="post" action="" enctype="multipart/form-data"><?php
  445. }?><table class="widefat fixed" style="max-width:800px;margin-top:20px;background: #ffffff" cellspacing="0">
  446. <?php
  447. foreach ($options as $value) {
  448.     $class=($class!='alternate')?"alternate":"alternate1";
  449.     switch ( $value['type'] ) {
  450.         case 'file':
  451.         case 'text':
  452.         agi_option_wrapper_header($value,$class);
  453.         ?><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /><?php
  454.         agi_option_wrapper_footer($value);
  455.         break;
  456.         case 'screenshot':
  457.         agi_option_wrapper_header($value,$class);
  458.         ?><p>In order to test screenshot preview roll over the <a href="http://www.cssglobe.com" class="screenshot" rel="<?php echo $value['url']; ?>">Css Globe</a> link.</p><?php
  459.         agi_option_wrapper_footer($value);
  460.         break;
  461.         case 'select':
  462.         agi_option_wrapper_header($value,$style);
  463.         ?><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  464.                     <?php foreach ($value['options'] as $option) { ?>
  465.                     <option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
  466.                     <?php } ?>
  467.         </select><?php
  468.         agi_option_wrapper_footer($value);
  469.         break;
  470.         case 'textarea':
  471.         $ta_options = $value['options'];
  472.         agi_option_wrapper_header($value,$class);
  473.         ?><textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" rows="60"  cols="20" style="width:400px;height:100px;"><?php
  474.             if( get_settings($value['id']) != "") {
  475.                 echo stripslashes(get_settings($value['id']));
  476.             }else{
  477.                 echo $value['std'];
  478.             }?>