/** * Return an instance of this class. * * @since 0.1.0 * * @return object A single instance of this class. */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
function category_mappings_settings_callback() { echo '</td></tr><tr>'; $option = get_option($this->plugin_slug . '_category_mappings', false); $pricelist_cats = WC_Pricefiles::get_instance()->get_category_list(); $shop_categories = get_terms('product_cat'); echo '<tr><th>' . __('Shop categories', $this->plugin_slug) . '</th>'; echo '<th>' . __('Pricefile categories', $this->plugin_slug) . '</th></tr>'; foreach ($shop_categories as $shop_cat) { if ($option) { $current = $option[$shop_cat->term_id]; } else { $current = 0; } echo '<tr style="border-bottom: 1px solid #EEE; max-width: 750px"><td><label>' . $shop_cat->name . ' (' . $shop_cat->count . '): </label></td>'; echo '<td><select id="woocommerce_pricefiles_category_mappings_' . $shop_cat->slug . '" name="' . $this->plugin_slug . '_category_mappings[' . $shop_cat->term_id . ']" class="pricelist_cat_mapping" data-placeholder="' . __('Select category', $this->plugin_slug) . '" >'; echo '<option value=""></option>'; foreach ($pricelist_cats as $plc_id => $plc_name) { echo '<option value="' . esc_attr($plc_id) . '" ' . selected($plc_id, $current, false) . '>' . $plc_name . '</option>'; } echo '</select></td></tr>'; } echo '<tr><td><label for="' . $this->plugin_slug . '_category_mappings_overwrite"><input type="checkbox" id="' . $this->plugin_slug . '_category_mappings_overwrite" name="' . $this->plugin_slug . '_category_mappings[overwrite]" value="1" /> ' . __('Overwrite existing pricefile categories', $this->plugin_slug) . '</label></td></tr>'; }
function WC_Pricefiles() { require_once WP_PRICEFILES_PLUGIN_PATH . 'includes/pricefiles.php'; return WC_Pricefiles::get_instance(); }
$all_terms = get_terms($attribute_taxonomy_name, 'orderby=name&hide_empty=0'); if ($all_terms) { $m = get_post_meta($post->ID, WC_PRICEFILES_PLUGIN_SLUG . '_manufacturer', true); if (empty($m)) { $manufacturer_field['options'][''] = __('Choose manufacturer', WC_PRICEFILES_PLUGIN_SLUG); } foreach ($all_terms as $term) { //echo '<option value="' . esc_attr($term->slug) . '" ' . selected($term->slug, $current, false) . '>' . $term->name . '</option>'; $manufacturer_field['options'][$term->slug] = $term->name; } woocommerce_wp_select($manufacturer_field); } else { _e(sprintf('You need to add manufacturers to use the manufaturer field.<br />You can add manufacturers <a href="%s">here</a>', admin_url('edit-tags.php?taxonomy=pa_manufacturer&post_type=product')), WC_PRICEFILES_PLUGIN_SLUG); } } $pricelist_cats = WC_Pricefiles::get_instance()->get_category_list(); // Ensure it exists if (!empty($pricelist_cats)) { $current = get_post_meta($post->ID, '_pricelist_cat', true); $category_field = array('id' => WC_PRICEFILES_PLUGIN_SLUG . '_pricelist_cat', 'label' => __('Category'), 'class' => 'chosen-select', 'options' => array()); $c = get_post_meta($post->ID, WC_PRICEFILES_PLUGIN_SLUG . '_pricelist_cat', true); if (empty($c)) { $category_field['options'][''] = __('Choose category', WC_PRICEFILES_PLUGIN_SLUG); } foreach ($pricelist_cats as $id => $name) { $category_field['options'][esc_attr($id)] = esc_attr($name); } woocommerce_wp_select($category_field); } // Prisjakt Status $current = get_post_meta($post->ID, '_prisjakt_status', true);
function pricefile_display_callback() { global $wc_pricefiles_list; $pricefile_base_url = get_bloginfo('url') . '/?pricefile='; echo '<p>' . __('Copy and send to the respective service.', $this->plugin_slug) . '</p>'; $available_pricefiles = WC_Pricefiles::get_instance()->get_available_pricefiles(); foreach ($available_pricefiles as $slug => $data) { echo '<h4>' . $data['name'] . '</h4>'; $last_updated = get_option(WC_PRICEFILES_PLUGIN_SLUG . '_cache_last_updated_' . $slug, false); echo '<p>'; echo '<input class="wide" type="text" size="110" value="' . $pricefile_base_url . $slug . '" disabled /><br />'; echo '<span class="description"></span>'; if ($last_updated && $this->plugin_options['use_cache'] == 1) { echo 'Last updated: ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), current_time('timestamp')); } echo '</p>'; } echo '<p>'; echo _e('More information:', $this->plugin_slug) . '<br />'; foreach ($available_pricefiles as $slug => $data) { if (!empty($data['info_link'])) { echo '<a href="' . $data['info_link'] . '">' . $data['name'] . '</a><br />'; } } echo '</p>'; }