WordPress.org

Plugin Directory

Changeset 1371672


Ignore:
Timestamp:
03/15/16 16:02:09 (17 months ago)
Author:
ulfben
Message:

Swapping out get_template_directory for get_stylesheet_directory to see if custom CSS-files work better with child-themes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-jquery-lightbox/trunk/wp-jquery-lightbox.php

    r1319207 r1371672  
    108108        } 
    109109    }    
    110     $uri = ( $haveThemeCss ) ? get_template_directory_uri().'/'.$fileName : plugin_dir_url(__FILE__).'styles/'.$fileName;    
    111     wp_enqueue_style('jquery.lightbox.min.css', $uri, false, '1.4.6');   
     110    $uri = ( $haveThemeCss ) ? get_stylesheet_directory_uri().'/'.$fileName : plugin_dir_url(__FILE__).'styles/'.$fileName;  
     111    wp_enqueue_style('jquery.lightbox.min.css', $uri, false, '1.4.8');   
    112112} 
    113113 
     
    115115    if(is_admin() || is_feed()){return;} 
    116116    wp_enqueue_script('jquery', '', array(), false, true); 
    117     wp_enqueue_script('wp-jquery-lightbox-swipe', plugins_url(JQLB_TOUCH_SCRIPT, __FILE__),  Array('jquery'), '1.4.6', true);    
    118     wp_enqueue_script('wp-jquery-lightbox', plugins_url(JQLB_SCRIPT, __FILE__),  Array('jquery'), '1.4.6', true); 
     117    wp_enqueue_script('wp-jquery-lightbox-swipe', plugins_url(JQLB_TOUCH_SCRIPT, __FILE__),  Array('jquery'), '1.4.8', true);    
     118    wp_enqueue_script('wp-jquery-lightbox', plugins_url(JQLB_SCRIPT, __FILE__),  Array('jquery'), '1.4.8', true); 
    119119    wp_localize_script('wp-jquery-lightbox', 'JQLBSettings', array( 
    120120        'showTitle' => get_option('jqlb_showTitle'), 
     
    161161    return jqlb_do_regexp($content, $id); 
    162162} 
     163 
     164//Matt's version to support multiple rel values 
     165//https://wordpress.org/support/topic/fix-for-auto-lightboxing-links-that-contain-rel-attributes-already?replies=12 
     166function jqlb_do_regexp_multirel($content, $id){ 
     167    $id = esc_attr($id); 
     168    $a_tag_img_regex = "/(<a[^>]+href=['\"][^>]+\\.(?:bmp|gif|jpg|jpeg|png)[^>]+)>/i"; 
     169    if (preg_match_all($a_tag_img_regex, $content, $a_tag_matches, PREG_SET_ORDER)) { 
     170        foreach ($a_tag_matches as $a_tag) { 
     171            $new_a_tag = $a_tag[0]; 
     172            $rel_regex = "/(rel=['\"])(?![^>]*?(?:lightbox|nolb|nobox))([^'\"]+)(['\"])/i"; 
     173            $new_a_tag = preg_replace($rel_regex, '$1lightbox['.$id.'] $2$3', $new_a_tag); 
     174 
     175            $no_rel_regex = "/(<a(?![^>]*?rel=['\"].+)[^>]+href=['\"][^>]+\\.(?:bmp|gif|jpg|jpeg|png)[^>]+)>/i"; 
     176            $new_a_tag = preg_replace($no_rel_regex, '$1 rel="lightbox['.$id.']">', $new_a_tag); 
     177 
     178            if ($new_a_tag != $a_tag[0]) $content = str_replace($a_tag[0], $new_a_tag, $content); 
     179        } 
     180    } 
     181    return $content; 
     182} 
     183 
    163184 
    164185/* automatically insert rel="lightbox[nameofpost]" to every image with no manual work.  
Note: See TracChangeset for help on using the changeset viewer.