/** * Get redirect * * @since 0.1.0 */ public function get_redirect($id) { $item = Red_Item::get_by_id($id); $object = new StdClass(); $object->id = $item->get_id(); $object->from = $item->get_url(); $object->to = $item->get_action_data(); return $object; }
function process_bulk_action() { if (!isset($_POST['item'])) { return; } if (in_array($this->current_action(), array('reset', 'enable', 'disable', 'delete'))) { $redirections = array(); foreach ((array) $_POST['item'] as $id) { $redirect = Red_Item::get_by_id(intval($id)); if ($redirect) { $redirections[] = $redirect; } } array_map(array(&$this, 'process_action_items'), $redirections); Red_Module::flush($this->current_group->module_id); } }
public function ajax_redirect_save() { global $hook_suffix; $hook_suffix = ''; $red_id = intval($_POST['id']); $this->check_ajax_referer('redirection-redirect_save_' . $red_id); $redirect = Red_Item::get_by_id($red_id); if ($redirect) { $redirect->update($_POST); $pager = new Redirection_Table(array()); $json = array('html' => $pager->column_url($redirect), 'code' => $redirect->get_action_code()); } else { $json['error'] = __('Unable to perform action') . ' - could not find redirect'; } $this->output_ajax_response($json); }
function red_redirect_move() { if (check_ajax_referer('redirection-items')) { $target = intval($this->post['target']); if (preg_match_all('/=(\\d*)/', $this->post['checked'], $items) > 0) { foreach ($items[1] as $item) { $redirect = Red_Item::get_by_id($item); $redirect->move_to($target); } } } }
function save_order($items, $start) { global $wpdb; foreach ($items as $pos => $id) { $wpdb->update($wpdb->prefix . 'redirection_items', array('position' => $pos + $start), array('id' => $id)); } $item = Red_Item::get_by_id($id); $group = Red_Group::get($item->group_id); if ($group) { Red_Module::flush($group->module_id); } }
function process_bulk_action() { if (!isset($_POST['item'])) { return; } if (in_array($this->current_action(), array('reset', 'enable', 'disable', 'delete'))) { $redirections = array(); $flush = array(); foreach ((array) $_POST['item'] as $id) { $redirect = Red_Item::get_by_id(intval($id)); if ($redirect) { if ($this->current_action() === 'reset') { $redirect->reset(); } elseif ($this->current_action() === 'enable') { $redirect->enable(); $flush[] = $redirect->get_group_id(); } elseif ($this->current_action() === 'disable') { $redirect->disable(); $flush[] = $redirect->get_group_id(); } elseif ($this->current_action() === 'delete') { $redirect->delete(); } } } $flush = array_unique($flush); foreach ($flush as $group_id) { Red_Module::flush($group_id); } } }
function save_order($items, $start) { global $wpdb; foreach ($items as $pos => $id) { $wpdb->query("UPDATE {$wpdb->prefix}redirection_items SET position='" . ($pos + $start) . "' WHERE id='{$id}'"); } $item = Red_Item::get_by_id($id); $group = Red_Group::get($item->group_id); Red_Module::flush($group->module_id); }