plugin updates
This commit is contained in:
@@ -1,197 +1,197 @@
|
||||
<?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;
|
||||
<?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
File diff suppressed because it is too large
Load Diff
@@ -1,92 +1,92 @@
|
||||
<?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();
|
||||
<?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,477 +1,477 @@
|
||||
<?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 {
|
||||
|
||||
/**
|
||||
* 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' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->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' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$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;
|
||||
<?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 {
|
||||
|
||||
/**
|
||||
* 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' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->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' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,484 +1,484 @@
|
||||
.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; }
|
||||
.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 +1,103 @@
|
||||
/* 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;
|
||||
}
|
||||
/* 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 +1,279 @@
|
||||
/* 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);
|
||||
/* 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 +1,97 @@
|
||||
/* 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 );
|
||||
/* 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,160 +1,160 @@
|
||||
<?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;
|
||||
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['category'] = ! empty( $data['offer-category'] ) ? wp_strip_all_tags( (string) $data['offer-category'] ) : 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 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<?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;
|
||||
|
||||
$schema['offers']['@type'] = 'Offer';
|
||||
$schema['offers']['category'] = ! empty( $data['offer-category'] ) ? wp_strip_all_tags( (string) $data['offer-category'] ) : 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,210 +1,210 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?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 +1,47 @@
|
||||
<?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 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<?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 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user