atkp_posttypes_product_init(); add_action( 'admin_menu', array( $this, 'atkp_product_adminmenus' ), 10 ); add_action( 'admin_footer', array( $this, 'atkp_product_footer_function' ) ); //add_action('parent_file', array($this, 'keep_taxonomy_menu_open')); } function atkp_product_footer_function() { global $pagenow; $cpt = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ( $pagenow == 'edit.php' ) && ( $cpt == ATKP_PRODUCT_POSTTYPE ) ) { ?> caption == '' ) { $taxonomy->caption = $taxonomy->name; } if ( $taxonomy->captionplural == '' ) { $taxonomy->captionplural = $taxonomy->caption; } if ( $taxonomy->showui && $taxonomy->issystemfield ) { add_submenu_page( ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin', $taxonomy->captionplural, $taxonomy->captionplural, 'edit_posts', 'edit-tags.php?taxonomy=' . $taxonomy->name, false ); } } } add_filter( 'parent_file', function ( $file ) { $screen = get_current_screen(); if ( ! isset( $screen->taxonomy ) || ! isset( $screen->base ) ) { return $file; } $set_file = false; if ( 'edit-tags' === $screen->base ) { $taxonomies = atkp_udtaxonomy::load_taxonomies(); if ( $taxonomies != null ) { foreach ( $taxonomies as $taxonomy ) { if ( $taxonomy->showui && $taxonomy->issystemfield ) { if ( $taxonomy->name === $screen->taxonomy ) { $set_file = true; } } } } } // in my case I drilled down to if($screen->id...); I used what you posted in your if clause above if ( $set_file ) { $file = ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin'; } //probably need to set this as a string; for the parent slug represented by $this->plugin_slug ; return $file; } ); } function atkp_posttypes_product_init() { $this->register_productPostType(); $this->register_filter(); if ( is_admin() ) { add_action( 'add_meta_boxes', array( &$this, 'product_boxes' ) ); add_action( 'save_post', array( &$this, 'product_detail_save' ) ); add_thickbox(); ATKPTools::add_column( ATKP_PRODUCT_POSTTYPE, esc_html__( 'Status', 'affiliate-toolkit-starter' ), function ( $post_id ) { $products = atkp_product_collection::load( $post_id ); $prd = $products->get_main_product(); $selectedshopid = $prd->shopid; if ( $prd->shop == null ) { try { if ( $selectedshopid != '' && atkp_shop::exists( $selectedshopid ) ) { $shps = atkp_shop::load( $selectedshopid ); } } catch ( Exception $ex ) { echo 'parent shop not found. '; $shps = null; } } else { $shps = $prd->shop; } echo '' . esc_html__( 'ID', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $post_id ) . ', '; $shop_config = $prd->get_shops_from_config(); if ( ! isset( $shps ) || $shps == null ) { echo '' . esc_html__( 'No shop', 'affiliate-toolkit-starter' ) . ''; } else { $logourls = array(); foreach ( $products->products as $product ) { $shop_config = array_diff( $shop_config, array( $product->shopid ) ); if ( $product->shop != null ) { if ( $product->shop->get_smalllogourl() != '' ) { $logourls[] = '' . esc_attr( $product->shop->get_title() ) . ''; } else { $logourls[] = '' . ( esc_html( $product->shop->get_title() ) ) . ''; } if ( count( $logourls ) > 5 ) { break; } } } echo '' . esc_html__( 'Shops', 'affiliate-toolkit-starter' ) . ': ' . wp_kses( implode( ',', $logourls ), array( 'a' => array( 'title' => array(), 'target' => array(), 'href' => array() ), 'img' => array( 'alt' => array(), 'src' => array(), 'style' => array() ) ) ) . ''; } if ( count( $shop_config ) > 0 ) { $logourls = array(); foreach ( $shop_config as $shop_co ) { $myshop = atkp_shop::load( ( $shop_co )); if ( $myshop == null ) { continue; } if ( $myshop->get_smalllogourl() != '' ) { $logourls[] = '' . esc_attr( $myshop->get_title() ) . ''; } else { $logourls[] = '' . ( esc_html( $myshop->get_title() ) ) . ''; } } echo '
' . esc_html__( 'No result', 'affiliate-toolkit-starter' ) . ': ' . wp_kses( implode( ',', $logourls ), array( 'a' => array( 'title' => array(), 'target' => array(), 'href' => array() ), 'img' => array( 'alt' => array(), 'src' => array(), 'style' => array() ) ) ) . ''; } $updatedon = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_updatedon' ); if ( isset( $updatedon ) && $updatedon != '' ) { $infotext = esc_html__( '%refresh_date% at %refresh_time%', 'affiliate-toolkit-starter' ); $infotext = str_replace( '%refresh_date%', ATKPTools::get_formatted_date( $updatedon ), $infotext ); $infotext = str_replace( '%refresh_time%', ATKPTools::get_formatted_time( $updatedon ), $infotext ); echo '
' . esc_html__( 'Updated on', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $infotext ) . ''; } $message = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_message' ); if ( isset( $message ) && $message != '' ) { echo '
' . esc_html__( 'Message', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $message ) . ''; } do_action( 'atkp_product_status_column', $post_id ); }, 3 ); add_action( 'admin_enqueue_scripts', array( $this, 'image_enqueue' ) ); add_action( 'admin_head', array( $this, 'hidey_admin_head' ) ); ATKPTools::add_column( ATKP_PRODUCT_POSTTYPE, esc_html__( 'Main image', 'affiliate-toolkit-starter' ), function ( $post_id ) { $prodcollection = atkp_product_collection::load( $post_id ); $product = $prodcollection->get_main_product(); $imageurl = $product->smallimageurl; if ( $imageurl == '' ) { $imageurl = $product->mediumimageurl; } if ( $imageurl == '' ) { $imageurl = $product->largeimageurl; } if ( $imageurl != '' ) { echo ''; } }, 1 ); add_action( 'before_delete_post', 'atkp_delete_images' ); function atkp_delete_images( $post_id ) { // We check if the global post type isn't ours and just return global $post_type; if ( $post_type == ATKP_PRODUCT_POSTTYPE ) { if ( has_post_thumbnail( $post_id ) ) { $attachment_id = get_post_thumbnail_id( $post_id ); if ( $attachment_id ) { wp_delete_attachment( $attachment_id, true ); } } do_action( 'atkp_product_delete_images', $post_id ); } } } } function hidey_admin_head() { echo ''; } /** * Loads the image management javascript */ function image_enqueue() { global $typenow; if ( $typenow == ATKP_PRODUCT_POSTTYPE ) { wp_enqueue_media(); // Registers and enqueues the required javascript. wp_register_script( 'meta-box-image', plugin_dir_url( ATKP_PLUGIN_FILE ) . 'js/meta-box-image.js', array( 'jquery' ), ATKP_UPDATE_VERSION, true ); wp_localize_script( 'meta-box-image', 'meta_image', array( 'title' => esc_html__( 'Choose or Upload an image', 'affiliate-toolkit-starter' ), 'button' => esc_html__( 'Use this image', 'affiliate-toolkit-starter' ), ) ); wp_enqueue_script( 'meta-box-image' ); } } function register_filter() { add_filter( 'parse_query', array( &$this, 'admin_posts_filter' ) ); add_action( 'restrict_manage_posts', array( &$this, 'admin_posts_filter_restrict_manage_posts' ) ); } function admin_posts_filter( $query ) { if ( ! $query->is_main_query() ) { return; } $filterfield = ATKPTools::get_get_parameter( ATKP_PLUGIN_PREFIX . '_filterfield', 'string' ); $posttype = ATKPTools::get_get_parameter( 'post_type', 'string' ); if ( $posttype == ATKP_PRODUCT_POSTTYPE && ! self::$overridefilter ) { global $pagenow; if ( is_admin() && $pagenow == 'edit.php' && isset( $filterfield ) && $filterfield != '' ) { if ( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'atkp_product' ) { if ( $filterfield == 'filter_error' ) { $x = new atkp_producttable_helper(); $productids = $x->get_product_ids_with_error(); if ( empty( $productids ) ) { // keine fehlerhaften Produkte -> keine Beiträge anzeigen $query->query_vars['post__in'] = array( 0 ); } else { $query->query_vars['post__in'] = $productids; } } else if ( $filterfield == 'filter_saleprice' ) { $x = new atkp_producttable_helper(); $productids = $x->get_product_ids_without_saleprice(); if ( empty( $productids ) ) { // keine fehlerhaften Produkte -> keine Beiträge anzeigen $query->query_vars['post__in'] = array( 0 ); } else { $query->query_vars['post__in'] = $productids; } } else { $parts = explode( '_', $filterfield ); $sfilter = isset( $parts[1] ) ? $parts[1] : ''; $filds = array(); for ( $x = 1; $x < ( $sfilter == '' ? 2 : ( ATKP_FILTER_COUNT + 1 ) ); $x ++ ) { $filds[] = array( 'key' => ATKP_PRODUCT_POSTTYPE . '_shopid' . ( $x > 1 ? '_' . $x : '' ), 'value' => $sfilter, 'compare' => $sfilter != '' ? '=' : 'NOT EXISTS' ); } $filds['relation'] = 'OR'; $query->set( 'meta_query', $filds ); } remove_filter( 'parse_query', 'admin_posts_filter' ); } } } } private static $overridefilter; function admin_posts_filter_restrict_manage_posts() { $posttype = ATKPTools::get_get_parameter( 'post_type', 'string' ); if ( $posttype != ATKP_PRODUCT_POSTTYPE ) { return; } atkp_posttypes_product::$overridefilter = true; $shops = atkp_shop::get_list(); atkp_posttypes_product::$overridefilter = false; ?> esc_html__( 'Products', 'affiliate-toolkit-starter' ), 'singular_name' => esc_html__( 'Product', 'affiliate-toolkit-starter' ), 'add_new_item' => esc_html__( 'Add new Product', 'affiliate-toolkit-starter' ), 'edit_item' => esc_html__( 'Edit Product', 'affiliate-toolkit-starter' ), 'new_item' => esc_html__( 'New Product', 'affiliate-toolkit-starter' ), 'all_items' => esc_html__( 'Products', 'affiliate-toolkit-starter' ), 'view_item' => esc_html__( 'View Product', 'affiliate-toolkit-starter' ), 'search_items' => esc_html__( 'Search Products', 'affiliate-toolkit-starter' ), 'not_found' => esc_html__( 'No products found', 'affiliate-toolkit-starter' ), 'not_found_in_trash' => esc_html__( 'No products found in the Trash', 'affiliate-toolkit-starter' ), 'parent_item_colon' => '', 'menu_name' => esc_html__( 'AT Products', 'affiliate-toolkit-starter' ), ); $importProductimage = atkp_options::$loader->get_product_importimage(); $supports = array( 'title', 'author' ); if ( $importProductimage ) { $supports = array( 'title', 'thumbnail', 'author' ); } $args = array( 'labels' => $labels, 'description' => esc_html__( 'Holds our products and product specific data', 'affiliate-toolkit-starter' ), 'public' => false, // it's not public, it shouldn't have it's own permalink, and so on 'publicly_queryable' => false, // it shouldn't be queryable on the frontend 'show_ui' => true, // you should be able to edit it in wp-admin 'exclude_from_search' => true, // you should exclude it from search results 'show_in_nav_menus' => true, // you shouldn't be able to add it to menus 'has_archive' => false, // it shouldn't have archive page 'rewrite' => false, 'taxonomies' => array(), 'query_var' => true, 'menu_position' => 20, 'supports' => $supports, 'capability_type' => 'post', 'menu_icon' => plugin_dir_url( ATKP_PLUGIN_FILE ) . '/images/affiliate_toolkit_menu.png', 'show_in_menu' => ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin', ); $args = apply_filters( 'atkp_product_register_post_type', $args ); register_post_type( ATKP_PRODUCT_POSTTYPE, $args ); $taxonomies = atkp_udtaxonomy::load_taxonomies(); if ( $taxonomies != null ) { foreach ( $taxonomies as $taxonomy ) { //falls taxonomie bereits von anderem plugin installiert wurde if ( taxonomy_exists( $taxonomy->name ) || $taxonomy->name == '' ) { continue; } if ( $taxonomy->caption == '' ) { $taxonomy->caption = $taxonomy->name; } if ( $taxonomy->captionplural == '' ) { $taxonomy->captionplural = $taxonomy->caption; } $this->taxonomies[] = $taxonomy->name; $labels = array( 'name' => $taxonomy->captionplural, 'singular_name' => $taxonomy->caption, /* translators: %s: taxonomy name (plural) */ 'search_items' => sprintf( esc_html__( 'Search %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->captionplural ) ), /* translators: %s: taxonomy name (plural) */ 'all_items' => sprintf( esc_html__( 'All %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->captionplural ) ), /* translators: %s: taxonomy name (singular) */ 'edit_item' => sprintf( esc_html__( 'Edit %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->caption ) ), /* translators: %s: taxonomy name (singular) */ 'update_item' => sprintf( esc_html__( 'Update %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->caption ) ), /* translators: %s: taxonomy name (singular) */ 'add_new_item' => sprintf( esc_html__( 'Add New %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->caption ) ), /* translators: %s: taxonomy name (singular) */ 'new_item_name' => sprintf( esc_html__( 'New %s', 'affiliate-toolkit-starter' ), esc_html( $taxonomy->caption ) ), 'menu_name' => $taxonomy->captionplural ); // register taxonomy $taxs = array( ATKP_PRODUCT_POSTTYPE ); $taxs = apply_filters( 'atkp_taxonomy_posttypes', $taxs, $taxonomy ); $taxargs = array( 'taxonomies' => $taxs, 'hierarchical' => true, 'labels' => $labels, 'show_admin_column' => $taxonomy->isproductgroup, 'show_ui' => $taxonomy->showui, 'public' => false, 'update_count_callback' => '_update_generic_term_count', 'capabilities' => array( 'manage_terms' => 'edit_posts', 'edit_terms' => 'edit_posts', 'delete_terms' => 'edit_posts', 'assign_terms' => 'edit_posts' ), 'show_in_menu' => false, 'query_var' => true ); $taxargs = apply_filters( 'atkp_register_taxonomy', $taxargs, $taxonomy->name ); register_taxonomy( $taxonomy->name, $taxs, $taxargs ); } } } function keep_taxonomy_menu_open( $parent_file ) { global $current_screen; $taxonomy_current = $current_screen->taxonomy; if ( isset( $taxonomy_current ) && $taxonomy_current ) { foreach ( $this->taxonomies as $taxonomy ) { if ( $taxonomy->name == $taxonomy_current->name ) { $parent_file = ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin'; break; } } } if ( isset( $current_screen->post_type ) && $current_screen->post_type = 'atkp_template' ) { $parent_file = ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin'; } return $parent_file; } function product_boxes() { add_meta_box( ATKP_PRODUCT_POSTTYPE . '_shop_box', esc_html__( 'Filter Information', 'affiliate-toolkit-starter' ), array( &$this, 'product_shop_box_content' ), ATKP_PRODUCT_POSTTYPE, 'normal', 'high' ); add_meta_box( ATKP_PRODUCT_POSTTYPE . '_products_box', esc_html__( 'Products found', 'affiliate-toolkit-starter' ), array( &$this, 'product_products_box_content' ), ATKP_PRODUCT_POSTTYPE, 'normal', 'high' ); add_meta_box( ATKP_PRODUCT_POSTTYPE . '_detail_box', esc_html__( 'Detailed information', 'affiliate-toolkit-starter' ), array( &$this, 'product_detail_box_content' ), ATKP_PRODUCT_POSTTYPE, 'normal', 'high' ); add_meta_box( ATKP_PRODUCT_POSTTYPE . '_queue_box', esc_html__( 'Queue History', 'affiliate-toolkit-starter' ), array( &$this, 'product_queue_box_content' ), ATKP_PRODUCT_POSTTYPE, 'normal', 'low' ); } function product_queue_box_content( $post ) { $atkp_queuetable_helper = new atkp_queuetable_helper(); if ( ! $atkp_queuetable_helper->exists_table()[0] ) { /* translators: %s: database table name */ echo esc_html( sprintf( __( 'database table does not exists: %s', 'affiliate-toolkit-starter' ), $atkp_queuetable_helper->get_producttable_tablename() ) ); return; } $entries = $atkp_queuetable_helper->get_list_entry( 0, $post->ID, null, 100, 1, 'id', 'desc' ); ?>
0 ) { $link = admin_url( 'admin.php?page=ATKP_viewqueue&action=detail&queueid=' . $queueid ); if ( $link == null ) { echo esc_html($queueid); } else { $title = esc_html__( 'Queue', 'affiliate-toolkit-starter' ); echo '' . esc_html( $title ) . ' (' . esc_html( $queueid ) . ')'; } } ?> 0 ) { $link = get_edit_post_link( $shopid ); if ( $link == null ) { echo esc_html($shopid); } else { $title = get_the_title( $shopid ); echo '' . esc_html( $title ) . ' (' . esc_html( $shopid ) . ')'; } } ?> ' . esc_html__( 'Successfully', 'affiliate-toolkit-starter' ) . ''; break; case atkp_queue_entry_status::ERROR: echo '' . esc_html__( 'Error', 'affiliate-toolkit-starter' ) . ''; break; case atkp_queue_entry_status::NOT_PROCESSED: echo '' . esc_html__( 'Not processed', 'affiliate-toolkit-starter' ) . ''; break; case atkp_queue_entry_status::PROCESSED: echo '' . esc_html__( 'Processed', 'affiliate-toolkit-starter' ) . ''; break; case atkp_queue_entry_status::FINISHED: echo '' . esc_html__( 'Finalized', 'affiliate-toolkit-starter' ) . ''; break; case atkp_queue_entry_status::PREPARED: echo '' . esc_html__( 'Prepared for processing', 'affiliate-toolkit-starter' ) . ''; break; } ?>
exists_table()[0] ) { /* translators: %s: database table name */ echo esc_html( sprintf( __( 'database table does not exists: %s', 'affiliate-toolkit-starter' ), $atkp_producttable_helper->get_producttable_tablename() ) ); return; } if ( $this->atkp_product_collection == null ) { $this->atkp_product_collection = atkp_product_collection::load( $post->ID, '', true ); } ?>ID, ATKP_PRODUCT_POSTTYPE . '_hide_shops' ); $idx = 1; foreach ( $this->atkp_product_collection->products as $product ) { ?>
shop == null ? atkp_shop::load( $product->shopid ) : $product->shop; $is_checked = ''; if ( $ss != null ) { if ( $hide_shops != null ) { foreach ( $hide_shops as $h ) { if ( $h['shop_id'] == $ss->id && $h['product_id'] == $product->productid ) { $is_checked = 'checked'; break; } } } } ?>
mediumimageurl; if ( $imageurl == '' ) { $imageurl = $product->smallimageurl; } if ( $imageurl == '' ) { $imageurl = $product->largeimageurl; } if ( $imageurl != '' ) { echo ''; } ?> hidepricecomparision ) { ?>
:
: get_smalllogourl() != '' ) { echo '' . esc_attr( $ss->get_title() ) . ''; } else if ( $ss != null ) { echo '' . ( esc_html( $ss->get_title() ) ) . ''; } else { echo 'no shop?'; } ?>
: asin ); ?>
: title ) > 40 ? substr( $product->title, 0, 37 ) . '...' : $product->title ); ?>
: images == null ? 0 : count( $product->images ) ); ?>
: cpcfloat == 0 ? esc_html__( 'Affiliate product', 'affiliate-toolkit-starter' ) : esc_html( $product->cpc . ' (' . $product->cpcfloat . ')' ) ?>
: saleprice == '' ) { ?> saleprice ); ?> (salepricefloat ); ?> )
: shipping != '' && strlen( $product->shipping ) > 40 ? substr( $product->shipping, 0, 37 ) . '..' : $product->shipping ); ?>
: availability != '' && strlen( $product->availability ) > 40 ? substr( $product->availability, 0, 37 ) . '..' : $product->availability ); ?>
: updatedon ) ) . ' ' . ATKPTools::get_formatted_time( ( $product->updatedon ) ) . ( $product->isupdated != null && $product->isupdated == false ? ' ' . esc_html__( 'Update planned', 'affiliate-toolkit-starter' ) : '' ) ) ?>
: class="atkp-hide-product" name="id . '_' . $product->productid) ?>" value="1">
ID, ATKP_PRODUCT_POSTTYPE . '_asin' . ( $x > 1 ? '_' . $x : '' ) ); $asintype = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_asintype' . ( $x > 1 ? '_' . $x : '' ) ); $selectedshopid = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_shopid' . ( $x > 1 ? '_' . $x : '' ) ); if ( $asin == null && $asintype == null && $selectedshopid == null && $i != 0 ) { continue; } $i ++; if ( $selectedshopid > 0 ) { $shop_ids[] = $selectedshopid; } ?> 0 ) { $shop_ids = array_unique( $shop_ids ); foreach ( $shop_ids as $shop_id ) { $s = atkp_shop::load( $shop_id ); $plugin_name = ATKPTools::get_plugin_name_from_object( $s->provider ); // Prüfe Lizenz if ( ! ATKPTools::is_license_active_for_plugin( $plugin_name ) ) { ?>

:

ID, ATKP_PRODUCT_POSTTYPE . '_updatedon' ); $message = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_message' ); ?>

' . esc_html( $message ) . ''; ?> ID ); ?>
atkp_product_collection == null ) { $this->atkp_product_collection = atkp_product_collection::load( $post->ID, '', true ); } ?> $tabcontent ) { echo '
'; call_user_func( $tabcontent, $post ); echo '
'; } ?> atkp_product_collection->get_main_product( '', true ); ?> ID ); $importProductimage = atkp_options::$loader->get_product_importimage(); if ( $importProductimage ) { ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_title' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_mpn' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_productgroup' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_manufacturer' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_author' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_numberofpages' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_brand' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_releasedate' ); ?>
ID, ATKP_PRODUCT_POSTTYPE . '_description_mode' ); $desc_str = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_description' ); if ( $desc_mode_str == '' && $desc_str != '' ) { $desc_mode_str = 1; } $desc_mode = intval( $desc_mode_str ); ?>
> > >
description : '' ); echo '
' . wp_kses( $pl, array( 'br' => array(), 'ul' => array(), 'li' => array() ) ) . '
'; ob_start(); wp_editor( $desc_str, ATKP_PRODUCT_POSTTYPE . '_description', array( 'media_buttons' => false, 'textarea_name' => ATKP_PRODUCT_POSTTYPE . '_description', 'textarea_rows' => 10, ) ); $textarea_html = ob_get_clean(); echo '
' . $textarea_html . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_editor output is safe ?>
ID, ATKP_PRODUCT_POSTTYPE . '_features_mode' ); $feat_str = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_features' ); if ( $feat_mode_str == '' && $feat_str != '' ) { $feat_mode_str = 1; } $feat_mode = intval( $feat_mode_str ); ?>
> > >
features : '' ); echo '
' . wp_kses( $pl, array( 'ul' => array(), 'li' => array() ) ) . '
'; ob_start(); wp_editor( $feat_str, ATKP_PRODUCT_POSTTYPE . '_features', array( 'media_buttons' => false, 'textarea_name' => ATKP_PRODUCT_POSTTYPE . '_features', 'textarea_rows' => 10, ) ); $textarea_html = ob_get_clean(); echo '
' . $textarea_html . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_editor output is safe ?>
ID, ATKP_PRODUCT_POSTTYPE . '_postid' ); if ( $postid != null ) { if ( is_array( $postid ) ) { foreach ( $postid as $p ) { $title = get_the_title( $p ); if ( ! isset( $title ) || $title == '' ) { $title = esc_html__( 'edit post', 'affiliate-toolkit-starter' ); } echo '' . esc_html( $title ) . ' '; } } else { $title = get_the_title( $postid ); if ( ! isset( $title ) || $title == '' ) { $title = esc_html__( 'edit post', 'affiliate-toolkit-starter' ); } echo '' . esc_html( $title ) . ''; } } else { esc_html__( 'This product is not used as a main product in any post.', 'affiliate-toolkit-starter' ); } ?>
ID, ATKP_PRODUCT_POSTTYPE . '_dontimportmainimage' ), false ); ?>>
ID, ATKP_PRODUCT_POSTTYPE . '_outputashtml' ), true ); ?>>
'; } function product_tab2( $post ) { $mainproduct = $this->atkp_product_collection->get_main_product( '', true ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_producturl' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_addtocarturl' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_customerreviewsurl' ); ?>
atkp_product_collection->get_main_product( '', true ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_rating' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_reviewcount' ); ?>
atkp_product_collection->get_main_product( '', true ); ?> ID ); ?>
ID, ATKP_PRODUCT_POSTTYPE . '_mediumimageurl' ); if ( $imageurl == '' ) { $imageurl = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_smallimageurl' ); } if ( $imageurl == '' ) { $imageurl = ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_largeimageurl' ); } if ( $imageurl == '' && $mainproduct != null ) { $imageurl = $mainproduct->mediumimageurl; } if ( $imageurl == '' && $mainproduct != null ) { $imageurl = $mainproduct->smallimageurl; } if ( $imageurl == '' && $mainproduct != null ) { $imageurl = $mainproduct->largeimageurl; } ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_smallimageurl' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_mediumimageurl' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_largeimageurl' ); ?>
images as $img ) { echo ''; } } ?>
atkp_product_collection->get_main_product( '', true ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_listprice' ); ?> ID, ATKP_PRODUCT_POSTTYPE . '_listprice' ) != '' ) { ?> (ID, ATKP_PRODUCT_POSTTYPE . '_listpricefloat' ) ); ?>)
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_amountsaved' ); ?> ID, ATKP_PRODUCT_POSTTYPE . '_amountsaved' ) != '' ) { ?> (ID, ATKP_PRODUCT_POSTTYPE . '_amountsavedfloat' ) ); ?>)
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_percentagesaved' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_saleprice' ); ?> ID, ATKP_PRODUCT_POSTTYPE . '_saleprice' ) != '' ) { ?> (ID, ATKP_PRODUCT_POSTTYPE . '_salepricefloat' ) ); ?>)
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_baseprice' ); ?> ID, ATKP_PRODUCT_POSTTYPE . '_baseprice' ) != '' ) { ?> (ID, ATKP_PRODUCT_POSTTYPE . '_basepricefloat' ) ); ?>)
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_baseunit' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_baseunits' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_availability' ); ?>
create_clipboard_button( ATKP_PRODUCT_POSTTYPE . '_shipping' ); ?> ID, ATKP_PRODUCT_POSTTYPE . '_shipping' ) != '' ) { ?> (ID, ATKP_PRODUCT_POSTTYPE . '_shippingfloat' ) ); ?>)
ID, ATKP_PRODUCT_POSTTYPE . '_isprime' ), true ); ?>>
ID, ATKP_PRODUCT_POSTTYPE . '_iswarehouse' ), true ); ?>>
atkp_product_collection->get_main_product( '', true ); ?>
parentasin; ?>
variations; // ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_variations' ); $variationname = $mainproduct == null ? null : $mainproduct->variationname; // ATKPTools::get_post_setting( $post->ID, ATKP_PRODUCT_POSTTYPE . '_variationname' ); if ( isset( $variations ) && is_array( $variations ) ) { ?>
$value ) { array_push( $displaylist, htmlentities( $value ) ); } } echo esc_html( implode( ' > ', $displaylist ) ); ?>
asin); ?> variationname as $key => $value ) { array_push( $displaylist, htmlentities( $value ) ); } echo esc_html( implode( ' > ', $displaylist ) ); ?> producturl ) . '" target="blank">' . esc_html( $variation->title ) . ''; ?>
 
