GithubHelp home page GithubHelp logo

flyntwp / flynt Goto Github PK

View Code? Open in Web Editor NEW
694.0 26.0 80.0 35.93 MB

Component based WordPress starter theme, powered by ACF Pro and Timber, optimized for a11y and fast page load results.

Home Page: https://flyntwp.com

License: MIT License

PHP 55.29% JavaScript 8.86% CSS 0.10% SCSS 15.89% Twig 19.86%
wordpress-starter-theme wordpress-theme wordpress acf timber components

flynt's Introduction

Flynt – WordPress Starter Theme for Developers

Fall in love with WordPress (again)

standard-readme compliant Build Status Code Quality

Flynt is a lightning-fast WordPress Starter Theme for component-based development with ACF Pro.

Dependencies

Install

  1. Clone this repo to <your-project>/wp-content/themes.
  2. Change the domain variable in flynt/vite.config.js to match your domain: const wordpressHost = 'http://your-project.test'
  3. Navigate to the theme folder and run the following command in your terminal:
# wp-content/themes/flynt
composer install
npm install
npm run build
  1. Open the WordPress backend and activate the Flynt theme.

Usage

To start developing run the following command:

# wp-content/themes/flynt
npm start

All files in assets and Components will now be watched for changes and served. Happy coding!

Build

After developing it is required to generate compiled files in the ./dist folder.

To generate the compiled files, run the following command:

# wp-content/themes/flynt
npm run build

To skip the linting process (optional) and to generate the compiled files, run the command:

# wp-content/themes/flynt
npm run build:production

Base Style

Flynt comes with a ready to use Base Style built according to our best practices for building simple, maintainable components. Go to domain/BaseStyle to see it in action.

Assets

The ./assets folder contains all global JavaScript, SCSS, images, and font files for the theme. Files inside this folder are watched for changes and compile to ./dist.

The main.scss file is compiled to ./dist/assets/main.css which is enqueued in the front-end.

The admin.scss file is compiled to ./dist/assets/admin.css which is enqueued in the administrator back-end of WordPress, so styles added to this file will take effect only in the back-end.

Lib & Inc

The ./lib folder includes helper functions and basic setup logic. You will most likely not need to modify any files inside ./lib. All files in the ./lib folder are autoloaded via PSR-4.

The ./inc folder is a more organised version of WordPress' functions.php and contains all custom theme logic. All files in the ./inc folder are automatically required.

For organisation, ./inc has three subfolders. We recommend using these three folders to keep the theme well-structured:

  • customPostTypes
    Use this folder to register custom WordPress post types.
  • customTaxonomies
    Use this folder to register custom WordPress taxonomies.
  • fieldGroups
    Use this folder to register Advanced Custom Fields field groups. (See Field Groups for more information.)

After the files from ./lib and ./inc are loaded, all components from the ./Components folder are loaded.

Page Templates

Flynt uses Timber to structure its page templates and Twig for rendering them. Timber's documentation is extensive and up to date, so be sure to get familiar with it.

As part of the Twig Extension the theme uses a Twig function in to render components into templates:

Besides the main document structure (in ./templates/_document.twig), everything else is a component.

Components

A component is a self-contained building-block. Each component contains its own layout, its ACF fields, PHP logic, scripts, and styles.

  ExampleComponent/
  ├── _style.scss
  ├── functions.php
  ├── index.twig
  ├── README.md
  ├── screenshot.png
  ├── script.js

The functions.php file for every component in the ./Components folder is executed during the WordPress action after_setup_theme. This is run from the ./functions.php file of the theme.

To render components into a template, see Page Templates.

Web Components

Web components provide a standard component model for encapsulation and interoperability HTML elements. Most components are based on an autonomous custom element called flynt-component.

To define the name of a specific component use the name attribute, which should match the component’s folder name, to be ensure that its JavaScript is loaded as specified (see JavaScript modules for more details).

For example:

<flynt-component name="BlockWysiwyg" …></flynt-component>

JavaScript modules

Using a module based approach, allows to breaks JavaScript into separate files and keep them encapsuled inside Components itself.

Different loading strategies can be defined for each component independently when using the custom element flynt-component:

  • load:on="idle"
    Initialises after full page load, when the browser enters idle state.
    Usage example: Elements that don’t need to be interactive immediately.
  • load:on="visible"
    Initialises after the element get visible in the viewport.
    Usage example: Elements that go “below the fold” or should be loaded when the user sees them.
  • load:on="load" (default)
    Initialises immediately when the page loads.
    Usage example: Elements that need to be interactive as soon as possible.
  • load:on:media="(min-width: 1024px)"
    Initialises when the specified media query matches.
    Usage example: Elements which may only be visible on certain screen sizes.

