Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1004803

    i have enqueued a script on Enfold – that allows me to play only one youtube video at a time.
    Clicking on a new youtube video this starts playing and the other playing goes to pause.
    This script does not work – if js merging is active. _ maybe because it loads the YouTubeIframeAPI asynchron.

    is there a way to enqueue scripts and exclude them from merging?
    Like bwp minify got this feature – but i like to have your merging tool – and not an additional Plugin.

    #1004988

    Hey Guenter,

    https://cl.ly/da223d677705 From what I see here in the /enfold/config-templatebuilder/avia-template-builder/php/asset-manager.class.php, you can use the filter avf_exclude_assets to exclude files from being processed.

    Best regards,
    Victoria

    #1005111

    and how to apply this filter on my specific js file – with an absolute path to it or is it enough to have the js name.
    i enqueued it only on few pages via:

    function youtube_single_js_script() {
    	if ( is_page( array( 31239, 31341, 31464, 31484, 31824, 32089, 32257 ))) {
        wp_enqueue_script( 'Youtube-Single', get_stylesheet_directory_uri().'/js/youtube-singleplay.js', array('jquery'), '1.0', true );
    }
    }
    add_action( 'wp_enqueue_scripts', 'youtube_single_js_script' );

    are the scripts we load via Child-Theme functions.php even included in merging? If then it has more to do with the fact that the merged files are now below this embedded script.

    #1005304

    so my observation now is that these files enqueued by child-theme functions.php or some plugins are not included in merging process.
    The Script files goes to a footer merged file and this is behind my script. Don’t know why this is important for the script to work.
    My trial to include these scripts of the functions.php of my child-theme via :

    add_filter('avf_merge_assets', function() {
        return array('css' => 'all', 'js' => 'all');
    });

    does not work – they were not included.
    Edit: bwp-minify does include those files and the script works in this constallation. ( Enfold disable merging via Enfold Options)

    #1005324

    Hi,

    You can use this code to exclude (additional) files:

    
    add_filter('avf_exclude_assets', 'avia_exclude_files_from_compression', 10, 1);
    function avia_exclude_files_from_compression($excluded_files)
    {
      $exclude_css = array('admin-bar', 'dashicons');
      $exclude_js = array('jquery-core', 'admin-bar', 'comment-reply');
    
      $excluded_files['css'] = array_merge($excluded_files['css'], $exclude_css);
      $excluded_files['js'] = array_merge($excluded_files['js'], $exclude_js);
      return $excluded_files;
    }
    

    Replace ‘admin-bar’, ‘dashicons’ with the names of your css files (i.e. the example files would be admin-bar.css and dashicons.css) and ‘jquery-core’, ‘admin-bar’, ‘comment-reply’ with the names of your js files (i.e. the example files would be jquery-core.js and admin-bar.js and comment-reply.js).

    Best regards,
    Dude

    #1005536

    thanks Dude – but this file is not compressed / merged by default.

    what about the trial to force include this file – i tried this:

    add_filter('avf_force_include_asset', 'avia_force_include_files', 10, 1);
    function avia_force_include_files($force_included) {
    	$force_include_js = array('youtube-singleplay');
    	$force_included['js'] = array_merge($force_included['js'], $force_include_js);
      return $force_included;
    }

    but it does not include that little external script (enqueued via child-theme functions.php)

    do i have to give in this line the path to the script:
    $force_include_js = array('youtube-singleplay');

    by the way you can see script in action here ( but with bwp minify): https://webers-testseite.de/youtube-videos/
    Password is : Enfold
    start one video and than the next without stopping the first.
    because i don’t want to style every test-page DSGVO konform (GDPR)

    #1005548

    Hi,

    Please create me an admin account and I’ll debug the code. Please make sure the theme file editor (Appearance > Editor) is not blocked.

    Best regards,
    Dude

    #1005674

    aber sei bitte vorsichtig, das ist meine große Testseite wo ich allen möglichen Code ausprobiere.
    meine functions.php des child-themes hat alleine schon 1200 zeilen !
    ich habe nochmal ein Duplicator Backup gemacht – also keine Angst. Es ist alles irgendwie gesichert

    #1005677

    Wie gesagt – selbst wenn das Merging von js und css an ist, ist dieses extern eingebundene Script nicht bei den gemergeten Files dabei.
    Deshalb wollt ich testen, ob man dieses Script einfach mit einbindet in das Merging. deshalb mein Versuch über das andere Filter es einzubinden.

    #1006550

    Hallo Günter,

    Tatsächlich ein bug – danke dafür.

    Im File enfold\config-templatebuilder\avia-template-builder\php\asset-manager.class.php um Zeile 242 findest Du:

    
    if( ('all' == $this->which_files[$file_type] ) || 
    					('avia-module' == $this->which_files[$file_type] && strpos($file, 'avia-module') !== false ) ||
    					('avia' == $this->which_files[$file_type] && strpos($file, 'avia') !== false ) ||
    					( $force_print )) 
    

    Bitte ersetzen durch:

    
    				if( ('all' == $this->which_files[$file_type] ) || 
    					('avia-module' == $this->which_files[$file_type] && strpos($file, 'avia-module') !== false ) ||
    					('avia' == $this->which_files[$file_type] && strpos($file, 'avia') !== false ) ||
    					( $force_print ) ||
    					( in_array( $file, $this->force_include[ $file_type ] ) )
    				) 
    

    Im Filter avf_force_include_asset dann nur mehr den Namen angeben – in Deinem Fall youtube-singleplay.

    Hab einen Pullrequest fürs nächste Update angelegt.

    LG,
    Günter

    #1006822

    Danke fürs schnelle Feedback.

    Leider wird das script auch so nicht eingebunden in das Merging ?

    #1007011

    Hi,

    Hast du den Namen genommen, den Du in wp_enqueue_script verwendet hast (case sensitive !!!):

    
    wp_enqueue_script( 'Youtube-Single', get_stylesheet_directory_uri().'/js/youtube-singleplay.js', array('jquery'), '1.0', true );
    

    d.h.

    
    add_filter('avf_force_include_asset', 'avia_force_include_files', 10, 1);
    function avia_force_include_files($force_included) {
    	$force_include_js = array('Youtube-Single');
    	$force_included['js'] = array_merge($force_included['js'], $force_include_js);
      return $force_included;
    }
    

    LG
    Günter

    #1007018

    natürlich nicht – sorry – ich habe den Titel des js genommen – Asche auf mein Haupt

    Edit : es funktioniert ! – aber kommt nicht zu dem günschten Erfolg.

    Kann ich Einfluss nehmen an welcher Stelle das Script mit in das Merging genommen wird?

    PS: wenn ich das gemergete File nehme und mal durch einen beautifier laufen lasse sehe ich , dass das Script so eingefügt wurde:

    
    })(jQuery);;   // vorheriges Script Ende  - hier sind zwei Semicolon ? kann das Einfluss haben ?
    var tag = document.createElement('script');  // mein Script 

    PS : ich arbeit jetzt mal selbst dran – vielleicht ist es nicht gut wenn wir gleichzeitig als Admin drin sind und dran arbeiten.

    • This reply was modified 6 years, 2 months ago by Guenni007.
    #1007023

    Hi,

    Versuche es mit:

    
    add_action( 'wp_enqueue_scripts', 'youtube_single_js_script', 1 );
    

    Sollte das nicht gehen mit:

    
    add_action( 'init', 'youtube_single_js_script', 1 );
    

    Best regards,
    Günter

    #1007075

    von Enfold Seite klappt wohl alles soweit –
    ich habe es mal mit 9999 eingebunden und dann steht es definitv am Ende der Komprimierten Files.
    Mein Gedanke war, dass die Reihenfolge in der es aufgerufen wird wichtig ist – denn die gemergeten Files liegen ja dann hinter dem nicht eingebundenem Script. – BWP Minify macht das so. Die komprimierten Files werden vor diesem Script aufgerufen.

    Egal – wenn ich es brauchen sollte, dann nehme ich halt BWP Minify für diese spezielle Seite dann.
    Kann geschlossen werden.

    #1007165

    Hi,

    Passt – schönen tag noch.

    LG,
    Günter

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.