| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugisn Options value |
| 4 |
* return on/off |
| 5 |
*/ |
| 6 |
function ever_compare_get_option( $option, $section, $default = '' ){ |
| 7 |
$options = get_option( $section ); |
| 8 |
if ( isset( $options[$option] ) ) { |
| 9 |
return $options[$option]; |
| 10 |
} |
| 11 |
return $default; |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* [ever_compare_woocommerce_installed] |
| 16 |
* @return [boolean] |
| 17 |
*/ |
| 18 |
function ever_compare_woocommerce_installed() { |
| 19 |
return class_exists( 'WooCommerce' ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Get Post List |
| 24 |
* return array |
| 25 |
*/ |
| 26 |
function ever_compare_get_post_list( $post_type = 'page' ){ |
| 27 |
$options = array(); |
| 28 |
$options['0'] = __('Select','ever-compare'); |
| 29 |
$perpage = -1; |
| 30 |
$all_post = array( 'posts_per_page' => $perpage, 'post_type'=> $post_type ); |
| 31 |
$post_terms = get_posts( $all_post ); |
| 32 |
if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ){ |
| 33 |
foreach ( $post_terms as $term ) { |
| 34 |
$options[ $term->ID ] = $term->post_title; |
| 35 |
} |
| 36 |
return $options; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
/** |
| 42 |
* Get Post List |
| 43 |
* return array |
| 44 |
*/ |
| 45 |
function ever_compare_get_available_attributes() { |
| 46 |
$attribute_list = array(); |
| 47 |
|
| 48 |
if( function_exists( 'wc_get_attribute_taxonomies' ) ) { |
| 49 |
$attribute_list = wc_get_attribute_taxonomies(); |
| 50 |
} |
| 51 |
|
| 52 |
$checked = !empty( ever_compare_get_option( 'show_fields', 'ever_compare_table_settings_tabs' ) ) ? ever_compare_get_option( 'show_fields', 'ever_compare_table_settings_tabs' ) : array(); |
| 53 |
|
| 54 |
$fields = array( |
| 55 |
'title' => esc_html__( 'Title', 'ever-compare' ), |
| 56 |
'ratting' => esc_html__( 'Ratting', 'ever-compare' ), |
| 57 |
'price' => esc_html__( 'Price', 'ever-compare' ), |
| 58 |
'add_to_cart' => esc_html__( 'Add To Cart', 'ever-compare' ), |
| 59 |
'description' => esc_html__( 'Description', 'ever-compare' ), |
| 60 |
'availability' => esc_html__( 'Availability', 'ever-compare' ), |
| 61 |
'sku' => esc_html__( 'Sku', 'ever-compare' ), |
| 62 |
'weight' => esc_html__( 'Weight', 'ever-compare' ), |
| 63 |
'dimensions' => esc_html__( 'Dimensions', 'ever-compare' ), |
| 64 |
); |
| 65 |
|
| 66 |
$fields = array_merge( $checked, $fields ); |
| 67 |
|
| 68 |
if ( count( $attribute_list ) > 0 ) { |
| 69 |
foreach ( $attribute_list as $attribute ) { |
| 70 |
$fields[ 'pa_' . $attribute->attribute_name ] = $attribute->attribute_label; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
return $fields; |
| 75 |
} |