token = WooBuilder::$token;
$this->url = WooBuilder::$url;
$this->path = WooBuilder::$path;
$this->version = WooBuilder::$version;
} // End __construct()
/**
* Adds admin only actions
* @action admin_init
*/
public function admin_init() {
add_filter( 'pootlepb_builder_post_types', array( $this, 'remove_ppb_product' ), 99 );
register_setting( 'pootlepage-display', 'pootlepb-template-product' );
add_settings_field( 'responsive', __( 'WooBuilder starter template', 'ppb-panels' ), array(
$this,
'template_product_field',
), 'pootlepage-display', 'display' );
}
public function template_product_field() {
$selected = get_option( 'pootlepb-template-product' );
$prods = get_posts( [
'post_status' => 'publish',
'numberposts' => 99,
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'panels_data',
'compare' => 'EXISTS',
),
)
] );
?>
This product's page builder rows will be used as starter for all products.
>
token );
} else {
_e( 'Check this to enable', $this->token );
}
?>
post_type == 'product' ) {
wp_enqueue_script( $this->token, "$this->url/assets/edit-product.js", array( 'jquery' ) );
$nonce_url = wp_nonce_url( get_the_permalink( $post->ID ), 'ppb-live-edit-nonce', 'ppbLiveEditor' );
$nonce_url .= '&woobuilder-nonce=' . wp_create_nonce( 'enable_ppb_product_builder' );
wp_localize_script( $this->token, 'wcProductBuilderLiveEditLink', $nonce_url );
echo <<
a.button.pootle {
margin: .5em 0 .25em .5em;
}
button.wp-switch-editor {
padding: .5em .7em;
}
.field.field-woobuilder .chosen-choices .search-choice {
display: block;
float: none;
margin: 5px 0;
}
HTML;
}
}
/**
* Removes product from ppb supported posts on admin end.
* @param $post_types Post types
* @return array Post types
*/
public function remove_ppb_product( $post_types ) {
$post_types = array_unique( $post_types );
unset( $post_types[ array_search( 'product', $post_types ) ] );
return $post_types;
}
/**
* Adds editor panel tab
* @param array $tabs The array of tabs
* @return array Tabs
* @filter pootlepb_content_block_tabs
* @since 1.0.0
*/
public function content_block_tabs( $tabs ) {
if ( WooBuilder::is_ppb_product() ) {
$tabs[ $this->token ] = array(
'label' => 'Product Builder',
'priority' => 5,
);
}
return $tabs;
}
/**
* Adds content block panel fields
* @param array $fields Fields to output in content block panel
* @return array Tabs
* @filter pootlepb_content_block_fields
* @since 1.0.0
*/
public function content_block_fields( $fields ) {
if ( WooBuilder::is_ppb_product() ) {
$fields[ $this->token ] = array(
'name' => 'Display',
'type' => 'multi-select',
'priority' => 1,
'options' => array(
'' => 'Choose...',
'[ppb_product_title]' => 'Product Title',
'[ppb_product_images]' => 'Product images',
'[ppb_product_short_description]' => 'Short Description',
'[ppb_product_price]' => 'Product Price',
'[ppb_product_add_to_cart]' => 'Add to Cart',
'[ppb_product_tabs]' => 'Product tabs',
'[ppb_product_reviews]' => 'Product reviews',
'[ppb_product_related]' => 'Related products',
'[ppb_product_rating]' => 'Product rating',
),
'tab' => $this->token,
);
}
return $fields;
}
}