/** * Renders the rest of the columns in the list table. * * @since 2.0.0 * * @param object $optin The optin object. * @param string $column_name The name of the column. * @return string $value The value of the column. */ public function column_default($optin, $column_name) { // Load the track datastore interface. $track_store = new Optin_Monster_Track_Datastore($optin->ID); switch ($column_name) { case 'name': $value = !empty($optin->post_title) ? $optin->post_title : $optin->post_name; break; case 'notes': $value = get_post_meta($optin->ID, '_om_split_notes', true); $split = get_post_meta($optin->ID, '_om_is_clone', true); if (empty($split)) { $value = '<span class="om-split-test-title">' . __('Parent Optin', 'optin-monster') . '</span>'; } break; case 'impressions': $value = number_format($track_store->get_impressions()); break; case 'conversions': $value = number_format($track_store->get_conversions()); break; case 'percent': $imp = $track_store->get_impressions(); $conv = $track_store->get_conversions(); $value = 0 == $conv ? '0' : number_format($conv / $imp * 100, 2) . '%'; break; case 'status': $meta = get_post_meta($optin->ID, '_om_meta', true); $value = Optin_Monster_Common::get_instance()->get_optin_status($meta); $value .= '<div class="row-actions">'; $value .= Optin_Monster_Common::get_instance()->get_optin_status_link($meta, $optin->ID); $value .= '</div>'; break; case 'settings': $link = '<a href="#" class="om-settings-button" title="' . esc_attr__('Optin settings', 'optin-monster') . '"><i class="fa fa-cog"></i></a>'; $link .= '<div class="om-settings-popover">'; $link .= $this->get_settings_actions($optin); $link .= '</div>'; $value = $link; break; default: $value = apply_filters('optin_monster_column_value', '', $optin, $column_name); break; } return apply_filters('optin_monster_table_column', $value, $optin, $column_name); }
/** * Collects data about the optins. * * @since 2.1.0 * @return array */ private function get_optins() { if (!class_exists('Optin_Monster_Track_Datastore')) { require plugin_dir_path($this->base->file) . 'includes/global/track-datastore.php'; } $optin_posts = $this->base->get_optins(); $optins = array(); foreach ((array) $optin_posts as $optin) { $datastore = new Optin_Monster_Track_Datastore($optin->ID); $meta = get_post_meta($optin->ID, '_om_meta', true); $optins[] = array('type' => isset($meta['type']) ? $meta['type'] : 'Unknown', 'theme' => isset($meta['theme']) ? $meta['theme'] : 'Unknown', 'impressions' => $datastore->get_impressions(), 'conversions' => $datastore->get_conversions(), 'affiliate_link' => isset($meta['powered_by']) ? $meta['powered_by'] : 0); } return $optins; }