Plugin Directory

Changeset 3178540


Ignore:
Timestamp:
10/30/2024 07:17:41 AM (14 months ago)
Author:
veppa
Message:

Optimization and bugfixes

Location:
http-requests-manager
Files:
4 edited
6 copied

Legend:

Unmodified
Added
Removed
  • http-requests-manager/tags/1.3.6/assets/js/admin.js

    r3145574 r3178540  
    649649                if (row.request_source === 'core')
    650650                {
    651                     var more_info = VPHRM.row_core_more_info(row, request_args);
    652                     if (more_info)
    653                     {
    654                         row.request_source += ': ' + more_info;
     651                    var more_info = VPHRM.row_core_more_info(row,request_args);
     652                    if(more_info)
     653                    {
     654                        row.request_source += ': '+more_info;
    655655                    }
    656656                }
     
    781781                    return 'health';
    782782                }
    783                 if (backtrace[x] === 'WP_Upgrader->download_package')
    784                 {
    785                     return 'download';
    786                 }
    787783            }
    788784
     
    790786            // check url
    791787            var base_url = row['url'].split('?')[0].replace('http://', 'https://');
    792 
     788       
    793789            if (base_url.search('https://api.wordpress.org/plugins/update-check/') != -1)
    794790            {
     
    822818            {
    823819                return 'translations';
    824             }
    825             if (base_url.search('https://downloads.wordpress.org/') != -1)
    826             {
    827                 return 'download';
    828820            }
    829821
     
    882874            {
    883875                page.badges = [];
    884 
     876               
    885877                page.badges.push('<i class="vphrm-badge"><b>page_type:</b> ' + page.page_type + '</i>');
    886878                page.badges.push('<i class="vphrm-badge"><b>is_user_logged_in:</b> ' + (page.info.is_user_logged_in ? 'true' : 'false') + '</i>');
  • http-requests-manager/tags/1.3.6/http-requests-manager.php

    r3145574 r3178540  
    55  Plugin URI:   https://veppa.com/http-requests-manager/
    66  Description: Limit, Debug, Optimize WP_HTTP requests. Limit by request count, page load time, reduce timeout for each request. Speed up login and admin pages.
    7   Version: 1.3.5
     7  Version: 1.3.6
    88  Author: veppa
    99  Author URI: https://veppa.com/
     
    3131/**
    3232 * TODO:
    33 
    34   - marketing: remove all other affiliate links.
    35   -     - incorporate video tutorials to interface with popup/direct link.
    36 
    37 
     33 *
     34  - add blocking by theme
     35  - add blocking by core function
     36  - disable all enclosure checks and rely only on file extension
    3837  - safe-mode: show instruction about safe mode and operation mode on beginning. after dismissed move note to bottom.
    3938  - [maybe] group prevent enclosure checks and pingbacks. write 1 log instead of 50+
     
    4241  - remove duplicate info about requests in page array.
    4342  - optimization: define hooks only for selected mode and logging combination. define hooks granularly.
    44 
    4543  -------------------------------------------
    4644 * conflict test.
     
    7270  -     - on shutdown
    7371
    74 
    75   update plugin tags:
    76   tag                   total       1st page min    top     poistion
    77   -----------------------------------------
    78   wp_http               3           0               2000        2
    79   log                   100         400             200k
    80   - api             400         5000
    81   - requests            5           0               2000        2
    82   - update-checks       3           0               2000        2
    83   --
    84   + debug               200         1000
    85   + optimization        120         1000
    86   + limit               40          10              10k
    87   --
    88   update                140         2000            700k
    89   speed             180         2000
    90   optimize          140         9k              5m
    91   performance           380         100k            5m
    92   block             740         20k             700k
    93  *
    9472 */
    9573defined('ABSPATH') or exit;
     
    9775class HTTP_Requests_Manager
    9876{
    99 
    100     const VERSION = '1.3.5';
     77   
     78    const VERSION = '1.3.6';
    10179    const ID = 'http-requests-manager';
    10280    const TIMEOUT = 2;
     
    11593    private static $request_action;
    11694    private static $request_action_info;
    117     private static $custom_rules_limit = 10;
     95    private static $custom_rules_limit = 30;
    11896    private static $page_id;
    11997    private static $mu_plugin_file_name = '/a-http-requests-manager.php';
     
    17321710
    17331711    /**
    1734      * Count included plugin, theme, core files
    1735      *
    1736      * $arr_file_count = array(
    1737      *      core => 123
    1738      *      plugin  => array(
    1739      *                  plugin-slug     => 2,
    1740      *                  plugin-slug2    => 3,
    1741      *                  plugin-slug3    => 6,
    1742      *              )
    1743      *      theme   => array( theme-slug => 9 )
    1744      *      plugin_count    => 3
    1745      * );
     1712     * Return loaded plugin slugs as array
    17461713     *
    17471714     * @return array
    17481715     */
    1749     static public function get_included_file_counts()
    1750     {
    1751         // count included files
     1716    static public function get_loaded_plugins()
     1717    {
     1718        $plugin_slugs = array();
     1719
     1720        static $abspath = null;
     1721        if(is_null($abspath))
     1722        {
     1723            $abspath = str_replace('\\', '/', ABSPATH);
     1724        }
     1725
     1726
    17521727        $incs = get_included_files();
    1753 
    1754         // count files per plugin, theme, core
    1755         $arr_file_count = array(
    1756             'total'  => count($incs),
    1757             'core'   => 0,
    1758             'plugin' => array()
    1759         );
    1760         foreach($incs as $file)
    1761         {
    1762             $file_info = self::get_file_type($file);
    1763             $type = $file_info['type'];
    1764             $slug = isset($file_info['slug']) ? $file_info['slug'] : false;
    1765 
    1766             if(false !== $slug)
    1767             {
    1768                 if(!isset($arr_file_count[$type][$slug]))
    1769                 {
    1770                     $arr_file_count[$type][$slug] = 0;
    1771                 }
    1772                 $arr_file_count[$type][$slug]++;
    1773             }
    1774             else
    1775             {
    1776                 $arr_file_count[$type]++;
    1777             }
    1778         }
    1779 
    1780         if(isset($arr_file_count['plugin']))
    1781         {
    1782             $arr_file_count['plugin_count'] = count($arr_file_count['plugin']);
    1783         }
    1784 
    1785         return $arr_file_count;
    1786     }
    1787 
    1788     /**
    1789      * Return loaded plugin slugs as array
    1790      *
    1791      * @return array
    1792      */
    1793     static public function get_loaded_plugins()
    1794     {
    1795         // get all loaded plugins as comma seperated string
    1796         $file_counts = self::get_included_file_counts();
    1797 
    1798         $plugin_slugs = array();
    1799 
    1800         if(!empty($file_counts['plugin']))
    1801         {
    1802             $plugin_slugs = array_keys($file_counts['plugin']);
    1803         }
     1728        $incs = implode("\n", $incs);
     1729        $incs = str_replace('\\', '/', $incs);
     1730        $incs = str_replace($abspath, '', $incs);
     1731
     1732        preg_match_all('(wp-content\/plugins\/([^/]*))', $incs, $matches);
     1733
     1734        if(!empty($matches[1]))
     1735        {
     1736            $plugin_slugs = array_unique($matches[1]);
     1737        }
     1738
     1739        /* echo "<!-- get_loaded_plugins \n";
     1740          echo " --- \n" . $incs . " --- \n";
     1741          print_r($matches);
     1742          echo " ----  \n";
     1743          print_r($plugin_slugs);
     1744          echo " -->\n";
     1745         */
    18041746
    18051747        return $plugin_slugs;
     
    23902332    }
    23912333
     2334    static private function normalize_path_if_needed($file)
     2335    {
     2336        if(strpos($file, '\\'))
     2337        {
     2338            return wp_normalize_path($file);
     2339        }
     2340        return $file;
     2341    }
     2342
    23922343    /**
    23932344     * detect if file related to plugin, theme or core. Return array with wp root relative file name, type and slug of plugin.
     
    24022353        if(is_null($abspath))
    24032354        {
    2404             $abspath = wp_normalize_path(ABSPATH);
     2355            $abspath = self::normalize_path_if_needed(ABSPATH);
    24052356        }
    24062357
     
    24082359        $plugin_dir_prefix = 'wp-content/plugins/';
    24092360
    2410         $file = wp_normalize_path($file);
     2361        $file = self::normalize_path_if_needed($file);
    24112362        $file_short = self::remove_prefix($file, $abspath);
    24122363
     
    24172368
    24182369        // plugin or theme
    2419         if(false !== strpos($file_short, $plugin_dir_prefix))
     2370        if(0 === strpos($file_short, $plugin_dir_prefix))
    24202371        {
    24212372            // this is plugin           
     
    24242375            $row['type'] = 'plugin';
    24252376        }
    2426         elseif(false !== strpos($file_short, $theme_dir_prefix))
     2377        elseif(0 === strpos($file_short, $theme_dir_prefix))
    24272378        {
    24282379            // this is theme
     
    25252476    static public function remove_prefix($str, $prefix)
    25262477    {
    2527         if(substr($str, 0, strlen($prefix)) == $prefix)
     2478        //if(substr($str, 0, strlen($prefix)) == $prefix)
     2479        if(strpos($str, $prefix) === 0)
    25282480        {
    25292481            $str = substr($str, strlen($prefix));
     
    25702522                $return = 'login';
    25712523            }
    2572 
    2573             if(is_null($return))
    2574             {
    2575                 $return = (is_admin() ? 'admin' : 'frontend');
    2576             }
    2577         }
    2578 
    2579         return $return;
     2524        }
     2525
     2526        // certain or fallback type
     2527        return is_null($return) ? (is_admin() ? 'admin' : 'frontend') : $return;
    25802528    }
    25812529
     
    27952743        if(is_null($return))
    27962744        {
     2745
    27972746            // store sanitized value
    2798             $return = strtolower(sanitize_text_field($_SERVER['SCRIPT_NAME']));
     2747            if(isset($_SERVER['SCRIPT_NAME']))
     2748            {
     2749                $return = strtolower(sanitize_text_field($_SERVER['SCRIPT_NAME']));
     2750            }
     2751            else
     2752            {
     2753                $return = '';
     2754            }
    27992755        }
    28002756
     
    28412797    static public function page_url()
    28422798    {
    2843         $host = sanitize_text_field($_SERVER['HTTP_HOST']);
    2844         $uri = sanitize_text_field($_SERVER['REQUEST_URI']);
    2845 
    2846         return (is_ssl() ? 'https://' : 'http://') . $host . $uri;
     2799        if(isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI']))
     2800        {
     2801            $host = sanitize_text_field($_SERVER['HTTP_HOST']);
     2802            $uri = sanitize_text_field($_SERVER['REQUEST_URI']);
     2803            $current_url = (is_ssl() ? 'https://' : 'http://') . $host . $uri;
     2804        }
     2805        else
     2806        {
     2807            // use wordpress functions
     2808            global $wp;
     2809            $current_url = home_url(add_query_arg(array(), $wp->request));
     2810        }
     2811
     2812        return $current_url;
    28472813    }
    28482814
  • http-requests-manager/tags/1.3.6/readme.txt

    r3145574 r3178540  
    55Requires at least: 4.7
    66Tested up to: 6.6
    7 Stable tag: 1.3.5
     7Stable tag: 1.3.6
    88License: GPLv2
    99
     
    1717
    1818Reason may be slow external WP_HTTP requests. [HTTP Requests Manager plugin](https://veppa.com/http-requests-manager/) will log all WP HTTP requests with time taken to complete for each request. If there are multiple requests per page they will be color grouped.
     19
     20https://youtu.be/l_fvAnKPJkM
     21
     22[Check plugin overview on YouTube] (https://youtu.be/l_fvAnKPJkM) | [Watch plugin tutorials] (https://youtube.com/playlist?list=PLvn-qBzU0II7b5D4OYDnKpNpuvxiM0f4b)
     23
    1924
    2025Plugin tested with PHP version 5.6, 7.x and up to 8.3.
     
    121126* [Share button without plugin](https://veppa.com/share-button/) – add super fast native sharing button to your website. Tiny inline code, ad blocker safe, no external dependencies.
    122127* [bbPress WP Tweaks](https://veppa.com/bbpress-wp-tweaks/) – add custom sidebar, additional widgets and forum columns for sites powered with bbPress forum plugin.
     128* [Tutorial to get high PageSpeed Score](https://veppa.com/share-button/) – video showing how I get PageSpeed Score 100 for my own website powered by WordPress CMS.
    123129
    124130Visit veppa.com to learn from my [WordPress tutorials](https://veppa.com/category/learn-wordpress/).
     
    127133
    1281341. Download and activate the plugin.
    129 2. Browse to `Tools > HTTP Requests Manager` to view log entries and choose operation mode. Operation mode "Smart block" will be activated by default.
     1352. Browse to `Tools` → `HTTP Requests Manager` to view log entries and choose operation mode. Operation mode "Only log HTTP requests" will be activated by default.
     1363. Use "Smart block" operation mode to optimize WP_HTTP usage.
    130137
    131138== Screenshots ==
     
    192199== Changelog ==
    193200
     201= 1.3.6 - 30 October 2024  =
     202
     203  * Fixed: Checking HTTP_HOST variable existence before using.
     204  * Fixed: Page type detection rechecked if used fallback type admin or frontend. (rest api detected as frontend because of late initialization).
     205  * Update: Optimized code related to loaded plugin detection. Reduced function execution time from 300ms to 17ms.
     206  * Update: Increased custom rules limit from 10 to 30.
     207
    194208= 1.3.5 - 2 September 2024  =
    195209
    196  * Fixed: Increased request_source field size to 255 characters. Some requests were not written because of small field size.
     210 * Fixed: Increased request_source field size to 255 characters.
    197211
    198212= 1.3.4 - 26 August 2024  =
  • http-requests-manager/tags/1.3.6/templates/page-settings.php

    r3141611 r3178540  
    5959                        <td>
    6060                            <input type="checkbox" name="load_must_use" value="1" id="load_must_use" <?php echo (HTTP_Requests_Manager::get_option('load_must_use') ? ' checked="checked"' : '') ?> />
    61                             <label for="load_must_use">Enable priority loading with Must-Use plugin feature.</label>
     61                            <label>Enable priority loading with Must-Use plugin feature.</label>
    6262                        </td>
    6363                    </tr>
     
    6666                        <td>
    6767                            <input type="checkbox" name="disable_logging" value="1" id="disable_logging" <?php echo (HTTP_Requests_Manager::get_option('disable_logging') ? ' checked="checked"' : '') ?> />
    68                             <label for="disable_logging">Disable logging. Faster, no new logs will be added to database. You can still analyze existing logs.</label>
     68                            <label>Disable logging. Faster, no new logs will be added to database. You can still analyze existing logs.</label>
    6969                        </td>
    7070                    </tr>
     
    236236                    Download PDF checklist that I use to get 90+ score on WordPress websites.</span>
    237237                </a>
    238                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#rankmath" target="_blank">
    239                     <span class="vphrm-card-val">◢</span>
    240                     <span class="vphrm-card-name"><b class="vphrm-card-h3">Rank Math SEO plugin</b>
    241                         Optimize posts for target keyword. Content SEO checklist with best practices. Track SEO performance for each post using Google Search Console data.</span>
    242                 </a>
    243                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#a2hosting" target="_blank">
    244                     <span class="vphrm-card-val">a2</span>
    245                     <span class="vphrm-card-name"><b class="vphrm-card-h3">A2hosting</b>
    246                         WordPress hosting for any website. Good for beginners and has managed hosting for big sites as well.</span>
    247                 </a>
    248                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#kwfinder" target="_blank">
    249                     <span class="vphrm-card-val">𝕂</span>
    250                     <span class="vphrm-card-name"><b class="vphrm-card-h3">KWfinder</b>
    251                         Get easy to rank keywords. View best performing keywords of your competitors. Beginner friendly pricing. Has free plan as well.</span>
     238                <a class="vphrm-card vphrm-card-wide" href="https://youtu.be/W9wroFTw2mM" target="_blank">
     239                    <span class="vphrm-card-val">▷</span>
     240                    <span class="vphrm-card-name"><b class="vphrm-card-h3">PageSpeed Score 100</b>
     241                    Video tutorial optimizing WordPress with 25 plugins, 2 external JS, YouTube video embeds.</span>
    252242                </a>
    253243            </p>
  • http-requests-manager/trunk/assets/js/admin.js

    r3145574 r3178540  
    649649                if (row.request_source === 'core')
    650650                {
    651                     var more_info = VPHRM.row_core_more_info(row, request_args);
    652                     if (more_info)
    653                     {
    654                         row.request_source += ': ' + more_info;
     651                    var more_info = VPHRM.row_core_more_info(row,request_args);
     652                    if(more_info)
     653                    {
     654                        row.request_source += ': '+more_info;
    655655                    }
    656656                }
     
    781781                    return 'health';
    782782                }
    783                 if (backtrace[x] === 'WP_Upgrader->download_package')
    784                 {
    785                     return 'download';
    786                 }
    787783            }
    788784
     
    790786            // check url
    791787            var base_url = row['url'].split('?')[0].replace('http://', 'https://');
    792 
     788       
    793789            if (base_url.search('https://api.wordpress.org/plugins/update-check/') != -1)
    794790            {
     
    822818            {
    823819                return 'translations';
    824             }
    825             if (base_url.search('https://downloads.wordpress.org/') != -1)
    826             {
    827                 return 'download';
    828820            }
    829821
     
    882874            {
    883875                page.badges = [];
    884 
     876               
    885877                page.badges.push('<i class="vphrm-badge"><b>page_type:</b> ' + page.page_type + '</i>');
    886878                page.badges.push('<i class="vphrm-badge"><b>is_user_logged_in:</b> ' + (page.info.is_user_logged_in ? 'true' : 'false') + '</i>');
  • http-requests-manager/trunk/http-requests-manager.php

    r3145574 r3178540  
    55  Plugin URI:   https://veppa.com/http-requests-manager/
    66  Description: Limit, Debug, Optimize WP_HTTP requests. Limit by request count, page load time, reduce timeout for each request. Speed up login and admin pages.
    7   Version: 1.3.5
     7  Version: 1.3.6
    88  Author: veppa
    99  Author URI: https://veppa.com/
     
    3131/**
    3232 * TODO:
    33 
    34   - marketing: remove all other affiliate links.
    35   -     - incorporate video tutorials to interface with popup/direct link.
    36 
    37 
     33 *
     34  - add blocking by theme
     35  - add blocking by core function
     36  - disable all enclosure checks and rely only on file extension
    3837  - safe-mode: show instruction about safe mode and operation mode on beginning. after dismissed move note to bottom.
    3938  - [maybe] group prevent enclosure checks and pingbacks. write 1 log instead of 50+
     
    4241  - remove duplicate info about requests in page array.
    4342  - optimization: define hooks only for selected mode and logging combination. define hooks granularly.
    44 
    4543  -------------------------------------------
    4644 * conflict test.
     
    7270  -     - on shutdown
    7371
    74 
    75   update plugin tags:
    76   tag                   total       1st page min    top     poistion
    77   -----------------------------------------
    78   wp_http               3           0               2000        2
    79   log                   100         400             200k
    80   - api             400         5000
    81   - requests            5           0               2000        2
    82   - update-checks       3           0               2000        2
    83   --
    84   + debug               200         1000
    85   + optimization        120         1000
    86   + limit               40          10              10k
    87   --
    88   update                140         2000            700k
    89   speed             180         2000
    90   optimize          140         9k              5m
    91   performance           380         100k            5m
    92   block             740         20k             700k
    93  *
    9472 */
    9573defined('ABSPATH') or exit;
     
    9775class HTTP_Requests_Manager
    9876{
    99 
    100     const VERSION = '1.3.5';
     77   
     78    const VERSION = '1.3.6';
    10179    const ID = 'http-requests-manager';
    10280    const TIMEOUT = 2;
     
    11593    private static $request_action;
    11694    private static $request_action_info;
    117     private static $custom_rules_limit = 10;
     95    private static $custom_rules_limit = 30;
    11896    private static $page_id;
    11997    private static $mu_plugin_file_name = '/a-http-requests-manager.php';
     
    17321710
    17331711    /**
    1734      * Count included plugin, theme, core files
    1735      *
    1736      * $arr_file_count = array(
    1737      *      core => 123
    1738      *      plugin  => array(
    1739      *                  plugin-slug     => 2,
    1740      *                  plugin-slug2    => 3,
    1741      *                  plugin-slug3    => 6,
    1742      *              )
    1743      *      theme   => array( theme-slug => 9 )
    1744      *      plugin_count    => 3
    1745      * );
     1712     * Return loaded plugin slugs as array
    17461713     *
    17471714     * @return array
    17481715     */
    1749     static public function get_included_file_counts()
    1750     {
    1751         // count included files
     1716    static public function get_loaded_plugins()
     1717    {
     1718        $plugin_slugs = array();
     1719
     1720        static $abspath = null;
     1721        if(is_null($abspath))
     1722        {
     1723            $abspath = str_replace('\\', '/', ABSPATH);
     1724        }
     1725
     1726
    17521727        $incs = get_included_files();
    1753 
    1754         // count files per plugin, theme, core
    1755         $arr_file_count = array(
    1756             'total'  => count($incs),
    1757             'core'   => 0,
    1758             'plugin' => array()
    1759         );
    1760         foreach($incs as $file)
    1761         {
    1762             $file_info = self::get_file_type($file);
    1763             $type = $file_info['type'];
    1764             $slug = isset($file_info['slug']) ? $file_info['slug'] : false;
    1765 
    1766             if(false !== $slug)
    1767             {
    1768                 if(!isset($arr_file_count[$type][$slug]))
    1769                 {
    1770                     $arr_file_count[$type][$slug] = 0;
    1771                 }
    1772                 $arr_file_count[$type][$slug]++;
    1773             }
    1774             else
    1775             {
    1776                 $arr_file_count[$type]++;
    1777             }
    1778         }
    1779 
    1780         if(isset($arr_file_count['plugin']))
    1781         {
    1782             $arr_file_count['plugin_count'] = count($arr_file_count['plugin']);
    1783         }
    1784 
    1785         return $arr_file_count;
    1786     }
    1787 
    1788     /**
    1789      * Return loaded plugin slugs as array
    1790      *
    1791      * @return array
    1792      */
    1793     static public function get_loaded_plugins()
    1794     {
    1795         // get all loaded plugins as comma seperated string
    1796         $file_counts = self::get_included_file_counts();
    1797 
    1798         $plugin_slugs = array();
    1799 
    1800         if(!empty($file_counts['plugin']))
    1801         {
    1802             $plugin_slugs = array_keys($file_counts['plugin']);
    1803         }
     1728        $incs = implode("\n", $incs);
     1729        $incs = str_replace('\\', '/', $incs);
     1730        $incs = str_replace($abspath, '', $incs);
     1731
     1732        preg_match_all('(wp-content\/plugins\/([^/]*))', $incs, $matches);
     1733
     1734        if(!empty($matches[1]))
     1735        {
     1736            $plugin_slugs = array_unique($matches[1]);
     1737        }
     1738
     1739        /* echo "<!-- get_loaded_plugins \n";
     1740          echo " --- \n" . $incs . " --- \n";
     1741          print_r($matches);
     1742          echo " ----  \n";
     1743          print_r($plugin_slugs);
     1744          echo " -->\n";
     1745         */
    18041746
    18051747        return $plugin_slugs;
     
    23902332    }
    23912333
     2334    static private function normalize_path_if_needed($file)
     2335    {
     2336        if(strpos($file, '\\'))
     2337        {
     2338            return wp_normalize_path($file);
     2339        }
     2340        return $file;
     2341    }
     2342
    23922343    /**
    23932344     * detect if file related to plugin, theme or core. Return array with wp root relative file name, type and slug of plugin.
     
    24022353        if(is_null($abspath))
    24032354        {
    2404             $abspath = wp_normalize_path(ABSPATH);
     2355            $abspath = self::normalize_path_if_needed(ABSPATH);
    24052356        }
    24062357
     
    24082359        $plugin_dir_prefix = 'wp-content/plugins/';
    24092360
    2410         $file = wp_normalize_path($file);
     2361        $file = self::normalize_path_if_needed($file);
    24112362        $file_short = self::remove_prefix($file, $abspath);
    24122363
     
    24172368
    24182369        // plugin or theme
    2419         if(false !== strpos($file_short, $plugin_dir_prefix))
     2370        if(0 === strpos($file_short, $plugin_dir_prefix))
    24202371        {
    24212372            // this is plugin           
     
    24242375            $row['type'] = 'plugin';
    24252376        }
    2426         elseif(false !== strpos($file_short, $theme_dir_prefix))
     2377        elseif(0 === strpos($file_short, $theme_dir_prefix))
    24272378        {
    24282379            // this is theme
     
    25252476    static public function remove_prefix($str, $prefix)
    25262477    {
    2527         if(substr($str, 0, strlen($prefix)) == $prefix)
     2478        //if(substr($str, 0, strlen($prefix)) == $prefix)
     2479        if(strpos($str, $prefix) === 0)
    25282480        {
    25292481            $str = substr($str, strlen($prefix));
     
    25702522                $return = 'login';
    25712523            }
    2572 
    2573             if(is_null($return))
    2574             {
    2575                 $return = (is_admin() ? 'admin' : 'frontend');
    2576             }
    2577         }
    2578 
    2579         return $return;
     2524        }
     2525
     2526        // certain or fallback type
     2527        return is_null($return) ? (is_admin() ? 'admin' : 'frontend') : $return;
    25802528    }
    25812529
     
    27952743        if(is_null($return))
    27962744        {
     2745
    27972746            // store sanitized value
    2798             $return = strtolower(sanitize_text_field($_SERVER['SCRIPT_NAME']));
     2747            if(isset($_SERVER['SCRIPT_NAME']))
     2748            {
     2749                $return = strtolower(sanitize_text_field($_SERVER['SCRIPT_NAME']));
     2750            }
     2751            else
     2752            {
     2753                $return = '';
     2754            }
    27992755        }
    28002756
     
    28412797    static public function page_url()
    28422798    {
    2843         $host = sanitize_text_field($_SERVER['HTTP_HOST']);
    2844         $uri = sanitize_text_field($_SERVER['REQUEST_URI']);
    2845 
    2846         return (is_ssl() ? 'https://' : 'http://') . $host . $uri;
     2799        if(isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI']))
     2800        {
     2801            $host = sanitize_text_field($_SERVER['HTTP_HOST']);
     2802            $uri = sanitize_text_field($_SERVER['REQUEST_URI']);
     2803            $current_url = (is_ssl() ? 'https://' : 'http://') . $host . $uri;
     2804        }
     2805        else
     2806        {
     2807            // use wordpress functions
     2808            global $wp;
     2809            $current_url = home_url(add_query_arg(array(), $wp->request));
     2810        }
     2811
     2812        return $current_url;
    28472813    }
    28482814
  • http-requests-manager/trunk/readme.txt

    r3145574 r3178540  
    55Requires at least: 4.7
    66Tested up to: 6.6
    7 Stable tag: 1.3.5
     7Stable tag: 1.3.6
    88License: GPLv2
    99
     
    1717
    1818Reason may be slow external WP_HTTP requests. [HTTP Requests Manager plugin](https://veppa.com/http-requests-manager/) will log all WP HTTP requests with time taken to complete for each request. If there are multiple requests per page they will be color grouped.
     19
     20https://youtu.be/l_fvAnKPJkM
     21
     22[Check plugin overview on YouTube] (https://youtu.be/l_fvAnKPJkM) | [Watch plugin tutorials] (https://youtube.com/playlist?list=PLvn-qBzU0II7b5D4OYDnKpNpuvxiM0f4b)
     23
    1924
    2025Plugin tested with PHP version 5.6, 7.x and up to 8.3.
     
    121126* [Share button without plugin](https://veppa.com/share-button/) – add super fast native sharing button to your website. Tiny inline code, ad blocker safe, no external dependencies.
    122127* [bbPress WP Tweaks](https://veppa.com/bbpress-wp-tweaks/) – add custom sidebar, additional widgets and forum columns for sites powered with bbPress forum plugin.
     128* [Tutorial to get high PageSpeed Score](https://veppa.com/share-button/) – video showing how I get PageSpeed Score 100 for my own website powered by WordPress CMS.
    123129
    124130Visit veppa.com to learn from my [WordPress tutorials](https://veppa.com/category/learn-wordpress/).
     
    127133
    1281341. Download and activate the plugin.
    129 2. Browse to `Tools > HTTP Requests Manager` to view log entries and choose operation mode. Operation mode "Smart block" will be activated by default.
     1352. Browse to `Tools` → `HTTP Requests Manager` to view log entries and choose operation mode. Operation mode "Only log HTTP requests" will be activated by default.
     1363. Use "Smart block" operation mode to optimize WP_HTTP usage.
    130137
    131138== Screenshots ==
     
    192199== Changelog ==
    193200
     201= 1.3.6 - 30 October 2024  =
     202
     203  * Fixed: Checking HTTP_HOST variable existence before using.
     204  * Fixed: Page type detection rechecked if used fallback type admin or frontend. (rest api detected as frontend because of late initialization).
     205  * Update: Optimized code related to loaded plugin detection. Reduced function execution time from 300ms to 17ms.
     206  * Update: Increased custom rules limit from 10 to 30.
     207
    194208= 1.3.5 - 2 September 2024  =
    195209
    196  * Fixed: Increased request_source field size to 255 characters. Some requests were not written because of small field size.
     210 * Fixed: Increased request_source field size to 255 characters.
    197211
    198212= 1.3.4 - 26 August 2024  =
  • http-requests-manager/trunk/templates/page-settings.php

    r3141611 r3178540  
    5959                        <td>
    6060                            <input type="checkbox" name="load_must_use" value="1" id="load_must_use" <?php echo (HTTP_Requests_Manager::get_option('load_must_use') ? ' checked="checked"' : '') ?> />
    61                             <label for="load_must_use">Enable priority loading with Must-Use plugin feature.</label>
     61                            <label>Enable priority loading with Must-Use plugin feature.</label>
    6262                        </td>
    6363                    </tr>
     
    6666                        <td>
    6767                            <input type="checkbox" name="disable_logging" value="1" id="disable_logging" <?php echo (HTTP_Requests_Manager::get_option('disable_logging') ? ' checked="checked"' : '') ?> />
    68                             <label for="disable_logging">Disable logging. Faster, no new logs will be added to database. You can still analyze existing logs.</label>
     68                            <label>Disable logging. Faster, no new logs will be added to database. You can still analyze existing logs.</label>
    6969                        </td>
    7070                    </tr>
     
    236236                    Download PDF checklist that I use to get 90+ score on WordPress websites.</span>
    237237                </a>
    238                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#rankmath" target="_blank">
    239                     <span class="vphrm-card-val">◢</span>
    240                     <span class="vphrm-card-name"><b class="vphrm-card-h3">Rank Math SEO plugin</b>
    241                         Optimize posts for target keyword. Content SEO checklist with best practices. Track SEO performance for each post using Google Search Console data.</span>
    242                 </a>
    243                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#a2hosting" target="_blank">
    244                     <span class="vphrm-card-val">a2</span>
    245                     <span class="vphrm-card-name"><b class="vphrm-card-h3">A2hosting</b>
    246                         WordPress hosting for any website. Good for beginners and has managed hosting for big sites as well.</span>
    247                 </a>
    248                 <a class="vphrm-card vphrm-card-wide" href="https://veppa.com/tools/?utm_source=wp&utm_medium=plugin&utm_campaign=options#kwfinder" target="_blank">
    249                     <span class="vphrm-card-val">𝕂</span>
    250                     <span class="vphrm-card-name"><b class="vphrm-card-h3">KWfinder</b>
    251                         Get easy to rank keywords. View best performing keywords of your competitors. Beginner friendly pricing. Has free plan as well.</span>
     238                <a class="vphrm-card vphrm-card-wide" href="https://youtu.be/W9wroFTw2mM" target="_blank">
     239                    <span class="vphrm-card-val">▷</span>
     240                    <span class="vphrm-card-name"><b class="vphrm-card-h3">PageSpeed Score 100</b>
     241                    Video tutorial optimizing WordPress with 25 plugins, 2 external JS, YouTube video embeds.</span>
    252242                </a>
    253243            </p>
Note: See TracChangeset for help on using the changeset viewer.