data['is_breakdance'] = true;
}
/*
* Show labels for product title on single page
*/
function breakdance_render_element_html( $elementHtml, $node ) {
if ( is_singular('product') && $node && isset( $node['data'] ) && isset( $node['data']['type'] ) && $node['data']['type'] === 'EssentialElements\\WooProductTitle' ) {
$elementHtml = AWL_Label_Display::instance()->show_label( 'before_title' ) . $elementHtml;
}
// Integration for WooCommerce Gallery for Breakdance plugin
if ( is_singular('product') && $node && isset( $node['data'] ) && isset( $node['data']['type'] ) && $node['data']['type'] === 'WPSix\\WooGallery' ) {
$on_image_label = AWL_Label_Display::instance()->show_label( 'on_image' ) ;
if ( strpos( $elementHtml, 'woo-gallery-main-swiper' ) !== false ) {
$elementHtml = preg_replace( '/
__( "Breakdance: Is Breakdance block", "advanced-woo-labels" ),
"id" => "awl_is_breakdance",
"type" => "bool",
"operators" => "equals",
);
return $options;
}
/*
* Add custom condition rule method
*/
public function condition_rules( $rules ) {
$rules['awl_is_breakdance'] = array( $this, 'awl_is_breakdance' );
return $rules;
}
/*
* Condition: Is Breakdance block
*/
public function awl_is_breakdance( $condition_rule ) {
global $product;
$match = false;
$operator = $condition_rule['operator'];
$value = $condition_rule['value'];
$compare_value = 'false';
if ( isset( $this->data['is_breakdance'] ) && $this->data['is_breakdance'] ) {
$compare_value = 'true';
}
if ( 'equal' == $operator ) {
$match = ($compare_value == $value);
} elseif ( 'not_equal' == $operator ) {
$match = ($compare_value != $value);
}
return $match;
}
}
endif;
AWL_Breakdance::instance();