register_shopPostType(); add_action('add_meta_boxes', array(&$this, 'list_boxes')); add_action('save_post', array(&$this, 'list_detail_save')); add_action('admin_enqueue_scripts', array($this, 'image_enqueue')); add_action('admin_head', array($this, 'hidey_admin_head')); add_action('atkp_shop_to_trash', array($this, 'atkp_shop_to_trash'), 10, 1); $this->post_parent_qv(); ATKPTools::add_column(ATKP_SHOP_POSTTYPE, esc_html__('Status', 'affiliate-toolkit-starter'), function ($post_id) { $selwebservice = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_webservice'); $shop_provider = atkp_shop_provider_base::retrieve_provider($selwebservice); if ($shop_provider != null) { echo '' . esc_html__('Type', 'affiliate-toolkit-starter') . ': ' . esc_html($shop_provider->get_caption()) . '
'; } echo '' . esc_html__('ID', 'affiliate-toolkit-starter') . ': ' . esc_html($post_id) . ''; if ($selwebservice != ATKP_SUBSHOPTYPE) { $error = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_message'); echo ', '; if ($error == null || empty($error)) { echo '' . esc_html__('Connected', 'affiliate-toolkit-starter') . ''; } else { echo '' . esc_html__('Not connected', 'affiliate-toolkit-starter') . ' (' . esc_html($error) . ')'; } } else { $parent_id = wp_get_post_parent_id($post_id); $parent_name = get_the_title($parent_id); if ($parent_id && $parent_id != 0) { $pp_url = add_query_arg(array('post_type' => 'atkp_shop', 'post_parent' => $parent_id), 'edit.php'); echo '
' . esc_html__('Parent shop', 'affiliate-toolkit-starter') . ': ' . esc_html($parent_name) . ''; } } do_action('atkp_shop_status_column', $post_id); $holdontop = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_holdshopontop'); if ($holdontop == '' || !is_numeric(($holdontop))) { if ($holdontop == true) { $holdontop = 10; } else { $holdontop = 100; } } $holdontop = intval($holdontop); /* translators: %s: sort order number */ echo '
' . sprintf(esc_html__('Sort order: %s', 'affiliate-toolkit-starter'), esc_html($holdontop)); }, 3); ATKPTools::add_column(ATKP_SHOP_POSTTYPE, esc_html__('Imported Product count', 'affiliate-toolkit-starter'), function ($post_id) { $atkp_producttable_helper = new atkp_producttable_helper(); $stats = $atkp_producttable_helper->count_products_by_shop_with_stats($post_id); echo '' . esc_html__('Total', 'affiliate-toolkit-starter') . ': ' . esc_html($stats['total']) . '
'; echo '' . esc_html__('Error-free', 'affiliate-toolkit-starter') . ': ' . esc_html($stats['success']) . '
'; echo '' . esc_html__('Faulty', 'affiliate-toolkit-starter') . ': ' . esc_html($stats['error']); }, 3); ATKPTools::add_column(ATKP_SHOP_POSTTYPE, esc_html__('Logo', 'affiliate-toolkit-starter'), function ($post_id) { $shps = atkp_shop::load($post_id); try { $imageurl = $shps->get_smalllogourl(); if ($imageurl == '') { $imageurl = $shps->get_logourl(); } if ($imageurl != '') { echo '' . esc_attr($shps->get_title()) . ''; } } catch (Exception $e) { echo esc_html($e->getMessage()); } }, 1); add_filter('map_meta_cap', function ($caps, $cap, $user_id, $args) { // Nothing to do if ('delete_post' !== $cap || empty($args[0])) { return $caps; } // Target the payment and transaction post types if (in_array(get_post_type($args[0]), [ATKP_SHOP_POSTTYPE], true) && wp_get_post_parent_id(get_the_ID()) > 0) { $caps[] = 'do_not_allow'; } return $caps; }, 10, 4); } function post_parent_qv() { if (is_admin()) { $GLOBALS['wp']->add_query_var('post_parent'); } } /** * Loads the image management javascript */ function image_enqueue() { global $typenow; if ($typenow == ATKP_SHOP_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'), ATKPSettings::plugin_get_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 hidey_admin_head() { echo ''; } function atkp_shop_to_trash($shop_id) { $args = array( 'post_parent' => $shop_id, 'post_type' => 'atkp_shop' ); $posts = get_posts($args); if (is_array($posts) && count($posts) > 0) { foreach ($posts as $post) { wp_trash_post($post->ID); } } } function register_shopPostType() { $labels = array( 'name' => esc_html__('Shops', 'affiliate-toolkit-starter'), 'singular_name' => esc_html__('Shop', 'affiliate-toolkit-starter'), 'add_new_item' => esc_html__('Add new Shop', 'affiliate-toolkit-starter'), 'edit_item' => esc_html__('Edit Shop', 'affiliate-toolkit-starter'), 'new_item' => esc_html__('New Shop', 'affiliate-toolkit-starter'), 'all_items' => esc_html__('Shops', 'affiliate-toolkit-starter'), 'view_item' => esc_html__('View Shop', 'affiliate-toolkit-starter'), 'search_items' => esc_html__('Search Shops', 'affiliate-toolkit-starter'), 'not_found' => esc_html__('No shops found', 'affiliate-toolkit-starter'), 'not_found_in_trash' => esc_html__('No shops found in the Trash', 'affiliate-toolkit-starter'), 'parent_item_colon' => '', 'menu_name' => esc_html__('Shops', 'affiliate-toolkit-starter'), ); $args = array( 'labels' => $labels, 'description' => 'Holds our Shop', '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 (the misspelled key had no effect, so this keeps the previous behaviour) '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' => false, // you shouldn't be able to add it to menus 'has_archive' => false, // it shouldn't have archive page 'rewrite' => false, // it shouldn't have rewrite rules 'hierarchical' => true, 'capability_type' => 'page', 'menu_position' => 200, 'supports' => array('title'), 'show_in_menu' => ATKP_PLUGIN_PREFIX . '_affiliate_toolkit-plugin', ); $args = apply_filters('atkp_shop_register_post_type', $args); register_post_type(ATKP_SHOP_POSTTYPE, $args); } function list_boxes() { add_meta_box( ATKP_SHOP_POSTTYPE . '_detail_box', esc_html__('Shop Information', 'affiliate-toolkit-starter'), array(&$this, 'shop_detail_box_content'), ATKP_SHOP_POSTTYPE, 'normal', 'default' ); add_meta_box( ATKP_SHOP_POSTTYPE . '_queue_box', esc_html__('Queue History', 'affiliate-toolkit-starter'), array(&$this, 'shop_queue_box_content'), ATKP_SHOP_POSTTYPE, 'normal', 'low' ); add_meta_box( ATKP_SHOP_POSTTYPE . '_copy_settings_box', esc_html__('Copy Settings', 'affiliate-toolkit-starter'), array(&$this, 'shop_copy_settings_box_content'), ATKP_SHOP_POSTTYPE, 'side', 'low' ); } function shop_copy_settings_box_content() { $postmetas = get_post_meta(get_the_ID()); $array_fields = array(); $array_fields['post_id'] = get_the_ID(); foreach ($postmetas as $meta_key => $meta_value) { if (substr($meta_key, 0, 5) == 'atkp_') { $array_fields[$meta_key] = ($meta_value); } } ?> 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_queuetable_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; } ?>
ID, ATKP_SHOP_POSTTYPE . '_access_webservice'); $alreadysaved = (bool) $selwebservice != ''; if ($selwebservice == ATKP_SUBSHOPTYPE) { $parentid = wp_get_post_parent_id($post->ID); if ($parentid == 0) { $access_test = '' . esc_html__('parent shop not found:', 'affiliate-toolkit-starter') . ' ' . esc_html($post->ID) . ''; } else { $title = get_the_title($parentid); if ($title == '') { $title = esc_html__('open shop', 'affiliate-toolkit-starter'); } $access_test = '' . esc_html($title) . ''; $shopid = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_shopid'); $programid = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_programid'); $access_test .= '
';
                $access_test .= '
' . esc_html__('Shopid: ', 'affiliate-toolkit-starter') . esc_html($shopid); $access_test .= '
' . esc_html__('Programid: ', 'affiliate-toolkit-starter') . esc_html($programid); $access_test .= '
'; } } else { $error = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_access_message'); if (!$alreadysaved) { $error = esc_html__('Access data not defined.', 'affiliate-toolkit-starter'); } if (($error == null || empty($error))) { $access_test = '' . esc_html__('Connected', 'affiliate-toolkit-starter') . ''; } else { $access_test = '' . esc_html__('Not connected', 'affiliate-toolkit-starter') . ' (' . esc_html($error) . ')'; } } ?>
array('style' => array()), 'a' => array('href' => array(), 'target' => array()), 'pre' => array(), 'br' => array() )); ?>
ID); $plugin_name = ATKPTools::get_plugin_name_from_object($s->provider); // Prüfe Lizenz if (!ATKPTools::is_license_active_for_plugin($plugin_name)) { ?>

:

output_detail($post); } else { foreach ($locations as $value => $provider) { if ($alreadysaved) { if ($value != $selwebservice) { continue; } } echo '
'; echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Provider generates its own escaped HTML form fields. echo $provider->get_configuration($post); echo '
'; echo ''; } ?> type == atkp_shop_type::MULTI_SHOPS) { ?> type == atkp_shop_type::MULTI_SHOPS || $s->type == atkp_shop_type::SUB_SHOPS) { ?> output_detail($post); } if ($alreadysaved) { ?> ID); ?>
autogeneratesubshops, true ); ?>>
ID, ATKP_SHOP_POSTTYPE . '_default_shops'); $selectedshops = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_selected_shops'); $allselected = true; if (is_array($defaultshops)) { foreach ($defaultshops as $subshop) { $found = false; if (is_array($selectedshops)) { foreach ($selectedshops as $selectedsubshop) { if ($subshop->shopid == $selectedsubshop->shopid && $subshop->programid == $selectedsubshop->programid) { $found = true; break; } } } else { //wenn selectedshop nicht gesetzt ist dann ist es noch von der alten subshop logik.. if ($subshop->enabled) { $found = true; } } if (!$found) { $allselected = false; } ?> />
/>
ID, ATKP_SHOP_POSTTYPE . '_displayshoplogo'), false); ?>>
id="" name="" value="1" ID, ATKP_SHOP_POSTTYPE . '_enableofferload')); ?>>

