Created
October 12, 2018 10:38
-
-
Save anik/11cea42894200d147b39e1151912e9e5 to your computer and use it in GitHub Desktop.
Code 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WPPB_Dokan_Shortcode { | |
public function get_name(){ | |
return 'wppb_dokan_shortcode'; | |
} | |
public function get_icon() { | |
return 'wppb-font-Page-grid'; | |
} | |
public function get_category_name(){ | |
return __( 'Dokan Shortcode', 'wp-page-builder-dokan' ); | |
} | |
public function get_title(){ | |
return __( 'Dokan Shortcode', 'wp-page-builder-dokan' ); | |
} | |
# headline Settings Fields | |
public function get_settings() { | |
$settings = array( | |
'product_shortcode' => array( | |
'type' => 'select', | |
'title' => __('Select Column', 'wp-page-builder-dokan'), | |
'values' => array( | |
'[dokan-dashboard]' => __( 'Dashboard', 'wp-page-builder-dokan' ), | |
'[dokan-stores]' => __( 'Store Listing', 'wp-page-builder-dokan' ), | |
'[dokan-my-orders]' => __( 'My Orders', 'wp-page-builder-dokan' ), | |
'[dokan-top-rated-product]' => __( 'Top Rated Products', 'wp-page-builder-dokan' ), | |
'dokan-best-selling-product' => __( 'Best Selling Products', 'wp-page-builder-dokan' ), | |
'[dokan-customer-migration]' => __( 'Become a Vendor ', 'wp-page-builder-dokan' ), | |
), | |
'std' => 'dokan-best-selling-product', | |
), | |
'products_number' => array( | |
'type' => 'number', | |
'title' => __('Number of Slider', 'wp-page-builder-dokan'), | |
'std' => '8', | |
), | |
'seller_id_switch' => array( | |
'type' => 'switch', | |
'title' => __('Own ID','wp-pagebuilder'), | |
'std' => '1', | |
'depends' => array(array('product_shortcode', '==', 'dokan-best-selling-product')), | |
), | |
'seller_id' => array( | |
'type' => 'text', | |
'title' => __('Seller ID', 'wp-page-builder-dokan'), | |
'std' => '4', | |
'depends' => array(array('seller_id_switch', '!=', '1')), | |
), | |
); | |
return $settings; | |
} | |
# Title Render HTML | |
public function render($data = null){ | |
$settings = $data['settings']; | |
$shortcode = $settings['product_shortcode']; | |
$products_number = $settings['products_number']; | |
$seller_id_switch = $settings['seller_id_switch']; | |
$seller_id = $settings['seller_id']; | |
if( $shortcode == 'dokan-best-selling-product' ){ | |
if( $seller_id_switch ){ | |
$shortcode = '[dokan-best-selling-product no_of_product="'.$products_number.'" seller_id="'.get_current_user_id().'" ]'; | |
}else{ | |
$shortcode = '[dokan-best-selling-product no_of_product="'.$products_number.'" seller_id="'.$seller_id.'" ]'; | |
} | |
} | |
return do_shortcode( $shortcode ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment