/** * This function will create new registration forms for students and parents. * * This function is responsible for creating new registration forms for both * students and parents. This function will only create new registration forms * for students and parents if it is used ONLY in conjunction with the form * used to create new music competitions. * * @param Entry Object $entry The entry that was just submitted * @param Form Object $form The form used to submit entries * * @since 1.0.0 * @author KREW */ public static function aria_create_teacher_and_student_forms($confirmation, $form, $entry, $ajax) { // make sure the create competition form is calling this function $competition_creation_form_id = ARIA_API::aria_get_create_competition_form_id(); if ($form['id'] === $competition_creation_form_id) { /* Calls wp_die and returns a value of 86? self::aria_update_page_ids(); */ $field_mapping = self::aria_get_competition_entry_meta(); $competition_name = $entry[$field_mapping['Name of Competition']]; // create the student and teacher forms $student_form_id = self::aria_create_student_form($entry); $teacher_form_id = self::aria_create_teacher_form($entry, unserialize($entry[(string) $field_mapping['Volunteer Times']])); $student_form_url = self::aria_publish_form("{$competition_name} Student Registration", $student_form_id); $teacher_form_url = self::aria_publish_form("{$competition_name} Teacher Registration", $teacher_form_id); // create the sutdent and teacher (master) forms $student_master_form_id = ARIA_Create_Master_Forms::aria_create_student_master_form($competition_name); $teacher_master_form_id = ARIA_Create_Master_Forms::aria_create_teacher_master_form($competition_name); $related_forms = array('student_public_form_id' => $student_form_id, 'teacher_public_form_id' => $teacher_form_id, 'student_master_form_id' => $student_master_form_id, 'teacher_master_form_id' => $teacher_master_form_id, 'student_public_form_url' => $student_form_url, 'teacher_public_form_url' => $teacher_form_url); $student_public_form = GFAPI::get_form($student_form_id); $teacher_public_form = GFAPI::get_form($teacher_form_id); $student_master_form = GFAPI::get_form($student_master_form_id); $teacher_master_form = GFAPI::get_form($teacher_master_form_id); $student_public_form['aria_relations'] = $related_forms; $teacher_public_form['aria_relations'] = $related_forms; $student_master_form['aria_relations'] = $related_forms; $teacher_master_form['aria_relations'] = $related_forms; GFAPI::update_form($student_public_form); GFAPI::update_form($teacher_public_form); GFAPI::update_form($student_master_form); GFAPI::update_form($teacher_master_form); $teacher_public_form = GFAPI::get_form($teacher_form_id); $confirmation = 'Congratulations! A new music competition has been '; $confirmation .= 'created. The following forms are now available for '; $confirmation .= ' students and teachers to use for registration: </br>'; $confirmation .= "<a href={$student_form_url}>{$competition_name} Student Registration</a>"; $confirmation .= " was published. </br>"; $confirmation .= "<a href={$teacher_form_url}> {$competition_name} Teacher Registration </a>"; $confirmation .= " was published."; return $confirmation; } else { wp_die("ERROR: No form currently exists that allows the festival chairman\n to create a new music competition \n FormID: {$form[id]} \n func_call {$competition_creation_form_id}"); } }
/** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Plugin_Name_Loader. Orchestrates the hooks of the plugin. * - Plugin_Name_i18n. Defines internationalization functionality. * - Plugin_Name_Admin. Defines all hooks for the admin area. * - Plugin_Name_Public. Defines all hooks for the public side of the site. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 1.0.0 * @access private */ private function load_dependencies() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-aria-loader.php'; $this->loader = new ARIA_Loader(); /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-plugin-name-i18n.php'; /** * The class responsible for defining all actions that occur in the admin area. */ require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-plugin-name-admin.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-aria-public.php'; // Include all of the ARIA files needed as dependencies. require_once "class-aria-create-competition.php"; require_once "class-aria-music.php"; require_once "class-aria-form-hooks.php"; // Register all of the hooks needed by ARIA // Creating student and teacher forms /* !!! like below, this might not work if aria_get_create_competition_form_id returns a value of -1. !!! */ $this->loader->add_action('gform_confirmation_' . strval(ARIA_API::aria_get_create_competition_form_id()), 'ARIA_Create_Competition', 'aria_create_teacher_and_student_forms', 10, 4); $this->loader->add_action('gform_after_submission', 'ARIA_Form_Hooks', 'aria_after_student_submission', 10, 2); // Adding music upload/download functionality $this->loader->add_action('gform_after_submission_' . strval(ARIA_API::aria_get_song_upload_form_id()), 'ARIA_Music', 'aria_add_music_from_csv', 10, 2); // For before/after student and teacher registration /* note: these values are hardcoded for now can't do this here because we do not know the form ID of the student form before the create competition functionality is invoked */ /* $this->loader->add_action('gform_after_submission_292', 'ARIA_Form_Hooks', 'aria_after_student_submission', 10, 2); */ // Modifying the upload path $this->loader->add_filter('gform_upload_path', 'ARIA_Music', 'aria_modify_upload_path', 10, 2); }