Coder Social home page Coder Social logo

digitoimistodude / air-helper Goto Github PK

View Code? Open in Web Editor NEW
45.0 45.0 7.0 576 KB

Air helper brings our preferences to Air-light based themes and extends with many ways like adding WooCommerce support.

License: MIT License

PHP 94.53% CSS 1.41% JavaScript 4.06%
woocommerce wordpress wordpress-plugin

air-helper's People

Contributors

eliaskau avatar niq1982 avatar raikasdev avatar ronilaukkarinen avatar timiwahalahti avatar villekujansuu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

air-helper's Issues

Consider showing warning about allowed domains for email delivery when in dev & stage environments

Currently, you need to know that we limit the domains to which emails can be sent when in development and staging environments. When the receiving address is not in that domain, the to-address is forced to be ours.

We probably should show visible reminder about this on the dashboard since this doesn't affect us but can cause issues for developers that aren't from our company. The notice could be dismissible.

Why notice instead, for example, defaulting the forced address to admin_email? Because when working on a site that has been in production already, that email can be clients instead of ours.

I've also thought about detecting if we're on Dude dev or stage env, to put the email forcing on only in those situations. But haven't yet come up with a solution that would be reliable.

Thoughts @ronilaukkarinen @EliasKau?

the_block_content() doesn't work with string

If using for example get_option( 'page_for_posts' ), blocks will not load up:

<?php the_block_content( get_option( 'page_for_posts' ) ); ?>

Instead if we use absint it works:

<?php the_block_content( absint( get_option( 'page_for_posts' ) ) ); ?>

Air-helper should be improved so that it checks whether there's string or int.

Allow plugins.php visibility from user_meta

Currently plugins.php is removed from menu if user email domain is not on the list provided. List can be altered via hook.

This approach isn't really suitable for big organizations. We need to allow plugins.php visibility for specific singular users. It can be done by using user_meta.

function air_helper_maybe_remove_plugins_from_admin_menu( $menu_links ) {

Remove CarbonFields support

Carbon Fields is no longer used in our projects so support for it should be dropped off from air helper. Same goes to post meta revision support, which was introduced in support for CF previews.

Copy files and functions to own plugin which will be added as a MU for clients using CF.

Remove useless information from <head>

WordPress 5.7.2 outputs things like this:

<link rel="https://api.w.org/" href="//localhost:3000/wp-json/" /><link rel="alternate" type="application/json" href="//localhost:3000/wp-json/wp/v2/pages/701" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="//localhost:3000/wp/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="//localhost:3000/wp/wp-includes/wlwmanifest.xml" />
<link rel="alternate" type="application/json+oembed" href="//localhost:3000/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fairdev.test%2F" />
<link rel="alternate" type="text/xml+oembed" href="//localhost:3000/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fairdev.test%2F&#038;format=xml" />

These cause invalidity errors like this:

18:1-76      error  Bad value “https://api.w.org/” for attribute “rel” on element “link”: The string “https://api.w.org/” is not a registered keyword.

My suggestion is to remove these with:

/**
 * Remove WP REST API json links in <head> html
 */
remove_action( 'wp_head', 'rest_output_link_wp_head' );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'template_redirect', 'rest_output_link_header', 11 );

Support scrset and <picture>

Example with WordPress native functions:

<picture>
  <source media="(min-width: 320px) and (max-width: 767px)" srcset="<?php echo esc_url( wp_get_attachment_image_url( $item['image'], 'medium' ) ); ?>">
  <source media="(min-width: 768px) and (max-width: 1199px)" srcset="<?php echo esc_url( wp_get_attachment_image_url( $item['image'], 'large' ) ); ?>">
  <source media="(min-width: 1200px)" srcset="<?php echo esc_url( wp_get_attachment_image_url( $item['image'], 'full' ) ); ?>">
  <img
    loading="lazy"
    src="<?php echo esc_url( wp_get_attachment_image_url( $item['image'], 'large' ) ); ?>"
    alt="<?php echo esc_attr( get_post_meta( $case_study['image'], '_wp_attachment_image_alt', true ) ); ?>"
  >
</picture>

