function column_compet_price($item) { $compet_price = $item['compet_price'] ? $this->number_format($item['compet_price'], 2) : '—'; $listing_url = WPLA_ListingsModel::getUrlForItemObj($item); $view_offers_url = str_replace('/dp/', '/gp/offer-listing/', $listing_url); $view_offers_link = '<a href="' . $view_offers_url . '" target="_blank">» view</a>'; return sprintf('%1$s<br><small style="color:silver">%2$s</small>', $compet_price, $view_offers_link); }
/** ************************************************************************ * Recommended. This is a custom column method and is responsible for what * is rendered in any column with a name/slug of 'title'. Every time the class * needs to render a column, it first looks for a method named * column_{$column_title} - if it exists, that method is run. If it doesn't * exist, column_default() is called instead. * * This example also illustrates how to implement rollover actions. Actions * should be an associative array formatted as 'slug'=>'link html' - and you * will need to generate the URLs yourself. You could even ensure the links * * * @see WP_List_Table::::single_row_columns() * @param array $item A singular item (one full row's worth of data) * @return string Text to be placed inside the column <td> (profile title only) **************************************************************************/ function column_listing_title($item) { // get current page with paging as url param $page = $_REQUEST['page']; if (isset($_REQUEST['paged'])) { $page .= '&paged=' . $_REQUEST['paged']; } $listing_url = WPLA_ListingsModel::getUrlForItemObj($item); $view_pnq_log_url = 'admin-ajax.php?action=wpla_view_pnq_log&sku=' . $item['sku']; //Build row actions $actions = array('edit' => sprintf('<a href="?page=%s&action=%s&listing=%s">%s</a>', 'wpla', 'edit', $item['id'], __('Edit', 'wpla')), 'create_product' => sprintf('<a href="?page=%s&action=%s&listing=%s">%s</a>', $page, 'create_product', $item['id'], __('Create Product', 'wpla')), 'open' => sprintf('<a href="%s" target="_blank">%s</a>', $listing_url, __('View on Amazon', 'wpla')), 'end_item' => sprintf('<a href="?page=%s&action=%s&listing=%s">%s</a>', $page, 'end_item', $item['id'], __('End Listing', 'wpla')), 'resubmit' => sprintf('<a href="?page=%s&action=%s&listing=%s">%s</a>', $page, 'resubmit', $item['id'], __('Submit again', 'wpla')), 'delete' => sprintf('<a href="?page=%s&action=%s&listing=%s">%s</a>', $page, 'delete', $item['id'], __('Delete', 'wpla')), 'view_pnq_log' => sprintf('<a href="%s" target="_blank" class="thickbox">%s</a>', $view_pnq_log_url, __('Changelog', 'wpla'))); // $profile_data = maybe_unserialize( $item['profile_data'] ); $listing_title = $item['listing_title']; // limit item title to 80 characters // if ( WPLA_ListingsModel::mb_strlen($listing_title) > 80 ) $listing_title = WPLA_ListingsModel::mb_substr( $listing_title, 0, 77 ) . '...'; // make title link to products edit page if ($item['post_id']) { $post_id = $item['parent_id'] ? $item['parent_id'] : $item['post_id']; $listing_title = '<a class="product_title_link" href="post.php?post=' . $post_id . '&action=edit">' . $listing_title . '</a>'; } // show warning if WooCommerce product has been deleted if (!$this->getProduct($item['post_id']) && $item['status'] != 'imported') { $tip_msg = 'The product #' . $item['post_id'] . ' has been deleted!<br>Please do <i>not</i> delete products from WooCommerce, or delete the listing first.'; $img_url = WPLA_URL . '/img/error.gif'; $listing_title .= ' <img src="' . $img_url . '" style="height:12px; padding:0;" class="tips" data-tip="' . $tip_msg . '"/> '; $listing_title = str_replace('product_title_link', 'missing_product_title_link', $listing_title); } // add variations link $listing_title .= $this->generateVariationsHtmlLink($item, null); /* // show errors and warning on online and failed items if ( in_array( $item['status'], array( 'online', 'failed' ) ) ) { $history = maybe_unserialize( $item['history'] ); $tips_errors = array(); $tips_warnings = array(); if ( is_array( $history ) ) { foreach ( $history['errors'] as $feed_error ) { $tips_errors[] = WPLA_FeedValidator::formatAmazonFeedError( $feed_error ); } foreach ( $history['warnings'] as $feed_error ) { $tips_warnings[] = WPLA_FeedValidator::formatAmazonFeedError( $feed_error ); } } if ( ! empty( $tips_errors ) ) { $listing_title .= '<br><small style="color:darkred">'.join('<br>',$tips_errors).'</small>'; } if ( ! empty( $tips_warnings ) ) { $listing_title .= '<small><br><a href="#" onclick="jQuery(\'#warnings_container_'.$item['id'].'\').slideToggle();return false;">» '.''.sizeof($tips_warnings).' warning(s)'.'</a></small>'; $listing_title .= '<div id="warnings_container_'.$item['id'].'" style="display:none">'; $listing_title .= '<small>'.join('<br>',$tips_warnings).'</small>'; $listing_title .= '</div>'; } // show description on normal items // } elseif ( $item['description'] ) { // $description = strip_tags( $item['description'] ); // if ( strlen($description) > 100 ) $description = substr( $description, 0, 100 ) . '...'; // $listing_title .= '<br><span style="color:silver">'.$description.'</span>'; } */ // disable some actions depending on status if ($item['status'] != 'imported') { unset($actions['create_product']); } if (!$item['asin']) { unset($actions['open']); } if ($item['status'] != 'published') { unset($actions['end_item']); } if ($item['status'] != 'changed') { unset($actions['revise']); } if ($item['status'] != 'ended') { unset($actions['delete']); } if ($item['status'] != 'ended') { unset($actions['relist']); } if ($item['status'] != 'relisted') { unset($actions['update']); } if ($item['status'] != 'failed') { unset($actions['resubmit']); } if ($_REQUEST['page'] != 'wpla-tools') { unset($actions['view_pnq_log']); } //Return the title contents //return sprintf('%1$s <span style="color:silver">%2$s</span>%3$s', return sprintf('%1$s %2$s', $listing_title, $this->row_actions($actions)); }