Plugin Directory

Changeset 3321154


Ignore:
Timestamp:
07/02/2025 11:06:03 AM (8 months ago)
Author:
aryans
Message:
  • Improved Google Analytics Detection
Location:
site-suggest
Files:
32 added
3 edited

Legend:

Unmodified
Added
Removed
  • site-suggest/trunk/app/info-controller.php

    r3318243 r3321154  
    413413        }
    414414
     415
     416        public function get_active_heavy_plugin_categories() {
     417            if ( ! function_exists( 'is_plugin_active' ) ) {
     418                include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
     419            }
     420
     421            $active_plugin_categories = array();
     422
     423            // Define known memory-intensive plugins by their main file path relative to wp-content/plugins/
     424            $heavy_plugins = array(
     425                'page_builder' => array(
     426                    'elementor/elementor.php',
     427                    'js_composer/js_composer.php', // WPBakery Page Builder
     428                    'divi-builder/divi-builder.php',
     429                    'beaver-builder-lite-version/fl-builder.php',
     430                    'fl-builder/fl-builder.php', // Beaver Builder Pro
     431                    'oxygen/oxygen.php', // Oxygen Builder
     432                ),
     433                'multilingual' => array(
     434                    'sitepress-multilingual-cms/sitepress.php', // WPML
     435                    'polylang/polylang.php',
     436                    'translatepress-multilingual/index.php',
     437                ),
     438                'ecommerce' => array(
     439                    'woocommerce/woocommerce.php',
     440                ),
     441                'complex_utility' => array( // E.g., backups, advanced security, image optimization
     442                    'updraftplus/updraftplus.php',
     443                    'smush/smush.php',
     444                    'wordfence/wordfence.php',
     445                    'imagify/imagify.php',
     446                    'buddypress/bp-loader.php',
     447                    'sfwd-lms/sfwd-lms.php',
     448                ),
     449                // Add more categories and plugin paths as you identify them
     450            );
     451
     452            foreach ( $heavy_plugins as $category => $plugin_paths ) {
     453                foreach ( $plugin_paths as $path ) {
     454                    if ( is_plugin_active( $path ) ) {
     455                        $active_plugin_categories[] = $category;
     456                        break; // Found one in this category, move to next category
     457                    }
     458                }
     459            }
     460            return array_unique( $active_plugin_categories ); // Ensure unique categories
     461        }
     462
     463        public function determine_suggested_memory_limit() {
     464            $suggested_limit = 128; // MB - Baseline for a basic WordPress site
     465
     466            $active_heavy_plugin_categories = $this->get_active_heavy_plugin_categories();
     467
     468            // Adjust based on identified heavy plugin categories
     469            if ( in_array( 'page_builder', $active_heavy_plugin_categories ) ) {
     470                $suggested_limit = max( $suggested_limit, 512 ); // Page builders are very memory intensive
     471            }
     472            if ( in_array( 'multilingual', $active_heavy_plugin_categories ) ) {
     473                $suggested_limit = max( $suggested_limit, 256 ); // Multilingual adds significant overhead
     474            }
     475            if ( in_array( 'ecommerce', $active_heavy_plugin_categories ) ) {
     476                $suggested_limit = max( $suggested_limit, 256 ); // WooCommerce can be memory hungry
     477            }
     478            if ( in_array( 'complex_utility', $active_heavy_plugin_categories ) ) {
     479                // If multiple complex utility plugins, might need higher, but start with an increment.
     480                $suggested_limit = max( $suggested_limit, 128 ); // Add a bit more for these
     481            }
     482
     483            if ( in_array( 'page_builder', $active_heavy_plugin_categories ) && in_array( 'multilingual', $active_heavy_plugin_categories ) ) {
     484                $suggested_limit = max( $suggested_limit, 1024 );
     485            }
     486
     487           
     488            $heavy_themes = array(
     489                ["name" => 'Bricks', 'memory' => 256],
     490                ["name" => 'Divi', 'memory' => 256],
     491            );
     492
     493            $theme = wp_get_theme();
     494            $theme_name = $theme->name;
     495            if(!empty($heavy_themes)){
     496                foreach($heavy_themes as $heavy_theme){
     497                    if($theme_name == $heavy_theme['name']){
     498                        $suggested_limit = max($suggested_limit, $heavy_theme['memory']);
     499                        break;
     500                    }
     501                }
     502            }
     503
     504            // Ensure suggested limit is a common increment
     505            // You can define common increments if you prefer: 128, 256, 512, 768, 1024
     506            if ($suggested_limit > 512 && $suggested_limit <= 768) {
     507                $suggested_limit = 768;
     508            } elseif ($suggested_limit > 768) {
     509                $suggested_limit = 1024;
     510            }
     511
     512
     513            // Consider the current environment (e.g., multisite might need more)
     514            if ( is_multisite() ) {
     515                $suggested_limit = max( $suggested_limit, 512 );
     516            }
     517
     518            return $suggested_limit;
     519        }
     520
    415521        public function ss_convert_to_mb($size) {
    416522            $unit = strtoupper(substr($size, -1));
     
    427533        public function check_memory_limit_suggestion(){
    428534            $current_limit = ini_get('memory_limit');
     535            $real_peak_used_memory = get_option('stsgt_peak_memory_limit', 0);
     536
    429537            $current_mb = $this->ss_convert_to_mb($current_limit);
    430             $recommended = 256;
     538            $recommended = $this->determine_suggested_memory_limit();
    431539           
     540            $recommended = max(($real_peak_used_memory * 1.5), $recommended);
     541
     542            $peak_memory_text = 'Peak Usage - '.$real_peak_used_memory.'M';
    432543            $sgst_limit = '';
    433544            if($current_mb < $recommended){
    434                 $sgst_limit = 'Should increase current memory limit (Current '.$current_mb.')';
     545                $sgst_limit = 'Should increase current memory limit to '.$recommended.'M , (Current '.$current_mb.'M). '.$peak_memory_text;
    435546            }else{
    436                 $sgst_limit = 'Current Limit '.$current_mb;
     547                $sgst_limit = 'Current Limit is '.$current_mb.'M , which more than recomended '.$recommended.'M. '.$peak_memory_text;
    437548            }
    438549            return $sgst_limit;
     
    15181629        function is_google_analytic_installed()
    15191630        {
    1520             $html = $this->html;
    1521             if (strpos($html, 'analytics.js') !== false || strpos($html, 'collect?') !== false || strpos($html, 'google-analytics') !== false) {
    1522                 return 'Yes';
    1523             }
     1631            $remote_data = wp_remote_get('http://sitesuggestcheck.satest.online/?url='.get_site_url());
     1632            if(!is_wp_error($remote_data)){
     1633                $response = $remote_data['body'];
     1634                $resp_arr = json_decode($response, true);
     1635           
     1636                if($resp_arr && !empty($resp_arr)){
     1637                    return isset($resp_arr['googleAnalytics']) && $resp_arr['googleAnalytics'] == true ? 'Yes' : 'No';
     1638                }
     1639            }
     1640
     1641            // $html = $this->html;
     1642            // if (strpos($html, 'analytics.js') !== false || strpos($html, 'collect?') !== false || strpos($html, 'google-analytics') !== false) {
     1643            //     return 'Yes';
     1644            // }
    15241645            return 'No';
    15251646        }
  • site-suggest/trunk/readme.txt

    r3318243 r3321154  
    44Tested up to:      6.8
    55Requires PHP:      8.0
    6 Stable tag:        1.2.0
     6Stable tag:        1.2.1
    77License:           GPLv2 or later
    88License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    126126     - https://ws.detectlanguage.com/0.2/detect
    127127
     1286. **Detect Google Analytics API**
     129   - This API is used to detect the Google analytics.. 
     130   - API Endpoint used:
     131     - http://sitesuggestcheck.satest.online
     132
    128133
    129134Site Suggest adheres to best practices when interacting with third-party services. No sensitive user data is shared; only publicly accessible information about your site is used to generate reports.
     
    145150
    146151== Changelog ==
     152
     153= 1.2.1 - 2025-07-2 =
     154* Improved Google Analytics Detection
    147155
    148156= 1.2.0 - 2025-06-26 =
  • site-suggest/trunk/site-suggest.php

    r3318243 r3321154  
    66 * Author: Blurr Studio
    77 * Author URI: https://blurr.it/
    8  * Version: 1.2.0
     8 * Version: 1.2.1
    99 * License: GPL v2 or later
    1010 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3636            define('stsgt_URL', plugin_dir_url(__FILE__));
    3737            define('stsgt_SLUG', 'site-suggest');
    38             define('stsgt_VERSION', '1.2.0');
     38            define('stsgt_VERSION', '1.2.1');
    3939        }
    4040
Note: See TracChangeset for help on using the changeset viewer.