Automatic attributes

  • Alt-tag
  • Img urls

Attributes

Parameters that need to be changed optionally:

  • aria-hidden="true/false" depending on whether the image is decorative or not
  • Media queries media, in case if there's a different sized area that does not work for the "default" sizes, for example medium 300px gets smudged when stretching to 400px area.
  • Image sizes in each viewports
  • Default size inside img src (in effect in all viewports that are not defined)

References

Broken Admin-Menu

After installing the plugin, the menu in admin area is broken. The section "Design" dissapears.

Plugin Version: 2.18.0
Wordpress: 6.1.1

Maybe disable some views by default

In most of our projects, there's really no need for most of the default archive views that WordPress haves. Sometimes in hurry, those might end up being forgotten and looking really bad (unstyled).

I'm considering disabling search view, tag, category, author and date archives by default. Every view could be de-disabled via hook in theme or plugin. In the name of backward compatibility, if added to plugin, we need to check if plugin version is earlier than X and do de-disable automatically.

Opinions @ronilaukkarinen and @artotoivanen?

Lazy loading attribute

Issue by @iniznet:

Considering add lazy loading attribute to img tag for browser who support it, otherwise load the lazyload js.
Something like:

if ( // check if browser support lazy loading attribute ) {
} else {
  // browser doesn't support it, so load the lazyload js
} 

As it explained here: lazy loading article
Although current caniuse still around 70%: caniuse

I think it would be great if it was implemented by default without needing to edit the JS every time we set up the starter theme.

Fix Gravity Forms scripts

By default, we move scripts including jQuery to the footer of the site. This breaks Gravity Forms, as it tries to use jQuery before it's actually loaded.

For now, this has been fixed project by project when needed but having fix always there would make sense. Ensure that fix is only applied to new projects.

The fix could be something like

add_filter('gform_init_scripts_footer', '__return_true');
add_filter( 'gform_cdata_open', __NAMESPACE__ . '\wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
  $content = 'document.addEventListener( "DOMContentLoaded", function() { ';
  return $content;
}
add_filter( 'gform_cdata_close', __NAMESPACE__ . '\wrap_gform_cdata_close' );
function wrap_gform_cdata_close( $content = '' ) {
  $content = ' }, false );';
  return $content;
}

Image size as direct argument

Instead of

<?php native_lazyload_tag( $image_id, [ 'sizes' => [ 'big' => 'thumbnail' ] ] ) ?>

We could just

<?php native_lazyload_tag( $image_id, 'thumbnail' ) ?>

Warning when overriding Hide ACF for all users with user meta

Thought I should let you know that I get this warning when overriding this with user meta and the override wont work:

( ! ) Warning: Undefined variable $menu_links in \content\plugins\air-helper\inc\admin\acf.php on line 28

Adding $menu_links in function air_helper_maybe_hide_acf() or changing this if ( 'true' === $meta_override ) { return $menu_links; } to this if ( 'true' === $meta_override ) { return true } fixes it.

Remove Woocommerce support

Woocommerce isn't used on most of the client cases so it's un-neccessary to have few functions of modifications in air helper. Also in most of the client cases with Woocommeece extensive cutomisation is needed nevertheless.

Rewrite and restructure code

Currently there are few huge files containing all functionality. Split the files to smaller ones and order functionality based on affected area. Escpecially hooks.php and functions.php do need work.

Disable core lazy load

WordPress 5.5 introduced native lazyloading. We have our own at the moment, so native onde should be disabled with add_filter( 'wp_lazy_loading_enabled', '__return_false' );

Move orderby fix to priority

In some cases, order by alphabetical fixes do not work because called too late. Move those to priority flight.

Consider hiding themes.php and moving nav-menus.php to top level

Some clients find it hard to find where to update their site navigation. On the other hand, they don't need to access themes, widgets or customizers nearly at all.

For these reasons, we should consider hiding themes.php and adding nav-menus.php to the top level of the dashboard menu for client users.

Bring back admin bar

Admin bar is really usable when editing the site. Benefits of it overrule the small design implications that the admin bar has. Thus bring back admin bar, but remove all un-necessary things from it.

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.