plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,168 +0,0 @@
<?php
/**
* Schema Pro Admin Helper.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Admin_Helper' ) ) {
/**
* Class BSF_SP_Admin_Helper.
*/
final class BSF_SP_Admin_Helper {
/**
* Member Variable
*
* @since 0.0.1
* @var instance
*/
private static $instance;
/**
* Initiator
*
* @since 0.0.1
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Returns an option from the database for
* the admin settings page.
*
* @param string $key The option key.
* @param mixed $default Option default value if option is not available.
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
* @return string Return the option value
* @since 0.0.1
*/
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
// Get the site-wide option if we're in the network admin.
if ( $network_override && is_multisite() ) {
$value = get_site_option( $key, $default );
} else {
$value = get_option( $key, $default );
}
return $value;
}
/**
* Provide Widget settings.
*
* @return array()
* @since 0.0.1
*/
public static function get_block_options() {
$blocks = BSF_SP_Helper::$block_list;
$saved_blocks = self::get_admin_settings_option( '_wpsp_blocks' );
if ( is_array( $blocks ) ) {
foreach ( $blocks as $slug => $data ) {
$_slug = str_replace( 'wpsp/', '', $slug );
if ( isset( $saved_blocks[ $_slug ] ) ) {
if ( 'disabled' === $saved_blocks[ $_slug ] ) {
$blocks[ $slug ]['is_activate'] = false;
} else {
$blocks[ $slug ]['is_activate'] = true;
}
} else {
$blocks[ $slug ]['is_activate'] = ( isset( $data['default'] ) ) ? $data['default'] : false;
}
}
}
BSF_SP_Helper::$block_list = $blocks;
return apply_filters( 'wpsp_enabled_blocks', BSF_SP_Helper::$block_list );
}
/**
* Updates an option from the admin settings page.
*
* @param string $key The option key.
* @param mixed $value The value to update.
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
* @return mixed
* @since 0.0.1
*/
public static function update_admin_settings_option( $key, $value, $network = false ) {
// Update the site-wide option since we're in the network admin.
if ( $network && is_multisite() ) {
update_site_option( $key, $value );
} else {
update_option( $key, $value );
}
}
/**
* Get Specific Stylesheet
*
* @since 1.13.4
*/
public static function create_specific_stylesheet() {
$saved_blocks = self::get_admin_settings_option( '_wpsp_blocks' );
$combined = array();
$is_already_faq = false;
foreach ( BSF_SP_Config::$block_attributes as $key => $block ) {
$block_name = str_replace( 'wpsp/', '', $key );
if ( isset( $saved_blocks[ $block_name ] ) && 'disabled' === $saved_blocks[ $block_name ] ) {
continue;
}
switch ( $block_name ) {
case 'faq-child':
case 'faq':
if ( ! $is_already_faq ) {
$combined[] = 'faq';
$combined[] = 'faq-child';
$is_already_faq = true;
}
break;
default:
$combined[] = $block_name;
break;
}
}
$combined_path = plugin_dir_path( BSF_AIOSRS_PRO_FILE ) . 'dist/style-blocks.css';
wp_delete_file( $combined_path );
$style = '';
$wp_filesystem = BSF_SP_Helper::get_instance()->get_filesystem();
foreach ( $combined as $key => $c_block ) {
$style .= $wp_filesystem->get_contents( plugin_dir_path( BSF_AIOSRS_PRO_FILE ) . 'wpsp-blocks/assets/css/blocks/' . $c_block . '.css' );
}
$wp_filesystem->put_contents( $combined_path, $style, FS_CHMOD_FILE );
}
}
/**
* Prepare if class 'WPSP_Admin_Helper' exist.
* Kicking this off by calling 'get_instance()' method
*/
BSF_SP_Admin_Helper::get_instance();
}

View File

@@ -1,169 +0,0 @@
<?php
/**
* Schema Pro Admin.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Admin' ) ) {
/**
* Class BSF_SP_Admin.
*/
final class BSF_SP_Admin {
/**
* Calls on initialization
*
* @since 0.0.1
*/
public static function init() {
if ( ! is_admin() ) {
return;
}
self::wpsp_initialize_ajax();
add_action( 'wpsp_render_admin_content', __CLASS__ . '::render_content' );
// Activation hook.
add_action( 'admin_init', __CLASS__ . '::wpsp_activation_redirect' );
}
/**
* Activation Reset
*/
public static function wpsp_activation_redirect() {
$do_redirect = apply_filters( 'wpsp_enable_redirect_activation', get_option( '__wpsp_do_redirect' ) );
if ( $do_redirect ) {
update_option( '__wpsp_do_redirect', false );
if ( ! is_multisite() ) {
wp_safe_redirect( esc_url( admin_url( 'options-general.php?page=' . SP_SLUG ) ) );
exit();
}
}
}
/**
* Initialize Ajax
*/
public static function wpsp_initialize_ajax() {
// if ( ! current_user_can( 'manage_options' ) ) {
// return;
// }
// Ajax requests.
add_action( 'wp_ajax_wpsp_activate_widget', __CLASS__ . '::wpsp_activate_widget' );
add_action( 'wp_ajax_wpsp_deactivate_widget', __CLASS__ . '::wpsp_deactivate_widget' );
add_action( 'wp_ajax_wpsp_bulk_activate_widgets', __CLASS__ . '::wpsp_bulk_activate_widgets' );
add_action( 'wp_ajax_wpsp_bulk_deactivate_widgets', __CLASS__ . '::wpsp_bulk_deactivate_widgets' );
}
/**
* Activate module
*/
public static function wpsp_activate_widget() {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
check_ajax_referer( 'wpsp-block-nonce', 'nonce' );
$block_id = isset( $_POST['block_id'] ) ? sanitize_text_field( $_POST['block_id'] ) : '';
$blocks = BSF_SP_Admin_Helper::get_admin_settings_option( '_wpsp_blocks', array() );
$blocks[ $block_id ] = $block_id;
$blocks = array_map( 'esc_attr', $blocks );
// Update blocks.
BSF_SP_Admin_Helper::update_admin_settings_option( '_wpsp_blocks', $blocks );
BSF_SP_Admin_Helper::create_specific_stylesheet();
wp_send_json_success();
}
/**
* Deactivate module
*/
public static function wpsp_deactivate_widget() {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
check_ajax_referer( 'wpsp-block-nonce', 'nonce' );
$block_id = isset( $_POST['block_id'] ) ? sanitize_text_field( $_POST['block_id'] ) : '';
$blocks = BSF_SP_Admin_Helper::get_admin_settings_option( '_wpsp_blocks', array() );
$blocks[ $block_id ] = 'disabled';
$blocks = array_map( 'esc_attr', $blocks );
// Update blocks.
BSF_SP_Admin_Helper::update_admin_settings_option( '_wpsp_blocks', $blocks );
BSF_SP_Admin_Helper::create_specific_stylesheet();
wp_send_json_success();
}
/**
* Activate all module
*/
public static function wpsp_bulk_activate_widgets() {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
check_ajax_referer( 'wpsp-block-nonce', 'nonce' );
// Get all widgets.
$all_blocks = BSF_SP_Helper::$block_list;
$new_blocks = array();
// Set all extension to enabled.
foreach ( $all_blocks as $slug => $value ) {
$_slug = str_replace( 'wpsp/', '', $slug );
$new_blocks[ $_slug ] = $_slug;
}
// Escape attrs.
$new_blocks = array_map( 'esc_attr', $new_blocks );
// Update new_extensions.
BSF_SP_Admin_Helper::update_admin_settings_option( '_wpsp_blocks', $new_blocks );
BSF_SP_Admin_Helper::create_specific_stylesheet();
wp_send_json_success();
}
/**
* Deactivate all module
*/
public static function wpsp_bulk_deactivate_widgets() {
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
check_ajax_referer( 'wpsp-block-nonce', 'nonce' );
// Get all extensions.
$old_blocks = BSF_SP_Helper::$block_list;
$new_blocks = array();
// Set all extension to enabled.
foreach ( $old_blocks as $slug => $value ) {
$_slug = str_replace( 'wpsp/', '', $slug );
$new_blocks[ $_slug ] = 'disabled';
}
// Escape attrs.
$new_blocks = array_map( 'esc_attr', $new_blocks );
// Update new_extensions.
BSF_SP_Admin_Helper::update_admin_settings_option( '_wpsp_blocks', $new_blocks );
BSF_SP_Admin_Helper::create_specific_stylesheet();
wp_send_json_success();
}
}
BSF_SP_Admin::init();
}

View File