Example:

<flynt-component name="BlockWysiwyg" load:on="visible"></flynt-component>

If it makes logical sense, loading strategies can be combined:

<flynt-component name="NavigationMain" load:on="idle" load:on:media="(min-width: 1024px)">

With nested components the loading strategy is waiting for parents. If you have a component with load:on="idle" nested inside a component with load:on="visible", the child component will only be loaded on visible of the parent component.

Advanced Custom Fields

Defining Advanced Custom Fields (ACF) can be done in functions.php for each component. As a best practice, we recommend defining your fields inside a function named getACFLayout() which you can then call in a field group.

For example:

namespace Flynt\Components\BlockWysiwyg;

function getACFLayout()
{
    return [
        'name' => 'blockWysiwyg',
        'label' => __('Block: Wysiwyg', 'flynt'),
        'sub_fields' => [
            [
                'label' => __('Content', 'flynt'),
                'name' => 'contentHtml',
                'type' => 'wysiwyg',
                'delay' => 0,
                'media_upload' => 0,
                'required' => 1,
            ],
        ]
    ];
}

Field Groups

Field groups are needed to show registered fields in the WordPress back-end. All field groups are created in the ./inc/fieldGroups folder. Two field groups exist by default: pageComponents.php and postComponents.php.

We call the function getACFLayout() defined in the functions.php file of each component to load fields into a field group.

For example:

use ACFComposer\ACFComposer;
use Flynt\Components;

add_action('Flynt/afterRegisterComponents', function () {
    ACFComposer::registerFieldGroup([
        'name' => 'pageComponents',
        'title' => 'Page Components',
        'style' => 'seamless',
        'fields' => [
            [
                'name' => 'pageComponents',
                'label' => __('Page Components', 'flynt'),
                'type' => 'flexible_content',
                'button_label' => __('Add Component', 'flynt'),
                'layouts' => [
                    Components\BlockWysiwyg\getACFLayout(),
                ]
            ]
        ],
        'location' => [
            [
                [
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'page'
                ]
            ]
        ]
    ]);
});

Here we use the ACF Field Group Composer plugin, which provides the advantage that all fields automatically get a unique key.

ACF Option Pages

Flynt includes several utility functions for creating Advanced Custom Fields options pages. Briefly, these are:

  • Flynt\Utils\Options::addTranslatable
    Adds fields into a new group inside the Translatable Options options page. When used with the WPML plugin, these fields will be returned in the current language.
  • Flynt\Utils\Options::addGlobal
    Adds fields into a new group inside the Global Options options page. When used with WPML, these fields will always be returned from the primary language. In this way these fields are global and cannot be translated.
  • Flynt\Utils\Options::getTranslatable
    Retrieve a translatable option.
  • Flynt\Utils\Options::getGlobal
    Retrieve a global option.

Timber Dynamic Resize

Timber provides a resize filter to resize images on first page load. Resizing many images at the same time can result in a server timeout. That's why Flynt provides a resizeDynamic filter, that resizes images asynchronously upon first request of the image itself. Resized images are stored in uploads/resized. To regenerate all image sizes and file versions, delete the folder.

To enable Dynamic Resize, go to Global Options -> Timber Dynamic Resize.

Twig Extensions

readingTime (Type: Filter)

Returns the reading time of a string in minutes.

{{ 'This is a string'|readingTime }}

Example from Components/GridPostsArchive/index.twig


renderComponent($componentName, $data) (Type: Function)

Renders a component. See Page Templates.

{% for component in post.meta('pageComponents') %}
    {{ renderComponent(component) }}
{% endfor %}

Example from templates/page.twig

placeholderImage($width, $height, $color = null) (Type: Function)

Useful in combination with lazysizes for lazy loading. Returns a "data:image/svg+xml;base64" placeholder image.

{{ placeholderImage(768, 512, 'rgba(125, 125, 125, 0.1)') }}

Example from Components/BlockImage/index.twig


resizeDynamic($src, $w, $h = 0, $crop = 'default', $force = false) (Type: Filter)

Resizes an image dynamically. See Timber Dynamic Resize.

{{ post.thumbnail.src|resizeDynamic(1920, (1920 / 3 * 2)|round, 'center') }}

Example from Components/BlockImage/index.twig


Troubleshooting

Images

In some setups images may not show up, returning a 404 by the server.

The most common reason for this is that you are using nginx and your server is not set up in the the recommended standard. You can see that this is the case, if an image url return a 404 from nginx, not from WordPress itself.

In this case, please add something like

