Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • claude
    Member

    This thread is intended to help you by investigating as much as I’m able to so you don’t have to and you can simply point me in the right direction to take a deeper look.

    In the previous topic post, which was closed, you said “Finally had a chance to look at this. It doesn’t look like Page Builder is doing things the WordPress way, so we won’t be able to support using Piklist Widgets.” and then the topic was closed.

    When you responded to this thread you said “We haven’t even looked at this issue…”.

    What did you conclude when you responded to the previous thread? These statements don’t, at least on the surface, seem to be consistent so I wonder if you could just say a few words about what you already know about this problem.

    claude
    Member

    I found a little time to walk through some off the piklist code (only about an hour so my understanding remains limited). My previous questions may have been naive but I as I looked at the widget-related code in piklist, it dawned on me that the key difference between widgets that work in the page builders is the way piklist wraps the selection of a piklist-specific widget inside the Piklist_Universal_Widget.

    Is Piklist_Universal_Widget the only widget actually registered with WordPress? (Parts/widget declarations are actually hosted by this widget and their methods – ie: form, update, widget) are delegated to the declared code inside a piklist-enabled theme or plugin).

    In the SiteOrigin builder the inserted Widget is referred to as “Untitled Widget”.

    The debug logs show:
    [07-Jan-2016 22:43:51 UTC] PHP Notice: Undefined index: widget in […] class-piklist-universal-widget.php on line 157

    The builder renders a truncated string that looks like this” “scription_wrapper][field_description][/field_description_wrapper]”

    I instrumented the $instance references before and after the call and found that in neither case is the $instance[‘widget’] value present. I suppose this implies that the previous $this->register_widgets(); call (in the widget function) is not correctly fetching the (virtual) widget.

    I’m not sure if any of this helps lead to any particular next step but let me know what you think and I can take investigate to take this to the next level, assuming any of this is helpful.

    claude
    Member

    The best explanation I’ve found so far seems to be:

    https://www.wpbeaverbuilder.com/support/q/support-for-advanced-custom-fields-5-fields-in-widgets/

    I wonder if you could confirm that this is a plausible explanation.

    After a little research, it sounds like most page builders (and there are at least three where folks have asked why piklist does not working with their builder (I’d have to search again to find them more specifically). In the SiteOrigin case, they have one developer on the builder but it was mentioned that they would be happy to talk about the cause if someone from piklist were to have a conversation.

    So here’s my take (and I’m not asking for anything other than your thoughts here):

    1) The builders seem to expect some kind of client-side entity/class reference/name which they use to instantiate widgets?
    2) Does this imply JavaScript code?
    3) If I wanted to generate suitable client-side code what would it look like? I don’t have enough experience with standard widgets to know what their life-cycle (by this I mean the life-cycle sequence – creation, initialization, data hydration, execution, rendering, cleanup, etc). just yet but I can maybe dig around a bit.

    claude
    Member

    Hey Steve, I wasn’t implying that you should prioritize this but rather that you might be able to take a moment to explain the gap, as your look at the problem (from he previous thread) may have revealed. Someone could then use that guidance to take a closer look and maybe, as you suggest, submit a patch if the gap is not too wide.

    I’m pretty tech savvy but completely new to PHP and WordPress. Most of my expertise centers on the (Enterprise) Java stack, and to slightly reduced degree the Microsoft stack. Web front-end technologies (HTTP/HTML/CSS/JS) are even more familiar since they tend cross those stacks so that part is quite familiar. I’m on my 5th book about WordPress but I only started gearing up for this project 3 weeks ago.

    BTW: I’m impressed with the agility that WordPress brings to the table, especially with a tool like Piklist (the more I dig in the more impressed I am with you and your team’s work). I’m less impressed with PHP as a language/markup engine but I can see how it became the basis of so many web projects.

    in reply to: Feedback and Questions #5493
    claude
    Member

    I presume if I just overwrite the plugin directory with the beta zip that will be sufficient to upgrade?

    BTW: When I assimilate new technologies I tend to write a few simple utilities that make it easier to express some central concepts. This helps me work through the details more deeply than I would otherwise and provides some basic tools I might use if I find them practical, so The first thing I wrote was a FieldBuilder that uses the fluent builder pattern. I’ll flesh this out and probably write a blog about it.

    Usage follows this approach, where the first example uses the build call to get a constructed array and the second uses some shortcuts for common use cases.

    
    $field1 = CDEFieldBuilder::create('text')
      ->name('cde_test')
      ->label('Test field')
      ->value('Value')
      ->description('Description text')
      ->help('Help text')
      ->attr('class', 'text')
      ->build();
      
    piklist('field', $field1);
    
    CDEFieldBuilder::select('cde_select', 'Select field', 'option2')
      ->hints('Description and help text')
      ->choice('option1', "Value 1")
      ->choice('option2', "Value 2")
      ->choice('option3', "Value 3")
      ->field();
    

    I’m still debating whether the first case is actually more compact than the array declarations but the second certainly is. (hints uses a single value as both the description and help text, a lazy way of quickly prototyping, but it takes two parameters as well. I find this slightly easier to read.

    The builder code is simple and looks like this:

    
    class CDEFieldBuilder {
      
      private $building = array();
      
      function __construct($type) {
        $this->building['type'] = $type;
      }
      
      // STATIC CREATION
      
      public static function create($type) {
        return new CDEFieldBuilder($type);
      }
      
      public static function text($name, $label, $value = '') {
        return CDEFieldBuilder::create('text')->common($name, $label, $value);
      }
      
      public static function select($name, $label, $value = '') {
        return CDEFieldBuilder::create('select')->common($name, $label, $value);
      }
      
      // FLUENT ATTRIBUTES
      
      public function name($name) {
        $this->building['field'] = $name;
        return $this;
      }
      
      public function label($label) {
        $this->building['label'] = $label;
        return $this;
      }
      
      public function value($value) {
        $this->building['value'] = $value;
        return $this;
      }
      
      // Combine the most common properties
      public function common($name, $label, $value = '') {
        $this->building['field'] = $name;
        $this->building['label'] = $label;
        $this->building['value'] = $value;
        return $this;
      }
      
      public function description($description) {
        $this->building['description'] = $description;
        return $this;
      }
      
      public function help($help) {
        $this->building['help'] = $help;
        return $this;
      }
      
      // Combine description and help (same if only one provided)
      public function hints($description, $help = NULL) {
        if ($help == NULL) {
          $help = $description;
        }
        $this->building['description'] = $description;
        $this->building['help'] = $help;
        return $this;
      }
      
      public function attributes($attributes) {
        $this->building['attributes'] = $attributes;
        return $this;
      }
      
      // ADD SINGLE ATTRIBUTE
      public function attr($name, $value) {
        if (!isset($this->building['attributes'])) {
          $this->building['attributes'] = array();
        }
        $this->building['attributes'][$name] = $value;
        return $this;
      }
      
      // ADD SINGLE CHOICE
      public function choice($name, $value) {
        if (!isset($this->building['choices'])) {
          $this->building['choices'] = array();
        }
        $this->building['choices'][$name] = $value;
        return $this;
      }
      
      // GET BUILT ARRAY OR ADD IT AS A PIKLIST FIELD 
      
      public function build() {
        return $this->building;
      }
    
      public function field() {
        return piklist('field', $this->building);
      }
    }
    
    in reply to: Feedback and Questions #5492
    claude
    Member

    Hey Steve, thanks for responding.

    Re: 1 – By life-cycle, I just mean what loads in what order and what gets checked in what sequence. That may be too broad a request for clarification but I think it could be a useful addition to the documentation since integration points (actions/filters, other events) are hit at different stages of the life-cycle. Based on your response, it sounds like it doesn’t matter how many plugins exist with Plugin Type: headers.

    Re: 2 – The empty widget at run-time has been resolved and was something on my end but the blank widget in the admin editor, as per the screen shot is not. I would have expected the default view to be something that identifies the drag-able box as a Piklist widget and once a selection has been made from the pull-down a label that identifies the specific widget selected. It is simply white with the drop-down icon and so it took me quite a bit of time to realize that it was in fact the piklist widget after all.

    in reply to: Feedback and Questions #5484
    claude
    Member

    Follow up: I am able to see the output from the widget. Some kind of caching problem maybe? The two points I raised are still worth asking about and I would love to hear about the plugin life-cycle and whether the blank widget view in WordPress admin is a known issue.

    PS: I hope my mention of experience in the post is not take as arrogant. I find it helpful to know what a developer’s experience is when trying to explain things myself and figured this would provide some context to anyone who responds.

Viewing 7 posts - 1 through 7 (of 7 total)