htmlburger/carbon-fields-yoast

Helper library that allows developers to choose which fields from Carbon Fields to include in the Yoast readability score meter

v1.0.1 2019-03-07 14:12 UTC

This package is auto-updated.

Last update: 2021-01-05 16:02:39 UTC


README

Carbon Fields Yoast is an addon to Carbon Fields that allows developers to choose which fields from Carbon Fields to include in the Yoast readability score meter.

How to use?

Install via composer:

composer require htmlburger/carbon-fields-yoast

In functions.php, add the following:

add_action( 'after_setup_theme', 'crb_initialize_carbon_yoast' );
function crb_initialize_carbon_yoast() {
	include_once __DIR__ . '/vendor/autoload.php';

	new \Carbon_Fields_Yoast\Carbon_Fields_Yoast;
}

add_action( 'admin_enqueue_scripts', 'crb_enqueue_admin_scripts' );
function crb_enqueue_admin_scripts() {
	wp_enqueue_script( 'crb-admin', get_stylesheet_directory_uri() . '/js/admin.js', array( 'carbon-fields-yoast' ) );
}

In js/admin.js in your theme, add the following:

var $doc = $(document);
var $win = $(window);

$doc.ready(function () {
	$win.on('YoastSEO:ready', function () {
		new CarbonFieldsYoast();
	});
});

This will initialize the Carbon Fields Yoast addon. The CarbonFieldsYoast object accepts the following arguments:

[Number] refreshInterval - Defaults to 300ms

This is the time interval on which the meta fields are being parsed.

[Array] fieldsByTypeToExclude

This contains the type of fields that shouldn't be parsed. By default, only text, textarea and rich text fields are being parsed.

[Array] fieldsByNameToExclude

This contains the name of the fields that shouldn't be parsed. By default, there aren't excluded fields.