location ~ "^(.*)/wp-content/uploads/(.*)$" {
  try_files $uri $uri/ /index.php$is_args$args;
}

to your site config.

Other issues might come from Flynt not being able to determine the relative url of your uploads folder. If you have a non-standard WordPress folder structure, or if you use a plugin that manipulates home_url (for example, WPML) this can cause problems when using resizeDynamic.

In this care try to set the relative upload path manually and refresh the permalink settings in the back-end:

add_filter('Flynt/TimberDynamicResize/relativeUploadDir', function () {
    return 'app/uploads'; // Example for Bedrock installs.
});

SSL certificate for dev server

If you want to use https in development, please define the following variables inside a .env file:

VITE_DEV_SERVER_HOST=https://your-project.test
VITE_DEV_SERVER_KEY=<path-to-ssl-certificate-key>/your-project.test_key.pem
VITE_DEV_SERVER_CERT=<path-to-ssl-certificate-cert>/your-project.test_cert.pem

Maintainers

This project is maintained by Bleech.

The main people in charge of this repo are:

Contributing

To contribute, please use GitHub issues. Pull requests are accepted. Please also take a moment to read the Contributing Guidelines and Code of Conduct.

If editing the README, please conform to the standard-readme specification.

License

MIT © Bleech

flynt's People

Contributors

aaronmeder avatar alexheinrich avatar ashanticode avatar berdeb avatar biozed avatar domtra avatar emcarru avatar hanifbirgani avatar harunbleech avatar jobvdmeer avatar koukouchris avatar lukashfmn avatar madflip avatar maltekiessling avatar mrnmrhcs avatar myempireofducttape avatar nikola-bleech avatar steffenbew avatar szepeviktor avatar timohubois avatar usingthesystem avatar vanaf1979 avatar vandebled 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flynt's Issues

Restrict access to .twig files

I think it's better to restrict access to .twig files in the webserver config level.

Apache:

<FilesMatch ".+\.twig$">
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order deny,allow
        Deny from all
    </IfModule>
</FilesMatch>

Nginx:

location ~- \.twig$ {
  deny all;
}

Performance metrics?

This is a very intriguing starter. Based on a first look, webcomponents and ACF appear to be a rhyming couplet. Do you have performance metrics?

Move component to another page

Hi guys. Many thanks for all your work.

Could you please clarify if there is a possibility to move a component to another page? It seems like a very basic functionality, however I wasn't able to do this, no matter how long I was trying to. Let's assume I have some component with lots of data set up for a homepage, and I want to move it to some other page with all its data, is it correct that I will need to enter all content once again? That may be unbelievable waste of time.

I was trying a few plugins, like ACF Extended, but it didn't help with the problem, the only thing I noticed is possibility to clone component within same page, but not to another one.

Thanks a lot in advance for your help!

Alex

Introduce static analysis

Adding @phpstan to CI is like adding 100 pairs of eyes.

composer require --dev szepeviktor/phpstan-wordpress php-stubs/acf-pro-stubs

phpstan.neon.dist

includes:
    - vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
    level: max
    inferPrivatePropertyTypeFromConstructor: true
    dynamicConstantNames:
        - WP_ENV
    paths:
        - lib/
        - inc/
    autoload_files:
        - vendor/paulthewalton/acf-pro-stubs/acf-pro-stubs.php
        - vendor/twig/twig/src/Extension/CoreExtension.php
        - inc/timberLoader.php
        # Includes
        - inc/baseStyle.php
        - inc/componentLogServer.php
        - inc/fieldVariables.php
        - inc/options.php
        - inc/theContentFix.php
        - inc/tinyMce.php
        - inc/yoastToBottom.php
        - inc/youtubeNoCookieEmbed.php
        # Components
        - Components/BlockCollapse/functions.php
        #- Components/BlockCookieNotice/functions.php
        - Components/BlockImage/functions.php
        - Components/BlockImageText/functions.php
        #- Components/BlockNotFound/functions.php
        #- Components/BlockPostHeader/functions.php
        - Components/BlockVideoOembed/functions.php
        - Components/BlockWysiwyg/functions.php
        - Components/FeatureAdminComponentScreenshots/functions.php
        #- Components/FeatureGoogleAnalytics/functions.php
        - Components/FormPasswordProtection/functions.php
        - Components/GridImageText/functions.php
        #- Components/GridPostsArchive/functions.php
        - Components/GridPostsLatest/functions.php
        - Components/ListComponents/functions.php
        #- Components/ListSearchResults/functions.php
        #- Components/NavigationBurger/functions.php
        #- Components/NavigationFooter/functions.php
        #- Components/NavigationMain/functions.php
        - Components/SliderImages/functions.php
    ignoreErrors:
        # Uses func_get_args()
        - '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'

