/** * Wordpress Settings Page Form * * @param null $defaults * @return Nette\Forms\Form */ public static function settings($defaults = NULL) { // prep $emailSubjectName = isset($defaults['senderName']) ? $defaults['senderName'] : html_entity_decode(get_option('blogname'), ENT_QUOTES); // Form $form = new Form('adminSettings'); // Cron settings $form->addGroup('Cron Settings'); $formCron = $form->addContainer('cron'); $formCron->addSelect('timing', 'Select when the post e-mail should be sent.', array('When a new post is published. (not recommended)', 'In the morning. (approx. 9AM)', 'In the evening. (approx. 9PM)')); // Misc $form->addGroup('Miscellaneous Settings'); $formMisc = $form->addContainer('misc'); $formMisc->addSelect('deactivation', 'Upon user\'s unsubscription from e-mail digest', array('Delete User', 'Only Deactivate User (that\'s evil)')); $formMisc->addText('senderEmail', 'Sender\'s e-mail address, one used to send e-mail digest from')->setOption('description', 'Default: ' . get_option('admin_email'))->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Must be valid e-mail address'); $formMisc->addText('senderName', 'Sender\'s name')->setOption('description', 'Default: ' . html_entity_decode(get_option('blogname'), ENT_QUOTES)); $formMisc->addSelect('emailSubject', 'Post digest e-mail subject', array('New Post from ' . $emailSubjectName, 'POST_TITLE by ' . $emailSubjectName, 'POST_TITLE')); $formMisc->addCheckbox('log', 'Enable message log')->setOption('description', '(logs errors, cron schedules, successfully sent digests, etc.)'); // if blog is on different url, allow users to select back button url if (\SimpleSubscribe\Utils::getPostsPageUrl()) { $homeUrlDesc = Html::el('small')->setHtml('Backlink on ' . Html::el('a', array('href' => SUBSCRIBE_API_URL, 'target' => '_blank'))->setText('confirmation / unsubscription page') . ', by default it\'s homepage.'); $formMisc->addSelect('homeUrl', 'Homepage link', array(SUBSCRIBE_HOME_URL, \SimpleSubscribe\Utils::getPostsPageUrl()))->setOption('description', $homeUrlDesc); } // Form fields $form->addGroup('Additional subscribe form fields'); $formForm = $form->addContainer('form'); $formForm->addCheckbox('firstName', 'First Name'); $formForm->addCheckbox('lastName', 'Last Name'); $formForm->addCheckbox('age', 'Age'); $formForm->addCheckbox('interests', 'Interests'); $formForm->addCheckbox('location', 'Location'); // Categories $form->addGroup('Digest Category'); $formCat = $form->addContainer('cat'); // List thru categories $formCat->addCheckbox('0', 'All')->setOption('description', 'If you select All, the other categories will deselect automatically.'); foreach (get_categories(array('hide_empty' => 0)) as $category) { $formCat->addCheckbox($category->term_id, $category->name); } $form->addGroup(); // Js $form->addGroup('Front-end'); $formVal = $form->addContainer('val'); $formVal->addCheckbox('js', 'Use javascript validation in the front-end?'); $formVal->addCheckbox('css', 'Use SimpleSubscribe stylesheet?'); // Submit $form->addSubmit('submit', 'Save')->setAttribute('class', 'button-primary'); // set dafaults if ($defaults) { $form->setDefaults($defaults); } return $form; }
/** * Backbutton homepage link * * @return null */ public function getBackLinkUrl() { $postsPage = \SimpleSubscribe\Utils::getPostsPageUrl(); $postsPageSettings = isset($this->options['misc']['homeUrl']) ? TRUE : FALSE; if ($postsPageSettings) { return $postsPage; } return SUBSCRIBE_HOME_URL; }