neilgee
8/25/2017 - 9:32 AM

Business Profile Schema Extender for Store

Business Profile Schema Extender for Store

<?php
/**
 * Plugin Name: Business Profile Business Exttnder
 * Plugin URI: http://wpbeaches.com
 * Description: Modifies the Business Profile plugin to include extra info for business.
 * Version: 0.0.1
 * Author: Neil Gowran
 * Author URI: http://wpbeaches.com
 * License:     GNU General Public License v2.0 or later
 * Reference - https://gist.github.com/NateWr/b28bb63ba8a73bb14eac
 */
if ( ! defined( 'ABSPATH' ) )
	exit;
/**
 * Add Schema options for a local business store which is a florist store
 *
 * This preserves the existing options and just adds the one for
 * Florist which is a sublevel of Store. But if your working in an environment where
 * these are the only options you'll need, you can replace the options
 * array instead of adding to it.
 */
 add_filter( 'bpfwp_settings_page', 'prefix_extend_schema', 100 ); 
 // This example is using the themes prefix of prefix to extend the plugin which uses bpfwp
function prefix_extend_schema( $sap ) {
	// Loop over the schema options. When we hit the
	// Store option which already exists, add in our florist business schema.
	$new_schema_options = array();
	foreach ( $sap->pages['bpfwp-settings']->sections['bpfwp-seo']->settings['schema_type']->options as $schema => $label ) {
		$new_schema_options[$schema] = $label;
		if ( $schema == 'Store' ) {
			$new_schema_options['Florist'] 	= '-- Florist';// Adding in new schema
		}
	}
	// Replace the existing schema options with the new ones
	$sap->pages['bpfwp-settings']->sections['bpfwp-seo']->settings['schema_type']->options = $new_schema_options;
	return $sap;
}