/** * Function, check for POST data and update billboard accordingly * will redirect if successful * * @return void */ function uds_billboard_process_updates() { global $uds_billboard_attributes, $uds_billboard_general_options; $post = isset($_POST['uds_billboard']) ? $_POST['uds_billboard'] : array(); if (empty($post) || !is_admin()) { return; } $billboard = new uBillboard(); $billboard->update($post); if ($billboard->isValid()) { $message = ''; if ((int) $post['regenerate-thumbs'] != 0) { if (!$billboard->createThumbs()) { $message = 'uds-message=' . urlencode(__('Failed to generate thumbnails', uds_billboard_textdomain)) . '&uds-class=' . urlencode('warning'); } } $billboards = maybe_unserialize(get_option(UDS_BILLBOARD_OPTION, array())); $billboards[$billboard->name] = $billboard; update_option(UDS_BILLBOARD_OPTION, maybe_serialize($billboards)); if (empty($message)) { $message = 'uds-message=' . urlencode(__('Billboard updated successfully', uds_billboard_textdomain)) . '&uds-class=' . urlencode('updated'); } if (is_ajax()) { die('OK'); } } else { $message = 'uds-message=' . urlencode(__('Failed to update uBillboard', uds_billboard_textdomain)) . '&uds-class=' . urlencode('error'); } if (is_ajax()) { die('ERROR'); } wp_safe_redirect(admin_url('admin.php?page=uds_billboard_edit&uds-billboard-edit=' . urlencode($billboard->name) . '&' . $message)); exit; }
function uds_billboard_import_v2() { $v2 = uds_billboard_get_v2(); $billboards = uBillboard::upgradeFromV2($v2); update_option(UDS_BILLBOARD_OPTION, maybe_serialize($billboards)); $message = 'uds-message=' . urlencode(__('Billboards imported successfully', uds_billboard_textdomain)) . '&uds-class=' . urlencode('updated'); wp_redirect('admin.php?page=uds_billboard_admin&' . $message); }
<?php // Load Billboards $billboards = maybe_unserialize(get_option(UDS_BILLBOARD_OPTION, array())); // Select billboard for editing if (!empty($_GET['uds-billboard-edit']) && !empty($billboards[$_GET['uds-billboard-edit']])) { $billboard = $billboards[$_GET['uds-billboard-edit']]; } // safety check if (!isset($billboard) || !is_a($billboard, 'uBillboard')) { $billboard = new uBillboard(); $billboard->setUniqueName(); } // Add new empty slide at the end, if the user wants to add new slide $billboard->addEmptySlide(); ?> <div class="wrap"> <!-- Heading --> <div id="icon-edit" class="icon32 icon32-posts-post"><br /></div> <h2><?php _e('Edit uBillboard', uds_billboard_textdomain); ?> </h2> <!-- Form --> <form id="billboard_update_form" method="post" action="<?php echo admin_url('admin.php?page=uds_billboard_edit&uds-billboard=' . $billboard->name); ?> " class="uds-billboard-form"> <?php wp_nonce_field('uds-billboard-update', 'uds-billboard-update-nonce'); ?>