Monthly Archives: January 2021

Validate CF7 email address field

/* validate email address on forms */
add_filter( 'wpcf7_validate_email*', 'custom_email_confirmation_validation_filter', 20, 2 );
function custom_email_confirmation_validation_filter( $result, $tag ) {
	if ( 'your-email-confirm' == $tag->name ) {
		$your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : '';
		$your_email_confirm = isset( $_POST['your-email-confirm'] ) ? trim( $_POST['your-email-confirm'] ) : '';
	  
		if ( $your_email != $your_email_confirm ) {
		  $result->invalidate( $tag, "Email addresses do not match, please check and try again" );
		}
	}
	return $result;
}

Full width Gutenberg editor

// Full width Gutenberg editor
add_action('admin_head', 'editor_full_width_gutenberg');
function editor_full_width_gutenberg() {
  echo '<style>
    .block-editor__container .wp-block {
        max-width: none !important;
	}
	.editor-styles-wrapper {
	    padding: 5% !important;
	} 
    /*code editor*/
    .edit-post-text-editor__body,edit-post-visual-editor {
    	max-width: none !important;	
    	margin-left: 5%;
    	margin-right: 5%;
    }
  </style>';
}
// add styles to gutenberg
function gutenbergtheme_editor_styles() {
    wp_enqueue_style( 'gutenbergtheme-blocks-style', get_template_directory_uri() . '/blocks.css');
}
add_action( 'enqueue_block_editor_assets', 'gutenbergtheme_editor_styles' );