PluginSilentUpgrader.php
2 weeks ago
PluginSilentUpgraderSkin.php
2 weeks ago
Util.php
2 weeks ago
index.php
2 weeks ago
Util.php
204 lines
| 1 | <?php |
| 2 | |
| 3 | namespace CustomFacebookFeed\Helpers; |
| 4 | |
| 5 | if (!defined('ABSPATH')) { |
| 6 | exit; // Exit if accessed directly |
| 7 | } |
| 8 | |
| 9 | /** |
| 10 | * Class Util. |
| 11 | * Holds utility functions for the plugin. |
| 12 | * |
| 13 | * @package CustomFacebookFeed\Helpers |
| 14 | */ |
| 15 | class Util |
| 16 | { |
| 17 | /** |
| 18 | * Check if the plugin is page is Facebook page. |
| 19 | * |
| 20 | * @return bool |
| 21 | */ |
| 22 | public static function is_fb_page() |
| 23 | { |
| 24 | static $plugin_pages = array( |
| 25 | 'cff-top', |
| 26 | 'cff-feed-builder', |
| 27 | 'cff-settings', |
| 28 | 'cff-oembeds-manager', |
| 29 | 'cff-extensions-manager', |
| 30 | 'cff-about-us', |
| 31 | 'cff-support', |
| 32 | ); |
| 33 | $current_page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
| 34 | return in_array($current_page, $plugin_pages, true); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Check if current page is a specific page. |
| 39 | * |
| 40 | * @return bool |
| 41 | */ |
| 42 | public static function current_page_is($page) |
| 43 | { |
| 44 | $current_screen = get_current_screen(); |
| 45 | return $current_screen !== null && ! empty($current_screen) && strpos($current_screen->id, $page) !== false; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Get other active plugins of Smash Balloon |
| 50 | * |
| 51 | * @since 4.1.9 |
| 52 | */ |
| 53 | public static function get_sb_active_plugins_info() |
| 54 | { |
| 55 | // get the WordPress's core list of installed plugins |
| 56 | if (! function_exists('get_plugins')) { |
| 57 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 58 | } |
| 59 | $installed_plugins = get_plugins(); |
| 60 | |
| 61 | $is_tiktok_installed = false; |
| 62 | $tiktok_plugin = 'feeds-for-tiktok/feeds-for-tiktok.php'; |
| 63 | if (isset($installed_plugins['tiktok-feeds-pro/tiktok-feeds-pro.php'])) { |
| 64 | $is_tiktok_installed = true; |
| 65 | $tiktok_plugin = 'tiktok-feeds-pro/tiktok-feeds-pro.php'; |
| 66 | } elseif (isset($installed_plugins['feeds-for-tiktok/feeds-for-tiktok.php'])) { |
| 67 | $is_tiktok_installed = true; |
| 68 | } |
| 69 | |
| 70 | $is_facebook_installed = false; |
| 71 | $facebook_plugin = 'custom-facebook-feed/custom-facebook-feed.php'; |
| 72 | if ( |
| 73 | isset($installed_plugins['custom-facebook-feed-pro/custom-facebook-feed.php']) |
| 74 | || isset($installed_plugins['custom-facebook-feed/custom-facebook-feed.php']) |
| 75 | ) { |
| 76 | $is_facebook_installed = true; |
| 77 | $facebook_plugin = is_plugin_active('custom-facebook-feed-pro/custom-facebook-feed.php') |
| 78 | ? 'custom-facebook-feed-pro/custom-facebook-feed.php' |
| 79 | : $facebook_plugin; |
| 80 | } |
| 81 | |
| 82 | $is_instagram_installed = false; |
| 83 | $instagram_plugin = 'instagram-feed/instagram-feed.php'; |
| 84 | if ( |
| 85 | isset($installed_plugins['instagram-feed-pro/instagram-feed.php']) |
| 86 | || isset($installed_plugins['instagram-feed/instagram-feed.php']) |
| 87 | ) { |
| 88 | $is_instagram_installed = true; |
| 89 | $instagram_plugin = is_plugin_active('instagram-feed-pro/instagram-feed.php') |
| 90 | ? 'instagram-feed-pro/instagram-feed.php' |
| 91 | : $instagram_plugin; |
| 92 | } |
| 93 | |
| 94 | $is_twitter_installed = false; |
| 95 | $twitter_plugin = 'custom-twitter-feeds/custom-twitter-feed.php'; |
| 96 | |
| 97 | if ( |
| 98 | isset($installed_plugins['custom-twitter-feeds-pro/custom-twitter-feed.php']) |
| 99 | || isset($installed_plugins['custom-twitter-feeds/custom-twitter-feed.php']) |
| 100 | ) { |
| 101 | $is_twitter_installed = true; |
| 102 | $twitter_plugin = is_plugin_active('custom-twitter-feeds-pro/custom-twitter-feed.php') |
| 103 | ? 'custom-twitter-feeds-pro/custom-twitter-feed.php' |
| 104 | : $twitter_plugin; |
| 105 | } |
| 106 | |
| 107 | $is_youtube_installed = false; |
| 108 | $youtube_plugin = 'feeds-for-youtube/youtube-feed.php'; |
| 109 | if ( |
| 110 | isset($installed_plugins['youtube-feed-pro/youtube-feed-pro.php']) |
| 111 | || isset($installed_plugins['feeds-for-youtube/youtube-feed.php']) |
| 112 | ) { |
| 113 | $is_youtube_installed = true; |
| 114 | $youtube_plugin = is_plugin_active('youtube-feed-pro/youtube-feed-pro.php') |
| 115 | ? 'youtube-feed-pro/youtube-feed-pro.php' |
| 116 | : $youtube_plugin; |
| 117 | } |
| 118 | |
| 119 | $is_reviews_installed = false; |
| 120 | $reviews_plugin = 'reviews-feed/sb-reviews.php'; |
| 121 | if ( |
| 122 | isset($installed_plugins['reviews-feed-pro/sb-reviews-pro.php']) |
| 123 | || isset($installed_plugins['reviews-feed/sb-reviews.php']) |
| 124 | ) { |
| 125 | $is_reviews_installed = true; |
| 126 | $reviews_plugin = is_plugin_active('reviews-feed-pro/sb-reviews-pro.php') |
| 127 | ? 'reviews-feed-pro/sb-reviews-pro.php' |
| 128 | : $reviews_plugin; |
| 129 | } |
| 130 | |
| 131 | $is_social_wall_installed = isset($installed_plugins['social-wall/social-wall.php']) ? true : false; |
| 132 | $social_wall_plugin = 'social-wall/social-wall.php'; |
| 133 | |
| 134 | |
| 135 | return array( |
| 136 | 'is_facebook_installed' => $is_facebook_installed, |
| 137 | 'is_instagram_installed' => $is_instagram_installed, |
| 138 | 'is_twitter_installed' => $is_twitter_installed, |
| 139 | 'is_youtube_installed' => $is_youtube_installed, |
| 140 | 'is_reviews_installed' => $is_reviews_installed, |
| 141 | 'is_tiktok_installed' => $is_tiktok_installed, |
| 142 | 'is_social_wall_installed' => $is_social_wall_installed, |
| 143 | 'facebook_plugin' => $facebook_plugin, |
| 144 | 'instagram_plugin' => $instagram_plugin, |
| 145 | 'twitter_plugin' => $twitter_plugin, |
| 146 | 'youtube_plugin' => $youtube_plugin, |
| 147 | 'reviews_plugin' => $reviews_plugin, |
| 148 | 'tiktok_plugin' => $tiktok_plugin, |
| 149 | 'social_wall_plugin' => $social_wall_plugin, |
| 150 | 'installed_plugins' => $installed_plugins |
| 151 | ); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Get the info of the other active plugins of Smash Balloon |
| 156 | * |
| 157 | * @since 4.1.9 |
| 158 | */ |
| 159 | public static function get_smash_plugins_status_info() |
| 160 | { |
| 161 | $plugins = self::get_sb_active_plugins_info(); |
| 162 | |
| 163 | $plugins_status = array( |
| 164 | 'instagram' => array( |
| 165 | 'installed' => $plugins['is_instagram_installed'], |
| 166 | 'active' => is_plugin_active($plugins['instagram_plugin']), |
| 167 | 'plugin_file' => $plugins['instagram_plugin'] |
| 168 | ), |
| 169 | 'facebook' => array( |
| 170 | 'installed' => $plugins['is_facebook_installed'], |
| 171 | 'active' => is_plugin_active($plugins['facebook_plugin']), |
| 172 | 'plugin_file' => $plugins['facebook_plugin'] |
| 173 | ), |
| 174 | 'twitter' => array( |
| 175 | 'installed' => $plugins['is_twitter_installed'], |
| 176 | 'active' => is_plugin_active($plugins['twitter_plugin']), |
| 177 | 'plugin_file' => $plugins['twitter_plugin'] |
| 178 | ), |
| 179 | 'youtube' => array( |
| 180 | 'installed' => $plugins['is_youtube_installed'], |
| 181 | 'active' => is_plugin_active($plugins['youtube_plugin']), |
| 182 | 'plugin_file' => $plugins['youtube_plugin'] |
| 183 | ), |
| 184 | 'social_wall' => array( |
| 185 | 'installed' => $plugins['is_social_wall_installed'], |
| 186 | 'active' => is_plugin_active($plugins['social_wall_plugin']), |
| 187 | 'plugin_file' => $plugins['social_wall_plugin'] |
| 188 | ), |
| 189 | 'tiktok' => array( |
| 190 | 'installed' => $plugins['is_tiktok_installed'], |
| 191 | 'active' => is_plugin_active($plugins['tiktok_plugin']), |
| 192 | 'plugin_file' => $plugins['tiktok_plugin'] |
| 193 | ), |
| 194 | 'reviews' => array( |
| 195 | 'installed' => $plugins['is_reviews_installed'], |
| 196 | 'active' => is_plugin_active($plugins['reviews_plugin']), |
| 197 | 'plugin_file' => $plugins['reviews_plugin'] |
| 198 | ) |
| 199 | ); |
| 200 | |
| 201 | return $plugins_status; |
| 202 | } |
| 203 | } |
| 204 |