Forum Replies Created

Viewing 15 replies - 256 through 270 (of 322 total)
  • Plugin Author optimalisatie

    (@optimalisatie)

    I am sorry, I do not understand Russian ??

    Best,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    Hi!

    You can find the default modules in /wp-content/plugins/above-the-fold-optimization/modules/localizejs/. You should copy the module structure to create a new module.

    The module should contain (adminpanel) configuration HTML and basic settings such as update interval. You can also use several include options, e.g. WordPress native include or replacement of the file in the original (async) javascript source code.

    An example (doubleclick-dc.inc.php):

    <?php
    
    /**
     * DoubleClick Google Analytics dc.js
     *
     * @since      2.3
     * @package    abovethefold
     * @subpackage abovethefold/admin
     * @author     Optimalisatie.nl <[email protected]>
     */
    
    class Abovethefold_LocalizeJSModule_DoubleclickDc extends Abovethefold_LocalizeJSModule {
    
    	// The name of the module
    	public $name = 'DoubleClick Google Analytics (dc.js)';
    	public $link = 'https://support.google.com/analytics/answer/2444872';
    
    	public $update_interval = 86400; // once per day
    	public $script_source = 'https://stats.g.doubleclick.net/dc.js';
    
    	public $snippets = array();
    
    	/**
    	 * Initialize the class and set its properties.
    	 *
    	 * @since    2.0
    	 * @var      object    $CTRL       The above the fold admin controller..
    	 */
    	public function __construct( &$CTRL ) {
    
    		parent::__construct( $CTRL );
    
    		if ($this->CTRL->options['localizejs'][$this->classname]['enabled']) {
    			switch ($this->CTRL->options['localizejs'][$this->classname]['incmethod']) {
    				case "replace":
    
    				break;
    				default:
    					$this->CTRL->loader->add_action('wp_head', $this, 'setup_analytics_script', -1);
    					$this->CTRL->loader->add_action('wp_enqueue_scripts', $this, 'enqueue_script', -1);
    				break;
    			}
    		}
    
    	}
    
    	/**
    	 * Include script
    	 */
    	public function enqueue_script( ) {
    
    		list($script_url, $script_time) = $this->get_script( true );
    
    		wp_enqueue_script( 'google-analytics-doubleclick', $script_url , array(), date('Ymd', $script_time) );
    
    	}
    
    	/**
    	 * Analytics object setup
    	 */
    	public function setup_analytics_script( ) {
    
    ?>
    <script>
    (function(d,w,c){
    w['GoogleAnalyticsObject']=c;w[c]=w[c]||function(){ (w[c].q=w[c].q||[]).push(arguments); },w[c].l=1*new Date(); })(document,window,'ga');
    </script>
    <?php
    
    	}
    
    	/**
    	 * Parse Google Analytics javascript and return original code (to replace) and file-URL.
    	 *
    	 * @since 2.3
    	 */
    	public function parse_analytics_js( $code ) {
    
    		/**
    		 * analytics.js
    		 *
    		 * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/
    		 * @since 2.3
    		 */
    		if (strpos($code,'doubleclick.net/dc.js') !== false) {
    
    			$regex = array();
    
    			$replace = '';
    			if ($this->CTRL->options['localizejs'][$this->classname]['incmethod'] === 'replace') {
    
    				$regex[] = '#([\'|"])([^/\)\'"]+doubleclick\.net/dc\.js)[\'|"]#Ui';
    
    				list($script_url,$script_time) = $this->get_script( true );
    				$script_url = preg_replace('|^http(s)?:|Ui','',$script_url);
    				$replace = '$1' . $script_url . '$1';
    
    			} else {
    
    				/**
    				 * Remove async snippet
    				 */
    				$regex[] = '#\(function\(\)([\s]+)?\{[^\}]+doubleclick\.net/dc\.js[^\}]+\}\)\(\);#is';
    			}
    
    			foreach ($regex as $str) {
    				$code = preg_replace($str,$replace,$code);
    			}
    
    		}
    
    		return $code;
    
    	}
    
    	/**
    	 * Admin configuration options
    	 */
    	public function admin_config( $extra_config = '' ) {
    
    		$config = '<div class="inside">';
    
    		$config .= 'Include method: <select name="'.$this->option_name('incmethod').'">
    			'.$this->select_options(array(
    				'replace' => 'Replace URL in original code',
    				'native' => 'WordPress native script include'
    			),$this->options['incmethod']).'
    		</select>';
    
    		$config .= '</div>';
    
    		parent::admin_config( $config );
    
    	}
    
    	/**
    	 * Parse HTML
    	 */
    	public function parse_html( $html ) {
    
    		$html = $this->parse_analytics_js( $html );
    
    		return parent::parse_html( $html );
    
    	}
    
    	/**
    	 * Parse Javascript
    	 */
    	public function parse_js( $js ) {
    
    		$js = $this->parse_analytics_js( $js );
    
    		return parent::parse_js( $js );
    
    	}
    
    }

    Let me know if you are able to get it to work! I am also interested in the created modules to add as new default modules.

    Best Regards,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    Hi!

    I’ve checked the package.json and the dependency is there:

    "devDependencies": {
        "grunt": "latest",
        "grunt-contrib-cssmin": "latest",
        "grunt-contrib-uglify": "latest",
        "matchdep": "latest",
        "penthouse": "latest"
      }

    You could try to manually install it using the following command:

    npm install penthouse

    I’ve included new example code for professional Grunt.js based Penthouse.js usage in v2.3.5.

    Best Regards,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    If the problem is within the critical path CSS, the plugin is not the cause. It simply prints the inline CSS unmodified in the <head> of the page.

    Did you check if the error in the inline CSS returned? Perhaps you accidentally updated the inline CSS with erroneous code.

    Plugin Author optimalisatie

    (@optimalisatie)

    Hi!

    Thanks for the bug report! The issues have been resolved in v2.3.5.

    Best Regards,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    The plugin is updated to v2.3.5. If you try the plugin again, please let me know if the problem has been resolved.

    Plugin Author optimalisatie

    (@optimalisatie)

    Hi!

    The bug was not related to PHP7 but due to stricter error reporting (possibly default in PHP7). The buffer was passed as reference.

    The bug has been resolved in v2.3.5.

    Best Regards,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    Hi!

    The issue was related to the loading order of WordPress plugins (ob_start is called at runtime in W3 Total Cache).

    The issue has been resolved in v2.3.5.

    Best Regards,
    Jan Jaap

    Plugin Author optimalisatie

    (@optimalisatie)

    Thank you for the bug report! The localizeJS feature is a beta-feature.

    It appears that you are using an old PHP version. I will have to investigate an alternative solution but it has no priority due to the beta state of the feature. It may take some time and I am not sure that support for old PHP versions will be added.

    The LocalizeJS feature is not required for the base functionality of the plugin.

    Plugin Author optimalisatie

    (@optimalisatie)

    My apologies for the late reply.

    Perhaps you are using an old version of the plugin. The issue should be resolved in the latest version.

    Plugin Author optimalisatie

    (@optimalisatie)

    My apologies for the late reply.

    Thank you for the bug-report!

    The issue should be resolved in the latest version.

    Plugin Author optimalisatie

    (@optimalisatie)

    Thanks for the bug report!

    The issues are resolved in the next version (v2.3.4).

    Plugin Author optimalisatie

    (@optimalisatie)

    Hello!

    My apologies for the late reply.

    There is no limit on the text-box or plugin. The submitted CSS text is written to a regular text file so the limit must be related to PHP input or file storage.

    Plugin Author optimalisatie

    (@optimalisatie)

    Hello!

    My apologies for the late reply.

    There is no limit on the text-box or plugin. The submitted CSS text is written to a regular text file so the limit must be related to PHP input or file storage.

    Plugin Author optimalisatie

    (@optimalisatie)

    Thank you for the bug report! The localizeJS feature is a beta-feature. I’ve investigated the issue and found a bug. The bug has been fixed in the next version (v2.3.4).

Viewing 15 replies - 256 through 270 (of 322 total)