Giter VIP home page Giter VIP logo

fewbricks's People

Contributors

aaronranard avatar folbert avatar maries24 avatar zackphilipps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fewbricks's Issues

Create brick boilerplate

Create a file that holds the basic code for a brick. Reference that file from the readme file instead of putting the boilerplate code there.

Key for a group must start with "group_"

Well this nearly killed me.

ACF would not display Fewbricks groups in admin, until (after a VERY LONG time), I worked out it ignores groups where the key doesn't begin with "group_".

This is an easy fix, adding this line to the top of the __contruct() of \fewbricks\acf\field_group class.

$key = (strpos($key, 'group_') === 0) ? $key : "group_$key";

A

Remove fluent/chaining

Remove returning $this from setter methods. This is to remove the possibilities of chaining which I feel is not the way to go. It makes the code using the functions harder to read IMHO.

Testing performance on PHP export

Test if automatically creating/reading PHP code is really worth it. It should be but let's try to find out just how much load time can be saved using it.

Feature to test implemented in 4beef2f

Demo not initiated

The instructions say "You should now, instead of the standard WYSIWYG area, see a bunch of fields and buttons that looks like the standard ACF GUI. That is actually what it is with the exception that they have been put there using Febwricks. Head on over to [theme]/fewbricks/field-groups/init.php to start tracking what is going on and how everything works."

However, I'm still seeing the normal wysiwyg area. I've triple checked that I installed it per your instructions. My copy of "template-fewbricks-demo.php" resides in the root if matters, and the new page created was set to use that template.

Any ideas what I'm missing here? Was there a step where .json data is supposed to be imported or some such? Scratching my head at what I did wrong.

Thank,

Mark

Is v2 taking into account new developments over at ACF concerning Gutenberg?

Hi,

I'm not aware of how exactly, ACF are changing the way fields are built and handled once Gutenberg is merged into core but, i'm sure there will be many changes over the next year.

When building Fewbricks V2, are these changes plus Gutenberg itself and what it means for the future of common place WordPress development being considered?

Preferred/better approach to registering field groups

Me again.

In \fewbricks\acf\field_groups class, I've replaced

register_field_group($this->settings);

with

if( function_exists('acf_add_local_field_group') ) {
        
        add_action('acf/init', function() {
        	acf_add_local_field_group($this->settings);
        });
        
}

This is the prescribed way in ACF5 and it ensured registration must happen at the right time.

I also think this action, in the plugin root file, is then probably not needed (i.e. just run the construct() immediately):

add_action('after_setup_theme', function() {
    fewbricks\fewbricks::construct();
});

A

Installation - two issues

hello
wanted to give fewbricks a run but I'm running into two issues:

  1. instructions says that I need to copy the fewbricks folder into my theme folder - this works unless I'm using a child theme - I'm using a Genesis child theme - copying the fewbricks folder to the child theme folder doesn't work - I had to copy/move it to the Genesis parent folder.
  2. Created a new page and assigned the demo template provided - trying to open that page leads to the following error: Fatal error: Class 'Timber' not found in /Users/......./wp-acf/wp-content/plugins/fewbricks/lib/brick.php on line 587

what am I missing?

thanks

Composer autoload for bricks and layouts

First, this codebase is absolute amazing. I pulled up the demo and BAM...just works.

Noticed you were using your own spl loader for the [theme]/fewbricks/[file] loading. If this is already a composer package, why not use composer's autoloader?

ACF Clone field type?

Hiya Folbert. I've just discovered this and it looks awesome.

Just noticed that you've not updated yet to accommodate the ACF Clone field.

What are your thoughts there?

Cheers

A

Add standardized ways to add attributes to layouts

Maybe even be able to group attributes in case you have multiple elements in your layouts and want to set different attributes on those elements.

/**
* $append = true if value should be appended to existing value of attribute
*/
set_attribute($name, $value, $group_name = false) {
}
/**
* Special function for styles since values should have ';' to separate values.
*/
add_style($attribute, $value$group_name = false) {
  $attr['style'] .= $attribute . ':' . $value . ';'
}
clear_attribute($name, $group_name = false) {
}

Add function get_field_values to brick-class

