WPWeekly Episode 362 – Fitness, Freelancing, and More With Michelle Schulp

In this episode, John James Jacoby and I are joined by Michelle Schulp, an independent freelancer and Director of Technology at AIGA Minnesota. We discussed the impacts speaking at multiple WordCamps had on her business early on, why she continues to be a freelance contractor as opposed to managing her own agency, and the role fitness has in her life. We also touch on what her personal experience has been like as a woman in the WordPress community.

Stories Discussed:

WordPress Security Team Discusses Backporting Security Releases to Fewer Versions

WordSesh EMEA Coming September 25: A New Virtual WordPress Event for Europe, Middle East, and Africa

How to Be A WordPress Ally

Fitness and Freelance

Add support for gradients in cover image

WPWeekly Meta:

Next Episode: Wednesday, August 7th 3:00 P.M. Eastern

Subscribe to WordPress Weekly via Itunes

Subscribe to WordPress Weekly via RSS

Subscribe to WordPress Weekly via Stitcher Radio

Subscribe to WordPress Weekly via Google Play

Listen To Episode #362:

Gutenberg 6.2 Adds Nesting Capabilities to Cover, Media & Text Blocks

Gutenberg 6.2 has two new user-facing features that were added based on community feedback. The Cover and Media & Text blocks now allow for nesting any type of block inside.

Previously, the Cover block only allowed users to add a heading, button, or paragraph block. Users had resorted to employing clunky solutions to get around the restrictions, such as using the group block with a custom class and using CSS to add backgrounds and overlay styling. The restrictions have now been removed to give users greater flexibility in styling these blocks.

Another new user-facing feature in 6.2 is the ability to customize the link target of the Button block, enabling users to designate the link to open in a new tab. Gutenberg Phase 2 lead Riad Benguella said this small improvement was a frequently requested feature.

This release also introduces a new PHP API to simplify the registration of block styles variations. It offers a simple way for plugin and theme developers to register block styles using only PHP function calls, instead of using JavaScript. This should make styling blocks more approachable for those who are more comfortable with PHP.

Gutenberg 6.2 includes more than two dozen enhancements and bug fixes, along with many mobile and documentation improvements. Check out the changelog in the release post for more details.

Fetching Data in React using React Async

You’re probably used to fetching data in React using axios or fetch. The usual method of handling data fetching is to:

  • Make the API call.
  • Update state using the response if all goes as planned.
  • Or, in cases where errors are encountered, an error message is displayed to the user.

There will always be delays when handling requests over the network. That’s just part of the deal when it comes to making a request and waiting for a response. That’s why we often make use of a loading spinner to show the user that the expected response is loading.

See the Pen
ojRMaN
by Geoff Graham (@geoffgraham)
on CodePen.

All these can be done using a library called React Async.

React Async is a promised-based library that makes it possible for you to fetch data in your React application. Let’s look at various examples using components, hooks and helpers to see how we can implement loading states when making requests.

For this tutorial, we will be making use of Create React App. You can create a project by running:

npx create-react-app react-async-demo

When that is done, run the command to install React Async in your project, using yarn or npm:

## yarn
yarn add react-async

## npm
npm install react-async --save

Example 1: Loaders in components

The library allows us to make use of <Async> directly in our JSX. As such, the component example will look like this;

// Let's import React, our styles and React Async
import React from 'react';
import './App.css';
import Async from 'react-async';

// We'll request user data from this API
const loadUsers = () =>
  fetch("https://jsonplaceholder.typicode.com/users")
    .then(res => (res.ok ? res : Promise.reject(res)))
    .then(res => res.json())

// Our component
function App() {
  return (
    <div className="container">
      <Async promiseFn={loadUsers}>
        {({ data, err, isLoading }) => {
          if (isLoading) return "Loading..."
          if (err) return `Something went wrong: ${err.message}`

          if (data)
            return (
              <div>
                <div>
                  <h2>React Async - Random Users</h2>
                </div>
                {data.map(user=> (
                  <div key={user.username} className="row">
                    <div className="col-md-12">
                      <p>{user.name}</p>
                      <p>{user.email}</p>
                    </div>
                  </div>
                ))}
              </div>
            )
        }}
      </Async>
    </div>
  );
}

