Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active August 25, 2017 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/cca542e4896acb866a48ec746d2fd930 to your computer and use it in GitHub Desktop.
Save neilgee/cca542e4896acb866a48ec746d2fd930 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment