register_listPostType();
$this->register_filter();
add_action( 'add_meta_boxes', array( &$this, 'list_boxes' ) );
add_action( 'save_post', array( &$this, 'list_detail_save' ) );
ATKPTools::add_column( ATKP_LIST_POSTTYPE, __( 'Status', 'affiliate-toolkit-starter' ), function ( $post_id ) {
$selectedshopid = ATKPTools::get_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_shopid' );
try {
if ( $selectedshopid != '' && atkp_shop::exists( $selectedshopid ) ) {
$shps = atkp_shop::load( $selectedshopid );
}
} catch ( Exception $ex ) {
echo 'parent shop not found. ';
$shps = null;
}
echo '' . esc_html__( 'ID', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $post_id ) . ' , ';
if ( ! isset( $shps ) || $shps == null ) {
echo '' . esc_html__( 'No shop', 'affiliate-toolkit-starter' ) . ' ';
} else {
$shop = '';
if ( $shps->get_smalllogourl() != '' ) {
$shop = ' ';
} else {
$shop = '' . ( esc_attr( $shps->get_title() ) ) . ' ';
}
echo '' . esc_html__( 'Shop', 'affiliate-toolkit-starter' ) . ': ' .
wp_kses( $shop, array(
'a' => array( 'title' => array(), 'target' => array(), 'href' => array() ),
'img' => array( 'alt' => array(), 'style' => array(), 'src' => array() )
) ) .
' ';
}
$updatedon = ATKPTools::get_post_setting( $post_id, ATKP_LIST_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 ) . ' ';
}
$selectedsourceval = ATKPTools::get_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_source' );
$durations = array(
10 => esc_html__( 'Category - Best Seller', 'affiliate-toolkit-starter' ),
11 => esc_html__( 'Category - New Releases', 'affiliate-toolkit-starter' ),
20 => esc_html__( 'Search', 'affiliate-toolkit-starter' ),
30 => esc_html__( 'Extended Search', 'affiliate-toolkit-starter' ),
//24 => __('Search - Order items by keywords. Rank is determined by the keywords in the product description.', 'affiliate-toolkit-starter'),
//25 => __('Search - Order items by customer reviews, from highest to lowest ranked..', 'affiliate-toolkit-starter'),
//40 => __( 'Similarity - Find similar products', ATKP_PLUGIN_PREFIX ),
);
foreach ( $durations as $value => $name ) {
if ( $value == $selectedsourceval ) {
echo '' . esc_html__( 'Type', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $name ) . ' ';
break;
}
}
$message = ATKPTools::get_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_message' );
if ( isset( $message ) && $message != '' ) {
echo '' . esc_html__( 'Message', 'affiliate-toolkit-starter' ) . ': ' . esc_html( $message ) . ' ';
}
do_action( 'atkp_list_status_column', $post_id );
}, 2 );
ATKPTools::add_column( ATKP_LIST_POSTTYPE, esc_html__( 'Products', 'affiliate-toolkit-starter' ), function ( $post_id ) {
$count = ATKPTools::get_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_count' );
echo '' . esc_html( $count ) . ' ';
do_action( 'atkp_list_count_column', $post_id );
}, 3 );
}
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_LIST_POSTTYPE && ! atkp_posttypes_list::$overridefilter ) {
global $pagenow;
if ( is_admin() && $pagenow == 'edit.php' && isset( $filterfield ) && $filterfield != '' ) {
if ( $filterfield == 'filter_error' ) {
$meta_query = array(
array(
'key' => 'atkp_list_message',
'value' => '',
'compare' => '!=', // sorgt dafür, dass nur nicht-leere Werte gefunden werden
),
);
$query->set( 'meta_query', $meta_query );
} else {
$parts = explode( '_', $filterfield );
$query->set( 'meta_query', array(
array(
'key' => ATKP_LIST_POSTTYPE . '_shopid',
'value' => isset( $parts[1] ) ? $parts[1] : '',
'compare' => isset( $parts[1] ) && $parts[1] != '' ? '=' : 'NOT EXISTS'
)
) );
}
}
}
}
private static $overridefilter;
function admin_posts_filter_restrict_manage_posts() {
$posttype = ATKPTools::get_get_parameter( 'post_type', 'string' );
if ( $posttype != ATKP_LIST_POSTTYPE ) {
return;
}
atkp_posttypes_list::$overridefilter = true;
$shops = atkp_shop::get_list( );
atkp_posttypes_list::$overridefilter = false;
?>
' . esc_html__( 'Lists with error', 'affiliate-toolkit-starter' ) . '';
echo '' . esc_html__( 'No shop', 'affiliate-toolkit-starter' ) . ' ';
foreach ( $shops as $shop ) {
/* translators: %1$s: shop title, %2$s: shop ID */
echo 'type == atkp_shop_type::SUB_SHOPS ? 'disabled' : '' ) . ' value="' . esc_attr( 'shop_' . $shop->id ) . '" ' . ( $filterfield == 'shop_' . $shop->id ? 'selected' : '' ) . '>' . sprintf( esc_html__( 'Shop: %1$s (%2$s)', 'affiliate-toolkit-starter' ), esc_html( $shop->title ), esc_html( $shop->id ) ) . ' ';
foreach ( $shop->children as $child ) {
/* translators: %1$s: child shop title, %2$s: child shop ID */
echo 'id ? 'selected' : '' ) . '>- ' . sprintf( esc_html__( '%1$s (%2$s)', 'affiliate-toolkit-starter' ), esc_html( $child->title ), esc_html( $child->id ) ) . ' ';
}
}
?>
esc_html__( 'Lists', 'affiliate-toolkit-starter' ),
'singular_name' => esc_html__( 'List', 'affiliate-toolkit-starter' ),
'add_new_item' => esc_html__( 'Add New List', 'affiliate-toolkit-starter' ),
'edit_item' => esc_html__( 'Edit List', 'affiliate-toolkit-starter' ),
'new_item' => esc_html__( 'New List', 'affiliate-toolkit-starter' ),
'all_items' => esc_html__( 'Lists', 'affiliate-toolkit-starter' ),
'view_item' => esc_html__( 'View List', 'affiliate-toolkit-starter' ),
'search_items' => esc_html__( 'Search Lists', 'affiliate-toolkit-starter' ),
'not_found' => esc_html__( 'No lists found', 'affiliate-toolkit-starter' ),
'not_found_in_trash' => esc_html__( 'No lists found in the Trash', 'affiliate-toolkit-starter' ),
'parent_item_colon' => '',
'menu_name' => esc_html__( 'AT Lists', 'affiliate-toolkit-starter' ),
);
$args = array(
'labels' => $labels,
'description' => 'Holds our lists',
'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' => true, // 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
'supports' => array( 'title' ),
'capability_type' => 'post',
'menu_position' => 20,
'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_list_register_post_type', $args );
register_post_type( ATKP_LIST_POSTTYPE, $args );
}
function list_boxes() {
add_meta_box(
ATKP_LIST_POSTTYPE . '_shop_box',
esc_html__( 'Shop Information', 'affiliate-toolkit-starter' ),
array( &$this, 'list_shop_box_content' ),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
add_meta_box(
ATKP_LIST_POSTTYPE . '_detail_box',
esc_html__( 'List Information', 'affiliate-toolkit-starter' ),
array( &$this, 'list_detail_box_content' ),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
add_meta_box(
ATKP_LIST_POSTTYPE . '_preview_box',
esc_html__( 'List Preview', 'affiliate-toolkit-starter' ),
array( &$this, 'list_preview_box_content' ),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
add_meta_box(
ATKP_LIST_POSTTYPE . '_queue_box',
esc_html__( 'Queue History', 'affiliate-toolkit-starter' ),
array( &$this, 'list_queue_box_content' ),
ATKP_LIST_POSTTYPE,
'normal',
'low'
);
}
function list_queue_box_content( $post ) {
$atkp_queuetable_helper = new atkp_queuetable_helper();
if ( ! $atkp_queuetable_helper->exists_table()[0] ) {
echo esc_html__( 'database table does not exists:', 'affiliate-toolkit-starter' ) . ' ' . esc_html( $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] ) {
echo esc_html__( 'database table does not exists:', 'affiliate-toolkit-starter' ) . ' ' . esc_html( $atkp_listtable_helper->get_listtable_tablename() );
return;
}
$selectedshopid = ATKPTools::get_post_setting( $post->ID, ATKP_LIST_POSTTYPE . '_shopid' );
$productlist = $atkp_listtable_helper->load_list( $post->ID, $selectedshopid );//ATKPTools::get_post_setting( $post->ID, ATKP_LIST_POSTTYPE . '_productlist' );
// echo("$productlist: ".serialize($productlist));
$preferlocalproductinfo = ATKPTools::get_post_setting( $post->ID, ATKP_LIST_POSTTYPE . '_preferlocalproduct' );
if ( $productlist != null ) {
?>
asin );
if ( $prd_found != '' ) {
$value = $prd_found;
}
}
break;
case 'productid':
$prodcollection = atkp_product_collection::load( $value );
if ( $prodcollection != null ) {
$value = $prodcollection->get_main_product();
}
break;
}
if ( $value == '' ) {
continue;
}
$prdid = $value->productid;
if ( $prdid == '' ) {
$prdid = '-';
}
?>
producturl != '' ) {
echo sprintf( '%s %s ', esc_html( $counter ), esc_url( $value->producturl ), esc_html( substr( $value->title, 0, 180 ) ) );
} else {
echo sprintf( '%s %s', esc_html( $counter ), esc_html( substr( $value->title, 0, 180 ) ) );
}
$product_id_display = $value->productid > 0 ? '' . esc_html($value->productid) . ' ' : esc_html($value->productid);
echo wp_kses( sprintf( ' (Unique-ID: %1$s, Product-ID: %2$s) ', esc_html($value->asin), $product_id_display ), array( 'a' => array( 'href' => array(), 'target' => array() ), 'br' => array() ) );
?>
getMessage(), "\n";
}
}
?>
post_type; //ATKPTools::get_post_parameter('post_type', 'string');
if ( ATKP_LIST_POSTTYPE != $posttype ) {
return;
}
$shopid = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_shopid', 'string' );
$source = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_source', 'string' );
$nodeid = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_node_id', 'string' );
$searchdepartment = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_search_department', 'string' );
$searchkeyword = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_search_keyword', 'string' );
$searchorderby = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_search_orderby', 'string' );
$autoimportproducts = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_autoimportproducts', 'bool' );
$autodeleteproducts = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_autodeleteproducts', 'bool' );
if($autodeleteproducts)
$autoimportproducts = false;
$preferlocalproduct = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_preferlocalproduct', 'bool' );
$loadmoreoffers = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_loadmoreoffers', 'bool' );
$productid = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_productid', 'string' );
$listurl = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_listurl', 'url' );
$extsearchlimit = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_extendedsearch_limit', 'int' );
$searchlimit = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_search_limit', 'int' );
$searchtitelfilter = implode( "\n", array_map( 'sanitize_text_field', explode( "\n", ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_search_titelfilter', 'multistring' ) ) ) );
$filterfield1 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield1', 'string' );
$filtertext1 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext1', 'string' );
$filterfield2 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield2', 'string' );
$filtertext2 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext2', 'string' );
$filterfield3 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield3', 'string' );
$filtertext3 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext3', 'string' );
$filterfield4 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield4', 'string' );
$filtertext4 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext4', 'string' );
$filterfield5 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield5', 'string' );
$filtertext5 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext5', 'string' );
$filterfield6 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield6', 'string' );
$filtertext6 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext6', 'string' );
$filterfield7 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield7', 'string' );
$filtertext7 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext7', 'string' );
$filterfield8 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield8', 'string' );
$filtertext8 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext8', 'string' );
$filterfield9 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield9', 'string' );
$filtertext9 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext9', 'string' );
$filterfield10 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filterfield10', 'string' );
$filtertext10 = ATKPTools::get_post_parameter( ATKP_LIST_POSTTYPE . '_filtertext10', 'string' );
$products = '';
$productpara = isset( $_POST[ ATKP_LIST_POSTTYPE . '_products' ] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST[ ATKP_LIST_POSTTYPE . '_products' ] ) ) : null;
if ( $productpara != null ) {
foreach ( $productpara as $selectedproduct ) {
if ( $products == '' ) {
$products = $selectedproduct;
} else {
$products .= "\n" . $selectedproduct;
}
}
}
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_shopid', $shopid );
if ( $shopid == '' ) {
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_listurl', $listurl );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_products', $products );
} else {
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_source', $source );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_autoimportproducts', $autoimportproducts );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_autodeleteproducts', $autodeleteproducts );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_preferlocalproduct', $preferlocalproduct );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_loadmoreoffers', $loadmoreoffers );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_search_department', $searchdepartment );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_search_keyword', $searchkeyword );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_search_orderby', $searchorderby );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_node_id', $nodeid );
//ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE.'_keyword', $keyword);
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_productid', $productid );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_extendedsearch_limit', $extsearchlimit );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_search_limit', $searchlimit );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_search_titelfilter', $searchtitelfilter );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield1', $filterfield1 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext1', $filtertext1 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield2', $filterfield2 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext2', $filtertext2 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield3', $filterfield3 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext3', $filtertext3 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield4', $filterfield4 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext4', $filtertext4 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield5', $filterfield5 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext5', $filtertext5 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield6', $filterfield6 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext6', $filtertext6 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield7', $filterfield7 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext7', $filtertext7 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield8', $filterfield8 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext8', $filtertext8 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield9', $filterfield9 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext9', $filtertext9 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filterfield10', $filterfield10 );
ATKPTools::set_post_setting( $post_id, ATKP_LIST_POSTTYPE . '_filtertext10', $filtertext10 );
}
do_action( 'atkp_list_save_fields', $post_id );
//wenn die Extension nicht geladen ist, kann das Plugin nicht arbeiten
//Wenn keine Einstellungen definiert wurden um Daten zu laden, keine Liste generieren
atkp_queueservices::do_manual_list_update( $post_id, esc_html__( 'Manual list update', 'affiliate-toolkit-starter' ) );
}
}
?>