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', ATKP_PLUGIN_PREFIX), function($post_id){
$selectedshopid = ATKPTools::get_post_setting($post_id, ATKP_LIST_POSTTYPE.'_shopid', 0);
try {
if($selectedshopid != '' && atkp_shop::exists($selectedshopid))
$shps = atkp_shop::load($selectedshopid, false);
} catch(Exception $ex) {
echo 'parent shop not found. ';
$shps = null;
}
echo '' . __( 'ID', ATKP_PLUGIN_PREFIX ) . ': ' . $post_id . ', ';
if(!isset($shps) || $shps == null)
echo ''.__('Manual list', ATKP_PLUGIN_PREFIX).'';
else
echo ''. __('Shop', ATKP_PLUGIN_PREFIX).': '.$shps->title.'';
$updatedon = ATKPTools::get_post_setting($post_id, ATKP_LIST_POSTTYPE.'_updatedon', true );
if(isset($updatedon) && $updatedon != '') {
$infotext = __('%refresh_date% at %refresh_time%', ATKP_PLUGIN_PREFIX);
$infotext = str_replace('%refresh_date%', ATKPTools::get_formatted_date($updatedon), $infotext);
$infotext = str_replace('%refresh_time%', ATKPTools::get_formatted_time($updatedon), $infotext);
echo '
'. __('Updated on', ATKP_PLUGIN_PREFIX).': '.$infotext.'';
}
$selectedsourceval = ATKPTools::get_post_setting($post_id, ATKP_LIST_POSTTYPE.'_source', 10);
$durations = array(
10 => __('Category - Best Seller', ATKP_PLUGIN_PREFIX),
11 => __('Category - New Releases', ATKP_PLUGIN_PREFIX),
20 => __('Search', ATKP_PLUGIN_PREFIX),
30 => __('Extended Search', ATKP_PLUGIN_PREFIX),
//24 => __('Search - Order items by keywords. Rank is determined by the keywords in the product description.', ATKP_PLUGIN_PREFIX),
//25 => __('Search - Order items by customer reviews, from highest to lowest ranked..', ATKP_PLUGIN_PREFIX),
40 => __('Similarity - Find similar products', ATKP_PLUGIN_PREFIX),
);
foreach ($durations as $value => $name)
if ($value == $selectedsourceval)
{
echo '
'. __('Type', ATKP_PLUGIN_PREFIX).': '.$name.'';
break;
}
$message = ATKPTools::get_post_setting($post_id, ATKP_LIST_POSTTYPE.'_message', true );
if(isset($message) && $message != '') {
echo '
'. __('Message', ATKP_PLUGIN_PREFIX).': '.esc_html($message).'';
}
}, 2);
}
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 )
{
$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' ) {
$query->query_vars['meta_key'] = ATKP_LIST_POSTTYPE . '_message';
$query->query_vars['meta_value'] = '';
$query->query_vars['meta_compare'] = 'EXISTS';
} 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( '', true);
atkp_posttypes_list::$overridefilter = false;
?>
__( 'Lists', ATKP_PLUGIN_PREFIX ),
'singular_name' => __( 'List', ATKP_PLUGIN_PREFIX ),
'add_new_item' => __( 'Add New List', ATKP_PLUGIN_PREFIX ),
'edit_item' => __( 'Edit List' , ATKP_PLUGIN_PREFIX),
'new_item' => __( 'New List' , ATKP_PLUGIN_PREFIX),
'all_items' => __( 'Lists' , ATKP_PLUGIN_PREFIX),
'view_item' => __( 'View List' , ATKP_PLUGIN_PREFIX),
'search_items' => __( 'Search Lists' , ATKP_PLUGIN_PREFIX),
'not_found' => __( 'No lists found' , ATKP_PLUGIN_PREFIX),
'not_found_in_trash' => __( 'No lists found in the Trash' , ATKP_PLUGIN_PREFIX),
'parent_item_colon' => '',
'menu_name' => __( 'AT Lists' , ATKP_PLUGIN_PREFIX),
);
$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_queriable' => true, // you should be able to query it
'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',
);
$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',
__( 'Shop Information', ATKP_PLUGIN_PREFIX),
array(&$this, 'list_shop_box_content'),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
add_meta_box(
ATKP_LIST_POSTTYPE.'_detail_box',
__( 'List Information', ATKP_PLUGIN_PREFIX),
array(&$this, 'list_detail_box_content'),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
add_meta_box(
ATKP_LIST_POSTTYPE.'_preview_box',
__( 'List Preview', ATKP_PLUGIN_PREFIX),
array(&$this, 'list_preview_box_content'),
ATKP_LIST_POSTTYPE,
'normal',
'default'
);
}
function list_shop_box_content( $post ) {
wp_nonce_field( plugin_basename( __FILE__ ), 'list_shop_box_content_nonce' );
?>
|
'.esc_html($message).''; ?> |
|
| ID, ATKP_LIST_POSTTYPE.'_source', 10); ?> | |
| ID, ATKP_LIST_POSTTYPE.'_source') == '' ? true : ATKPTools::get_post_setting($post->ID, ATKP_LIST_POSTTYPE.'_preferlocalproduct'), true); ?>> | |
| ID, ATKP_LIST_POSTTYPE.'_autoimportproducts'), true); ?>> | |
| ID, ATKP_LIST_POSTTYPE.'_loadmoreoffers')); ?>> | |
|
ID, ATKP_LIST_POSTTYPE.'_search_titelfilter', true ); ?> |
|
ID, ATKP_LIST_POSTTYPE.'_products', true ); ?>
|
|
|
|
Shipping Availability', ATKP_PLUGIN_PREFIX ) ?> |
|||
| producturl !='')
echo( $counter.'. '.substr($value->title,0, 180).' ('.$value->asin.', '.$prdid.') '); else echo( $counter.'. '. substr($value->title,0, 180).' ('.$value->asin.', '.$prdid.') '); ?> | ||||
| shopid == $shop->id || $offer->oldid == $shop->id ) { echo esc_attr( $shop->title ); break; } } ?>: link != '') { echo ''.esc_attr($offer->number). ''; } else { echo $offer->number; } ?> | price; ?> price != '' ) { ?> (pricefloat; ?>) | updatedon == null ? __( 'marked for price update', ATKP_PLUGIN_PREFIX ) : 'last update: ' . $offer->updatedon ) ; echo ($offer->message != '' ? ' / ' : ''); echo ( $offer->message != '' && strlen( $offer->message ) > 183 ? substr( $offer->message, 0, 180 ) . '...' : $offer->message ); ?> | ||