• Resolved madmax4ever

    (@madmax4ever)


    While trying your plugin, with DEBUG ON (PHP 7.4), I get, when deactivating it whereas image module was loaded with Fast rewrite:

    PHP Deprecated: Non-static method WPPP_Dynamic_Images::flush_rewrite_rules() should not be called statically in /my_wordpress/wp-content/plugins/wp-performance-pack/wp-performance-pack.php [...]

    As you can read, it’s because of:

    public function deactivate() {
      if ( $this->options['dynamic_images'] ) {
        // Delete rewrite rules from htaccess
        WPPP_Dynamic_Images::flush_rewrite_rules( false );
      }

    My workaround was to add the following static function inside class.wppp_dynamic_images.php :

    	public static function static_flush_rewrite_rules() {
    		// init is called prior to options update
    		// so add or remove rules before flushing
    		global $wp_rewrite;
    		if ( $wp_rewrite && isset( $wp_rewrite->non_wp_rules['(.*)-([0-9]+)x([0-9]+)?c?\.((?i)jpeg|jpg|png|gif)'] ) ) {
    			unset( $wp_rewrite->non_wp_rules['(.*)-([0-9]+)x([0-9]+)?c?\.((?i)jpeg|jpg|png|gif)'] );
    		}
    		flush_rewrite_rules();
    	}

    And modify accordingly wp-performance-pack.php by switching to it:

    public function deactivate() {
      if ( $this->options['dynamic_images'] ) {
        // Delete rewrite rules from htaccess
        WPPP_Dynamic_Images::static_flush_rewrite_rules();
      }

    Just to share with you.

    Great plugin by the way ??

  • The topic ‘Deprecated call when deactivating’ is closed to new replies.