array('label' => __('Identity', 'ai-eshop-optimizer'), 'icon' => 'id-card'), 'about' => array('label' => __('About', 'ai-eshop-optimizer'), 'icon' => 'book-open'), 'display' => array('label' => __('Display', 'ai-eshop-optimizer'), 'icon' => 'eye'), 'related' => array('label' => __('Related', 'ai-eshop-optimizer'), 'icon' => 'link'), 'products' => array('label' => __('Products', 'ai-eshop-optimizer'), 'icon' => 'package'), ); } public function get_tab_base_url() { $tax = AIEO_DMM_Need_Extras_Data::managed_taxonomies(); $tax = !empty($tax) ? (string) reset($tax) : 'pa_need'; return admin_url('edit-tags.php?taxonomy=' . rawurlencode($tax)); } public function register_hooks() { if (!is_admin()) { return; } foreach (AIEO_DMM_Need_Extras_Data::managed_taxonomies() as $tax) { add_action($tax . '_edit_form_fields', array($this, 'render_term_extras'), 1, 2); add_action('edited_' . $tax, array($this, 'save_term_extras'), 10, 2); add_action('created_' . $tax, array($this, 'save_term_extras'), 10, 2); } add_action('admin_enqueue_scripts', array($this, 'enqueue_term_admin_assets')); } public function render_term_extras($term, $taxonomy) { if (!is_object($term) || !isset($term->term_id)) { return; } if (!in_array($taxonomy, AIEO_DMM_Need_Extras_Data::managed_taxonomies(), true)) { return; } $term_id = (int) $term->term_id; $row = AIEO_DMM_Need_Extras_Data::get($taxonomy, $term_id); $icon_url = $row['icon_image_id'] ? wp_get_attachment_image_url((int) $row['icon_image_id'], 'thumbnail') : ''; $hero_url = $row['hero_image_id'] ? wp_get_attachment_image_url((int) $row['hero_image_id'], 'medium') : ''; $hidden = (string) get_term_meta($term_id, 'aieo_hidden', true) === 'yes'; global $wpdb; $product_count = (int) $wpdb->get_var($wpdb->prepare( "SELECT COUNT(DISTINCT tr.object_id) FROM {$wpdb->term_relationships} tr JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id JOIN {$wpdb->posts} p ON p.ID = tr.object_id AND p.post_type = 'product' AND p.post_status = 'publish' WHERE tt.taxonomy = %s AND tt.term_id = %d", $taxonomy, $term_id )); $bulk_admin_url = admin_url('admin.php?page=ai-eshop-dmm&dmm_tab=product_needs'); ?>

'aieo_ne[about_text]', 'textarea_rows' => 8, 'media_buttons' => true, 'teeny' => false, 'quicktags' => true, ) ); ?>

'aieo_ne[footer_text]', 'textarea_rows' => 6, 'media_buttons' => true, 'teeny' => false, 'quicktags' => true, ) ); ?>

' . esc_html__('Related-tab component unavailable.', 'ai-eshop-optimizer') . '

'; } ?>

0): ?> get_col($wpdb->prepare( "SELECT p.ID FROM {$wpdb->term_relationships} tr JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id JOIN {$wpdb->posts} p ON p.ID = tr.object_id AND p.post_type = 'product' AND p.post_status = 'publish' WHERE tt.taxonomy = %s AND tt.term_id = %d ORDER BY p.ID DESC LIMIT 10", $taxonomy, $term_id )); ?>

taxonomy, AIEO_DMM_Need_Extras_Data::managed_taxonomies(), true)) { return; } $raw = wp_unslash($_POST['aieo_ne']); if (!is_array($raw)) { return; } $patch = array(); if (isset($raw['icon_image_id'])) { $patch['icon_image_id'] = (int) $raw['icon_image_id']; } if (isset($raw['hero_image_id'])) { $patch['hero_image_id'] = (int) $raw['hero_image_id']; } if (isset($raw['headline'])) { $patch['headline'] = sanitize_text_field((string) $raw['headline']); } if (isset($raw['about_text'])) { $patch['about_text'] = wp_kses_post((string) $raw['about_text']); } if (isset($raw['priority'])) { $patch['priority'] = (int) $raw['priority']; } if (isset($raw['footer_text'])) { $patch['footer_text'] = wp_kses_post((string) $raw['footer_text']); } AIEO_DMM_Need_Extras_Data::save($term->taxonomy, $term_id, $patch); $hidden = !empty($raw['hidden_from_frontend']); update_term_meta($term_id, 'aieo_hidden', $hidden ? 'yes' : ''); } public function enqueue_term_admin_assets($hook) { if ($hook !== 'term.php') { return; } $tax = isset($_GET['taxonomy']) ? sanitize_key(wp_unslash($_GET['taxonomy'])) : ''; if (!in_array($tax, AIEO_DMM_Need_Extras_Data::managed_taxonomies(), true)) { return; } wp_enqueue_media(); wp_enqueue_editor(); wp_enqueue_style( 'aieo-dmm-category-extras-admin', AIEO_URI . 'assets/css/aieo-dmm-category-extras-admin.css', array(), AIEO_VERSION ); wp_enqueue_script( 'aieo-dmm-category-extras-admin', AIEO_URI . 'assets/js/aieo-dmm-category-extras-admin.js', array('jquery'), AIEO_VERSION, true ); wp_localize_script('aieo-dmm-category-extras-admin', 'aieoCategoryExtras', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce(AIEO_DMM::NONCE_ACTION), 'i18n' => array( 'noResults' => __('No matches.', 'ai-eshop-optimizer'), 'searching' => __('Searching…', 'ai-eshop-optimizer'), 'pickImage' => __('Select image', 'ai-eshop-optimizer'), 'useImage' => __('Use this image', 'ai-eshop-optimizer'), ), )); } public function render_subtab() { global $wpdb; $count = (int) $wpdb->get_var('SELECT COUNT(*) FROM ' . AIEO_DMM_Need_Extras_Data::table()); list($open, $close) = AIEO_DMM_UI::card(array( 'anchor' => 'need-extras-overview', 'icon' => 'circle-question-mark', 'title' => __('Per-need metadata', 'ai-eshop-optimizer'), 'description' => __('Per-need icon, hero, headline, about text, footer, priority + bidirectional Related panel. Edit individual needs at WooCommerce → Products → Attributes → Needs → click a need.', 'ai-eshop-optimizer'), 'col' => 2, )); echo $open; echo '
'; echo \Rooster\Admin\Ui::stat(__('Need metadata rows', 'ai-eshop-optimizer'), number_format_i18n($count)); echo '
'; $link = \Rooster\Admin\Ui::button( __('Open Product → Needs bulk editor', 'ai-eshop-optimizer'), array('href' => admin_url('admin.php?page=ai-eshop-dmm&dmm_tab=product_needs')) ); echo '

' . $link . '

'; echo $close; } }