__('January', 'affiliate-power'), 'month2' => __('February', 'affiliate-power'), 'month3' => __('March', 'affiliate-power'), 'month4' => __('April', 'affiliate-power'), 'month5' => __('May', 'affiliate-power'), 'month6' => __('June', 'affiliate-power'), 'month7' => __('July', 'affiliate-power'), 'month8' => __('August', 'affiliate-power'), 'month9' => __('September', 'affiliate-power'), 'month10' => __('October', 'affiliate-power'), 'month11' => __('November', 'affiliate-power'), 'month12' => __('December', 'affiliate-power'), 'day1' => __('Sun', 'affiliate-power'), 'day2' => __('Mon', 'affiliate-power'), 'day3' => __('Tue', 'affiliate-power'), 'day4' => __('Wed', 'affiliate-power'), 'day5' => __('Thu', 'affiliate-power'), 'day6' => __('Fri', 'affiliate-power'), 'day7' => __('Sat', 'affiliate-power') ) ); //wp_enqueue_style( 'wp-jquery-ui-datepicker' ); wp_enqueue_style('jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); } //-------------- //CHANGE EXISTING ADMIN PAGES //-------------- static public function addEarningsColummnToPosts($defaults) { if ( current_user_can('manage_options') ) { $defaults['earnings'] = __('Affiliate Income', 'affiliate-power'); } return $defaults; } static public function addEarningsToPosts($column_name, $id) { if ( $column_name == 'earnings' && current_user_can('manage_options') ) { global $wpdb; $sql = $wpdb->prepare(' SELECT sum(Commission), sum(Confirmed) FROM '.$wpdb->prefix.'ap_transaction LEFT JOIN '.$wpdb->prefix.'ap_clickout ON '.$wpdb->prefix.'ap_transaction.SubId = '.$wpdb->prefix.'ap_clickout.ap_clickoutID WHERE '.$wpdb->prefix.'ap_clickout.postID = %d OR '.$wpdb->prefix.'ap_transaction.SubId = %d AND TransactionStatus <> "Cancelled"', $id, $id); $arr_earnings = $wpdb->get_row($sql, ARRAY_N); $total_earning = number_format($arr_earnings[0], 2, ',', '.'); $confirmed_earning = number_format($arr_earnings[1], 2, ',', '.'); $output = $total_earning . ' € ('.$confirmed_earning.' €)'; //$output = $arr_earnings[0]; echo $output; } } static public function addPluginLinks($links, $file) { if (is_array($links)) $links[] = ''.__('Settings').''; return $links; } static public function makeEarningsColumnSortable( $columns ) { $columns['earnings'] = 'earnings'; return $columns; } //todo: fix sort, this is not working because earnings is not in post data table static public function handleSortEarningsColumn( $vars ) { if ( isset( $vars['orderby'] ) && $vars['orderby'] == 'earnings' ) { $vars = array_merge( $vars, array( 'meta_key' => 'earnings', 'orderby' => 'meta_value_num' ) ); } return $vars; } } ?>