HEX
Server:
System: Linux aac286ea486c 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 08:51:45 EDT 2026 x86_64
User: root (0)
PHP: 8.2.30
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,disk_free_space,diskfreespace
Upload Files
File: /dom877180/wp-content/plugins/custom-twitter-feeds/inc/Integrations/Analytics/SB_Analytics.php
<?php
/**
 * SB_Analytics plugin integration
 * Class to impelement filters to return
 * data needed in the SB_Analytics plugin
 */

namespace TwitterFeed\Integrations\Analytics;

use TwitterFeed\Builder\CTF_Db;

class SB_Analytics
{
	/**
	 * Summary of current_plugin
	 * @var string
	 */
	private static $current_plugin = 'twitter';


	/**
	 * Summary of __construct
	 */
	public function __construct()
	{
		$this->init();
	}

	/**
	 * Summary of init
	 * @return void
	 */
	public function init()
	{
		//Filter Top Posts
		add_filter(
			'sb_analytics_filter_top_posts',
			[$this, 'filter_top_posts'],
			10,
			3
		);

		//Filter Profile Details
		add_filter(
			'sb_analytics_filter_profile_details',
			[$this, 'filter_profile_details'],
			10,
			3
		);

		//Filter Feed Lists
		add_filter(
			'sb_analytics_filter_feed_list',
			[$this, 'filter_feed_list'],
			10,
			3
		);
	}

	/**
	 * Summary of filter_top_posts
	 *
	 * @param mixed $posts
	 * @param mixed $post_ids
	 * @param mixed $plugin_slug
	 *
	 * @return mixed
	 */
	public function filter_top_posts($posts, $post_ids, $plugin_slug)
	{
		if ($plugin_slug !== self::$current_plugin) {
			return $posts;
		}

		return CTF_Db::get_posts_by_ids($post_ids);
	}

	/**
	 * Summary of filter_profile_details
	 *
	 * @param mixed $profile_details
	 * @param mixed $feed_id
	 * @param mixed $plugin_slug
	 *
	 * @return mixed
	 */
	public function filter_profile_details($profile_details, $feed_id, $plugin_slug)
	{
		if ($plugin_slug !== self::$current_plugin) {
			return $profile_details;
		}

		$source	= CTF_Db::get_feed_source_info($feed_id);
		if (empty($source) || empty($source['name'])) {
			return [];
		}

		return [
			'pluginSlug' => self::$current_plugin,
			'id'         => $source['name'],
			'profile'    => [
				'label'    => $source['name'],
				'imageSrc' => $source['picture']
			]
		];
	}

	/**
	 * Summary of filter_feed_list
	 *
	 * @param mixed $feeds
	 * @param mixed $plugin_slug
	 *
	 * @return mixed
	 */
	public function filter_feed_list($feeds, $plugin_slug)
	{
		if ($plugin_slug !== self::$current_plugin) {
			return $feeds;
		}

		$results = [];
		$db_fees = CTF_Db::all_feeds_query(); //Get All stored Feeds

		//Transform result feed schema
		foreach ($db_fees as $feed) {
			array_push(
				$results,
				[
					'value' => [
						'feed_id' => $feed['id'],
					],
					'label' => $feed['feed_name'],
				]
			);
		}
		return $results;
	}

}