Refactured some spaghetti code.
authorHenryk Gerlach <hgerlach@gmx.de>
Mon, 07 Jul 2008 17:19:11 +0200
changeset 244a602ed5d39
parent 1 a54fe2712ade
child 3 9ff5cad8a79d
Refactured some spaghetti code.
robots-meta.php
     1.1 --- a/robots-meta.php	Thu Jul 03 14:35:05 2008 +0200
     1.2 +++ b/robots-meta.php	Mon Jul 07 17:19:11 2008 +0200
     1.3 @@ -107,172 +107,28 @@
     1.4  				if (!current_user_can('manage_options')) die(__('You cannot edit the Robots Meta options.'));
     1.5  				check_admin_referer('robots-meta-udpatesettings');
     1.6  				
     1.7 -				if (isset($_POST['admin'])) {
     1.8 -					$options['admin'] = true;
     1.9 -				} else {
    1.10 -					$options['admin'] = false;
    1.11 +				foreach (array('admin', 'allfeeds', 'commentfeeds', 'disableauthor', 'disabledate', 
    1.12 +				          'disableexplanation', 'login', 'noindexauthor', 'noindexcat', 'noindexdate', 
    1.13 +					  'noindextag', 'noarchive', 'nofollowcatsingle', 'nofollowcatpage', 
    1.14 +					  'nofollowindexlinks', 'nofollowmeta', 'nofollowmeta', 'nofollowcommentlinks', 
    1.15 +					  'nofollowtaglinks', 'noodp', 'noydir', 'pagedhome', 'search', 'replacemetawidget',
    1.16 +					  'redirectsearch', 'trailingslash') 
    1.17 +				as $option_name) {
    1.18 +					if (isset($_POST[$option_name])) {
    1.19 +						$options[$option_name] = true;
    1.20 +					} else {
    1.21 +						$options[$option_name] = false;
    1.22 +					}
    1.23  				}
    1.24 -
    1.25 -				if (isset($_POST['allfeeds'])) {
    1.26 +			        foreach (array('googleverify', 'msverify', 'yahooverify', 'version') as $option_name) {
    1.27 +					if (isset($_POST[$option_name])) {
    1.28 +						$options[$option_name] = $_POST[$option_name];
    1.29 +					}
    1.30 +				}
    1.31 +                                if ($options['allfeeds']) {
    1.32  					$options['commentfeeds'] = true;
    1.33 -					$options['allfeeds'] = true;
    1.34 -				} else {
    1.35 -					$options['allfeeds'] = false;
    1.36 -				}
    1.37 -
    1.38 -				if (isset($_POST['commentfeeds'])) {
    1.39 -					$options['commentfeeds'] = true;
    1.40 -				} else {
    1.41 -					$options['commentfeeds'] = false;
    1.42 -				}
    1.43 -
    1.44 -				if (isset($_POST['disableauthor'])) {
    1.45 -					$options['disableauthor'] = true;
    1.46 -				} else {
    1.47 -					$options['disableauthor'] = false;
    1.48 -				}
    1.49 -
    1.50 -				if (isset($_POST['disabledate'])) {
    1.51 -					$options['disabledate'] = true;
    1.52 -				} else {
    1.53 -					$options['disabledate'] = false;
    1.54 -				}
    1.55 -
    1.56 -				if (isset($_POST['disableexplanation'])) {
    1.57 -					$options['disableexplanation'] = true;
    1.58 -				} else {
    1.59 -					$options['disableexplanation'] = false;
    1.60 -				}
    1.61 -
    1.62 -				if (isset($_POST['login'])) {
    1.63 -					$options['login'] = true;
    1.64 -				} else {
    1.65 -					$options['login'] = false;
    1.66 -				}
    1.67 -
    1.68 -				if (isset($_POST['noindexauthor'])) {
    1.69 -					$options['noindexauthor'] = true;
    1.70 -				} else {
    1.71 -					$options['noindexauthor'] = false;
    1.72 -				}
    1.73 -
    1.74 -				if (isset($_POST['noindexcat'])) {
    1.75 -					$options['noindexcat'] = true;
    1.76 -				} else {
    1.77 -					$options['noindexcat'] = false;
    1.78 -				}
    1.79 -
    1.80 -				if (isset($_POST['noindexdate'])) {
    1.81 -					$options['noindexdate'] = true;
    1.82 -				} else {
    1.83 -					$options['noindexdate'] = false;
    1.84 -				}
    1.85 +				} 
    1.86  				
    1.87 -				if (isset($_POST['noindextag'])) {
    1.88 -					$options['noindextag'] = true;
    1.89 -				} else {
    1.90 -					$options['noindextag'] = false;
    1.91 -				}
    1.92 -
    1.93 -				if (isset($_POST['noarchive'])) {
    1.94 -					$options['noarchive'] = true;
    1.95 -				} else {
    1.96 -					$options['noarchive'] = false;
    1.97 -				}
    1.98 -
    1.99 -				if (isset($_POST['nofollowcatsingle'])) {
   1.100 -					$options['nofollowcatsingle'] = true;
   1.101 -				} else {
   1.102 -					$options['nofollowcatsingle'] = false;
   1.103 -				}
   1.104 -
   1.105 -				if (isset($_POST['nofollowcatpage'])) {
   1.106 -					$options['nofollowcatpage'] = true;
   1.107 -				} else {
   1.108 -					$options['nofollowcatpage'] = false;
   1.109 -				}
   1.110 -
   1.111 -				if (isset($_POST['nofollowindexlinks'])) {
   1.112 -					$options['nofollowindexlinks'] = true;
   1.113 -				} else {
   1.114 -					$options['nofollowindexlinks'] = false;
   1.115 -				}
   1.116 -
   1.117 -				if (isset($_POST['nofollowmeta'])) {
   1.118 -					$options['nofollowmeta'] = true;
   1.119 -				} else {
   1.120 -					$options['nofollowmeta'] = false;
   1.121 -				}
   1.122 -
   1.123 -				if (isset($_POST['nofollowcommentlinks'])) {
   1.124 -					$options['nofollowcommentlinks'] = true;
   1.125 -				} else {
   1.126 -					$options['nofollowcommentlinks'] = false;
   1.127 -				}
   1.128 -
   1.129 -				if (isset($_POST['nofollowtaglinks'])) {
   1.130 -					$options['nofollowtaglinks'] = true;
   1.131 -				} else {
   1.132 -					$options['nofollowtaglinks'] = false;
   1.133 -				}
   1.134 -
   1.135 -				if (isset($_POST['noodp'])) {
   1.136 -					$options['noodp'] = true;
   1.137 -				} else {
   1.138 -					$options['noodp'] = false;
   1.139 -				}
   1.140 -
   1.141 -				if (isset($_POST['noydir'])) {
   1.142 -					$options['noydir'] = true;
   1.143 -				} else {
   1.144 -					$options['noydir'] = false;
   1.145 -				}
   1.146 -				
   1.147 -				if (isset($_POST['pagedhome'])) {
   1.148 -					$options['pagedhome'] = true;
   1.149 -				} else {
   1.150 -					$options['pagedhome'] = false;
   1.151 -				}
   1.152 -
   1.153 -				if (isset($_POST['search'])) {
   1.154 -					$options['search'] = true;
   1.155 -				} else {
   1.156 -					$options['search'] = false;
   1.157 -				}
   1.158 -				
   1.159 -				if (isset($_POST['replacemetawidget'])) {
   1.160 -					$options['replacemetawidget'] = true;
   1.161 -				} else {
   1.162 -					$options['replacemetawidget'] = false;
   1.163 -				}
   1.164 -
   1.165 -				if (isset($_POST['redirectsearch'])) {
   1.166 -					$options['redirectsearch'] = true;
   1.167 -				} else {
   1.168 -					$options['redirectsearch'] = false;
   1.169 -				}
   1.170 -
   1.171 -				if (isset($_POST['trailingslash'])) {
   1.172 -					$options['trailingslash'] = true;
   1.173 -				} else {
   1.174 -					$options['trailingslash'] = false;
   1.175 -				}
   1.176 -				
   1.177 -				if (isset($_POST['googleverify'])) {
   1.178 -					$options['googleverify'] = $_POST['googleverify'];
   1.179 -				}
   1.180 -
   1.181 -				if (isset($_POST['msverify'])) {
   1.182 -					$options['msverify'] = $_POST['msverify'];
   1.183 -				}
   1.184 -
   1.185 -				if (isset($_POST['yahooverify'])) {
   1.186 -					$options['yahooverify'] = $_POST['yahooverify'];
   1.187 -				}
   1.188 -
   1.189 -				if (isset($_POST['version'])) {
   1.190 -					$options['version'] = $_POST['version'];
   1.191 -				}
   1.192  				$opt = serialize($options);
   1.193  				update_option('RobotsMeta', $opt);
   1.194  			}