then run vendor/bin/phpstan analyze -l 4

Please consider reading https://www.php-fig.org/psr/psr-1/#23-side-effects
...which implies loading Components with PSR-4 (aka. Composer loader) and being implemented as classes.

Question: Preloaded Components

Hello,

I'm developing a website using Flynt and have really enjoyed is so far. I'm curious if there's an good way to pre-populate specific components on and page with the same template, just like is available with standard ACF. I have tried to find a solution by digging around in the code, but haven't come up with anything. If this is possible and someone could explain it to me I would really appreciate it.

Thanks

Child theme support

Hi, I don't do much Wordpress, and just wanted to ask if child theme is supported with Flynt...and if so, what do I have to do to get it up and running?

Thanks

Warning: in_array() expects parameter 2 to be array, string given in flynt-1.1.0\inc\theContentFix.php on line 24

Hello,

After adding slider componet when I tried to save page I got this warning.
Warning: in_array() expects parameter 2 to be array, string given in flynt-1.1.0\inc\theContentFix.php on line 24

if (in_array([
'revision',
'nav_menu_item',
'attachment',
'customize_changeset'
], $postArr['post_type'])) {

Shouldn't be it like

if (in_array($postArr['post_type'], [ 'revision', 'nav_menu_item', 'attachment', 'customize_changeset' ])) {

Regards

composer install - command not found

Hi, I'm tying to install Flynt on my wordpress on localhost. I'm having troubles with composer install:

***-MBP:flynt-1.1.1 ***$ composer install
-bash: composer: command not found

Can please someone help me with this?

localhost:3000 not responding

Hey guys, I installed your theme to my local wordpress but I can't seem to run it properly. I get to position 5. "Run npm run start and start developing. Your local server is available at localhost:3000."

I run the command, Windows Firewall is asking for permission, but after that, I get a message from my browser, that the webserver is not responding. I can open my wordpress installation and see that the theme is installed correctly. But I can't access the localhost:3000.

I tried googling but that didn't help yet. Obviously. ;) So it would be very nice to hear from you guys.

Regards,
Michael

Remove jQuery

I have searched the whole front-end codes of Flynt to find jQuery usages and got the following results:

  • getScript (2 files)
  • DOM Selector (6 files)
  • Event handler (6 files)
  • Class manipulation (3 files)
  • Get element width/height (2 files)
  • Find (1 file)
  • Data attribute handling (2 files)
  • Style manipulation (1 file)

All of the functions above could be written in lightweight vanilla js for better optimization, speedup page loads, and reduce depending on massive old libraries like jquery. What do you think about getting rid of jquery?

Images have no height

I am using a clean install of the theme to test with, on a clean install of WP. I have made no changes whatsoever other than configuring the host URL. Using any component that has images, none of the images have a set height, so they do not appear.

Screen Shot 2019-12-09 at 10 18 43 AM

Screen Shot 2019-12-09 at 10 18 56 AM

I regenerated the thumbnails to be sure, but that nad no effect. The above images are inspecting the Block: Image Text component, but this issue occurs so far in all components that can use an image.

Pregmatch compilation error

Hi again

it works fine so far, but on pages / posts i get a compilation error:

preg_match(): Compilation failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 5 in D:\laragon\www\XXX\wp-includes\class-wp.php on line 222

And yes, its Windows :)

Remove Gutenberg styles from the head tag

Considering that Flynt disables the Gutenberg by default, we can safely remove Gutenberg styles from the head tag:

/**
 * Remove Gutenberg default styles
 */
add_action('wp_print_styles', function (): void {
    wp_dequeue_style('wp-block-library');
    wp_dequeue_style('wp-block-library-theme');
});

I can make a PR to add this to the core.

Minify JS/CSS

Hi, how can I activate the minification of the css and js files?

Thanks

Using FlyntWP with Gatsby

Heyho. I recently fell in love with GatsbyJS and would love to try Flynt out in combination with Gatsby to create static websites. Did you ever had a thought on that or have an idea how this could be implemented with the current Flynt stack?

Is there a way to get page components via the WPJSON API or do we need to make adjustments to make FlyntWP headless compatible?

Call custom function not working

I have a custom non WordPress function I would like to call, and tried the Timber docs with the examples mentioned there but it only throws errors.

Basically I would like to call the following function in the templates where needed with arguments to return the appropriate SVG Icon.

function get_svg_icon( $icon , $class = NULL ) { $svg = '<svg class="icon icon-' . $icon . ' ' . $class . '"><use xlink:href="'. get_bloginfo('template_url') . '/dist/assets/icons/symbol-defs.svg#' . $icon . '"></use></svg>'; return $svg; }

Uncaught Error: Flynt\Utils\acf_add_options_page()

Hi guys,

i installed Flynt, changed the const host to localhost and called https:localhost:3000.
Then i installed the plugin that you have to install and after reloading the page i got this error.

Maybe someone could get me a hint what to do now ;-)