export default App;

First, we created a function called loadUsers. This will make the API call using the fetch API. And, when it does, it returns a promise which gets resolved. After that, the needed props are made available to the component.

The props are:

  • isLoading: This handles cases where the response has not be received from the server yet.
  • err: For cases when an error is encountered. You can also rename this to error.
  • data: This is the expected data obtained from the server.

As you can see from the example, we return something to be displayed to the user dependent on the prop.

Example 2: Loaders in hooks

If you are a fan of hooks (as you should), there is a hook option available when working with React Async. Here’s how that looks:

// Let's import React, our styles and React Async
import React from 'react';
import './App.css';
import { useAsync } from 'react-async';

// Then we'll fetch user data from this API
const loadUsers = async () =>
  await fetch("https://jsonplaceholder.typicode.com/users")
    .then(res => (res.ok ? res : Promise.reject(res)))
    .then(res => res.json())

// Our component
function App() {
  const { data, error, isLoading } = useAsync({ promiseFn: loadUsers })
  if (isLoading) return "Loading..."
  if (error) return `Something went wrong: ${error.message}`
  if (data)
  
  // The rendered component
  return (
    <div className="container">
      <div>
        <h2>React Async - Random Users</h2>
      </div>
      {data.map(user=> (
        <div key={user.username} className="row">
          <div className="col-md-12">
            <p>{user.name}</p>
            <p>{user.email}</p>
          </div>
        </div>
      ))}
    </div>
  );
}

export default App;

This looks similar to the component example, but in this scenario, we’re making use of useAsync and not the Async component. The response returns a promise which gets resolved, and we also have access to similar props like we did in the last example, with which we can then return to the rendered UI.

Example 3: Loaders in helpers

Helper components come in handy in making our code clear and readable. These helpers can be used when working with an useAsync hook or with an Async component, both of which we just looked at. Here is an example of using the helpers with the Async component.

// Let's import React, our styles and React Async
import React from 'react';
import './App.css';
import Async from 'react-async';

// This is the API we'll use to request user data
const loadUsers = () =>
  fetch("https://jsonplaceholder.typicode.com/users")
    .then(res => (res.ok ? res : Promise.reject(res)))
    .then(res => res.json())

// Our App component
function App() {
  return (
    <div className="container">
      <Async promiseFn={loadUsers}>
          <Async.Loading>Loading...</Async.Loading>
          <Async.Fulfilled>
            {data => {
              return (
                <div>
                  <div>
                    <h2>React Async - Random Users</h2>
                  </div>
                  {data.map(user=> (
                    <div key={user.username} className="row">
                      <div className="col-md-12">
                        <p>{user.name}</p>
                        <p>{user.email}</p>
                      </div>
                    </div>
                  ))}
                </div>
              )
            }}
          </Async.Fulfilled>
          <Async.Rejected>
            {error => `Something went wrong: ${error.message}`}
          </Async.Rejected>
      </Async>
    </div>
  );
}

export default App;

This looks similar to when we were making use of props. With that done, you could break the different section of the app into tiny components.

Conclusion

If you have been growing weary of going the route I mentioned in the opening section of this tutorial, you can start making of React Async in that project you are working on. The source code used in this tutorial can be found in their different branches on GitHub.

The post Fetching Data in React using React Async appeared first on CSS-Tricks.

How NOT to Be API-Misled for Connectivity!

How NOT to be API-misled for connectivity!

It was a few years back when API-led connectivity was getting popular and our customers wanted to see it being brought into practice. Some of them also began to choose their hybrid integration products based on the product’s inherent support for the approach. After having implemented two large hybrid integration programs for two different industries (Banking and Manufacturing), I thought I should share my experience as do’s and don’ts for API-led connectivity and Hybrid Integration.

API-led connectivity

The approach was termed as the next step in the evolution of SOA, which is why its principles and the very fundamental concepts will remain timeless, at least in the context of software architecture.

Setting World-Writable File Permissions Prior to Preparing the Backup Can Break It

