Changeset 2215734
- Timestamp:
- 12/20/2019 02:06:19 PM (6 years ago)
- Location:
- libsyn-podcasting/trunk
- Files:
-
- 5 edited
-
admin/functions.php (modified) (3 diffs)
-
admin/lib/Libsyn.php (modified) (1 diff)
-
admin/lib/Libsyn/Service.php (modified) (3 diffs)
-
admin/lib/Libsyn/Service/Logger.php (modified) (16 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libsyn-podcasting/trunk/admin/functions.php
r2213760 r2215734 719 719 if ( !empty( $showId ) ) { 720 720 $show = $plugin->getShow( $api, $api->getShowId() ); 721 $showTitle = $show->{'user-shows'}->show_title; 722 wp_add_dashboard_widget('libsyn_stats_summary', __('Libsyn Publisher Hub Stats for ' . $showTitle, 'libsyn-podcasting'), 'display_libsyn_stats_summary'); 721 if ( !empty($show) ) { 722 $showTitle = $show->{'user-shows'}->show_title; 723 wp_add_dashboard_widget('libsyn_stats_summary', __('Libsyn Publisher Hub Stats for ' . $showTitle, 'libsyn-podcasting'), 'display_libsyn_stats_summary'); 724 } 723 725 } 724 726 } catch ( Exception $e ) { … … 742 744 if ( !empty( $totalShowDownloads ) ) { 743 745 $statsShowThreeMonth = $plugin->getStatsShowThreeMonth($api, $api->getShowId()); 744 $monthArr = array_reverse( $statsShowThreeMonth->stats_show_three_month->show_three_month ); 745 746 $displayMonthArr = array(); 746 if ( !empty($statsShowThreeMonth) && !empty($statsShowThreeMonth->stats_show_three_month) ) { 747 $monthArr = array_reverse( $statsShowThreeMonth->stats_show_three_month->show_three_month ); 748 } else { 749 $monthArr = array(); 750 } 751 752 $displayShowMonthArr = array(); 747 753 foreach ( $monthArr as $monthObj ) { 748 754 $displayShowMonthArr[] = array( … … 823 829 } 824 830 825 function displayStatsIfPresent($statsArr , $offset, $key) {826 if ( array_key_exists( $offset, $statsArr ) ) {831 function displayStatsIfPresent($statsArr = array(), $offset = 0, $key = '') { 832 if ( ( !empty($statsArr) && !empty($key) ) && array_key_exists( $offset, $statsArr ) ) { 827 833 if ( array_key_exists( $key, $statsArr[$offset] ) ) { 828 834 return $statsArr[$offset][$key]; -
libsyn-podcasting/trunk/admin/lib/Libsyn.php
r2213760 r2215734 4 4 protected $text_dom = LIBSYN_TEXT_DOMAIN; 5 5 protected $plugin_name = "Libsyn/Wordpress"; 6 protected $plugin_version = "1.2.2. 5";6 protected $plugin_version = "1.2.2.6"; 7 7 protected $api_table_name = "libsyn_podcast_plugin"; 8 8 protected $api_base_uri = "https://api.libsyn.com"; -
libsyn-podcasting/trunk/admin/lib/Libsyn/Service.php
r2213760 r2215734 88 88 $logFilePath = $this->plugin_admin_dir . $this->text_dom.'.log'; 89 89 $data = ''; 90 if ( function_exists('wp_is_writable') ) { 91 $loggerWritable = wp_is_writable($logFilePath); 92 } else { 93 $loggerWritable = is_writable($logFilePath); 94 } 95 90 96 if ( file_exists($logFilePath) ) { 91 if ( is_writable($logFilePath)) {97 if ( $loggerWritable ) { 92 98 //check log file last modified and clear if older than a week 93 99 if ( $this->wp_time - (60*24*7) >= filemtime($logFilePath) ) { … … 109 115 fwrite($logFile, $data); 110 116 fclose($logFile); 111 chmod($logFilePath, 0777);117 @chmod($logFilePath, 0777); 112 118 } catch (Exception $e) { 113 119 //do nothing … … 115 121 } 116 122 117 //NOTE: We could use the logger FP as a directory also and then it will create auto date filename logs. (just pass directory instead of file below) 118 if ( ( function_exists('wp_is_writable') && wp_is_writable($logFilePath) ) || is_writable($logFilePath) ) { 123 if ( !isset($this->logger) ) { 124 $this->logger = false; 125 } 126 if ( !isset($this->loggerFP) ) { 127 $this->loggerFP = false; 128 } 129 130 if ( $loggerWritable ) { 119 131 try { 120 if ( !empty($logFilePath) ) {132 if ( !empty($logFilePath) && is_string($logFilePath) ) { 121 133 $this->logger = new \Libsyn\Service\Logger($logFilePath, $this->text_dom); 122 134 $this->loggerFP = $logFilePath; 123 } else {124 $this->logger = false;125 $this->loggerFP = false;126 135 } 127 136 } catch (Exception $e) { 128 $this->logger = false; 129 $this->loggerFP = false; 137 //Cannot Log error, no logs. 130 138 } 131 } else { 132 $this->logger = false; 133 $this->loggerFP = false; 134 } 135 } else { 136 $this->logger = false; 137 $this->loggerFP = false; 139 } 138 140 } 139 141 -
libsyn-podcasting/trunk/admin/lib/Libsyn/Service/Logger.php
r2112228 r2215734 53 53 const LOG_LEVEL_NONE = 'none'; 54 54 55 55 56 56 /** 57 57 * Logger constructor … … 62 62 * @param string $log_level (optional) Lowest log level to log. 63 63 */ 64 public function __construct( string $log_file, string $channel, string$log_level = null) {64 public function __construct($log_file, $channel, $log_level = null) { 65 65 $this->log_file = $log_file; 66 66 $this->channel = $channel; … … 88 88 * @param string $log_level 89 89 */ 90 public function setLogLevel( string$log_level) {90 public function setLogLevel($log_level) { 91 91 if (!array_key_exists($log_level, $this->LEVELS)) { 92 92 throw new \DomainException("Log level $log_level is not a valid log level. Must be one of (" . implode(', ', array_keys($this->LEVELS)) . ')'); … … 100 100 * @param string $channel 101 101 */ 102 public function setChannel( string$channel) {102 public function setChannel($channel) { 103 103 $this->channel = $channel; 104 104 } … … 110 110 * @param bool $stdout 111 111 */ 112 public function setOutput( bool$stdout) {112 public function setOutput($stdout) { 113 113 $this->stdout = $stdout; 114 114 } … … 123 123 * @throws \RuntimeException 124 124 */ 125 public function debug($message = '', array$data = null) {125 public function debug($message = '', $data = null) { 126 126 if ($this->logAtThisLevel(LogLevel::DEBUG)) { 127 127 $this->log(LogLevel::DEBUG, $message, $data); … … 138 138 * @throws \RuntimeException 139 139 */ 140 public function info($message = '', array$data = null) {140 public function info($message = '', $data = null) { 141 141 if ($this->logAtThisLevel(LogLevel::INFO)) { 142 142 $this->log(LogLevel::INFO, $message, $data); … … 153 153 * @throws \RuntimeException 154 154 */ 155 public function notice($message = '', array$data = null) {155 public function notice($message = '', $data = null) { 156 156 if ($this->logAtThisLevel(LogLevel::NOTICE)) { 157 157 $this->log(LogLevel::NOTICE, $message, $data); … … 169 169 * @throws \RuntimeException 170 170 */ 171 public function warning($message = '', array$data = null) {171 public function warning($message = '', $data = null) { 172 172 if ($this->logAtThisLevel(LogLevel::WARNING)) { 173 173 $this->log(LogLevel::WARNING, $message, $data); … … 185 185 * @throws \RuntimeException 186 186 */ 187 public function error($message = '', array$data = null) {187 public function error($message = '', $data = null) { 188 188 if ($this->logAtThisLevel(LogLevel::ERROR)) { 189 189 $this->log(LogLevel::ERROR, $message, $data); … … 200 200 * @throws \RuntimeException 201 201 */ 202 public function critical($message = '', array$data = null) {202 public function critical($message = '', $data = null) { 203 203 if ($this->logAtThisLevel(LogLevel::CRITICAL)) { 204 204 $this->log(LogLevel::CRITICAL, $message, $data); … … 216 216 * @throws \RuntimeException 217 217 */ 218 public function alert($message = '', array$data = null) {218 public function alert($message = '', $data = null) { 219 219 if ($this->logAtThisLevel(LogLevel::ALERT)) { 220 220 $this->log(LogLevel::ALERT, $message, $data); … … 232 232 * @throws \RuntimeException 233 233 */ 234 public function emergency($message = '', array$data = null) {234 public function emergency($message = '', $data = null) { 235 235 if ($this->logAtThisLevel(LogLevel::EMERGENCY)) { 236 236 $this->log(LogLevel::EMERGENCY, $message, $data); … … 248 248 * @throws \RuntimeException when log file cannot be opened for writing. 249 249 */ 250 public function log($level, $message = '', array$data = null) {250 public function log($level, $message = '', $data = null) { 251 251 // Build log line 252 252 list($exception, $data) = $this->handleException($data); … … 287 287 * @return array [exception, data (without exception)] 288 288 */ 289 private function handleException( array$data = null) {289 private function handleException($data = null) { 290 290 if (isset($data['exception']) && $data['exception'] instanceof \Throwable) { 291 291 $exception = $data['exception']; … … 331 331 * @return string 332 332 */ 333 private function formatLogLine( string $level, string $message, string $data, string$exception_data) {333 private function formatLogLine($level, $message, $data, $exception_data) { 334 334 return 335 335 $this->getTime() . self::TAB . -
libsyn-podcasting/trunk/readme.txt
r2213760 r2215734 4 4 Requires at least: 4.0 5 5 Requires PHP: 5.4 6 Tested up to: 5.3. 17 Stable tag: 1.2.2. 56 Tested up to: 5.3.2 7 Stable tag: 1.2.2.6 8 8 License: GPLv3 or later 9 9 Author URI: https://support.libsyn.com/kb/libsyn-publisher-hub/ … … 48 48 == Changelog == 49 49 50 = 1.2.2.6 = 51 * Misc. compatibility bug fixes. 52 * Testing up to Wordpress 5.3.2 53 50 54 = 1.2.2.5 = 51 55 * Added extra logging information for debug log.
Note: See TracChangeset
for help on using the changeset viewer.