Fatal error: Uncaught Error: Call to undefined function Flynt\Utils\acf_add_options_page() in C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\Options.php:77 Stack trace: #0 C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\Options.php(96): Flynt\Utils\Options::createOptionPage('global') #1 C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\Options.php(204): Flynt\Utils\Options::createOptionSubPage('global', 'Default') #2 C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\Options.php(199): Flynt\Utils\Options::addOptions('Acf', Array, 'global', 'Default') #3 C:\xampp\htdocs\wp-content\themes\flynt\inc\acf.php(33): Flynt\Utils\Options::addGlobal('Acf', Array) #4 C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\FileLoader.php(66): require_once('C:\xampp\htdocs...') #5 [internal function]: Flynt\Utils\FileLoader::Flynt\Utils{closure}(Object(DirectoryIterator)) #6 C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\FileLoader.php(34): call_user_func(Object(Closure), Object(DirectoryIterator)) #7 C:\xampp\htdocs\wp-content\th in C:\xampp\htdocs\wp-content\themes\flynt\lib\Utils\Options.php on line 77

Main Nav Support Drop down

Is the main navigation supposed to support drop down menus? It looks like the footer nav has a sub-menu with {% if item.get_children and level + 1 <= maxLevel %} but it doesn't work.

I tried to use the timber nav walker but couldn't get the css to work using level-1 and level 2. It appears that the css is missing for level-0.

Any help would be appreciated.

Dave

Min. PHP

What is the minimum PHP version?

Please add it to composer.json.
Thanks.

All Components are not showing in backend editor

Hi
I have installed the theme but I can see there are total 9 components showing into editor.
image

I can see there are 21 components files into theme but only 9 are rendering.

Please help me ASAP.

Thanks

Connecting an application (plugin) to Flynt

Hello!

I'm planning implement our application as a WordPress plugin plus some Composer packages and use Flynt.

What would you suggest to send content (HTML output) from the plugin to Flynt?
I'd like something better (something OOP) than shortcodes or actions.
What do you have to offer?

Cc: @Jony-Shark

A lot of PHPCBF errors on fresh install

Hello,
i made a fresh install with the latest node (13.12.0) and when i run npm run build i get for every php file an error:

Example:

1 | ERROR | [x] End of line character is invalid; expected "\n" but
| | found "\r\n"
| | (Generic.Files.LineEndings.InvalidEOLChar)
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY

Along with

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: run-s --silent checkVersion clean lint build:production build:rev
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

editor-style technique

Hello team Flynt (and Bleech)!

I normally create an editor-style.css so I can customise the css within the TinyMce editor. And since the theme is using SASS, it makes sense to try and utilise the SASS process to generate this stylesheet, so it can inherit styles.

This is how I achieved it - is this a good method, or would you guys have achieved this in a more optimal way?
In an ideal world I wouldn't want to be editing the build-config.js, but I didn't see any other way?

/build-config.js

  webpack: {
    entry: {
      "assets/main": "./assets/main.js",
      "assets/admin": "./assets/admin.js",
      "assets/editor-style": "./assets/editor-style.js",
    },
    copy: [getCopyConfig("./Components/**/*"), getCopyConfig("./assets/**/*")],
  },

/inc/tinyMce.php

// Editor Styles
add_editor_style('dist/assets/editor-style.css');

/assets/editor-style.js

import "./scripts/publicPath";
import "./editor-style.scss";

function importAll(r) {
  r.keys().forEach(r);
}

importAll(require.context("../Components/", true, /\/editor-style\.js$/));

/assets/editor-style.scss

@import "styles/variables";
@import "styles/mixins";
@import "styles/base";
etc.

Cheers,
Tim

p.s. I'm loving the new theme release v1+. So thank you for that!
It's a huge improvement over the beta version, and already feels a lot faster to use : )

How can I add my new class for new wordpress custom widget?

I made the file like the following:

themes\flynt\Components\SiteFooter\Widgets\WPMobileAppNavMenuWidget.php

and that file content like the following:

<?php

namespace Flynt\Components\SiteFooter\Widgets;

use WP_Widget;

class WPMobileAppNavMenuWidget extends WP_Widget
{
....
}

and I tried to use above Class in themes\flynt\Components\SiteFooter\functions.php

like this

<?php