@@ -1,548 +0,0 @@
<?php
/**
* Schema Pro Blocks Helper.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Block_Helper' ) ) {
/**
* Class BSF_SP_Block_Helper.
*/
final class BSF_SP_Block_Helper {
/**
* Get FAQ CSS.
*
* @since 2.2.0
* @param array $attr The block attributes.
* @param string $id The selector ID.
*/
public static function get_faq_css( $attr, $id ) {
$defaults = BSF_SP_Helper::$block_list['wpsp/faq']['attributes'];
$attr = array_merge( $defaults, $attr );
$icon_color = $attr['iconColor'];
$icon_active_color = $attr['iconActiveColor'];
$attr['questionBottomPaddingDesktop'] = ( 10 === $attr['questionBottomPaddingDesktop'] && 10 !== $attr['vquestionPaddingDesktop'] ) ? $attr['vquestionPaddingDesktop'] : $attr['questionBottomPaddingDesktop'];
$attr['questionLeftPaddingDesktop'] = ( 10 === $attr['questionLeftPaddingDesktop'] && 10 !== $attr['hquestionPaddingDesktop'] ) ? $attr['hquestionPaddingDesktop'] : $attr['questionLeftPaddingDesktop'];
$attr['questionBottomPaddingTablet'] = ( 10 === $attr['questionBottomPaddingTablet'] && 10 !== $attr['vquestionPaddingTablet'] ) ? $attr['vquestionPaddingTablet'] : $attr['questionBottomPaddingTablet'];
$attr['questionLeftPaddingTablet'] = ( 10 === $attr['questionLeftPaddingTablet'] && 10 !== $attr['hquestionPaddingTablet'] ) ? $attr['hquestionPaddingTablet'] : $attr['questionLeftPaddingTablet'];
$attr['questionBottomPaddingMobile'] = ( 10 === $attr['questionBottomPaddingMobile'] && 10 !== $attr['vquestionPaddingMobile'] ) ? $attr['vquestionPaddingMobile'] : $attr['questionBottomPaddingMobile'];
$attr['questionLeftPaddingMobile'] = ( 10 === $attr['questionLeftPaddingMobile'] && 10 !== $attr['hquestionPaddingMobile'] ) ? $attr['hquestionPaddingMobile'] : $attr['questionLeftPaddingMobile'];
if ( ! isset( $attr['iconColor'] ) || '' === $attr['iconColor'] ) {
$icon_color = $attr['questionTextColor'];
}
if ( ! isset( $attr['iconActiveColor'] ) || '' === $attr['iconActiveColor'] ) {
$icon_active_color = $attr['questionTextActiveColor'];
}
$icon_size = BSF_SP_Helper::get_css_value( $attr['iconSize'], $attr['iconSizeType'] );
$t_icon_size = BSF_SP_Helper::get_css_value( $attr['iconSizeTablet'], $attr['iconSizeType'] );
$m_icon_size = BSF_SP_Helper::get_css_value( $attr['iconSizeMobile'], $attr['iconSizeType'] );
$selectors = array(
' .wpsp-icon svg' => array(
'width' => $icon_size,
'height' => $icon_size,
'font-size' => $icon_size,
'fill' => $icon_color,
),
' .wpsp-icon-active svg' => array(
'width' => $icon_size,
'height' => $icon_size,
'font-size' => $icon_size,
'fill' => $icon_active_color,
),
' .wpsp-faq-child__outer-wrap' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['rowsGap'], 'px' ),
),
' .wpsp-faq-item' => array(
'background-color' => $attr['boxBgColor'],
'border-style' => $attr['borderStyle'],
'border-width' => BSF_SP_Helper::get_css_value( $attr['borderWidth'], 'px' ),
'border-radius' => BSF_SP_Helper::get_css_value( $attr['borderRadius'], 'px' ),
'border-color' => $attr['borderColor'],
),
' .wpsp-faq-item .wpsp-question' => array(
'color' => $attr['questionTextColor'],
),
' .wpsp-faq-item.wpsp-faq-item-active .wpsp-question' => array(
'color' => $attr['questionTextActiveColor'],
),
' .wpsp-faq-item:hover .wpsp-question' => array(
'color' => $attr['questionTextActiveColor'],
),
' .wpsp-faq-questions-button' => array(
'padding-top' => BSF_SP_Helper::get_css_value( $attr['vquestionPaddingDesktop'], $attr['questionPaddingTypeDesktop'] ),
'padding-bottom' => BSF_SP_Helper::get_css_value( $attr['questionBottomPaddingDesktop'], $attr['questionPaddingTypeDesktop'] ),
'padding-right' => BSF_SP_Helper::get_css_value( $attr['hquestionPaddingDesktop'], $attr['questionPaddingTypeDesktop'] ),
'padding-left' => BSF_SP_Helper::get_css_value( $attr['questionLeftPaddingDesktop'], $attr['questionPaddingTypeDesktop'] ),
),
' .wpsp-faq-content span' => array(
'margin-top' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingDesktop'], $attr['answerPaddingTypeDesktop'] ),
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingDesktop'], $attr['answerPaddingTypeDesktop'] ),
'margin-right' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingDesktop'], $attr['answerPaddingTypeDesktop'] ),
'margin-left' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingDesktop'], $attr['answerPaddingTypeDesktop'] ),
),
'.wpsp-faq-icon-row .wpsp-faq-item .wpsp-faq-icon-wrap' => array(
'margin-right' => BSF_SP_Helper::get_css_value( $attr['gapBtwIconQUestion'], 'px' ),
),
'.wpsp-faq-icon-row-reverse .wpsp-faq-item .wpsp-faq-icon-wrap' => array(
'margin-left' => BSF_SP_Helper::get_css_value( $attr['gapBtwIconQUestion'], 'px' ),
),
' .wpsp-faq-item:hover .wpsp-icon svg' => array(
'fill' => $icon_active_color,
),
' .wpsp-faq-item .wpsp-faq-questions-button.wpsp-faq-questions' => array(
'flex-direction' => $attr['iconAlign'],
),
' .wpsp-faq-item .wpsp-faq-content p' => array(
'color' => $attr['answerTextColor'],
),
);
$t_selectors = array(
' .wpsp-faq-questions-button' => array(
'padding-top' => BSF_SP_Helper::get_css_value( $attr['vquestionPaddingTablet'], $attr['questionPaddingTypeDesktop'] ),
'padding-bottom' => BSF_SP_Helper::get_css_value( $attr['questionBottomPaddingTablet'], $attr['questionPaddingTypeDesktop'] ),
'padding-right' => BSF_SP_Helper::get_css_value( $attr['hquestionPaddingTablet'], $attr['questionPaddingTypeDesktop'] ),
'padding-left' => BSF_SP_Helper::get_css_value( $attr['questionLeftPaddingTablet'], $attr['questionPaddingTypeDesktop'] ),
),
' .wpsp-faq-content span' => array(
'margin-top' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingTablet'], $attr['answerPaddingTypeDesktop'] ),
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingTablet'], $attr['answerPaddingTypeDesktop'] ),
'margin-right' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingTablet'], $attr['answerPaddingTypeDesktop'] ),
'margin-left' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingTablet'], $attr['answerPaddingTypeDesktop'] ),
),
' .wpsp-icon svg' => array(
'width' => $t_icon_size,
'height' => $t_icon_size,
'font-size' => $t_icon_size,
),
' .wpsp-icon-active svg' => array(
'width' => $t_icon_size,
'height' => $t_icon_size,
'font-size' => $t_icon_size,
),
);
$m_selectors = array(
' .wpsp-faq-questions-button' => array(
'padding-top' => BSF_SP_Helper::get_css_value( $attr['vquestionPaddingMobile'], $attr['questionPaddingTypeDesktop'] ),
'padding-bottom' => BSF_SP_Helper::get_css_value( $attr['questionBottomPaddingMobile'], $attr['questionPaddingTypeDesktop'] ),
'padding-right' => BSF_SP_Helper::get_css_value( $attr['hquestionPaddingMobile'], $attr['questionPaddingTypeDesktop'] ),
'padding-left' => BSF_SP_Helper::get_css_value( $attr['questionLeftPaddingMobile'], $attr['questionPaddingTypeDesktop'] ),
),
' .wpsp-faq-content span' => array(
'margin-top' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingMobile'], $attr['answerPaddingTypeDesktop'] ),
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['vanswerPaddingMobile'], $attr['answerPaddingTypeDesktop'] ),
'margin-right' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingMobile'], $attr['answerPaddingTypeDesktop'] ),
'margin-left' => BSF_SP_Helper::get_css_value( $attr['hanswerPaddingMobile'], $attr['answerPaddingTypeDesktop'] ),
),
' .wpsp-icon svg' => array(
'width' => $m_icon_size,
'height' => $m_icon_size,
'font-size' => $m_icon_size,
),
' .wpsp-icon-active svg' => array(
'width' => $m_icon_size,
'height' => $m_icon_size,
'font-size' => $m_icon_size,
),
);
if ( 'accordion' === $attr['layout'] && true === $attr['inactiveOtherItems'] ) {
$selectors[' .wp-block-wpsp-faq-child.wpsp-faq-child__outer-wrap .wpsp-faq-content '] = array(
'display' => 'none',
);
}
if ( 'accordion' === $attr['layout'] && true === $attr['expandFirstItem'] ) {
$selectors[' .wpsp-faq__wrap.wpsp-buttons-layout-wrap > .wpsp-faq-child__outer-wrap:first-child > .wpsp-faq-child__wrapper .wpsp-faq-item.wpsp-faq-item-active .wpsp-faq-content '] = array(
'display' => 'block',
);
}
if ( true === $attr['enableSeparator'] ) {
$selectors[' .wpsp-faq-child__outer-wrap .wpsp-faq-content '] = array(
'border-style' => 'solid',
'border-top-color' => $attr['borderColor'],
'border-top-width' => BSF_SP_Helper::get_css_value( $attr['borderWidth'], 'px' ),
'border-right-width' => '0px',
'border-bottom-width' => '0px',
'border-left-width' => '0px',
);
}
if ( 'grid' === $attr['layout'] ) {
$selectors['.wpsp-faq-layout-grid .wpsp-faq__wrap .wpsp-faq-child__outer-wrap '] = array(
'text-align' => $attr['align'],
);
$selectors['.wpsp-faq-layout-grid .wpsp-faq__wrap.wpsp-buttons-layout-wrap '] = array(
'grid-template-columns' => 'repeat(' . $attr['columns'] . ', 1fr)',
'grid-column-gap' => BSF_SP_Helper::get_css_value( $attr['columnsGap'], 'px' ),
'grid-row-gap' => BSF_SP_Helper::get_css_value( $attr['rowsGap'], 'px' ),
'display' => 'grid',
);
$t_selectors['.wpsp-faq-layout-grid .wpsp-faq__wrap.wpsp-buttons-layout-wrap '] = array(
'grid-template-columns' => 'repeat(' . $attr['tcolumns'] . ', 1fr)',
);
$m_selectors['.wpsp-faq-layout-grid .wpsp-faq__wrap.wpsp-buttons-layout-wrap '] = array(
'grid-template-columns' => 'repeat(' . $attr['mcolumns'] . ', 1fr)',
);
}
$combined_selectors = array(
'desktop' => $selectors,
'tablet' => $t_selectors,
'mobile' => $m_selectors,
);
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'question', ' .wpsp-faq-questions-button .wpsp-question', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'answer', ' .wpsp-faq-item .wpsp-faq-content p', $combined_selectors );
return BSF_SP_Helper::generate_all_css( $combined_selectors, '.wpsp-block-' . $id );
}
/**
* Get How To CSS
*
* @since 2.4.0
* @param array $attr The block attributes.
* @param string $id The selector ID.
* @return array The Widget List.
*/
public static function get_how_to_css( $attr, $id ) {
$defaults = BSF_SP_Helper::$block_list['wpsp/how-to']['attributes'];
$attr = array_merge( $defaults, $attr );
$t_selectors = array();
$m_selectors = array();
$selectors = array(
' .wpsp-how-to-main-wrap' => array(
'text-align' => $attr['overallAlignment'],
),
' .wpsp-how-to-main-wrap p.wpsp-howto-desc-text' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['row_gap'], 'px' ),
),
' .wpsp-how-to-main-wrap .wpsp-howto__source-wrap' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['row_gap'], 'px' ),
),
' .wpsp-how-to-main-wrap span.wpsp-howto__time-wrap' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['row_gap'], 'px' ),
),
' .wpsp-how-to-main-wrap span.wpsp-howto__cost-wrap' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['row_gap'], 'px' ),
),
' .wpsp-tools__wrap .wpsp-how-to-tools-child__wrapper:last-child' => array(
'margin-bottom' => '0px',
),
' .wpsp-how-to-materials .wpsp-how-to-materials-child__wrapper:last-child' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['row_gap'], 'px' ),
),
' .wpsp-howto-steps__wrap .wp-block-wpsp-how-to-child' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['step_gap'], 'px' ),
),
' .wpsp-howto-steps__wrap .wp-block-wpsp-how-to-child:last-child' => array(
'margin-bottom' => '0px',
),
' span.wpsp-howto__time-wrap .wpsp-howto-timeNeeded-value' => array(
'margin-left' => BSF_SP_Helper::get_css_value( $attr['timeSpace'], 'px' ),
),
' span.wpsp-howto__cost-wrap .wpsp-howto-estcost-value' => array(
'margin-left' => BSF_SP_Helper::get_css_value( $attr['costSpace'], 'px' ),
),
' .wpsp-how-to-main-wrap .wpsp-howto-heading-text' => array(
'color' => $attr['headingColor'],
),
' .wpsp-howto-desc-text' => array(
'color' => $attr['subHeadingColor'],
),
' .wpsp-howto__wrap span.wpsp-howto__time-wrap p' => array(
'color' => $attr['subHeadingColor'],
),
' .wpsp-howto__wrap span.wpsp-howto__cost-wrap p' => array(
'color' => $attr['subHeadingColor'],
),
' .wpsp-howto__wrap span.wpsp-howto__time-wrap h4.wpsp-howto-timeNeeded-text' => array(
'color' => $attr['showTotaltimecolor'],
),
' .wpsp-howto__wrap span.wpsp-howto__cost-wrap h4.wpsp-howto-estcost-text' => array(
'color' => $attr['showTotaltimecolor'],
),
' .wpsp-how-to-tools__wrap .wpsp-howto-req-tools-text' => array(
'color' => $attr['showTotaltimecolor'],
),
' .wpsp-how-to-materials__wrap .wpsp-howto-req-materials-text' => array(
'color' => $attr['showTotaltimecolor'],
),
' .wpsp-how-to-steps__wrap .wpsp-howto-req-steps-text' => array(
'color' => $attr['showTotaltimecolor'],
),
);
$selectors[' .wpsp-tools__wrap .wpsp-how-to-tools-child__wrapper'] = array(
'color' => $attr['subHeadingColor'],
);
$selectors[' .wpsp-how-to-materials .wpsp-how-to-materials-child__wrapper'] = array(
'color' => $attr['subHeadingColor'],
);
$combined_selectors = array(
'desktop' => $selectors,
'tablet' => $t_selectors,
'mobile' => $m_selectors,
);
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'subHead', ' p', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'price', ' h4', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'head', ' .wpsp-howto-heading-text', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'subHead', ' .wpsp-tools .wpsp-tools__label', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'subHead', ' .wpsp-materials .wpsp-materials__label', $combined_selectors );
return BSF_SP_Helper::generate_all_css( $combined_selectors, ' .wpsp-block-' . $id );
}
/**
* Get Howto child CSS
*
* @since 2.4.0
* @param array $attr The block attributes.
* @param string $id The selector ID.
* @return array The Widget List.
*/
public static function get_how_to_child_css( $attr, $id ) {
$defaults = BSF_SP_Helper::$block_list['wpsp/how-to-child']['attributes'];
$attr = array_merge( $defaults, (array) $attr );
$m_selectors = array();
$t_selectors = array();
$cta_icon_size = BSF_SP_Helper::get_css_value( $attr['ctaFontSize'], $attr['ctaFontSizeType'] );
$m_cta_icon_size = BSF_SP_Helper::get_css_value( $attr['ctaFontSizeMobile'], $attr['ctaFontSizeType'] );
$t_cta_icon_size = BSF_SP_Helper::get_css_value( $attr['ctaFontSizeTablet'], $attr['ctaFontSizeType'] );
$icon_size = BSF_SP_Helper::get_css_value( $attr['iconSize'], 'px' );
$selectors = array(
' .wpsp-ifb-icon' => array(
'height' => $icon_size,
'width' => $icon_size,
'line-height' => $icon_size,
),
' .wpsp-ifb-icon > span' => array(
'font-size' => $icon_size,
'height' => $icon_size,
'width' => $icon_size,
'line-height' => $icon_size,
'color' => $attr['iconColor'],
),
' .wpsp-ifb-icon svg' => array(
'fill' => $attr['iconColor'],
),
' .wpsp-ifb-icon:hover > span' => array(
'color' => $attr['iconHover'],
),
' .wpsp-ifb-icon:hover svg' => array(
'fill' => $attr['iconHover'],
),
' .wpsp-how-to__link-to-all:hover ~ .wpsp-how-to__content-wrap .wpsp-ifb-icon svg' => array(
'fill' => $attr['iconHover'],
),
' .wpsp-how-to__content-wrap .wpsp-ifb-imgicon-wrap' => array(
'margin-left' => BSF_SP_Helper::get_css_value( $attr['iconLeftMargin'], 'px' ),
'margin-right' => BSF_SP_Helper::get_css_value( $attr['iconRightMargin'], 'px' ),
'margin-top' => BSF_SP_Helper::get_css_value( $attr['iconTopMargin'], 'px' ),
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['iconBottomMargin'], 'px' ),
),
' .wpsp-howto-child .wpsp-ifb-image-content img' => array(
'border-radius' => BSF_SP_Helper::get_css_value( $attr['iconimgBorderRadius'], 'px' ),
),
// Title Style.
' .wpsp-ifb-title' => array(
'color' => $attr['headingColor'],
'margin-bottom' => $attr['headSpace'] . 'px',
),
// Description Style.
' .wpsp-ifb-desc' => array(
'color' => $attr['subHeadingColor'],
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['subHeadSpace'], 'px' ),
),
// Seperator.
' .wpsp-ifb-separator' => array(
'width' => BSF_SP_Helper::get_css_value( $attr['seperatorWidth'], $attr['separatorWidthType'] ),
'border-top-width' => BSF_SP_Helper::get_css_value( $attr['seperatorThickness'], 'px' ),
'border-top-color' => $attr['seperatorColor'],
'border-top-style' => $attr['seperatorStyle'],
),
' .wpsp-ifb-separator-parent' => array(
'margin-bottom' => BSF_SP_Helper::get_css_value( $attr['seperatorSpace'], 'px' ),
),
// CTA icon space.
' .wpsp-ifb-align-icon-after' => array(
'margin-left' => BSF_SP_Helper::get_css_value( $attr['ctaIconSpace'], 'px' ),
),
' .wpsp-ifb-align-icon-before' => array(
'margin-right' => BSF_SP_Helper::get_css_value( $attr['ctaIconSpace'], 'px' ),
),
);
$selectors[' .wpsp-howto-child-cta-link'] = array(
'color' => $attr['ctaLinkColor'],
);
$selectors[' .wpsp-ifb-cta .wpsp-howto-child-cta-link:hover'] = array(
'color' => $attr['ctaLinkHoverColor'],
);
$selectors[' .wpsp-howto-child-cta-link .wpsp-ifb-button-icon'] = array(
'font-size' => $cta_icon_size,
'height' => $cta_icon_size,
'width' => $cta_icon_size,
'line-height' => $cta_icon_size,
);
$selectors[' .wpsp-howto-child-cta-link .wpsp-ifb-text-icon'] = array(
'font-size' => $cta_icon_size,
'height' => $cta_icon_size,
'width' => $cta_icon_size,
'line-height' => $cta_icon_size,
);
$selectors[' .wpsp-howto-child-cta-link svg'] = array(
'fill' => $attr['ctaLinkColor'],
);
$selectors[' .wpsp-howto-child-cta-link:hover svg'] = array(
'fill' => $attr['ctaLinkHoverColor'],
);
$selectors[' .wpsp-ifb-button-wrapper .wpsp-howto-child-cta-link'] = array(
'color' => $attr['ctaBtnLinkColor'],
'background-color' => $attr['ctaBgColor'],
'border-style' => $attr['ctaBorderStyle'],
'border-color' => $attr['ctaBorderColor'],
'border-radius' => BSF_SP_Helper::get_css_value( $attr['ctaBorderRadius'], 'px' ),
'border-width' => BSF_SP_Helper::get_css_value( $attr['ctaBorderWidth'], 'px' ),
'padding-top' => BSF_SP_Helper::get_css_value( $attr['ctaBtnVertPadding'], 'px' ),
'padding-bottom' => BSF_SP_Helper::get_css_value( $attr['ctaBtnVertPadding'], 'px' ),
'padding-left' => BSF_SP_Helper::get_css_value( $attr['ctaBtnHrPadding'], 'px' ),
'padding-right' => BSF_SP_Helper::get_css_value( $attr['ctaBtnHrPadding'], 'px' ),
);
$selectors[' .wpsp-ifb-button-wrapper .wpsp-howto-child-cta-link svg'] = array(
'fill' => $attr['ctaBtnLinkColor'],
);
$selectors[' .wpsp-ifb-button-wrapper .wpsp-howto-child-cta-link:hover'] = array(
'color' => $attr['ctaLinkHoverColor'],
'background-color' => $attr['ctaBgHoverColor'],
'border-color' => $attr['ctaBorderhoverColor'],
);
$selectors[' .wpsp-ifb-button-wrapper .wpsp-howto-child-cta-link:hover svg'] = array(
'fill' => $attr['ctaLinkHoverColor'],
);
if ( $attr['imageWidthType'] ) {
// Image.
$selectors[' .wpsp-ifb-image-content img'] = array(
'width' => BSF_SP_Helper::get_css_value( $attr['imageWidth'], 'px' ),
'max-width' => BSF_SP_Helper::get_css_value( $attr['imageWidth'], 'px' ),
);
}
if ( 'above-title' === $attr['iconimgPosition'] || 'below-title' === $attr['iconimgPosition'] ) {
$selectors[' .wpsp-how-to__content-wrap'] = array(
'text-align' => $attr['headingAlign'],
);
}
$m_selectors = array(
' .wpsp-howto-child-cta-link .wpsp-ifb-button-icon' => array(
'font-size' => $m_cta_icon_size,
'height' => $m_cta_icon_size,
'width' => $m_cta_icon_size,
'line-height' => $m_cta_icon_size,
),
' .wpsp-howto-child-cta-link .wpsp-ifb-text-icon' => array(
'font-size' => $m_cta_icon_size,
'height' => $m_cta_icon_size,
'width' => $m_cta_icon_size,
'line-height' => $m_cta_icon_size,
),
);
$t_selectors = array(
' .wpsp-howto-child-cta-link .wpsp-ifb-button-icon' => array(
'font-size' => $t_cta_icon_size,
'height' => $t_cta_icon_size,
'width' => $t_cta_icon_size,
'line-height' => $t_cta_icon_size,
),
' .wpsp-howto-child-cta-link .wpsp-ifb-text-icon' => array(
'font-size' => $t_cta_icon_size,
'height' => $t_cta_icon_size,
'width' => $t_cta_icon_size,
'line-height' => $t_cta_icon_size,
),
);
$combined_selectors = array(
'desktop' => $selectors,
'tablet' => $t_selectors,
'mobile' => $m_selectors,
);
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'head', ' .wpsp-ifb-title', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'subHead', ' .wpsp-ifb-desc', $combined_selectors );
$combined_selectors = BSF_SP_Helper::get_typography_css( $attr, 'cta', ' .wpsp-howto-child-cta-link', $combined_selectors );
$base_selector = '.wp-block-wpsp-how-to-child.wpsp-block-';
return BSF_SP_Helper::generate_all_css( $combined_selectors, $base_selector . $id );
}
/**
* Prepare if class 'Schema_Pro_Loader' exist.
* Kicking this off by calling 'get_instance()' method
*/
}
}

