Plugin Directory

Changeset 2415365


Ignore:
Timestamp:
11/09/2020 06:27:16 PM (5 years ago)
Author:
eatbuildplay
Message:

Release v1.0.3

Location:
acf-engine/trunk
Files:
775 added
13 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • acf-engine/trunk/acfengine.php

    r2413640 r2415365  
    44 *
    55 * Plugin Name: ACF Engine
    6  * Plugin URI: https://eatbuildplay.com/plugins/acfengine/
     6 * Plugin URI: https://acfengine.com/
    77 * Description: Provides data-driven solutions powered by ACF including custom post types, custom taxonomies, options pages and rendering templates.
    8  * Version: 1.0.2
     8 * Version: 1.0.3
    99 * Author: Eat/Build/Play
    1010 * Author URI: https://eatbuildplay.com
     
    1717
    1818use  AcfEngine\Core\AdminMenu ;
    19 use  AcfEngine\Core\PostTypePostType ;
    20 use  AcfEngine\Core\PostTypeCustom ;
    21 use  AcfEngine\Core\PostTypeManager ;
     19use  AcfEngine\Core\PostType\PostTypeManager ;
    2220use  AcfEngine\Core\TaxonomyManager ;
    2321use  AcfEngine\Core\TaxonomyCustom ;
     
    2725use  AcfEngine\Core\BlockType\BlockTypeManager ;
    2826use  AcfEngine\Core\TemplateManager ;
    29 use  AcfEngine\Core\RenderCodeManager ;
     27use  AcfEngine\Core\FormManager ;
    3028use  AcfEngine\Core\Import ;
    3129define( 'ACF_ENGINE_PATH', plugin_dir_path( __FILE__ ) );
    3230define( 'ACF_ENGINE_URL', plugin_dir_url( __FILE__ ) );
    33 define( 'ACF_ENGINE_VERSION', '1.0.1' );
     31define( 'ACF_ENGINE_VERSION', '1.0.3' );
    3432define( 'ACF_ENGINE_TEXT_DOMAIN', 'acf-engine' );
    3533class Plugin
     
    5149        $import->init();
    5250        // init the post type manager
    53         $ptm = new PostTypeManager();
    54         $ptm->setup();
     51        $m = new PostTypeManager();
     52        $m->setup();
    5553        // init taxonomy manager
    56         $tm = new TaxonomyManager();
    57         $tm->setup();
     54        $m = new TaxonomyManager();
     55        $m->setup();
    5856        // init options page manager
    59         $opm = new OptionsPageManager();
    60         $opm->setup();
     57        $m = new OptionsPageManager();
     58        $m->setup();
    6159        // init block type manager
    62         $opm = new BlockTypeManager();
    63         $opm->setup();
     60        $m = new BlockTypeManager();
     61        $m->setup();
    6462        // init template manager
    65         $opm = new TemplateManager();
    66         $opm->setup();
     63        $m = new TemplateManager();
     64        $m->setup();
    6765        /* end load pro component managers */
    6866        /* enqueue scripts */
    6967        add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] );
     68        // add the action delete file json post type or taxonomy
     69        add_action(
     70            'before_delete_post',
     71            [ $this, 'acfg_before_delete_post' ],
     72            10,
     73            1
     74        );
     75        /*
     76         * Handle rewrite flush if requested
     77         */
     78       
     79        if ( get_option( 'acfg_flush_rewrite', 0 ) == 1 ) {
     80            flush_rewrite_rules();
     81            update_option( 'acfg_flush_rewrite', 1 );
     82        }
     83   
     84    }
     85   
     86    public function acfg_before_delete_post( $id_acfg )
     87    {
     88        $acfg_post = get_post( $id_acfg );
     89       
     90        if ( $acfg_post->post_type == 'acfg_post_type' ) {
     91            $acfg_key = get_post_meta( $id_acfg, 'key', true );
     92            wp_delete_file( \AcfEngine\Plugin::dataStoragePath() . 'post-types/' . $acfg_key . '.json' );
     93        }
     94       
     95       
     96        if ( $acfg_post->post_type == 'acfg_taxonomy' ) {
     97            $acfg_key = get_post_meta( $id_acfg, 'key', true );
     98            wp_delete_file( \AcfEngine\Plugin::dataStoragePath() . 'taxonomies/' . $acfg_key . '.json' );
     99        }
     100   
    70101    }
    71102   
     
    97128           
    98129            $className = 'BlockType/' . $className;
     130        } elseif ( 0 === strpos( $className, 'AcfEngine\\Core\\PostType' ) ) {
     131            $className = str_replace( 'AcfEngine\\Core\\PostType\\', '', $className );
     132            $className = 'PostType/' . $className;
    99133        } else {
    100134            $className = str_replace( 'AcfEngine\\Core\\', '', $className );
     
    123157            '1.0.0',
    124158            false
    125         );
    126         wp_enqueue_script(
    127             'acfg-react',
    128             ACF_ENGINE_URL . 'build/index.js',
    129             array( 'wp-blocks', 'wp-element', 'wp-polyfill' ),
    130             '18a3fbe1ffe108ec652b0df97bee372e',
    131             true
    132159        );
    133160        wp_enqueue_style(
     
    154181   
    155182    // Create a helper function for easy SDK access.
    156     public function freemius()
     183    public static function freemius()
    157184    {
    158185        global  $afcgFreemius ;
  • acf-engine/trunk/fields/group_5f72fe851e515.json

    r2413640 r2415365  
    209209                        "id": ""
    210210                    },
    211                     "default_value": "",
     211                    "default_value": "dashicons-feedback",
    212212                    "placeholder": "dashicons-feedback",
    213213                    "prepend": "",
     
    343343        },
    344344        {
     345            "key": "field_5fa42099542d3",
     346            "label": "Update Item",
     347            "name": "update_item",
     348            "type": "text",
     349            "instructions": "",
     350            "required": 0,
     351            "conditional_logic": 0,
     352            "wrapper": {
     353                "width": "",
     354                "class": "",
     355                "id": ""
     356            },
     357            "default_value": "",
     358            "placeholder": "",
     359            "prepend": "",
     360            "append": "",
     361            "maxlength": ""
     362        },
     363        {
    345364            "key": "field_5f7e160a29a7d",
    346365            "label": "New Item",
     
    365384            "label": "View Item",
    366385            "name": "view_item",
     386            "type": "text",
     387            "instructions": "",
     388            "required": 0,
     389            "conditional_logic": 0,
     390            "wrapper": {
     391                "width": "",
     392                "class": "",
     393                "id": ""
     394            },
     395            "default_value": "",
     396            "placeholder": "",
     397            "prepend": "",
     398            "append": "",
     399            "maxlength": ""
     400        },
     401        {
     402            "key": "field_5fa420db542d4",
     403            "label": "View Items",
     404            "name": "view_items",
    367405            "type": "text",
    368406            "instructions": "",
     
    9801018        },
    9811019        {
     1020            "key": "field_5fa41742b552b",
     1021            "label": "Slug",
     1022            "name": "slug",
     1023            "type": "text",
     1024            "instructions": "",
     1025            "required": 0,
     1026            "conditional_logic": [
     1027                [
     1028                    {
     1029                        "field": "field_5f7f2f74c6ed3",
     1030                        "operator": "==",
     1031                        "value": "1"
     1032                    }
     1033                ]
     1034            ],
     1035            "wrapper": {
     1036                "width": "",
     1037                "class": "",
     1038                "id": ""
     1039            },
     1040            "default_value": "",
     1041            "placeholder": "defaults to hyphenated form of key such as \"vehicle\" or \"vehicle-type\"",
     1042            "prepend": "",
     1043            "append": "",
     1044            "maxlength": ""
     1045        },
     1046        {
     1047            "key": "field_5fa41754b552c",
     1048            "label": "With Front",
     1049            "name": "with_front",
     1050            "type": "true_false",
     1051            "instructions": "",
     1052            "required": 0,
     1053            "conditional_logic": [
     1054                [
     1055                    {
     1056                        "field": "field_5f7f2f74c6ed3",
     1057                        "operator": "==",
     1058                        "value": "1"
     1059                    }
     1060                ]
     1061            ],
     1062            "wrapper": {
     1063                "width": "",
     1064                "class": "",
     1065                "id": ""
     1066            },
     1067            "message": "",
     1068            "default_value": 1,
     1069            "ui": 1,
     1070            "ui_on_text": "",
     1071            "ui_off_text": ""
     1072        },
     1073        {
     1074            "key": "field_5fa41763b552d",
     1075            "label": "Feeds",
     1076            "name": "feeds",
     1077            "type": "true_false",
     1078            "instructions": "",
     1079            "required": 0,
     1080            "conditional_logic": [
     1081                [
     1082                    {
     1083                        "field": "field_5f7f2f74c6ed3",
     1084                        "operator": "==",
     1085                        "value": "1"
     1086                    }
     1087                ]
     1088            ],
     1089            "wrapper": {
     1090                "width": "",
     1091                "class": "",
     1092                "id": ""
     1093            },
     1094            "message": "",
     1095            "default_value": 1,
     1096            "ui": 1,
     1097            "ui_on_text": "",
     1098            "ui_off_text": ""
     1099        },
     1100        {
     1101            "key": "field_5fa4176eb552e",
     1102            "label": "Pages",
     1103            "name": "pages",
     1104            "type": "true_false",
     1105            "instructions": "",
     1106            "required": 0,
     1107            "conditional_logic": [
     1108                [
     1109                    {
     1110                        "field": "field_5f7f2f74c6ed3",
     1111                        "operator": "==",
     1112                        "value": "1"
     1113                    }
     1114                ]
     1115            ],
     1116            "wrapper": {
     1117                "width": "",
     1118                "class": "",
     1119                "id": ""
     1120            },
     1121            "message": "",
     1122            "default_value": 1,
     1123            "ui": 1,
     1124            "ui_on_text": "",
     1125            "ui_off_text": ""
     1126        },
     1127        {
     1128            "key": "field_5fa4177ab552f",
     1129            "label": "Ep Mask",
     1130            "name": "ep_mask",
     1131            "type": "true_false",
     1132            "instructions": "",
     1133            "required": 0,
     1134            "conditional_logic": [
     1135                [
     1136                    {
     1137                        "field": "field_5f7f2f74c6ed3",
     1138                        "operator": "==",
     1139                        "value": "1"
     1140                    }
     1141                ]
     1142            ],
     1143            "wrapper": {
     1144                "width": "",
     1145                "class": "",
     1146                "id": ""
     1147            },
     1148            "message": "",
     1149            "default_value": 1,
     1150            "ui": 1,
     1151            "ui_on_text": "",
     1152            "ui_off_text": ""
     1153        },
     1154        {
    9821155            "key": "field_5f7f674f17ae8",
    9831156            "label": "Advanced",
     
    10891262            "ui_on_text": "",
    10901263            "ui_off_text": ""
     1264        },
     1265        {
     1266            "key": "field_5fa861ae70b73",
     1267            "label": "has_archive_slug",
     1268            "name": "has_archive_slug",
     1269            "type": "text",
     1270            "instructions": "",
     1271            "required": 0,
     1272            "conditional_logic": 0,
     1273            "wrapper": {
     1274                "width": "",
     1275                "class": "",
     1276                "id": ""
     1277            },
     1278            "default_value": "",
     1279            "placeholder": "Default will match post type key",
     1280            "prepend": "",
     1281            "append": "",
     1282            "maxlength": ""
    10911283        },
    10921284        {
     
    12031395    "active": true,
    12041396    "description": "",
    1205     "modified": 1603045394
     1397    "modified": 1604870978
    12061398}
  • acf-engine/trunk/fields/group_5f7ed829eb760.json

    r2413640 r2415365  
    5858                "single_post": "Single Post",
    5959                "archive_page": "Archive Page",
    60                 "loop_post": "Post Loop",
    61                 "header": "Header",
    62                 "footer": "Footer"
     60                "loop_post": "Post Loop"
    6361            },
    6462            "allow_null": 0,
     
    102100            "append": "",
    103101            "maxlength": ""
     102        },
     103        {
     104            "key": "field_5fa6dc538e452",
     105            "label": "CSS",
     106            "name": "css",
     107            "type": "acf_code_field",
     108            "instructions": "",
     109            "required": 0,
     110            "conditional_logic": 0,
     111            "wrapper": {
     112                "width": "",
     113                "class": "",
     114                "id": ""
     115            },
     116            "default_value": "",
     117            "placeholder": "",
     118            "mode": "css",
     119            "theme": "monokai"
    104120        }
    105121    ],
     
    121137    "active": true,
    122138    "description": "",
    123     "modified": 1604085026
     139    "modified": 1604771444
    124140}
  • acf-engine/trunk/fields/group_5f90db6737ef5.json

    r2413640 r2415365  
    2121            "append": "",
    2222            "maxlength": ""
     23        },
     24        {
     25            "key": "field_5fa6629d372c8",
     26            "label": "Type",
     27            "name": "type",
     28            "type": "taxonomy",
     29            "instructions": "",
     30            "required": 0,
     31            "conditional_logic": 0,
     32            "wrapper": {
     33                "width": "",
     34                "class": "",
     35                "id": ""
     36            },
     37            "taxonomy": "acfg_type",
     38            "field_type": "checkbox",
     39            "add_term": 1,
     40            "save_terms": 0,
     41            "load_terms": 0,
     42            "return_format": "id",
     43            "multiple": 0,
     44            "allow_null": 0
    2345        },
    2446        {
     
    6183            "sub_fields": [
    6284                {
     85                    "key": "field_5fa66258fa5bd",
     86                    "label": "Date",
     87                    "name": "date",
     88                    "type": "date_picker",
     89                    "instructions": "",
     90                    "required": 0,
     91                    "conditional_logic": 0,
     92                    "wrapper": {
     93                        "width": "",
     94                        "class": "",
     95                        "id": ""
     96                    },
     97                    "display_format": "Y-m-d",
     98                    "return_format": "Y-m-d",
     99                    "first_day": 1
     100                },
     101                {
    63102                    "key": "field_5f90db997a73b",
    64103                    "label": "Result",
     
    81120                    "layout": "horizontal",
    82121                    "return_format": "value"
     122                },
     123                {
     124                    "key": "field_5fa7266dd3f9e",
     125                    "label": "Notes",
     126                    "name": "notes",
     127                    "type": "textarea",
     128                    "instructions": "",
     129                    "required": 0,
     130                    "conditional_logic": 0,
     131                    "wrapper": {
     132                        "width": "",
     133                        "class": "",
     134                        "id": ""
     135                    },
     136                    "default_value": "",
     137                    "placeholder": "",
     138                    "maxlength": "",
     139                    "rows": "",
     140                    "new_lines": ""
    83141                }
    84142            ]
     
    102160    "active": true,
    103161    "description": "",
    104     "modified": 1603328964
     162    "modified": 1604789891
    105163}
  • acf-engine/trunk/fields/group_5f9b154fa80ce.json

    r2413640 r2415365  
    9696                "value": "acf\/acfg-icon"
    9797            }
     98        ],
     99        [
     100            {
     101                "param": "block",
     102                "operator": "==",
     103                "value": "acf\/acfg-image-box"
     104            }
     105        ],
     106        [
     107            {
     108                "param": "block",
     109                "operator": "==",
     110                "value": "acf\/acfg-testimonial"
     111            }
    98112        ]
    99113    ],
     
    106120    "active": true,
    107121    "description": "",
    108     "modified": 1604001394
     122    "modified": 1604686175
    109123}
  • acf-engine/trunk/readme.txt

    r2413640 r2415365  
    66Tested up to: 5.5
    77Stable tag: 1.0
    8 Requires PHP: 7.4
     8Requires PHP: 7.3
    99License: GPLv3 or later
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2424Yes it is modelled after the JetEngine approach and was inspired by the comprehensive building tools provided by JetEngine. However ACF Engine diverges from JetEngine in two primary ways, first by using ACF exclusively as the meta field hander and secondly by taking a Gutenberg block first approach to rendering.
    2525
     26= How does ACF Engine store JSON definitions of objects? =
     27
     28ACF Engine parses all the data settings for a given object such as a custom post type, converts this into JSON and stores it under the "/acfengine" directory which is located at /wp-content/uploads/acfengine/. If you have 2 sites with ACF Engine running, you should find you can easily drop a JSON object definition file from one site to another and have that object load automatically.
     29
    2630== Screenshots ==
    2731
    28321. Main Menu
     332. ACF Engine Dashboard, provides an overview of all the objects you've created with ACF Engine and links to manage your objects.
    2934
    3035== Changelog ==
     36
     37= 1.0.3 =
     38* Fixed incorrect PHP version requirement listing
     39* Added new screenshots for the directory listing
     40* Optimized loading of core block types
     41* Removed RenderCode objects in favor of focusing on more Template options
    3142
    3243= 1.0.2 =
  • acf-engine/trunk/scripts/css/acfg.css

    r2413640 r2415365  
    1212 * Content Box Single Templates
    1313 */
    14  
     14
    1515/*
    1616.acfg-single-content {
     
    1919}
    2020*/
     21
     22/* Repeater Field Style Defaults */
     23.acfg-repeater {
     24  margin: 30px 0;
     25}
     26.acfg-repeater-item {
     27  margin: 25px;
     28  padding: 25px 0;
     29  border-bottom: solid 1px #D8D8D8;
     30}
  • acf-engine/trunk/src/AdminMenu.php

    r2413640 r2415365  
    4141            'acfg_block_type',
    4242            'acfg_template',
    43             'acfg_component',
    44             'acfg_render_code'
     43            'acfg_form',
     44            'acfg_component'
    4545        ];
    4646        if ( in_array( $current_screen->post_type, $cpts ) ) {
     
    103103            'edit.php?post_type=acfg_template'
    104104        );
    105         $plugin = new \AcfEngine\Plugin();
    106105    }
    107106   
  • acf-engine/trunk/src/BlockType/AcfField/AcfField.php

    r2413640 r2415365  
    3535
    3636        if( $isPreview ) {
    37             $templatePostType = get_field('post_type', $editorPostId);
    3837
    39             $previewPosts = get_posts([
    40                 'post_type' => $templatePostType
    41             ]);
    42             if( empty( $previewPosts )) {
    43                 print 'SORRY NO POSTS AVAILABLE TO USE FOR PREVIEW.';
    44                 return;
    45             }
     38            $previewPost = $this->getPreviewPost( $editorPostId );
     39            $postId = $previewPost->ID;
    4640
    47             $previewPost = $previewPosts[0];
    4841            $fieldKey = get_field('meta_key');
    4942        $fieldPostId = get_field('post_id');
     43
    5044            if( $fieldPostId == 'current' ) {
    5145                $fieldValue = get_field( $fieldKey, $previewPost->ID );
     
    5650            }
    5751
    58             print '<h2>';
    59         print $fieldValue;
    60         print '</h2>';
    61             return;
     52        } else {
     53
     54            // live render
     55            $postId = $editorPostId;
     56
     57            $fieldKey = get_field('meta_key');
     58        $fieldPostId = get_field('post_id');
     59
     60            if( $fieldPostId == 'current' ) {
     61                $fieldValue = get_field( $fieldKey, $editorPostId );
     62                $fieldObject = get_field_object( $fieldKey, $editorPostId );
     63            } else {
     64                $fieldValue = get_field( $fieldKey, $fieldPostId );
     65                $fieldObject = get_field_object( $fieldKey, $fieldPostId );
     66            }
    6267
    6368        }
    6469
    65     $data = $block['data'];
    66     $fieldKey = get_field('meta_key');
    67     $fieldPostId = get_field('post_id');
    68         $wrapTag = get_field('wrap_tag');
    69 
    70         if( $fieldPostId == 'current' ) {
    71             $fieldValue = get_field( $fieldKey, $editorPostId );
    72             $fieldObject = get_field_object( $fieldKey, $editorPostId );
    73         } else {
    74             $fieldValue = get_field( $fieldKey, $fieldPostId );
    75             $fieldObject = get_field_object( $fieldKey, $fieldPostId );
    76         }
    77 
    78         if( $fieldValue == '' || $wrapTag == '' ) {
     70        if( $fieldValue == '' ) {
    7971            return;
    8072        }
    8173
    82     print '<' . $wrapTag . '>';
     74    $this->render( $fieldObject, $fieldValue, $postId );
    8375
    84         $tl = new TemplateLoader();
     76  }
     77
     78
     79    protected function render( $fieldObject, $fieldValue, $postId ) {
     80
     81        $wrapTag = get_field('wrap_tag');
     82
     83        print '<' . $wrapTag . '>';
     84
     85        $tl = new \AcfEngine\Core\TemplateLoader();
    8586        $tl->path = 'templates/fields/' . $fieldObject['type'] . '/';
    8687        $tl->name = 'default';
    8788        $tl->data = [
    88             'field' => $fieldObject,
    89             'postId' => $editorPostId
     89            'value'     => $fieldValue,
     90            'field'     => $fieldObject,
     91            'postId'    => $postId
    9092        ];
    91 
    92         //var_dump( $tl );
    9393
    9494        $tl->render();
     
    9696    print '</' . $wrapTag . '>';
    9797
    98   }
    99 
    100     protected function renderPreview() {
    101 
    102 
    103 
    104 
    105     }
    106 
    107     protected function renderFront() {
    108 
    109 
    110 
    11198    }
    11299
  • acf-engine/trunk/src/BlockType/BlockQuote/BlockQuote.php

    r2413640 r2415365  
    2727  public function callback( $block, $content, $isPreview, $postId ) {
    2828
    29         if( $isPreview ) {
    30             $previewPost = $this->getPreviewPost( $postId );
    31             $postId = $previewPost->ID;
    32     }
    3329
    3430        $this->render( $block, $content, $postId );
     
    3733
    3834    protected function render( $block, $content, $postId ) {
    39         print 'BLOCK QUOTE';
     35        ob_start(); ?>
     36        <div class="acfg-blockquote-container">
     37            <blockquote class="acfg-blockquote"><?= get_field('text') ?></blockquote>
     38            <cite class="acfg-author">- <?= get_field('author') ?></cite>
     39        </div>
     40        <style>
     41            .acfg-blockquote-container{
     42                max-width: 600px !important;
     43                margin: auto;
     44            }
     45            .acfg-blockquote{
     46                font-weight: 100;
     47                font-style: italic;
     48                line-height: 1.4;
     49                position: relative;
     50                border: none;
     51
     52                <?php if( $fontSize = get_field('font_size') ) { ?>
     53                font-size: <?= $fontSize ?>px;
     54                <?php }else{ ?>
     55                font-size: 16px;
     56                <?php } ?>
     57
     58                <?php if( $padding = get_field('padding') ) { ?>
     59                padding: <?= $padding ?>px;
     60                <?php }else{ ?>
     61                padding: 8px;
     62                <?php } ?>
     63
     64                <?php if( $margin = get_field('margin') ) { ?>
     65                margin: <?= $margin ?>px !important;
     66                <?php }else{ ?>
     67                margin: 0 !important;
     68                <?php } ?>
     69
     70                <?php if( $color = get_field('color') ) { ?>
     71                    color: <?= $color ?>;
     72                <?php }else{ ?>
     73                    color: #000;
     74                <?php } ?>
     75            }
     76            .acfg-blockquote:before,
     77            .acfg-blockquote:after {
     78                position: absolute;
     79                color: #777777;
     80                font-size: 8rem;
     81                width: 4rem;
     82                height: 4rem;
     83            }
     84
     85            .acfg-blockquote:before {
     86                content: '“';
     87                left: -5rem;
     88                top: -2rem;
     89            }
     90
     91            .acfg-blockquote:after {
     92                content: '”';
     93                right: -4rem;
     94                bottom: 1rem;
     95            }
     96            .acfg-author {
     97                text-transform: capitalize;
     98                line-height: 3;
     99                text-align: left;
     100                max-width: 600px;
     101                width: 100%;
     102                color: #777777;
     103                font-weight: 700;
     104                <?php if( $padding = get_field('padding') ) { ?>
     105                    padding-left: <?= $padding ?>px;
     106                <?php }else{ ?>
     107                    padding-left: 0;
     108                <?php } ?>
     109            }
     110        </style>
     111
     112        <?php
     113        print ob_get_clean();
     114
    40115    }
    41116
  • acf-engine/trunk/src/BlockType/BlockTypeManager.php

    r2413640 r2415365  
    33namespace AcfEngine\Core\BlockType;
    44
    5 if (!defined('ABSPATH')) {
    6     exit;
     5if ( !defined( 'ABSPATH' ) ) {
     6    exit;
    77}
    8 
    9 class BlockTypeManager {
    10 
    11   public function setup() {
    12 
    13     add_action('save_post', [$this, 'savePost'], 10, 3);
    14     add_action('acf/init', [$this, 'registerBlockTypes']);
    15 
    16   }
    17 
    18 
    19   public function savePost( $postId, $post, $update ) {
    20 
    21     // only target our post type registrations
    22     if( $post->post_type !== 'acfg_block_type' ) {
    23       return;
    24     }
    25 
    26         $data = new \stdClass();
    27 
    28         $data->key = get_field('key', $postId);
    29         if( !$data->key ) {
    30             return;
    31         }
    32 
    33         $data->id = $postId;
    34         $data->title                    = get_field('title', $postId);
    35         $data->description      = get_field('title', $postId);
    36         $data->renderCode       = get_field('render_code', $postId);
    37         $data->category             = get_field('category', $postId);
    38         $data->icon                     = get_field('icon', $postId);
    39         $data->keywords             = get_field('keywords', $postId);
    40         $data->postTypes            = get_field('post_types', $postId);
    41         $data->mode                     = get_field('mode', $postId);
    42         $data->align                    = get_field('align', $postId);
    43         $data->alignText            = get_field('align_text', $postId);
    44         $data->alignContent     = get_field('align_content', $postId);
    45         $data->renderTemplate   = get_field('render_template', $postId);
    46         $data->renderCallback   = get_field('render_callback', $postId);
    47         $data->enqueueStyle     = get_field('enqueue_style', $postId);
    48         $data->enqueueScript    = get_field('enqueue_script', $postId);
    49         $data->enqueueAssets    = get_field('enqueue_assets', $postId);
    50         $data->supports             = get_field('supports', $postId);
    51 
    52         /* update post title */
    53         remove_action( 'save_post', [$this, 'savePost'] );
    54         wp_update_post(
    55             [
    56                 'ID' => $postId,
    57                 'post_title' => $data->title
    58             ]
    59         );
    60 
    61     $json = json_encode( $data );
    62     \file_put_contents( \AcfEngine\Plugin::dataStoragePath() . 'block-types/' . $data->key . '.json', $json );
    63 
    64   }
    65 
    66   public function registerBlockTypes() {
    67 
    68 
    69         /*
    70          * Register internal React block types
    71          */
    72         new FancyText();
    73         new NavBar();
    74 
    75         /*
    76          * Register internal ACF block types
    77          */
    78 
    79         $bt = new Accordion();
    80         $bt->init();
    81 
    82         $bt = new AcfTemplate();
    83         $bt->init();
    84 
    85         $bt = new AcfField();
    86         $bt->init();
    87 
    88         $bt = new AcfFieldNumber();
    89         $bt->init();
    90 
    91         $bt = new AcfFieldImage();
    92         $bt->init();
    93 
    94         $bt = new AcfRepeaterGallery();
    95         $bt->init();
    96 
    97         $bt = new BigHeadline();
    98         $bt->init();
    99 
    100         $bt = new Image();
    101         $bt->init();
    102 
    103         $bt = new Header();
    104         $bt->init();
    105 
    106         $bt = new Footer();
    107         $bt->init();
    108 
    109         $bt = new Heading();
    110         $bt->init();
    111 
    112         $bt = new TextEditor();
    113         $bt->init();
    114 
    115         $bt = new Video();
    116         $bt->init();
    117 
    118         $bt = new Button();
    119         $bt->init();
    120 
    121         $bt = new StarRating();
    122         $bt->init();
    123 
    124         $bt = new Icon();
    125         $bt->init();
    126 
    127         $bt = new CallToAction();
    128         $bt->init();
    129 
    130         $bt = new BlockQuote();
    131         $bt->init();
    132 
    133         $bt = new CountDown();
    134         $bt->init();
    135 
    136         $bt = new Counter();
    137         $bt->init();
    138 
    139         $bt = new Alert();
    140         $bt->init();
    141 
    142         $bt = new FlipBox();
    143         $bt->init();
    144 
    145         $bt = new Form();
    146         $bt->init();
    147 
    148         $bt = new GoogleMap();
    149         $bt->init();
    150 
    151         $bt = new Gallery();
    152         $bt->init();
    153 
    154         $bt = new Html();
    155         $bt->init();
    156 
    157         $bt = new IconBox();
    158         $bt->init();
    159 
    160         $bt = new IconList();
    161         $bt->init();
    162 
    163         $bt = new ImageBox();
    164         $bt->init();
    165 
    166         $bt = new ImageCarousel();
    167         $bt->init();
    168 
    169         $bt = new Login();
    170         $bt->init();
    171 
    172         $bt = new Logo();
    173         $bt->init();
    174 
    175         $bt = new Lottie();
    176         $bt->init();
    177 
    178         $bt = new Menu();
    179         $bt->init();
    180 
    181         $bt = new Posts();
    182         $bt->init();
    183 
    184         $bt = new PriceTable();
    185         $bt->init();
    186 
    187         $bt = new MenuAnchor();
    188         $bt->init();
    189 
    190         $bt = new Portfolio();
    191         $bt->init();
    192 
    193         $bt = new Slides();
    194         $bt->init();
    195 
    196         $bt = new ShareButtons();
    197         $bt->init();
    198 
    199         $bt = new Register();
    200         $bt->init();
    201 
    202         $bt = new Reviews();
    203         $bt->init();
    204 
    205         $bt = new ProgressBar();
    206         $bt->init();
    207 
    208         $bt = new Testimonial();
    209         $bt->init();
    210 
    211         $bt = new TableOfContents();
    212         $bt->init();
    213 
    214         $bt = new Tabs();
    215         $bt->init();
    216 
    217         $bt = new SocialIcons();
    218         $bt->init();
    219 
    220         $bt = new Users();
    221         $bt->init();
    222 
    223         $bt = new Toggle();
    224         $bt->init();
    225 
    226     // get all the data files stored
    227     $dataFiles = $this->findBlockTypeDataFiles();
    228 
    229     if( !empty( $dataFiles )) {
    230 
    231       foreach( $dataFiles as $filename ) {
    232 
    233         $data = $this->loadDataFile( $filename );
    234                 $obj    = $this->initObject( $data );
    235         $obj->register();
    236 
    237       }
    238     }
    239   }
    240 
    241     public function fetchByKey( $key ) {
    242 
    243         $posts = get_posts([
    244             'post_type'     => 'acfg_block_type',
    245             'numberposts' => -1,
    246             'meta_query' => [
    247                 [
    248                     'key'   => 'key',
    249                     'value' => $key
    250                 ]
    251             ]
    252         ]);
    253 
    254         if( !$posts || empty( $posts )) {
    255             return false;
    256         }
    257 
    258         return $posts[0];
    259 
    260     }
    261 
    262     public function initObject( $data ) {
    263         $obj = new BlockTypeCustom();
    264         $obj->setKey( $data->key );
    265         $obj->setTitle( $data->title );
    266         $obj->setDescription( $data->description );
    267         return $obj;
    268     }
    269 
    270     public function loadDataFile( $filename ) {
    271         $json = file_get_contents( \AcfEngine\Plugin::dataStoragePath() . 'block-types/' . $filename );
    272         return json_decode( $json );
    273     }
    274 
    275     // public option to get the data file list
    276     public function getDataFiles() {
    277         return $this->findBlockTypeDataFiles();
    278     }
    279 
    280   protected function findBlockTypeDataFiles() {
    281 
    282     $files = [];
    283         if( !is_dir( \AcfEngine\Plugin::dataStoragePath() . 'block-types')) {
    284             return [];
    285         }
    286     $dir = new \DirectoryIterator( \AcfEngine\Plugin::dataStoragePath() . 'block-types' );
    287 
    288     foreach ($dir as $fileInfo) {
    289       if (!$fileInfo->isDot()) {
    290         $files[] = $fileInfo->getFilename();
    291       }
    292     }
    293 
    294     return $files;
    295 
    296   }
    297 
    298 
    299 
     8class BlockTypeManager
     9{
     10    public function setup()
     11    {
     12        add_action(
     13            'save_post',
     14            [ $this, 'savePost' ],
     15            10,
     16            3
     17        );
     18        add_action( 'acf/init', [ $this, 'registerBlockTypes' ] );
     19    }
     20   
     21    public function savePost( $postId, $post, $update )
     22    {
     23        // only target our post type registrations
     24        if ( $post->post_type !== 'acfg_block_type' ) {
     25            return;
     26        }
     27        $data = new \stdClass();
     28        $data->key = get_field( 'key', $postId );
     29        if ( !$data->key ) {
     30            return;
     31        }
     32        $data->id = $postId;
     33        $data->title = get_field( 'title', $postId );
     34        $data->description = get_field( 'title', $postId );
     35        $data->renderCode = get_field( 'render_code', $postId );
     36        $data->category = get_field( 'category', $postId );
     37        $data->icon = get_field( 'icon', $postId );
     38        $data->keywords = get_field( 'keywords', $postId );
     39        $data->postTypes = get_field( 'post_types', $postId );
     40        $data->mode = get_field( 'mode', $postId );
     41        $data->align = get_field( 'align', $postId );
     42        $data->alignText = get_field( 'align_text', $postId );
     43        $data->alignContent = get_field( 'align_content', $postId );
     44        $data->renderTemplate = get_field( 'render_template', $postId );
     45        $data->renderCallback = get_field( 'render_callback', $postId );
     46        $data->enqueueStyle = get_field( 'enqueue_style', $postId );
     47        $data->enqueueScript = get_field( 'enqueue_script', $postId );
     48        $data->enqueueAssets = get_field( 'enqueue_assets', $postId );
     49        $data->supports = get_field( 'supports', $postId );
     50        /* update post title */
     51        remove_action( 'save_post', [ $this, 'savePost' ] );
     52        wp_update_post( [
     53            'ID'         => $postId,
     54            'post_title' => $data->title,
     55        ] );
     56        $json = json_encode( $data );
     57        \file_put_contents( \AcfEngine\Plugin::dataStoragePath() . 'block-types/' . $data->key . '.json', $json );
     58    }
     59   
     60    public function registerBlockTypes()
     61    {
     62        $this->registerInternalBlockTypes();
     63        $this->registerDefinedBlockTypes();
     64    }
     65   
     66    public function registerInternalBlockTypes()
     67    {
     68        /*
     69         * Register internal ACF block types
     70         */
     71        $bt = new Accordion();
     72        $bt->init();
     73        $bt = new AcfTemplate();
     74        $bt->init();
     75        $bt = new AcfField();
     76        $bt->init();
     77        $bt = new AcfFieldNumber();
     78        $bt->init();
     79        $bt = new AcfFieldImage();
     80        $bt->init();
     81        $bt = new BigHeadline();
     82        $bt->init();
     83        $bt = new Image();
     84        $bt->init();
     85        $bt = new Header();
     86        $bt->init();
     87        $bt = new Footer();
     88        $bt->init();
     89        $bt = new Heading();
     90        $bt->init();
     91        $bt = new TextEditor();
     92        $bt->init();
     93        $bt = new Video();
     94        $bt->init();
     95        $bt = new Button();
     96        $bt->init();
     97        $bt = new StarRating();
     98        $bt->init();
     99        $bt = new Icon();
     100        $bt->init();
     101        $bt = new CallToAction();
     102        $bt->init();
     103        $bt = new Alert();
     104        $bt->init();
     105        $bt = new BlockQuote();
     106        $bt->init();
     107        $bt = new CountDown();
     108        $bt->init();
     109        $bt = new Counter();
     110        $bt->init();
     111        $bt = new FlipBox();
     112        $bt->init();
     113        $bt = new Form();
     114        $bt->init();
     115        $bt = new GoogleMap();
     116        $bt->init();
     117        $bt = new Gallery();
     118        $bt->init();
     119        $bt = new Html();
     120        $bt->init();
     121        $bt = new IconBox();
     122        $bt->init();
     123        $bt = new IconList();
     124        $bt->init();
     125        $bt = new ImageBox();
     126        $bt->init();
     127        $bt = new ImageCarousel();
     128        $bt->init();
     129        $bt = new Login();
     130        $bt->init();
     131        $bt = new Logo();
     132        $bt->init();
     133        $bt = new Menu();
     134        $bt->init();
     135        $bt = new Posts();
     136        $bt->init();
     137        $bt = new MenuAnchor();
     138        $bt->init();
     139        $bt = new Portfolio();
     140        $bt->init();
     141        $bt = new Slides();
     142        $bt->init();
     143        $bt = new ShareButtons();
     144        $bt->init();
     145        $bt = new Register();
     146        $bt->init();
     147        $bt = new Reviews();
     148        $bt->init();
     149        $bt = new ProgressBar();
     150        $bt->init();
     151        $bt = new Testimonial();
     152        $bt->init();
     153        $bt = new Tabs();
     154        $bt->init();
     155        $bt = new SocialIcons();
     156        $bt->init();
     157        $bt = new Users();
     158        $bt->init();
     159        $bt = new Toggle();
     160        $bt->init();
     161    }
     162   
     163    public function registerDefinedBlockTypes()
     164    {
     165        // get all the data files stored
     166        $dataFiles = $this->findBlockTypeDataFiles();
     167        if ( !empty($dataFiles) ) {
     168            foreach ( $dataFiles as $filename ) {
     169                $data = $this->loadDataFile( $filename );
     170                $obj = $this->initObject( $data );
     171                $obj->register();
     172            }
     173        }
     174    }
     175   
     176    public function fetchByKey( $key )
     177    {
     178        $posts = get_posts( [
     179            'post_type'   => 'acfg_block_type',
     180            'numberposts' => -1,
     181            'meta_query'  => [ [
     182            'key'   => 'key',
     183            'value' => $key,
     184        ] ],
     185        ] );
     186        if ( !$posts || empty($posts) ) {
     187            return false;
     188        }
     189        return $posts[0];
     190    }
     191   
     192    public function initObject( $data )
     193    {
     194        $obj = new BlockTypeCustom();
     195        $obj->setKey( $data->key );
     196        $obj->setTitle( $data->title );
     197        $obj->setDescription( $data->description );
     198        return $obj;
     199    }
     200   
     201    public function loadDataFile( $filename )
     202    {
     203        $json = file_get_contents( \AcfEngine\Plugin::dataStoragePath() . 'block-types/' . $filename );
     204        return json_decode( $json );
     205    }
     206   
     207    // public option to get the data file list
     208    public function getDataFiles()
     209    {
     210        return $this->findBlockTypeDataFiles();
     211    }
     212   
     213    protected function findBlockTypeDataFiles()
     214    {
     215        $files = [];
     216        if ( !is_dir( \AcfEngine\Plugin::dataStoragePath() . 'block-types' ) ) {
     217            return [];
     218        }
     219        $dir = new \DirectoryIterator( \AcfEngine\Plugin::dataStoragePath() . 'block-types' );
     220        foreach ( $dir as $fileInfo ) {
     221            if ( !$fileInfo->isDot() ) {
     222                $files[] = $fileInfo->getFilename();
     223            }
     224        }
     225        return $files;
     226    }
    300227
    301228}
  • acf-engine/trunk/src/BlockType/Counter/Counter.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'COUNTER';
     39
     40        ob_start(); ?>
     41        <div class="acfg-counter">
     42            <p class="acfg-timer acfg-count-number" data-to='<?= get_field('final_number') ?>' data-speed='<?= get_field('timer') ?>'></p>
     43            <p class="acfg-count-title "><?= get_field('title') ?></p>
     44        </div>
     45        <style>
     46            .acfg-counter {
     47                padding: <?= get_field('padding') ?>px;
     48            }
     49            .acfg-count-number {
     50                font-size: <?= get_field('number_counter')['font_size_number'] ?>px;
     51                font-weight: <?= get_field('number_counter')['font_weight_number'] ?>;
     52                margin: <?= get_field('number_counter')['margin_number'] ?>px;
     53                text-align: center;
     54                color: <?= get_field('number_counter')['color_number'] ?>;
     55            }
     56            .acfg-count-title {
     57                font-size: <?= get_field('title_counter')['font_size_title'] ?>px;
     58                font-weight: <?= get_field('title_counter')['font_weight_title'] ?>;
     59                margin: <?= get_field('title_counter')['margin_title'] ?>px;
     60                text-align: center;
     61                color: <?= get_field('title_counter')['color_title'] ?>;
     62            }
     63        </style>
     64        <script>
     65            (function ($) {
     66                $.fn.countTo = function (options) {
     67                    options = options || {};
     68
     69                    return $(this).each(function () {
     70                        // set options for current element
     71                        var settings = $.extend({}, $.fn.countTo.defaults, {
     72                            from:            $(this).data('from'),
     73                            to:              $(this).data('to'),
     74                            speed:           $(this).data('speed'),
     75                            refreshInterval: $(this).data('refresh-interval'),
     76                            decimals:        $(this).data('decimals')
     77                        }, options);
     78
     79                        // how many times to update the value, and how much to increment the value on each update
     80                        var loops = Math.ceil(settings.speed / settings.refreshInterval),
     81                            increment = (settings.to - settings.from) / loops;
     82
     83                        // references & variables that will change with each update
     84                        var self = this,
     85                            $self = $(this),
     86                            loopCount = 0,
     87                            value = settings.from,
     88                            data = $self.data('countTo') || {};
     89
     90                        $self.data('countTo', data);
     91
     92                        // if an existing interval can be found, clear it first
     93                        if (data.interval) {
     94                            clearInterval(data.interval);
     95                        }
     96                        data.interval = setInterval(updateTimer, settings.refreshInterval);
     97
     98                        // initialize the element with the starting value
     99                        render(value);
     100
     101                        function updateTimer() {
     102                            value += increment;
     103                            loopCount++;
     104
     105                            render(value);
     106
     107                            if (typeof(settings.onUpdate) == 'function') {
     108                                settings.onUpdate.call(self, value);
     109                            }
     110
     111                            if (loopCount >= loops) {
     112                                // remove the interval
     113                                $self.removeData('countTo');
     114                                clearInterval(data.interval);
     115                                value = settings.to;
     116
     117                                if (typeof(settings.onComplete) == 'function') {
     118                                    settings.onComplete.call(self, value);
     119                                }
     120                            }
     121                        }
     122
     123                        function render(value) {
     124                            var formattedValue = settings.formatter.call(self, value, settings);
     125                            $self.html(formattedValue);
     126                        }
     127                    });
     128                };
     129
     130                $.fn.countTo.defaults = {
     131                    from: 0,               // the number the element should start at
     132                    to: 0,                 // the number the element should end at
     133                    speed: 1000,           // how long it should take to count between the target numbers
     134                    refreshInterval: 100,  // how often the element should be updated
     135                    decimals: 0,           // the number of decimal places to show
     136                    formatter: formatter,  // handler for formatting the value before rendering
     137                    onUpdate: null,        // callback method for every time the element is updated
     138                    onComplete: null       // callback method for when the element finishes updating
     139                };
     140
     141                function formatter(value, settings) {
     142                    return value.toFixed(settings.decimals);
     143                }
     144            }(jQuery));
     145
     146            jQuery(function ($) {
     147                // custom formatting example
     148                $('.acfg-count-number').data('countToOptions', {
     149                    formatter: function (value, options) {
     150                        return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ',');
     151                    }
     152                });
     153
     154                // start all the timers
     155                $('.acfg-timer').each(count);
     156
     157                function count(options) {
     158                    var $this = $(this);
     159                    options = $.extend({}, options || {}, $this.data('countToOptions') || {});
     160                    $this.countTo(options);
     161                }
     162            });
     163        </script>
     164        <?php
     165        print ob_get_clean();
    40166    }
    41167
  • acf-engine/trunk/src/BlockType/Html/Html.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'HTML';
     39        print get_field('code');
    4040    }
    4141
  • acf-engine/trunk/src/BlockType/IconBox/IconBox.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'ICON BOX';
     39        ob_start();
     40        $boxedWidth = get_field( 'boxed_width' );
     41        ?>
     42
     43        <div class="acfg-icon-box">
     44            <div class="acfg-iconbox">
     45                <span class="dashicons <?= get_field( 'icon' ) ?>"></span>
     46            </div>
     47            <div class="acfg-text">
     48                <span class="acfg-box"><?= get_field( 'text' ) ?></span>
     49            </div>
     50        </div>
     51
     52        <style>
     53            .acfg-iconbox .dashicons {
     54                font-size: <?= get_field( 'width' ) ?>px;
     55                width: <?= get_field( 'width' ) ?>px;
     56                height: <?= get_field( 'height' ) ?>px;
     57                color: <?= get_field( 'color' ) ?>;
     58            }
     59            <?php if  ($boxedWidth) { ?>
     60                .acfg-icon-box {
     61                    max-width: <?= get_field( 'max_width' ) ?>px !important;
     62                    margin-right: auto;
     63                    margin-left: auto;
     64                }
     65            <?php } ?>
     66            .acfg-icon-box {
     67                text-align: <?= get_field( 'alignment' ) ?>;
     68            }
     69            .acfg-text {
     70                padding: <?= get_field('box')['padding'] ?>px;
     71                margin: <?= get_field('box')['margin'] ?>px;
     72            }
     73            .acfg-text .acfg-box {
     74                font-size: <?= get_field('box')['font_size'] ?>px;
     75                font-weight: <?= get_field('box')['font_weight'] ?>;
     76                color: <?= get_field('box')['color'] ?>;
     77            }
     78        </style>
     79
     80        <?php
     81        print ob_get_clean();
    4082    }
    4183
  • acf-engine/trunk/src/BlockType/IconList/IconList.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'ICON LIST';
     39        ob_start();
     40        $boxedWidth = get_field( 'boxed_width' );
     41        ?>
     42
     43        <div class="acfg-icon-box">
     44            <div class="acfg-iconbox">
     45                <span class="dashicons <?= get_field( 'icon' ) ?>"></span>
     46            </div>
     47            <div class="acfg-text">
     48                <span class="acfg-box"><?= get_field( 'text' ) ?></span>
     49            </div>
     50        </div>
     51
     52        <style>
     53            .acfg-icon-box .acfg-iconbox .dashicons {
     54                font-size: <?= get_field( 'width' ) ?>px;
     55                width: <?= get_field( 'width' ) ?>px;
     56                height: <?= get_field( 'height' ) ?>px;
     57                color: <?= get_field( 'color' ) ?>;
     58            }
     59            <?php if  ($boxedWidth) { ?>
     60            .acfg-icon-box {
     61                max-width: <?= get_field( 'max_width' ) ?>px !important;
     62                margin-right: auto;
     63                margin-left: auto;
     64            }
     65            <?php } ?>
     66            .acfg-icon-box {
     67                text-align: left;
     68                display: flex;
     69                align-items: center;
     70            }
     71            .acfg-icon-box .acfg-text {
     72                padding: <?= get_field('box')['padding'] ?>px;
     73                margin: <?= get_field('box')['margin'] ?>px;
     74                line-height: 1.5;
     75            }
     76            .acfg-icon-box .acfg-text .acfg-box {
     77                font-size: <?= get_field('box')['font_size'] ?>px;
     78                font-weight: <?= get_field('box')['font_weight'] ?>;
     79                color: <?= get_field('box')['color'] ?>;
     80            }
     81        </style>
     82
     83        <?php
     84        print ob_get_clean();
    4085    }
    4186
  • acf-engine/trunk/src/BlockType/ImageBox/ImageBox.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'IMAGE BOX';
     39        ob_start();
     40        $image  = get_field('image');
     41        $size = 'full';
     42        $boxedWidth = get_field( 'boxed_width' );
     43        ?>
     44
     45        <div class="acfg-image-box">
     46            <figure>
     47                <?= wp_get_attachment_image( $image, $size ) ?>
     48                <figcaption><?= get_field( 'caption' ) ?></figcaption>
     49            </figure>
     50        </div>
     51        <style>
     52            .acfg-image-box {
     53                max-width: 100%;
     54                text-align: <?= get_field( 'alignment' ) ?>;
     55            }
     56            <?php if  ($boxedWidth) { ?>
     57            .acfg-image-box  {
     58                max-width: <?= get_field( 'max_width' ) ?>px !important;
     59                margin-right: auto;
     60                margin-left: auto;
     61            }
     62            <?php } ?>
     63            .acfg-image-box figcaption {
     64                font-size: <?= get_field('text_image_box')['font_size'] ?>px;
     65                font-weight: <?= get_field('text_image_box')['font_weight'] ?>;
     66                color: <?= get_field('text_image_box')['color'] ?>;
     67                background-color: <?= get_field('text_image_box')['background_color'] ?>;
     68                padding: <?= get_field('text_image_box')['padding'] ?>px;
     69                margin: <?= get_field('text_image_box')['margin'] ?>px;
     70            }
     71        </style>
     72        <?php
     73      print ob_get_clean();
    4074    }
    4175
  • acf-engine/trunk/src/BlockType/Testimonial/Testimonial.php

    r2413640 r2415365  
    3737
    3838    protected function render( $block, $content, $postId ) {
    39         print 'TESTIMONIAL';
     39      ob_start();
     40        $image  = get_field('image');
     41        $size = 'full';
     42        $boxedWidth = get_field( 'boxed_width' );
     43      ?>
     44        <div class="acfg-testimonials" >
     45            <div class="acfg-testimonial">
     46                <?= wp_get_attachment_image( $image, $size ) ?>
     47                <h2 class="acfg-tertimonial-name"><?= get_field( 'name' ) ?></h2>
     48                <h3 class="acfg-tertimonial-company"><?= get_field( 'company' ) ?></h3>
     49                <p class="acfg-tertimonial-content"><?= get_field( 'body' ) ?></p>
     50                <div class="acfg-tertimonial-stars" style="--rating: <?= get_field( 'rating' ) ?>;" aria-label="Rating of this product is 2.3 out of 5.">
     51            </div>
     52        </div>
     53        <style>
     54            :root {
     55                --star-size: <?= get_field('stars_testimonial')['font_size'] ?>px;
     56                --star-color: <?= get_field('stars_testimonial')['color'] ?>;
     57                --star-background: <?= get_field('stars_testimonial')['backgound_color'] ?>;
     58            }
     59            .acfg-tertimonial-stars {
     60                --percent: calc(var(--rating) / 5 * 100%);
     61
     62                display: inline-block;
     63                font-size: var(--star-size);
     64                font-family: Times; /* make sure ★ appears correctly */
     65                line-height: 1;
     66                height: ;
     67            }
     68            .acfg-tertimonial-stars::before {
     69                 content: "★★★★★";
     70                 letter-spacing: 3px;
     71                 background: linear-gradient(
     72                         90deg,
     73                         var(--star-background) var(--percent),
     74                         var(--star-color) var(--percent)
     75                 );
     76                 -webkit-background-clip: text;
     77                 -webkit-text-fill-color: transparent;
     78             }
     79            /* outer wrap div around list */
     80
     81            <?php if  ($boxedWidth) { ?>
     82            .acfg-testimonials  {
     83                max-width: <?= get_field( 'max_width' ) ?>px !important;
     84                margin: 30px auto;
     85            }
     86            <?php } ?>
     87
     88            /* singular testimonial */
     89            .acfg-testimonial {
     90                background-color: #FFF;
     91                border: solid 1px #D6D6D6;
     92                text-align: center;
     93                font-family: verdana, sans-serif;
     94                margin: 15px auto;
     95                padding: 25px;
     96                width: 600px;
     97            }
     98
     99            .acfg-testimonial img {
     100                height: <?= get_field('image_testimonial')['height'] ?>px !important;
     101                width: <?= get_field('image_testimonial')['height'] ?>px !important;
     102                margin: auto;
     103                border-radius: 50%;
     104            }
     105
     106            /* name */
     107            .acfg-testimonial h2 {
     108                color: <?= get_field('name_testimonial')['color'] ?>;
     109                font-size: <?= get_field('name_testimonial')['font_size'] ?>px;
     110                margin: <?= get_field('name_testimonial')['margin'] ?>px;
     111                padding: <?= get_field('name_testimonial')['padding'] ?>px;
     112            }
     113
     114            /* company */
     115            .acfg-testimonial h3 {
     116                color: <?= get_field('company_testimonial')['color'] ?>;
     117                font-size: <?= get_field('company_testimonial')['font_size'] ?>px;
     118                margin: <?= get_field('company_testimonial')['margin'] ?>px;
     119                padding: <?= get_field('company_testimonial')['padding'] ?>px;
     120            }
     121
     122            /* body */
     123            .acfg-testimonial p {
     124                color: <?= get_field('body_testimonial')['color'] ?>;
     125                font-size: <?= get_field('body_testimonial')['font_size'] ?>px;
     126                font-style: italic;
     127                margin: <?= get_field('body_testimonial')['margin'] ?>px;
     128                padding: <?= get_field('body_testimonial')['padding'] ?>px;
     129                text-align: <?= get_field( 'alignment' ) ?>;
     130            }
     131
     132        </style>
     133
     134        <?php
     135        print ob_get_clean();
    40136    }
    41137
  • acf-engine/trunk/src/Form.php

    r2413640 r2415365  
    2424   */
    2525  public function register() {
     26
     27        $args = $this->args();
     28        acf_register_form( $args );
    2629
    2730    }
  • acf-engine/trunk/src/TaxonomyManager.php

    r2413640 r2415365  
    6868
    6969    $json = json_encode( $data );
     70
     71    if (!is_dir(\AcfEngine\Plugin::dataStoragePath() . 'taxonomies/')) {
     72        mkdir(\AcfEngine\Plugin::dataStoragePath() . 'taxonomies/', 0777, true);
     73    }
     74
    7075    \file_put_contents( \AcfEngine\Plugin::dataStoragePath() . 'taxonomies/' . $data->key . '.json', $json );
    7176
  • acf-engine/trunk/templates/fields/button_group/default.php

    r2413640 r2415365  
    1 <?php print $value; ?>
     1<div class="acfg-field-button-group">
     2  <?php print $value; ?>
     3</div>
  • acf-engine/trunk/templates/fields/date_picker/default.php

    r2413640 r2415365  
    1 <?php print $value; ?>
     1<div class="acfg-field-date-picker">
     2  <?php print $value; ?>
     3</div>
  • acf-engine/trunk/templates/fields/repeater/default.php

    r2413640 r2415365  
    88
    99  while ( have_rows( $field['key'], $postId )) :
     10
     11    print '<div class="acfg-repeater-item">';
    1012
    1113    the_row();
     
    2628    }
    2729
     30    print '</div>';
     31
    2832  endwhile;
    2933
  • acf-engine/trunk/templates/fields/text/default.php

    r2413640 r2415365  
    1 <?php print $value; ?>
     1<div class="acfg-field-text">
     2  <?php print $value; ?>
     3<div>
  • acf-engine/trunk/templates/fields/textarea/default.php

    r2413640 r2415365  
    1 <?php print $value; ?>
     1<div class="acfg-field-textarea">
     2  <?php print $value; ?>
     3<div>
  • acf-engine/trunk/templates/singles/base.php

    r2413640 r2415365  
    4343</div><!-- .acfg-single-content -->
    4444
     45<!-- custom css -->
     46<?php
     47
     48$css = get_field('css', $templateId);
     49
     50print '<style>';
     51print $css;
     52print '</style>';
     53
     54?>
     55
    4556<?php get_footer(); ?>
Note: See TracChangeset for help on using the changeset viewer.