feed_builder = Container::getInstance()->get(Feed_Builder::class); } public function register() { parent::register(); add_filter( 'sby_localized_settings', [ $this, 'filter_settings_object' ] ); } public static function get_whitespace( $times ) { return str_repeat( ' ', $times ); } public function filter_settings_object( $settings ) { $settings['system_info'] = $this->get_system_info(); $settings['system_info_n'] = str_replace( '
', "\n", $this->get_system_info() ); $settings['feeds'] = Container::getInstance()->get(Feed_Builder::class)->get_feed_list(); return $settings; } public function get_system_info() { $output = ''; // Build the output strings $output .= $this->get_site_n_server_info(); $output .= $this->get_active_plugins_info(); $output .= $this->get_global_settings_info(); $output .= $this->get_feeds_settings_info(); $output .= $this->get_sources_info(); $output .= $this->get_cron_report(); return $output; } /** * Get Site and Server Info * * @since 6.0 * * @return string */ public function get_site_n_server_info() { $allow_url_fopen = ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No'; $php_curl = is_callable( 'curl_init' ) ? 'Yes' : 'No'; $php_json_decode = function_exists( 'json_decode' ) ? 'Yes' : 'No'; $php_ssl = in_array( 'https', stream_get_wrappers(), true ) ? 'Yes' : 'No'; $settings = sby_get_database_settings(); $api_verification_status = get_option('sby_api_key_verification', null); $output = '## SITE/SERVER INFO: ##
'; $output .= 'Plugin Version:' . self::get_whitespace( 11 ) . esc_html( SBY_PLUGIN_NAME ) . '
'; $output .= 'Site URL:' . self::get_whitespace( 17 ) . esc_html( site_url() ) . '
'; $output .= 'Home URL:' . self::get_whitespace( 17 ) . esc_html( home_url() ) . '
'; $output .= 'WordPress Version:' . self::get_whitespace( 8 ) . esc_html( get_bloginfo( 'version' ) ) . '
'; $output .= 'PHP Version:' . self::get_whitespace( 14 ) . esc_html( PHP_VERSION ) . '
'; $output .= 'Web Server Info:' . self::get_whitespace( 10 ) . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . '
'; $output .= 'PHP allow_url_fopen:' . self::get_whitespace( 6 ) . esc_html( $allow_url_fopen ) . '
'; $output .= 'PHP cURL:' . self::get_whitespace( 17 ) . esc_html( $php_curl ) . '
'; $output .= 'JSON:' . self::get_whitespace( 21 ) . esc_html( $php_json_decode ) . '
'; $output .= 'SSL Stream:' . self::get_whitespace( 15 ) . esc_html( $php_ssl ) . '
'; $output .= 'API Key:' . self::get_whitespace( 18 ) . esc_html( isset($settings['api_key']) ? $settings['api_key'] : 'Empty' ) . '
'; $output .= 'API Status:' . self::get_whitespace( 15 ) . esc_html( !empty($api_verification_status) ? ($api_verification_status->status == true ? "Successful" : "Failed") : 'Unknown' ) . '
'; $output .= '
'; return $output; } /** * Get Active Plugins * * @since 6.0 * * @return string */ public function get_active_plugins_info() { $plugins = get_plugins(); $active_plugins = get_option( 'active_plugins' ); $output = '## ACTIVE PLUGINS: ##
'; foreach ( $plugins as $plugin_path => $plugin ) { if ( in_array( $plugin_path, $active_plugins, true ) ) { $output .= esc_html( $plugin['Name'] ) . ': ' . esc_html( $plugin['Version'] ) . '
'; } } $output .= '
'; return $output; } /** * Get Global Settings * * @since 6.0 * * @return string */ public function get_global_settings_info() { $output = '## GLOBAL SETTINGS: ##
'; $sby_license_key = get_option( 'sby_license_key' ); $sby_license_data = get_option( 'sby_license_data' ); $sby_license_status = get_option( 'sby_license_status' ); $sby_settings = get_option( 'settings', array() ); $usage_tracking = get_option( 'sby_usage_tracking', array( 'last_send' => 0, 'enabled' => \sby_is_pro_version(), ) ); $output .= 'License key: '; if ( $sby_license_key ) { $output .= esc_html( $sby_license_key ); } else { $output .= ' Not added'; } $output .= '
'; $output .= 'License status: '; if ( $sby_license_status ) { $output .= $sby_license_status; } else { $output .= ' Inactive'; } $output .= '
'; $output .= 'Preserve settings if plugin is removed: '; $output .= isset( $sby_settings['preserve_settings'] ) && ( $sby_settings['preserve_settings'] ) ? 'Yes' : 'No'; $output .= '
'; $output .= 'Connected Accounts: '; $output .= 'Placeholder!'; $output .= '
'; $output .= 'Caching: '; if ( wp_next_scheduled( 'sby_feed_update' ) ) { $time_format = get_option( 'time_format' ); if ( ! $time_format ) { $time_format = 'g:i a'; } // $schedule = wp_get_schedule( 'sby_feed_update' ); if ( $schedule === '30mins' ) { $schedule = __( 'every 30 minutes', 'feeds-for-youtube' ); } if ( $schedule === 'twicedaily' ) { $schedule = __( 'every 12 hours', 'feeds-for-youtube' ); } $sby_next_cron_event = wp_next_scheduled( 'sby_feed_update' ); $output = __( 'Next check', 'feeds-for-youtube' ) . ': ' . gmdate( $time_format, $sby_next_cron_event + sby_get_utc_offset() ) . ' (' . $schedule . ')'; } else { $output .= 'Nothing currently scheduled'; } $output .= '
'; $output .= 'GDPR: '; $output .= isset( $sby_settings['gdpr'] ) ? $sby_settings['gdpr'] : ' Not setup'; $output .= '
'; $output .= 'Custom CSS: '; $output .= isset( $sby_settings['custom_css'] ) && ! empty( $sby_settings['custom_css'] ) ? $sby_settings['custom_css'] : 'Empty'; $output .= '
'; $output .= 'Custom JS: '; $output .= isset( $sby_settings['custom_js'] ) && ! empty( $sby_settings['custom_js'] ) ? $sby_settings['custom_js'] : 'Empty'; $output .= '
'; $output .= 'Usage Tracking: '; $output .= isset( $usage_tracking['enabled'] ) && $usage_tracking['enabled'] === true ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'AJAX theme loading fix: '; $output .= isset( $sby_settings['ajax_theme'] ) && $sby_settings['ajax_theme'] ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'AJAX Initial: '; $output .= isset( $sby_settings['sb_ajax_initial'] ) && $sby_settings['sb_ajax_initial'] === true ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'Enqueue in Head: '; $output .= isset( $sby_settings['enqueue_js_in_head'] ) && $sby_settings['enqueue_js_in_head'] === true ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'Disable WP Posts: '; $output .= !empty($sby_settings['disable_wp_posts']) ? 'True' : 'False';; $output .= '
'; $output .= 'Enqueue in Shortcode: '; $output .= isset( $sby_settings['enqueue_css_in_shortcode'] ) && $sby_settings['enqueue_css_in_shortcode'] === true ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'Enable JS Image: '; $output .= isset( $sby_settings['disable_js_image_loading'] ) && $sby_settings['disable_js_image_loading'] === false ? 'Enabled' : 'Disabled'; $output .= '
'; $output .= 'Admin Error Notice: '; $output .= isset( $sby_settings['disable_admin_notice'] ) && $sby_settings['disable_admin_notice'] === false ? 'Enabled' : 'Disabled'; $output .= '
'; return $output; } /** * Get Feeds Settings * * @since 6.0 * * @return string */ public function get_feeds_settings_info() { $output = '## FEEDS: ##
'; $feeds_list = $this->feed_builder->get_feed_list(); $i = 0; foreach ( $feeds_list as $feed ) { $settings = json_decode($feed['settings'], true); $type = ! empty( $settings['type'] ) ? $settings['type'] : 'channel'; if ( $i >= 25 ) { break; } $output .= $feed['feed_name']; $output .= '
'; if ( isset( $feed['location_summary'] ) && count( $feed['location_summary'] ) > 0 ) { $first_feed = $feed['location_summary'][0]; if ( ! empty( $first_feed['link'] ) ) { $output .= esc_html( $first_feed['link'] ) . '?sb_debug'; $output .= '
'; } } if ( $i < ( count( $feeds_list ) - 1 ) ) { $output .= '
'; } $i++; } $output .= '
'; return $output; } /** * Get Feeds Settings * * @since 6.0 * * @return string */ public function get_sources_info() { $output = '## Sources: ##
'; foreach ( [] as $source ) { $output .= $source['account_id']; $output .= '
'; $output .= 'Type: ' . esc_html( $source['account_type'] ); $output .= '
'; $output .= 'Username: ' . esc_html( $source['username'] ); $output .= '
'; $output .= 'Error: ' . esc_html( $source['error'] ); $output .= '
'; $output .= '
'; $output .= '
'; } $output .= '
'; return $output; } /** * Get Reports * * @since 6.0 * * @return string */ public function get_cron_report() { $output = '## Cron Cache Report: ##
'; $cron_report = get_option( 'sby_cron_report', array() ); if ( ! empty( $cron_report ) ) { $output .= 'Time Ran: ' . esc_html( $cron_report['notes']['time_ran'] ); $output .= '
'; $output .= 'Found Feeds: ' . esc_html( $cron_report['notes']['num_found_transients'] ); $output .= '
'; $output .= '
'; foreach ( $cron_report as $key => $value ) { if ( $key !== 'notes' ) { $output .= esc_html( $key ) . ':'; $output .= '
'; if ( ! empty( $value['last_retrieve'] ) ) { $output .= 'Last Retrieve: ' . esc_html( $value['last_retrieve'] ); $output .= '
'; } $output .= 'Did Update: ' . esc_html( $value['did_update'] ); $output .= '
'; $output .= '
'; } } } else { $output .= '
'; } $cron = _get_cron_array(); foreach ( $cron as $key => $data ) { $is_target = false; foreach ( $data as $key2 => $val ) { if ( strpos( $key2, 'sby' ) !== false || strpos( $key2, 'sb_youtube' ) !== false ) { $is_target = true; $output .= esc_html( $key2 ); $output .= '
'; } } if ( $is_target ) { $output .= esc_html( date( 'Y-m-d H:i:s', $key ) ); $output .= '
'; $output .= esc_html( 'Next Scheduled: ' . round( ( (int) $key - time() ) / 60 ) . ' minutes' ); $output .= '
'; $output .= '
'; } } return $output; } }