View File

@@ -1,98 +0,0 @@
<?php
/**
* Schema Pro Block Helper.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Block_JS' ) ) {
/**
* Class BSF_SP_Block_JS.
*/
class BSF_SP_Block_JS {
/**
* Adds Google fonts for FAQ block.
*
* @since 1.15.0
* @param array $attr the blocks attr.
*/
public static function blocks_faq_gfont( $attr ) {
$question_load_google_font = isset( $attr['questionloadGoogleFonts'] ) ? $attr['questionloadGoogleFonts'] : '';
$question_font_family = isset( $attr['questionFontFamily'] ) ? $attr['questionFontFamily'] : '';
$question_font_weight = isset( $attr['questionFontWeight'] ) ? $attr['questionFontWeight'] : '';
$question_font_subset = isset( $attr['questionFontSubset'] ) ? $attr['questionFontSubset'] : '';
$answer_load_google_font = isset( $attr['answerloadGoogleFonts'] ) ? $attr['answerloadGoogleFonts'] : '';
$answer_font_family = isset( $attr['answerFontFamily'] ) ? $attr['answerFontFamily'] : '';
$answer_font_weight = isset( $attr['answerFontWeight'] ) ? $attr['answerFontWeight'] : '';
$answer_font_subset = isset( $attr['answerFontSubset'] ) ? $attr['answerFontSubset'] : '';
BSF_SP_Helper::blocks_google_font( $question_load_google_font, $question_font_family, $question_font_weight, $question_font_subset );
BSF_SP_Helper::blocks_google_font( $answer_load_google_font, $answer_font_family, $answer_font_weight, $answer_font_subset );
}
/**
* Adds Google fonts for How To block.
*
* @since 2.4.0
* @param array $attr the blocks attr.
*/
public static function blocks_how_to_gfont( $attr ) {
$head_load_google_font = isset( $attr['headLoadGoogleFonts'] ) ? $attr['headLoadGoogleFonts'] : '';
$head_font_family = isset( $attr['headFontFamily'] ) ? $attr['headFontFamily'] : '';
$head_font_weight = isset( $attr['headFontWeight'] ) ? $attr['headFontWeight'] : '';
$head_font_subset = isset( $attr['headFontSubset'] ) ? $attr['headFontSubset'] : '';
$subhead_load_google_font = isset( $attr['subHeadLoadGoogleFonts'] ) ? $attr['subHeadLoadGoogleFonts'] : '';
$subhead_font_family = isset( $attr['subHeadFontFamily'] ) ? $attr['subHeadFontFamily'] : '';
$subhead_font_weight = isset( $attr['subHeadFontWeight'] ) ? $attr['subHeadFontWeight'] : '';
$subhead_font_subset = isset( $attr['subHeadFontSubset'] ) ? $attr['subHeadFontSubset'] : '';
$price_load_google_font = isset( $attr['priceLoadGoogleFonts'] ) ? $attr['priceLoadGoogleFonts'] : '';
$price_font_family = isset( $attr['priceFontFamily'] ) ? $attr['priceFontFamily'] : '';
$price_font_weight = isset( $attr['priceFontWeight'] ) ? $attr['priceFontWeight'] : '';
$price_font_subset = isset( $attr['priceFontSubset'] ) ? $attr['priceFontSubset'] : '';
BSF_SP_Helper::blocks_google_font( $head_load_google_font, $head_font_family, $head_font_weight, $head_font_subset );
BSF_SP_Helper::blocks_google_font( $subhead_load_google_font, $subhead_font_family, $subhead_font_weight, $subhead_font_subset );
BSF_SP_Helper::blocks_google_font( $price_load_google_font, $price_font_family, $price_font_weight, $price_font_subset );
}
/**
* Adds Google fonts for HowTo Child Block.
*
* @since 2.4.0
* @param array $attr the blocks attr.
*/
public static function blocks_how_to_child_gfont( $attr ) {
$head_load_google_font = isset( $attr['headLoadGoogleFonts'] ) ? $attr['headLoadGoogleFonts'] : '';
$head_font_family = isset( $attr['headFontFamily'] ) ? $attr['headFontFamily'] : '';
$head_font_weight = isset( $attr['headFontWeight'] ) ? $attr['headFontWeight'] : '';
$head_font_subset = isset( $attr['headFontSubset'] ) ? $attr['headFontSubset'] : '';
$subhead_load_google_font = isset( $attr['subHeadLoadGoogleFonts'] ) ? $attr['subHeadLoadGoogleFonts'] : '';
$subhead_font_family = isset( $attr['subHeadFontFamily'] ) ? $attr['subHeadFontFamily'] : '';
$subhead_font_weight = isset( $attr['subHeadFontWeight'] ) ? $attr['subHeadFontWeight'] : '';
$subhead_font_subset = isset( $attr['subHeadFontSubset'] ) ? $attr['subHeadFontSubset'] : '';
$cta_load_google_font = isset( $attr['ctaLoadGoogleFonts'] ) ? $attr['ctaLoadGoogleFonts'] : '';
$cta_font_family = isset( $attr['ctaFontFamily'] ) ? $attr['ctaFontFamily'] : '';
$cta_font_weight = isset( $attr['ctaFontWeight'] ) ? $attr['ctaFontWeight'] : '';
$cta_font_subset = isset( $attr['ctaFontSubset'] ) ? $attr['ctaFontSubset'] : '';
BSF_SP_Helper::blocks_google_font( $cta_load_google_font, $cta_font_family, $cta_font_weight, $cta_font_subset );
BSF_SP_Helper::blocks_google_font( $head_load_google_font, $head_font_family, $head_font_weight, $head_font_subset );
BSF_SP_Helper::blocks_google_font( $subhead_load_google_font, $subhead_font_family, $subhead_font_weight, $subhead_font_subset );
}
}
}

