Created
July 10, 2023 18:59
-
-
Save dlxsnippets/3d33ba67e1ceec089645093eae817dc3 to your computer and use it in GitHub Desktop.
Change the Paragraph Block's Placeholder Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: DLX Change Paragraph Placeholder | |
* Plugin URI: https://dlxplugins.com | |
* Description: Change the placeholder text for the paragraph block. | |
* Version: 1.0.0 | |
* Requires at least: 6.0 | |
* Requires PHP: 7.3 | |
* Author: Ronald Huereca | |
* Author URI: https://mediaron.com | |
* License: GPL v2 or later | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
* | |
* @package DLXChangeParagraphPlaceholder | |
*/ | |
namespace DLXPlugins\ChangeParagraphPlaceholder; | |
add_filter( 'block_type_metadata', __NAMESPACE__ . '\modify_paragraph_attributes', 10, 1 ); | |
/** | |
* Set Paragraph defaults. | |
* | |
* @param array $metadata { | |
* An array of arguments. | |
* | |
* @type string $name Block name. | |
* @type array $attributes Block attributes. | |
* } | |
*/ | |
function modify_paragraph_attributes( $metadata ) { | |
// Check the block type. | |
if ( 'core/paragraph' !== $metadata['name'] ) { | |
return $metadata; | |
} | |
// Add accordion view (collapsed view). | |
$metadata['attributes']['placeholder']['default'] = 'Please type or use "/" command.'; | |
// Return the metadata. | |
return $metadata; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment