function move_to_template() { $migrations = new migrations(); $liste = $migrations->GetLists(); foreach ($liste as $lista) { $term = term_exists($lista->nomelista, 'mailing_lists'); /* TODO: verificare se il term esiste... */ if ($term !== 0 && $term !== null) { echo $lista->nomelista . "Template already migrated!"; } else { //inserisco il post del template $post = array('post_status' => 'publish', 'post_type' => 'sendit_template', 'post_author' => $user_ID, 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_content' => $dummy_content, 'post_name' => 'Template imported from ' . sanitize_title($lista->nomelista), 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_title' => 'Template imported from ' . sanitize_title($lista->nomelista), 'import_id' => 0); $new_template_id = wp_insert_post($post, $wp_error); update_post_meta($new_template_id, 'newsletter_css', ''); update_post_meta($new_template_id, 'headerhtml', $lista->header); update_post_meta($new_template_id, 'footerhtml', $lista->footer); update_post_meta($new_template_id, 'old_list_id', $lista->id_lista); } //end if term exists } }
function add_contacts() { $migrations = new migrations(); $liste = $migrations->GetLists(); //print_r($contact); $html = '<h3><span class="dashicons-before dashicons-admin-users"></span>Add Contacts #</h3>'; $html .= '<div id="contacts_modal_response"></div>'; $html .= '<form method="post" class="senditcontactaddform">'; $html .= '<label for="list_id" class="sendit-form-label">Mailing List</label><br />'; $html .= '<select name="list_id" id="list_id">'; foreach ($liste as $lista) { $html .= '<option value="' . $lista->id_lista . '">' . $lista->id_lista . ' - ' . $lista->nomelista . '</option>'; } $html .= '</select><br />'; $html .= '<label for="email" class="sendit-form-label">email (1 per line)</label><br /> <textarea id="emails" name="emails" cols="50" rows="10" required></textarea><hr />'; $html .= '<button type="button" id="insert_contacts" class="insert_contacts button action">Save</button>'; $html .= '</form>'; echo $html; die; }