/** * Basic form submit info. * * @param array $attr * @param array $postData * * @return array|bool */ protected function handleFormSubmit($attr, $postData) { $postData = isset($postData[$this->getUniqueId()]) ? $postData[$this->getUniqueId()] : false; $status = array(); // Only do some work, if we have a type and the postData points to us. if (isset($attr['type']) && $postData) { switch (strtolower($attr['type'])) { case 'subscribe': $status = $this->handleSubscribeSubmit($attr, $postData); break; case 'unsubscribe': $status = $this->handleUnsubscribe($attr, $postData); break; default: } } // Store status for templating TemplateWrapper::registerInstance('submit', $status); return $status; }
// Use a PSR-4 autoloader for our classes // Register the Shortcode $wptripolis_shortcode = new \WPTripolis\WPTripolisShortcode(__FILE__); // Admin only stuff includes the "settings" page and the "Tools" page if (is_admin()) { $wptripolis_admin = new \WPTripolis\OptionsScreen(__FILE__); // Here be the Settings page $wptripolis_tool = new \WPTripolis\WPTripolisShortcodeGenerator(__FILE__, 'WP-Tripolis Generator', 'Generate Tripolis code'); // Here be the Shortcode generator tool } // =================================================================== // Boring definitions here // =================================================================== // To not scare away all the people, have some wrappers for templates // Setup the wrapper \WPTripolis\TemplateWrapper::registerInstance('shortcode', $wptripolis_shortcode); // Define functions /** * Field Loop function. Initializes loop, or iterates to next field * * @return bool */ function wptripolis_have_fields() { return \WPTripolis\TemplateWrapper::haveFields(); } /** * Returns the complete field definition as an array * * @return array|FALSE */