Working on the custom taxonomy search
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Dec 2014 20:24:24 +0000 (15:24 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Dec 2014 20:24:24 +0000 (15:24 -0500)
controllers/admin.php
controllers/front.php
models/job.php
models/list-applications.php

index 0dabf7d..5af6a65 100644 (file)
@@ -34,14 +34,14 @@ class glm_employment_admin
             'applications',
             array($this, 'get_applications')
         );
-        add_submenu_page(
-            'edit.php?post_type=' . GLM_EMP_POST_TYPE,
-            'settings',
-            'Settings',
-            'manage_options',
-            'job_settings',
-            array($this, 'show_job_settings')
-        );
+//        add_submenu_page(
+//            'edit.php?post_type=' . GLM_EMP_POST_TYPE,
+//            'settings',
+//            'Settings',
+//            'manage_options',
+//            'job_settings',
+//            array($this, 'show_job_settings')
+//        );
     }
 
     public function show_job_settings()
index ad53b0a..ec99176 100644 (file)
@@ -276,8 +276,10 @@ class glm_employment_front
                     if (!isset($field['name'])) {
                         continue;
                     }
+//                    $form[$rowKey][$fieldKey]['value']
+//                        = filter_var($_REQUEST[$field['name']], FILTER_SANITIZE_STRING);
                     $form[$rowKey][$fieldKey]['value']
-                        = filter_var($_REQUEST[$field['name']], FILTER_SANITIZE_STRING);
+                        = filter_input(INPUT_POST, $field['name'], FILTER_SANITIZE_STRING);
                     if (in_array($field['name'], array('fname', 'lname', 'mname'))) {
                         $this->$field['name'] = $form[$rowKey][$fieldKey]['value'];
                     }
index bf7681e..643e11f 100644 (file)
@@ -9,7 +9,8 @@ class glm_employment_job
     {
         $this->pluginDirName = $path;
         add_action('init', array($this, 'addPostTypes'));
-        add_action('init', array($this, 'createJobTaxonomy'));
+        add_action('init', array($this, 'createJobTaxonomy'), 0);
+        
         add_filter('post_updated_messages', array($this, 'jobsUpdatedMessages'));
 
         add_filter('manage_edit-glm_jobs_columns',
@@ -32,9 +33,10 @@ class glm_employment_job
         return $columns;
     }
 
-    public function jobFilter($query)
+    public function jobFilter(&$query)
     {
-        $qv = &$query->query_vars;
+        $qv =& $query->query_vars;
+
         if (isset($qv['post_type']) && $qv['post_type'] == GLM_EMP_POST_TYPE
             && isset($qv[GLM_EMP_TAX_CATEGORIES]) && $qv[GLM_EMP_TAX_CATEGORIES] != 0
         ) {
@@ -47,12 +49,13 @@ class glm_employment_job
             $term = get_term_by('id',$qv[GLM_EMP_TAX_DEPARTMENTS],GLM_EMP_TAX_DEPARTMENTS);
             $qv[GLM_EMP_TAX_DEPARTMENTS] = $term->slug;
         }
+        return $query;
     }
 
     public function jobFilterList()
     {
-        global $wp_query;
         $screen = get_current_screen();
+        global $wp_query;
         if ($screen->post_type == GLM_EMP_POST_TYPE) {
             $tax1 = get_taxonomy(GLM_EMP_TAX_CATEGORIES);
             wp_dropdown_categories(array(
@@ -205,7 +208,8 @@ class glm_employment_job
             'capability_type' => 'post',
             'hierarchical'    => false,
             'rewrite'         => array('slug' => 'jobs'),
-            'taxonomies'      => array(GLM_EMP_TAX_CATEGORIES, GLM_EMP_TAX_DEPARTMENTS)
+//            'taxonomies'      => array(GLM_EMP_TAX_CATEGORIES, GLM_EMP_TAX_DEPARTMENTS),
+            'show_in_menu'    => true
         );
         register_post_type(GLM_EMP_POST_TYPE, $args);
     }
@@ -256,7 +260,7 @@ class glm_employment_job
 
         register_taxonomy(
             GLM_EMP_TAX_CATEGORIES,
-            GLM_EMP_POST_TYPE,
+            null, //GLM_EMP_POST_TYPE,
             array(
                 'label'        => __('Job Category'),
                 'labels'       => $labels,
@@ -264,8 +268,10 @@ class glm_employment_job
                 'show_ui'      => true,
                 'query_var'    => GLM_EMP_TAX_CATEGORIES,
                 'rewrite'      => array('slug' => GLM_EMP_TAX_CATEGORIES),
+                'show_admin_column' => true,
+                '_builtin' => true
         ));
-
+        register_taxonomy_for_object_type(GLM_EMP_TAX_CATEGORIES, GLM_EMP_POST_TYPE);
         $labels = array(
             'name'                       => _x('Departments',
                                                'taxonomy general name'),
@@ -287,7 +293,7 @@ class glm_employment_job
 
         register_taxonomy(
             GLM_EMP_TAX_DEPARTMENTS,
-            GLM_EMP_POST_TYPE,
+            null, //GLM_EMP_POST_TYPE,
             array(
                 'label'        => __('Job Department'),
                 'labels'       => $labels,
@@ -296,6 +302,7 @@ class glm_employment_job
                 'query_var'    => GLM_EMP_TAX_DEPARTMENTS,
                 'rewrite'      => array('slug' => GLM_EMP_TAX_DEPARTMENTS),
         ));
+        register_taxonomy_for_object_type(GLM_EMP_TAX_DEPARTMENTS, GLM_EMP_POST_TYPE);
     }
 
     function jobsEditColumns($columns)
index b30a648..987d7c5 100644 (file)
@@ -31,13 +31,16 @@ class List_Applications extends GLM_List_Table
         } else {
             $where[] = "archived <> true";
         }
+        $where[] = "(SELECT count(*) FROM "
+            . $this->wpdb->prefix . GLM_EMP_FORM_TABLE . " glm_ft WHERE glm_ft.form_part = 7 AND glm_ft.application = glm_at.id)";
         $sql = "
         SELECT id as ID,fname,lname,create_time,archived,position,resume
-          FROM " . $this->wpdb->prefix . GLM_EMP_APPLICATION_TABLE . "
+          FROM " . $this->wpdb->prefix . GLM_EMP_APPLICATION_TABLE . " glm_at
         ";
         if (!empty($where)) {
             $sql .= " WHERE ".implode(" AND ", $where);
         }
+        //var_dump($sql);
         return $this->wpdb->get_results(
            $sql,
             ARRAY_A