This will allow for writing
$data = $this->get_field_values(['field_name', 'another_field_name]);

instead of

$data['field_name'] = $this->get_field('field_name');
$data['another_field_name'] = $this->get_field('another_field_name');

Code:

/**
     * @param $field_names
     * @return array
     */
    protected function get_field_values($field_names)
    {

        $values = [];

        foreach($field_names AS $field_name) {
            $values[$field_name] = $this->get_field($field_name);
        }

        return $values;

    }

Add function to brick.php to batch-get field values from options

    /**
     * @param array $field_names ['field_name_1', 'field_name_2', ['field_name_3' => 'name_to_save_as']]
     * @return array
     */
    protected function get_field_values_from_options($field_names)
    {

        $values = [];

        foreach($field_names AS $field_name) {

            if(is_array($field_name)) {
                $key = key($field_name);
                $values[$field_name[$key]] = get_field($key, 'options');
            } else {
                $values[$field_name] = get_field($field_name, 'options');
            }
        }

        return $values;

    }

Add filter / hook to override template directory

Please add a filter in brick::get_brick_template_html() to override the default base directory for template files in the theme directory, like

$template_base_path = apply_filters('fewbricks/brick/template_base_path', get_stylesheet_directory() . '/fewbricks/bricks/');
$template_path = $template_base_path .
            str_replace('_', '-', \fewbricks\helpers\get_real_class_name($this)) .
            '.template.php';

Fewbricks2 will come with major breaking changes

In short, an update from Fewbricks 1.X to v2 will not be possible without rewriting some/most/all code that is using Fewbricks.

The plan is to rewrite core to adhere to PSR-2 when it comes to class names etc. I will probably also do a complete overhaul on how field groups, fields etc. are registered "under the hood" and the API to communicate with Fewbricks. All existing functionality will be kept and some new functionality will be added. During the years since i created the first, unpublished, version of Fewbricks and up to now, I have learnt a lot about ACF, WP and PHP in general so I will try to apply that to v2.

Please note that there is absolutely no ETA for a release of any kind. But do feel welcome to make feature requests.

Helper functions for setting publish status on brick level

By giving each brick its own publish-status, admins could add new bricks and setting them statuses such as "draft" or "unpublished" or, by default, "published".

Let's try to find a way to add helper functions to accommodate easy implementation of such a feature on brick level.

Repeater within flex content

Hi @folbert ! Great work, this is awesome stuff.

I am running into a slight issue, which is that there seems to be no way to "terminate" a Repeater within a Flexible Content field.

See screenshot: http://jmp.sh/AlEg9Wf

The last three tabs there are actually supposed to be part of the next Layout. But since the code is just add_sub_field over and over, it appears to just tack them on to the Repeater:

# =============================================================================>
# 5. 25/75 Image and Text
# =============================================================================>
$l = new layout( '5. 25/75 Image and Text', 'image_text_25_75', '201704051323a' );

// Content tab
$l->add_sub_field(
  new acf_fields\tab(
    'Content', '', '201704051323b', [
      'placement' => 'top',
      'endpoint' => 0,
    ]
  )
);

$repeater = (
  new acf_fields\repeater(
    '25/75 Image and Text', 'image_text_25_75_row', '201704051335a', [
      'min' => 1,
      'max' => 6,
      'layout' => 'block',
      'button_label' => 'Add Row',
    ]
  )
);

$repeater->add_sub_field(
  new acf_fields\radio(
    'Image Position', 'image_position', '201704051341a', [
      'wrapper' => [
        'width' => '50'
      ],
      'choices' => [
        'left' => 'Left',
        'right' => 'Right',
      ],
      'layout' => 'horizontal',
      'return_format' => 'value'
    ]
  )
);

$l->add_sub_field( $repeater );

// Styles tab
$l->add_sub_field(
  new acf_fields\tab(
    'Styles', '', '201704051353a', [
      'placement' => 'top',
      'endpoint' => 0,
    ]
  )
);

$l->add_brick( new colors( 'colors', '201704051253b' ) );

$fc->add_layout( $l );


# =============================================================================>
# 7. 50/50 Text
# =============================================================================>
$l = new layout( '7. 50/50 Text', 'text_50_50', '201704051323a' );

$l->add_sub_field(
  new acf_fields\radio(
    'Headline Format', 'headline_format', '201704051355a', [
      'instructions' => '<span style="font-size:11px; font-style:italic;">If single headline, headline will be centered over both columns. If two headlines, each headline will be aligned left over their respective columns.</span>',
      'choices' => array (
        'one' => 'Single',
        'two' => 'Double',
      ),
      'default_value' => 'one : Single',
      'layout' => 'vertical',
      'return_format' => 'value',
    ]
  )
);

// Left Side tab
$l->add_sub_field(
  new acf_fields\tab(
    'Left Side', '', '201704051428a', [
      'placement' => 'top',
      'endpoint' => 0,
    ]
  )
);

$l->add_sub_field(
  new acf_fields\text(
    'Left Headline', 'left_headline', '201704051432a', [
      'conditional_logic' => array (
        array (
          array (
            'field' => '201704051355a',
            'operator' => '==',
            'value' => 'two',
          ),
        ),
      ),
    ]
  )
);

$l->add_sub_field(
  new acf_fields\wysiwyg(
    'Left Content', 'left_content', '201704051434a'
  )
);

// Right Side tab
$l->add_sub_field(
  new acf_fields\tab(
    'Right Side', '', '201704051435a', [
      'placement' => 'top',
      'endpoint' => 0,
    ]
  )
);

$l->add_sub_field(
  new acf_fields\text(
    'Right Headline', 'right_headline', '201704051435b', [
      'conditional_logic' => array (
        array (
          array (
            'field' => '201704051355a',
            'operator' => '==',
            'value' => 'two',
          ),
        ),
      ),
    ]
  )
);

$l->add_sub_field(
  new acf_fields\wysiwyg(
    'Right Content', 'right_content', '201704051435c'
  )
);

// Styles tab
$l->add_sub_field(
  new acf_fields\tab(
    'Styles', '', '201704051436a', [
      'placement' => 'top',
      'endpoint' => 0,
    ]
  )
);

$l->add_brick( new colors( 'colors', '201704051441b' ) );

$fc->add_layout( $l );

Note: When adding the Repeater to the Layout, I have tried both add_sub_field and add_repeater, and both produce the same result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.