namespace Flynt\Components\SiteFooter;

use Flynt\Components\SiteFooter\Widgets\WPMobileAppNavMenuWidget;

add_action('widgets_init', function () {
    register_widget('Flynt\Components\SiteFooter\Widgets\WPMobileAppNavMenuWidget');
})

but it didn't worked. so I added the require function like the following

<?php

namespace Flynt\Components\SiteFooter;

require_once dirname(__FILE__) . '/Widgets/WPMobileAppNavMenuWidget.php';

add_action('widgets_init', function () {
    register_widget('Flynt\Components\SiteFooter\Widgets\WPMobileAppNavMenuWidget');
})

after that, code is working.
but I would like to avoide to use require_once.
how can I do this on Flynnt theme?
thanks

Oembed.php: vimeo embed warning

When embedding vimeo videos, a warning message appears:

Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1 in /web/app/themes/.../lib/Utils/Oembed.php on line 24 

It can be suppressed by prepending the line with an @ symbol:

@$Dom->loadHTML($iframeTagHtml);

Theme breaks after removing default components

I would like to use flynt as a framework, but build my own components. On a fresh install of the flynt starter theme, things work great. However, if I delete all the default components from the components directory, the theme breaks completely. I can only get a 500 response when I try to access either the frontend or the admin dashboard that says, "The site is experiencing technical difficulties."

I was expecting/hoping that I could use flynt but with my own components and not the built in flynt ones, is this supposed to be possible or is it impossible by design? If not, are all the default components required or is there a minimum requirement? I would like to remove as many unused things as I can.

Base Style Select Field styling is off on Firefox

Problem
The select field seems to be a bit off on Firefox (MacOS). I presume the behaviour is the same on other operation systems.

Expected Behaviour
The select field should look the same as in Chrome

Information
Firefox Version: Firefox 71.0b10
MacOS Version: MacOS Mojave 10.14.6

grafik

WPML Language Drop Down List doesn't add to the header menu

Hello

add_filter('Flynt/addComponentData?name=SiteHeader', function ($data) {
    $data['header_menu'] = new Timber\Menu('header_menu');
    $data['logo'] = [
        'src' => Asset::requireUrl('Components/SiteHeader/Assets/logo.png'),
        'alt' => get_bloginfo('name')
    ];

    return $data;
});
      {% for item in header_menu.items %}
        <li class="{{ item.classes | join(' ') }}">
          <a href="{{ item.link }}">{{ item.title }}</a>
          {% if item.children %}
            <ul class="submenu">
              {% for child in item.children %}
                <li class="{{ child.classes | join(' ') }}">
                    <a href="{{ child.link }}">{{ child.title }}</a>
                </li>
              {% endfor %}
            </ul>
          {% endif %}
        </li>
      {% endfor %}

for navigation, I used the above code.
and I want two languages for English and Portugues.
but when I set Menu language switcher on WPML, only the current language(English) item is added to the header menu.

How can I fix that issue?

Regards

Optional Gutenberg support

Hey FlyntWP / bleech team! Hope everything is fine!

For the last 4 days I played around with the new ACF Pro Gutenberg Blocks in ACF Pro 5.8 and I think it's now way easier to register Flynt components into Gutenberg and also load necessary style and javascript files for the admin area.

I worked on a prototype and got dynamic component registration working for Gutenberg outside of the Flynt ecosystem. I started to implement optional Gutenberg component registration and Component rendering into the Flynt theme yesterday and look forward to send a pull request very soon.

Are you already working on something similar?

My current state looks as following:

  1. Implemented a useGutenberg protected static variable in the Defaults class
  2. Added the useGutenberg static function to update the protected variable
  3. Added useGutenberg(false) into the Init.php
  4. Added a check for the useGutenberg variable in the RemoveEditor.php file (If set to true, the default editor will be loaded with Gutenberg activated)
  5. Disabled Component Registration via ACF layouts in the API class when useGutenberg is true

Now I'm working on the registration via acf_register_block_type() and updating the renderer to use the_content() if Gutenberg is enabled instead of the dynamic renderer via the ACF layout field.

Obviously there are some differences and incompatibilities with the ACF layout approach and the Gutenberg approach.

I also think there should be an option to remove the default Wordpress blocks to keep Flynt components clean and simple and avoid mixing them with default Wordpress blocks.

Happy to hear from you and have some insights or thoughts from you.

PS:
The new and simpler approach back to the Wordpress roots is really refreshing and fun to work with! Great job!

missing autoload.php

