/** ************************************************************************ * Recommended. This method is called when the parent class can't find a method * specifically build for a given column. Generally, it's recommended to include * one method for each column you want to render, keeping your package class * neat and organized. For example, if the class needs to process a column * named 'title', it would first see if a method named $this->column_title() * exists - if it does, that method will be used. If it doesn't, this one will * be used. Generally, you should try to use custom column methods as much as * possible. * * Since we have defined a column_title() method later on, this method doesn't * need to concern itself with any column with a name of 'title'. Instead, it * needs to handle everything else. * * For more detailed insight into how columns are handled, take a look at * WP_List_Table::single_row_columns() * * @param array $item A singular item (one full row's worth of data) * @param array $column_name The name/slug of the column to be processed * @return string Text or HTML to be placed inside the column <td> **************************************************************************/ function column_default($item, $column_name) { switch ($column_name) { case 'rating': case 'director': return $item[$column_name]; case 'count_subscribers': $role = get_post_meta($item->ID, 'sync_role', true); $add = ''; if ($role != 'none' && $role != false) { $add = " - <a href='" . SendPress_Admin::link('Subscribers_Sync') . "&listID=" . $item->ID . "'>" . __('Sync', 'sendpress') . "</a>"; } return SendPress_data::get_count_subscribers($item->ID) . $add; case 'count_unsubscribes': return SendPress_data::get_count_subscribers($item->ID, 3); case 'count_bounced': return SendPress_data::get_count_subscribers($item->ID, 4); case 'last_send_date': return date('Y-m-d'); case 'actions': $role = get_post_meta($item->ID, 'sync_role', true); $add = ''; if ($role != 'none' && $role != false) { $add = " - <a href='" . SendPress_Admin::link('Subscribers_Sync') . "&listID=" . $item->ID . "'>" . __('Sync', 'sendpress') . "</a>"; } $str = '<div class="inline-buttons"> <a class="btn btn-info" href="?page=' . SPNL()->validate->page($_REQUEST['page']) . '&view=subscribers&listID=' . $item->ID . '"><span class="glyphicon glyphicon-edit"></span> ' . __('View', 'sendpress') . '/' . __('Edit', 'sendpress') . '</a> '; $role = get_post_meta($item->ID, 'sync_role', true); $add = ''; if ($role != 'none' && $role != false) { $str .= "<a class='btn btn-primary' href='" . SendPress_Admin::link('Subscribers_Sync') . "&listID=" . $item->ID . "'><span class='glyphicon glyphicon-refresh'></span> " . __('Sync', 'sendpress') . "</a> "; } else { if (apply_filters('sendpress_show_import_button', true, $this->_sendpress)) { $str .= '<a class="list-import btn btn-primary" href="?page=' . SPNL()->validate->page($_REQUEST['page']) . '&view=csvimport&listID=' . $item->ID . '"><span class="glyphicon glyphicon-upload"></span> ' . __('Import', 'sendpress') . '</a> '; } $str .= '<a class="btn btn-primary" href="?page=' . SPNL()->validate->page($_REQUEST['page']) . '&view=add&listID=' . $item->ID . '"><span class="glyphicon glyphicon-user"></span> ' . __('Add', 'sendpress') . '</a> '; $str .= '<a class="btn btn-primary" href="?page=' . SPNL()->validate->page($_REQUEST['page']) . '&action=export-list&listID=' . $item->ID . '"><span class="glyphicon glyphicon-download"></span> ' . __('Export', 'sendpress') . '</a> '; $str .= '<a class="btn btn-primary" href="' . SendPress_Admin::link('Subscribers_Listform', array('listID' => $item->ID)) . '"><span class="glyphicon glyphicon-list"></span> ' . __('Form', 'sendpress') . '</a> '; } $str .= '<a class="btn " href="?page=' . SPNL()->validate->page($_REQUEST['page']) . '&view=listedit&listID=' . $item->ID . '"><i class="icon-cog"></i></a> </div>'; return $str; default: return print_r($item, true); //Show the whole array for troubleshooting purposes } }
static function create_settings_post($title = 'Settings', $type = "", $copy_from = 0) { $defaults = SendPress_data::get_default_settings_for_type($type); // Create post object $my_post = array('post_title' => $title, 'post_status' => 'draft', 'post_type' => 'sp_settings'); // Insert the post into the database $postid = wp_insert_post($my_post); add_post_meta($postid, "_sp_settings_id", $postid, true); if ($copy_from > 0) { $defaults = SendPress_Data::get_post_meta_object($copy_from, false); } foreach ($defaults as $key => $value) { add_post_meta($postid, $key, $value, true); } return $postid; }