Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter laurosollero

    (@laurosollero)

    Cool, nice to hear! The only change we could do is maybe, just maybe, change the name of the event. I’m fine with that.

    I’ve used the same snippet of code found on the SO on other projects, but letting the user insert the SVG is way cooler!

    Thank you for your project, I’ll try and translate it to Brazilian Portuguese.

    Long live open source! =D

    Thread Starter laurosollero

    (@laurosollero)

    Here is a use, still in progress…

    https://abfh.nutsaboutbrand.com/apoiadores/

    The JS let me create a click, get info about the state (name and initials)… In other project I will animate a bit the SVG!

    If you don’t want to integrate it to your project, it’s not a problem! I can create a sub project, give you credit, and go on with my life! ??

    Thread Starter laurosollero

    (@laurosollero)

    Removing duplicate…

    Thread Starter laurosollero

    (@laurosollero)

    Hey,
    Yes, I thought that might be the case, so I’ve inserted these lines:

    // Add replaced image's ID to the new SVG
    if(typeof imgID === 'undefined') {
      if(typeof svgID === 'undefined') {
        imgID = 'svg-replaced-'+index;
        $svg = $svg.attr('id', imgID);
      } else {
        imgID = svgID;
      }
    } else {
      $svg = $svg.attr('id', imgID);
    }

    And added this on the .each:

    .each(function(index){

    Here is the svg-inline.js complete:

    jQuery(document).ready(function ($) {
      // Check to see if user set alternate class
      var target  = (cssTarget != 'img.' ? cssTarget : 'img.style-svg');
      jQuery(target).each(function(index){
        var $img = jQuery(this);
        var imgID = $img.attr('id');
        var imgClass = $img.attr('class');
        var imgURL = $img.attr('src');
    
        jQuery.get(imgURL, function(data) {
          // Get the SVG tag, ignore the rest
          var $svg = jQuery(data).find('svg');
    
          var svgID = $svg.attr('id');
    
          // Add replaced image's ID to the new SVG if necessary
          if(typeof imgID === 'undefined') {
            if(typeof svgID === 'undefined') {
              imgID = 'svg-replaced-'+index;
              $svg = $svg.attr('id', imgID);
            } else {
              imgID = svgID;
            }
          } else {
            $svg = $svg.attr('id', imgID);
          }
          // Add replaced image's classes to the new SVG
          if(typeof imgClass !== 'undefined') {
              $svg = $svg.attr('class', imgClass+' replaced-svg');
          }
          // Remove any invalid XML tags as per https://validator.w3.org
          $svg = $svg.removeAttr('xmlns:a');
          // Replace image with new SVG
          $img.replaceWith($svg);
          jQuery(document).trigger('svg.loaded', [imgID]);
        }, 'xml');
      });
    });

    Thread Starter laurosollero

    (@laurosollero)

    OK, thanks for your time Simon.. I am the dev trying to figure it out, more of a Drupal guy but this client’s website was already made in WordPress.

    I can always check for the cookie exists before calling the:
    add_filter('the_content', array(&$MP3JP, 'replace_links'), 1);

    As authenticated users won’t be listening to the music, only anonymous.
    I would rather not hack your code but… I’ve tried to call the add_filter later, from my theme, but I would still need to hack your code…

    Don’t get me wrong, you can make money anyway you want but I would not hire a dev to complete my job as I am not making that much money…

    For anyone having some problem like this, this snippet just check for the cookie saying that the user is logged in, it is not safe (cookies are easily spoofed) but I take care of access control with another module. As the module runs before WordPress is already fully loaded you can’t check if the user is really logged using it’s own functions, neither is possible to check for the page it is running:

    $logged_in = false;
    if (count($_COOKIE)) {
      foreach ($_COOKIE as $key => $val) {
        if (substr($key, 0, 19) === "wordpress_logged_in") {
          $logged_in = true;
        }
      }
    }
Viewing 5 replies - 1 through 5 (of 5 total)