Changeset 1496912
- Timestamp:
- 09/16/2016 12:46:35 PM (9 years ago)
- Location:
- the-loyalty-box-woocommerce-rewards-program/trunk
- Files:
-
- 3 edited
-
includes/loyaltybox.inc.php (modified) (4 diffs)
-
includes/wc-loyaltybox-settings.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
the-loyalty-box-woocommerce-rewards-program/trunk/includes/loyaltybox.inc.php
r1182491 r1496912 430 430 return $result; 431 431 } 432 433 /** 434 * logError.435 *436 * A method to log errors information to disk437 *438 * @version 1.0.0439 *440 * @author Double Eye441 *442 * @since 1.0.0443 * @access public444 *445 * @param $info446 * @param bool $first_line447 *448 * @static449 */432 433 /** 434 * logError. 435 * 436 * A method to log errors information to disk 437 * 438 * @version 1.0.0 439 * 440 * @author Double Eye 441 * 442 * @since 1.0.0 443 * @access public 444 * 445 * @param $info 446 * @param bool $first_line 447 * 448 * @static 449 */ 450 450 public static function logError($info, $first_line = false) 451 451 { 452 $option_name = 'wc_settings_tab_loyaltybox_error_logging'; 453 $check_switch = Loyaltybox::check_if_errors_enabled($option_name); 452 454 $log = date('Y-m-d H:i:s.uP')." => ".$info.PHP_EOL; 453 455 if ($first_line) { 454 456 $log = PHP_EOL.PHP_EOL.$log; 455 457 } 456 file_put_contents(LOYALTYBOX_ERROR_LOG, $log, FILE_APPEND); 458 if($check_switch == true){ 459 file_put_contents(LOYALTYBOX_ERROR_LOG, $log, FILE_APPEND); 460 } 457 461 } 458 462 … … 480 484 public static function makeRequest($paramArray = null, $methodCall = null, $getDetails = FALSE) 481 485 { 486 $option_name = 'wc_settings_tab_loyaltybox_request_logging'; 487 $check_switch = Loyaltybox::check_if_errors_enabled($option_name); 482 488 $url = self::$endpoint; 483 489 $time_start = microtime(true); … … 501 507 @ob_clean(); 502 508 $request = $client->__getLastRequest(); 503 file_put_contents(LOYALTYBOX_REQUEST_LOG, " ".$methodCall."-".date('Y-m-d H:i:s.uP')." ".PHP_EOL." ", FILE_APPEND); 504 file_put_contents(LOYALTYBOX_REQUEST_LOG, $request, FILE_APPEND); 505 file_put_contents(LOYALTYBOX_REQUEST_LOG, $resultContent, FILE_APPEND); 509 if($check_switch == true){ 510 file_put_contents(LOYALTYBOX_REQUEST_LOG, " ".$methodCall."-".date('Y-m-d H:i:s.uP')." ".PHP_EOL." ", FILE_APPEND); 511 file_put_contents(LOYALTYBOX_REQUEST_LOG, $request, FILE_APPEND); 512 file_put_contents(LOYALTYBOX_REQUEST_LOG, $resultContent, FILE_APPEND); 513 } 506 514 } 507 515 if ($getDetails) { … … 525 533 } 526 534 } 535 536 /** 537 * On_off_for_error_reporting 538 * 539 * A method to check if the user has enabled error reporting 540 * 541 * @version 1.0.0 542 * 543 * @author Double Eye 544 * 545 * @since 1.0.0 546 * @access public 547 * 548 * @param $option_name 549 * 550 * @static 551 */ 552 public static function check_if_errors_enabled($option_name) 553 { 554 global $wpdb; 555 $values = get_transient( 'special_query_results' ); 556 if ( false === $values ) { 557 // If it wasn't there, then regenerate the data and save the transient 558 $special_query_results = $wpdb->get_results( "SELECT * FROM wp_options WHERE option_name = '$option_name'", OBJECT ); 559 set_transient( 'special_query_results', $special_query_results, HOUR_IN_SECONDS ); 560 $values = get_transient( 'special_query_results' ); 561 } 562 if($values[0]->option_value == 'yes'){ 563 return true; 564 } else { 565 return false; 566 } 567 } 568 527 569 528 570 /** -
the-loyalty-box-woocommerce-rewards-program/trunk/includes/wc-loyaltybox-settings.php
r1169142 r1496912 253 253 'id' => 'wc_settings_tab_loyaltybox_section_end', 254 254 ), 255 'request_logging' => array( 256 'name' => __('Loyaltybox Log Files', 'woocommerce-settings-tab-loyaltybox'), 257 'type' => 'checkbox', 258 'default' => 'no', 259 'show_if_checked' => 'option', 260 'desc' => __( 'Request logging', 'woocommerce-settings-tab-demo' ), 261 'id' => 'wc_settings_tab_loyaltybox_request_logging', 262 ), 263 'error_logging' => array( 264 'type' => 'checkbox', 265 'default' => 'no', 266 'show_if_checked' => 'option', 267 'desc' => __( 'Error logging', 'woocommerce-settings-tab-demo' ), 268 'id' => 'wc_settings_tab_loyaltybox_error_logging', 269 ), 270 'plugin_logging' => array( 271 'type' => 'checkbox', 272 'default' => 'no', 273 'show_if_checked' => 'option', 274 'desc' => __( 'Plugin logging', 'woocommerce-settings-tab-demo' ), 275 'id' => 'wc_settings_tab_loyaltybox_plugin_logging', 276 ), 255 277 ); 256 278 -
the-loyalty-box-woocommerce-rewards-program/trunk/readme.txt
r1468297 r1496912 52 52 == Changelog == 53 53 54 = 1.03 = 55 * Added configuration for logging 56 54 57 = 1.02 = 55 58 * Tested with WordPress 4.5.3 and WooCommerce 2.6.4 … … 60 63 == Upgrade Notice == 61 64 65 = 1.03 = 66 * Added configuration for logging 67 62 68 = 1.02 = 63 69 * Tested with WordPress 4.5.3 and WooCommerce 2.6.4
Note: See TracChangeset
for help on using the changeset viewer.