htmlburger / carbon-fields-yoast
Helper library that allows developers to choose which fields from Carbon Fields to include in the Yoast readability score meter
Installs: 2 659
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 9
Forks: 6
Open Issues: 4
Language:JavaScript
This package is auto-updated.
Last update: 2024-11-09 18:32:58 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.