0,00

ID, ATKP_SHOP_POSTTYPE . '_customtitle'); $customsmalllogourl = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_customsmalllogourl'); $customlogourl = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_customlogourl'); $feedurl = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_feedurl'); $productcount = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_productcount'); $customfield1 = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_customfield1'); $customfield2 = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_customfield2'); $customfield3 = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_customfield3'); $chartcolor = ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_chartcolor'); $ontop = intval(ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_holdshopontop')); $hidepricecomparision = intval(ATKPTools::get_post_setting($post->ID, ATKP_SHOP_POSTTYPE . '_hidepricecomparision')); $subshop = atkp_shop::load($post->ID); //$subshops= ATKPTools::get_post_setting( $post->ID, ATKP_SHOP_POSTTYPE.'_default_shops'); // if(is_array($subshops)) // var_dump($subshops); //if(is_array($subshops)) //$subshop = $shps[0]; ?> smalllogourl; $logourl = $subshop->logourl; } if ($customsmalllogourl != '') { $smallimageurl = $customsmalllogourl; } if ($customlogourl != '') { $logourl = $customlogourl; } if ($smallimageurl != '') { ?>

/> save_child) { return; } $post = get_post($post_id); $posttype = $post->post_type; //ATKPTools::get_post_parameter('post_type', 'string'); if (ATKP_SHOP_POSTTYPE != $posttype) { return; } if (isset($_POST['atkp_paste_settings']) && $_POST['atkp_paste_settings'] != '') { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- JSON data, decoded and processed below. $import_settings = wp_unslash($_POST['atkp_paste_settings']); $x = json_decode($import_settings); if ($x) { $fields = array_keys(get_object_vars($x)); foreach ($fields as $field) { if ($field == 'post_id') { } else if ($field == 'post_title') { //TODO: Set post title } else { $unval = is_array($x->$field) ? (count($x->$field) > 0 ? $x->$field[0] : null) : $x->$field; if ($unval != null) { require_once(ATKP_PLUGIN_DIR . '/includes/shopproviders/subshop.php'); if(defined('ATKP_CSV_PLUGIN_DIR')) { require_once(ATKP_CSV_PLUGIN_DIR . '/includes/columnconfig.php'); } $data = @unserialize($unval); if ($data !== false) { $unval = $data; } } //ungeslashte Importdaten, update_post_meta() unslasht selbst update_post_meta($post_id, $field, wp_slash($unval)); } } //do_action('atkp_shop_save_fields', $post_id); return; } } //speichern der einstellungen $message = ''; ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_message', esc_html__('Connecting...', 'affiliate-toolkit-starter')); $webservice = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_webservice'); if ($webservice == '' || $webservice == null) { $webservice = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_access_webservice', 'string'); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_webservice', $webservice); } if ($webservice != '' && $webservice != ATKP_SUBSHOPTYPE) { $myprovider = atkp_shop_provider_base::retrieve_provider($webservice); if ($myprovider == null) { /* translators: %s: webservice provider identifier */ throw new Exception(esc_html(sprintf(__('provider not found: %s', 'affiliate-toolkit-starter'), $webservice))); } $myprovider->set_configuration($post_id); $message = $myprovider->check_configuration($post_id); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_customtitle')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customtitle', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customtitle', 'string')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield1')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customfield1', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield1', 'html')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield2')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customfield2', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield2', 'html')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield3')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customfield3', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customfield3', 'html')); } ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_holdshopontop', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_holdshopontop', 'int')); if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_chartcolor')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_chartcolor', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_chartcolor', 'string')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_displayshoplogo', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_displayshoplogo', 'bool')); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_enableofferload', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_enableofferload', 'bool')); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_auto_generate_subshops', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_auto_generate_subshops', 'bool')); } else { $val = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_displayshoplogo', 'hey'); if ($val == 'hey') ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_displayshoplogo', true); } ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_hidepricecomparision', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_hidepricecomparision', 'bool')); $redirectiontype = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_redirectiontype', 'int'); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_redirectiontype', $redirectiontype); $apikey = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_apikey', 'string'); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_apikey', $apikey); $tooltip = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_text_tooltip', 'string'); $buyattext = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_text_buyat', 'html'); $addtocarttext = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_text_addtocart', 'html'); $small_logo_url = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customsmalllogourl', 'url'); $logo_url = ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_customlogourl', 'url'); if (isset($myprovider)) { if ($buyattext == null || $buyattext == '') { $buyattext = $myprovider->get_defaultbtn1_text(); } if ($addtocarttext == null || $addtocarttext == '') { $addtocarttext = $myprovider->get_defaultbtn2_text(); } if ($tooltip == null || $tooltip == '') { /* translators: %s: shop name */ $tooltip = esc_html__('Buy now at %s', 'affiliate-toolkit-starter'); } if ($small_logo_url == null || $small_logo_url == '') { $small_logo_url = $myprovider->get_default_small_logo($post_id); } if ($logo_url == null || $logo_url == '') { $logo_url = $myprovider->get_default_logo($post_id); } } ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_text_tooltip', $tooltip); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_text_buyat', $buyattext); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_text_addtocart', $addtocarttext); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customsmalllogourl', $small_logo_url); ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_customlogourl', $logo_url); if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_currencysign', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign', 'string')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign_customprefix')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_currencysign_customprefix', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign_customprefix', 'string')); } if (ATKPTools::exists_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign_customsuffix')) { ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_currencysign_customsuffix', ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_currencysign_customsuffix', 'string')); } if ($webservice != ATKP_SUBSHOPTYPE) { $defaultshops = ATKPTools::get_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_default_shops'); /** @var $selectedshops atkp_shop[] */ $selectedshops = array(); if (is_array($defaultshops)) { foreach ($defaultshops as $subshop) { if (ATKPTools::get_post_parameter(ATKP_SHOP_POSTTYPE . '_subshop-' . $subshop->shopid . '-' . $subshop->programid, 'bool') == true) { $selectedshops[] = $subshop; } } } ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_selected_shops', $selectedshops); $subshops_saved = array(); wp_suspend_cache_addition(true); if (is_array($selectedshops)) { foreach ($selectedshops as $subshop) { $subshop->parent_id = $post_id; $this->save_child = true; $subshopid = atkp_shop::create_subshop($subshop); $this->save_child = false; $subshops_saved[] = $subshopid; } } wp_suspend_cache_addition(false); $subshops_old = get_posts(array( // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Required to find shops not in saved list. 'fields' => 'ids', 'post_parent' => $post_id, 'post_type' => ATKP_SHOP_POSTTYPE, 'numberposts' => -1, 'post_status' => array('draft', 'publish'), 'exclude' => $subshops_saved // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude )); foreach ($subshops_old as $subshop_id) { wp_trash_post($subshop_id); } } ATKPTools::set_post_setting($post_id, ATKP_SHOP_POSTTYPE . '_access_message', $message); do_action('atkp_shop_save_fields', $post_id); } } ?>