Pilot-in / PiloPress

The most advanced WordPress Page Builder using Advanced Custom Fields & TailwindCSS
https://www.pilopress.com
62 stars 11 forks source link

Having occurence number for each layout in layouts list #196

Open barnemax-pilotin opened 2 years ago

barnemax-pilotin commented 2 years ago

Is your feature request related to a problem? Please describe. Being able to have visibility about the number of occurences of each layout on a website

2022-03-10_11h46_14

Describe the solution you'd like An idea would to be to use these filters on the different flexibles : acf/update_value/name=pip_flexible_header acf/update_value/name=pip_flexible_footer acf/update_value/name=pip_flexible

With these filters, counting the numbers of layouts per page and updating an option with an array of the following structure

$occurences = array(
    [post_id] => array( 
        'menu-contained-nemo'           => 1,
        'checkerboard-contained-nemo'   => 9,
        'menu-discus-blabla'            => 0
    ),
    [post_id] => array( 
        'menu-contained-nemo'           => 0,
        'checkerboard-contained-nemo'   => 2,
        'menu-discus-blabla'            => 3
    ),
   [...]
);

On delete_post removing the index of the post ID in the option.

Then maybe having another option that stocks the results of the number of layouts all across the site (using a foreach and doing the sum of all the same indexes), so we don't calculate everything on the layouts listings (edit.php?post_type=acf-field-group&layouts=1) - idk what's better performance wise for this.