HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux sci 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: tpdc (1002)
PHP: 7.4.3-4ubuntu2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/nsci/wp-content/themes/soledad/inc/social-counter/counter-facebook-api.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
if ( ! class_exists( 'Penci_Social_Counter_Facebook_API' ) ):
	class Penci_Social_Counter_Facebook_API {
		public static function get_count( $data, $cache_period ) {

			$page_id        = preg_replace( '/\s+/', '', $data['name'] );
			$facebook_count = get_transient( 'penci_counter_facebook' . $page_id );

			if ( ! $facebook_count ) {

				$counter = self::get_fb_count( $page_id );

				if ( $counter ) { //To update the stored data
					$data['count'] = $counter;
					set_transient( 'penci_counter_facebook' . $page_id, $counter, $cache_period );
				}
			} else {
				$data['count'] = $facebook_count;
			}

			$data['url']  = "https://www.facebook.com/$page_id";
			$data['icon'] = penci_icon_by_ver( 'fab fa-facebook-f' );

			return $data;
		}

		public static function get_fb_count( $name ) {
			$url      = 'https://www.facebook.com/plugins/likebox.php?href=https://facebook.com/' . $name . '&show_faces=true&header=false&stream=false&show_border=false&locale=en_US';
			$response = wp_remote_get( $url, array(
				'timeout' => 20,
			) );
			$pattern  = "/<div class=\"_1drq\" style=\"max-width: 220px;\">(.*?)<\/div>/";
			$counter  = penci_get_the_number( $pattern, $response['body'] );
			if ( $counter ) {
				return (int) $counter;
			} else {
				return 0;
			}
		}
	}

endif;