示例#1
0
 /**
  * @param string $status
  *
  * @return int The number of forms changed
  */
 public static function change_form_status($status)
 {
     $available_status = array('untrash' => array('permission' => 'frm_edit_forms', 'new_status' => 'published'), 'trash' => array('permission' => 'frm_delete_forms', 'new_status' => 'trash'));
     if (!isset($available_status[$status])) {
         return;
     }
     FrmAppHelper::permission_check($available_status[$status]['permission']);
     $params = FrmForm::list_page_params();
     //check nonce url
     check_admin_referer($status . '_form_' . $params['id']);
     $count = 0;
     if (FrmForm::set_status($params['id'], $available_status[$status]['new_status'])) {
         $count++;
     }
     $available_status['untrash']['message'] = sprintf(_n('%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable'), $count);
     $available_status['trash']['message'] = sprintf(_n('%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable'), $count, '<a href="' . esc_url(wp_nonce_url('?page=formidable&frm_action=untrash&form_type=' . (isset($_REQUEST['form_type']) ? sanitize_title($_REQUEST['form_type']) : '') . '&id=' . $params['id'], 'untrash_form_' . $params['id'])) . '">', '</a>');
     $message = $available_status[$status]['message'];
     self::display_forms_list($params, $message);
 }