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 '';
}
} 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; } ?> |
';
$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() )); ?> |
| 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 |
|
|
|