View File

@@ -1,338 +0,0 @@
<?php
/**
* Schema Pro Config.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Config' ) ) {
/**
* Class BSF_SP_Config.
*/
class BSF_SP_Config {
/**
* Block Attributes
*
* @var block_attributes
*/
public static $block_attributes = null;
/**
* Block Assets
*
* @var block_attributes
*/
public static $block_assets = null;
/**
* Get Widget List.
*
* @since 0.0.1
*
* @return array The Widget List.
*/
public static function get_block_attributes() {
if ( null === self::$block_attributes ) {
self::$block_attributes = array(
'wpsp/faq' => array(
'slug' => '',
'title' => __( 'FAQ - Schema Pro', 'wp-schema-pro' ),
'description' => __( 'This block helps you add a FAQ section with inbuilt schema support.', 'wp-schema-pro' ),
'default' => true,
'js_assets' => array( 'wpsp-faq-js' ),
'attributes' => array(
'block_id' => '',
'layout' => 'accordion',
'inactiveOtherItems' => true,
'expandFirstItem' => false,
'enableSchemaSupport' => false,
'align' => 'left',
'enableSeparator' => false,
'rowsGap' => 10,
'columnsGap' => 10,
'boxBgColor' => '#FFFFFF',
'boxPaddingTypeMobile' => 'px',
'boxPaddingTypeTablet' => 'px',
'boxPaddingTypeDesktop' => 'px',
'vBoxPaddingMobile' => 10,
'hBoxPaddingMobile' => 10,
'vBoxPaddingTablet' => 10,
'hBoxPaddingTablet' => 10,
'vBoxPaddingDesktop' => 10,
'hBoxPaddingDesktop' => 10,
'borderStyle' => 'solid',
'borderWidth' => 1,
'borderRadius' => 2,
'borderColor' => '#D2D2D2',
'questionTextColor' => '#313131',
'questionTextActiveColor' => '#313131',
'questionPaddingTypeDesktop' => 'px',
'vquestionPaddingMobile' => 10,
'vquestionPaddingTablet' => 10,
'vquestionPaddingDesktop' => 10,
'hquestionPaddingMobile' => 10,
'hquestionPaddingTablet' => 10,
'hquestionPaddingDesktop' => 10,
'answerTextColor' => '#313131',
'answerPaddingTypeDesktop' => 'px',
'vanswerPaddingMobile' => 10,
'vanswerPaddingTablet' => 10,
'vanswerPaddingDesktop' => 10,
'hanswerPaddingMobile' => 10,
'hanswerPaddingTablet' => 10,
'hanswerPaddingDesktop' => 10,
'iconColor' => '',
'iconActiveColor' => '',
'gapBtwIconQUestion' => 10,
'questionloadGoogleFonts' => false,
'answerloadGoogleFonts' => false,
'questionFontFamily' => 'Default',
'questionFontWeight' => '',
'questionFontSubset' => '',
'questionFontSize' => '',
'questionFontSizeType' => 'px',
'questionFontSizeTablet' => '',
'questionFontSizeMobile' => '',
'questionLineHeight' => '',
'questionLineHeightType' => 'em',
'questionLineHeightTablet' => '',
'questionLineHeightMobile' => '',
'answerFontFamily' => 'Default',
'answerFontWeight' => '',
'answerFontSubset' => '',
'answerFontSize' => '',
'answerFontSizeType' => 'px',
'answerFontSizeTablet' => '',
'answerFontSizeMobile' => '',
'answerLineHeight' => '',
'answerLineHeightType' => 'em',
'answerLineHeightTablet' => '',
'answerLineHeightMobile' => '',
'icon' => 'fas fa-plus',
'iconActive' => 'fas fa-minus',
'iconAlign' => 'row',
'iconSize' => 15,
'iconSizeMobile' => 15,
'iconSizeTablet' => 15,
'iconSizeType' => 'px',
'columns' => 2,
'tcolumns' => 2,
'mcolumns' => 1,
'schema' => '',
'enableToggle' => true,
'questionLeftPaddingTablet' => 10,
'questionBottomPaddingTablet' => 10,
'questionLeftPaddingDesktop' => 10,
'questionBottomPaddingDesktop' => 10,
'questionLeftPaddingMobile' => 10,
'questionBottomPaddingMobile' => 10,
),
),
'wpsp/faq-child' => array(
'slug' => '',
'title' => __( 'FAQ - Schema Pro Child', 'wp-schema-pro' ),
'description' => __( 'This block helps you add single FAQ.', 'wp-schema-pro' ),
'default' => true,
'attributes' => array(
'block_id' => '',
'question' => '',
'answer' => '',
'icon' => 'fas fa-plus',
'iconActive' => 'fas fa-minus',
'layout' => 'accordion',
),
),
'wpsp/how-to' => array(
'slug' => '',
'title' => __( 'How-to - Schema Pro', 'wp-schema-pro' ),
'description' => __( 'This block allows you to design attractive How-to pages or articles with automatically adding How-to Schema to your page.', 'wp-schema-pro' ),
'default' => true,
'attributes' => array(
'block_id' => '',
'overallAlignment' => 'left',
'toolsCount' => 1,
'materialCount' => 1,
'tools' => '',
'materials' => '',
'showTotaltime' => false,
'showEstcost' => false,
'showTools' => false,
'showMaterials' => false,
'mainimage' => '',
'imgSize' => 'thumbnail',
'timeSpace' => 5,
'costSpace' => 5,
'time' => '30',
'cost' => '65',
'currencyType' => ' USD',
'headingAlign' => 'left',
'descriptionAlign' => 'left',
'headingColor' => '',
'showEstcostcolor' => '',
'showTotaltimecolor' => '',
'subHeadingColor' => '',
'headingTag' => 'h3',
'headSpace' => 15,
'headFontFamily' => 'Default',
'headFontWeight' => '',
'headFontSubset' => '',
'headFontSizeType' => 'px',
'headLineHeightType' => 'em',
'headFontSize' => '',
'headFontSizeTablet' => '',
'headFontSizeMobile' => '',
'headLineHeight' => '',
'headLineHeightTablet' => '',
'headLineHeightMobile' => '',
'subHeadFontFamily' => 'Default',
'subHeadFontWeight' => '',
'subHeadFontSubset' => '',
'subHeadFontSize' => '',
'subHeadFontSizeType' => 'px',
'subHeadFontSizeTablet' => '',
'subHeadFontSizeMobile' => '',
'subHeadLineHeight' => '',
'subHeadLineHeightType' => 'em',
'subHeadLineHeightTablet' => '',
'subHeadLineHeightMobile' => '',
'separatorSpace' => 15,
'headLoadGoogleFonts' => false,
'subHeadLoadGoogleFonts' => false,
'priceFontSizeType' => 'px',
'priceFontSize' => '',
'priceFontSizeTablet' => '',
'priceFontSizeMobile' => '',
'priceFontFamily' => 'Default',
'priceFontWeight' => '',
'priceFontSubset' => '',
'priceLineHeightType' => 'em',
'priceLineHeight' => '',
'priceLineHeightTablet' => '',
'priceLineHeightMobile' => '',
'priceLoadGoogleFonts' => false,
'row_gap' => 20,
'step_gap' => 20,
'schema' => '',
),
),
'wpsp/how-to-child' => array(
'slug' => '',
'title' => __( 'Steps', 'wp-schema-pro' ),
'description' => __( 'This steps box allows you to place an image along with a heading and description within a single block.', 'wp-schema-pro' ),
'default' => true,
'attributes' => array(
'classMigrate' => false,
'headingAlign' => 'left',
'headingColor' => '',
'subHeadingColor' => '',
'headFontSize' => '',
'headFontSizeType' => 'px',
'headFontSizeTablet' => '',
'headFontSizeMobile' => '',
'headFontFamily' => '',
'headFontWeight' => '',
'headFontSubset' => '',
'headLineHeightType' => 'em',
'headLineHeight' => '',
'headLineHeightTablet' => '',
'headLineHeightMobile' => '',
'headLoadGoogleFonts' => false,
'subHeadFontSize' => '',
'subHeadFontSizeType' => 'px',
'subHeadFontSizeTablet' => '',
'subHeadFontSizeMobile' => '',
'subHeadFontFamily' => '',
'subHeadFontWeight' => '',
'subHeadFontSubset' => '',
'subHeadLineHeightType' => 'em',
'subHeadLineHeight' => '',
'subHeadLineHeightTablet' => '',
'subHeadLineHeightMobile' => '',
'subHeadLoadGoogleFonts' => false,
'separatorWidth' => '',
'separatorHeight' => '',
'separatorWidthType' => '%',
'headSpace' => '10',
'separatorSpace' => '10',
'subHeadSpace' => '10',
'iconColor' => '#333',
'iconSize' => '40',
'iconimgPosition' => 'above-title',
'block_id' => '',
'iconHover' => '',
'iconimgBorderRadius' => '0',
'seperatorStyle' => 'solid',
'seperatorWidth' => '30',
'seperatorColor' => '#333',
'seperatorThickness' => '2',
'ctaLinkColor' => '#333',
'ctaFontSize' => '',
'ctaFontSizeType' => 'px',
'ctaFontSizeMobile' => '',
'ctaFontSizeTablet' => '',
'ctaFontFamily' => '',
'ctaFontWeight' => '',
'ctaFontSubset' => '',
'ctaLoadGoogleFonts' => false,
'ctaBtnLinkColor' => '#333',
'ctaBgColor' => 'transparent',
'ctaBtnVertPadding' => '10',
'ctaBtnHrPadding' => '14',
'ctaBorderStyle' => 'solid',
'ctaBorderColor' => '#333',
'ctaBorderWidth' => '1',
'ctaBorderRadius' => '0',
'iconLeftMargin' => '5',
'iconRightMargin' => '10',
'iconTopMargin' => '5',
'iconBottomMargin' => '5',
'imageSize' => 'thumbnail',
'imageWidthType' => false,
'imageWidth' => '120',
'seperatorSpace' => '15',
'ctaLinkHoverColor' => '',
'ctaBgHoverColor' => '',
'ctaBorderhoverColor' => '',
'ctaIconSpace' => '5',
),
),
);
}
return self::$block_attributes;
}
/**
* Get Block Assets.
*
* @since 1.13.4
*
* @return array The Asset List.
*/
public static function get_block_assets() {
$minify = BSF_AIOSRS_Pro_Helper::bsf_schema_pro_is_wp_debug_enable() ? 'js/faq.js' : 'min-js/faq.min.js';
$faq_js = BSF_AIOSRS_PRO_URI . 'wpsp-blocks/assets/' . $minify;
if ( null === self::$block_assets ) {
self::$block_assets = array(
'wpsp-faq-js' => array(
'src' => $faq_js,
'dep' => array(),
'skipEditor' => true,
),
);
}
return self::$block_assets;
}
}
}