When I go through the install process and then activate the theme I get the following error in the browser: Warning: require_once(/var/www/html/wp-content/themes/flynt-1.1.1/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/wp-content/themes/flynt-1.1.1/functions.php on line 7
I feel like I have missed a step but I'm not sure what?

feat: Ideas to make it reusable accross projects

Hello,

I am familiarizing with the framework and really like what you have achieved, thanks for sharing with the community!

I was planning to use it as a core-framework for multiple websites, thus creating a local composer package that I'd pull into each site, that would bring common Components (especially admin ones), the logic (most of the /lib files and /inc files) and admin assets.
Website specific content/settings would need to be outside of the core framework:

  • Components (thus should be loadable from multiple folders)
  • global frontend assets
  • inc/customPostTypes
  • inc/customTaxonomies
  • inc/fieldsGroups

Have you considered at one point doing this kind of setup?

I stumbled upon stoutlogic ACF builder which seems to do the same as your acf-field-group-composer but in a less verbose way, is there any major features missing in ACF builder that would prevent the switch?

Gutenberg support?

Is there documentation on accessing the Gutenberg editor?
Is there a way to restore the default wordpress editor when editing a post?

Error Message: Unable to Find Template

Hi, I'm using Flynt Premium. I unzipped the file into the theme\flynt\Components\ folder.

I am getting the following error message:
Fatal error: Uncaught Twig\Error\LoaderError: Unable to find template
"D:/Bitnami2/project-sunshine/apps/wordpress/htdocs/wp-content/themes/flynt/Components/PremiumComponents/HeroImageText/index.twig"
(looked into:
D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt,
D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\views, ,
D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\Components\PremiumComponents/HeroImageText).

in D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\templates\page.twig:5
Stack trace: #0 D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\vendor\twig\twig\src\Loader\FilesystemLoader.php(150):
Twig\Loader\FilesystemLoader->findTemplate('D:/Bitnami2/pro...') #1 D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\vendor\twig\twig\src\Environment.php(299):
Twig\Loader\FilesystemLoader->getCacheKey('D:\Bitnami2\pro...')
#2 D:\Bitnami2\project-sunshine\apps\wordpre in D:\Bitnami2\project-sunshine\apps\wordpress\htdocs\wp-content\themes\flynt\templates\page.twig on line 5

The HeroImageText components file is in the directory. Although I did notice a back-slash right before the component name e.g. \PremiumComponent/HeroImageText .
Any help debugging would be appreciated.

Default component added to a new page?

Hi team Flynt!

I have a question about the Field Groups - is it possible to have a 'default' component added to a newly created page in the admin?

For example, with the code below, I'm currently only registering 1 component in this particular field group, so when the client creates a new page (or taxonomy as this would be), it would be handy if this component was added to the page by default.

Any thoughts or tips would be much appreciated!

Cheers,
Tim

<?php

use ACFComposer\ACFComposer;
use Flynt\Components;

add_action('Flynt/afterRegisterComponents', function () {
    ACFComposer::registerFieldGroup([
        'name' => 'moduleComponents',
        'title' => 'Module Components',
        'style' => 'seamless',
        'fields' => [
            [
                'name' => 'moduleComponents',
                'label' => __('Module Components', 'flynt'),
                'type' => 'flexible_content',
                'button_label' => __('Add Component', 'flynt'),
                'layouts' => [Components\TopicTemplate1\getACFLayout()],
            ],
        ],
        'location' => [
            [
                [
                    'param' => 'taxonomy',
                    'operator' => '==',
                    'value' => 'module',
                ],
            ],
        ],
    ]);
});

Activating Yoast SEO creates fatal error

When I activate the Yoast SEO plugin, I get this fatal error:

Fatal error: Uncaught Error: Class 'Flynt\Init' not found in /Users/spencer/DEKSIA/flynt/wp-content/themes/flynt/functions.php:16 Stack trace: #0 /Users/spencer/DEKSIA/flynt/wp-settings.php(497): include() #1 /Users/spencer/DEKSIA/flynt/wp-config.php(90): require_once('/Users/spencer/...') #2 /Users/spencer/DEKSIA/flynt/wp-load.php(37): require_once('/Users/spencer/...') #3 /Users/spencer/DEKSIA/flynt/wp-admin/admin.php(34): require_once('/Users/spencer/...') #4 /Users/spencer/DEKSIA/flynt/wp-admin/plugins.php(10): require_once('/Users/spencer/...') #5 {main} thrown in /Users/spencer/DEKSIA/flynt/wp-content/themes/flynt/functions.php on line 16

Create Action Ajax Wordpress on Component

Hello,
I'm having trouble creating an ajax action with:

function test_callback() {
echo 'test';
}
add_action ('wp_ajax_test', 'test_callback');
add_action ('wp_ajax_nopriv_test' ',' test_callback ');

If I insert the declaration on the function.php file of the component, wordpress does not see it.
If instead I insert the declaration on the file inc/theme.php then it works correctly.

Swap absolute paths with relative ones when importing NPM based SCSS partials.

Overview of the Issue:
SCSS partials are currently imported using absolute paths. For example in main.scss file:
@import '../node_modules/easings-css/easings';

Motivation or Use Case:
Import code is longer than needed and prone to typographical errors. Any future change in folder/path structure might introduce errors as all the instances of the path need to be manually updated.

Suggest a Fix:
This can be fixed, buy adding node_modules path in the webpack.config.js file at line #71, like so:
includePaths: ['node_modules'],

SCSS partial files can be then referenced using the relative paths, like so:
@import 'easings-css/easings';

Attempted PHP update broke WordPress Website

I'm running Flynt with the latest WordPress release on an AWS Lightsail Instance. WordPress dashboard suggested that my PHP version should be updated to 7.4, and so I tried to update my server's PHP version to 7.4 through the command line. I must have done something wrong, since the command "php -v" still shows an older version and my server homepage shows the default Apache2 page, not WordPress. I'm at a loss here and wondered if this is a conflicting issue within Flynt or if I just did something completely wrong that broke WordPress. Any help would be greatly appreciated. Thanks.

What is the install procedure when on Windows?

I am trying to use this on a dev project but I've tried 4 different times in different ways to install it and it doesn't work.

The instructions say to run composer install, that works.
Then it says to run npm install, this works, though it the audit complains about a lot of packages.

It's running npm run build that won't work. I get multiple of these:

npm ERR! code ELIFECYCLE

Part of the issue is that the build command doesn't use a syntax that Windows can use. For example it can't just run NODE_ENV=production..... You have to use the set command for environment vars.
And then it uses a variable $npm_execpath which doesn't do anything.
It runs gulp command but that doesn't seem to be installed by npm? I had to install that globally for it to work like this.

The linter commands fail.

I've tried this 3 times with fresh clones from Git in different paths on my computer, using two tools (AMPPS, and Local by Flywheel), neither worked. Flywheel was the worst, npm install didn't even work, it had a lot of permissions errors.

Then I downloaded a live/working version of a Flynt theme and ran npm install on it, then tried to run build and it still didn't work.

I'm not sure what else to try and fix! I tried to do npm update just to see if updating packages across the board would work, and it didn't.

Here is the output in my CLI:

D:\www\www\temp-site\wp-content\themes\test-theme  ([email protected])
$ npm run build
> [email protected] build D:\www\www\temp-site\wp-content\themes\test-theme
> check-node-version --package -p && npm run clean && set NODE_ENV=production webpack --progress --display=minimal && gulp rev

node: 10.16.0
npm: 6.10.2
npx: 6.10.2
yarn: 1.17.3

> [email protected] clean D:\www\www\temp-site\wp-content\themes\test-theme
> rm -rf ./dist

[16:34:05] Using gulpfile D:\www\www\temp-site\wp-content\themes\test-theme\gulpfile.js
[16:34:05] Starting 'rev'...
[16:34:05] Starting 'revAssets'...
[16:34:05] Finished 'revAssets' after 122 ms
[16:34:05] Starting 'revUpdateReferences'...
[16:34:05] 'revUpdateReferences' errored after 15 ms
[16:34:05] Error: File not found with singular glob: D:/www/www/temp-site/wp-content/themes/test-theme/dist\rev-manifest.json (if this was purposeful, use `allowEmpty` option)
    at Glob.<anonymous> (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob-stream\readable.js:84:17)
    at Object.onceWrapper (events.js:286:20)
    at Glob.emit (events.js:198:13)
    at Glob.EventEmitter.emit (domain.js:448:20)
    at Glob._finish (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:197:8)
    at done (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:182:14)
    at Glob._processSimple2 (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:688:12)
    at D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:676:10
    at Glob._stat2 (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:772:12)
    at lstatcb_ (D:\www\www\temp-site\wp-content\themes\test-theme\node_modules\glob\glob.js:764:12)
[16:34:05] 'rev' errored after 144 ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `check-node-version --package -p && npm run clean && set NODE_ENV=production webpack --progress --display=minimal && gulp rev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vigil\AppData\Roaming\npm-cache\_logs\2019-09-11T23_34_05_389Z-debug.log

D:\www\www\temp-site\wp-content\themes\test-theme  ([email protected])

You'll notice I changed the build commands to at least try to get them working on Windows, but it still fails with the gulp rev stuff it seems like.

I don't know what else to try.

Thanks for any help

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.