plugin updates
This commit is contained in:
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Brainstorm_Update_AIOSRS_Pro initial setup
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'Brainstorm_Update_AIOSRS_Pro' ) ) :
|
||||
|
||||
/**
|
||||
* Brainstorm Update
|
||||
*/
|
||||
class Brainstorm_Update_AIOSRS_Pro {
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
* @var object Class object.
|
||||
* @access private
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
self::version_check();
|
||||
|
||||
add_action( 'init', array( $this, 'load' ), 999 );
|
||||
add_filter( 'bsf_get_license_message_wp-schema-pro', array( $this, 'license_message_aiosrs_pro' ), 10, 2 );
|
||||
add_filter( 'bsf_skip_braisntorm_menu', array( $this, 'skip_menu' ) );
|
||||
add_filter( 'bsf_skip_author_registration', array( $this, 'skip_menu' ) );
|
||||
add_filter( 'bsf_remove_wp-schema-pro_from_registration_listing', '__return_true' );
|
||||
add_filter( 'agency_updater_productname_wp-schema-pro', array( $this, 'product_name' ) );
|
||||
|
||||
// Add popup license form on plugin list page.
|
||||
add_action( 'plugin_action_links_' . BSF_AIOSRS_PRO_BASE, array( $this, 'bsf_aiosrs_pro_license_form_and_links' ) );
|
||||
add_action( 'network_admin_plugin_action_links_' . BSF_AIOSRS_PRO_BASE, array( $this, 'bsf_aiosrs_pro_license_form_and_links' ) );
|
||||
|
||||
add_filter( 'bsf_registration_page_url_wp-schema-pro', array( $this, 'bsf_aiosrs_pro_bsf_registration_page_url' ) );
|
||||
add_filter( 'bsf_product_activation_notice_wp-schema-pro', __class__ . '::update_aiosrs_license_notice', 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated the license notice when white label is activated.
|
||||
*
|
||||
* @param string $message for license notice.
|
||||
* @param string $url for activate button.
|
||||
* @param string $product_name replace the name with white label.
|
||||
* @return string message.
|
||||
*/
|
||||
public static function update_aiosrs_license_notice( $message, $url, $product_name ) {
|
||||
|
||||
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
|
||||
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
|
||||
$product_name = $branding['sp_plugin_name'];
|
||||
}
|
||||
/* translators: %s: search term */
|
||||
return sprintf( __( 'Please <a href= %1$s class="bsf-core-license-form-btn" plugin-slug="wp-schema-pro"> activate </a>your copy of the<i> %2$s </i>to get update notifications, access to support features & other resources!', 'wp-schema-pro' ), $url, $product_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show action links on the plugin screen.
|
||||
*
|
||||
* @param mixed $links Plugin Action links.
|
||||
* @return array Filtered plugin action links.
|
||||
*/
|
||||
public function bsf_aiosrs_pro_license_form_and_links( $links = array() ) {
|
||||
if ( function_exists( 'get_bsf_inline_license_form' ) ) {
|
||||
|
||||
$args = array(
|
||||
'product_id' => 'wp-schema-pro',
|
||||
'popup_license_form' => true,
|
||||
);
|
||||
|
||||
return get_bsf_inline_license_form( $links, $args, 'edd' );
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bsf registration page
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function bsf_aiosrs_pro_bsf_registration_page_url() { // phpcs:ignore WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement
|
||||
if ( is_multisite() ) {
|
||||
return network_admin_url( 'plugins.php?bsf-inline-license-form=wp-schema-pro' );
|
||||
} else {
|
||||
return admin_url( 'plugins.php?bsf-inline-license-form=wp-schema-pro' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Product Name.
|
||||
*
|
||||
* @param string $name Product Name.
|
||||
* @return string product name.
|
||||
*/
|
||||
public function product_name( $name ) {
|
||||
|
||||
$branding = get_option( 'wp-schema-pro-branding-settings' );
|
||||
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
|
||||
$name = $branding['sp_plugin_name'];
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip Menu.
|
||||
*
|
||||
* @param array $products products.
|
||||
* @return array $products updated products.
|
||||
*/
|
||||
public function skip_menu( $products ) {
|
||||
$products[] = 'wp-schema-pro';
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update brainstorm product version and product path.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function version_check() {
|
||||
|
||||
$bsf_core_version_file = realpath( BSF_AIOSRS_PRO_DIR . '/admin/bsf-core/version.yml' );
|
||||
|
||||
// Is file 'version.yml' exist?
|
||||
if ( is_file( $bsf_core_version_file ) ) {
|
||||
global $bsf_core_version, $bsf_core_path;
|
||||
$bsf_core_dir = realpath( BSF_AIOSRS_PRO_DIR . '/admin/bsf-core/' );
|
||||
$version = file_get_contents( realpath( plugin_dir_path( BSF_AIOSRS_PRO_FILE ) . '/admin/bsf-core/version.yml' ) );
|
||||
|
||||
// Compare versions.
|
||||
if ( version_compare( $version, (string) $bsf_core_version, '>' ) ) {
|
||||
$bsf_core_version = $version;
|
||||
$bsf_core_path = $bsf_core_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Message for license.
|
||||
*
|
||||
* @param string $content Content.
|
||||
* @param string $purchase_url purchase_url.
|
||||
* @return string output message.
|
||||
*/
|
||||
public function license_message_aiosrs_pro( $content, $purchase_url ) {
|
||||
$purchase_url = apply_filters( 'wp_schema_pro_licence_url', $purchase_url );
|
||||
|
||||
$message = "<p><a target='_blank' href='" . esc_url( $purchase_url ) . "'>" . esc_html__( 'Get the license >>', 'wp-schema-pro' ) . '</a></p>';
|
||||
|
||||
$branding = get_option( 'wp-schema-pro-branding-settings' );
|
||||
|
||||
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
|
||||
$message = '';
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the brainstorm updater.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load() {
|
||||
global $bsf_core_version, $bsf_core_path;
|
||||
if ( is_file( realpath( $bsf_core_path . '/index.php' ) ) ) {
|
||||
include_once realpath( $bsf_core_path . '/index.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
Brainstorm_Update_AIOSRS_Pro::get_instance();
|
||||
|
||||
endif;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* AMP for Schema Pro
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exit if accessed directly.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* BSF_AIOSRS_Pro_Amp initial setup
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
/**
|
||||
* This class initializes Schema for AMP
|
||||
*
|
||||
* @class BSF_AIOSRS_Pro_Amp
|
||||
*/
|
||||
final class BSF_AIOSRS_Pro_Amp {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @access public
|
||||
* @var $amp_activated set default to false.
|
||||
*/
|
||||
public static $amp_activated = false;
|
||||
|
||||
/**
|
||||
* AMP Options.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
/**
|
||||
* Constructor function.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'amp_schema_markup' ) );
|
||||
}
|
||||
/**
|
||||
* Rendering the Schema markup for AMP Template.
|
||||
*/
|
||||
public static function amp_schema_markup() {
|
||||
|
||||
if ( apply_filters( 'wp_schema_pro_remove_amp_schema_markup', true ) ) {
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
|
||||
$schema_markup = BSF_AIOSRS_Pro_Markup::get_instance();
|
||||
|
||||
if ( isset( $settings['schema-location'] ) ) {
|
||||
|
||||
switch ( $settings['schema-location'] ) {
|
||||
case 'head':
|
||||
add_action( 'amp_post_template_head', array( $schema_markup, 'schema_markup' ) );
|
||||
add_action( 'amp_post_template_head', array( $schema_markup, 'global_schemas_markup' ) );
|
||||
break;
|
||||
|
||||
case 'footer':
|
||||
add_action( 'amp_post_template_footer', array( $schema_markup, 'schema_markup' ) );
|
||||
add_action( 'amp_post_template_footer', array( $schema_markup, 'global_schemas_markup' ) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BSF_AIOSRS_Pro_Amp::get_instance();
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* White labeling for Schema Pro
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Branding' ) ) {
|
||||
|
||||
/**
|
||||
* BSF_AIOSRS_Pro_Branding initial setup
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
/**
|
||||
* This class initializes Schema Branding
|
||||
*
|
||||
* @class BSF_AIOSRS_Pro_Branding
|
||||
*/
|
||||
final class BSF_AIOSRS_Pro_Branding {
|
||||
|
||||
/**
|
||||
* Function that initializes necessary filters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init() {
|
||||
add_filter( 'all_plugins', __CLASS__ . '::plugins_page' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Branding on the plugins page.
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @param array $plugins An array data for each plugin.
|
||||
* @return array
|
||||
*/
|
||||
public static function plugins_page( $plugins ) {
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$branding = get_site_option( 'wp-schema-pro-branding-settings' );
|
||||
|
||||
} else {
|
||||
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
}
|
||||
|
||||
$basename = plugin_basename( BSF_AIOSRS_PRO_DIR . 'wp-schema-pro.php' );
|
||||
|
||||
if ( isset( $plugins[ $basename ] ) && is_array( $branding ) ) {
|
||||
|
||||
$sp_plugin_name = ( array_key_exists( 'sp_plugin_name', $branding ) ) ? $branding['sp_plugin_name'] : '';
|
||||
$sp_plugin_desc = ( array_key_exists( 'sp_plugin_desc', $branding ) ) ? $branding['sp_plugin_desc'] : '';
|
||||
$sp_author_name = ( array_key_exists( 'sp_plugin_author_name', $branding ) ) ? $branding['sp_plugin_author_name'] : '';
|
||||
$sp_author_url = ( array_key_exists( 'sp_plugin_author_url', $branding ) ) ? $branding['sp_plugin_author_url'] : '';
|
||||
|
||||
if ( '' !== $sp_plugin_name ) {
|
||||
$plugins[ $basename ]['Name'] = $sp_plugin_name;
|
||||
$plugins[ $basename ]['Title'] = $sp_plugin_name;
|
||||
}
|
||||
|
||||
if ( '' !== $sp_plugin_desc ) {
|
||||
$plugins[ $basename ]['Description'] = $sp_plugin_desc;
|
||||
}
|
||||
|
||||
if ( '' !== $sp_author_name ) {
|
||||
$plugins[ $basename ]['Author'] = $sp_author_name;
|
||||
$plugins[ $basename ]['AuthorName'] = $sp_author_name;
|
||||
}
|
||||
|
||||
if ( '' !== $sp_author_url ) {
|
||||
$plugins[ $basename ]['AuthorURI'] = $sp_author_url;
|
||||
$plugins[ $basename ]['PluginURI'] = $sp_author_url;
|
||||
}
|
||||
}
|
||||
return $plugins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BSF_AIOSRS_Pro_Branding::init();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,191 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Utils.
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BSF_AIOSRS_Pro_Helper.
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Helper {
|
||||
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var settings
|
||||
*/
|
||||
public static $settings;
|
||||
|
||||
/**
|
||||
* Default static array
|
||||
*
|
||||
* @var default_options
|
||||
*/
|
||||
private static $default_options = array(
|
||||
// General Settings.
|
||||
'wp-schema-pro-general-settings' => array(
|
||||
'organization' => '',
|
||||
'site-represent' => '',
|
||||
'site-name' => '',
|
||||
'person-name' => '',
|
||||
'site-logo' => 'custom',
|
||||
'site-logo-custom' => '',
|
||||
),
|
||||
|
||||
// Social Profiles.
|
||||
'wp-schema-pro-social-profiles' => array(
|
||||
'facebook' => '',
|
||||
'twitter' => '',
|
||||
'google-plus' => '',
|
||||
'instagram' => '',
|
||||
'youtube' => '',
|
||||
'linkedin' => '',
|
||||
'pinterest' => '',
|
||||
'soundcloud' => '',
|
||||
'tumblr' => '',
|
||||
'wikipedia' => '',
|
||||
'myspace' => '',
|
||||
'other' => array(),
|
||||
),
|
||||
|
||||
// Global Schemas.
|
||||
'wp-schema-pro-global-schemas' => array(
|
||||
'about-page' => '',
|
||||
'contact-page' => '',
|
||||
'site-navigation-element' => '',
|
||||
'breadcrumb' => '1',
|
||||
'sitelink-search-box' => '1',
|
||||
),
|
||||
|
||||
// Advanced Settings.
|
||||
'aiosrs-pro-settings' => array(
|
||||
'quick-test' => '1',
|
||||
'menu-position' => 'options-general.php',
|
||||
'schema-location' => 'head',
|
||||
'yoast-compatibility' => '1',
|
||||
'schema-validation' => '',
|
||||
'default_image' => '',
|
||||
'delete-schema-data' => '',
|
||||
|
||||
),
|
||||
|
||||
// Corporate Contact.
|
||||
'wp-schema-pro-corporate-contact' => array(
|
||||
'contact-type' => '',
|
||||
'telephone' => '',
|
||||
'url' => '',
|
||||
'email' => '',
|
||||
'areaServed' => '',
|
||||
'contact-hear' => '',
|
||||
'contact-toll' => '',
|
||||
'availableLanguage' => '',
|
||||
'cp-schema-type' => '',
|
||||
'areaserved-type' => '',
|
||||
'country' => array(),
|
||||
'place' => '',
|
||||
'contact-page-id' => '',
|
||||
'contact-type-other' => '',
|
||||
|
||||
),
|
||||
|
||||
// Branding Settings.
|
||||
'wp-schema-pro-branding-settings' => array(
|
||||
'sp_plugin_name' => '',
|
||||
'sp_plugin_sname' => '',
|
||||
'sp_plugin_desc' => '',
|
||||
'sp_plugin_author_name' => '',
|
||||
'sp_plugin_author_url' => '',
|
||||
'sp_hide_label' => 'disabled',
|
||||
),
|
||||
'wp-schema-pro-breadcrumb-setting' => array(
|
||||
'product' => '',
|
||||
'product_cat' => '',
|
||||
'product_tag' => '',
|
||||
'enable_bread' => '1',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
self::prepare_schema_pro_options();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare options from database.
|
||||
*/
|
||||
public static function prepare_schema_pro_options() {
|
||||
$options = array_keys( self::$default_options );
|
||||
foreach ( $options as $option ) {
|
||||
self::$settings[ $option ] = get_option( $option );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the scripts at the backend.
|
||||
*/
|
||||
public static function bsf_schema_pro_enqueue_admin_script() {
|
||||
global $pagenow;
|
||||
return 'post-new.php' === $pagenow || 'post.php' === $pagenow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options.
|
||||
*/
|
||||
public static function bsf_schema_pro_set_default_options() {
|
||||
|
||||
foreach ( self::$default_options as $key => $default_option ) {
|
||||
$settings = get_option( $key );
|
||||
if ( ! get_option( $key ) ) {
|
||||
update_option( $key, $default_option );
|
||||
} else {
|
||||
foreach ( $default_option as $name => $setting ) {
|
||||
if ( ! isset( $settings[ $name ] ) ) {
|
||||
$settings[ $name ] = $default_option[ $name ];
|
||||
}
|
||||
}
|
||||
// Updated settings if new settings added.
|
||||
update_option( $key, $settings );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete decrypted cached structured option data.
|
||||
delete_option( BSF_AIOSRS_PRO_CACHE_KEY );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the WP_debug.
|
||||
*/
|
||||
public static function bsf_schema_pro_is_wp_debug_enable() {
|
||||
return true === ( defined( 'WP_DEBUG' ) && WP_DEBUG );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BSF_AIOSRS_Pro_Helper::get_instance();
|
||||
@@ -1,516 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas - Markup.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Markup' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Markup {
|
||||
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $schema_post_result = array();
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initalize
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
|
||||
|
||||
add_action( 'wp', array( $this, 'disable_astra_theme_schema' ) );
|
||||
add_filter( 'the_content', array( $this, 'rating_markup' ) );
|
||||
add_shortcode( 'wp_schema_pro_rating_shortcode', array( $this, 'rating_markup' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_action( 'wp_ajax_aiosrs_user_rating', array( $this, 'aiosrs_user_rating_callback' ) );
|
||||
add_action( 'wp_ajax_nopriv_aiosrs_user_rating', array( $this, 'aiosrs_user_rating_callback' ) );
|
||||
add_filter( 'body_class', array( $this, 'wp_schema_body_class' ) );
|
||||
|
||||
if ( isset( $settings['schema-location'] ) ) {
|
||||
|
||||
switch ( $settings['schema-location'] ) {
|
||||
case 'head':
|
||||
add_action( 'wp_head', array( $this, 'schema_markup' ) );
|
||||
add_action( 'wp_head', array( $this, 'global_schemas_markup' ) );
|
||||
break;
|
||||
case 'footer':
|
||||
add_action( 'wp_footer', array( $this, 'schema_markup' ) );
|
||||
add_action( 'wp_footer', array( $this, 'global_schemas_markup' ) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding class to body
|
||||
*
|
||||
* @param array $classes body classes.
|
||||
* @return array
|
||||
*/
|
||||
public function wp_schema_body_class( $classes ) {
|
||||
|
||||
$classes[] = 'wp-schema-pro-' . BSF_AIOSRS_PRO_VER;
|
||||
|
||||
return $classes;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Guest user rating
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function aiosrs_user_rating_callback() {
|
||||
|
||||
check_ajax_referer( 'schema-pro-user-rating', 'nonce' );
|
||||
|
||||
$response = array(
|
||||
'success' => false,
|
||||
);
|
||||
if ( isset( $_POST['post_id'] ) && isset( $_POST['rating'] ) && isset( $_POST['schemaId'] ) ) {
|
||||
$post_id = absint( $_POST['post_id'] );
|
||||
$schema_id = absint( $_POST['schemaId'] );
|
||||
$new_rating = absint( $_POST['rating'] );
|
||||
if ( $new_rating > 5 ) {
|
||||
$new_rating = 5;
|
||||
}
|
||||
$new_rating = $new_rating <= 0 ? 1 : $new_rating;
|
||||
$client_ip = $this->get_client_ip();
|
||||
|
||||
$all_ratings = get_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, true );
|
||||
if ( empty( $all_ratings ) ) {
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, $new_rating );
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, 1 );
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, array( $client_ip => $new_rating ) );
|
||||
$response['success'] = true;
|
||||
$response['rating'] = $new_rating;
|
||||
$response['rating-avg'] = sprintf(
|
||||
/* translators: 1: rating */
|
||||
_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
|
||||
esc_html( $new_rating )
|
||||
);
|
||||
$response['review-count'] = __( '1 Review', 'wp-schema-pro' );
|
||||
} else {
|
||||
|
||||
$all_ratings[ $client_ip ] = $new_rating;
|
||||
$all_ratings = array_filter( $all_ratings );
|
||||
$review_count = count( $all_ratings );
|
||||
$avg_rating = round( array_sum( $all_ratings ) / $review_count, 1 );
|
||||
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, $avg_rating );
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, $review_count );
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, $all_ratings );
|
||||
|
||||
$response['success'] = true;
|
||||
$response['rating'] = $avg_rating;
|
||||
$response['rating-avg'] = sprintf(
|
||||
/* translators: 1: rating */
|
||||
_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
|
||||
esc_html( $avg_rating )
|
||||
);
|
||||
$response['review-count'] = sprintf(
|
||||
/* translators: 1: number of reviews */
|
||||
_n( '(%1s Review)', '(%1s Reviews)', absint( $review_count ), 'wp-schema-pro' ),
|
||||
absint( $review_count )
|
||||
);
|
||||
}
|
||||
// Deleting cached structured data.
|
||||
delete_post_meta( $post_id, BSF_AIOSRS_PRO_CACHE_KEY );
|
||||
do_action( 'wp_schema_pro_after_update_user_rating', $post_id );
|
||||
}
|
||||
wp_send_json( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the client IP address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_client_ip() {
|
||||
|
||||
if ( getenv( 'HTTP_CLIENT_IP' ) ) {
|
||||
$ipaddress = getenv( 'HTTP_CLIENT_IP' );
|
||||
} elseif ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
|
||||
$ipaddress = getenv( 'HTTP_X_FORWARDED_FOR' );
|
||||
} elseif ( getenv( 'HTTP_X_FORWARDED' ) ) {
|
||||
$ipaddress = getenv( 'HTTP_X_FORWARDED' );
|
||||
} elseif ( getenv( 'HTTP_FORWARDED_FOR' ) ) {
|
||||
$ipaddress = getenv( 'HTTP_FORWARDED_FOR' );
|
||||
} elseif ( getenv( 'HTTP_FORWARDED' ) ) {
|
||||
$ipaddress = getenv( 'HTTP_FORWARDED' );
|
||||
} elseif ( getenv( 'REMOTE_ADDR' ) ) {
|
||||
$ipaddress = getenv( 'REMOTE_ADDR' );
|
||||
} else {
|
||||
$ipaddress = 'UNKNOWN';
|
||||
}
|
||||
|
||||
return $ipaddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Script & Styles for frontend.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
|
||||
if ( is_singular() ) {
|
||||
$post_id = get_the_ID();
|
||||
$minfy_css = BSF_AIOSRS_Pro_Helper::bsf_schema_pro_is_wp_debug_enable() ? 'css/frontend.css' : 'min-css/frontend.min.css';
|
||||
$minfy_js = BSF_AIOSRS_Pro_Helper::bsf_schema_pro_is_wp_debug_enable() ? 'js/frontend.js' : 'min-js/frontend.min.js';
|
||||
wp_enqueue_style( 'dashicons' );
|
||||
wp_register_script( 'wp-schema-pro-fontend-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . $minfy_js, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
|
||||
wp_register_style( 'wp-schema-pro-fontend-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . $minfy_css, array(), BSF_AIOSRS_PRO_VER );
|
||||
wp_localize_script(
|
||||
'wp-schema-pro-fontend-script',
|
||||
'AIOSRS_Frontend',
|
||||
array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'post_id' => $post_id,
|
||||
'user_rating_nonce' => wp_create_nonce( 'schema-pro-user-rating' ),
|
||||
'success_msg' => __( 'Thanks!', 'wp-schema-pro' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add rating markup in content
|
||||
*
|
||||
* @param html $content Post content.
|
||||
* @return html
|
||||
*/
|
||||
public function rating_markup( $content = '' ) {
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
return $content;
|
||||
}
|
||||
$rating_enabled = array();
|
||||
$result = self::get_schema_posts();
|
||||
if ( is_array( $result ) && ! empty( $result ) ) {
|
||||
|
||||
$current_post_id = get_the_id();
|
||||
foreach ( $result as $post_id => $post_data ) {
|
||||
|
||||
$schema_type = get_post_meta( $post_id, 'bsf-aiosrs-schema-type', true );
|
||||
$schema_meta = get_post_meta( $post_id, 'bsf-aiosrs-' . $schema_type, true );
|
||||
|
||||
$schema_enabled = BSF_AIOSRS_Pro_Custom_Fields_Markup::enable_schema_post_option();
|
||||
$schema_enabled_meta_key = $schema_type . '-' . $post_id . '-enabled-schema';
|
||||
$schema_enabled_meta_value = get_post_meta( $current_post_id, $schema_enabled_meta_key, true );
|
||||
$schema_enabled_meta_value = ! empty( $schema_enabled_meta_value ) ? $schema_enabled_meta_value : 'disabled';
|
||||
$schema_rating_value = isset( $schema_meta['schema-type'] ) ? $schema_meta['schema-type'] . '-rating' : '';
|
||||
|
||||
if ( empty( $current_post_id ) || empty( $schema_type ) || empty( $schema_meta ) || ( $schema_enabled && 'disabled' === $schema_enabled_meta_value ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $schema_meta as $meta_key => $metavalue ) {
|
||||
if ( $meta_key === $schema_rating_value && 'accept-user-rating' === $metavalue ) {
|
||||
$rating_enabled[] = $post_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( isset( $schema_meta['rating'] ) && 'accept-user-rating' === $schema_meta['rating'] ) || ( 'accept-user-rating' === $schema_rating_value ) ) {
|
||||
$rating_enabled[] = $post_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$post_id = get_the_ID();
|
||||
if ( ! empty( $rating_enabled ) ) {
|
||||
ob_start();
|
||||
|
||||
foreach ( $rating_enabled as $index => $schema_id ) {
|
||||
|
||||
if ( 'publish' !== get_post_status( $schema_id ) ) {
|
||||
unset( $rating_enabled[ $index ] );
|
||||
update_post_meta( $post_id, 'bsf-schema-pro-accept-user-rating', $rating_enabled );
|
||||
continue;
|
||||
}
|
||||
|
||||
$review_counts = get_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, true );
|
||||
$review_counts = ! empty( $review_counts ) ? $review_counts : 0;
|
||||
$avg_rating = get_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, true );
|
||||
$avg_rating = ! empty( $avg_rating ) ? $avg_rating : 0;
|
||||
|
||||
wp_enqueue_script( 'wp-schema-pro-fontend-script' );
|
||||
wp_enqueue_style( 'wp-schema-pro-fontend-style' );
|
||||
$avg_rating = apply_filters( 'update_avg_star_ratings_schema_pro_markup', $avg_rating );
|
||||
apply_filters( 'add_ratings_schema_pro_markup', $review_counts, $avg_rating );
|
||||
?>
|
||||
<div class="aiosrs-rating-wrap" data-schema-id="<?php echo esc_attr( $schema_id ); ?>">
|
||||
<?php
|
||||
BSF_AIOSRS_Pro_Custom_Fields_Markup::get_star_rating_markup( $avg_rating );
|
||||
?>
|
||||
<div class="aiosrs-rating-summary-wrap">
|
||||
<span class="aiosrs-rating">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: rating */
|
||||
esc_attr_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
|
||||
esc_html( $avg_rating )
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
<span class="aiosrs-rating-count">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: number of reviews */
|
||||
esc_html( _n( '(%1s Review)', '(%1s Reviews)', absint( $review_counts ), 'wp-schema-pro' ) ),
|
||||
absint( $review_counts )
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
$content .= ob_get_clean();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current page schemas.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_schema_posts() {
|
||||
|
||||
if ( is_singular() ) {
|
||||
if ( empty( self::$schema_post_result ) ) {
|
||||
|
||||
$option = array(
|
||||
'location' => 'bsf-aiosrs-schema-location',
|
||||
'exclusion' => 'bsf-aiosrs-schema-exclusion',
|
||||
);
|
||||
|
||||
self::$schema_post_result = BSF_Target_Rule_Fields::get_instance()->get_posts_by_conditions( 'aiosrs-schema', $option );
|
||||
|
||||
}
|
||||
}
|
||||
return self::$schema_post_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable astra theme schemas.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable_astra_theme_schema() {
|
||||
|
||||
$result = self::get_schema_posts();
|
||||
if ( is_array( $result ) && ! empty( $result ) ) {
|
||||
|
||||
// Disable default Astra article schema.
|
||||
add_filter( 'astra_article_schema_enabled', '__return_false' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schema Markup in JSON-LD form.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function schema_markup() {
|
||||
|
||||
$current_post_id = get_the_id();
|
||||
|
||||
$result = self::get_schema_posts();
|
||||
|
||||
if ( is_array( $result ) && ! empty( $result ) ) {
|
||||
$json_ld_markup = get_post_meta( $current_post_id, BSF_AIOSRS_PRO_CACHE_KEY, true );
|
||||
if ( $json_ld_markup ) {
|
||||
echo $json_ld_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
return;
|
||||
}
|
||||
foreach ( $result as $post_id => $post_data ) {
|
||||
|
||||
$schema_type = get_post_meta( $post_id, 'bsf-aiosrs-schema-type', true );
|
||||
$schema_meta = get_post_meta( $post_id, 'bsf-aiosrs-' . $schema_type, true );
|
||||
|
||||
$schema_enabled = BSF_AIOSRS_Pro_Custom_Fields_Markup::enable_schema_post_option();
|
||||
$schema_enabled_meta_key = $schema_type . '-' . $post_id . '-enabled-schema';
|
||||
$schema_enabled_meta_value = get_post_meta( $current_post_id, $schema_enabled_meta_key, true );
|
||||
$schema_enabled_meta_value = ! empty( $schema_enabled_meta_value ) ? $schema_enabled_meta_value : 'disabled';
|
||||
|
||||
if ( empty( $current_post_id ) || empty( $schema_type ) || empty( $schema_meta ) || ( $schema_enabled && 'disabled' === $schema_enabled_meta_value ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
do_action( "wp_schema_before_schema_markup_{$schema_type}", $current_post_id, $schema_type );
|
||||
|
||||
$enabled = apply_filters( 'wp_schema_pro_schema_enabled', true, $current_post_id, $schema_type );
|
||||
$enabled_comment = apply_filters( 'wp_schema_pro_comment_before_markup_enabled', true );
|
||||
if ( true === $enabled_comment ) {
|
||||
$json_ld_markup .= '<!-- Schema optimized by Schema Pro -->';
|
||||
}
|
||||
if ( true === $enabled ) {
|
||||
if ( 'custom-markup' === $schema_type ) {
|
||||
$custom_markup = BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta );
|
||||
if ( isset( $custom_markup[ $schema_type ] ) && ! empty( $custom_markup[ $schema_type ] ) ) {
|
||||
$custom_markup[ $schema_type ] = trim( $custom_markup[ $schema_type ] );
|
||||
$first_schema_character = substr( $custom_markup[ $schema_type ], 0, 1 );
|
||||
$last_schema_character = substr( $custom_markup[ $schema_type ], -1, 1 );
|
||||
if ( '{' === $first_schema_character && '}' === $last_schema_character ) {
|
||||
$json_ld_markup .= '<script type="application/ld+json">';
|
||||
$json_ld_markup .= $custom_markup[ $schema_type ];
|
||||
$json_ld_markup .= '</script>';
|
||||
} else {
|
||||
$json_ld_markup .= $custom_markup[ $schema_type ];
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// @codingStandardsIgnoreStart
|
||||
$json_ld_markup .= '<script type="application/ld+json">';
|
||||
if ( version_compare( PHP_VERSION, '5.3', '>' ) ) {
|
||||
$json_ld_markup .= wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta ),JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
} else {
|
||||
$json_ld_markup .= wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta ));
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
$json_ld_markup .= '</script>';
|
||||
}
|
||||
if ( true === $enabled_comment ) {
|
||||
$json_ld_markup .= '<!-- / Schema optimized by Schema Pro -->';
|
||||
}
|
||||
}
|
||||
|
||||
do_action( "wp_schema_after_schema_markup_{$schema_type}", $current_post_id, $schema_type );
|
||||
}
|
||||
|
||||
echo $json_ld_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
$json_ld_markup = addcslashes( $json_ld_markup, '"\\/' );
|
||||
update_post_meta( $current_post_id, 'wp_schema_pro_optimized_structured_data', $json_ld_markup );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global Schema
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @param int $post_id Post Id.
|
||||
* @param string $type Schema type.
|
||||
*/
|
||||
public static function global_schema_markup( $post_id, $type ) {
|
||||
|
||||
do_action( "wp_schema_before_global_schema_markup_{$type}", $post_id, $type );
|
||||
|
||||
$enabled_global_schema = apply_filters( 'wp_schema_pro_global_schema_enabled', true, $post_id, $type );
|
||||
$enabled_global_comment = apply_filters( 'wp_schema_pro_comment_before_markup_enabled', true );
|
||||
if ( true === $enabled_global_schema ) {
|
||||
if ( true === $enabled_global_comment ) {
|
||||
echo '<!-- ' . esc_html( $type ) . ' Schema optimized by Schema Pro -->';
|
||||
}
|
||||
// @codingStandardsIgnoreStart
|
||||
echo '<script type="application/ld+json">';
|
||||
if ( ! version_compare( PHP_VERSION, '5.3', '>' ) ) {
|
||||
echo wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_global_schema( $post_id, $type ),JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
|
||||
} else {
|
||||
echo wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_global_schema( $post_id, $type ));
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
echo '</script>';
|
||||
if ( true === $enabled_global_comment ) {
|
||||
echo '<!-- / ' . esc_html( $type ) . ' Schema optimized by Schema Pro -->';
|
||||
}
|
||||
}
|
||||
|
||||
do_action( "wp_schema_after_global_schema_markup_{$type}", $post_id, $type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Global Schemas
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function global_schemas_markup() {
|
||||
|
||||
$yoast_enabled = WP_Schema_Pro_Yoast_Compatibility::get_option( 'wp_schema_pro_yoast_enabled' );
|
||||
$yoast_company_person = WP_Schema_Pro_Yoast_Compatibility::get_option( 'company_or_person' );
|
||||
$yoast_advanced_meta = WP_Schema_Pro_Yoast_Compatibility::get_option( 'disableadvanced_meta' );
|
||||
$yoast_breadcrumb = WP_Schema_Pro_Yoast_Compatibility::get_option( 'breadcrumbs-enable' );
|
||||
$post_id = get_the_ID();
|
||||
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
$global_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
|
||||
if ( 'person' === $general_settings['site-represent'] || 'personblog' === $general_settings['site-represent'] ) {
|
||||
$general_settings['site-represent'] = 'person';
|
||||
}
|
||||
if ( 'organization' === $general_settings['site-represent'] || 'Webshop' === $general_settings['site-represent'] || 'Smallbusiness' === $general_settings['site-represent'] || 'Otherbusiness' === $general_settings['site-represent'] ) {
|
||||
$general_settings['site-represent'] = 'organization';
|
||||
}
|
||||
if ( is_front_page() && ( ! $yoast_company_person || empty( $yoast_company_person ) ) && ! empty( $general_settings['site-represent'] ) ) {
|
||||
|
||||
echo esc_html( self::global_schema_markup( $post_id, $general_settings['site-represent'] ) );
|
||||
}
|
||||
if ( ! empty( $global_settings['site-navigation-element'] ) ) {
|
||||
echo esc_html( self::global_schema_markup( $post_id, 'site-navigation-element' ) );
|
||||
}
|
||||
if ( ! $yoast_enabled && '1' === $global_settings['sitelink-search-box'] ) {
|
||||
echo esc_html( self::global_schema_markup( $post_id, 'sitelink-search-box' ) );
|
||||
}
|
||||
if ( ! is_front_page() && ! ( $yoast_advanced_meta && $yoast_breadcrumb ) && '1' === $global_settings['breadcrumb'] ) {
|
||||
echo esc_html( self::global_schema_markup( $post_id, 'breadcrumb' ) );
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
return;
|
||||
}
|
||||
if ( absint( $global_settings['about-page'] ) === $post_id ) {
|
||||
|
||||
echo esc_html( self::global_schema_markup( $post_id, 'about-page' ) );
|
||||
}
|
||||
if ( absint( $global_settings['contact-page'] ) === $post_id ) {
|
||||
echo esc_html( self::global_schema_markup( $post_id, 'contact-page' ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
BSF_AIOSRS_Pro_Markup::get_instance();
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exit if accessed directly.
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* This class initializes Schema for AMP
|
||||
*
|
||||
* @class BSF_AIOSRS_Pro_Schema_Global_Uninstall
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Uninstall {
|
||||
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Constructor function.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->delete_all_plugin_data();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
/**
|
||||
* Delete function.
|
||||
*/
|
||||
public function delete_queries() {
|
||||
global $wpdb;
|
||||
$delete_keys = BSF_AIOSRS_Pro_Helper::$settings;
|
||||
$delete_keys_options = array_keys( $delete_keys );
|
||||
$delete_options_placeholders = implode( ', ', array_fill( 0, count( $delete_keys_options ), '%s' ) );
|
||||
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s", '%' . $wpdb->esc_like( 'bsf-aiosrs-' ) . '%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->posts} WHERE post_type LIKE %s", '%' . $wpdb->esc_like( 'aiosrs-schema' ) . '%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||
$query = "DELETE FROM {$wpdb->options} WHERE option_name IN ($delete_options_placeholders)";
|
||||
// @codingStandardsIgnoreStart
|
||||
$wpdb->query( $wpdb->prepare( $query, $delete_keys_options ) );
|
||||
wp_cache_delete($delete_options_placeholders,'options');
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
/**
|
||||
* Delete Schema from single site or multisite.
|
||||
*/
|
||||
public function delete_all_plugin_data() {
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
|
||||
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
|
||||
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
|
||||
if ( '1' === $delete_schema ) {
|
||||
self::delete_queries();
|
||||
}
|
||||
} else {
|
||||
global $wpdb;
|
||||
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$original_blog_id = get_current_blog_id();
|
||||
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
|
||||
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
|
||||
foreach ( $blog_ids as $blog_id ) {
|
||||
switch_to_blog( $blog_id );
|
||||
if ( '1' === $delete_schema ) {
|
||||
self::delete_queries();
|
||||
}
|
||||
}
|
||||
switch_to_blog( $original_blog_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BSF_AIOSRS_Pro_Schema_Global_Uninstall::get_instance();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,481 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schema Pro - Schema Wizard
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Wizard' ) ) :
|
||||
|
||||
/**
|
||||
* BSF_AIOSRS_Pro_Schema_Wizard class.
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Wizard {
|
||||
protected $steps = array();
|
||||
protected $step;
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( apply_filters( 'wp_schema_pro_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
|
||||
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
||||
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
|
||||
}
|
||||
|
||||
$this->steps = array(
|
||||
'basic-config' => array(
|
||||
'name' => __( 'Choose Schema Type', 'wp-schema-pro' ),
|
||||
'view' => array( $this, 'choose_schema_type' ),
|
||||
'handler' => array( $this, 'choose_schema_type_save' ),
|
||||
),
|
||||
'enable-on' => array(
|
||||
'name' => __( 'Set Target Pages', 'wp-schema-pro' ),
|
||||
'view' => array( $this, 'implement_on_callback' ),
|
||||
'handler' => array( $this, 'implement_on_callback_save' ),
|
||||
),
|
||||
'setup-ready' => array(
|
||||
'name' => __( 'Ready!', 'wp-schema-pro' ),
|
||||
'view' => array( $this, 'schema_ready' ),
|
||||
'handler' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add admin menus/screens.
|
||||
*/
|
||||
public function admin_menus() {
|
||||
add_dashboard_page( '', '', 'manage_options', 'aiosrs-pro-setup', '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the setup wizard.
|
||||
*/
|
||||
public function setup_wizard() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $_GET['page'] ) || 'aiosrs-pro-setup' !== $_GET['page'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
||||
|
||||
wp_enqueue_style( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array( 'dashicons', 'install' ), BSF_AIOSRS_PRO_VER );
|
||||
wp_enqueue_style( 'aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
|
||||
wp_register_script( 'aiosrs-pro-admin-edit-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery', 'jquery-ui-tooltip' ), BSF_AIOSRS_PRO_VER, true );
|
||||
wp_register_script( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
|
||||
|
||||
wp_enqueue_style( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false );
|
||||
wp_enqueue_style( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.css', '', BSF_AIOSRS_PRO_VER, false );
|
||||
wp_register_script( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array( 'jquery', 'backbone', 'wp-util' ), BSF_AIOSRS_PRO_VER, true );
|
||||
wp_register_script( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.js', array( 'jquery', 'bsf-target-rule-select2' ), BSF_AIOSRS_PRO_VER, true );
|
||||
wp_register_script( 'bsf-user-role', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/user-role.js', array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
|
||||
|
||||
wp_enqueue_media();
|
||||
wp_localize_script(
|
||||
'bsf-target-rule',
|
||||
'Targetrule',
|
||||
array(
|
||||
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'security' => wp_create_nonce( 'schema_nonce' ),
|
||||
)
|
||||
);
|
||||
if ( ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), 'aiosrs-pro-setup' ) ) && ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
|
||||
call_user_func( $this->steps[ $this->step ]['handler'] );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->setup_wizard_header();
|
||||
$this->setup_wizard_steps();
|
||||
$this->setup_wizard_content();
|
||||
$this->setup_wizard_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next step link
|
||||
*/
|
||||
public function get_next_step_link() {
|
||||
$keys = array_keys( $this->steps );
|
||||
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Header.
|
||||
*/
|
||||
public function setup_wizard_header() {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php esc_html_e( 'Schema Setup', 'wp-schema-pro' ); ?></title>
|
||||
<script type="text/javascript">
|
||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||
var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>';
|
||||
</script>
|
||||
<?php wp_print_scripts( array( 'bsf-target-rule-select2', 'bsf-target-rule', 'bsf-user-role', 'aiosrs-pro-admin-edit-script', 'aiosrs-pro-setup' ) ); ?>
|
||||
<?php do_action( 'admin_print_styles' ); ?>
|
||||
</head>
|
||||
<body class="aiosrs-pro-setup wp-core-ui">
|
||||
<div id="aiosrs-pro-logo">
|
||||
<?php
|
||||
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
if ( '' !== $brand_adv['sp_plugin_name'] ) {
|
||||
?>
|
||||
<h2 class="wpsp-setup-pro-title"><?php echo esc_html( $brand_adv['sp_plugin_name'] ); ?></h2>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo esc_url( BSF_AIOSRS_PRO_WEBSITE_URL ); ?>" target="_blank"><img src="<?php echo esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png' ); ?>" alt="<?php esc_attr_e( 'Schema Pro', 'wp-schema-pro' ); ?>" ></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Footer.
|
||||
*/
|
||||
public function setup_wizard_footer() {
|
||||
|
||||
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url( BSF_AIOSRS_Pro_Admin::$parent_page_slug );
|
||||
?>
|
||||
<div class="close-button-wrapper">
|
||||
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php esc_html_e( 'Exit Setup Wizard', 'wp-schema-pro' ); ?></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the steps.
|
||||
*/
|
||||
public function setup_wizard_steps() {
|
||||
|
||||
$ouput_steps = $this->steps;
|
||||
?>
|
||||
<ol class="aiosrs-pro-setup-steps">
|
||||
<?php
|
||||
foreach ( $ouput_steps as $step_key => $step ) :
|
||||
$classes = '';
|
||||
if ( $step_key === $this->step ) {
|
||||
$classes = 'active';
|
||||
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
|
||||
$classes = 'done';
|
||||
}
|
||||
?>
|
||||
<li class="<?php echo esc_attr( $classes ); ?>">
|
||||
<span><?php echo esc_html( $step['name'] ); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the content for the current step.
|
||||
*/
|
||||
public function setup_wizard_content() {
|
||||
echo '<div class="aiosrs-pro-setup-content">';
|
||||
call_user_func( $this->steps[ $this->step ]['view'] );
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Introduction step.
|
||||
*/
|
||||
public function choose_schema_type() {
|
||||
?>
|
||||
<h1><?php esc_html_e( 'Select the Schema Type:', 'wp-schema-pro' ); ?></h1>
|
||||
<form method="post">
|
||||
<input type="hidden" id="bsf-aiosrs-schema-title" name="bsf-aiosrs-schema-title" class="bsf-aiosrs-schema-title" >
|
||||
<input type="hidden" id="bsf-aiosrs-schema-type" name="bsf-aiosrs-schema-type" class="bsf-aiosrs-schema-type" >
|
||||
<table class="form-table aiosrs-pro-basic-config">
|
||||
<tr>
|
||||
<td><!-- Comment
|
||||
<?php foreach ( BSF_AIOSRS_Pro_Schema::$schema_meta_fields as $key => $schema_field ) { ?>
|
||||
--><span class="aiosrs-pro-schema-temp-wrap" data-schema-type="<?php echo esc_attr( $schema_field['key'] ); ?>" data-schema-title="<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>" >
|
||||
<i class="<?php echo isset( $schema_field['icon'] ) ? esc_attr( $schema_field['icon'] ) : 'dashicons dashicons-media-default'; ?>"></i>
|
||||
<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>
|
||||
</span><!-- Comment
|
||||
<?php } ?>
|
||||
--></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="aiosrs-pro-setup-actions step">
|
||||
<input type="submit" class="uct-activate button-primary button button-large button-next" disabled="true" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
|
||||
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Locale Settings.
|
||||
*/
|
||||
public function choose_schema_type_save() {
|
||||
check_admin_referer( 'aiosrs-pro-setup' );
|
||||
|
||||
// Update site title & tagline.
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
$title = isset( $_POST['bsf-aiosrs-schema-title'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-title'] ) : 0;
|
||||
$type = isset( $_POST['bsf-aiosrs-schema-type'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-type'] ) : 0;
|
||||
|
||||
$default_fields = array();
|
||||
if ( isset( BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'] ) ) {
|
||||
$default_data = BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'];
|
||||
foreach ( $default_data as $key => $value ) {
|
||||
if ( 'repeater' === $value['type'] ) {
|
||||
foreach ( $value['fields'] as $subkey => $subvalue ) {
|
||||
if ( isset( $subvalue['default'] ) && 'none' !== $subvalue['default'] ) {
|
||||
$default_fields[ $key ][0][ $subkey ] = $subvalue['default'];
|
||||
} else {
|
||||
$default_fields[ $key ][0][ $subkey ] = 'create-field';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( isset( $value['default'] ) && 'none' !== $value['default'] ) {
|
||||
$default_fields[ $key ] = $value['default'];
|
||||
} else {
|
||||
$default_fields[ $key ] = 'create-field';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$postarr = array(
|
||||
'post_type' => 'aiosrs-schema',
|
||||
'post_title' => $title,
|
||||
'post_status' => 'publish',
|
||||
'meta_input' => array(
|
||||
'bsf-aiosrs-schema-type' => $type,
|
||||
'bsf-aiosrs-' . $type => $default_fields,
|
||||
),
|
||||
);
|
||||
$post_id = wp_insert_post( $postarr );
|
||||
|
||||
if ( ! is_wp_error( $post_id ) ) {
|
||||
$redirect_url = add_query_arg( 'schema-id', $post_id, $redirect_url );
|
||||
}
|
||||
|
||||
wp_safe_redirect( esc_url_raw( $redirect_url ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale settings
|
||||
*/
|
||||
public function implement_on_callback() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
$schema_id = 0;
|
||||
$title = '';
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
|
||||
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
|
||||
$schema_id = intval( $_GET['schema-id'] );
|
||||
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
|
||||
$title = get_the_title( $schema_id );
|
||||
}
|
||||
|
||||
$meta_values = array(
|
||||
'include-locations' => array(
|
||||
'rule' => array( 'basic-singulars' ),
|
||||
),
|
||||
'exclude-locations' => array(),
|
||||
);
|
||||
?>
|
||||
|
||||
<h1>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1 schema title */
|
||||
wp_kses_post( 'Where %s schema should be integrated?', 'wp-schema-pro' ),
|
||||
esc_html( $title )
|
||||
);
|
||||
?>
|
||||
</h1>
|
||||
<form method="post">
|
||||
<input type="hidden" name="schema-id" value="<?php echo esc_attr( $schema_id ); ?>">
|
||||
<table class="bsf-aiosrs-schema-table widefat">
|
||||
<tr class="bsf-aiosrs-schema-row">
|
||||
<td class="bsf-aiosrs-schema-row-heading">
|
||||
<label><?php esc_html_e( 'Enable On', 'wp-schema-pro' ); ?></label>
|
||||
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'Add target pages where this Schema should appear.', 'wp-schema-pro' ); ?>"></i>
|
||||
</td>
|
||||
<td class="bsf-aiosrs-schema-row-content">
|
||||
<?php
|
||||
BSF_Target_Rule_Fields::target_rule_settings_field(
|
||||
'bsf-aiosrs-schema-location',
|
||||
array(
|
||||
'title' => __( 'Display Rules', 'wp-schema-pro' ),
|
||||
'value' => '[{"type":"basic-global","specific":null}]',
|
||||
'tags' => 'site,enable,target,pages',
|
||||
'rule_type' => 'display',
|
||||
'add_rule_label' => __( 'Add “AND” Rule', 'wp-schema-pro' ),
|
||||
),
|
||||
$meta_values['include-locations']
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="bsf-aiosrs-schema-row">
|
||||
<td class="bsf-aiosrs-schema-row-heading">
|
||||
<label><?php esc_html_e( 'Exclude From', 'wp-schema-pro' ); ?></label>
|
||||
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'This Schema will not appear at these pages.', 'wp-schema-pro' ); ?>"></i>
|
||||
</td>
|
||||
<td class="bsf-aiosrs-schema-row-content">
|
||||
<?php
|
||||
BSF_Target_Rule_Fields::target_rule_settings_field(
|
||||
'bsf-aiosrs-schema-exclusion',
|
||||
array(
|
||||
'title' => __( 'Exclude On', 'wp-schema-pro' ),
|
||||
'value' => '[]',
|
||||
'tags' => 'site,enable,target,pages',
|
||||
'add_rule_label' => __( 'Add “OR” Rule', 'wp-schema-pro' ),
|
||||
'rule_type' => 'exclude',
|
||||
),
|
||||
$meta_values['exclude-locations']
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="aiosrs-pro-setup-actions step">
|
||||
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
|
||||
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Locale Settings.
|
||||
*/
|
||||
public function implement_on_callback_save() {
|
||||
check_admin_referer( 'aiosrs-pro-setup' );
|
||||
|
||||
$schema_id = isset( $_POST['schema-id'] ) ? sanitize_text_field( $_POST['schema-id'] ) : 0;
|
||||
$enabled_on = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-location' );
|
||||
$exclude_from = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-exclusion' );
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
if ( $schema_id ) {
|
||||
|
||||
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
|
||||
update_post_meta( $schema_id, 'bsf-aiosrs-schema-location', $enabled_on );
|
||||
update_post_meta( $schema_id, 'bsf-aiosrs-schema-exclusion', $exclude_from );
|
||||
}
|
||||
|
||||
wp_safe_redirect( esc_url_raw( $redirect_url ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Location rules of schema for Custom meta box.
|
||||
*
|
||||
* @param array $enabled_on Enabled on rules.
|
||||
* @param array $exclude_from Exlcude on rules.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_display_rules_for_meta_box( $enabled_on, $exclude_from ) {
|
||||
$locations = array();
|
||||
$enabled_location = array();
|
||||
$exclude_location = array();
|
||||
|
||||
$args = array(
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
);
|
||||
$post_types = get_post_types( $args );
|
||||
unset( $post_types['attachment'] );
|
||||
|
||||
$args['_builtin'] = false;
|
||||
$custom_post_type = get_post_types( $args );
|
||||
$post_types = array_merge( $post_types, $custom_post_type );
|
||||
|
||||
if ( ! empty( $enabled_on ) && isset( $enabled_on['rule'] ) ) {
|
||||
$enabled_location = $enabled_on['rule'];
|
||||
}
|
||||
if ( ! empty( $exclude_from ) && isset( $exclude_from['rule'] ) ) {
|
||||
$exclude_location = $exclude_from['rule'];
|
||||
}
|
||||
|
||||
if ( in_array( 'specifics', $enabled_location, true ) || ( in_array( 'basic-singulars', $enabled_location, true ) && ! in_array( 'basic-singulars', $exclude_location, true ) ) ) {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$locations[ $post_type ] = 1;
|
||||
}
|
||||
} else {
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$key = $post_type . '|all';
|
||||
if ( in_array( $key, $enabled_location, true ) && ! in_array( $key, $exclude_location, true ) ) {
|
||||
$locations[ $post_type ] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $locations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final step.
|
||||
*/
|
||||
public function schema_ready() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$schema_id = 0;
|
||||
$title = '';
|
||||
|
||||
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
|
||||
$schema_id = intval( $_GET['schema-id'] );
|
||||
$title = get_the_title( $schema_id );
|
||||
}
|
||||
|
||||
?>
|
||||
<h1><?php esc_html_e( 'Your Schema is Ready!', 'wp-schema-pro' ); ?></h1>
|
||||
|
||||
<div class="aiosrs-pro-setup-next-steps">
|
||||
<div class="aiosrs-pro-setup-next-steps-last">
|
||||
|
||||
<p class="success">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1 schema title */
|
||||
wp_kses_post( 'Congratulations! The <i>%s</i> Schema has been added and enabled on selected target locations.', 'wp-schema-pro' ),
|
||||
esc_html( $title )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<p class="success">
|
||||
<strong><?php esc_html_e( 'Here’s what to do next:', 'wp-schema-pro' ); ?></strong><br>
|
||||
<?php esc_html_e( 'Step 1: Complete the setup and proceed to fill the required properties of this schema.', 'wp-schema-pro' ); ?><br>
|
||||
<?php esc_html_e( 'Step 2: Add necessary Schema information on individual pages and posts.', 'wp-schema-pro' ); ?><br>
|
||||
<?php esc_html_e( 'Step 3: Test if Schema is integrated correctly.', 'wp-schema-pro' ); ?>
|
||||
</p>
|
||||
|
||||
<table class="form-table aiosrs-pro-schema-ready">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo ( $schema_id ) ? esc_attr( get_edit_post_link( $schema_id ) ) : '#'; ?>" type="button" class="button button-primary button-hero" ><?php esc_html_e( 'Complete Setup', 'wp-schema-pro' ); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
new BSF_AIOSRS_Pro_Schema_Wizard();
|
||||
|
||||
endif;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,702 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schema Pro - Setup Wizard
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!class_exists('BSF_AIOSRS_Pro_Setup_Wizard')) :
|
||||
|
||||
/**
|
||||
* BSF_AIOSRS_Pro_Setup_Wizard class.
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Setup_Wizard
|
||||
{
|
||||
|
||||
public $steps = array();
|
||||
public $step;
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
if (apply_filters('wp_schema_pro_enable_setup_wizard', true) && current_user_can('manage_options')) {
|
||||
if (get_transient('wp-schema-pro-activated')) {
|
||||
delete_transient('wp-schema-pro-activated');
|
||||
}
|
||||
add_action('admin_menu', array($this, 'admin_menus'));
|
||||
add_action('admin_init', array($this, 'setup_wizard'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add admin menus/screens.
|
||||
*/
|
||||
public function admin_menus()
|
||||
{
|
||||
add_dashboard_page('', '', 'manage_options', 'aiosrs-pro-setup-wizard', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the setup wizard.
|
||||
*/
|
||||
public function setup_wizard()
|
||||
{
|
||||
if (isset($_REQUEST['wp_schema_pro_admin_page_nonce']) && !wp_verify_nonce(sanitize_text_field($_REQUEST['wp_schema_pro_admin_page_nonce']), 'wp_schema_pro_admin_page')) {
|
||||
return;
|
||||
}
|
||||
if (empty($_GET['page']) || 'aiosrs-pro-setup-wizard' !== $_GET['page']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->steps = array(
|
||||
'welcome' => array(
|
||||
'name' => __('Welcome', 'wp-schema-pro'),
|
||||
'view' => array($this, 'welcome'),
|
||||
),
|
||||
'general-setting' => array(
|
||||
'name' => __('General', 'wp-schema-pro'),
|
||||
'view' => array($this, 'general_setting'),
|
||||
'handler' => array($this, 'general_setting_save'),
|
||||
),
|
||||
'social-profiles' => array(
|
||||
'name' => __('Social Profiles', 'wp-schema-pro'),
|
||||
'view' => array($this, 'social_profiles'),
|
||||
'handler' => array($this, 'social_profiles_save'),
|
||||
),
|
||||
'global-schemas' => array(
|
||||
'name' => __('Other Schemas', 'wp-schema-pro'),
|
||||
'view' => array($this, 'global_schemas'),
|
||||
'handler' => array($this, 'global_schemas_save'),
|
||||
),
|
||||
'success' => array(
|
||||
'name' => __('Done', 'wp-schema-pro'),
|
||||
'view' => array($this, 'success'),
|
||||
'handler' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
|
||||
|
||||
wp_enqueue_style('aiosrs-pro-setup-wizard', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array('dashicons', 'install'), BSF_AIOSRS_PRO_VER);
|
||||
wp_enqueue_style('aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false');
|
||||
wp_enqueue_style('aiosrs-pro-admin-settings-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'settings-style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false');
|
||||
wp_register_script('aiosrs-pro-settings-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'settings-script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array('jquery', 'bsf-target-rule-select2', 'wp-i18n'), BSF_AIOSRS_PRO_VER, true);
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('media');
|
||||
wp_enqueue_style('bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false);
|
||||
wp_register_script('bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array('jquery', 'backbone', 'wp-util'), BSF_AIOSRS_PRO_VER, true);
|
||||
wp_localize_script(
|
||||
'aiosrs-pro-settings-script',
|
||||
'AIOSRS_search',
|
||||
apply_filters(
|
||||
'aiosrs_pro_settings_script_localize',
|
||||
array(
|
||||
'search_field' => wp_create_nonce('spec_schema'),
|
||||
)
|
||||
)
|
||||
);
|
||||
wp_register_script('aiosrs-pro-setup-wizard', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array('jquery'), BSF_AIOSRS_PRO_VER, true);
|
||||
if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field($_POST['_wpnonce']), 'aiosrs-pro-setup-wizard') && !empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
|
||||
call_user_func($this->steps[$this->step]['handler']);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->setup_wizard_header();
|
||||
$this->setup_wizard_steps();
|
||||
$this->setup_wizard_content();
|
||||
$this->setup_wizard_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous step link
|
||||
*/
|
||||
public function get_prev_step_link()
|
||||
{
|
||||
$keys = array_keys($this->steps);
|
||||
return add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps), true) - 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next step link
|
||||
*/
|
||||
public function get_next_step_link()
|
||||
{
|
||||
$keys = array_keys($this->steps);
|
||||
return add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps), true) + 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Header.
|
||||
*/
|
||||
public function setup_wizard_header()
|
||||
{
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php esc_html_e('Schema Setup', 'wp-schema-pro'); ?></title>
|
||||
<script type="text/javascript">
|
||||
addLoadEvent = function(func) {
|
||||
if (typeof jQuery != "undefined") jQuery(document).ready(func);
|
||||
else if (typeof wpOnload != 'function') {
|
||||
wpOnload = func;
|
||||
} else {
|
||||
var oldonload = wpOnload;
|
||||
wpOnload = function() {
|
||||
oldonload();
|
||||
func();
|
||||
}
|
||||
}
|
||||
};
|
||||
var ajaxurl = '<?php echo esc_url(admin_url('admin-ajax.php', 'relative')); ?>';
|
||||
</script>
|
||||
<?php wp_print_scripts(array('aiosrs-pro-admin-edit-script', 'aiosrs-pro-settings-script', 'aiosrs-pro-setup-wizard')); ?>
|
||||
<?php do_action('admin_print_styles'); ?>
|
||||
<?php do_action('admin_print_scripts'); ?>
|
||||
</head>
|
||||
|
||||
<body class="aiosrs-pro-setup-wizard wp-core-ui">
|
||||
<div id="aiosrs-pro-logo">
|
||||
<?php
|
||||
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
if ('' !== $brand_adv['sp_plugin_name']) {
|
||||
?>
|
||||
<h2 class="wpsp-setup-pro-title"><?php echo esc_html($brand_adv['sp_plugin_name']); ?></h2>
|
||||
<?php } else { ?>
|
||||
<a href="https://wpschema.com/" target="_blank"><img src="<?php echo esc_url(BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png'); ?>" alt="<?php esc_attr_e('Schema Pro', 'wp-schema-pro'); ?>"></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard Footer.
|
||||
*/
|
||||
public function setup_wizard_footer()
|
||||
{
|
||||
|
||||
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url('settings');
|
||||
?>
|
||||
<div class="close-button-wrapper">
|
||||
<a href="<?php echo esc_url($admin_url); ?>" class="wizard-close-link"><?php esc_html_e('Exit Setup Wizard', 'wp-schema-pro'); ?></a>
|
||||
</div>
|
||||
</body>
|
||||
<?php do_action('admin_footer'); ?>
|
||||
<?php do_action('admin_print_footer_scripts'); ?>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the steps.
|
||||
*/
|
||||
public function setup_wizard_steps()
|
||||
{
|
||||
|
||||
$ouput_steps = $this->steps;
|
||||
?>
|
||||
<ol class="aiosrs-pro-setup-wizard-steps">
|
||||
<?php
|
||||
foreach ($ouput_steps as $step_key => $step) :
|
||||
$classes = '';
|
||||
if ($step_key === $this->step) {
|
||||
$classes = 'active';
|
||||
} elseif (array_search($this->step, array_keys($this->steps), true) > array_search($step_key, array_keys($this->steps), true)) {
|
||||
$classes = 'done';
|
||||
}
|
||||
$url = add_query_arg('step', $step_key)
|
||||
?>
|
||||
<li class="<?php echo esc_attr($classes); ?>">
|
||||
<a href="<?php echo esc_url($url); ?>"><span><?php echo esc_html($step['name']); ?></span></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the content for the current step.
|
||||
*/
|
||||
public function setup_wizard_content()
|
||||
{
|
||||
echo '<div class="aiosrs-pro-setup-wizard-content ' . esc_attr($this->step) . '-content-wrap">';
|
||||
call_user_func($this->steps[$this->step]['view']);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Welcome.
|
||||
*/
|
||||
public function welcome()
|
||||
{
|
||||
if (is_multisite()) {
|
||||
$branding_msg = get_site_option('wp-schema-pro-branding-settings');
|
||||
} else {
|
||||
$branding_msg = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
}
|
||||
$sp_name = isset($branding_msg['sp_plugin_name']) ? $branding_msg['sp_plugin_name'] : '';
|
||||
if ('' !== $sp_name) {
|
||||
/* translators: %s: search term */
|
||||
$brand_msg = sprintf(__('Welcome to %s setup wizard !', 'wp-schema-pro'), $sp_name);
|
||||
/* translators: %s: search term */
|
||||
$brand_steup = sprintf(__('%s adds Google-recommended schema markups across your site and specific pages. This improves your SEO and allows search engines to display rich snippets for your website.', 'wp-schema-pro'), $sp_name);
|
||||
?>
|
||||
<h1><?php echo esc_html($brand_msg); ?></h1>
|
||||
<p class="success"><?php echo esc_html($brand_steup); ?></p>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<h1><?php esc_html_e('Welcome To Schema Pro Setup Wizard!', 'wp-schema-pro'); ?></h1>
|
||||
<p class="success">
|
||||
<?php esc_html_e('Schema Pro adds Google-recommended schema markups across your site and specific pages. This improves your SEO and allows search engines to display rich snippets for your website.', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<p class="success">
|
||||
<?php esc_html_e('This wizard is the first step to making Google understand your site better. Just fill in the required basic information. It’s easy!', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<?php if ('' === $sp_name) { ?>
|
||||
<p class="success">
|
||||
<?php echo sprintf(wp_kses_post('<a href="https://www.youtube.com/watch?v=xOiMA0am9QY" target="_blank">Watch a detailed video on the setup wizard tutorial.</a>', 'wp-schema-pro')); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<p class="aiosrs-pro-setup-wizard-actions step">
|
||||
<a href="<?php echo esc_url($this->get_next_step_link()); ?>" class="button-primary button button-large button-next"><?php esc_html_e('Start', 'wp-schema-pro'); ?> »</a>
|
||||
<?php wp_nonce_field('aiosrs-pro-setup-wizard'); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* General Setting
|
||||
*/
|
||||
public function general_setting()
|
||||
{
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
?>
|
||||
|
||||
<h1><?php esc_html_e('General', 'wp-schema-pro'); ?></h1>
|
||||
<p class="success"><?php esc_html_e('To help Google understand what your website is about, select the most suitable type for your website below, and fill in the required basic information.', 'wp-schema-pro'); ?></p>
|
||||
<form method="post">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('This Website Represents ', 'wp-schema-pro'); ?></th>
|
||||
<td>
|
||||
<select name="wp-schema-pro-general-settings[site-represent]">
|
||||
<option <?php selected($settings['site-represent'], ''); ?> value=""> <?php esc_html_e('--None--', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'person'); ?> value="person"> <?php esc_html_e('Personal Website', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'Otherbusiness'); ?> value="Otherbusiness"> <?php esc_html_e('Business Website', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'organization'); ?> value="organization"> <?php esc_html_e('Organization', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'personblog'); ?> value="personblog"> <?php esc_html_e('Personal Blog', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'Smallbusiness'); ?> value="Smallbusiness"> <?php esc_html_e('Community Blog/News Website ', 'wp-schema-pro'); ?></option>
|
||||
<option <?php selected($settings['site-represent'], 'Webshop'); ?> value="Webshop"> <?php esc_html_e('Webshop', 'wp-schema-pro'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
if ('person' === $settings['site-represent'] || 'personblog' === $settings['site-represent']) {
|
||||
$settings['site-represent'] = 'person';
|
||||
}
|
||||
if ('organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent']) {
|
||||
$settings['site-represent'] = 'organization';
|
||||
}
|
||||
?>
|
||||
<tr class="wp-schema-pro-site-logo-wrap">
|
||||
<th id=''><?php esc_html_e('Website Logo', 'wp-schema-pro'); ?></th>
|
||||
<td>
|
||||
<select style='display:none' name="wp-schema-pro-general-settings[site-logo]" class="wp-schema-pro-custom-option-select">
|
||||
<option <?php selected($settings['site-logo'], 'custom'); ?> value="custom"><?php esc_html_e('Add Custom Logo', 'wp-schema-pro'); ?></option>
|
||||
</select>
|
||||
<div class="custom-field-wrapper site-logo-custom-wrap">
|
||||
<input type="hidden" class="single-image-field" name="wp-schema-pro-general-settings[site-logo-custom]" value="<?php echo esc_attr($settings['site-logo-custom']); ?>" />
|
||||
<?php
|
||||
if (!empty($settings['site-logo-custom'])) {
|
||||
$image_url = wp_get_attachment_url($settings['site-logo-custom']);
|
||||
} else {
|
||||
$logo_id = '';
|
||||
if (function_exists('the_custom_logo') && has_custom_logo()) {
|
||||
$logo_id = get_theme_mod('custom_logo');
|
||||
}
|
||||
$image_url = wp_get_attachment_url($logo_id);
|
||||
}
|
||||
?>
|
||||
<div class="image-field-wrap <?php echo (!empty($image_url)) ? 'bsf-custom-image-selected' : ''; ?>"">
|
||||
<a href=" #" class="aiosrs-image-select button"><span class="dashicons dashicons-format-image"></span><?php esc_html_e('Select Image', 'wp-schema-pro'); ?></a>
|
||||
<a href="#" class="aiosrs-image-remove dashicons dashicons-no-alt wp-ui-text-highlight"></a>
|
||||
<?php if (isset($image_url) && !empty($image_url)) : ?>
|
||||
<a href="#" class="aiosrs-image-select img"><img src="<?php echo esc_url($image_url); ?>" /></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<p class='aiosrs-pro-field-description'><?php esc_html_e('Recommended minimum logo size 112 x 112 pixels.', 'wp-schema-pro'); ?></p>
|
||||
<p class='aiosrs-pro-field-description'><?php esc_html_e('The image must be in .jpg, .png, .gif, .svg, or .webp format.', 'wp-schema-pro'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="wp-schema-pro-person-name-wrap" <?php echo ('person' !== $settings['site-represent']) ? 'style="display: none;"' : ''; ?>>
|
||||
<th class='wpsp-organization-label'><?php esc_html_e('Website Owner Name', 'wp-schema-pro'); ?></th>
|
||||
<td>
|
||||
<input type="text" name="wp-schema-pro-general-settings[person-name]" value="<?php echo esc_attr($settings['person-name']); ?>" placeholder="<?php echo esc_attr(get_bloginfo('name')); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="wp-schema-pro-site-name-wrap" <?php echo ('organization' !== $settings['site-represent']) ? 'style="display: none;"' : ''; ?>>
|
||||
<th class='wpsp-organization-label'><?php esc_html_e('Organization Name', 'wp-schema-pro'); ?></th>
|
||||
<td>
|
||||
<input type="text" name="wp-schema-pro-general-settings[site-name]" value="<?php echo esc_attr($settings['site-name']); ?>" placeholder="<?php echo esc_attr(get_bloginfo('name')); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="wp-schema-pro-site-name-wrap " <?php echo ('organization' !== $settings['site-represent']) ? 'style="display: none;"' : ''; ?>>
|
||||
<th>
|
||||
<?php
|
||||
esc_html_e(
|
||||
'Organization Type',
|
||||
'wp-schema-pro'
|
||||
);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
$option_list = BSF_AIOSRS_Pro_Schema::get_dropdown_options('Organization-type');
|
||||
?>
|
||||
<select class="wpsp-setup-configuration-settings" name="wp-schema-pro-general-settings[organization]">
|
||||
<?php
|
||||
if (!empty($option_list)) {
|
||||
foreach ($option_list as $key => $value) {
|
||||
if ('-- None --' !== $value) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php selected($settings['organization'], $key); ?>><?php echo esc_html($value); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<p style="font-style: italic;">
|
||||
<?php
|
||||
$brand_bread = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
if (('1' === $brand_bread['sp_hide_label']) || true === (defined('WP_SP_WL') && WP_SP_WL)) {
|
||||
esc_html_e('Select the type that best describes your website. If you can\'t find one that applies exactly, use the generic "General/Other" type. Further create Local Business schema for "General/Other" type.', 'wp-schema-pro');
|
||||
} else {
|
||||
esc_html_e('Select the type that best describes your website. If you can\'t find one that applies exactly, use the generic "General/Other" type. Further create Local Business schema for "General/Other" type. ', 'wp-schema-pro');
|
||||
echo sprintf(
|
||||
wp_kses_post('<a href="https://wpschema.com/docs/organization-type-in-setup-wizard/" target="_blank">Learn more</a>', 'wp-schema-pro')
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="aiosrs-pro-setup-wizard-actions step">
|
||||
<?php wp_nonce_field('aiosrs-pro-setup-wizard'); ?>
|
||||
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e('Next', 'wp-schema-pro'); ?> »" name="save_step" />
|
||||
<a href="<?php echo esc_url($this->get_prev_step_link()); ?>" class="button-primary button button-large button-prev">« <?php esc_html_e('Previous', 'wp-schema-pro'); ?></a>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* General Setting Save.
|
||||
*/
|
||||
public function general_setting_save()
|
||||
{
|
||||
check_admin_referer('aiosrs-pro-setup-wizard');
|
||||
|
||||
if (isset($_POST['wp-schema-pro-general-settings'])) {
|
||||
update_option('wp-schema-pro-general-settings', array_map('sanitize_text_field', $_POST['wp-schema-pro-general-settings']));
|
||||
}
|
||||
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
wp_safe_redirect(esc_url_raw($redirect_url));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Social Profiles
|
||||
*/
|
||||
public function social_profiles()
|
||||
{
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
|
||||
?>
|
||||
<h1><?php esc_html_e('Social Profiles', 'wp-schema-pro'); ?></h1>
|
||||
<p class="success"><?php esc_html_e('Please enter all your possible social media profiles. These links can appear in the knowledge panel of the search results for your website.', 'wp-schema-pro'); ?></p>
|
||||
<form method="post">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Facebook', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[facebook]" value="<?php echo esc_attr($settings['facebook']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Instagram', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[instagram]" value="<?php echo esc_attr($settings['instagram']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('YouTube', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[youtube]" value="<?php echo esc_attr($settings['youtube']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Twitter', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[twitter]" value="<?php echo esc_attr($settings['twitter']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Pinterest', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[pinterest]" value="<?php echo esc_attr($settings['pinterest']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('LinkedIn', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[linkedin]" value="<?php echo esc_attr($settings['linkedin']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('SoundCloud', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[soundcloud]" value="<?php echo esc_attr($settings['soundcloud']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Tumblr', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[tumblr]" value="<?php echo esc_attr($settings['tumblr']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('Wikipedia', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[wikipedia]" value="<?php echo esc_attr($settings['wikipedia']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''><?php esc_html_e('MySpace', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[myspace]" value="<?php echo esc_attr($settings['myspace']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<tr style="display:none">
|
||||
<th id=''><?php esc_html_e('Google+', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" name="wp-schema-pro-social-profiles[google-plus]" value="<?php echo esc_attr($settings['google-plus']); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
if ( isset( $settings ) && ! empty( $settings ) && is_array( $settings['other'] ) ) {
|
||||
foreach ( $settings['other'] as $sub_social_profiles => $value ) {
|
||||
if ( isset( $value ) && ! empty( $value ) ) {
|
||||
?>
|
||||
<tr style="display:none">
|
||||
<th id='' class="wpsp-other-th"><?php esc_html_e('Other', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" class="wpsp-other" name="wp-schema-pro-social-profiles[other][<?php echo esc_attr($sub_social_profiles); ?>]" value="<?php echo esc_attr($value); ?>" placeholder="<?php echo esc_attr('Enter URL'); ?>" /><span class="wpsp-field-close remove-row dashicons dashicons-dismiss "><a href="#" class=""></a></span></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr style="display:none" class="empty-row screen-reader-text"> <!-- empty hidden one for jQuery -->
|
||||
<th id='' class="wpsp-other-th"><?php esc_html_e('Other', 'wp-schema-pro'); ?></th>
|
||||
<td><input type="url" class="wpsp-other" name="wp-schema-pro-social-profiles[other][]" value="" placeholder="<?php echo esc_attr('Enter URL'); ?>" /><span class="wpsp-field-close remove-row dashicons dashicons-dismiss "><a href="#" class="remove-row"></a></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="aiosrs-pro-setup-wizard-actions step">
|
||||
<?php wp_nonce_field('aiosrs-pro-setup-wizard'); ?>
|
||||
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e('Next', 'wp-schema-pro'); ?> »" name="save_step" />
|
||||
<a href="<?php echo esc_url($this->get_prev_step_link()); ?>" class="button-primary button button-large button-prev">« <?php esc_html_e('Previous', 'wp-schema-pro'); ?></a>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Social Profiles Save.
|
||||
*/
|
||||
public function social_profiles_save()
|
||||
{
|
||||
check_admin_referer('aiosrs-pro-setup-wizard');
|
||||
|
||||
if (isset($_POST['wp-schema-pro-social-profiles'])) {
|
||||
update_option('wp-schema-pro-social-profiles', array_map('sanitize_text_field', $_POST['wp-schema-pro-social-profiles']));
|
||||
}
|
||||
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
wp_safe_redirect(esc_url_raw($redirect_url));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global Schemas
|
||||
*/
|
||||
public function global_schemas()
|
||||
{
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
|
||||
?>
|
||||
<h1><?php esc_html_e('Other Schemas', 'wp-schema-pro'); ?></h1>
|
||||
<p class="success"><?php esc_html_e('Fill in additional information about your website to make sure that search engines fully understand what it’s about. This will help improve your SEO further.', 'wp-schema-pro'); ?></p>
|
||||
<form method="post">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th id=''>
|
||||
<?php esc_html_e('Select About Page', 'wp-schema-pro'); ?>
|
||||
<?php
|
||||
$message = __('Select your about page from the dropdown list. This will add AboutPage schema on the selected page.', 'wp-schema-pro');
|
||||
BSF_AIOSRS_Pro_Admin::get_tooltip($message);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<select class="wp-select2 wpsp-setup-configuration-settings" name="wp-schema-pro-global-schemas[about-page]">
|
||||
<option value=""><?php esc_html_e('--None--', 'wp-schema-pro'); ?></option>
|
||||
<?php foreach (BSF_AIOSRS_Pro_Admin::$pages as $page_id => $page_title) { ?>
|
||||
<option <?php selected($page_id, $settings['about-page']); ?> value="<?php echo esc_attr($page_id); ?>"><?php echo esc_html($page_title); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id=''>
|
||||
<?php esc_html_e('Select Contact Page', 'wp-schema-pro'); ?>
|
||||
<?php
|
||||
$message = __('Select your contact page from the dropdown list. This will add ContactPage schema on the selected page.', 'wp-schema-pro');
|
||||
BSF_AIOSRS_Pro_Admin::get_tooltip($message);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<select class="wp-select2 wpsp-setup-configuration-settings" name="wp-schema-pro-global-schemas[contact-page]">
|
||||
<option value=""><?php esc_html_e('--None--', 'wp-schema-pro'); ?></option>
|
||||
<?php foreach (BSF_AIOSRS_Pro_Admin::$pages as $page_id => $page_title) { ?>
|
||||
<option <?php selected($page_id, $settings['contact-page']); ?> value="<?php echo esc_attr($page_id); ?>"><?php echo esc_html($page_title); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id='' class="tooltip-with-image-wrapper">
|
||||
<?php esc_html_e('Select Menu for SiteLinks Schema', 'wp-schema-pro'); ?>
|
||||
<?php
|
||||
$message = '<img class="tooltip-image" src="' . esc_url(BSF_AIOSRS_PRO_URI . '/admin/assets/images/sitelinks.jpg') . '" />';
|
||||
BSF_AIOSRS_Pro_Admin::get_tooltip($message);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<?php $nav_menus = wp_get_nav_menus(); ?>
|
||||
<select name="wp-schema-pro-global-schemas[site-navigation-element]">
|
||||
<option <?php selected('', $settings['site-navigation-element']); ?> value=""><?php esc_html_e('--None--', 'wp-schema-pro'); ?></option>
|
||||
<?php foreach ($nav_menus as $menu) { ?>
|
||||
<option <?php selected($menu->term_id, $settings['site-navigation-element']); ?> value="<?php echo esc_attr($menu->term_id); ?>"><?php echo esc_html($menu->name); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p class="success aiosrs-pro-field-description"><?php esc_html_e('This helps Google understand the most important pages on your website and can generate Rich Snippets.', 'wp-schema-pro'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id='' class="tooltip-with-image-wrapper">
|
||||
<?php esc_html_e('Enable SiteLinks Search Box', 'wp-schema-pro'); ?>
|
||||
<?php
|
||||
$message = '<img class="tooltip-image" src="' . esc_url(BSF_AIOSRS_PRO_URI . '/admin/assets/images/sitelink-search.jpg') . '" />';
|
||||
BSF_AIOSRS_Pro_Admin::get_tooltip($message);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="hidden" name="wp-schema-pro-global-schemas[sitelink-search-box]" value="disabled" />
|
||||
<input type="checkbox" name="wp-schema-pro-global-schemas[sitelink-search-box]" <?php checked('1', $settings['sitelink-search-box']); ?> value="1" /> <?php esc_html_e('Yes', 'wp-schema-pro'); ?>
|
||||
</label>
|
||||
<p class="success aiosrs-pro-field-description"><?php esc_html_e('If enabled, Google can display a search box on your search website’s search results.', 'wp-schema-pro'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th id='' class="tooltip-with-image-wrapper">
|
||||
<?php esc_html_e('Enable Breadcrumbs', 'wp-schema-pro'); ?>
|
||||
<?php
|
||||
$message = '<img class="tooltip-image" src="' . esc_url(BSF_AIOSRS_PRO_URI . '/admin/assets/images/breadcrumbs.jpg') . '" />';
|
||||
BSF_AIOSRS_Pro_Admin::get_tooltip($message);
|
||||
?>
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="hidden" name="wp-schema-pro-global-schemas[breadcrumb]" value="disabled" />
|
||||
<input type="checkbox" name="wp-schema-pro-global-schemas[breadcrumb]" <?php checked('1', $settings['breadcrumb']); ?> value="1" /> <?php esc_html_e('Yes', 'wp-schema-pro'); ?>
|
||||
</label>
|
||||
<p class="success aiosrs-pro-field-description"><?php esc_html_e('If enabled, Google can add breadcrumbs to your website’s and pages search results.', 'wp-schema-pro'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="aiosrs-pro-setup-wizard-actions step">
|
||||
<?php wp_nonce_field('aiosrs-pro-setup-wizard'); ?>
|
||||
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e('Next', 'wp-schema-pro'); ?> »" name="save_step" />
|
||||
<a href="<?php echo esc_url($this->get_prev_step_link()); ?>" class="button-primary button button-large button-prev">« <?php esc_html_e('Previous', 'wp-schema-pro'); ?></a>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Global Schemas Save.
|
||||
*/
|
||||
public function global_schemas_save()
|
||||
{
|
||||
check_admin_referer('aiosrs-pro-setup-wizard');
|
||||
|
||||
if (isset($_POST['wp-schema-pro-global-schemas'])) {
|
||||
update_option('wp-schema-pro-global-schemas', array_map('sanitize_text_field', $_POST['wp-schema-pro-global-schemas']));
|
||||
$new_data = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-breadcrumb-setting'];
|
||||
if (isset($new_data['enable_bread'])) {
|
||||
$old_data = isset($_POST['wp-schema-pro-global-schemas']['breadcrumb']) ? sanitize_text_field($_POST['wp-schema-pro-global-schemas']['breadcrumb']) : '';
|
||||
$new_data['enable_bread'] = $old_data;
|
||||
update_option('wp-schema-pro-breadcrumb-setting', $new_data);
|
||||
}
|
||||
}
|
||||
|
||||
$redirect_url = $this->get_next_step_link();
|
||||
wp_safe_redirect(esc_url_raw($redirect_url));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final step.
|
||||
*/
|
||||
public function success()
|
||||
{
|
||||
|
||||
?>
|
||||
<h1><?php esc_html_e('Well done!', 'wp-schema-pro'); ?></h1>
|
||||
|
||||
<div class="aiosrs-pro-setup-wizard-next-steps">
|
||||
<div class="aiosrs-pro-setup-wizard-next-steps-last">
|
||||
<p class="success">
|
||||
<?php esc_html_e('You\'ve successfully added schema to your website! You’re on your way to get rich snippets for your pages.', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<p class="success">
|
||||
<?php esc_html_e('The information you provided is globally applied to the website. You can always go back, change, and add more to this later from your dashboard.', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<p class="success">
|
||||
<?php esc_html_e('From the dashboard, you can also explore other advanced features like breadcrumbs and white label services.', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<p class="success">
|
||||
<span class="wpsp-text-strong"><?php esc_html_e('Wondering what’s next?', 'wp-schema-pro'); ?></span>
|
||||
<?php esc_html_e(' The next step would be to create and set schema markups for your individual pages.', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
<p class="success">
|
||||
<?php esc_html_e('Give it a try now!', 'wp-schema-pro'); ?>
|
||||
</p>
|
||||
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo esc_url(admin_url('index.php?page=aiosrs-pro-setup')); ?>" type="button" class="button button-primary button-hero"><?php esc_html_e('Create First Schema', 'wp-schema-pro'); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
new BSF_AIOSRS_Pro_Setup_Wizard();
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schema Pro Init
|
||||
*
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
define( 'BSF_REMOVE_WP-SCHEMA-PRO_FROM_REGISTRATION_LISTING', true );
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro' ) ) {
|
||||
|
||||
/**
|
||||
* BSF_AIOSRS_Pro initial setup
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro {
|
||||
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Includes Required Files.
|
||||
$this->includes();
|
||||
add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) );
|
||||
add_action( 'wp_ajax_wp_schema_pro_setup_wizard_notice', array( $this, 'wp_schema_pro_setup_wizard_notice_callback' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup Wizard
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function setup_wizard_notice() {
|
||||
|
||||
if ( get_transient( 'wp-schema-pro-activated' ) ) {
|
||||
$url = admin_url( 'index.php?page=aiosrs-pro-setup-wizard' );
|
||||
$branding_notice = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
|
||||
|
||||
echo '<div class="wp-schema-pro-setup-wizard-notice notice notice-success is-dismissible">';
|
||||
if ( '' !== $branding_notice['sp_plugin_name'] ) {
|
||||
/* translators: %s: search term */
|
||||
$brand_notice = sprintf( esc_html__( 'Configure %s step by step. ', 'wp-schema-pro' ), $branding_notice['sp_plugin_name'] );
|
||||
echo '<p>' . esc_html( $brand_notice ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Start Setup Wizard »', 'wp-schema-pro' ) . '</a></p>';
|
||||
} else {
|
||||
echo '<p>' . esc_html__( 'Not sure where to start with Schema Pro? Check out our initial ', 'wp-schema-pro' ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'setup wizard first »', 'wp-schema-pro' ) . '</a></p>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
$(document).on('click', '.wp-schema-pro-setup-wizard-notice .notice-dismiss', function(){
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action : 'wp_schema_pro_setup_wizard_notice',
|
||||
nonce : '<?php echo esc_attr( wp_create_nonce( 'wp-schema-pro-setup-wizard-notice' ) ); ?>'
|
||||
},
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss Notice
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function wp_schema_pro_setup_wizard_notice_callback() {
|
||||
|
||||
check_ajax_referer( 'wp-schema-pro-setup-wizard-notice', 'nonce' );
|
||||
|
||||
delete_transient( 'wp-schema-pro-activated' );
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Include required files.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function includes() {
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/target-rule/class-bsf-target-rule-fields.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/class-bsf-custom-post-list-table.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-wp-schema-pro-yoast-compatibility.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-admin.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-custom-fields-markup.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-branding.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-amp.php';
|
||||
|
||||
/**
|
||||
* Frontend.
|
||||
*/
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema-template.php';
|
||||
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-markup.php';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
BSF_AIOSRS_Pro::get_instance();
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schema Pro Yoast Compatibilty
|
||||
*
|
||||
* @since 1.1.0
|
||||
* @package Schema Pro
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_Schema_Pro_Yoast_Compatibility' ) ) {
|
||||
|
||||
/**
|
||||
* WP_Schema_Pro_Yoast_Compatibility initial setup
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class WP_Schema_Pro_Yoast_Compatibility {
|
||||
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Yoast SEO is activated or not.
|
||||
*
|
||||
* @access private
|
||||
* @var $activated Yoast SEO is activated or not.
|
||||
*/
|
||||
public static $activated = false;
|
||||
|
||||
/**
|
||||
* Yoast SEO Options.
|
||||
*
|
||||
* @access private
|
||||
* @var $wpseo Yoast SEO options.
|
||||
*/
|
||||
private static $wpseo = array();
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor function.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
if ( defined( 'WPSEO_VERSION' ) && class_exists( 'WPSEO_Options' ) ) {
|
||||
self::$activated = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Yoast Options
|
||||
*
|
||||
* @param string $key Yoast Option key.
|
||||
* @return array Get yoast compatibility options.
|
||||
*/
|
||||
public static function get_option( $key = '' ) {
|
||||
|
||||
$settings = get_option( 'aiosrs-pro-settings', array() );
|
||||
if ( ! self::$activated || ( isset( $settings['yoast-compatibility'] ) && '1' !== $settings['yoast-compatibility'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'wp_schema_pro_yoast_enabled' === $key ) {
|
||||
return true;
|
||||
}
|
||||
if ( empty( self::$wpseo ) && method_exists( 'WPSEO_Options', 'get_options' ) ) {
|
||||
self::$wpseo = WPSEO_Options::get_options( array( 'wpseo', 'wpseo_social', 'wpseo_internallinks', 'wpseo_titles' ) );
|
||||
}
|
||||
|
||||
return isset( self::$wpseo[ $key ] ) ? self::$wpseo[ $key ] : false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
WP_Schema_Pro_Yoast_Compatibility::get_instance();
|
||||
@@ -1,612 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schema List Table
|
||||
*
|
||||
* @package Schema Pro
|
||||
**/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Load WP_List_Table if not loaded.
|
||||
if ( ! class_exists( 'WP_List_Table' ) ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Customizer Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_Custom_Post_List_Table extends WP_List_Table {
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var int $per_page items per page
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public $per_page = 30;
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var int $per_page items per page
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public $custom_post_type = 'post';
|
||||
|
||||
/**
|
||||
* BSF_Custom_Post_List_Table
|
||||
*
|
||||
* @param string $post_type Custom post type slug.
|
||||
*/
|
||||
public function __construct( $post_type ) {
|
||||
global $status, $page;
|
||||
|
||||
$this->custom_post_type = $post_type;
|
||||
parent::__construct(
|
||||
array(
|
||||
'singular' => $post_type,
|
||||
'plural' => $post_type . 's',
|
||||
'ajax' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* No Advanced Headers found message
|
||||
*/
|
||||
public function no_items() {
|
||||
$post_type_object = get_post_type_object( $this->custom_post_type );
|
||||
echo sprintf(
|
||||
/* translators: %s: post type label */
|
||||
esc_html__( 'No %s found', 'wp-schema-pro' ),
|
||||
esc_html( $post_type_object->labels->singular_name )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default columns
|
||||
*
|
||||
* @param array $item default column items.
|
||||
* @param array $column_name default column names.
|
||||
* @return void
|
||||
*/
|
||||
public function column_default( $item, $column_name ) {
|
||||
|
||||
switch ( $column_name ) {
|
||||
case 'post_title':
|
||||
case 'date':
|
||||
default:
|
||||
}
|
||||
|
||||
do_action( 'manage_' . $this->custom_post_type . '_posts_custom_column', $column_name, $item['ID'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sortable columns
|
||||
*
|
||||
* @return sortable_columns sortable columns.
|
||||
*/
|
||||
public function get_sortable_columns() {
|
||||
$sortable_columns = array(
|
||||
'post_title' => array( 'post_title', false ),
|
||||
'date' => array( 'date', false ),
|
||||
);
|
||||
return apply_filters( 'manage_' . $this->custom_post_type . '_sortable_columns', $sortable_columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort columns
|
||||
*
|
||||
* @param array $a default column items.
|
||||
* @param array $b default column names.
|
||||
* @return array $result sortable columns.
|
||||
*/
|
||||
public function usort_reorder( $a, $b ) {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
// If no sort, default to title.
|
||||
$orderby = ( ! empty( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'post_title';
|
||||
// If no order, default to asc.
|
||||
$order = ( ! empty( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'asc';
|
||||
// Determine sort order.
|
||||
$result = strcmp( $a[ $orderby ], $b[ $orderby ] );
|
||||
// Send final sort direction to usort.
|
||||
return ( 'asc' === $order ) ? $result : -$result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get columns
|
||||
*
|
||||
* @return array $columns display columns.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'post_title' => esc_html__( 'Title', 'wp-schema-pro' ),
|
||||
'date' => esc_html__( 'Date', 'wp-schema-pro' ),
|
||||
);
|
||||
return apply_filters( 'manage_' . $this->custom_post_type . '_posts_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bulk actions
|
||||
*
|
||||
* @return array $actions bulk actions.
|
||||
*/
|
||||
public function get_bulk_actions() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
$current = ( ! empty( $_REQUEST['post_status'] ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'all' );
|
||||
if ( 'trash' === $current ) {
|
||||
$actions = array(
|
||||
'restore' => esc_html__( 'Restore', 'wp-schema-pro' ),
|
||||
'delete' => esc_html__( 'Delete Permanently', 'wp-schema-pro' ),
|
||||
);
|
||||
} elseif ( 'draft' === $current ) {
|
||||
$actions = array(
|
||||
'trash' => esc_html__( 'Move to Trash', 'wp-schema-pro' ),
|
||||
);
|
||||
} else {
|
||||
$actions = array(
|
||||
'draft' => esc_html__( 'Draft', 'wp-schema-pro' ),
|
||||
'trash' => esc_html__( 'Move to Trash', 'wp-schema-pro' ),
|
||||
);
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process bulk actions
|
||||
*/
|
||||
public function process_bulk_action() {
|
||||
|
||||
// security check!
|
||||
$action = $this->current_action();
|
||||
if ( 'trash' === $action || 'delete' === $action || 'draft' === $action || 'restore' === $action ) {
|
||||
if ( isset( $_POST['_wpnonce'] ) && ! empty( $_POST['_wpnonce'] ) ) {
|
||||
|
||||
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
|
||||
$action = 'bulk-' . $this->_args['plural'];
|
||||
|
||||
if ( ! wp_verify_nonce( $nonce, $action ) ) {
|
||||
wp_die( 'Nope! Security check failed!' );
|
||||
}
|
||||
} else {
|
||||
wp_die( 'Nope! Security check failed!' );
|
||||
}
|
||||
|
||||
// Detect when a bulk action is being triggered...
|
||||
if ( 'trash' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
|
||||
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
|
||||
wp_trash_post( $id );
|
||||
}
|
||||
}
|
||||
if ( 'delete' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
|
||||
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
|
||||
wp_delete_post( $id );
|
||||
}
|
||||
}
|
||||
if ( 'draft' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
|
||||
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
|
||||
$post = array(
|
||||
'ID' => $id,
|
||||
'post_status' => 'draft',
|
||||
);
|
||||
wp_update_post( $post );
|
||||
}
|
||||
}
|
||||
if ( 'restore' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
|
||||
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
|
||||
wp_untrash_post( $id );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bulk actions
|
||||
*
|
||||
* @param array $item first columns checkbox.
|
||||
* @return array check box columns.
|
||||
*/
|
||||
public function column_cb( $item ) {
|
||||
return sprintf(
|
||||
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
||||
$this->_args['singular'],
|
||||
$item['ID']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get columns headers
|
||||
*
|
||||
* @param array $item columns header item.
|
||||
* @return array columns.
|
||||
*/
|
||||
public function column_post_title( $item ) {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$edit_post_link = get_edit_post_link( $item['ID'] );
|
||||
|
||||
$post_type_object = get_post_type_object( $this->custom_post_type );
|
||||
$can_edit_post = current_user_can( 'edit_post', $item['ID'] );
|
||||
$actions = array();
|
||||
$title = _draft_or_post_title();
|
||||
|
||||
$post_status = ( ! empty( $_REQUEST['post_status'] ) ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'all';
|
||||
if ( $can_edit_post && 'trash' !== $post_status ) {
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
get_edit_post_link( $item['ID'] ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'Edit “%s”', 'wp-schema-pro' ), $title ) ),
|
||||
__( 'Edit', 'wp-schema-pro' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $item['ID'] ) ) {
|
||||
if ( 'trash' === $post_status ) {
|
||||
$actions['untrash'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $item['ID'] ) ), 'untrash-post_' . $item['ID'] ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'Restore “%s” from the Trash', 'wp-schema-pro' ), $title ) ),
|
||||
__( 'Restore', 'wp-schema-pro' )
|
||||
);
|
||||
} elseif ( EMPTY_TRASH_DAYS ) {
|
||||
$actions['trash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
|
||||
get_delete_post_link( $item['ID'] ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'Move “%s” to the Trash', 'wp-schema-pro' ), $title ) ),
|
||||
_x( 'Trash', 'verb', 'wp-schema-pro' )
|
||||
);
|
||||
}
|
||||
if ( 'trash' === $post_status || ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
|
||||
get_delete_post_link( $item['ID'], '', true ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'Delete “%s” permanently', 'wp-schema-pro' ), $title ) ),
|
||||
__( 'Delete Permanently', 'wp-schema-pro' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_post_type_viewable( $post_type_object ) ) {
|
||||
if ( in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) {
|
||||
if ( $can_edit_post ) {
|
||||
$preview_link = get_preview_post_link( $post );
|
||||
$actions['view'] = sprintf(
|
||||
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
|
||||
esc_url( $preview_link ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'Preview “%s”', 'wp-schema-pro' ), $title ) ),
|
||||
__( 'Preview', 'wp-schema-pro' )
|
||||
);
|
||||
}
|
||||
} elseif ( 'trash' !== $post_status ) {
|
||||
$actions['view'] = sprintf(
|
||||
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
|
||||
get_permalink( $item['ID'] ),
|
||||
/* translators: %s: post title */
|
||||
esc_attr( sprintf( __( 'View “%s”', 'wp-schema-pro' ), $title ) ),
|
||||
__( 'View', 'wp-schema-pro' )
|
||||
);
|
||||
}
|
||||
}
|
||||
global $post;
|
||||
$post = get_post( $item['ID'], OBJECT ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
setup_postdata( $post );
|
||||
|
||||
ob_start();
|
||||
_post_states( $post );
|
||||
$post_states = ob_get_clean();
|
||||
|
||||
$actions = apply_filters( 'post_row_actions', $actions, $post );
|
||||
wp_reset_postdata();
|
||||
if ( 'trash' === $post_status ) {
|
||||
return sprintf( '<strong>%1$s%2$s</strong>%3$s', $item['post_title'], $post_states, $this->row_actions( $actions ) );
|
||||
} else {
|
||||
return sprintf( '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%2$s</a>%3$s</strong>%4$s', $edit_post_link, $item['post_title'], $post_states, $this->row_actions( $actions ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current page number
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return int Current page number
|
||||
*/
|
||||
public function get_paged() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date column
|
||||
*
|
||||
* @param array $post date column.
|
||||
*/
|
||||
public function column_date( $post ) {
|
||||
global $mode;
|
||||
|
||||
$post_id = $post['ID'];
|
||||
|
||||
if ( '0000-00-00 00:00:00' === $post['date'] ) {
|
||||
$t_time = __( 'Unpublished', 'wp-schema-pro' );
|
||||
$h_time = __( 'Unpublished', 'wp-schema-pro' );
|
||||
$time_diff = 0;
|
||||
} else {
|
||||
$t_time = get_the_time( __( 'Y/m/d g:i:s a', 'wp-schema-pro' ) );
|
||||
$m_time = $post['date'];
|
||||
$time = get_post_time( 'G', true, $post );
|
||||
|
||||
$time_diff = time() - $time;
|
||||
|
||||
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
|
||||
/* translators: 1: time */
|
||||
$h_time = sprintf( __( '%s ago', 'wp-schema-pro' ), human_time_diff( $time ) );
|
||||
} else {
|
||||
$h_time = mysql2date( __( 'Y/m/d', 'wp-schema-pro' ), $m_time );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'publish' === get_post_status( $post_id ) ) {
|
||||
$status = __( 'Published', 'wp-schema-pro' );
|
||||
} elseif ( 'future' === get_post_status( $post_id ) ) {
|
||||
if ( $time_diff > 0 ) {
|
||||
$status = '<strong class="error-message">' . __( 'Missed schedule', 'wp-schema-pro' ) . '</strong>';
|
||||
} else {
|
||||
$status = __( 'Scheduled', 'wp-schema-pro' );
|
||||
}
|
||||
} else {
|
||||
$status = __( 'Last Modified', 'wp-schema-pro' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the status text of the post.
|
||||
*
|
||||
* @since 4.8.0
|
||||
*
|
||||
* @param string $status The status text.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param string $column_name The column name.
|
||||
* @param string $mode The list display mode ('excerpt' or 'list').
|
||||
*/
|
||||
$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode );
|
||||
|
||||
if ( $status ) {
|
||||
echo esc_html( $status ) . '<br />';
|
||||
}
|
||||
|
||||
if ( 'excerpt' === $mode ) {
|
||||
/**
|
||||
* Filters the published time of the post.
|
||||
*
|
||||
* If `$mode` equals 'excerpt', the published time and date are both displayed.
|
||||
* If `$mode` equals 'list' (default), the publish date is displayed, with the
|
||||
* time and date together available as an abbreviation definition.
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param string $t_time The published time.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param string $column_name The column name.
|
||||
* @param string $mode The list display mode ('excerpt' or 'list').
|
||||
*/
|
||||
echo esc_html( apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ) );
|
||||
} else {
|
||||
|
||||
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
||||
echo '<abbr title="' . esc_attr( $t_time ) . '">' . esc_html( apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) ) . '</abbr>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the total number of {{custom-post}}
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return int $total Total number of {{custom-post}}
|
||||
*/
|
||||
public function get_total_custom_posts() {
|
||||
$num_posts = wp_count_posts( $this->custom_post_type, 'readable' );
|
||||
$total_posts = array_sum( (array) $num_posts );
|
||||
// Subtract post types that are not included in the admin all list.
|
||||
foreach ( get_post_stati(
|
||||
array(
|
||||
'show_in_admin_all_list' => false,
|
||||
)
|
||||
) as $state ) {
|
||||
$total_posts -= $num_posts->$state;
|
||||
}
|
||||
return $total_posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items.
|
||||
*
|
||||
* @param string $search search string.
|
||||
*/
|
||||
public function prepare_items( $search = '' ) {
|
||||
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
$post_status = ( ! empty( $_REQUEST['post_status'] ) ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'any';
|
||||
$data = array();
|
||||
$args = array(
|
||||
'post_type' => $this->custom_post_type,
|
||||
'posts_per_page' => $this->per_page,
|
||||
'paged' => $this->get_paged(),
|
||||
's' => $search,
|
||||
'post_status' => $post_status,
|
||||
);
|
||||
|
||||
$the_query = new WP_Query( $args );
|
||||
if ( $the_query->have_posts() ) :
|
||||
$key = 0;
|
||||
while ( $the_query->have_posts() ) :
|
||||
$the_query->the_post();
|
||||
$data[ $key ] = array(
|
||||
'ID' => get_the_ID(),
|
||||
'post_title' => get_the_title(),
|
||||
'date' => get_the_date(),
|
||||
);
|
||||
$key++;
|
||||
endwhile;
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
|
||||
$columns = $this->get_columns();
|
||||
|
||||
$hidden = array(); // No hidden columns.
|
||||
|
||||
$sortable = $this->get_sortable_columns();
|
||||
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
|
||||
$this->process_bulk_action();
|
||||
|
||||
usort( $data, array( $this, 'usort_reorder' ) );
|
||||
|
||||
$total_items = $this->get_total_custom_posts();
|
||||
|
||||
$this->items = $data;
|
||||
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $total_items,
|
||||
'per_page' => $this->per_page,
|
||||
'total_pages' => ceil( $total_items / $this->per_page ),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Views.
|
||||
*
|
||||
* @return array list of all views.
|
||||
*/
|
||||
public function get_views() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
$status_links = array();
|
||||
$num_posts = wp_count_posts( $this->custom_post_type, 'readable' );
|
||||
$class = '';
|
||||
$total_posts = array_sum( (array) $num_posts );
|
||||
|
||||
// Subtract post types that are not included in the admin all list.
|
||||
foreach ( get_post_stati(
|
||||
array(
|
||||
'show_in_admin_all_list' => false,
|
||||
)
|
||||
) as $state ) {
|
||||
$total_posts -= $num_posts->$state;
|
||||
}
|
||||
|
||||
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) ? ' class="current"' : '';
|
||||
$query_all_var = remove_query_arg( 'post_status' );
|
||||
/* translators: %s: count */
|
||||
$status_links['all'] = "<a href='" . esc_url( $query_all_var ) . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'wp-schema-pro' ), number_format_i18n( $total_posts ) ) . '</a>';
|
||||
|
||||
foreach ( get_post_stati(
|
||||
array(
|
||||
'show_in_admin_status_list' => true,
|
||||
),
|
||||
'objects'
|
||||
) as $status ) {
|
||||
$class = '';
|
||||
$status_name = $status->name;
|
||||
|
||||
if ( ! in_array( $status_name, array( 'publish', 'draft', 'pending', 'trash', 'future', 'private', 'auto-draft' ), true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( empty( $num_posts->$status_name ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) {
|
||||
$class = ' class="current"';
|
||||
}
|
||||
|
||||
$label = $status->label_count;
|
||||
$query_var = add_query_arg( 'post_status', $status_name );
|
||||
$status_links[ $status_name ] = "<a href='" . esc_url( $query_var ) . "'$class>" . sprintf( translate_nooped_plural( $label, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
|
||||
}
|
||||
|
||||
return $status_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render List Table Markup.
|
||||
*/
|
||||
public function render_markup() {
|
||||
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
|
||||
return;
|
||||
}
|
||||
$this->prepare_items();
|
||||
$post_type = $this->_args['singular'];
|
||||
$post_obj = get_post_type_object( $post_type );
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="wp-heading-inline"><?php echo esc_html( $post_obj->labels->name ); ?></h1>
|
||||
<?php
|
||||
$post_new_file = 'post-new.php?post_type=' . $post_type;
|
||||
|
||||
if ( isset( $post_new_file ) && current_user_can( $post_obj->cap->create_posts ) ) {
|
||||
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_obj->labels->add_new_item ) . '</a>';
|
||||
}
|
||||
// Search results for.
|
||||
$s = isset( $_REQUEST['s'] ) && strlen( sanitize_text_field( $_REQUEST['s'] ) ) ? sanitize_text_field( $_REQUEST['s'] ) : null;
|
||||
if ( $s ) {
|
||||
/* translators: %s: search keywords */
|
||||
printf( '<span class="subtitle">' . esc_html__( 'Search results for “%s”', 'wp-schema-pro' ) . '</span>', esc_html( $s ) );
|
||||
}
|
||||
?>
|
||||
<br><br>
|
||||
<?php
|
||||
// table post views with count.
|
||||
$this->views();
|
||||
?>
|
||||
<form id="<?php echo esc_attr( $post_type ); ?>-filter" method="post">
|
||||
<?php
|
||||
if ( $s ) {
|
||||
$this->prepare_items( $s );
|
||||
} else {
|
||||
$this->prepare_items();
|
||||
}
|
||||
$this->search_box(
|
||||
sprintf(
|
||||
/* translators: %s: Post Label */
|
||||
esc_html__( 'Search %s', 'wp-schema-pro' ),
|
||||
$post_obj->labels->name
|
||||
),
|
||||
'search_id'
|
||||
);
|
||||
$this->display();
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,484 +0,0 @@
|
||||
.select2-container {
|
||||
box-sizing: border-box;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
vertical-align: middle; }
|
||||
.select2-container .select2-selection--single {
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
height: 30px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.select2-container .select2-selection--single .select2-selection__rendered {
|
||||
display: block;
|
||||
padding-left: 8px;
|
||||
padding-right: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap; }
|
||||
.select2-container .select2-selection--single .select2-selection__clear {
|
||||
position: relative; }
|
||||
.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
|
||||
padding-right: 8px;
|
||||
padding-left: 20px; }
|
||||
.select2-container .select2-selection--multiple {
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
min-height: 32px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.select2-container .select2-selection--multiple .select2-selection__rendered {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
padding-left: 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap; }
|
||||
.select2-container .select2-search--inline {
|
||||
float: left; }
|
||||
.select2-container .select2-search--inline .select2-search__field {
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
font-size: 100%;
|
||||
margin-top: 5px;
|
||||
padding: 0; }
|
||||
.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
|
||||
-webkit-appearance: none; }
|
||||
|
||||
.select2-dropdown {
|
||||
background-color: white;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: -100000px;
|
||||
width: 100%;
|
||||
z-index: 1051; }
|
||||
|
||||
.select2-results {
|
||||
display: block; }
|
||||
|
||||
.select2-results__options {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
.select2-results__option {
|
||||
padding: 6px;
|
||||
user-select: none;
|
||||
-webkit-user-select: none; }
|
||||
.select2-results__option[aria-selected] {
|
||||
cursor: pointer; }
|
||||
|
||||
.select2-container--open .select2-dropdown {
|
||||
left: 0; }
|
||||
|
||||
.select2-container--open .select2-dropdown--above {
|
||||
border-bottom: none;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0; }
|
||||
|
||||
.select2-container--open .select2-dropdown--below {
|
||||
border-top: none;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0; }
|
||||
|
||||
.select2-search--dropdown {
|
||||
display: block;
|
||||
padding: 4px; }
|
||||
.select2-search--dropdown .select2-search__field {
|
||||
padding: 4px;
|
||||
width: 100%;
|
||||
box-sizing: border-box; }
|
||||
.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
|
||||
-webkit-appearance: none; }
|
||||
.select2-search--dropdown.select2-search--hide {
|
||||
display: none; }
|
||||
|
||||
.select2-close-mask {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
min-height: 100%;
|
||||
min-width: 100%;
|
||||
height: auto;
|
||||
width: auto;
|
||||
opacity: 0;
|
||||
z-index: 99;
|
||||
background-color: #fff;
|
||||
filter: alpha(opacity=0); }
|
||||
|
||||
.select2-hidden-accessible {
|
||||
border: 0 !important;
|
||||
clip: rect(0 0 0 0) !important;
|
||||
height: 1px !important;
|
||||
margin: -1px !important;
|
||||
overflow: hidden !important;
|
||||
padding: 0 !important;
|
||||
position: absolute !important;
|
||||
width: 1px !important; }
|
||||
|
||||
.select2-container--default .select2-selection--single {
|
||||
background-color: #fff;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px; }
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered {
|
||||
color: #444;
|
||||
line-height: 28px; }
|
||||
.select2-container--default .select2-selection--single .select2-selection__clear {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
font-weight: bold; }
|
||||
.select2-container--default .select2-selection--single .select2-selection__placeholder {
|
||||
color: #999; }
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow {
|
||||
height: 26px;
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
width: 20px; }
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow b {
|
||||
border-color: #888 transparent transparent transparent;
|
||||
border-style: solid;
|
||||
border-width: 5px 4px 0 4px;
|
||||
height: 0;
|
||||
left: 50%;
|
||||
margin-left: -4px;
|
||||
margin-top: -2px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 0; }
|
||||
|
||||
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
|
||||
float: left; }
|
||||
|
||||
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
|
||||
left: 1px;
|
||||
right: auto; }
|
||||
|
||||
.select2-container--default.select2-container--disabled .select2-selection--single {
|
||||
background-color: #eee;
|
||||
cursor: default; }
|
||||
.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
|
||||
display: none; }
|
||||
|
||||
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
|
||||
border-color: transparent transparent #888 transparent;
|
||||
border-width: 0 4px 5px 4px; }
|
||||
|
||||
.select2-container--default .select2-selection--multiple {
|
||||
background-color: white;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
cursor: text; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
||||
box-sizing: border-box;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 5px;
|
||||
width: 100%; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
|
||||
list-style: none; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
float: left; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__clear {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
margin-top: 5px;
|
||||
margin-right: 10px; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
background-color: #e4e4e4;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
cursor: default;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
margin-top: 5px;
|
||||
padding: 0 5px; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin-right: 2px; }
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
|
||||
color: #333; }
|
||||
|
||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
|
||||
float: right; }
|
||||
|
||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
||||
margin-left: 5px;
|
||||
margin-right: auto; }
|
||||
|
||||
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
|
||||
margin-left: 2px;
|
||||
margin-right: auto; }
|
||||
|
||||
.select2-container--default.select2-container--focus .select2-selection--multiple {
|
||||
border: solid black 1px;
|
||||
outline: 0; }
|
||||
|
||||
.select2-container--default.select2-container--disabled .select2-selection--multiple {
|
||||
background-color: #eee;
|
||||
cursor: default; }
|
||||
|
||||
.select2-container--default.select2-container--disabled .select2-selection__choice__remove {
|
||||
display: none; }
|
||||
|
||||
.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0; }
|
||||
|
||||
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0; }
|
||||
|
||||
.select2-container--default .select2-search--dropdown .select2-search__field {
|
||||
border: 1px solid #aaa; }
|
||||
|
||||
.select2-container--default .select2-search--inline .select2-search__field {
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: 0;
|
||||
box-shadow: none;
|
||||
-webkit-appearance: textfield; }
|
||||
|
||||
.select2-container--default .select2-results > .select2-results__options {
|
||||
max-height: 200px;
|
||||
overflow-y: auto; }
|
||||
|
||||
.select2-container--default .select2-results__option[role=group] {
|
||||
padding: 0; }
|
||||
|
||||
.select2-container--default .select2-results__option[aria-disabled=true] {
|
||||
color: #999; }
|
||||
|
||||
.select2-container--default .select2-results__option[aria-selected=true] {
|
||||
background-color: #ddd; }
|
||||
|
||||
.select2-container--default .select2-results__option .select2-results__option {
|
||||
padding-left: 1em; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__group {
|
||||
padding-left: 0; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__option {
|
||||
margin-left: -1em;
|
||||
padding-left: 2em; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
|
||||
margin-left: -2em;
|
||||
padding-left: 3em; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
|
||||
margin-left: -3em;
|
||||
padding-left: 4em; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
|
||||
margin-left: -4em;
|
||||
padding-left: 5em; }
|
||||
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
|
||||
margin-left: -5em;
|
||||
padding-left: 6em; }
|
||||
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected] {
|
||||
background-color: #5897fb;
|
||||
color: white; }
|
||||
|
||||
.select2-container--default .select2-results__group {
|
||||
cursor: default;
|
||||
display: block;
|
||||
padding: 6px; }
|
||||
|
||||
.select2-container--classic .select2-selection--single {
|
||||
background-color: #f7f7f7;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
outline: 0;
|
||||
background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
|
||||
background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
|
||||
background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
|
||||
.select2-container--classic .select2-selection--single:focus {
|
||||
border: 1px solid #5897fb; }
|
||||
.select2-container--classic .select2-selection--single .select2-selection__rendered {
|
||||
color: #444;
|
||||
line-height: 28px; }
|
||||
.select2-container--classic .select2-selection--single .select2-selection__clear {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
margin-right: 10px; }
|
||||
.select2-container--classic .select2-selection--single .select2-selection__placeholder {
|
||||
color: #999; }
|
||||
.select2-container--classic .select2-selection--single .select2-selection__arrow {
|
||||
background-color: #ddd;
|
||||
border: none;
|
||||
border-left: 1px solid #aaa;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
height: 26px;
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
width: 20px;
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
|
||||
background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
|
||||
.select2-container--classic .select2-selection--single .select2-selection__arrow b {
|
||||
border-color: #888 transparent transparent transparent;
|
||||
border-style: solid;
|
||||
border-width: 5px 4px 0 4px;
|
||||
height: 0;
|
||||
left: 50%;
|
||||
margin-left: -4px;
|
||||
margin-top: -2px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 0; }
|
||||
|
||||
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
|
||||
float: left; }
|
||||
|
||||
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
|
||||
border: none;
|
||||
border-right: 1px solid #aaa;
|
||||
border-radius: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
left: 1px;
|
||||
right: auto; }
|
||||
|
||||
.select2-container--classic.select2-container--open .select2-selection--single {
|
||||
border: 1px solid #5897fb; }
|
||||
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
|
||||
background: transparent;
|
||||
border: none; }
|
||||
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
|
||||
border-color: transparent transparent #888 transparent;
|
||||
border-width: 0 4px 5px 4px; }
|
||||
|
||||
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
|
||||
border-top: none;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
|
||||
background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
|
||||
background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
|
||||
|
||||
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
|
||||
border-bottom: none;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
|
||||
background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
|
||||
background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }
|
||||
|
||||
.select2-container--classic .select2-selection--multiple {
|
||||
background-color: white;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
cursor: text;
|
||||
outline: 0; }
|
||||
.select2-container--classic .select2-selection--multiple:focus {
|
||||
border: 1px solid #5897fb; }
|
||||
.select2-container--classic .select2-selection--multiple .select2-selection__rendered {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 5px; }
|
||||
.select2-container--classic .select2-selection--multiple .select2-selection__clear {
|
||||
display: none; }
|
||||
.select2-container--classic .select2-selection--multiple .select2-selection__choice {
|
||||
background-color: #e4e4e4;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
cursor: default;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
margin-top: 5px;
|
||||
padding: 0 5px; }
|
||||
.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
|
||||
color: #888;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin-right: 2px; }
|
||||
.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
|
||||
color: #555; }
|
||||
|
||||
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
||||
float: right; }
|
||||
|
||||
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
|
||||
margin-left: 5px;
|
||||
margin-right: auto; }
|
||||
|
||||
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
|
||||
margin-left: 2px;
|
||||
margin-right: auto; }
|
||||
|
||||
.select2-container--classic.select2-container--open .select2-selection--multiple {
|
||||
border: 1px solid #5897fb; }
|
||||
|
||||
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
|
||||
border-top: none;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0; }
|
||||
|
||||
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
|
||||
border-bottom: none;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0; }
|
||||
|
||||
.select2-container--classic .select2-search--dropdown .select2-search__field {
|
||||
border: 1px solid #aaa;
|
||||
outline: 0; }
|
||||
|
||||
.select2-container--classic .select2-search--inline .select2-search__field {
|
||||
outline: 0;
|
||||
box-shadow: none; }
|
||||
|
||||
.select2-container--classic .select2-dropdown {
|
||||
background-color: white;
|
||||
border: 1px solid transparent; }
|
||||
|
||||
.select2-container--classic .select2-dropdown--above {
|
||||
border-bottom: none; }
|
||||
|
||||
.select2-container--classic .select2-dropdown--below {
|
||||
border-top: none; }
|
||||
|
||||
.select2-container--classic .select2-results > .select2-results__options {
|
||||
max-height: 200px;
|
||||
overflow-y: auto; }
|
||||
|
||||
.select2-container--classic .select2-results__option[role=group] {
|
||||
padding: 0; }
|
||||
|
||||
.select2-container--classic .select2-results__option[aria-disabled=true] {
|
||||
color: grey; }
|
||||
|
||||
.select2-container--classic .select2-results__option--highlighted[aria-selected] {
|
||||
background-color: #3875d7;
|
||||
color: white; }
|
||||
|
||||
.select2-container--classic .select2-results__group {
|
||||
cursor: default;
|
||||
display: block;
|
||||
padding: 6px; }
|
||||
|
||||
.select2-container--classic.select2-container--open .select2-dropdown {
|
||||
border-color: #5897fb; }
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +0,0 @@
|
||||
/* Select2 */
|
||||
span.select2.select2-container.select2-container--default {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
li.select2-results__option.select2-results__message {
|
||||
background: #ecebeb;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
tr td .select2-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.select2-container--default.select2-container--focus .select2-selection--multiple,
|
||||
.select2-container--default .select2-selection--multiple {
|
||||
border: 1px solid #ddd;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.select2-container .select2-search--inline,
|
||||
.select2-container--default .select2-search--inline .select2-search__field {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* Target Rule field */
|
||||
.bsf-target-rule-condition,
|
||||
.bsf-user-role-condition {
|
||||
position: relative;
|
||||
padding: 0 30px 0 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.target_rule-specific-page-wrap {
|
||||
position: relative;
|
||||
padding: 0 30px 0 0;
|
||||
}
|
||||
|
||||
.user_role-add-rule-wrap,
|
||||
.target_rule-add-rule-wrap,
|
||||
.target_rule-add-exclusion-rule,
|
||||
.user_role-add-rule-wrap {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.bsf-target-rule-display-on,
|
||||
.bsf-target-rule-exclude-on {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.target_rule-condition-delete,
|
||||
.user_role-condition-delete {
|
||||
position: absolute;
|
||||
color: #999;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
font-size: 18px;
|
||||
line-height: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.target_rule-condition-delete:hover {
|
||||
color: #d54e21;
|
||||
}
|
||||
|
||||
.target_rule-add-rule-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.target_rule-add-exclusion-rule {
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.configure-content [data-element="exclude_from"],
|
||||
.configure-content [data-element="exclusive_on"] {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.configure-content .bsf-allow-specific-posts input,
|
||||
.configure-content .bsf-post-types {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
.hide-on-devices input[type=checkbox] {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.search-panel.search-close-icon {
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bsf-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
/* eslint-env jquery */
|
||||
(function ($) {
|
||||
const initTargetRuleSelect2 = function (selector) {
|
||||
$(selector).select2({
|
||||
placeholder: 'Search pages / post / archives',
|
||||
|
||||
ajax: {
|
||||
url: ajaxurl,
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
delay: 250,
|
||||
data(params) {
|
||||
return {
|
||||
q: params.term, // search term
|
||||
page: params.page,
|
||||
action: 'bsf_get_posts_by_query',
|
||||
nonce: Targetrule.security,
|
||||
};
|
||||
},
|
||||
processResults(data) {
|
||||
// console.log(data);
|
||||
// console.log("inside");
|
||||
// parse the results into the format expected by Select2.
|
||||
// since we are using custom formatting functions we do not need to
|
||||
// alter the remote JSON data
|
||||
|
||||
return {
|
||||
results: data,
|
||||
};
|
||||
},
|
||||
cache: true,
|
||||
},
|
||||
minimumInputLength: 2,
|
||||
});
|
||||
};
|
||||
|
||||
const updateTargetRuleInput = function (wrapper) {
|
||||
const ruleInput = wrapper.find('.bsf-target_rule-input');
|
||||
const newValue = [];
|
||||
|
||||
wrapper.find('.bsf-target-rule-condition').each(function () {
|
||||
const $this = $(this);
|
||||
let tempObj = {};
|
||||
const ruleCondition = $this.find('select.target_rule-condition');
|
||||
const specificPage = $this.find('select.target_rule-specific-page');
|
||||
|
||||
const ruleConditionVal = ruleCondition.val();
|
||||
const specificPageVal = specificPage.val();
|
||||
|
||||
if ('' !== ruleConditionVal) {
|
||||
tempObj = {
|
||||
type: ruleConditionVal,
|
||||
specific: specificPageVal,
|
||||
};
|
||||
|
||||
newValue.push(tempObj);
|
||||
}
|
||||
});
|
||||
|
||||
const rulesString = JSON.stringify(newValue);
|
||||
ruleInput.val(rulesString);
|
||||
};
|
||||
|
||||
const updateCloseButton = function (wrapper) {
|
||||
const type = wrapper
|
||||
.closest('.bsf-target-rule-wrapper')
|
||||
.attr('data-type');
|
||||
const rules = wrapper.find('.bsf-target-rule-condition');
|
||||
let showClose = false;
|
||||
|
||||
if ('display' === type) {
|
||||
if (rules.length > 1) {
|
||||
showClose = true;
|
||||
}
|
||||
} else {
|
||||
showClose = true;
|
||||
}
|
||||
|
||||
rules.each(function () {
|
||||
if (showClose) {
|
||||
jQuery(this)
|
||||
.find('.target_rule-condition-delete')
|
||||
.removeClass('bsf-hidden');
|
||||
} else {
|
||||
jQuery(this)
|
||||
.find('.target_rule-condition-delete')
|
||||
.addClass('bsf-hidden');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const updateExclusionButton = function (forceShow, forceHide) {
|
||||
const displayOn = $('.bsf-target-rule-display-on-wrap');
|
||||
const excludeOn = $('.bsf-target-rule-exclude-on-wrap');
|
||||
|
||||
const excludeFieldWrap = excludeOn.closest('tr');
|
||||
const addExcludeBlock = displayOn.find(
|
||||
'.target_rule-add-exclusion-rule'
|
||||
);
|
||||
const excludeConditions = excludeOn.find('.bsf-target-rule-condition');
|
||||
|
||||
if (true === forceHide) {
|
||||
excludeFieldWrap.addClass('bsf-hidden');
|
||||
addExcludeBlock.removeClass('bsf-hidden');
|
||||
} else if (true === forceShow) {
|
||||
excludeFieldWrap.removeClass('bsf-hidden');
|
||||
addExcludeBlock.addClass('bsf-hidden');
|
||||
} else if (
|
||||
1 === excludeConditions.length &&
|
||||
'' ===
|
||||
$(excludeConditions[0])
|
||||
.find('select.target_rule-condition')
|
||||
.val()
|
||||
) {
|
||||
excludeFieldWrap.addClass('bsf-hidden');
|
||||
addExcludeBlock.removeClass('bsf-hidden');
|
||||
} else {
|
||||
excludeFieldWrap.removeClass('bsf-hidden');
|
||||
addExcludeBlock.addClass('bsf-hidden');
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
jQuery('.bsf-target-rule-condition').each(function () {
|
||||
const $this = $(this),
|
||||
condition = $this.find('select.target_rule-condition'),
|
||||
conditionVal = condition.val(),
|
||||
specificPage = $this.next('.target_rule-specific-page-wrap');
|
||||
|
||||
if ('specifics' === conditionVal) {
|
||||
specificPage.slideDown(300);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(
|
||||
'.bsf-target-rule-selector-wrapper select.target-rule-select2'
|
||||
).each(function (index, el) {
|
||||
initTargetRuleSelect2(el);
|
||||
});
|
||||
|
||||
jQuery('.bsf-target-rule-selector-wrapper').each(function () {
|
||||
updateCloseButton(jQuery(this));
|
||||
});
|
||||
|
||||
jQuery(document).on(
|
||||
'change',
|
||||
'.bsf-target-rule-condition select.target_rule-condition',
|
||||
function () {
|
||||
const $this = jQuery(this),
|
||||
thisVal = $this.val(),
|
||||
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
|
||||
|
||||
if ('specifics' === thisVal) {
|
||||
$this
|
||||
.closest('.bsf-target-rule-condition')
|
||||
.next('.target_rule-specific-page-wrap')
|
||||
.slideDown(300);
|
||||
} else {
|
||||
$this
|
||||
.closest('.bsf-target-rule-condition')
|
||||
.next('.target_rule-specific-page-wrap')
|
||||
.slideUp(300);
|
||||
}
|
||||
|
||||
updateTargetRuleInput(fieldWrap);
|
||||
}
|
||||
);
|
||||
|
||||
jQuery('.bsf-target-rule-selector-wrapper').on(
|
||||
'change',
|
||||
'.target-rule-select2',
|
||||
function () {
|
||||
const $this = jQuery(this),
|
||||
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
|
||||
|
||||
updateTargetRuleInput(fieldWrap);
|
||||
}
|
||||
);
|
||||
|
||||
jQuery('.bsf-target-rule-selector-wrapper').on(
|
||||
'click',
|
||||
'.target_rule-add-rule-wrap a',
|
||||
function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const $this = jQuery(this),
|
||||
id = $this.attr('data-rule-id'),
|
||||
newId = parseInt(id) + 1,
|
||||
type = $this.attr('data-rule-type'),
|
||||
ruleWrap = $this
|
||||
.closest('.bsf-target-rule-selector-wrapper')
|
||||
.find('.target_rule-builder-wrap'),
|
||||
template = wp.template(
|
||||
'bsf-target-rule-' + type + '-condition'
|
||||
),
|
||||
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
|
||||
|
||||
ruleWrap.append(template({ id: newId, type }));
|
||||
|
||||
initTargetRuleSelect2(
|
||||
'.bsf-target-rule-' + type + '-on .target-rule-select2'
|
||||
);
|
||||
|
||||
$this.attr('data-rule-id', newId);
|
||||
|
||||
updateCloseButton(fieldWrap);
|
||||
}
|
||||
);
|
||||
|
||||
jQuery('.bsf-target-rule-selector-wrapper').on(
|
||||
'click',
|
||||
'.target_rule-condition-delete',
|
||||
function () {
|
||||
const $this = jQuery(this),
|
||||
ruleCondition = $this.closest('.bsf-target-rule-condition'),
|
||||
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
|
||||
let cnt = 0;
|
||||
const dataType = fieldWrap.attr('data-type');
|
||||
if (
|
||||
'exclude' === dataType &&
|
||||
fieldWrap.find('.bsf-target-rule-condition').length === 1
|
||||
) {
|
||||
fieldWrap.find('.target_rule-condition').val('');
|
||||
fieldWrap.find('.target_rule-specific-page').val('');
|
||||
fieldWrap.find('.target_rule-condition').trigger('change');
|
||||
updateExclusionButton(false, true);
|
||||
} else {
|
||||
$this
|
||||
.parent('.bsf-target-rule-condition')
|
||||
.next('.target_rule-specific-page-wrap')
|
||||
.remove();
|
||||
ruleCondition.remove();
|
||||
}
|
||||
|
||||
fieldWrap.find('.bsf-target-rule-condition').each(function (i) {
|
||||
const condition = jQuery(this),
|
||||
oldRuleId = condition.attr('data-rule'),
|
||||
selectLocation = condition.find(
|
||||
'.target_rule-condition'
|
||||
),
|
||||
locationName = selectLocation.attr('name');
|
||||
|
||||
condition.attr('data-rule', i);
|
||||
|
||||
selectLocation.attr(
|
||||
'name',
|
||||
locationName.replace(
|
||||
'[' + oldRuleId + ']',
|
||||
'[' + i + ']'
|
||||
)
|
||||
);
|
||||
|
||||
condition
|
||||
.removeClass('bsf-target-rule-' + oldRuleId)
|
||||
.addClass('bsf-target-rule-' + i);
|
||||
|
||||
cnt = i;
|
||||
});
|
||||
|
||||
fieldWrap
|
||||
.find('.target_rule-add-rule-wrap a')
|
||||
.attr('data-rule-id', cnt);
|
||||
|
||||
updateCloseButton(fieldWrap);
|
||||
updateTargetRuleInput(fieldWrap);
|
||||
}
|
||||
);
|
||||
|
||||
jQuery('.bsf-target-rule-selector-wrapper').on(
|
||||
'click',
|
||||
'.target_rule-add-exclusion-rule a',
|
||||
function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
updateExclusionButton(true);
|
||||
}
|
||||
);
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -1,97 +0,0 @@
|
||||
/* eslint-env jquery */
|
||||
( function ( $ ) {
|
||||
const userRoleUpdateCloseButton = function ( wrapper ) {
|
||||
const rules = wrapper.find( '.bsf-user-role-condition' );
|
||||
let showClose = false;
|
||||
|
||||
if ( rules.length > 1 ) {
|
||||
showClose = true;
|
||||
}
|
||||
|
||||
rules.each( function () {
|
||||
if ( showClose ) {
|
||||
jQuery( this )
|
||||
.find( '.user_role-condition-delete' )
|
||||
.removeClass( 'bsf-hidden' );
|
||||
} else {
|
||||
jQuery( this )
|
||||
.find( '.user_role-condition-delete' )
|
||||
.addClass( 'bsf-hidden' );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
$( document ).ready( function () {
|
||||
jQuery( '.bsf-user-role-selector-wrapper' ).each( function () {
|
||||
userRoleUpdateCloseButton( jQuery( this ) );
|
||||
} );
|
||||
|
||||
jQuery( '.bsf-user-role-selector-wrapper' ).on(
|
||||
'click',
|
||||
'.user_role-add-rule-wrap a',
|
||||
function ( e ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const $this = jQuery( this ),
|
||||
id = $this.attr( 'data-rule-id' ),
|
||||
newId = parseInt( id ) + 1,
|
||||
ruleWrap = $this
|
||||
.closest( '.bsf-user-role-selector-wrapper' )
|
||||
.find( '.user_role-builder-wrap' ),
|
||||
template = wp.template( 'bsf-user-role-condition' ),
|
||||
fieldWrap = $this.closest( '.bsf-user-role-wrapper' );
|
||||
|
||||
ruleWrap.append( template( { id: newId } ) );
|
||||
|
||||
$this.attr( 'data-rule-id', newId );
|
||||
|
||||
userRoleUpdateCloseButton( fieldWrap );
|
||||
}
|
||||
);
|
||||
|
||||
jQuery( '.bsf-user-role-selector-wrapper' ).on(
|
||||
'click',
|
||||
'.user_role-condition-delete',
|
||||
function () {
|
||||
const $this = jQuery( this ),
|
||||
ruleCondition = $this.closest( '.bsf-user-role-condition' ),
|
||||
fieldWrap = $this.closest( '.bsf-user-role-wrapper' );
|
||||
let cnt = 0;
|
||||
ruleCondition.remove();
|
||||
|
||||
fieldWrap
|
||||
.find( '.bsf-user-role-condition' )
|
||||
.each( function ( i ) {
|
||||
const condition = jQuery( this ),
|
||||
oldRuleId = condition.attr( 'data-rule' ),
|
||||
selectLocation = condition.find(
|
||||
'.user_role-condition'
|
||||
),
|
||||
locationName = selectLocation.attr( 'name' );
|
||||
|
||||
condition.attr( 'data-rule', i );
|
||||
|
||||
selectLocation.attr(
|
||||
'name',
|
||||
locationName.replace(
|
||||
'[' + oldRuleId + ']',
|
||||
'[' + i + ']'
|
||||
)
|
||||
);
|
||||
|
||||
condition
|
||||
.removeClass( 'bsf-user-role-' + oldRuleId )
|
||||
.addClass( 'bsf-user-role-' + i );
|
||||
|
||||
cnt = i;
|
||||
} );
|
||||
|
||||
fieldWrap
|
||||
.find( '.user_role-add-rule-wrap a' )
|
||||
.attr( 'data-rule-id', cnt );
|
||||
|
||||
userRoleUpdateCloseButton( fieldWrap );
|
||||
}
|
||||
);
|
||||
} );
|
||||
} )( jQuery );
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Article' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Article {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
if ( isset( $data['schema-type'] ) && ! empty( $data['schema-type'] ) ) {
|
||||
$schema['@type'] = $data['schema-type'];
|
||||
}
|
||||
|
||||
if ( isset( $data['main-entity'] ) && ! empty( $data['main-entity'] ) ) {
|
||||
$schema['mainEntityOfPage']['@type'] = 'WebPage';
|
||||
$schema['mainEntityOfPage']['@id'] = esc_url( $data['main-entity'] );
|
||||
}
|
||||
|
||||
$schema['headline'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
$schema['datePublished'] = ! empty( $data['published-date'] ) ? wp_strip_all_tags( (string) $data['published-date'] ) : null;
|
||||
|
||||
$schema['dateModified'] = ! empty( $data['modified-date'] ) ? wp_strip_all_tags( (string) $data['modified-date'] ) : null;
|
||||
|
||||
if ( ! empty( $data['author'] ) ) {
|
||||
$schema['author']['@type'] = 'Person';
|
||||
$schema['author']['name'] = wp_strip_all_tags( (string) $data['author'] );
|
||||
$schema['author']['url'] = ! empty( $data['author-url'] ) ? wp_strip_all_tags( (string) $data['author-url'] ) : null;
|
||||
}
|
||||
|
||||
if ( ! empty( $data['orgnization-name'] ) ) {
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['name'] = wp_strip_all_tags( (string) $data['orgnization-name'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['site-logo'] ) && ! empty( $data['site-logo'] ) ) {
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['site-logo'], 'ImageObject2' );
|
||||
} else {
|
||||
$logo_id = get_post_thumbnail_id( $post['ID'] );
|
||||
if ( isset( $general_settings['site-logo'] ) && 'custom' === $general_settings['site-logo'] ) {
|
||||
$logo_id = isset( $general_settings['site-logo-custom'] ) ? $general_settings['site-logo-custom'] : '';
|
||||
}
|
||||
if ( $logo_id ) {
|
||||
// Add logo image size.
|
||||
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
|
||||
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
}
|
||||
// Remove logo image size.
|
||||
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
|
||||
}
|
||||
}
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_article', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Book' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Book {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Book';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $data['author'] ) ) {
|
||||
$schema['author']['@type'] = 'Person';
|
||||
$schema['author']['name'] = wp_strip_all_tags( (string) $data['author'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['url'] ) && ! empty( $data['url'] ) ) {
|
||||
$schema['url'] = esc_url( $data['url'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) {
|
||||
$schema['sameAs'] = esc_url( $data['same-as'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['work-example'] ) && ! empty( $data['work-example'] ) ) {
|
||||
foreach ( $data['work-example'] as $key => $value ) {
|
||||
|
||||
$schema['workExample'][ $key ]['@type'] = 'Book';
|
||||
$schema['workExample'][ $key ]['isbn'] = ! empty( $value['serial-number'] ) ? wp_strip_all_tags( (string) $value['serial-number'] ) : null;
|
||||
|
||||
$schema['workExample'][ $key ]['bookEdition'] = ! empty( $value['book-edition'] ) ? wp_strip_all_tags( (string) $value['book-edition'] ) : null;
|
||||
|
||||
$schema['workExample'][ $key ]['bookFormat'] = ! empty( $value['book-format'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string) $value['book-format'] ) : null;
|
||||
|
||||
$schema['workExample'][ $key ]['potentialAction']['@type'] = 'ReadAction';
|
||||
$schema['workExample'][ $key ]['potentialAction']['target']['@type'] = 'EntryPoint';
|
||||
$action_platform = explode( ',', $value['action-platform'] );
|
||||
$action_platform = array_map( 'trim', $action_platform );
|
||||
$schema['workExample'][ $key ]['potentialAction']['target']['urlTemplate'] = $value['url-template'];
|
||||
$schema['workExample'][ $key ]['potentialAction']['target']['actionPlatform'] = $action_platform;
|
||||
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['@type'] = 'Offer';
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['price'] = '0';
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['price'] = ! empty( $value['price'] ) ? wp_strip_all_tags( (string) $value['price'] ) : null;
|
||||
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['priceCurrency'] = ! empty( $value['currency'] ) ? wp_strip_all_tags( (string) $value['currency'] ) : null;
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['availability'] = ! empty( $value['avail'] ) ? wp_strip_all_tags( (string) $value['avail'] ) : null;
|
||||
|
||||
if ( isset( $value['country'] ) && ! empty( $value['country'] ) ) {
|
||||
$expects_acceptance = explode( ',', $value['country'] );
|
||||
$expects_acceptance = array_map( 'trim', $expects_acceptance );
|
||||
|
||||
$expects_acceptances = array();
|
||||
foreach ( $expects_acceptance as $index => $country_name ) {
|
||||
$expects_acceptances[ $index ]['@type'] = 'Country';
|
||||
$expects_acceptances[ $index ]['name'] = $country_name;
|
||||
}
|
||||
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['eligibleRegion'] = $expects_acceptances;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_book', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Course {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Course';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['courseCode'] = ! empty( $data['course-code'] ) ? wp_strip_all_tags( (string) $data['course-code'] ) : null;
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
if (isset($data['offers']) && !empty($data['offers'])) {
|
||||
foreach ($data['offers'] as $offer_key => $offer_value) {
|
||||
if (!empty($offer_value['category']) || !empty($offer_value['priceCurrency']) || !empty($offer_value['price'])) {
|
||||
$schema['offers'][$offer_key]['@type'] = 'Offer';
|
||||
$schema['offers'][$offer_key]['category'] = !empty($offer_value['offer-category']) ? wp_strip_all_tags((string)$offer_value['offer-category']) : null;
|
||||
$schema['offers'][$offer_key]['priceCurrency'] = !empty($offer_value['priceCurrency']) ? wp_strip_all_tags((string)$offer_value['priceCurrency']) : null;
|
||||
$schema['offers'][$offer_key]['price'] = !empty($offer_value['price']) ? wp_strip_all_tags((string)$offer_value['price']) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['course-instance'] ) && ! empty( $data['course-instance'] ) ) {
|
||||
|
||||
foreach ( $data['course-instance'] as $key => $value ) {
|
||||
|
||||
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ||
|
||||
isset( $value['description'] ) && ! empty( $value['description'] ) ||
|
||||
isset( $value['start-date'] ) && ! empty( $value['start-date'] ) ||
|
||||
isset( $value['location-address'] ) && ! empty( $value['location-address'] ) ) {
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['@type'] = 'CourseInstance';
|
||||
$schema['hasCourseInstance'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string) $value['name'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['description'] = ! empty( $value['description'] ) ? wp_strip_all_tags( (string) $value['description'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['courseMode'] = ! empty( $value['course-mode'] ) ? wp_strip_all_tags( (string) $value['course-mode'] ) : null;
|
||||
|
||||
if ( ! empty( $value['course-workload'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['courseWorkload'] = ! empty( $value['course-workload'] ) ? wp_strip_all_tags( (string) $value['course-workload'] ) : null;
|
||||
} elseif ( ! empty( $value['repeat-count'] ) && ! empty( $value['repeat-frequency'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['@type'] = 'Schedule';
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['repeatCount'] = ! empty( $value['repeat-count'] ) ? wp_strip_all_tags( (string) $value['repeat-count'] ) : null;
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['repeatFrequency'] = ! empty( $value['repeat-frequency'] ) ? wp_strip_all_tags( (string) $value['repeat-frequency'] ) : null;
|
||||
if ( ! empty( $value['start-date'] ) ) {
|
||||
if ( 'OfflineEventAttendanceMode' !== isset( $value['event-attendance-mode'] ) ) {
|
||||
$start_date = gmdate( DATE_ISO8601, strtotime( $value['start-date'] ) );
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['startDate'] = wp_strip_all_tags( (string) $start_date );
|
||||
} else {
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['startDate'] = wp_strip_all_tags( (string) $value['start-date'] );
|
||||
}
|
||||
}
|
||||
if ( ! empty( $value['end-date'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['courseSchedule']['endDate'] = ! empty( $value['end-date'] ) ? wp_strip_all_tags( (string) $value['end-date'] ) : null;
|
||||
}
|
||||
}
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['eventStatus'] = ! empty( $value['event-status'] ) ? wp_strip_all_tags( (string) $value['event-status'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['eventAttendanceMode'] = ! empty( $value['event-attendance-mode'] ) ? wp_strip_all_tags( (string) $value['event-attendance-mode'] ) : null;
|
||||
|
||||
if ( ! empty( $value['start-date'] ) ) {
|
||||
if ( 'OfflineEventAttendanceMode' !== isset( $value['event-attendance-mode'] ) ) {
|
||||
$start_date = gmdate( DATE_ISO8601, strtotime( $value['start-date'] ) );
|
||||
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( (string) $start_date );
|
||||
} else {
|
||||
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( (string) $value['start-date'] );
|
||||
}
|
||||
}
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['endDate'] = ! empty( $value['end-date'] ) ? wp_strip_all_tags( (string) $value['end-date'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['previousStartDate'] = ! empty( $value['previous-date'] ) ? wp_strip_all_tags( (string) $value['previous-date'] ) : null;
|
||||
|
||||
if ( isset( $value['online-location'] ) && ! empty( $value['online-location'] ) && 'OfflineEventAttendanceMode' !== $value['event-attendance-mode'] || 'MixedEventAttendanceMode' === $value['event-attendance-mode'] ) {
|
||||
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'VirtualLocation';
|
||||
$schema['hasCourseInstance'][ $key ]['location']['url'] = esc_url( $value['online-location'] );
|
||||
}
|
||||
|
||||
if ( isset( $value['image'] ) && ! empty( $value['image'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['image'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $value['location-name'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] ) {
|
||||
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'Place';
|
||||
$schema['hasCourseInstance'][ $key ]['location']['name'] = wp_strip_all_tags( (string) $value['location-name'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $value['location-address'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] && is_string( $value['location-address'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'Place';
|
||||
$schema['hasCourseInstance'][ $key ]['location']['address'] = wp_strip_all_tags( (string) $value['location-address'] );
|
||||
}
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['organizer']['@type'] = 'Organization';
|
||||
$schema['hasCourseInstance'][ $key ]['organizer']['name'] = ! empty( $value['course-organizer-name'] ) ? wp_strip_all_tags( (string) $value['course-organizer-name'] ) : null;
|
||||
$schema['hasCourseInstance'][ $key ]['organizer']['url'] = ! empty( $value['course-organizer-url'] ) ? wp_strip_all_tags( (string) $value['course-organizer-url'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['@type'] = 'Offer';
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['price'] = '0';
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['price'] = ! empty( $value['price'] ) ? wp_strip_all_tags( (string) $value['price'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['priceCurrency'] = ! empty( $value['currency'] ) ? wp_strip_all_tags( (string) $value['currency'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['url'] = ! empty( $value['url'] ) ? wp_strip_all_tags( (string) $value['url'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['validFrom'] = ! empty( $value['valid-from'] ) ? wp_strip_all_tags( (string) $value['valid-from'] ) : null;
|
||||
|
||||
$schema['hasCourseInstance'][ $key ]['offers']['availability'] = ! empty( $value['avail'] ) ? wp_strip_all_tags( (string) $value['avail'] ) : null;
|
||||
|
||||
if ( ! empty( $value['performer'] ) ) {
|
||||
$schema['hasCourseInstance'][ $key ]['performer']['@type'] = 'Person';
|
||||
$schema['hasCourseInstance'][ $key ]['performer']['name'] = wp_strip_all_tags( (string) $value['performer'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) ||
|
||||
( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) ) {
|
||||
|
||||
$schema['provider']['@type'] = 'Organization';
|
||||
|
||||
$schema['provider']['name'] = ! empty( $data['orgnization-name'] ) ? wp_strip_all_tags( (string) $data['orgnization-name'] ) : null;
|
||||
if ( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) {
|
||||
$schema['provider']['sameAs'] = esc_url( $data['same-as'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string) $data['rating'] ) : null;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( $data['review-count'] ) : null;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_course', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Custom_Markup' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Custom_Markup {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
if ( isset( $data['custom-markup'] ) && ! empty( $data['custom-markup'] ) ) {
|
||||
$schema['custom-markup'] = $data['custom-markup'];
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_article', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Event {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
|
||||
if ( isset( $data['schema-type'] ) && ! empty( $data['schema-type'] ) ) {
|
||||
$schema['@type'] = $data['schema-type'];
|
||||
}
|
||||
|
||||
$schema = self::prepare_basics( $schema, $data );
|
||||
$schema = self::prepare_attendence_mode( $schema, $data );
|
||||
$schema = self::prepare_location_by_attendence_mode( $schema, $data );
|
||||
$schema = self::prepare_dates( $schema, $data );
|
||||
$schema = self::prepare_offer( $schema, $data );
|
||||
$schema = self::prepare_performer( $schema, $data );
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_event', $schema, $data, $post );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare location by attendence mode schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_location_by_attendence_mode( $schema, $data ) {
|
||||
|
||||
if ( 'OnlineEventAttendanceMode' === $data['event-attendance-mode'] ) {
|
||||
$schema = self::prepare_location( $schema, $data, false );
|
||||
} elseif ( 'OfflineEventAttendanceMode' === $data['event-attendance-mode'] ) {
|
||||
$schema = self::prepare_location( $schema, $data, true );
|
||||
} else {
|
||||
$online_location = self::prepare_location( $schema, $data, false );
|
||||
$offline_location = self::prepare_location( $schema, $data, true );
|
||||
$schema['location'] = array( $online_location['location'], $offline_location['location'] );
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare location schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @param boolean $offline offline.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_location( $schema, $data, $offline = true ) {
|
||||
|
||||
if ( $offline ) {
|
||||
if ( ! empty( $data['location'] ) ) {
|
||||
$schema['location']['@type'] = 'Place';
|
||||
$schema['location']['name'] = wp_strip_all_tags( (string) $data['location'] );
|
||||
}
|
||||
|
||||
$schema['location']['@type'] = 'Place';
|
||||
$schema['location']['address']['@type'] = 'PostalAddress';
|
||||
$schema['location']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string) $data['location-street'] ) : null;
|
||||
$schema['location']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string) $data['location-locality'] ) : null;
|
||||
$schema['location']['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string) $data['location-postal'] ) : null;
|
||||
$schema['location']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string) $data['location-region'] ) : null;
|
||||
if ( ! empty( $data['location-country'] ) ) {
|
||||
|
||||
$schema['location']['address']['addressCountry']['@type'] = 'Country';
|
||||
$schema['location']['address']['addressCountry']['name'] = wp_strip_all_tags( (string) $data['location-country'] );
|
||||
}
|
||||
} else {
|
||||
$schema['location']['@type'] = 'VirtualLocation';
|
||||
$schema['location']['url'] = esc_url( $data['online-location'] );
|
||||
}
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Offer schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_offer( $schema, $data ) {
|
||||
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['price'] = '0';
|
||||
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string) $data['price'] ) : null;
|
||||
$schema['offers']['availability'] = ! empty( $data['avail'] ) ? wp_strip_all_tags( (string) $data['avail'] ) : null;
|
||||
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string) $data['currency'] ) : null;
|
||||
$schema['offers']['validFrom'] = ! empty( $data['valid-from'] ) ? wp_strip_all_tags( (string) $data['valid-from'] ) : null;
|
||||
if ( isset( $data['ticket-buy-url'] ) && ! empty( $data['ticket-buy-url'] ) ) {
|
||||
$schema['offers']['url'] = esc_url( $data['ticket-buy-url'] );
|
||||
}
|
||||
|
||||
return $schema;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Performer schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_performer( $schema, $data ) {
|
||||
|
||||
if ( ! empty( $data['performer'] ) ) {
|
||||
$schema['performer']['@type'] = 'Person';
|
||||
$schema['performer']['name'] = wp_strip_all_tags( (string) $data['performer'] );
|
||||
}
|
||||
$schema['organizer']['@type'] = 'Organization';
|
||||
$schema['organizer']['name'] = ! empty( $data['event-organizer-name'] ) ? wp_strip_all_tags( (string) $data['event-organizer-name'] ) : null;
|
||||
$schema['organizer']['url'] = ! empty( $data['event-organizer-url'] ) ? wp_strip_all_tags( (string) $data['event-organizer-url'] ) : null;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare dates schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_dates( $schema, $data ) {
|
||||
|
||||
$start_date = gmdate( DATE_ISO8601, strtotime( $data['start-date'] ) );
|
||||
$end_date = $data['end-date'];
|
||||
if ( 'OnlineEventAttendanceMode' === $data['event-attendance-mode'] && isset( $data['timezone'] ) && 'none' !== $data['timezone'] && '' !== $data['timezone'] ) {
|
||||
$timezone = new DateTimeZone( $data['timezone'] );
|
||||
$date_time = new DateTime( 'now', $timezone );
|
||||
$offset = timezone_offset_get( $timezone, $date_time );
|
||||
$timezone_offset = preg_replace( '/^00:/', '', gmdate( 'h:i', $offset ) );
|
||||
$start_date = substr( $start_date, 0, -4 );
|
||||
$end_date = substr( $end_date, 0, -4 );
|
||||
$start_date .= $timezone_offset;
|
||||
$end_date .= $timezone_offset;
|
||||
}
|
||||
|
||||
$schema['startDate'] = ! empty( $start_date ) ? wp_strip_all_tags( $start_date ) : null;
|
||||
|
||||
$schema['endDate'] = ! empty( $end_date ) ? wp_strip_all_tags( $end_date ) : null;
|
||||
|
||||
$schema['previousStartDate'] = 'EventRescheduled' === $data['event-status'] ? wp_strip_all_tags( (string) $data['previous-date'] ) : null;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare attendence schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_attendence_mode( $schema, $data ) {
|
||||
|
||||
$schema['eventAttendanceMode'] = isset( $data['schema-type'] ) && ! empty( $data['event-attendance-mode'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string) $data['event-attendance-mode'] ) : null;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare basic schema field.
|
||||
*
|
||||
* @param array $schema schema.
|
||||
* @param array $data data.
|
||||
* @return array
|
||||
*/
|
||||
public static function prepare_basics( $schema, $data ) {
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['eventStatus'] = ! empty( $data['event-status'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string) $data['event-status'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_FAQ' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_FAQ {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
global $post; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.VariableRedeclaration
|
||||
$schema = array();
|
||||
if ( isset( $data['question-answer'][0]['question'] ) && ! empty( $data['question-answer'][0]['question'] ) ) {
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'FAQPage';
|
||||
foreach ( $data['question-answer'] as $key => $value ) {
|
||||
if ( isset( $value['question'] ) && ! empty( $value['question'] ) ) {
|
||||
$schema['mainEntity'][ $key ]['@type'] = 'Question';
|
||||
$schema['mainEntity'][ $key ]['name'] = $value['question'];
|
||||
}
|
||||
if ( isset( $value['answer'] ) && ! empty( $value['answer'] ) ) {
|
||||
$schema['mainEntity'][ $key ]['acceptedAnswer']['@type'] = 'Answer';
|
||||
$schema['mainEntity'][ $key ]['acceptedAnswer']['text'] = $value['answer'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return apply_filters( 'wp_schema_pro_schema_faq', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_How_To' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_How_To {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'HowTo';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
$schema['totalTime'] = ! empty( $data['total-time'] ) ? wp_strip_all_tags( (string) $data['total-time'] ) : null;
|
||||
|
||||
if ( isset( $data['supply'] ) && ! empty( $data['supply'] ) ) {
|
||||
|
||||
foreach ( $data['supply'] as $key => $value ) {
|
||||
|
||||
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
|
||||
|
||||
$schema['supply'][ $key ]['@type'] = 'HowToSupply';
|
||||
|
||||
$schema['supply'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string) $value['name'] ) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['tool'] ) && ! empty( $data['tool'] ) ) {
|
||||
|
||||
foreach ( $data['tool'] as $key => $value ) {
|
||||
|
||||
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
|
||||
|
||||
$schema['tool'][ $key ]['@type'] = 'HowToTool';
|
||||
|
||||
$schema['tool'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string) $value['name'] ) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['steps'] ) && ! empty( $data['steps'] ) ) {
|
||||
foreach ( $data['steps'] as $key => $value ) {
|
||||
$schema['step'][ $key ]['@type'] = 'HowToStep';
|
||||
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
|
||||
$schema['step'][ $key ]['name'] = $value['name'];
|
||||
}
|
||||
if ( isset( $value['url'] ) && ! empty( $value['url'] ) ) {
|
||||
$schema['step'][ $key ]['url'] = $value['url'];
|
||||
}
|
||||
if ( isset( $value['description'] ) && ! empty( $value['description'] ) ) {
|
||||
$schema['step'][ $key ]['itemListElement']['@type'] = 'HowToDirection';
|
||||
$schema['step'][ $key ]['itemListElement']['text'] = $value['description'];
|
||||
}
|
||||
$step_image = wp_get_attachment_image_src( $value['image'], 'full' );
|
||||
if ( isset( $value['image'] ) && ! empty( $value['image'] ) ) {
|
||||
$schema['step'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $step_image, 'ImageObject' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_how_to', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Image_License' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Image_License {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
if ( isset( $data['image-license'] ) && ! empty( $data['image-license'] ) ) {
|
||||
foreach ( $data['image-license'] as $key => $value ) {
|
||||
$schema[ $key ]['@context'] = 'https://schema.org';
|
||||
$schema[ $key ]['@type'] = 'ImageObject';
|
||||
if ( isset( $value['content-url'] ) && ! empty( $value['content-url'] ) ) {
|
||||
$schema[ $key ]['contentUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['content-url'], 'URL' );
|
||||
}
|
||||
if ( isset( $value['license'] ) && ! empty( $value['license'] ) ) {
|
||||
$schema[ $key ]['license'] = esc_url( $value['license'] );
|
||||
}
|
||||
if ( isset( $value['acquire-license-Page'] ) && ! empty( $value['acquire-license-Page'] ) ) {
|
||||
$schema[ $key ]['acquireLicensePage'] = esc_url( $value['acquire-license-Page'] );
|
||||
}
|
||||
if ( isset( $value['credit-text'] ) && ! empty( $value['credit-text'] ) ) {
|
||||
$schema[ $key ]['creditText'] = esc_url( $value['credit-text'] );
|
||||
}
|
||||
if ( ! empty( $data['creator-type'] ) ) {
|
||||
$schema['creator']['@type'] = wp_strip_all_tags( (string) $data['creator-type'] );
|
||||
} else {
|
||||
$schema[ $key ]['creator']['@type'] = 'Person';
|
||||
}
|
||||
if ( isset( $value['creator'] ) && ! empty( $value['creator'] ) ) {
|
||||
$schema[ $key ]['creator']['name'] = esc_url( $value['creator'] );
|
||||
}
|
||||
if ( isset( $value['copy-right-notice'] ) && ! empty( $value['copy-right-notice'] ) ) {
|
||||
$schema[ $key ]['copyrightNotice'] = esc_url( $value['copy-right-notice'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_image_license', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Job_Posting' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Job_Posting {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'JobPosting';
|
||||
|
||||
$schema['title'] = ! empty( $data['title'] ) ? wp_strip_all_tags( (string) $data['title'] ) : null;
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? (string) $data['description'] : null;
|
||||
|
||||
$schema['datePosted'] = ! empty( $data['start-date'] ) ? wp_strip_all_tags( (string) $data['start-date'] ) : null;
|
||||
|
||||
$schema['validThrough'] = ! empty( $data['expiry-date'] ) ? wp_strip_all_tags( (string) $data['expiry-date'] ) : null;
|
||||
|
||||
$schema['employmentType'] = ! empty( $data['job-type'] ) ? wp_strip_all_tags( (string) $data['job-type'] ) : null;
|
||||
|
||||
if ( ! empty( $data['education-requirements'] ) && 'none' !== $data['education-requirements'] ) {
|
||||
$schema['educationRequirements']['@type'] = 'EducationalOccupationalCredential';
|
||||
$schema['educationRequirements']['credentialCategory'] = wp_strip_all_tags( (string) $data['education-requirements'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $data['experience-requirements'] ) && 'none' !== $data['experience-requirements'] ) {
|
||||
$schema['experienceRequirements']['@type'] = 'OccupationalExperienceRequirements';
|
||||
$schema['experienceRequirements']['monthsOfExperience'] = wp_strip_all_tags( (string) $data['experience-requirements'] );
|
||||
}
|
||||
|
||||
$schema['industry'] = ! empty( $data['industry'] ) ? wp_strip_all_tags( (string) $data['industry'] ) : null;
|
||||
|
||||
$schema['qualifications'] = ! empty( $data['qualifications'] ) ? wp_strip_all_tags( (string) $data['qualifications'] ) : null;
|
||||
|
||||
$schema['responsibilities'] = ! empty( $data['responsibilities'] ) ? wp_strip_all_tags( (string) $data['responsibilities'] ) : null;
|
||||
|
||||
$schema['skills'] = ! empty( $data['skills'] ) ? wp_strip_all_tags( (string) $data['skills'] ) : null;
|
||||
|
||||
$schema['workHours'] = ! empty( $data['work-hours'] ) ? wp_strip_all_tags( (string) $data['work-hours'] ) : null;
|
||||
|
||||
if ( ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) ||
|
||||
( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) ) {
|
||||
|
||||
$schema['hiringOrganization']['@type'] = 'Organization';
|
||||
|
||||
$schema['hiringOrganization']['name'] = wp_strip_all_tags( (string) $data['orgnization-name'] );
|
||||
if ( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) {
|
||||
$schema['hiringOrganization']['sameAs'] = esc_url( $data['same-as'] );
|
||||
}
|
||||
if ( isset( $data['organization-logo'] ) && ! empty( $data['organization-logo'] ) ) {
|
||||
|
||||
$schema['hiringOrganization']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['organization-logo'], 'ImageObject' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) ||
|
||||
( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) ||
|
||||
( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) ||
|
||||
( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) ||
|
||||
( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) ) {
|
||||
|
||||
$schema['jobLocation']['@type'] = 'Place';
|
||||
$schema['jobLocation']['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['jobLocation']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string) $data['location-street'] ) : null;
|
||||
$schema['jobLocation']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string) $data['location-locality'] ) : null;
|
||||
$schema['jobLocation']['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string) $data['location-postal'] ) : null;
|
||||
$schema['jobLocation']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string) $data['location-region'] ) : null;
|
||||
$schema['jobLocation']['address']['addressCountry'] = ! empty( $data['location-country'] ) ? wp_strip_all_tags( (string) $data['location-country'] ) : null;
|
||||
}
|
||||
|
||||
$schema['jobLocationType'] = ( ! empty( $data['job-location-type'] ) && 'none' !== $data['job-location-type'] ) ? wp_strip_all_tags( (string) $data['job-location-type'] ) : null;
|
||||
|
||||
if ( isset( $data['remote-location'] ) && ! empty( $data['remote-location'] ) ) {
|
||||
foreach ( $data['remote-location'] as $key => $value ) {
|
||||
$schema['applicantLocationRequirements'][ $key ]['@type'] = 'Country';
|
||||
$schema['applicantLocationRequirements'][ $key ]['name'] = wp_strip_all_tags( (string) $value['applicant-location'] );
|
||||
}
|
||||
} else {
|
||||
if ( isset( $data['applicant-location'] ) && ! empty( $data['applicant-location'] ) ) {
|
||||
$schema['applicantLocationRequirements']['@type'] = 'Country';
|
||||
$schema['applicantLocationRequirements']['name'] = wp_strip_all_tags( (string) $data['applicant-location'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['salary-currency'] ) && ! empty( $data['salary-currency'] ) ) {
|
||||
$schema['baseSalary']['@type'] = 'MonetaryAmount';
|
||||
$schema['baseSalary']['currency'] = wp_strip_all_tags( (string) $data['salary-currency'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['salary'] ) && ! empty( $data['salary'] ) ) ||
|
||||
( isset( $data['salary-unit'] ) && ! empty( $data['salary-unit'] ) ) ) {
|
||||
|
||||
$schema['baseSalary']['@type'] = 'MonetaryAmount';
|
||||
$schema['baseSalary']['value']['@type'] = 'QuantitativeValue';
|
||||
|
||||
$schema['baseSalary']['value']['value'] = ! empty( $data['salary'] ) ? wp_strip_all_tags( (string) $data['salary'] ) : null;
|
||||
$schema['baseSalary']['value']['minValue'] = ( ! empty( $data['salary-min-value'] ) && 'none' !== $data['salary-min-value'] ) ? wp_strip_all_tags( (string) $data['salary-min-value'] ) : null;
|
||||
$schema['baseSalary']['value']['maxValue'] = ( ! empty( $data['salary-max-value'] ) && 'none' !== $data['salary-max-value'] ) ? wp_strip_all_tags( (string) $data['salary-max-value'] ) : null;
|
||||
$schema['baseSalary']['value']['unitText'] = ! empty( $data['salary-unit'] ) ? wp_strip_all_tags( (string) $data['salary-unit'] ) : null;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_job_posting', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Local_Business' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Local_Business {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
|
||||
if ( isset( $data['schema-type'] ) && ! empty( $data['schema-type'] ) && 'ProfessionalService' !== $data['schema-type'] ) {
|
||||
$schema['@type'] = $data['schema-type'];
|
||||
} else {
|
||||
$schema['@type'] = 'LocalBusiness';
|
||||
}
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
$schema['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string) $data['telephone'] ) : null;
|
||||
|
||||
$schema['url'] = ! empty( $data['url'] ) ? wp_strip_all_tags( (string) $data['url'] ) : null;
|
||||
|
||||
if ( ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) ||
|
||||
( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) ||
|
||||
( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) ||
|
||||
( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) ||
|
||||
( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) ) {
|
||||
|
||||
$schema['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string) $data['location-street'] ) : null;
|
||||
$schema['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string) $data['location-locality'] ) : null;
|
||||
$schema['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string) $data['location-postal'] ) : null;
|
||||
$schema['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string) $data['location-region'] ) : null;
|
||||
$schema['address']['addressCountry'] = ! empty( $data['location-country'] ) ? wp_strip_all_tags( (string) $data['location-country'] ) : null;
|
||||
}
|
||||
|
||||
if ( ! empty( $data['rating'] ) && ! empty( $data['review-count'] ) && 'none' !== $data['rating'] && 'none' !== $data['review-count'] ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string) $data['rating'] ) : null;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string) $data['review-count'] ) : null;
|
||||
}
|
||||
|
||||
$schema['priceRange'] = ! empty( $data['price-range'] ) ? wp_strip_all_tags( (string) $data['price-range'] ) : null;
|
||||
|
||||
if ( isset( $data['hours-specification'] ) && ! empty( $data['hours-specification'] ) ) {
|
||||
foreach ( $data['hours-specification'] as $key => $value ) {
|
||||
$schema['openingHoursSpecification'][ $key ]['@type'] = 'OpeningHoursSpecification';
|
||||
$days = explode( ',', $value['days'] );
|
||||
$days = array_map( 'trim', $days );
|
||||
$schema['openingHoursSpecification'][ $key ]['dayOfWeek'] = $days;
|
||||
$schema['openingHoursSpecification'][ $key ]['opens'] = $value['opens'];
|
||||
$schema['openingHoursSpecification'][ $key ]['closes'] = $value['closes'];
|
||||
}
|
||||
}
|
||||
if ( isset( $data['geo-latitude'] ) && isset( $data['geo-longitude'] ) ) {
|
||||
$schema['geo']['@type'] = 'GeoCoordinates';
|
||||
$schema['geo']['latitude'] = wp_strip_all_tags( (string) $data['geo-latitude'] );
|
||||
$schema['geo']['longitude'] = wp_strip_all_tags( (string) $data['geo-longitude'] );
|
||||
|
||||
}
|
||||
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
|
||||
$contact_hear = isset( $contact_type['contact-hear'] ) ? $contact_type['contact-hear'] : '';
|
||||
$contact_toll = isset( $contact_type['contact-toll'] ) ? $contact_type['contact-toll'] : '';
|
||||
$contact_point_type = $contact_hear . ' ' . $contact_toll;
|
||||
$contact_point_type = explode( ' ', $contact_point_type );
|
||||
if ( '1' === $contact_type['cp-schema-type'] && true === apply_filters( 'wp_schema_pro_contactpoint_local_business_schema_enabled', true ) && isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
|
||||
$schema['ContactPoint']['@type'] = 'ContactPoint';
|
||||
|
||||
$schema ['ContactPoint']['contactType'] = ! empty( $contact_type['contact-type'] ) ? wp_strip_all_tags( (string) $contact_type['contact-type'] ) : null;
|
||||
$schema ['ContactPoint']['telephone'] = ! empty( $contact_type['telephone'] ) ? wp_strip_all_tags( (string) $contact_type['telephone'] ) : null;
|
||||
if ( isset( $contact_type['url'] ) && ! empty( $contact_type['url'] ) ) {
|
||||
$schema ['ContactPoint']['url'] = esc_url( $contact_type['url'] );
|
||||
}
|
||||
$schema ['ContactPoint']['email'] = ! empty( $contact_type['email'] ) ? wp_strip_all_tags( (string) $contact_type['email'] ) : null;
|
||||
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
|
||||
$language = explode( ',', $contact_type['areaServed'] );
|
||||
foreach ( $language as $key => $value ) {
|
||||
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
foreach ( $contact_point_type as $key => $value ) {
|
||||
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
$schema ['ContactPoint']['availableLanguage'] = ! empty( $contact_type['availableLanguage'] ) ? wp_strip_all_tags( (string) $contact_type['availableLanguage'] ) : null;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_local_business', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Person' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Person {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Person';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
if ( ( isset( $data['street'] ) && ! empty( $data['street'] ) ) ||
|
||||
( isset( $data['locality'] ) && ! empty( $data['locality'] ) ) ||
|
||||
( isset( $data['postal'] ) && ! empty( $data['postal'] ) ) ||
|
||||
( isset( $data['region'] ) && ! empty( $data['region'] ) ) ) {
|
||||
|
||||
$schema['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['address']['addressLocality'] = ! empty( $data['locality'] ) ? wp_strip_all_tags( (string) $data['locality'] ) : null;
|
||||
|
||||
$schema['address']['addressRegion'] = ! empty( $data['region'] ) ? wp_strip_all_tags( (string) $data['region'] ) : null;
|
||||
|
||||
$schema['address']['postalCode'] = ! empty( $data['postal'] ) ? wp_strip_all_tags( (string) $data['postal'] ) : null;
|
||||
|
||||
$schema['address']['streetAddress'] = ! empty( $data['street'] ) ? wp_strip_all_tags( (string) $data['street'] ) : null;
|
||||
}
|
||||
|
||||
$schema['email'] = ! empty( $data['email'] ) ? wp_strip_all_tags( (string) $data['email'] ) : null;
|
||||
|
||||
$schema['gender'] = ! empty( $data['gender'] ) ? wp_strip_all_tags( (string) $data['gender'] ) : null;
|
||||
|
||||
if ( isset( $data['dob'] ) && ! empty( $data['dob'] ) ) {
|
||||
$date_informat = gmdate( 'Y.m.d', strtotime( $data['dob'] ) );
|
||||
$schema['birthDate'] = wp_strip_all_tags( (string) $date_informat );
|
||||
}
|
||||
|
||||
$schema['memberOf'] = ! empty( $data['member'] ) ? wp_strip_all_tags( (string) $data['member'] ) : null;
|
||||
|
||||
$schema['nationality'] = ! empty( $data['nationality'] ) ? wp_strip_all_tags( (string) $data['nationality'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
$schema['jobTitle'] = ! empty( $data['job-title'] ) ? wp_strip_all_tags( (string) $data['job-title'] ) : null;
|
||||
|
||||
$schema['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string) $data['telephone'] ) : null;
|
||||
|
||||
if ( isset( $data['homepage-url'] ) && ! empty( $data['homepage-url'] ) ) {
|
||||
$schema['url'] = esc_url( $data['homepage-url'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['add-url'] ) && ! empty( $data['add-url'] ) ) {
|
||||
foreach ( $data['add-url'] as $key => $value ) {
|
||||
if ( isset( $value['same-as'] ) && ! empty( $value['same-as'] ) ) {
|
||||
$schema['sameAs'][ $key ] = esc_url( $value['same-as'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
|
||||
$contact_hear = isset( $contact_type['contact-hear'] ) ? $contact_type['contact-hear'] : '';
|
||||
$contact_toll = isset( $contact_type['contact-toll'] ) ? $contact_type['contact-toll'] : '';
|
||||
$contact_point_type = $contact_hear . ' ' . $contact_toll;
|
||||
$contact_point_type = explode( ' ', $contact_point_type );
|
||||
if ( '1' === $contact_type['cp-schema-type'] && true === apply_filters( 'wp_schema_pro_contactpoint_person_schema_enabled', true ) && isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
|
||||
$schema['ContactPoint']['@type'] = 'ContactPoint';
|
||||
|
||||
$schema ['ContactPoint']['contactType'] = ! empty( $contact_type['contact-type'] ) ? wp_strip_all_tags( (string) $contact_type['contact-type'] ) : null;
|
||||
$schema ['ContactPoint']['telephone'] = ! empty( $contact_type['telephone'] ) ? wp_strip_all_tags( (string) $contact_type['telephone'] ) : null;
|
||||
if ( isset( $contact_type['url'] ) && ! empty( $contact_type['url'] ) ) {
|
||||
$schema ['ContactPoint']['url'] = esc_url( $contact_type['url'] );
|
||||
}
|
||||
$schema ['ContactPoint']['email'] = ! empty( $contact_type['email'] ) ? wp_strip_all_tags( (string) $contact_type['email'] ) : null;
|
||||
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
|
||||
$language = explode( ',', $contact_type['areaServed'] );
|
||||
if ( is_array( $language )) {
|
||||
foreach ( $language as $key => $value ) {
|
||||
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($contact_point_type)) {
|
||||
foreach ( $contact_point_type as $key => $value ) {
|
||||
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
$schema ['ContactPoint']['availableLanguage'] = ! empty( $contact_type['availableLanguage'] ) ? wp_strip_all_tags( (string) $contact_type['availableLanguage'] ) : null;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_person', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Product' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Product {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Product';
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
$schema['sku'] = ! empty( $data['sku'] ) ? wp_strip_all_tags( (string) $data['sku'] ) : null;
|
||||
$schema['mpn'] = ! empty( $data['mpn'] ) ? wp_strip_all_tags( (string) $data['mpn'] ) : null;
|
||||
if ( ! empty( $data['brand-name'] ) ) {
|
||||
$schema['brand']['@type'] = 'Brand';
|
||||
$schema['brand']['name'] = wp_strip_all_tags( (string) $data['brand-name'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string) $data['rating'] ) : null;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string) $data['review-count'] ) : null;
|
||||
}
|
||||
if ( apply_filters( 'wp_schema_pro_remove_product_offers', true ) ) {
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['price'] = '0';
|
||||
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string) $data['price'] ) : null;
|
||||
$schema['offers']['priceValidUntil'] = ! empty( $data['price-valid-until'] ) ? wp_strip_all_tags( (string) $data['price-valid-until'] ) : null;
|
||||
|
||||
if ( isset( $data['url'] ) && ! empty( $data['url'] ) ) {
|
||||
$schema['offers']['url'] = esc_url( $data['url'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) ||
|
||||
( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) ) {
|
||||
|
||||
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string) $data['currency'] ) : null;
|
||||
$schema['offers']['availability'] = ! empty( $data['avail'] ) ? wp_strip_all_tags( (string) $data['avail'] ) : null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( apply_filters( 'wp_schema_pro_remove_product_reviews', true ) && isset( $data['product-review'] ) && ! empty( $data['product-review'] ) ) {
|
||||
foreach ( $data['product-review'] as $key => $value ) {
|
||||
if ( ( isset( $value['reviewer-name'] ) && ! empty( $value['reviewer-name'] ) ) && ( isset( $value['product-rating'] ) && ! empty( $value['product-rating'] ) ) ) {
|
||||
$schema['review'][ $key ]['@type'] = 'Review';
|
||||
$schema['review'][ $key ]['author']['name'] = wp_strip_all_tags( (string) $value['reviewer-name'] );
|
||||
if ( isset( $value['reviewer-type'] ) && ! empty( $value['reviewer-type'] ) ) {
|
||||
$schema['review'][ $key ]['author']['@type'] = wp_strip_all_tags( (string) $value['reviewer-type'] );
|
||||
} else {
|
||||
$schema['review'][ $key ]['author']['@type'] = 'Person';
|
||||
}
|
||||
|
||||
if ( isset( $value['product-rating'] ) && ! empty( $value['product-rating'] ) ) {
|
||||
$schema['review'][ $key ]['reviewRating']['@type'] = 'Rating';
|
||||
$schema['review'][ $key ]['reviewRating']['ratingValue'] = wp_strip_all_tags( (string) $value['product-rating'] );
|
||||
}
|
||||
|
||||
$schema['review'][ $key ]['reviewBody'] = ! empty( $value['review-body'] ) ? wp_strip_all_tags( (string) $value['review-body'] ) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch woocommerce review.
|
||||
if ( defined( 'WC_VERSION' ) && apply_filters( 'wp_schema_pro_add_woocommerce_review', false ) ) {
|
||||
$comments = get_comments(
|
||||
array(
|
||||
'number' => 5,
|
||||
'post_id' => $post['ID'],
|
||||
'status' => 'approve',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'parent' => 0,
|
||||
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
||||
array(
|
||||
'key' => 'rating',
|
||||
'type' => 'NUMERIC',
|
||||
'compare' => '>',
|
||||
'value' => 0,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( $comments ) {
|
||||
foreach ( $comments as $key => $comment ) {
|
||||
$schema['review'][ $key ]['@type'] = 'Review';
|
||||
$schema['review'][ $key ]['reviewRating']['@type'] = 'Rating';
|
||||
$schema['review'][ $key ]['reviewRating']['ratingValue'] = get_comment_meta( $comment->comment_ID, 'rating', true );
|
||||
$schema['review'][ $key ]['author']['@type'] = 'Person';
|
||||
$schema['review'][ $key ]['author']['name'] = get_comment_author( $comment );
|
||||
$schema['review'][ $key ]['reviewBody'] = get_comment_text( $comment );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_product', $schema, $data, $post );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
class BSF_AIOSRS_Pro_Schema_Recipe {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public static function render( $data, $post ) {
|
||||
// Get timezone string from WordPress settings.
|
||||
$timezone_string = get_option( 'timezone_string' );
|
||||
|
||||
// Check if the timezone string is not empty and is valid before setting it.
|
||||
if ( ! empty( $timezone_string ) && in_array( $timezone_string, timezone_identifiers_list() ) ) {
|
||||
// WordPress calculates offsets from UTC.
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( $timezone_string );
|
||||
} else {
|
||||
// If the timezone string is empty or invalid, set a fallback timezone.
|
||||
date_default_timezone_set( 'UTC' );
|
||||
}
|
||||
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Recipe';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['reviewer-type'] ) && ! empty( $data['reviewer-type'] ) ) {
|
||||
$schema['author']['@type'] = wp_strip_all_tags( (string) $data['reviewer-type'] );
|
||||
} else {
|
||||
$schema['author']['@type'] = 'Person';
|
||||
}
|
||||
$schema['author']['name'] = ! empty( $data['author'] ) ? wp_strip_all_tags( (string) $data['author'] ) : null;
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
$schema['prepTime'] = ! empty( $data['preperation-time'] ) ? wp_strip_all_tags( (string) $data['preperation-time'] ) : null;
|
||||
|
||||
$schema['cookTime'] = ! empty( $data['cook-time'] ) ? wp_strip_all_tags( (string) $data['cook-time'] ) : null;
|
||||
if ( isset( $data['recipe-yield'] ) && ! empty( $data['recipe-yield'] ) ) {
|
||||
$schema['recipeYield'] = esc_html( $data['recipe-yield'] );
|
||||
}
|
||||
$schema['keywords'] = ! empty( $data['recipe-keywords'] ) ? wp_strip_all_tags( (string) $data['recipe-keywords'] ) : null;
|
||||
|
||||
$schema['recipeCategory'] = ! empty( $data['recipe-category'] ) ? wp_strip_all_tags( (string) $data['recipe-category'] ) : null;
|
||||
|
||||
$schema['recipeCuisine'] = ! empty( $data['recipe-cuisine'] ) ? wp_strip_all_tags( (string) $data['recipe-cuisine'] ) : null;
|
||||
|
||||
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string) $data['rating'] ) : null;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string) $data['review-count'] ) : null;
|
||||
}
|
||||
|
||||
if ( isset( $data['nutrition'] ) && ! empty( $data['nutrition'] ) ) {
|
||||
$schema['nutrition']['@type'] = 'NutritionInformation';
|
||||
$schema['nutrition']['calories'] = wp_strip_all_tags( (string) $data['nutrition'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['ingredients'] ) && ! empty( $data['ingredients'] ) ) {
|
||||
$recipe_ingredients = explode( ',', $data['ingredients'] );
|
||||
foreach ( $recipe_ingredients as $key => $value ) {
|
||||
$schema['recipeIngredient'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['recipe-instructions'] ) && ! empty( $data['recipe-instructions'] ) ) {
|
||||
foreach ( $data['recipe-instructions'] as $key => $value ) {
|
||||
|
||||
if ( isset( $value['steps'] ) && ! empty( $value['steps'] ) ) {
|
||||
|
||||
$schema['recipeInstructions'][ $key ]['@type'] = 'HowToStep';
|
||||
$schema['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( (string) $value['steps'] );
|
||||
$schema['recipeInstructions'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string) $value['name'] ) : null;
|
||||
$schema['recipeInstructions'][ $key ]['url'] = ! empty( $value['url'] ) ? wp_strip_all_tags( (string) $value['url'] ) : null;
|
||||
if ( isset( $value['image'] ) && ! empty( $value['image'] ) ) {
|
||||
$schema['recipeInstructions'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['image'], 'URL' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['recipe-video'] ) && ! empty( $data['recipe-video'] ) ) {
|
||||
|
||||
foreach ( $data['recipe-video'] as $key => $value ) {
|
||||
if ( isset( $value['video-name'] ) && ! empty( $value['video-name'] ) ) {
|
||||
$schema['video'][ $key ]['@type'] = 'VideoObject';
|
||||
$schema['video'][ $key ]['name'] = wp_strip_all_tags( (string) $value['video-name'] );
|
||||
$schema['video'][ $key ]['description'] = ! empty( $value['video-desc'] ) ? wp_strip_all_tags( (string) $value['video-desc'] ) : null;
|
||||
if ( isset( $value['video-image'] ) && ! empty( $value['video-image'] ) ) {
|
||||
$schema['video'][ $key ]['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['video-image'], 'URL' );
|
||||
}
|
||||
if ( isset( $value['recipe-video-content-url'] ) && ! empty( $value['recipe-video-content-url'] ) ) {
|
||||
$schema['video'][ $key ]['contentUrl'] = esc_url( $value['recipe-video-content-url'] );
|
||||
}
|
||||
if ( isset( $value['recipe-video-embed-url'] ) && ! empty( $value['recipe-video-embed-url'] ) ) {
|
||||
$schema['video'][ $key ]['embedUrl'] = esc_url( $value['recipe-video-embed-url'] );
|
||||
}
|
||||
$schema['video'][ $key ]['duration'] = ! empty( $value['recipe-video-duration'] ) ? wp_strip_all_tags( (string) $value['recipe-video-duration'] ) : null;
|
||||
|
||||
// Convert uploadDate to DateTime object and set the timezone.
|
||||
$upload_date = new DateTime( $value['recipe-video-upload-date'] );
|
||||
$upload_date->setTimezone( new DateTimeZone( $timezone_string ?: 'UTC' ) );
|
||||
$schema['video'][ $key ]['uploadDate'] = $upload_date->format( 'c' );
|
||||
|
||||
// Use DateTime to handle timezone for 'expires'
|
||||
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) && is_string( $value['recipe-video-expires-date'] ) ) {
|
||||
$expires_date = new DateTime( $value['recipe-video-expires-date'] );
|
||||
$expires_date->setTimezone( new DateTimeZone( $timezone_string ?: 'UTC' ) );
|
||||
$schema['video'][ $key ]['expires'] = $expires_date->format( 'c' );
|
||||
}
|
||||
|
||||
$schema['video'][ $key ]['interactionCount'] = ! empty( $value['recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string) $value['recipe-video-interaction-count'] ) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_recipe', $schema, $data, $post );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Review {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Review';
|
||||
|
||||
/* start Book schema fields */
|
||||
|
||||
$data['schema-type'] = isset( $data['schema-type'] ) ? $data['schema-type'] : '';
|
||||
|
||||
switch ( $data['schema-type'] ) {
|
||||
case 'bsf-aiosrs-book':
|
||||
$schema['itemReviewed']['@type'] = 'Book';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-book-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-book-name'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-book-author'] ) && ! empty( $data['bsf-aiosrs-book-author'] ) ) {
|
||||
$schema['itemReviewed']['author']['@type'] = 'Person';
|
||||
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-book-author'] );
|
||||
$schema['itemReviewed']['author']['sameAs'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-book-same-As'] );
|
||||
|
||||
}
|
||||
$schema['itemReviewed']['isbn'] = ! empty( $data['bsf-aiosrs-book-serial-number'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-book-serial-number'] ) : null;
|
||||
$schema['description'] = ! empty( $data['bsf-aiosrs-book-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-book-description'] ) : null;
|
||||
$book_url = get_permalink( $post['ID'] );
|
||||
if ( isset( $book_url ) && ! empty( $book_url ) ) {
|
||||
$schema['url'] = esc_url( $book_url );
|
||||
}
|
||||
break;
|
||||
case 'bsf-aiosrs-course':
|
||||
$schema['itemReviewed']['@type'] = 'Course';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-course-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-course-name'] ) : null;
|
||||
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-course-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-course-description'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-course-orgnization-name'] ) && ! empty( $data['bsf-aiosrs-course-orgnization-name'] ) ) {
|
||||
$schema['itemReviewed']['provider']['@type'] = 'Organization';
|
||||
$schema['itemReviewed']['provider']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-course-orgnization-name'] );
|
||||
}
|
||||
break;
|
||||
case 'bsf-aiosrs-event':
|
||||
$schema['itemReviewed']['@type'] = 'event';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-event-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-name'] ) : null;
|
||||
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-event-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-description'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-event-image'] ) && ! empty( $data['bsf-aiosrs-event-image'] ) ) {
|
||||
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-event-image'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-event-start-date'] ) && ! empty( $data['bsf-aiosrs-event-start-date'] ) ) {
|
||||
if ( 'OfflineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) {
|
||||
$start_date = gmdate( DATE_ISO8601, strtotime( $data['bsf-aiosrs-event-start-date'] ) );
|
||||
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( (string) $start_date );
|
||||
} else {
|
||||
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-event-start-date'] );
|
||||
}
|
||||
}
|
||||
$schema['itemReviewed']['endDate'] = ! empty( $data['bsf-aiosrs-event-end-date'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-end-date'] ) : null;
|
||||
$schema['itemReviewed']['eventStatus'] = ! empty( $data['bsf-aiosrs-event-event-status'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-event-status'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['eventAttendanceMode'] = ! empty( $data['bsf-aiosrs-event-event-attendance-mode'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-event-attendance-mode'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['previousStartDate'] = ! empty( $data['bsf-aiosrs-event-previous-date'] ) && 'EventRescheduled' === $data['bsf-aiosrs-event-event-status'] ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-previous-date'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-event-online-location'] ) && ! empty( $data['bsf-aiosrs-event-online-location'] ) &&
|
||||
( 'OfflineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) ||
|
||||
( 'MixedEventAttendanceMode' === $data['bsf-aiosrs-event-event-attendance-mode'] ) ) {
|
||||
$schema['itemReviewed']['location']['@type'] = 'VirtualLocation';
|
||||
$schema['itemReviewed']['location']['url'] = esc_url( $data['bsf-aiosrs-event-online-location'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-event-performer'] ) && ! empty( $data['bsf-aiosrs-event-performer'] ) ) {
|
||||
$schema['itemReviewed']['performer']['@type'] = 'Person';
|
||||
$schema['itemReviewed']['performer']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-event-performer'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-event-location'] ) && ! empty( $data['bsf-aiosrs-event-location'] ) && 'OnlineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) {
|
||||
$schema['itemReviewed']['location']['@type'] = 'Place';
|
||||
$schema['itemReviewed']['location']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location'] );
|
||||
}
|
||||
if ( ( ( isset( $data['bsf-aiosrs-event-location-street'] ) && ! empty( $data['bsf-aiosrs-event-location-street'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-location-locality'] ) && ! empty( $data['bsf-aiosrs-event-location-locality'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-location-postal'] ) && ! empty( $data['bsf-aiosrs-event-location-postal'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-location-region'] ) && ! empty( $data['bsf-aiosrs-event-location-region'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-location-country'] ) && ! empty( $data['bsf-aiosrs-event-location-country'] ) ) ) && ( 'OnlineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) ) {
|
||||
$schema['itemReviewed']['location']['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['itemReviewed']['location']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-event-location-street'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location-street'] ) : null;
|
||||
$schema['itemReviewed']['location']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-event-location-locality'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location-locality'] ) : null;
|
||||
$schema['itemReviewed']['location']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-event-location-postal'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location-postal'] ) : null;
|
||||
$schema['itemReviewed']['location']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-event-location-region'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location-region'] ) : null;
|
||||
$schema['itemReviewed']['location']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-event-location-country'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-location-country'] ) : null;
|
||||
}
|
||||
$schema['itemReviewed']['offers']['@type'] = 'Offer';
|
||||
|
||||
if ( ( isset( $data['bsf-aiosrs-event-avail'] ) && ! empty( $data['bsf-aiosrs-event-avail'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-currency'] ) && ! empty( $data['bsf-aiosrs-event-currency'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-valid-from'] ) && ! empty( $data['bsf-aiosrs-event-valid-from'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-ticket-buy-url'] ) && ! empty( $data['bsf-aiosrs-event-ticket-buy-url'] ) ) ) {
|
||||
if ( isset( $data['bsf-aiosrs-event-ticket-buy-url'] ) && ! empty( $data['bsf-aiosrs-event-ticket-buy-url'] ) ) {
|
||||
$schema['itemReviewed']['offers']['url'] = esc_url( $data['bsf-aiosrs-event-ticket-buy-url'] );
|
||||
}
|
||||
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-event-price'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-price'] ) : null;
|
||||
$schema['itemReviewed']['offers']['availability'] = ! empty( $data['bsf-aiosrs-event-avail'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-avail'] ) : null;
|
||||
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-event-currency'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-currency'] ) : null;
|
||||
$schema['itemReviewed']['offers']['validFrom'] = ! empty( $data['bsf-aiosrs-event-valid-from'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-valid-from'] ) : null;
|
||||
}
|
||||
if ( ( isset( $data['bsf-aiosrs-event-event-organizer-name'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-name'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-event-event-organizer-url'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-url'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['organizer']['@type'] = 'Organization';
|
||||
|
||||
$schema['itemReviewed']['organizer']['name'] = ! empty( $data['bsf-aiosrs-event-event-organizer-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-event-event-organizer-name'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-event-event-organizer-url'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-url'] ) ) {
|
||||
$schema['itemReviewed']['organizer']['url'] = esc_url( $data['bsf-aiosrs-event-event-organizer-url'] );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'bsf-aiosrs-local-business':
|
||||
$schema['itemReviewed']['@type'] = 'LocalBusiness';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-local-business-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-name'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-local-business-image'] ) && ! empty( $data['bsf-aiosrs-local-business-image'] ) ) {
|
||||
|
||||
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-local-business-image'] );
|
||||
}
|
||||
$schema['itemReviewed']['telephone'] = ! empty( $data['bsf-aiosrs-local-business-telephone'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-telephone'] ) : null;
|
||||
if ( ( isset( $data['bsf-aiosrs-local-business-location-street'] ) && ! empty( $data['bsf-aiosrs-local-business-location-street'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-local-business-location-locality'] ) && ! empty( $data['bsf-aiosrs-local-business-location-locality'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-local-business-location-postal'] ) && ! empty( $data['bsf-aiosrs-local-business-location-postal'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-local-business-location-region'] ) && ! empty( $data['bsf-aiosrs-local-business-location-region'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-local-business-location-country'] ) && ! empty( $data['bsf-aiosrs-local-business-location-country'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['itemReviewed']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-local-business-location-street'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-location-street'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-local-business-location-locality'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-location-locality'] ) : null;
|
||||
$schema['itemReviewed']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-local-business-location-postal'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-location-postal'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-local-business-location-region'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-location-region'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-local-business-location-country'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-location-country'] ) : null;
|
||||
}
|
||||
$schema['itemReviewed']['priceRange'] = ! empty( $data['bsf-aiosrs-local-business-price-range'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-local-business-price-range'] ) : null;
|
||||
break;
|
||||
case 'bsf-aiosrs-recipe':
|
||||
$schema['itemReviewed']['@type'] = 'Recipe';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-recipe-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-name'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-recipe-image'] ) && ! empty( $data['bsf-aiosrs-recipe-image'] ) ) {
|
||||
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-recipe-image'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-author'] ) && ! empty( $data['bsf-aiosrs-recipe-author'] ) ) {
|
||||
$schema['itemReviewed']['author']['@type'] = 'Person';
|
||||
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-author'] );
|
||||
}
|
||||
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-recipe-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-description'] ) : null;
|
||||
$schema['itemReviewed']['prepTime'] = ! empty( $data['bsf-aiosrs-recipe-preperation-time'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-preperation-time'] ) : null;
|
||||
$schema['itemReviewed']['cookTime'] = ! empty( $data['bsf-aiosrs-recipe-cook-time'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-cook-time'] ) : null;
|
||||
$schema['itemReviewed']['keywords'] = ! empty( $data['bsf-aiosrs-recipe-recipe-keywords'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-keywords'] ) : null;
|
||||
$schema['itemReviewed']['recipeCategory'] = ! empty( $data['bsf-aiosrs-recipe-recipe-category'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-category'] ) : null;
|
||||
$schema['itemReviewed']['recipeCuisine'] = ! empty( $data['bsf-aiosrs-recipe-recipe-cuisine'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-cuisine'] ) : null;
|
||||
if ( ( isset( $data['bsf-aiosrs-recipe-rating'] ) && ! empty( $data['bsf-aiosrs-recipe-rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
|
||||
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-recipe-rating'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-rating'] ) : null;
|
||||
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-recipe-review-count'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-review-count'] ) : null;
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-nutrition'] ) && ! empty( $data['bsf-aiosrs-recipe-nutrition'] ) ) {
|
||||
$schema['itemReviewed']['nutrition']['@type'] = 'NutritionInformation';
|
||||
$schema['itemReviewed']['nutrition']['calories'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-nutrition'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-ingredients'] ) && ! empty( $data['bsf-aiosrs-recipe-ingredients'] ) ) {
|
||||
$recipe_ingredients = explode( ',', $data['bsf-aiosrs-recipe-ingredients'] );
|
||||
foreach ( $recipe_ingredients as $key => $value ) {
|
||||
$schema['itemReviewed']['recipeIngredient'][ $key ] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-recipe-instructions'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-instructions'] ) ) {
|
||||
$recipe_instructions = explode( ',', $data['bsf-aiosrs-recipe-recipe-instructions'] );
|
||||
foreach ( $recipe_instructions as $key => $value ) {
|
||||
if ( isset( $value ) && ! empty( $value ) ) {
|
||||
$schema['itemReviewed']['recipeInstructions'][ $key ]['@type'] = 'HowToStep';
|
||||
$schema['itemReviewed']['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( (string) $value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['bsf-aiosrs-recipe-video-name'] ) && ! empty( $data['bsf-aiosrs-recipe-video-name'] ) ) {
|
||||
$schema['itemReviewed']['video']['@type'] = 'VideoObject';
|
||||
$schema['itemReviewed']['video']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-video-name'] );
|
||||
$schema['itemReviewed']['video']['description'] = ! empty( $data['bsf-aiosrs-recipe-video-desc'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-video-desc'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-recipe-video-image'] ) && ! empty( $data['bsf-aiosrs-recipe-video-image'] ) ) {
|
||||
$schema['itemReviewed']['video']['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-recipe-video-image'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-content-url'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-content-url'] ) ) {
|
||||
$schema['itemReviewed']['video']['contentUrl'] = esc_url( $data['bsf-aiosrs-recipe-recipe-video-content-url'] );
|
||||
}
|
||||
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] ) ) {
|
||||
$schema['itemReviewed']['video']['embedUrl'] = esc_url( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] );
|
||||
}
|
||||
$schema['itemReviewed']['video']['duration'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-duration'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-video-duration'] ) : null;
|
||||
$schema['itemReviewed']['video']['uploadDate'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) : null;
|
||||
$schema['itemReviewed']['video']['interactionCount'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) : null;
|
||||
$schema['itemReviewed']['video']['expires'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) : null;
|
||||
}
|
||||
break;
|
||||
case 'bsf-aiosrs-software-application':
|
||||
$schema['itemReviewed']['@type'] = 'SoftwareApplication';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-software-application-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-name'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['operatingSystem'] = ! empty( $data['bsf-aiosrs-software-application-operating-system'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-operating-system'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['applicationCategory'] = ! empty( $data['bsf-aiosrs-software-application-category'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-category'] ) : null;
|
||||
|
||||
if ( ( isset( $data['bsf-aiosrs-software-application-rating'] ) && ! empty( $data['bsf-aiosrs-software-application-rating'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-software-application-review-count'] ) && ! empty( $data['bsf-aiosrs-software-application-review-count'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-software-application-rating'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-rating'] ) : null;
|
||||
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-software-application-review-count'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-review-count'] ) : null;
|
||||
}
|
||||
if ( true === apply_filters( 'wp_schema_pro_remove_software_application_offers_review_type', true ) ) {
|
||||
$schema['itemReviewed']['offers']['@type'] = 'Offer';
|
||||
$schema['itemReviewed']['offers']['price'] = '0';
|
||||
|
||||
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-software-application-price'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-price'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-software-application-currency'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-software-application-currency'] ) : null;
|
||||
}
|
||||
break;
|
||||
case 'bsf-aiosrs-product':
|
||||
$schema['itemReviewed']['@type'] = 'product';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-product-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-name'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-product-image'] ) && ! empty( $data['bsf-aiosrs-product-image'] ) ) {
|
||||
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-product-image'] );
|
||||
}
|
||||
|
||||
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-product-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-description'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['sku'] = ! empty( $data['bsf-aiosrs-product-sku'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-sku'] ) : null;
|
||||
$schema['itemReviewed']['mpn'] = ! empty( $data['bsf-aiosrs-product-mpn'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-mpn'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-product-brand-name'] ) && ! empty( $data['bsf-aiosrs-product-brand-name'] ) ) {
|
||||
$schema['itemReviewed']['brand']['@type'] = 'Organization';
|
||||
$schema['itemReviewed']['brand']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-product-brand-name'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['bsf-aiosrs-product-rating'] ) && ! empty( $data['bsf-aiosrs-product-rating'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-product-review-count'] ) && ! empty( $data['bsf-aiosrs-product-review-count'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-product-rating'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-rating'] ) : null;
|
||||
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-product-review-count'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-review-count'] ) : null;
|
||||
}
|
||||
if ( apply_filters( 'wp_schema_pro_remove_product_offers', true ) ) {
|
||||
$schema['itemReviewed']['offers']['@type'] = 'Offer';
|
||||
$schema['itemReviewed']['offers']['price'] = '0';
|
||||
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-product-price'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-price'] ) : null;
|
||||
$schema['itemReviewed']['offers']['priceValidUntil'] = ! empty( $data['bsf-aiosrs-product-price-valid-until'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-price-valid-until'] ) : null;
|
||||
|
||||
$schema['itemReviewed']['offers']['url'] = get_permalink( $post['ID'] );
|
||||
|
||||
if ( ( isset( $data['bsf-aiosrs-product-currency'] ) && ! empty( $data['bsf-aiosrs-product-currency'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-product-avail'] ) && ! empty( $data['bsf-aiosrs-product-avail'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-product-currency'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-currency'] ) : null;
|
||||
$schema['itemReviewed']['offers']['availability'] = ! empty( $data['bsf-aiosrs-product-avail'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-product-avail'] ) : null;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'bsf-aiosrs-movie':
|
||||
$schema['itemReviewed']['@type'] = 'Movie';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-movie-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-movie-name'] ) : null;
|
||||
$schema['itemReviewed']['sameAs'] = ! empty( $data['bsf-aiosrs-movie-same-As'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-movie-same-As'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-movie-image'] ) && ! empty( $data['bsf-aiosrs-movie-image'] ) ) {
|
||||
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-movie-image'] );
|
||||
}
|
||||
$schema['itemReviewed']['dateCreated'] = ! empty( $data['bsf-aiosrs-movie-dateCreated'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-movie-dateCreated'] ) : null;
|
||||
if ( isset( $data['bsf-aiosrs-movie-director-name'] ) && ! empty( $data['bsf-aiosrs-movie-director-name'] ) ) {
|
||||
$schema['itemReviewed']['director']['@type'] = 'Person';
|
||||
$schema['itemReviewed']['director']['name'] = wp_strip_all_tags( (string) $data['bsf-aiosrs-movie-director-name'] );
|
||||
}
|
||||
$schema['description'] = ! empty( $data['bsf-aiosrs-movie-description'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-movie-description'] ) : null;
|
||||
|
||||
break;
|
||||
case 'bsf-aiosrs-organization':
|
||||
$schema['itemReviewed']['@type'] = 'Organization';
|
||||
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-organization-name'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-name'] ) : null;
|
||||
if ( ( isset( $data['bsf-aiosrs-organization-location-street'] ) && ! empty( $data['bsf-aiosrs-organization-location-street'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-organization-location-locality'] ) && ! empty( $data['bsf-aiosrs-organization-location-locality'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-organization-location-postal'] ) && ! empty( $data['bsf-aiosrs-organization-location-postal'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-organization-location-region'] ) && ! empty( $data['bsf-aiosrs-organization-location-region'] ) ) ||
|
||||
( isset( $data['bsf-aiosrs-organization-location-country'] ) && ! empty( $data['bsf-aiosrs-organization-location-country'] ) ) ) {
|
||||
|
||||
$schema['itemReviewed']['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['itemReviewed']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-organization-location-street'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-location-street'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-organization-location-locality'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-location-locality'] ) : null;
|
||||
$schema['itemReviewed']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-organization-location-postal'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-location-postal'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-organization-location-region'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-location-region'] ) : null;
|
||||
$schema['itemReviewed']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-organization-location-country'] ) ? wp_strip_all_tags( (string) $data['bsf-aiosrs-organization-location-country'] ) : null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/*Review schema fields*/
|
||||
|
||||
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
|
||||
$schema['reviewRating']['@type'] = 'Rating';
|
||||
$schema['reviewRating']['ratingValue'] = wp_strip_all_tags( (string) $data['rating'] );
|
||||
}
|
||||
$schema['reviewBody'] = ! empty( $data['review-body'] ) ? wp_strip_all_tags( (string) $data['review-body'] ) : null;
|
||||
$schema['datePublished'] = ! empty( $data['date'] ) ? wp_strip_all_tags( (string) $data['date'] ) : null;
|
||||
$schema['author']['@type'] = ! empty( $data['reviewer-type'] ) ? wp_strip_all_tags( (string) $data['reviewer-type'] ) : 'Person';
|
||||
if ( isset( $data['reviewer-name'] ) && ! empty( $data['reviewer-name'] ) ) {
|
||||
$schema['author']['name'] = wp_strip_all_tags( (string) $data['reviewer-name'] );
|
||||
$author_data = get_userdata( $post['post_author'] );
|
||||
$author_name = ( isset( $author_data->user_nicename ) ) ? $author_data->user_nicename : '';
|
||||
$author_url = get_author_posts_url( $post['ID'] );
|
||||
$final_url = $author_url . '' . $author_name;
|
||||
$is_available = true;
|
||||
$schema['author']['sameAs'] = esc_url( $final_url );
|
||||
}
|
||||
if ( isset( $data['publisher-name'] ) && ! empty( $data['publisher-name'] ) ) {
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['name'] = wp_strip_all_tags( (string) $data['publisher-name'] );
|
||||
$prg_url_value = get_bloginfo( 'url' );
|
||||
$schema['publisher']['sameAs'] = esc_url( $prg_url_value );
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_review', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Service' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Service {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Service';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['serviceType'] = ! empty( $data['type'] ) ? wp_strip_all_tags( (string) $data['type'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['provider'] ) && ! empty( $data['provider'] ) ) ||
|
||||
( isset( $data['location-image'] ) && ! empty( $data['location-image'] ) ) ||
|
||||
( isset( $data['telephone'] ) && ! empty( $data['telephone'] ) ) ||
|
||||
( isset( $data['price-range'] ) && ! empty( $data['price-range'] ) ) ) {
|
||||
|
||||
$schema['provider']['@type'] = 'LocalBusiness';
|
||||
|
||||
$schema['provider']['name'] = ! empty( $data['provider'] ) ? wp_strip_all_tags( (string) $data['provider'] ) : null;
|
||||
if ( isset( $data['location-image'] ) && ! empty( $data['location-image'] ) ) {
|
||||
$schema['provider']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['location-image'] );
|
||||
}
|
||||
$schema['provider']['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string) $data['telephone'] ) : null;
|
||||
$schema['provider']['priceRange'] = ! empty( $data['price-range'] ) ? wp_strip_all_tags( (string) $data['price-range'] ) : null;
|
||||
}
|
||||
|
||||
if ( ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) ||
|
||||
( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) ||
|
||||
( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) ) {
|
||||
|
||||
$schema['provider']['@type'] = 'LocalBusiness';
|
||||
$schema['provider']['address']['@type'] = 'PostalAddress';
|
||||
|
||||
$schema['provider']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string) $data['location-locality'] ) : null;
|
||||
$schema['provider']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string) $data['location-region'] ) : null;
|
||||
$schema['provider']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string) $data['location-street'] ) : null;
|
||||
}
|
||||
|
||||
if ( isset( $data['area'] ) && ! empty( $data['area'] ) ) {
|
||||
$schema['areaServed']['@type'] = 'State';
|
||||
$schema['areaServed']['name'] = wp_strip_all_tags( (string) $data['area'] );
|
||||
}
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_service', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Software_Application' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Software_Application {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'SoftwareApplication';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['operatingSystem'] = ! empty( $data['operating-system'] ) ? wp_strip_all_tags( (string) $data['operating-system'] ) : null;
|
||||
|
||||
$schema['applicationCategory'] = ! empty( $data['category'] ) ? wp_strip_all_tags( (string) $data['category'] ) : null;
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
|
||||
}
|
||||
|
||||
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
|
||||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
|
||||
|
||||
$schema['aggregateRating']['@type'] = 'AggregateRating';
|
||||
|
||||
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string) $data['rating'] ) : null;
|
||||
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string) $data['review-count'] ) : null;
|
||||
}
|
||||
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['price'] = '0';
|
||||
|
||||
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string) $data['price'] ) : null;
|
||||
|
||||
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string) $data['currency'] ) : null;
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_software_application', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Video_Object {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $data Meta Data.
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $data, $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'VideoObject';
|
||||
|
||||
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string) $data['name'] ) : null;
|
||||
|
||||
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string) $data['description'] ) : null;
|
||||
|
||||
if ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) {
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['name'] = wp_strip_all_tags( (string) $data['orgnization-name'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['site-logo'] ) && ! empty( $data['site-logo'] ) ) {
|
||||
$schema['publisher']['@type'] = 'Organization';
|
||||
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['site-logo'], 'ImageObject' );
|
||||
}
|
||||
|
||||
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
|
||||
$schema['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'], 'URL' );
|
||||
}
|
||||
|
||||
$schema['uploadDate'] = ! empty( $data['upload-date'] ) ? wp_strip_all_tags( (string) $data['upload-date'] ) : null;
|
||||
|
||||
$schema['duration'] = ! empty( $data['duration'] ) ? wp_strip_all_tags( (string) $data['duration'] ) : null;
|
||||
|
||||
if ( isset( $data['content-url'] ) && ! empty( $data['content-url'] ) ) {
|
||||
$schema['contentUrl'] = esc_url( $data['content-url'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['embed-url'] ) && ! empty( $data['embed-url'] ) ) {
|
||||
$schema['embedUrl'] = esc_url( $data['embed-url'] );
|
||||
}
|
||||
|
||||
$schema['expires'] = ! empty( $data['expires-date'] ) ? wp_strip_all_tags( (string) $data['expires-date'] ) : null;
|
||||
|
||||
if ( isset( $data['interaction-count'] ) && ! empty( $data['interaction-count'] ) ) {
|
||||
$schema['interactionStatistic']['@type'] = 'InteractionCounter';
|
||||
$schema['interactionStatistic']['interactionType']['@type'] = 'WatchAction';
|
||||
$schema['interactionStatistic']['userInteractionCount'] = wp_strip_all_tags( (string) $data['interaction-count'] );
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $data['thumbnail-url'] ) && ! empty( $data['thumbnail-url'] ) ) {
|
||||
$schema['thumbnailUrl'] = $data['thumbnail-url'];
|
||||
}
|
||||
|
||||
if ( isset( $data['clip'] ) && ! empty( $data['clip'] ) ) {
|
||||
foreach ( $data['clip'] as $key => $value ) {
|
||||
$schema['hasPart'][$key]['@type'] = 'Clip';
|
||||
$schema['hasPart'][$key]['name'] = wp_strip_all_tags( (string) $value['clip-name'] );
|
||||
$schema['hasPart'][$key]['startOffset'] = wp_strip_all_tags( (string) $value['clip-start-offset'] );
|
||||
$schema['hasPart'][$key]['endOffset'] = wp_strip_all_tags( (string) $value['clip-end-offset'] );
|
||||
$schema['hasPart'][$key]['url'] = esc_url( $value['clip-url'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['seekto-action-start-offset'] ) && ! empty( $data['seekto-action-start-offset'] ) && isset( $data['content-url'] ) ) {
|
||||
$schema['potentialAction']['@type'] = 'SeekToAction';
|
||||
$schema['potentialAction']['target'] = esc_url( $data['seekto-action-target'] ) . '?t={seek_to_second_number}';
|
||||
$schema['potentialAction']['startOffset-input'] = 'required name=seek_to_second_number';
|
||||
}
|
||||
|
||||
if ( isset( $data['regions-allowed'] ) && ! empty( $data['regions-allowed'] ) ) {
|
||||
$schema['regionsAllowed'] = wp_strip_all_tags( (string) $data['regions-allowed'] );
|
||||
}
|
||||
|
||||
if ( isset( $data['is-live-broadcast'] ) && $data['is-live-broadcast'] ) {
|
||||
$schema['publication']['@type'] = 'BroadcastEvent';
|
||||
$schema['publication']['isLiveBroadcast'] = true;
|
||||
$schema['publication']['startDate'] = ! empty( $data['start-date'] ) ? wp_strip_all_tags( (string) $data['start-date'] ) : null;
|
||||
$schema['publication']['endDate'] = ! empty( $data['end-date'] ) ? wp_strip_all_tags( (string) $data['end-date'] ) : null;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_schema_video_object', $schema, $data, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_About_Page' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_About_Page {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'AboutPage';
|
||||
|
||||
$schema['mainEntityOfPage']['@type'] = 'WebPage';
|
||||
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
|
||||
|
||||
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
|
||||
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
|
||||
|
||||
$image_id = get_post_thumbnail_id( $post['ID'] );
|
||||
if ( ! empty( $image_id ) ) {
|
||||
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
|
||||
}
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
|
||||
$settings['site-represent'] = 'person';
|
||||
}
|
||||
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
|
||||
$settings['site-represent'] = 'organization';
|
||||
}
|
||||
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
|
||||
if ( 'organization' === $settings['site-represent'] ) {
|
||||
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
} else {
|
||||
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
}
|
||||
|
||||
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
|
||||
|
||||
if ( 'organization' === $settings['site-represent'] ) {
|
||||
$logo_id = get_theme_mod( 'custom_logo' );
|
||||
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
|
||||
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
|
||||
}
|
||||
if ( $logo_id ) {
|
||||
// Add logo image size.
|
||||
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
|
||||
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
}
|
||||
// Remove logo image size.
|
||||
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_about_page', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Breadcrumb' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Breadcrumb {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'BreadcrumbList';
|
||||
|
||||
$breadcrumb_list = BSF_AIOSRS_Pro_Schema_Template::get_breadcrumb_list();
|
||||
foreach ( $breadcrumb_list as $key => $breadcrumb ) {
|
||||
$schema['itemListElement'][ $key ]['@type'] = 'ListItem';
|
||||
$schema['itemListElement'][ $key ]['position'] = $key + 1;
|
||||
$schema['itemListElement'][ $key ]['item']['@id'] = esc_url( $breadcrumb['url'] );
|
||||
$schema['itemListElement'][ $key ]['item']['name'] = $breadcrumb['title'];
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_breadcrumb', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Contact_Page' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Contact_Page {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'ContactPage';
|
||||
|
||||
$schema['mainEntityOfPage']['@type'] = 'WebPage';
|
||||
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
|
||||
|
||||
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
|
||||
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
|
||||
|
||||
$image_id = get_post_thumbnail_id( $post['ID'] );
|
||||
if ( ! empty( $image_id ) ) {
|
||||
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
|
||||
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
|
||||
}
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
|
||||
$settings['site-represent'] = 'person';
|
||||
}
|
||||
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
|
||||
$settings['site-represent'] = 'organization';
|
||||
}
|
||||
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
|
||||
if ( 'organization' === $settings['site-represent'] ) {
|
||||
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
} else {
|
||||
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
}
|
||||
|
||||
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
|
||||
|
||||
if ( 'organization' === $settings['site-represent'] ) {
|
||||
$logo_id = get_theme_mod( 'custom_logo' );
|
||||
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
|
||||
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
|
||||
}
|
||||
if ( $logo_id ) {
|
||||
// Add logo image size.
|
||||
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
|
||||
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
|
||||
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
|
||||
}
|
||||
// Remove logo image size.
|
||||
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
|
||||
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_contact_page', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Organization' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Organization {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
|
||||
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
|
||||
$contact_hear = isset( $contact_type['contact-hear'] ) ? $contact_type['contact-hear'] : '';
|
||||
$contact_toll = isset( $contact_type['contact-toll'] ) ? $contact_type['contact-toll'] : '';
|
||||
$contactpoint = array( $contact_hear, $contact_toll );
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = ( isset( $general_settings['organization'] ) && ! empty( $general_settings['organization'] ) ) ? $general_settings['organization'] : 'organization';
|
||||
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
|
||||
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
|
||||
$schema['ContactPoint']['@type'] = 'ContactPoint';
|
||||
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
|
||||
if ( 'other' === $contact_type['contact-type'] ) {
|
||||
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
|
||||
} else {
|
||||
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
|
||||
}
|
||||
}
|
||||
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
|
||||
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
|
||||
}
|
||||
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
|
||||
$page_url = get_permalink( $contact_type['contact-page-id'] );
|
||||
$schema ['ContactPoint']['url'] = $page_url;
|
||||
} else {
|
||||
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
|
||||
}
|
||||
if ( isset( $contact_type['email'] ) && ! empty( $contact_type['email'] ) ) {
|
||||
$schema ['ContactPoint']['email'] = $contact_type['email'];
|
||||
}
|
||||
if ( isset( $contactpoint ) && ! empty( $contactpoint ) ) {
|
||||
|
||||
$schema ['ContactPoint']['contactOption'] = $contactpoint;
|
||||
}
|
||||
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
|
||||
$language = explode( ',', $contact_type['areaServed'] );
|
||||
foreach ( $language as $key => $value ) {
|
||||
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( $value );
|
||||
}
|
||||
}
|
||||
if ( isset( $contact_type['availableLanguage'] ) && ! empty( $contact_type['availableLanguage'] ) ) {
|
||||
$language = explode( ',', $contact_type['availableLanguage'] );
|
||||
foreach ( $language as $key => $value ) {
|
||||
$schema ['ContactPoint']['availableLanguage'][ $key ] = wp_strip_all_tags( $value );
|
||||
}
|
||||
} else {
|
||||
$schema ['ContactPoint']['availableLanguage'] = 'English';
|
||||
}
|
||||
}
|
||||
|
||||
$logo_id = get_post_thumbnail_id( $post['ID'] );
|
||||
if ( isset( $general_settings['site-logo-custom'] ) ) {
|
||||
$logo_id = isset( $general_settings['site-logo-custom'] ) ? $general_settings['site-logo-custom'] : '';
|
||||
} elseif ( isset( $general_settings['site-logo'] ) && 'customizer-logo' === $general_settings['site-logo'] ) {
|
||||
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
|
||||
$logo_id = get_theme_mod( 'custom_logo' );
|
||||
}
|
||||
}
|
||||
if ( $logo_id ) {
|
||||
$key = 'site-logo';
|
||||
$logo_image = BSF_AIOSRS_Pro_Schema_Template::get_image_object( $logo_id, $key );
|
||||
$schema['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
|
||||
}
|
||||
|
||||
foreach ( $social_profiles as $type => $social_link ) {
|
||||
if ( 'other' === $type && is_array( $social_link ) ) {
|
||||
foreach ( $social_link as $dynamic_social_link ) {
|
||||
if ( ! empty( $dynamic_social_link ) ) {
|
||||
$schema['sameAs'][] = $dynamic_social_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! empty( $social_link ) && ! is_array( $social_link ) ) {
|
||||
|
||||
$schema['sameAs'][] = $social_link;
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_organization', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Person' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Person {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
|
||||
$schema = array();
|
||||
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
|
||||
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'Person';
|
||||
$schema['name'] = ( isset( $general_settings['person-name'] ) && ! empty( $general_settings['person-name'] ) ) ? $general_settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
|
||||
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
|
||||
$schema['ContactPoint']['@type'] = 'ContactPoint';
|
||||
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
|
||||
if ( 'other' === $contact_type['contact-type'] ) {
|
||||
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
|
||||
} else {
|
||||
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
|
||||
}
|
||||
}
|
||||
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
|
||||
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
|
||||
}
|
||||
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
|
||||
$page_url = get_permalink( $contact_type['contact-page-id'] );
|
||||
$schema ['ContactPoint']['url'] = $page_url;
|
||||
} else {
|
||||
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $social_profiles ) ) {
|
||||
foreach ( $social_profiles as $type => $social_link ) {
|
||||
if ( 'other' === $type && is_array( $social_link ) ) {
|
||||
foreach ( $social_link as $dynamic_social_link ) {
|
||||
if ( ! empty( $dynamic_social_link ) ) {
|
||||
$schema['sameAs'][] = $dynamic_social_link;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
|
||||
$schema['sameAs'][] = $social_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_person', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
|
||||
$names = array();
|
||||
$urls = array();
|
||||
|
||||
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
|
||||
if ( isset( $settings['site-navigation-element'] ) && ! empty( $settings['site-navigation-element'] ) ) {
|
||||
$navigation_links = wp_get_nav_menu_items( $settings['site-navigation-element'] );
|
||||
|
||||
if ( $navigation_links ) {
|
||||
foreach ( $navigation_links as $link ) {
|
||||
$names[] = wp_strip_all_tags( $link->title );
|
||||
$urls[] = esc_url( $link->url );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert normal array into associative array
|
||||
*/
|
||||
$combine_array = array_combine( $names, $urls );
|
||||
$new_arr[] = array();
|
||||
$j = 0;
|
||||
foreach ( $combine_array as $key => $value ) {
|
||||
$new_arr[ $j ]['name'] = $key;
|
||||
$new_arr[ $j ]['url'] = $value;
|
||||
$j++;
|
||||
}
|
||||
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
|
||||
if ( isset( $new_arr ) && ! empty( $new_arr ) ) {
|
||||
foreach ( $new_arr as $key2 => $value2 ) {
|
||||
$schema['@graph'][ $key2 ]['@context'] = 'https://schema.org';
|
||||
$schema['@graph'][ $key2 ]['@type'] = 'SiteNavigationElement';
|
||||
$schema['@graph'][ $key2 ]['id'] = 'site-navigation';
|
||||
$schema['@graph'][ $key2 ]['name'] = isset( $value2['name'] ) ? $value2['name'] : '';
|
||||
$schema['@graph'][ $key2 ]['url'] = isset( $value2['url'] ) ? $value2['url'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_site_navigation_element', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Schemas Template.
|
||||
*
|
||||
* @package Schema Pro
|
||||
* @since 1.1.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box' ) ) {
|
||||
|
||||
/**
|
||||
* AIOSRS Schemas Initialization
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
class BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box {
|
||||
|
||||
/**
|
||||
* Render Schema.
|
||||
*
|
||||
* @param array $post Current Post Array.
|
||||
* @return array
|
||||
*/
|
||||
public static function render( $post ) {
|
||||
$schema = array();
|
||||
|
||||
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
|
||||
$schema['@context'] = 'https://schema.org';
|
||||
$schema['@type'] = 'WebSite';
|
||||
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
|
||||
$schema['url'] = home_url();
|
||||
|
||||
$potential_action = array();
|
||||
|
||||
$template_urls = apply_filters( 'wp_schema_pro_sitelink_srearch_box_template_urls', array( site_url( '?s=' ) ) );
|
||||
foreach ( $template_urls as $template_url ) {
|
||||
$potential_action[] = array(
|
||||
'@type' => 'SearchAction',
|
||||
'target' => esc_url( $template_url ) . '{search_term_string}',
|
||||
'query-input' => 'required name=search_term_string',
|
||||
);
|
||||
}
|
||||
|
||||
$schema['potentialAction'] = $potential_action;
|
||||
|
||||
return apply_filters( 'wp_schema_pro_global_schema_sitelink_search_box', $schema, $post );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user