It's bad practice to provide world-writable access to critical files in Linux, though we've seen time and time again that this is done to conveniently share files with other users, applications, or services. But with Xtrabackup, preparing backups could go wrong if the backup configuration has world-writable file permissions.

Say you performed a backup on a MySQL instance configured with data-at-rest encryption using the keyring plugin. On the backup directory, the generated backup-my.cnf contains these instructions to load this plugin that will be used by Xtrabackup while preparing the backup:

Secrets Manager in Anypoint Platform

We can use the secrets manager to write, read, and manage your secrets, keys, and Transport Layer Security (TLS) certificates within a unique source that allows access to other authorized platform services on your behalf.

This is the central and secure repository to manage the secrets. Please note that the Secrets manager is supported on Runtime Fabric and API Manager only. Secrets manager uses secure vault technology to store and control access to private keys, passwords, certificates, and other secrets.

Meta Box Plugin Introduces MB Blocks, a PHP-based Extension for Creating Custom Blocks

Meta Box, one of the most popular WordPress custom fields frameworks, has released a new extension for creating custom Gutenberg blocks using only PHP. MB Blocks gives developers the ability to build blocks with various settings, using a similar syntax as creating a meta box, without having to know React, Webpack, or Babel.

MB Blocks inherits many settings and field types from Meta Box to speed up development. Those who are experienced using Meta Box should be able to create a new Gutenberg block in under 10 minutes.

Tran Ngoc Tuan Anh created the Meta Box framework in 2010, launched on WordPress.org in 2011, and began releasing commercial extensions in 2014. The plugin’s user base has grown to more than 400,000 active installs and Tran now leads a three-person team, including two developers and one marketer.

“The revenue is not as good as other businesses, but it’s enough for us to run a small team,” Tran said. Learning React was new for his developers and it took them several months to get familiar with the framework before being able to create the MB Blocks extension.

Following in the footsteps of Advanced Custom Fields (ACF), which offers ACF blocks as part of its Pro version, Meta Box’s PHP-only block creation solution is only available as a commercial extension.

“The MB Blocks extension is our strategy to attract users to Meta Box,” Tran said. “Since Gutenberg is becoming a huge thing, people really need a way to work with it. With this extension, we hope to bring more premium users to Meta Box.”

With more than one million active installs, ACF is the market leader and Meta Box’s main competitor, but Tran said his team is also keeping an eye on other plugins like Toolset, CMB2 (200,000+ installs), and Pods (80,000+ installs). He identified flexibility as Meta Box’s chief differentiator, since it is a code-based solution that he believes gives developers a greater level of customization in creating custom fields.

“The main difference between Meta Box and ACF is Meta Box is more developer-focused. It’s mainly code-based, e.g. you define meta boxes and fields with code (it has the UI as a premium extension but code is still the main part),” Tran said. “Meta Box has some extra things like supporting custom table storage, making frontend forms, advanced conditional logic, and building user profiles on the frontend.”

Tran said he is satisfied with Gutenberg’s support for meta boxes at the moment but would like to see it improved.

“The way it works is kind of a ‘fake’ submission for post data via ajax,” he said. “Sometimes that makes users have to refresh the page to see the updated content. I mean for complex data, it still doesn’t have a good way to refresh the meta boxes when a post is saved. I wish there was was a way to do that.”

This may not be a priority for the Gutenberg team, as the ideal is for meta boxes to be converted to blocks wherever possible to maintain a unified editing interface. The reality is that many plugins are still not block-enabled, which is why the WordPress Plugin Directory has a section devoted to promoting those that are.

“Many users still need custom meta boxes because of two reasons: building custom Gutenberg blocks is not easy enough, and a lot of plugins still require meta boxes to work,” Tran said.

The availability of PHP-based solutions for creating custom Gutenberg blocks has been an important development for those who have been slow to take the deep dive into JavaScript and React. Tran said the feedback he has received from his userbase indicates that many have not prioritized gaining the skills necessary to become proficient at custom Gutenberg development.

“Our main users are web creators who build websites on a daily basis,” Tran said. “Many of them have built a solid foundation for their work to speed up the workflow. Things such as a page builder, a custom fields framework, a powerful theme, are their daily tools. Putting Gutenberg into this toolset requires a lot of time learning and mastering it. Sometimes it’s not feasible, especially when Gutenberg is not powerful enough to build websites. Most of them still use a page builder to build websites, while they keep testing Gutenberg to see what’s new.”

Tran said most of his customers are using page builders like Beaver Builder or Elementor. Some give access to their clients and others do not. This is where they often look to plugins like Meta Box to help them build settings for their websites.

With MB Blocks released today, the Meta Box team is moving forward on its roadmap, working on integrations with other plugins like WP All Import, and improving the Meta Box Builder to support creating relationships and settings pages with a UI.

Why You Should Avoid Using the @@IDENTITY Function

Phil Factor demonstrates why SQL Prompt has a 'Best Practice' rule (BP010) that checks for use of the @@IDENTITY function and suggests less error-prone ways to get the latest identity values used in a table.

The @@IDENTITY function returns the last IDENTITY value created in the same session. If you have a trigger on the table or if the table is a publication in a replication, then the value can sometimes be wrong. SQL Prompt's BP010 code analysis rule will warn you if it detects its use in your SQL code.

Pandas DataFrame Functions (Row and Column Manipulations)

In my first article, I gave a tutorial on some functions that will help you display your data with a Pandas DataFrame. Here, I will continue the tutorial and show you how to us a DataFrame to manipulate and visualize data. 

Rows and Columns Manipulation

Get a Distinct Value of a Column

To get the distinct values of a column, you can use the Numpy library. Do not forget to "import numpy as np" first. "np" is the conventional way to name the library in code.

Security: Additional Considerations

To understand the current and future state of the cybersecurity landscape, we spoke to and received written responses from 50 security professionals. When conducting interviews, we always wrap up the discussion with the question, "What have we not discussed that’s important for us to address in this research guide?" 

Based on the number and depth of responses, there was still a lot on peoples' minds.

Application Security Today

To understand the current and future state of application security, we obtained insights from five IT executives. We asked them, “How is your company securing applications?” Here’s what they told us:

  • We protect applications from the inside, adding sensors that understand the context of what the application is actually doing. This level of visibility beats external controls (e.g., understanding that NoSQL databases are not vulnerable to SQL Injection).
  • We have empathy for the developer since 80% of our clients are developers. We know developers are being asked to make something that’s relevant, useful, popular, scalable, performant, and secure. We begin by understanding that developers have a lot on their plates, and we think about how to make their lives as easy as possible. We make the AppSec concern consumable and actionable by the developer.
  • We can answer this question from two perspectives: how we help users of our Application Release Orchestration platform deliver secure software (including reporting in order to provide a paper trail of the various techniques used to secure the produced applications) and how we help ISVs that are building software that needs to be secure.

    Our platform provides clients with a way to create enterprise pipeline templates to document and execute all steps from code commit to production. These templates can serve as a yellow brick road to production that includes all manual and automated steps, amongst which security scanning is done as part of the process. The “shift left” practice in DevSecOps is helping organizations improve quality and security by moving to test earlier in the release process, and our DevOps Platform makes this process auditable and explicit. We do this by integrating other vendors, such as SonarQube, Black Duck, Checkmarx and Fortify, into pipelines, which can prevent the release from going forward as security violations are identified, even with the new discovery of zero-day vulnerabilities during the release process.

    Additionally, our security and compliance dashboard templates enable release managers and DevOps engineers to track security issues in applications that need to meet IT compliance requirements. We help them identify applications that are failing to meet security standards. The dashboard gives the team a complete overview of test results from the static application security testing (SAST), dynamic application security testing (DAST), and open source security management (OSSM) tools in their release pipelines.
  • We segment applications from each other and give them their own authenticated and encrypted network. Using a full PKI implementation, secure tunnels, dedicated data centers, and direct dedicated connections to cloud application providers we secure applications on a network end-to-end.
  • DevSecOps is the way to secure the application across the entire lifecycle — securing left, programming, building, and production is application security throughout the lifecycle. Development is getting faster, and application security needs to be able to support development.

Here’s who shared their insights: