Viewing 1 reply thread
  • Author
    Posts
    • #4663
      mcmaster
      Member

      I was trying to activate the custom stylesheet I defined for one of my Piklist add-ons. My plugin is in plugins/mcw-piklist-custom. Under that I have an add-ons directory. The only activated add-on is mcw-post-custom.

      I looked at the way Piklist Demos does it and found the following function:

        add_filter('piklist_assets', 'piklist_demo_assets');
        function piklist_demo_assets($assets)
        {
          array_push($assets['styles'], array(
            'handle' => 'piklist-demos'
            ,'src' => piklist::$addons['piklist']['url'] . '/add-ons/piklist-demos/parts/css/piklist-demo.css'
            ,'media' => 'screen, projection'
            ,'enqueue' => true
            ,'admin' => true
          ));
      
          return $assets;
        }
      

      I found it curious the way it’s using the piklist::$addons array to pick up the URL. Looked at that array, and here’s what I saw:

      Array
      (
          [piklist] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/plugins/piklist
                  [url] => http://marys.dev/wp-content/plugins/piklist
              )
      
          [theme] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/themes/marysriver/piklist
                  [url] => http://marys.dev/wp-content/themes/marysriver/piklist
              )
      
          [mcw-piklist-custom] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/plugins/mcw-piklist-custom
                  [url] => http://marys.dev/wp-content/plugins/mcw-piklist-custom
              )
      
          [wp-helpers] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/plugins/wp-helpers
                  [url] => http://marys.dev/wp-content/plugins/wp-helpers
              )
      
          [piklist-demos] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/plugins/piklist/add-ons/piklist-demos
                  [url] => http://marys.dev/wp-content/plugins/add-ons
              )
      
          [mcw-post-custom] => Array
              (
                  [path] => /Users/donna/Sites/marys/wp-content/plugins/mcw-piklist-custom/add-ons/mcw-post-custom
                  [url] => http://marys.dev/wp-content/plugins/add-ons
              )
      
      )

      I have two thoughts:

      1. I am uncomfortable accessing a class variable like this; would rather call a function to return a value. (data hiding) E.g., piklist::add_on_data( 'mcw-post-custom', 'url' )

      2. I’m curious as to why the add-on URLs do not have the correct path. E.g., for piklist-demos it should be http://marys.dev/wp-content/plugins/piklist/add-ons/piklist-demos.

      Thanks,
      Donna

    • #4667
      Steve
      Keymaster

      The URL for add-ons will be fixed in v0.9.9.5.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.