View File

@@ -1,731 +0,0 @@
<?php
/**
* Schema Pro Helper.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Helper' ) ) {
/**
* Class BSF_SP_Helper.
*/
final class BSF_SP_Helper {
/**
* Member Variable
*
* @since 2.2.0
* @var instance
*/
private static $instance;
/**
* Member Variable
*
* @since 2.2.0
* @var instance
*/
public static $block_list;
/**
* Schema Pro FAQ Layout Flag
*
* @since 1.18.1
* @var wpsp_faq_layout
*/
public static $wpsp_faq_layout = false;
/**
* Current Block List
*
* @since 2.2.0
* @var current_block_list
*/
public static $current_block_list = array();
/**
* Schema Pro Block Flag
*
* @since 2.2.0
* @var wpsp_flag
*/
public static $wpsp_flag = false;
/**
* Schema Pro File Generation Flag
*
* @since 2.2.0
* @var file_generation
*/
public static $file_generation = 'disabled';
/**
* Schema Pro File Generation Fallback Flag for CSS
*
* @since 2.2.0
* @var file_generation
*/
public static $fallback_css = false;
/**
* Schema Pro File Generation Fallback Flag for JS
*
* @since 2.2.0
* @var file_generation
*/
public static $fallback_js = false;
/**
* Enque Style and Script Variable
*
* @since 2.2.0
* @var instance
*/
public static $css_file_handler = array();
/**
* Stylesheet
*
* @since 2.2.0
* @var stylesheet
*/
public static $stylesheet;
/**
* Script
*
* @since 2.2.0
* @var script
*/
public static $script;
/**
* Store Json variable
*
* @since 2.2.0
* @var instance
*/
public static $icon_json;
/**
* Page Blocks Variable
*
* @since 2.2.0
* @var instance
*/
public static $page_blocks;
/**
* Google fonts to enqueue
*
* @var array
*/
public static $gfonts = array();
/**
* Initiator
*
* @since 2.2.0
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
require BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-config.php';
require BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-block-helper.php';
require BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-block-js.php';
self::$block_list = BSF_SP_Config::get_block_attributes();
add_action( 'wp', array( $this, 'generate_assets' ), 99 );
add_action( 'wp_enqueue_scripts', array( $this, 'block_assets' ), 10 );
add_action( 'wp_head', array( $this, 'frontend_gfonts' ), 120 );
add_action( 'wp_head', array( $this, 'print_stylesheet' ), 80 );
add_action( 'wp_footer', array( $this, 'print_script' ), 1000 );
}
/**
* Enqueue Gutenberg block assets for both frontend + backend.
*
* @since 2.2.0
*/
public function block_assets() {
$block_list_for_assets = self::$current_block_list;
$blocks = BSF_SP_Config::get_block_attributes();
foreach ( $block_list_for_assets as $key => $curr_block_name ) {
$js_assets = ( isset( $blocks[ $curr_block_name ]['js_assets'] ) ) ? $blocks[ $curr_block_name ]['js_assets'] : array();
$css_assets = ( isset( $blocks[ $curr_block_name ]['css_assets'] ) ) ? $blocks[ $curr_block_name ]['css_assets'] : array();
foreach ( $js_assets as $asset_handle => $val ) {
// Scripts.
if ( 'wpsp-faq-js' === $val ) {
if ( self::$wpsp_faq_layout ) {
wp_enqueue_script( 'wpsp-faq-js' );
}
} else {
wp_enqueue_script( $val );
}
}
foreach ( $css_assets as $asset_handle => $val ) {
// Styles.
wp_enqueue_style( $val );
}
}
}
/**
* Print the Script in footer.
*/
public function print_script() {
ob_start();
?>
<script type="text/javascript" id="wpsp-script-frontend"><?php echo esc_js( self::$script ); //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?></script>
<?php
ob_end_flush();
}
/**
* Print the Stylesheet in header.
*/
public function print_stylesheet() {
ob_start();
?>
<style id="wpsp-style-frontend"><?php echo self::$stylesheet; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?></style>
<?php
ob_end_flush();
}
/**
* Load the front end Google Fonts.
*/
public function frontend_gfonts() {
if ( empty( self::$gfonts ) ) {
return;
}
$show_google_fonts = apply_filters( 'wpsp_blocks_show_google_fonts', true );
if ( ! $show_google_fonts ) {
return;
}
$link = '';
$subsets = array();
foreach ( self::$gfonts as $key => $gfont_values ) {
if ( ! empty( $link ) ) {
$link .= '%7C'; // Append a new font to the string.
}
$link .= $gfont_values['fontfamily'];
if ( ! empty( $gfont_values['fontvariants'] ) ) {
$link .= ':';
$link .= implode( ',', $gfont_values['fontvariants'] );
}
if ( ! empty( $gfont_values['fontsubsets'] ) ) {
foreach ( $gfont_values['fontsubsets'] as $subset ) {
if ( ! in_array( $subset, $subsets, true ) ) {
array_push( $subsets, $subset );
}
}
}
}
if ( ! empty( $subsets ) ) {
$link .= '&amp;subset=' . implode( ',', $subsets );
}
if ( isset( $link ) && ! empty( $link ) ) {
echo '<link href="//fonts.googleapis.com/css?family=' . esc_attr( str_replace( '|', '%7C', $link ) ) . '" rel="stylesheet">'; //phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
}
}
/**
* Parse CSS into correct CSS syntax.
*
* @param array $selectors The block selectors.
* @param string $id The selector ID.
* @since 2.2.0
*/
public static function generate_css( $selectors, $id ) {
$styling_css = '';
if ( empty( $selectors ) ) {
return '';
}
foreach ( $selectors as $key => $value ) {
$css = '';
foreach ( $value as $j => $val ) {
if ( 'font-family' === $j && 'Default' === $val ) {
continue;
}
if ( ! empty( $val ) || 0 === $val ) {
if ( 'font-family' === $j ) {
$css .= $j . ': "' . $val . '";';
} else {
$css .= $j . ': ' . $val . ';';
}
}
}
if ( ! empty( $css ) ) {
$styling_css .= $id;
$styling_css .= $key . '{';
$styling_css .= $css . '}';
}
}
return $styling_css;
}
/**
* Get CSS value
*
* Syntax:
*
* get_css_value( VALUE, UNIT );
*
* E.g.
*
* get_css_value( VALUE, 'em' );
*
* @param string $value CSS value.
* @param string $unit CSS unit.
* @since 2.2.0
*/
public static function get_css_value( $value = '', $unit = '' ) {
if ( '' == $value ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return $value;
}
$css_val = '';
if ( ! empty( $value ) ) {
$css_val = esc_attr( $value ) . $unit;
}
return $css_val;
}
/**
* Generates CSS recurrsively.
*
* @param object $block The block object.
* @since 2.2.0
*/
public function get_block_css_and_js( $block ) {
$block = (array) $block;
$name = $block['blockName'];
$css = array();
$js = '';
$block_id = '';
if ( ! isset( $name ) ) {
return array(
'css' => array(),
'js' => '',
);
}
$blockattr = array();
if ( isset( $block['attrs'] ) && is_array( $block['attrs'] ) ) {
$blockattr = $block['attrs'];
if ( isset( $blockattr['block_id'] ) ) {
$block_id = $blockattr['block_id'];
}
}
self::$current_block_list[] = $name;
if ( strpos( $name, 'wpsp/' ) !== false ) {
self::$wpsp_flag = true;
}
switch ( $name ) {
case 'wpsp/faq':
if ( ! empty( $blockattr ) ) {
$css = BSF_SP_Block_Helper::get_faq_css( $blockattr, $block_id );
if ( ! isset( $blockattr['layout'] ) ) {
self::$wpsp_faq_layout = true;
}
BSF_SP_Block_JS::blocks_faq_gfont( $blockattr );
}
break;
case 'wpsp/how-to':
if ( ! empty( $blockattr ) ) {
$css += BSF_SP_Block_Helper::get_how_to_css( $blockattr, $block_id );
BSF_SP_Block_JS::blocks_how_to_gfont( $blockattr );
}
break;
case 'wpsp/how-to-child':
if ( ! empty( $blockattr ) ) {
$css += BSF_SP_Block_Helper::get_how_to_child_css( $blockattr, $block_id );
BSF_SP_Block_JS::blocks_how_to_child_gfont( $blockattr );
}
break;
default:
// Nothing to do here.
break;
}
if ( isset( $block['innerBlocks'] ) ) {
foreach ( $block['innerBlocks'] as $j => $inner_block ) {
if ( 'core/block' === $inner_block['blockName'] ) {
$id = ( isset( $inner_block['attrs']['ref'] ) ) ? $inner_block['attrs']['ref'] : 0;
if ( $id ) {
$content = get_post_field( 'post_content', $id );
$reusable_blocks = $this->parse( $content );
$assets = $this->get_assets( $reusable_blocks );
self::$stylesheet .= $assets['css'];
self::$script .= $assets['js'];
}
} else {
// Get CSS for the Block.
$inner_assets = $this->get_block_css_and_js( $inner_block );
$inner_block_css = $inner_assets['css'];
$css_desktop = ( isset( $css['desktop'] ) ? $css['desktop'] : '' );
$css_tablet = ( isset( $css['tablet'] ) ? $css['tablet'] : '' );
$css_mobile = ( isset( $css['mobile'] ) ? $css['mobile'] : '' );
if ( isset( $inner_block_css['desktop'] ) ) {
$css['desktop'] = $css_desktop . $inner_block_css['desktop'];
$css['tablet'] = $css_tablet . $inner_block_css['tablet'];
$css['mobile'] = $css_mobile . $inner_block_css['mobile'];
}
$js .= $inner_assets['js'];
}
}
}
self::$current_block_list = array_unique( self::$current_block_list );
return array(
'css' => $css,
'js' => $js,
);
}
/**
* Adds Google fonts all blocks.
*
* @param array $load_google_font the blocks attr.
* @param array $font_family the blocks attr.
* @param array $font_weight the blocks attr.
* @param array $font_subset the blocks attr.
*/
public static function blocks_google_font( $load_google_font, $font_family, $font_weight, $font_subset ) {
if ( true === $load_google_font ) {
if ( ! array_key_exists( $font_family, self::$gfonts ) ) {
$add_font = array(
'fontfamily' => $font_family,
'fontvariants' => ( isset( $font_weight ) && ! empty( $font_weight ) ? array( $font_weight ) : array() ),
'fontsubsets' => ( isset( $font_subset ) && ! empty( $font_subset ) ? array( $font_subset ) : array() ),
);
self::$gfonts[ $font_family ] = $add_font;
} else {
if ( isset( $font_weight ) && ! empty( $font_weight ) && ! in_array( $font_weight, self::$gfonts[ $font_family ]['fontvariants'], true ) ) {
array_push( self::$gfonts[ $font_family ]['fontvariants'], $font_weight );
}
if ( isset( $font_subset ) && ! empty( $font_subset ) && ! in_array( $font_subset, self::$gfonts[ $font_family ]['fontsubsets'], true ) ) {
array_push( self::$gfonts[ $font_family ]['fontsubsets'], $font_subset );
}
}
}
}
/**
* Generates stylesheet and appends in head tag.
*
* @since 2.2.0
*/
public function generate_assets() {
$this_post = array();
global $post;
$this_post = $post;
if ( ! is_object( $this_post ) ) {
return;
}
/**
* Filters the post to build stylesheet for.
*
* @param \WP_Post $this_post The global post.
*/
$this_post = apply_filters( 'wpsp_post_for_stylesheet', $this_post );
$this->get_generated_stylesheet( $this_post );
}
/**
* Generates stylesheet in loop.
*
* @param object $this_post Current Post Object.
* @since 2.2.0
*/
public function get_generated_stylesheet( $this_post ) {
if ( ! is_object( $this_post ) ) {
return;
}
if ( ! isset( $this_post->ID ) ) {
return;
}
if ( function_exists( 'has_blocks' ) && has_blocks( $this_post->ID ) && isset( $this_post->post_content ) ) {
$blocks = $this->parse( $this_post->post_content );
self::$page_blocks = $blocks;
if ( ! is_array( $blocks ) || empty( $blocks ) ) {
return;
}
$assets = $this->get_assets( $blocks );
self::$stylesheet .= $assets['css'];
self::$script .= $assets['js'];
}
}
/**
* Parse Guten Block.
*
* @param string $content the content string.
* @since 2.2.0
*/
public function parse( $content ) {
global $wp_version;
return ( version_compare( $wp_version, '5', '>=' ) ) ? parse_blocks( $content ) : gutenberg_parse_blocks( $content );
}
/**
* Generates stylesheet for reusable blocks.
*
* @param array $blocks Blocks array.
* @since 2.2.0
*/
public function get_assets( $blocks ) {
$desktop = '';
$tablet = '';
$mobile = '';
$tab_styling_css = '';
$mob_styling_css = '';
$js = '';
foreach ( $blocks as $i => $block ) {
if ( is_array( $block ) ) {
if ( '' === $block['blockName'] ) {
continue;
}
if ( 'core/block' === $block['blockName'] ) {
$id = ( isset( $block['attrs']['ref'] ) ) ? $block['attrs']['ref'] : 0;
if ( $id ) {
$content = get_post_field( 'post_content', $id );
$reusable_blocks = $this->parse( $content );
$assets = $this->get_assets( $reusable_blocks );
self::$stylesheet .= $assets['css'];
self::$script .= $assets['js'];
}
} else {
$block_assets = $this->get_block_css_and_js( $block );
// Get CSS for the Block.
$css = $block_assets['css'];
if ( isset( $css['desktop'] ) ) {
$desktop .= $css['desktop'];
$tablet .= $css['tablet'];
$mobile .= $css['mobile'];
}
$js .= $block_assets['js'];
}
}
}
if ( ! empty( $tablet ) ) {
$tab_styling_css .= '@media only screen and (max-width: ' . WPSP_TABLET_BREAKPOINT . 'px) {';
$tab_styling_css .= $tablet;
$tab_styling_css .= '}';
}
if ( ! empty( $mobile ) ) {
$mob_styling_css .= '@media only screen and (max-width: ' . WPSP_MOBILE_BREAKPOINT . 'px) {';
$mob_styling_css .= $mobile;
$mob_styling_css .= '}';
}
return array(
'css' => $desktop . $tab_styling_css . $mob_styling_css,
'js' => $js,
);
}
/**
* Get Typography Dynamic CSS.
*
* @param array $attr The Attribute array.
* @param string $slug The field slug.
* @param string $selector The selector array.
* @param array $combined_selectors The combined selector array.
* @since 2.2.0
* @return bool|string
*/
public static function get_typography_css( $attr, $slug, $selector, $combined_selectors ) {
$typo_css_desktop = array();
$typo_css_tablet = array();
$typo_css_mobile = array();
$already_selectors_desktop = ( isset( $combined_selectors['desktop'][ $selector ] ) ) ? $combined_selectors['desktop'][ $selector ] : array();
$already_selectors_tablet = ( isset( $combined_selectors['tablet'][ $selector ] ) ) ? $combined_selectors['tablet'][ $selector ] : array();
$already_selectors_mobile = ( isset( $combined_selectors['mobile'][ $selector ] ) ) ? $combined_selectors['mobile'][ $selector ] : array();
$family_slug = ( '' === $slug ) ? 'fontFamily' : $slug . 'FontFamily';
$weight_slug = ( '' === $slug ) ? 'fontWeight' : $slug . 'FontWeight';
$l_ht_slug = ( '' === $slug ) ? 'lineHeight' : $slug . 'LineHeight';
$f_sz_slug = ( '' === $slug ) ? 'fontSize' : $slug . 'FontSize';
$l_ht_type_slug = ( '' === $slug ) ? 'lineHeightType' : $slug . 'LineHeightType';
$f_sz_type_slug = ( '' === $slug ) ? 'fontSizeType' : $slug . 'FontSizeType';
$typo_css_desktop[ $selector ] = array(
'font-family' => $attr[ $family_slug ],
'font-weight' => $attr[ $weight_slug ],
'font-size' => ( isset( $attr[ $f_sz_slug ] ) ) ? self::get_css_value( $attr[ $f_sz_slug ], $attr[ $f_sz_type_slug ] ) : '',
'line-height' => ( isset( $attr[ $l_ht_slug ] ) ) ? self::get_css_value( $attr[ $l_ht_slug ], $attr[ $l_ht_type_slug ] ) : '',
);
$typo_css_desktop[ $selector ] = array_merge(
$typo_css_desktop[ $selector ],
$already_selectors_desktop
);
$typo_css_tablet[ $selector ] = array(
'font-size' => ( isset( $attr[ $f_sz_slug . 'Tablet' ] ) ) ? self::get_css_value( $attr[ $f_sz_slug . 'Tablet' ], $attr[ $f_sz_type_slug ] ) : '',
'line-height' => ( isset( $attr[ $l_ht_slug . 'Tablet' ] ) ) ? self::get_css_value( $attr[ $l_ht_slug . 'Tablet' ], $attr[ $l_ht_type_slug ] ) : '',
);
$typo_css_tablet[ $selector ] = array_merge(
$typo_css_tablet[ $selector ],
$already_selectors_tablet
);
$typo_css_mobile[ $selector ] = array(
'font-size' => ( isset( $attr[ $f_sz_slug . 'Mobile' ] ) ) ? self::get_css_value( $attr[ $f_sz_slug . 'Mobile' ], $attr[ $f_sz_type_slug ] ) : '',
'line-height' => ( isset( $attr[ $l_ht_slug . 'Mobile' ] ) ) ? self::get_css_value( $attr[ $l_ht_slug . 'Mobile' ], $attr[ $l_ht_type_slug ] ) : '',
);
$typo_css_mobile[ $selector ] = array_merge(
$typo_css_mobile[ $selector ],
$already_selectors_mobile
);
return array(
'desktop' => array_merge(
$combined_selectors['desktop'],
$typo_css_desktop
),
'tablet' => array_merge(
$combined_selectors['tablet'],
$typo_css_tablet
),
'mobile' => array_merge(
$combined_selectors['mobile'],
$typo_css_mobile
),
);
}
/**
* Parse CSS into correct CSS syntax.
*
* @param array $combined_selectors The combined selector array.
* @param string $id The selector ID.
* @since 2.2.0
*/
public static function generate_all_css( $combined_selectors, $id ) {
return array(
'desktop' => self::generate_css( $combined_selectors['desktop'], $id ),
'tablet' => self::generate_css( $combined_selectors['tablet'], $id ),
'mobile' => self::generate_css( $combined_selectors['mobile'], $id ),
);
}
/**
* Get an instance of WP_Filesystem_Direct.
*
* @since 1.14.4
* @return object A WP_Filesystem_Direct instance.
*/
public function get_filesystem() {
global $wp_filesystem;
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
return $wp_filesystem;
}
}
/**
* Prepare if class 'BSF_SP_Helper' exist.
* Kicking this off by calling 'get_instance()' method
*/
BSF_SP_Helper::get_instance();
}

