/** ************************************************************************ * 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) { $settings = SendPress_Data::get_post_meta_object($item->ID); switch ($column_name) { case 'name': return $item->post_title; break; case 'type': return ucwords(str_replace('_', ' ', $settings['_form_type'])); break; case 'shortcode': return '[sp-form formid=' . $item->ID . ']'; break; case 'actions': //$type = get_post_meta($item->ID, "_template_type", true); $a = '<div class="inline-buttons" style="text-align:right;">'; $a .= '<a class="btn btn-default" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID, 'create' => 1)) . '">' . __('Clone', 'sendpress') . '</a> <a class="btn btn-primary" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID)) . '">' . __('Edit', 'sendpress') . '</a>' . '</a> <a class="btn btn-danger" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID, 'delete' => 1)) . '">' . __('Delete', 'sendpress') . '</a>'; $a .= '</div>'; return $a; break; default: return print_r($item, true); //Show the whole array for troubleshooting purposes } }
/** * Output the form * * @param array $atts */ public static function output($atts, $content = null) { extract(shortcode_atts(self::options(), $atts)); if (is_numeric($formid)) { $options = SendPress_Data::get_post_meta_object($formid); } else { $options = false; } if (!$options) { switch ($formid) { case 'manage': $options = SendPress_Data::get_default_settings_for_type('manage_subscriptions', true); break; case 'signup': $options = SendPress_Data::get_default_settings_for_type('signup_widget', true); break; } } if ($options) { switch ($options['_form_type']) { case 'signup_widget': self::signup($options); break; case 'manage_subscriptions': //self::manage_sub_prerender(); self::manage_subscription($options); break; } } }
function html($sp) { $postid = isset($_GET['id']) ? $_GET['id'] : 0; $showCreate = isset($_GET['create']) && $_GET['create'] == 1 ? true : false; $showDelete = isset($_GET['delete']) && $_GET['delete'] == 1 ? true : false; $settings = SendPress_Data::get_post_meta_object($postid); $settings['_settings_id'] = $postid; if (!$postid && !$showCreate) { //self::display_forms(); $settings['_form_type'] = ''; } if ($showCreate) { //self::create_form(); $settings['_form_type'] = 'create_form'; } if ($showDelete) { //self::create_form(); $settings['_form_type'] = 'delete_form'; } if (strlen($settings['_form_type']) > 0) { echo '<form method="post" id="post">'; } switch ($settings['_form_type']) { case 'create_form': self::create_form(); break; case 'delete_form': self::delete_form(); break; case 'signup_widget': self::signup($settings); break; case 'manage_subscriptions': self::manage_subscriptions($settings); break; default: self::display_forms(); break; } if (strlen($settings['_form_type']) > 0) { wp_nonce_field($sp->_nonce_value); echo '</form>'; } }
static function update_post_meta_object($postid, $data) { $options = SendPress_Data::get_post_meta_object($postid); foreach ($options as $key => $value) { if (array_key_exists($key, $data)) { update_post_meta($postid, '_sp' . $key, $data[$key]); } else { update_post_meta($postid, '_sp' . $key, false); } } foreach ($data as $key => $value) { if (!array_key_exists($key, $options)) { update_post_meta($postid, '_sp' . $key, $data[$key]); } } }