application_form($post_id); } /** * Returns array of application features. * * @since 1.6 * @access public * @var string $post_id Post id. * @return array Application form fields. */ function aol_features($post_id = 0){ $aol = new SinglePostTemplate(); return $aol->ad_features(); } /** * Returns array of application form fields. * * @since 1.6 * @access public * @var string $post_id Post id. * @return array Application form fields. */ function aol_form_fields($post_id = 0){ $aol = new SinglePostTemplate(); return $aol->application_form_fields($post_id); } /** * Returns array of application form fields in correct order. * * @since 1.6 * @access public * @var string $post_id Post id. * @return array Application form fields. */ function get_aol_ad_post_meta($post_id){ $form_fields = array(); $keys_order = get_post_meta($post_id, '_aol_fields_order', TRUE); $metas = get_post_meta($post_id); //If fields order is not set in DB then fetch all form fields without order. if(empty($keys_order)){ foreach ($metas as $key => $val){ if(substr($key, 0, 9) == '_aol_app_') $form_fields[$key] = unserialize ($val[0]); } } //Get fields according to field order. else{ foreach ($keys_order as $key){ $form_fields[$key] = unserialize($metas[$key][0]); } } return $form_fields; } function aol_ad_filters(){ $filters = array(__('Category', 'apply-online') => __('Categories', 'apply-online'), __('Type', 'apply-online') => __('Types', 'apply-online'), __('Location', 'apply-online') => __('Locations', 'apply-online')); return apply_filters('aol_ad_filters', $filters); } function aol_app_statuses(){ $filters = array('pending' => 'Pending', 'rejected'=>'Rejected', 'shortlisted' => 'Shortlisted'); return apply_filters('aol_app_statuses', $filters); } function aol_ad_current_filters(){ $filters = aol_ad_filters(); $set_filters = get_option('aol_ad_filters', array()); if(!is_array($set_filters)) $set_filters = array(); foreach ($filters as $key => $val){ if(!in_array(sanitize_key($key), $set_filters)) unset($filters[$key]); } return $filters; } function aol_ad_cpt_filters($cpt){ $filters = aol_ad_filters(); $types = get_option('aol_ad_types', array()); $cpt_filters = isset($types[$cpt]['filters']) ? (array)$types[$cpt]['filters']: array(); foreach ($filters as $key => $val){ if(!in_array(sanitize_key($key), $cpt_filters)) unset($filters[$key]); } return $filters; } function aol_sanitize_taxonomies($taxonomies){ $tax_keys; foreach($taxonomies as $key => $tax){ $tax_keys[] = 'aol_ad_'.sanitize_key($key); } return $tax_keys; } if ( ! function_exists( 'aol_set_current_menu' ) ) { function aol_set_current_menu( $parent_file ) { global $submenu_file, $current_screen, $pagenow; # Set the submenu as active/current while anywhere in your Custom Post Type (nwcm_news) if ( $current_screen->post_type == 'aol_ad' ) { if ( $pagenow == 'edit-tags.php' or $pagenow == 'term.php' ) { $submenu_file = 'edit-tags.php?taxonomy='.str_replace('edit-', '', $current_screen->id).'&post_type=' . $current_screen->post_type; $parent_file = 'aol-settings'; } } return $parent_file; } add_filter( 'parent_file', 'aol_set_current_menu' ); } function aol_array_check($array){ if(!is_array($array)) $array = array(); return $array; } function aol_sanitize_filters($types){ foreach($types as $key => $type){ $types[$key] = array_merge(array('filters' => null), $type); } return $types; }