View File

@@ -1,233 +0,0 @@
<?php
/**
* Schema Pro Blocks Initializer
*
* Enqueue CSS/JS of all the blocks.
*
* @since 2.2.0
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* BSF_SP_Init_Blocks.
*
* @package Schema Pro
*/
class BSF_SP_Init_Blocks {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Hook: Frontend assets.
add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) );
// Hook: Editor assets.
add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ), 15 );
add_filter( 'block_categories_all', array( $this, 'register_block_category' ), 10, 2 );
}
/**
* Gutenberg block category for Schema Pro.
*
* @param array $categories Block categories.
* @since 2.2.0
*/
public function register_block_category( $categories ) {
return array_merge(
$categories,
array(
array(
'slug' => 'wpsp',
'title' => __( 'Schema Pro', 'wp-schema-pro' ),
),
)
);
}
/**
* Enqueue Gutenberg block assets for both frontend + backend.
*
* @since 2.2.0
*/
public function block_assets() {
$post = get_post();
/**
* Filters the post to build stylesheet for.
*
* @param \WP_Post $post The global post.
*/
$post = apply_filters( 'wpsp_post_for_stylesheet', $post );
if ( false === has_blocks( $post ) ) {
return;
}
if ( false === BSF_SP_Helper::$wpsp_flag ) {
return;
}
wp_enqueue_style(
'wpsp-block-css', // Handle.
BSF_AIOSRS_PRO_URI . 'dist/style-blocks.css', // Block style CSS.
array(),
BSF_AIOSRS_PRO_VER
);
$blocks = BSF_SP_Config::get_block_attributes();
$block_assets = BSF_SP_Config::get_block_assets();
foreach ( $blocks as $slug => $value ) {
$js_assets = ( isset( $blocks[ $slug ]['js_assets'] ) ) ? $blocks[ $slug ]['js_assets'] : array();
$css_assets = ( isset( $blocks[ $slug ]['css_assets'] ) ) ? $blocks[ $slug ]['css_assets'] : array();
foreach ( $js_assets as $asset_handle => $val ) {
// Scripts.
wp_register_script(
$val, // Handle.
$block_assets[ $val ]['src'],
$block_assets[ $val ]['dep'],
BSF_AIOSRS_PRO_VER,
true
);
$skip_editor = isset( $block_assets[ $val ]['skipEditor'] ) ? $block_assets[ $val ]['skipEditor'] : false;
if ( is_admin() && false === $skip_editor ) {
wp_enqueue_script( $val );
}
}
foreach ( $css_assets as $asset_handle => $val ) {
// Styles.
wp_register_style(
$val, // Handle.
$block_assets[ $val ]['src'],
$block_assets[ $val ]['dep'],
BSF_AIOSRS_PRO_VER
);
if ( is_admin() ) {
wp_enqueue_style( $val );
}
}
}
} // End function editor_assets().
/**
* Enqueue Gutenberg block assets for backend editor.
*
* @since 2.2.0
*/
public function editor_assets() {
$wpsp_ajax_nonce = wp_create_nonce( 'wpsp_ajax_nonce' );
$script_dep_path = BSF_AIOSRS_PRO_DIR . 'dist/blocks.asset.php';
$script_info = file_exists( $script_dep_path )
? include $script_dep_path
: array(
'dependencies' => array(),
'version' => BSF_AIOSRS_PRO_VER,
);
$script_dep = array_merge( $script_info['dependencies'], array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor', 'wp-api-fetch' ) );
// Scripts.
wp_enqueue_script(
'wpsp-block-editor-js', // Handle.
BSF_AIOSRS_PRO_URI . 'dist/blocks.js',
$script_dep, // Dependencies, defined above.
$script_info['version'], // BSF_AIOSRS_PRO_VER.
true // Enqueue the script in the footer.
);
// Common Editor style.
wp_enqueue_style(
'wpsp-block-common-editor-css', // Handle.
BSF_AIOSRS_PRO_URI . 'wpsp-blocks/assets/css/blocks.commoneditorstyle.build.css', // Block editor CSS.
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
BSF_AIOSRS_PRO_VER
);
$blocks = array();
$saved_blocks = BSF_SP_Admin_Helper::get_admin_settings_option( '_wpsp_blocks' );
if ( is_array( $saved_blocks ) ) {
foreach ( $saved_blocks as $slug => $data ) {
$_slug = 'wpsp/' . $slug;
$current_block = BSF_SP_Config::$block_attributes[ $_slug ];
if ( isset( $current_block['is_child'] ) && $current_block['is_child'] ) {
continue;
}
if ( isset( $current_block['is_active'] ) && ! $current_block['is_active'] ) {
continue;
}
if ( isset( $saved_blocks[ $slug ] ) && ( 'disabled' === $saved_blocks[ $slug ] ) ) {
array_push( $blocks, $_slug );
}
}
}
wp_localize_script(
'wpsp-block-editor-js',
'wpsp_blocks_info',
array(
'blocks' => BSF_SP_Config::get_block_attributes(),
'category' => 'wpsp',
'ajax_url' => admin_url( 'admin-ajax.php' ),
'tablet_breakpoint' => WPSP_TABLET_BREAKPOINT,
'mobile_breakpoint' => WPSP_MOBILE_BREAKPOINT,
'wpsp_ajax_nonce' => $wpsp_ajax_nonce,
'wpsp_home_url' => home_url(),
'wpsp_base_url' => BSF_AIOSRS_PRO_URI,
'wpsp_icons' => $this->get_svg_icons(),
)
);
} // End function editor_assets().
/**
* Get the SVG icons.
*/
private function get_svg_icons() {
$file_url = BSF_AIOSRS_PRO_URI . 'wpsp-config/controls/WPSPIcon.json';
$response = wp_remote_get( $file_url );
if ( is_wp_error( $response ) ) {
return array(); // Return an empty array if there's an error.
}
$body = wp_remote_retrieve_body( $response );
$icons = json_decode( $body, true );
return is_array( $icons ) ? $icons : array();
}
}
/**
* Prepare if class 'BSF_SP_Init_Blocks' exist.
* Kicking this off by calling 'get_instance()' method
*/
BSF_SP_Init_Blocks::get_instance();

View File

@@ -1,79 +0,0 @@
<?php
/**
* Schema Pro Blocks Loader.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_SP_Loader' ) ) {
/**
* Class BSF_Schema_Pro_Loader.
*/
final class BSF_SP_Loader {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
$this->wpsp_define_constants();
$this->wpsp_load_plugin();
}
/**
* Defines all constants
*
* @since 2.2.0
*/
public function wpsp_define_constants() {
define( 'SP_SLUG', 'wpsp' );
define( 'WPSP_TABLET_BREAKPOINT', '976' );
define( 'WPSP_MOBILE_BREAKPOINT', '767' );
}
/**
* Loads plugin files.
*
* @since 2.2.0
*
* @return void
*/
public function wpsp_load_plugin() {
require_once BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-init-blocks.php';
require_once BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-helper.php';
require_once BSF_AIOSRS_PRO_DIR . 'wpsp-blocks/classes/class-bsf-sp-admin-helper.php';
}
/**
* Prepare if class 'BSF_SP_Loader' exist.
* Kicking this off by calling 'get_instance()' method
*/
}
BSF_SP_Loader::get_instance();
}