Changeset 1823814
- Timestamp:
- 02/17/2018 12:41:16 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
woo-paytr-taksit-tab/trunk/WoocommercePaytrTaksitTab_OptionsManager.php
r1814019 r1823814 1 1 <?php 2 3 2 class WoocommercePaytrTaksitTab_OptionsManager { 4 3 … … 7 6 } 8 7 8 9 9 public function getOptionMetaData() { 10 10 return array(); 11 11 } 12 12 13 13 14 public function getOptionNames() { 14 15 return array_keys($this->getOptionMetaData()); 15 16 } 16 17 17 18 18 19 protected function initOptions() { 19 20 } 20 21 22 21 23 protected function deleteSavedOptions() { 22 24 $optionMetaData = $this->getOptionMetaData(); 23 25 if (is_array($optionMetaData)) { 24 26 foreach ($optionMetaData as $aOptionKey => $aOptionMeta) { 25 $prefixedOptionName = $this->prefix($aOptionKey); 27 $prefixedOptionName = $this->prefix($aOptionKey); 26 28 delete_option($prefixedOptionName); 27 29 } … … 29 31 } 30 32 33 31 34 public function getPluginDisplayName() { 32 35 return get_class($this); 33 36 } 34 37 38 35 39 public function prefix($name) { 36 40 $optionNamePrefix = $this->getOptionNamePrefix(); … … 41 45 } 42 46 47 43 48 public function &unPrefix($name) { 44 49 $optionNamePrefix = $this->getOptionNamePrefix(); … … 49 54 } 50 55 56 51 57 public function getOption($optionName, $default = null) { 52 $prefixedOptionName = $this->prefix($optionName); 58 $prefixedOptionName = $this->prefix($optionName); 53 59 $retVal = get_option($prefixedOptionName); 54 60 if (!$retVal && $default) { … … 58 64 } 59 65 66 60 67 public function deleteOption($optionName) { 61 $prefixedOptionName = $this->prefix($optionName); 68 $prefixedOptionName = $this->prefix($optionName); 62 69 return delete_option($prefixedOptionName); 63 70 } 64 71 65 72 66 73 public function addOption($optionName, $value) { 67 $prefixedOptionName = $this->prefix($optionName); 74 $prefixedOptionName = $this->prefix($optionName); 68 75 return add_option($prefixedOptionName, $value); 69 76 } 70 77 78 71 79 public function updateOption($optionName, $value) { 72 $prefixedOptionName = $this->prefix($optionName); 80 $prefixedOptionName = $this->prefix($optionName); 73 81 return update_option($prefixedOptionName, $value); 74 82 } 83 84 75 85 public function getRoleOption($optionName) { 76 86 $roleAllowed = $this->getOption($optionName); … … 81 91 } 82 92 93 83 94 protected function roleToCapability($roleName) { 84 95 switch ($roleName) { … … 101 112 } 102 113 114 103 115 public function isUserRoleEqualOrBetterThan($roleName) { 104 116 if ('Anyone' == $roleName) { … … 109 121 } 110 122 123 111 124 public function canUserDoRoleOption($optionName) { 112 125 $roleAllowed = $this->getRoleOption($optionName); … … 117 130 } 118 131 132 119 133 public function createSettingsMenu() { 120 134 $pluginName = $this->getPluginDisplayName(); 121 //create new top-level menu135 122 136 add_menu_page($pluginName . ' Plugin Settings', 123 137 $pluginName, … … 127 141 /*,plugins_url('/images/icon.png', __FILE__)*/); // if you call 'plugins_url; be sure to "require_once" it 128 142 143 129 144 add_action('admin_init', array(&$this, 'registerSettings')); 130 145 } … … 138 153 } 139 154 155 140 156 public function settingsPage() { 141 157 if (!current_user_can('manage_options')) { … … 145 161 $optionMetaData = $this->getOptionMetaData(); 146 162 163 147 164 if ($optionMetaData != null) { 148 165 foreach ($optionMetaData as $aOptionKey => $aOptionMeta) { 149 if (isset($ value[$aOptionKey])) {150 $this->updateOption($aOptionKey, $ value[$aOptionKey]);166 if (isset($[$aOptionKey])) { 167 $this->updateOption($aOptionKey, $[$aOptionKey]); 151 168 } 152 169 } 153 170 } 154 171 172 155 173 $settingsGroup = get_class($this) . '-settings-group'; 156 174 ?> 157 175 <div class="wrap"> 158 159 160 <h2><?php echo $this->getPluginDisplayName(); echo ' '; _e('Ayarları', 'woocommerce-paytr-taksit-tab'); ?></h2> 161 <p>Merchant Id'nizi <a href="https://www.paytr.com/" target="_blank">PayTr</a>'den Öğrenebilirsiniz.</p> 162 <p>Eklenti her türlü destek ve geliştirmeler için <a href="http://www.muratbutun.com/" title="Freelancer Web Tasarımcı" target="_blank" rel="nofollow">Murat Bütün</a> ile <a href="https://www.muratbutun.com/iletisim" target="_blank">iletişime</a> geçebilirisiniz.</p> 176 <h2><?php _e('System Settings', 'woocommerce-paytr-taksit-tab'); ?></h2> 177 <table cellspacing="1" cellpadding="2"><tbody> 178 <tr><td><?php _e('System', 'woocommerce-paytr-taksit-tab'); ?></td><td><?php echo php_uname(); ?></td></tr> 179 <tr><td><?php _e('PHP Version', 'woocommerce-paytr-taksit-tab'); ?></td> 180 <td><?php echo phpversion(); ?> 181 <?php 182 if (version_compare('5.2', phpversion()) > 0) { 183 echo ' <span style="background-color: #ffcc00;">'; 184 _e('(WARNING: This plugin may not work properly with versions earlier than PHP 5.2)', 'woocommerce-paytr-taksit-tab'); 185 echo '</span>'; 186 } 187 ?> 188 </td> 189 </tr> 190 <tr><td><?php _e('MySQL Version', 'woocommerce-paytr-taksit-tab'); ?></td> 191 <td><?php echo $this->getMySqlVersion() ?> 192 <?php 193 echo ' <span style="background-color: #ffcc00;">'; 194 if (version_compare('5.0', $this->getMySqlVersion()) > 0) { 195 _e('(WARNING: This plugin may not work properly with versions earlier than MySQL 5.0)', 'woocommerce-paytr-taksit-tab'); 196 } 197 echo '</span>'; 198 ?> 199 </td> 200 </tr> 201 </tbody></table> 202 203 <h2><?php echo $this->getPluginDisplayName(); echo ' '; _e('Settings', 'woocommerce-paytr-taksit-tab'); ?></h2> 163 204 164 205 <form method="post" action=""> … … 192 233 <p class="submit"> 193 234 <input type="submit" class="button-primary" 194 value="<?php _e(' Ayarlarınızı Kaydedin', 'woocommerce-paytr-taksit-tab') ?>"/>195 </p>235 value="<?php _e('', 'woocommerce-paytr-taksit-tab') ?>"/> 236 </p> 196 237 </form> 197 238 </div> … … 200 241 } 201 242 243 202 244 protected function createFormControl($aOptionKey, $aOptionMeta, $savedOptionValue) { 203 245 if (is_array($aOptionMeta) && count($aOptionMeta) >= 2) { // Drop-down list … … 225 267 } 226 268 } 269 270 227 271 protected function getOptionValueI18nString($optionValue) { 228 272 switch ($optionValue) { … … 247 291 return $optionValue; 248 292 } 293 294 249 295 protected function getMySqlVersion() { 250 296 global $wpdb; … … 256 302 } 257 303 304 258 305 public function getEmailDomain() { 306 259 307 $sitename = strtolower($_SERVER['SERVER_NAME']); 260 308 if (substr($sitename, 0, 4) == 'www.') { … … 264 312 } 265 313 } 314
Note: See TracChangeset
for help on using the changeset viewer.