id == $b->id ) { return 0; } return ( $a->id < $b->id ) ? - 1 : 1; } function substr_startswith( $haystack, $needle ) { return substr( $haystack, 0, strlen( $needle ) ) === $needle; } function product_detail_save( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } $nounce = ATKPTools::get_post_parameter( 'product_detail_box_content_nonce', 'string' ); if ( ! wp_verify_nonce( $nounce, plugin_basename( __FILE__ ) ) ) { return; } // The nonce only proves the request came from the product edit screen; it does // not prove this user may edit THIS product. Enforce per-post authorization so a // low-privileged user cannot store meta (e.g. the product URL) on a post they // are not allowed to edit. if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } $post = get_post( $post_id ); $posttype = $post->post_type; //ATKPTools::get_post_parameter('post_type', 'string'); if ( ATKP_PRODUCT_POSTTYPE != $posttype ) { return; } $shopid = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_shopid', 'string' ); $asin = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_asin', 'string' ); $asintype = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_asintype', 'string' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_asin', $asin ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_asintype', $asintype ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shopid', $shopid ); for ( $x = 2; $x < ( ATKP_FILTER_COUNT + 2 ); $x ++ ) { $shopid2 = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_shopid_' . $x, 'string' ); $asin2 = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_asin_' . $x, 'string' ); $asintype2 = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_asintype_' . $x, 'string' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_asin_' . $x, $asin2 ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_asintype_' . $x, $asintype2 ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shopid_' . $x, $shopid2 ); } $ean = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_ean', 'string' ); $isbn = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_isbn', 'string' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_ean', $ean ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_isbn', $isbn ); $lock_ean = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_ean_lock', 'bool' ); $lock_isbn = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_isbn_lock', 'bool' ); $lock_gtin = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_gtin_lock', 'bool' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_ean_lock', $lock_ean ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_isbn_lock', $lock_isbn ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_gtin_lock', $lock_gtin ); $title = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_title', 'string' ); $description = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_description', 'html' ); $description_mode = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_description_mode', 'int' ); $features_mode = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_features_mode', 'int' ); $outputashtml = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_outputashtml', 'bool' ); $sortorder = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_sortorder', 'int' ); $mpn = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_mpn', 'string' ); $brand = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_brand', 'string' ); $productgroup = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_productgroup', 'string' ); $releasedate = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_releasedate', 'string' ); $producturl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_producturl', 'url' ); $addtocarturl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_addtocarturl', 'url' ); $customerreviewurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_customerreviewsurl', 'url' ); $overridemainimage = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_overridemainimage', 'string' ); $smallimageurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_smallimageurl', 'url' ); $mediumimageurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_mediumimageurl', 'url' ); $largeimageurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_largeimageurl', 'url' ); $manufacturer = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manufacturer', 'string' ); $author = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_author', 'string' ); $numberofpages = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_numberofpages', 'int' ); $features = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_features', 'html' ); $isownreview = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_isownreview', 'bool' ); $rating = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_rating', 'double' ); $reviewcount = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_reviewcount', 'int' ); $reviewsurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_reviewsurl', 'url' ); $listprice = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_listprice', 'string' ); $amountsaved = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_amountsaved', 'string' ); $percentagesaved = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_percentagesaved', 'string' ); $saleprice = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_saleprice', 'string' ); $availability = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_availability', 'string' ); $shipping = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_shipping', 'string' ); $isprime = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_isprime', 'bool' ); $iswarehouse = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_iswarehouse', 'bool' ); $baseprice = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_baseprice', 'string' ); $baseunit = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_baseunit', 'string' ); $baseunits = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_baseunits', 'int' ); $predicate = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_predicate', 'string' ); $testdate = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_testdate', 'string' ); $testrating = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_testrating', 'string' ); $testresult = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_testresult', 'string' ); $reviewtext = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_reviewtext', 'string' ); $pro = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_pro', 'multistring' ); $contra = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_contra', 'multistring' ); $dontimportmainimage = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_dontimportmainimage', 'bool' ); $hide_shops = array(); foreach ( $_POST as $x => $xval ) { if ( ATKPTools::startsWith( $x, 'atkp_hide_product_' ) ) { $str = str_replace( 'atkp_hide_product_', '', $x ); $parts = explode( '_', $str ); $hide_shops[] = array( 'shop_id' => intval( $parts[0] ), 'product_id' => intval( $parts[1] ) ); } } ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_hide_shops', $hide_shops ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_overridemainimage', $overridemainimage ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_dontimportmainimage', $dontimportmainimage ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_pro', $pro ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_contra', $contra ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_predicate', $predicate ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_testdate', $testdate ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_testrating', $testrating ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_testresult', $testresult ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_reviewtext', $reviewtext ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_outputashtml', $outputashtml ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_sortorder', $sortorder ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_description_mode', $description_mode ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_features_mode', $features_mode ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_title', $title ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_description', $description ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_mpn', $mpn ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_brand', $brand ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_productgroup', $productgroup ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_releasedate', $releasedate ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manufacturer', $manufacturer ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_author', $author ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_numberofpages', $numberofpages ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_features', $features ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_producturl', $producturl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_addtocarturl', $addtocarturl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_customerreviewsurl', $customerreviewurl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_isownreview', $isownreview ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_reviewsurl', $reviewsurl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_smallimageurl', $smallimageurl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_mediumimageurl', $mediumimageurl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_largeimageurl', $largeimageurl ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_rating', $rating ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_reviewcount', $reviewcount ); $salepricefloat = ATKPTools::price_to_float( $saleprice ); $listpricefloat = ATKPTools::price_to_float( $listprice ); $product = new atkp_product(); $product->listpricefloat = $listpricefloat; $product->salepricefloat = $salepricefloat; if ( $product->listpricefloat > 0 && $product->salepricefloat > 0 ) { $productservice = new atkp_productservice(); $productservice->update_product_price_saved( $post_id, $product, true ); } else { ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_amountsaved', $amountsaved ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_percentagesaved', $percentagesaved ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_amountsavedfloat', ATKPTools::price_to_float( $amountsaved ) ); } ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_baseprice', $baseprice ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_basepricefloat', ATKPTools::price_to_float( $baseprice ) ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_baseunit', $baseunit ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_baseunits', $baseunits ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_listprice', $listprice ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_saleprice', $saleprice ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_availability', $availability ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shipping', $shipping ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_isprime', $isprime ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_iswarehouse', $iswarehouse ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_listpricefloat', ATKPTools::price_to_float( $listprice ) ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_salepricefloat', $salepricefloat ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shippingfloat', ATKPTools::price_to_float( $shipping ) ); do_action( 'atkp_product_save_pricefields', $post_id ); for ( $x = 0; $x < ATKP_VARIATION_COUNT; $x ++ ) { $name = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_variation_name_' . $x, 'string' ); $url = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_variation_url_' . $x, 'string' ); $imageurl = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_variation_imageurl_' . $x, 'string' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_variation_name_' . $x, $name ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_variation_url_' . $x, $url ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_variation_imageurl_' . $x, $imageurl ); } for ( $x = 0; $x < ATKP_MANUALOFFER_COUNT; $x ++ ) { $name = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_name_' . $x, 'string' ); $logo = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_logo_' . $x, 'url' ); $price = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_price_' . $x, 'string' ); $shipping = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_shipping_' . $x, 'string' ); $availability = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_availability_' . $x, 'string' ); $url = ATKPTools::get_post_parameter( ATKP_PRODUCT_POSTTYPE . '_manualoffer_url_' . $x, 'url' ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_name_' . $x, $name ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_url_' . $x, $url ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_logo_' . $x, $logo ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_price_' . $x, $price ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_shipping_' . $x, $shipping ); ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manualoffer_availability_' . $x, $availability ); } $images = array(); //echo serialize($_POST); foreach ( $_POST as $key => $value ) { $key = sanitize_text_field( $key ); $value = sanitize_text_field( $value ); $id = str_replace( 'atkp_product_largeimageurl_gallery_', '', $key ); $id = str_replace( 'atkp_product_smallimageurl_gallery_', '', $id ); $id = str_replace( 'atkp_product_mediumimageurl_gallery_', '', $id ); $checkit = 0; $add = 1; $udf = new atkp_product_image(); $udf->id = $id; foreach ( $images as $image ) { if ( $image->id == $udf->id ) { $udf = $image; $add = 0; break; } } if ( $this->substr_startswith( $key, 'atkp_product_largeimageurl_gallery' ) ) { $checkit = 1; $udf->largeimageurl = $value; } else if ( $this->substr_startswith( $key, 'atkp_product_smallimageurl_gallery' ) ) { $checkit = 1; $udf->smallimageurl = $value; } else if ( $this->substr_startswith( $key, 'atkp_product_mediumimageurl_gallery' ) ) { $checkit = 1; $udf->mediumimageurl = $value; } if ( $checkit && $add ) { array_push( $images, $udf ); } } ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_images', $images ); do_action( 'atkp_product_save_fields', $post_id ); if ( ATKPTools::get_post_parameter( 'atkp_product_filter_changed', 'int' ) == 1 ) { atkp_queueservices::do_manual_product_update( $post_id, esc_html__( 'Manual product update', 'affiliate-toolkit-starter' ) ); } else { $productservice = new atkp_productservice(); $productservice->update_product_categories( $post_id ); $productservice->update_product_mainimage( $post_id ); $productservice->update_product_status( $post_id ); do_action( 'atkp_product_updated', $post_id, null ); } } } ?>