/** * Adding a new admin * * @param string $admin_name * @param string $admin_id * * @return string */ public function add_admin($admin_name, $admin_id) { $success = 0; // If one of the fields is empty. if (empty($admin_name) || empty($admin_id)) { $response_body = $this->get_response_body('not_present'); } else { $admin_id = $this->parse_admin_id($admin_id); if (!isset($this->options['fb_admins'][$admin_id])) { $name = sanitize_text_field(urldecode($admin_name)); $admin_id = sanitize_text_field($admin_id); if (preg_match('/[0-9]+?/', $admin_id) && preg_match('/[\\w\\s]+?/', $name)) { $this->options['fb_admins'][$admin_id]['name'] = $name; $this->options['fb_admins'][$admin_id]['link'] = urldecode('http://www.facebook.com/' . $admin_id); $this->save_options(); $success = 1; $response_body = $this->form->get_admin_link($admin_id, $this->options['fb_admins'][$admin_id]); } else { $response_body = $this->get_response_body('invalid_format'); } } else { $response_body = $this->get_response_body('already_exists'); } } return json_encode(array('success' => $success, 'html' => $response_body)); }
/** * Returns the output from the form class * */ public function show_form() { $form = new Yoast_Social_Facebook_Form(); $form->show_form(); }