| 1 | <?php |
|---|
| 2 | if ( !defined('SLIMSTATPATH') ) { |
|---|
| 3 | die("Sorry, we do not allow direct or external access."); |
|---|
| 4 | } |
|---|
| 5 | |
|---|
| 6 | class wp_slimstat_ex_options { |
|---|
| 7 | var $page, $admin_url; |
|---|
| 8 | var $tmp_site = array(); |
|---|
| 9 | |
|---|
| 10 | function wp_slimstat_ex_options() { |
|---|
| 11 | global $SlimCfg; |
|---|
| 12 | $this->page = trim($_GET['page']); |
|---|
| 13 | $this->admin_url = get_option('siteurl') . '/wp-content/plugins/' . $SlimCfg->basedir . '/lib/ss-admin'; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | function get_url($page='option') { |
|---|
| 17 | global $SlimCfg; |
|---|
| 18 | switch ($page) { |
|---|
| 19 | default: |
|---|
| 20 | return $SlimCfg->option_page; |
|---|
| 21 | break; |
|---|
| 22 | case 'option': case 'pin': case 'exclusion': case 'permission': case 'site': case 'admin': |
|---|
| 23 | return 'admin.php?page=wp-slimstat-ex-' . $page; |
|---|
| 24 | break; |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | function update_options() { |
|---|
| 29 | global $SlimCfg; |
|---|
| 30 | if (!$SlimCfg->has_cap('manage_slimstat_options')) { |
|---|
| 31 | return; |
|---|
| 32 | } |
|---|
| 33 | if ( !isset($_POST['ssex_op']) || !is_array($_POST['ssex_op']) )// Main Options |
|---|
| 34 | return; |
|---|
| 35 | $intvals = array( 'tracking', 'usepins', 'guesstitle', 'cachelimit', 'limitrows', 'dbmaxage', 'iptohost', 'whois', 'meta', 'time_offset', 'use_ajax', 'nice_titles' ); |
|---|
| 36 | foreach($_POST['ssex_op'] as $key=>$value) { |
|---|
| 37 | $SlimCfg->option[$key] = (in_array($key, $intvals)) ? (int)$value : stripslashes(trim($value)); |
|---|
| 38 | } |
|---|
| 39 | update_option('wp_slimstat_ex', $SlimCfg->option); |
|---|
| 40 | echo '<div class="updated fade"><p>'.__('Wp-SlimStat-Ex options updated', 'wp-slimstat-ex').'</p></div>'; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | function options_page() { |
|---|
| 44 | global $SlimCfg; |
|---|
| 45 | if (!$SlimCfg->has_cap('manage_slimstat_options')) { |
|---|
| 46 | echo '<div class="error fade"><p>'.__('You do not have sufficient permissions to access this page.').'</p></div>'; |
|---|
| 47 | return; |
|---|
| 48 | } |
|---|
| 49 | $this->update_options(); |
|---|
| 50 | ?> |
|---|
| 51 | <div class="wrap"> |
|---|
| 52 | <h2><?php _e('General Options', 'wp-slimstat-ex'); ?></h2> |
|---|
| 53 | <form name="slimstat_option" method="post" action="<?php echo $this->get_url('option'); ?>"> |
|---|
| 54 | <div class="options"> |
|---|
| 55 | <!-- General Options Start --> |
|---|
| 56 | <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table"> |
|---|
| 57 | <tr valign="top"> |
|---|
| 58 | <th width="25%" scope="row"><?php _e('Enable Tracking?:', 'wp-slimstat-ex') ?></th> |
|---|
| 59 | <td><select name="ssex_op[tracking]"> |
|---|
| 60 | <option value="1"<?php selected(1, (int)$SlimCfg->option['tracking']); ?>>enable</option> |
|---|
| 61 | <option value="0"<?php selected(0, (int)$SlimCfg->option['tracking']); ?>>disable</option> |
|---|
| 62 | </select> |
|---|
| 63 | <br /> |
|---|
| 64 | <?php _e('— If you want to track blog visitors select "enable"', 'wp-slimstat-ex') ?></td> |
|---|
| 65 | </tr> |
|---|
| 66 | <?php //if (SLIMSTATDEV === true) { //dev?> |
|---|
| 67 | <tr valign="top"> |
|---|
| 68 | <th width="25%" scope="row"><?php _e('Track Mode:', 'wp-slimstat-ex') ?></th> |
|---|
| 69 | <td><select name="ssex_op[track_mode]"> |
|---|
| 70 | <option value="full"<?php selected('full', $SlimCfg->option['track_mode']); ?>><?php _e('Entire blog', 'wp-slimstat-ex'); ?></option> |
|---|
| 71 | <option value="footer"<?php selected('footer', $SlimCfg->option['track_mode']); ?>><?php _e('Blog pages only', 'wp-slimstat-ex'); ?></option> |
|---|
| 72 | <option value="footer_feed"<?php selected('footer_feed', $SlimCfg->option['track_mode']); ?>><?php _e('Blog pages and feed', 'wp-slimstat-ex'); ?></option> |
|---|
| 73 | </select> |
|---|
| 74 | <br /> |
|---|
| 75 | <?php _e('— If you need stats for REAL visitors, \'Blog pages only\' would be the one.', 'wp-slimstat-ex') ?></td> |
|---|
| 76 | </tr> |
|---|
| 77 | <?php //} ?> |
|---|
| 78 | <tr valign="top"> |
|---|
| 79 | <th width="25%" scope="row"><?php _e('Use Pins?:', 'wp-slimstat-ex') ?></th> |
|---|
| 80 | <td><select name="ssex_op[usepins]"> |
|---|
| 81 | <option value="1"<?php selected(1, (int)$SlimCfg->option['usepins']); ?>>true</option> |
|---|
| 82 | <option value="0"<?php selected(0, (int)$SlimCfg->option['usepins']); ?>>false</option> |
|---|
| 83 | </select> |
|---|
| 84 | <br /> |
|---|
| 85 | <?php _e('— If you want to use Pins select "true"', 'wp-slimstat-ex') ?></td> |
|---|
| 86 | </tr> |
|---|
| 87 | <tr valign="top"> |
|---|
| 88 | <th width="25%" scope="row"><?php _e('Use AJAX?:', 'wp-slimstat-ex') ?></th> |
|---|
| 89 | <td><select name="ssex_op[use_ajax]"> |
|---|
| 90 | <option value="1"<?php selected(1, (int)$SlimCfg->option['use_ajax']); ?>>true</option> |
|---|
| 91 | <option value="0"<?php selected(0, (int)$SlimCfg->option['use_ajax']); ?>>false</option> |
|---|
| 92 | </select> |
|---|
| 93 | <br /> |
|---|
| 94 | <?php _e('— Use "AJAX" or not?. Setting it to false will disable some modules.', 'wp-slimstat-ex') ?></td> |
|---|
| 95 | </tr> |
|---|
| 96 | <?php if ($SlimCfg->option['use_ajax']) { ?> |
|---|
| 97 | <tr valign="top"> |
|---|
| 98 | <th width="25%" scope="row"><?php echo __('Ajax cache limit:', 'wp-slimstat-ex') ?></th> |
|---|
| 99 | <td><input name="ssex_op[cachelimit]" type="text" value="<?php echo $SlimCfg->option['cachelimit']; ?>" size="3" /> |
|---|
| 100 | <?php echo __('minutes', 'wp-slimstat-ex'); ?><br /> |
|---|
| 101 | <?php echo __('— Cache time of Ajax result page by minutes. (disable cache = 0)', 'wp-slimstat-ex') ?></td> |
|---|
| 102 | </tr> |
|---|
| 103 | <?php } ?> |
|---|
| 104 | <tr valign="top"> |
|---|
| 105 | <th width="25%" scope="row"><?php _e('SQL limit rows:', 'wp-slimstat-ex') ?></th> |
|---|
| 106 | <td><input name="ssex_op[limitrows]" type="text" value="<?php echo $SlimCfg->option['limitrows']; ?>" size="3" /> |
|---|
| 107 | <?php _e('rows', 'wp-slimstat-ex'); ?> |
|---|
| 108 | <br /> |
|---|
| 109 | <?php _e('— Limit rows of each modules', 'wp-slimstat-ex') ?> |
|---|
| 110 | </td> |
|---|
| 111 | </tr> |
|---|
| 112 | <tr valign="top"> |
|---|
| 113 | <th width="25%" scope="row"><?php _e('DB max-age:', 'wp-slimstat-ex') ?></th> |
|---|
| 114 | <td><input name="ssex_op[dbmaxage]" type="text" value="<?php echo $SlimCfg->option['dbmaxage']; ?>" size="3" /> |
|---|
| 115 | <?php _e('days', 'wp-slimstat-ex'); ?> |
|---|
| 116 | <br /> |
|---|
| 117 | <?php _e('— Set database max-age by days (disable reduce DB : 0)', 'wp-slimstat-ex') ?> |
|---|
| 118 | <br /> |
|---|
| 119 | <?php _e('— You can reduce DB from ', 'wp-slimstat-ex') ?>"<a href="<?php echo $this->admin_url; ?>/admin.php">ss-admin</a>"<?php _e(' page', 'wp-slimstat-ex') ?> |
|---|
| 120 | </td> |
|---|
| 121 | </tr> |
|---|
| 122 | <tr valign="top"> |
|---|
| 123 | <th width="25%" scope="row"><?php _e('IPTC method:', 'wp-slimstat-ex') ?></th> |
|---|
| 124 | <?php if ($SlimCfg->geoip == 'mysql') { ?> |
|---|
| 125 | <td><ul> |
|---|
| 126 | <?php if ($SlimCfg->external_iptc == 'external') { ?> |
|---|
| 127 | <li><?php _e('You are using external IPTC remote DB', 'wp-slimstat-ex'); ?></li> |
|---|
| 128 | <?php } else { ?> |
|---|
| 129 | <li><?php _e('You are using Mysql IPTC DB', 'wp-slimstat-ex'); ?></li> |
|---|
| 130 | <?php } ?> |
|---|
| 131 | <li><?php _e('You can use GeoIP database(<a href="http://www.maxmind.com/app/geoip_country">GeoIP.dat</a> or <a href="http://www.maxmind.com/app/geolitecity">GeoLiteCity.dat</a>) from <a href="http://www.maxmind.com">MaxMind</a>.', 'wp-slimstat-ex'); ?></li> |
|---|
| 132 | <li><?php _e('As for the GeoSlimStat Pin, it\'s about 100 times faster than remote query (with <a href="http://www.maxmind.com/app/geolitecity">GeoLiteCity.dat</a>)', 'wp-slimstat-ex'); ?></li> |
|---|
| 133 | <li><?php _e('Upload GeoIP database(GeoIP.dat or GeoLiteCity.dat) file to <u>lib/geoip</u> folder, that\'s all', 'wp-slimstat-ex'); ?></li> |
|---|
| 134 | </ul> |
|---|
| 135 | <?php } else { ?> |
|---|
| 136 | <td><ul> |
|---|
| 137 | <?php |
|---|
| 138 | $geo_file = $SlimCfg->geoip == 'city' ? 'GeoLiteCity.dat' : 'GeoIP.dat'; |
|---|
| 139 | $geo_url = 'http://www.maxmind.com/app/' . ($SlimCfg->geoip == 'city' ? 'geolitecity' : 'geoip_country'); |
|---|
| 140 | ?> |
|---|
| 141 | <li><?php printf(__('You are using GeoIP databse(%s)', 'wp-slimstat-ex'), $geo_file); ?></li> |
|---|
| 142 | <li><?php printf(__('You can update your database file every start of month from <a href="http://www.maxmind.com">MaxMind</a>\'s free <a href="%s">GeoIP Source</a> page.', 'wp-slimstat-ex'), $geo_url); ?></li> |
|---|
| 143 | </ul> |
|---|
| 144 | <?php } ?> |
|---|
| 145 | <?php _e('— IP to Country Resource', 'wp-slimstat-ex') ?> |
|---|
| 146 | </td> |
|---|
| 147 | </tr> |
|---|
| 148 | </table> |
|---|
| 149 | <p class="submit"> |
|---|
| 150 | <input type="submit" name="update_options" value="<?php _e('Update Options', 'wp-slimstat-ex') ?> »" /> |
|---|
| 151 | </p> |
|---|
| 152 | <!-- General Options End --> |
|---|
| 153 | </div> |
|---|
| 154 | <div class="options"> |
|---|
| 155 | <!-- Display Options Start --> |
|---|
| 156 | <h3><?php _e('Display Options', 'wp-slimstat-ex'); ?></h3> |
|---|
| 157 | <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table"> |
|---|
| 158 | <tr valign="top"> |
|---|
| 159 | <th width="25%" scope="row"><?php _e('Visit type:', 'wp-slimstat-ex') ?></th> |
|---|
| 160 | <td><select name="ssex_op[visit_type]"> |
|---|
| 161 | <option value="uniques"<?php selected('uniques', $SlimCfg->option['visit_type']); ?>>uniques</option> |
|---|
| 162 | <option value="visits"<?php selected('visits', $SlimCfg->option['visit_type']); ?>>visits</option> |
|---|
| 163 | </select> |
|---|
| 164 | <br /> |
|---|
| 165 | <?php _e('— Select visit type. uniques: count unique ip, visits: 30-minute intervals', 'wp-slimstat-ex') ?></td> |
|---|
| 166 | </tr> |
|---|
| 167 | <tr valign="top"> |
|---|
| 168 | <th width="25%" scope="row"><?php _e('Guess post title?:', 'wp-slimstat-ex') ?></th> |
|---|
| 169 | <td><select name="ssex_op[guesstitle]"> |
|---|
| 170 | <option value="1"<?php selected(1, (int)$SlimCfg->option['guesstitle']); ?>>true</option> |
|---|
| 171 | <option value="0"<?php selected(0, (int)$SlimCfg->option['guesstitle']); ?>>false</option> |
|---|
| 172 | </select> |
|---|
| 173 | <br /> |
|---|
| 174 | <?php _e('— Get post title from resource(page address)', 'wp-slimstat-ex') ?></td> |
|---|
| 175 | </tr> |
|---|
| 176 | <tr valign="top"> |
|---|
| 177 | <th width="25%" scope="row"><?php _e('Get host name?:', 'wp-slimstat-ex') ?></th> |
|---|
| 178 | <td><select name="ssex_op[iptohost]"> |
|---|
| 179 | <option value="1"<?php selected(1, (int)$SlimCfg->option['iptohost']); ?>>true</option> |
|---|
| 180 | <option value="0"<?php selected(0, (int)$SlimCfg->option['iptohost']); ?>>false</option> |
|---|
| 181 | </select> |
|---|
| 182 | <br /> |
|---|
| 183 | <?php _e('— Get host name from remote address', 'wp-slimstat-ex') ?>(IP)</td> |
|---|
| 184 | </tr> |
|---|
| 185 | <tr valign="top"> |
|---|
| 186 | <th width="25%" scope="row"><?php _e('Use Whois link?:', 'wp-slimstat-ex') ?></th> |
|---|
| 187 | <td><select name="ssex_op[whois]"> |
|---|
| 188 | <option value="1"<?php selected(1, (int)$SlimCfg->option['whois']); ?>>true</option> |
|---|
| 189 | <option value="0"<?php selected(0, (int)$SlimCfg->option['whois']); ?>>false</option> |
|---|
| 190 | </select> — |
|---|
| 191 | <select name="ssex_op[whois_db]"> |
|---|
| 192 | <option value="dnsstuff"<?php selected('dnsstuff', $SlimCfg->option['whois_db']); ?>>dnsstuff.com</option> |
|---|
| 193 | <option value="iplookup"<?php selected('iplookup', $SlimCfg->option['whois_db']); ?>>ip-lookup.net</option> |
|---|
| 194 | </select> |
|---|
| 195 | <br /> |
|---|
| 196 | <?php _e('— Use "Whois" link on "Visitors" modules', 'wp-slimstat-ex') ?></td> |
|---|
| 197 | </tr> |
|---|
| 198 | </table> |
|---|
| 199 | <p class="submit"> |
|---|
| 200 | <input type="submit" name="update_options" value="<?php _e('Update Options', 'wp-slimstat-ex') ?> »" /> |
|---|
| 201 | </p> |
|---|
| 202 | <!-- Display Options End --> |
|---|
| 203 | </div> |
|---|
| 204 | <div class="options"> |
|---|
| 205 | <!-- Extra Options Start --> |
|---|
| 206 | <h3><?php _e('Extra Options', 'wp-slimstat-ex'); ?></h3> |
|---|
| 207 | <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table"> |
|---|
| 208 | <tr valign="top"> |
|---|
| 209 | <th width="25%" scope="row"><?php _e('Nice Titles:', 'wp-slimstat-ex') ?></th> |
|---|
| 210 | <td><select name="ssex_op[nice_titles]"> |
|---|
| 211 | <option value="1"<?php selected(1, (int)$SlimCfg->option['nice_titles']); ?>>true</option> |
|---|
| 212 | <option value="0"<?php selected(0, (int)$SlimCfg->option['nice_titles']); ?>>false</option> |
|---|
| 213 | </select> |
|---|
| 214 | <br /> |
|---|
| 215 | <?php _e('— Enable or disable "Nice Titles". Powered by <a href="http://www.dustindiaz.com/sweet-titles-finalized">SweetTitles</a>', 'wp-slimstat-ex') ?></td> |
|---|
| 216 | </tr> |
|---|
| 217 | <tr valign="top"> |
|---|
| 218 | <th width="25%" scope="row"><?php _e('Your server time is:', 'wp-slimstat-ex') ?></th> |
|---|
| 219 | <td><?php echo date('Y-m-d g:i:s a', time()); ?></td> |
|---|
| 220 | </tr> |
|---|
| 221 | <tr valign="top"> |
|---|
| 222 | <th width="25%" scope="row"><?php _e('Time Offset:', 'wp-slimstat-ex') ?></th> |
|---|
| 223 | <td><input name="ssex_op[time_offset]" type="text" value="<?php echo $SlimCfg->option['time_offset']; ?>" size="3" /> |
|---|
| 224 | <?php _e('hours', 'wp-slimstat-ex'); ?> |
|---|
| 225 | <?php _e('— Time offset from server time by hours.(NOT gmt offset)', 'wp-slimstat-ex') ?> |
|---|
| 226 | </td> |
|---|
| 227 | </tr> |
|---|
| 228 | <tr valign="top"> |
|---|
| 229 | <th width="25%" scope="row"><?php _e('Your blog time is:', 'wp-slimstat-ex') ?></th> |
|---|
| 230 | <td><?php echo date('Y-m-d g:i:s a', (time() + ($SlimCfg->option['time_offset'] * 60 * 60))); ?></td> |
|---|
| 231 | </tr> |
|---|
| 232 | </table> |
|---|
| 233 | <p class="submit"> |
|---|
| 234 | <input type="submit" name="update_options" value="<?php _e('Update Options', 'wp-slimstat-ex') ?> »" /> |
|---|
| 235 | </p> |
|---|
| 236 | <!-- Extra Options End --> |
|---|
| 237 | </div> |
|---|
| 238 | </form> |
|---|
| 239 | </div><!-- wrap --> |
|---|
| 240 | <?php |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | function activate_pin($id, &$pin) { |
|---|
| 244 | global $SlimCfg, $wpdb; |
|---|
| 245 | $location = $this->get_url('pin'); |
|---|
| 246 | $pin_file = SLIMSTATPATH . 'pins/'.$pin->name.'/pin.php'; |
|---|
| 247 | if ($pin->active) { |
|---|
| 248 | wp_redirect($location . '&activate=true&msg_code=already_act'); |
|---|
| 249 | exit; |
|---|
| 250 | } |
|---|
| 251 | ob_start(); |
|---|
| 252 | include_once($pin_file); |
|---|
| 253 | if (!class_exists($pin->name)) { |
|---|
| 254 | ob_end_clean(); |
|---|
| 255 | wp_redirect($location . '&activate=false&msg_code=not_compat'); |
|---|
| 256 | exit; |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | $temp_pin = new $pin->name(); |
|---|
| 260 | if ('sspins' != strtolower(get_parent_class($temp_pin))) { |
|---|
| 261 | ob_end_clean(); |
|---|
| 262 | wp_redirect($location . '&activate=false&msg_code=not_compat'); |
|---|
| 263 | exit; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | $compatible = $temp_pin->pin_compatible(); |
|---|
| 267 | if (!$compatible['compatible']) { |
|---|
| 268 | ob_end_clean(); |
|---|
| 269 | wp_redirect($location . '&activate=false&msg_code=not_compat'); |
|---|
| 270 | exit; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | $actions = $temp_pin->pin_actions(); |
|---|
| 274 | if ( $actions['extra_table'] && isset($temp_pin->extra_table) && |
|---|
| 275 | is_array($temp_pin->extra_table) && !empty($temp_pin->extra_table) ) {// dobule check if Pin really needs extra table |
|---|
| 276 | $create_table = SSPins::maybe_create_extra_table($temp_pin->extra_table); |
|---|
| 277 | if (!$create_table) { |
|---|
| 278 | ob_end_clean(); |
|---|
| 279 | wp_redirect($location . '&activate=false'); |
|---|
| 280 | exit; |
|---|
| 281 | } |
|---|
| 282 | } |
|---|
| 283 | $do_action = $temp_pin->activate_action(); |
|---|
| 284 | ob_end_clean(); |
|---|
| 285 | $query = "UPDATE `{$SlimCfg->table_pins}` SET `active` = 1 WHERE id = {$id} LIMIT 1"; |
|---|
| 286 | if ( false === $wpdb->query($query) ) |
|---|
| 287 | wp_redirect($location . '&activate=false'); |
|---|
| 288 | else |
|---|
| 289 | wp_redirect($location . '&activate=true'); |
|---|
| 290 | exit; |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | function deactivate_pin($id, &$pin) { |
|---|
| 294 | global $SlimCfg, $wpdb; |
|---|
| 295 | $location = $this->get_url('pin'); |
|---|
| 296 | $pin_file = SLIMSTATPATH . 'pins/'.$pin->name.'/pin.php'; |
|---|
| 297 | if (!$pin->active) { |
|---|
| 298 | wp_redirect($location . '&deactivate=true&msg_code=already_deact'); |
|---|
| 299 | exit; |
|---|
| 300 | } |
|---|
| 301 | ob_start(); |
|---|
| 302 | @include_once($pin_file); |
|---|
| 303 | if (class_exists($pin->name)) { |
|---|
| 304 | $temp_pin = new $pin->name(); |
|---|
| 305 | if ( 'sspins' == strtolower(get_parent_class($temp_pin)) ) |
|---|
| 306 | $temp_pin->deactivate_action(); |
|---|
| 307 | } |
|---|
| 308 | ob_end_clean(); |
|---|
| 309 | $query = "UPDATE `{$SlimCfg->table_pins}` SET `active` = 0 WHERE id = {$id} LIMIT 1"; |
|---|
| 310 | if ( false === $wpdb->query($query) ) |
|---|
| 311 | wp_redirect($location . '&deactivate=false'); |
|---|
| 312 | else |
|---|
| 313 | wp_redirect($location . '&deactivate=true'); |
|---|
| 314 | exit; |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | function manage_pins() { |
|---|
| 318 | global $SlimCfg, $wpdb; |
|---|
| 319 | if ( !isset($_GET["pinact"]) || $_GET["pinact"] === '' ) |
|---|
| 320 | return; |
|---|
| 321 | $pin_id = (int)$_GET['pinid']; |
|---|
| 322 | $pin_active = (int)$_GET['pinact']; |
|---|
| 323 | $action = $pin_active ? 'activate' : 'deactivate'; |
|---|
| 324 | $location = $this->get_url('pin'); |
|---|
| 325 | // check referer |
|---|
| 326 | check_admin_referer("{$action}-pin_{$pin_id}"); |
|---|
| 327 | |
|---|
| 328 | $pin = SSPins::getPin($pin_id); |
|---|
| 329 | if (!$pin) { |
|---|
| 330 | wp_redirect($location . '&' . $action . '=false&msg_code=invalid_id'); |
|---|
| 331 | exit; |
|---|
| 332 | } |
|---|
| 333 | $pin_file = SLIMSTATPATH . 'pins/'.$pin->name.'/pin.php'; |
|---|
| 334 | if (!file_exists($pin_file)) { |
|---|
| 335 | SSPins::delete_pin("`id` = $pin->id"); |
|---|
| 336 | wp_redirect($location . '&' . $action . '=false&msg_code=no_file'); |
|---|
| 337 | exit; |
|---|
| 338 | } |
|---|
| 339 | if ($pin_active) { |
|---|
| 340 | $this->activate_pin($pin_id, &$pin); |
|---|
| 341 | } else { |
|---|
| 342 | $this->deactivate_pin($pin_id, &$pin); |
|---|
| 343 | } |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | function option_pins() { |
|---|
| 347 | global $SlimCfg; |
|---|
| 348 | // activate or deactivate Pins |
|---|
| 349 | $this->manage_pins(); |
|---|
| 350 | $default_compatible = SSPins::pin_compatible(); |
|---|
| 351 | $code_to_msg = array( |
|---|
| 352 | 'invalid_id' => __('Invalid Pin ID.', 'wp-slimstat-ex'), |
|---|
| 353 | 'no_file' => __('Pin file does not exists.', 'wp-slimstat-ex'), |
|---|
| 354 | 'already_act' => __('Pin already activated.', 'wp-slimstat-ex'), |
|---|
| 355 | 'already_deact' => __('Pin already deactivated.', 'wp-slimstat-ex'), |
|---|
| 356 | 'not_compat' => $default_compatible['message'], |
|---|
| 357 | ); |
|---|
| 358 | $msg = ''; |
|---|
| 359 | if ( isset($_GET['activate']) && '' != $_GET['activate'] ) { |
|---|
| 360 | $msg_class = $_GET['activate'] == 'true' ? 'updated' : 'error'; |
|---|
| 361 | if ( isset($_GET['msg_code']) && isset($code_to_msg[$_GET['msg_code']]) ) |
|---|
| 362 | $msg = $code_to_msg[$_GET['msg_code']]; |
|---|
| 363 | else |
|---|
| 364 | $msg = $_GET['activate'] == 'true' ? __('Pin activated', 'wp-slimstat-ex') : __('Failed to activate Pin', 'wp-slimstat-ex'); |
|---|
| 365 | } else if ( isset($_GET['deactivate']) && '' != $_GET['deactivate'] ) { |
|---|
| 366 | $msg_class = $_GET['deactivate'] == 'true' ? 'updated' : 'error'; |
|---|
| 367 | if ( isset($_GET['msg_code']) && isset($code_to_msg[$_GET['msg_code']]) ) |
|---|
| 368 | $msg = $code_to_msg[$_GET['msg_code']]; |
|---|
| 369 | else |
|---|
| 370 | $msg = $_GET['deactivate'] == 'true' ? __('Pin deactivated', 'wp-slimstat-ex') : __('Failed to deactivate Pin', 'wp-slimstat-ex'); |
|---|
| 371 | } |
|---|
| 372 | if ( '' != $msg ) { |
|---|
| 373 | echo '<div class="'.$msg_class.' fade"><p>'.$msg.'</p></div>'; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | // require_once(SLIMSTATPATH . 'lib/pins.php'); |
|---|
| 377 | SSPins::findPins(); |
|---|
| 378 | $pins = SSPins::_getPins(0,5,true);// get all pins |
|---|
| 379 | $pageurl = $this->get_url('pin'); |
|---|
| 380 | ?> |
|---|
| 381 | <div class="wrap"> |
|---|
| 382 | <h2><?php _e('Manage Pins', 'wp-slimstat-ex') ?></h2> |
|---|
| 383 | <div class="options"> |
|---|
| 384 | <h3><?php _e('Pins', 'wp-slimstat-ex'); ?></h3> |
|---|
| 385 | <?php |
|---|
| 386 | if ( empty($pins) ) { |
|---|
| 387 | echo '<div class="updated"><p>There is no Pins available</p></div>'; |
|---|
| 388 | } else { |
|---|
| 389 | ?> |
|---|
| 390 | <table width="100%" cellpadding="3" cellspacing="3" class="widefat"> |
|---|
| 391 | <thead> |
|---|
| 392 | <tr> |
|---|
| 393 | <th class="vers"><?php _e('ID', 'wp-slimstat-ex'); ?></th> |
|---|
| 394 | <th class="name"><?php _e('Name (version)', 'wp-slimstat-ex'); ?></th> |
|---|
| 395 | <th class="vers"><?php _e('Author', 'wp-slimstat-ex'); ?></th> |
|---|
| 396 | <th class="desc"><?php _e('Description', 'wp-slimstat-ex'); ?></th> |
|---|
| 397 | <th class="togl"><?php _e('Acitve', 'wp-slimstat-ex'); ?></th> |
|---|
| 398 | </tr> |
|---|
| 399 | </thead> |
|---|
| 400 | <tbody id="plugins"> |
|---|
| 401 | <?php |
|---|
| 402 | $alt = ''; |
|---|
| 403 | foreach($pins as $pin) { |
|---|
| 404 | $alt = $alt == ' alternate' ? '' : ' alternate'; |
|---|
| 405 | $class_tr = $pin->active == 1 ? 'active' : 'waitingpin'; |
|---|
| 406 | $class_act = $pin->active == 1 ? 'delete' : 'edit'; |
|---|
| 407 | $act_text = $pin->active == 1 ? __('Deactivate', 'wp-slimstat-ex') : __('Activate', 'wp-slimstat-ex'); |
|---|
| 408 | $action = $pin->active == 1 ? 'deactivate' : 'activate'; |
|---|
| 409 | $act_link = wp_nonce_url($pageurl . "&noheader=true&pinact=".(int)!$pin->active."&pinid={$pin->id}", "{$action}-pin_{$pin->id}"); |
|---|
| 410 | ?> |
|---|
| 411 | <tr class="<?php echo $class_tr . $alt; ?>"> |
|---|
| 412 | <td class="vers"><?php echo $pin->id; ?></td> |
|---|
| 413 | <td class="name"><?php echo $pin->title . " ( " . $pin->version . " )"; ?></td> |
|---|
| 414 | <td class="vers"><a href="<?php echo $pin->url; ?>" title="Author URL"><?php echo $pin->author; ?></a></td> |
|---|
| 415 | <td class="desc" width="50%"><?php echo $pin->text; ?></td> |
|---|
| 416 | <td class="togl action-links"><a class="<?php echo $class_act; ?>" href="<?php echo $act_link; ?>"><?php echo $act_text; ?></a></td> |
|---|
| 417 | </tr> |
|---|
| 418 | <?php |
|---|
| 419 | } /* foreach */ |
|---|
| 420 | ?> |
|---|
| 421 | </tbody> |
|---|
| 422 | </table> |
|---|
| 423 | </div> |
|---|
| 424 | <?php |
|---|
| 425 | $active_pins = SSPins::_getPins(1,5);// get all active pins |
|---|
| 426 | if (empty($active_pins)) |
|---|
| 427 | return; |
|---|
| 428 | $include_pins = SSPins::_incPins(0);// include all active pins - funtionable pins are already included. |
|---|
| 429 | $i = 0; |
|---|
| 430 | $_opt_pins = array(); |
|---|
| 431 | foreach($active_pins as $pin) { |
|---|
| 432 | if (!class_exists($pin->name)) |
|---|
| 433 | continue; |
|---|
| 434 | $_pin{$i} = new $pin->name(); |
|---|
| 435 | if ('sspins' != strtolower(get_parent_class($_pin{$i}))) |
|---|
| 436 | continue; |
|---|
| 437 | $_pin_opt = $_pin{$i}->pin_actions(); |
|---|
| 438 | if (!$_pin_opt['options']) |
|---|
| 439 | continue; |
|---|
| 440 | $_opt_pins[] = array($_pin{$i}, $pin); |
|---|
| 441 | $i++; |
|---|
| 442 | } |
|---|
| 443 | if (empty($_opt_pins)) |
|---|
| 444 | return; |
|---|
| 445 | ?> |
|---|
| 446 | <h3><?php _e('Pin Options', 'wp-slimstat-ex'); ?></h3> |
|---|
| 447 | <?php |
|---|
| 448 | SSPins::update_pin_options($_opt_pins); |
|---|
| 449 | SSPins::pin_option_menu_bar($_opt_pins); |
|---|
| 450 | ?> |
|---|
| 451 | <form name="slimstat_pin_options" id="slimstat_pin_options" method="post" action="<?php echo $this->get_url('pin'); ?>#slimstat_pin_options"> |
|---|
| 452 | <?php |
|---|
| 453 | $first_option = true; |
|---|
| 454 | foreach($_opt_pins as $pin) { |
|---|
| 455 | $display = $first_option ? '' : ' style="display:none;"'; |
|---|
| 456 | $first_option = false; |
|---|
| 457 | ?> |
|---|
| 458 | <div class="options" id="pin_option_<?php echo $pin[1]->id; ?>"<?php echo $display; ?>> |
|---|
| 459 | <h4>[ <?php printf(__('%s Options', 'wp-slimstat-ex'), wp_specialchars($pin[1]->title, 1 |
|---|