Hide elements for search jobs in admin side
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 18 Dec 2014 13:34:44 +0000 (08:34 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 18 Dec 2014 13:34:44 +0000 (08:34 -0500)
controllers/front.php
css/glm_jobs.css [new file with mode: 0644]
glm-employment.php
models/SH_Walker_TaxonomyDropdown.php [new file with mode: 0644]
models/job.php
views/front/jobDetail.php
views/front/jobSearch.php

index ff5ff84..3307d4e 100644 (file)
@@ -83,6 +83,8 @@ class glm_employment_front
         $job_id = (isset($_REQUEST['job']))
             ? filter_var($_REQUEST['job'], FILTER_VALIDATE_INT)
             : false;
+
+        ob_start();
         if ($applyOnline) {
             $this->show_apply_form();
         } else if ($job_id) {
@@ -91,6 +93,9 @@ class glm_employment_front
             $this->search_form();
             $this->list_jobs();
         }
+        $output = ob_get_contents();
+        ob_end_clean();
+        return $output;
     }
 
     /**
@@ -524,7 +529,7 @@ class glm_employment_front
             'taxonomy'         => 'glm_jobsdepartment',
             'hide_if_empty'    => false,
         );
-        $form_url   = home_url() . '/searchJobs/?search=1';
+        $form_url   = get_permalink();
         $categories = get_terms('glm_jobscategory');
         include $this->frontViewDir . '/jobSearch.php';
     }
diff --git a/css/glm_jobs.css b/css/glm_jobs.css
new file mode 100644 (file)
index 0000000..f8f5a0b
--- /dev/null
@@ -0,0 +1,6 @@
+
+#post-query-submit,
+#post-search-input,
+#search-submit {
+    display:none;
+}
index 247b1d5..56f88a0 100644 (file)
@@ -71,11 +71,17 @@ $employmentApp = new glm_employment_setup();
 /**
  * Load style sheet for displaying the view and print for the application forms
  */
-function glm_load_style()
+function glm_load_view_style()
 {
-    wp_enqueue_style('foundation',
-            plugin_dir_url(__FILE__) . 'css/foundation.css');
+    wp_enqueue_style('foundation', plugin_dir_url(__FILE__) . 'css/foundation.css');
+}
+function glm_load_edit_style()
+{
+    wp_enqueue_style('glm_jobs', plugin_dir_url(__FILE__) . 'css/glm_jobs.css');
 }
 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'view') {
-    add_action('admin_enqueue_scripts', 'glm_load_style');
+    add_action('admin_enqueue_scripts', 'glm_load_view_style');
+}
+if (isset($_REQUEST['post_type']) && $_REQUEST['post_type'] == GLM_EMP_POST_TYPE) {
+    add_action('admin_enqueue_scripts', 'glm_load_edit_style');
 }
diff --git a/models/SH_Walker_TaxonomyDropdown.php b/models/SH_Walker_TaxonomyDropdown.php
new file mode 100644 (file)
index 0000000..4b89299
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+/*
+ * A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID.
+ *
+ * See http://core.trac.wordpress.org/ticket/13258
+ *
+ * Usage, as normal:
+ * wp_dropdown_categories($args);
+ *
+ * But specify the custom walker class, and (optionally) a 'id' or 'slug' for the 'value' parameter:
+ * $args=array('walker'=> new SH_Walker_TaxonomyDropdown(), 'value'=>'slug', .... );
+ * wp_dropdown_categories($args);
+ *
+ * If the 'value' parameter is not set it will use term ID for categories, and the term's slug for other taxonomies in the value attribute of the term's <option>.
+ */
+class SH_Walker_TaxonomyDropdown
+    extends Walker_CategoryDropdown
+{
+
+    function start_el(&$output, $category, $depth, $args)
+    {
+        $pad      = str_repeat('&nbsp;', $depth * 3);
+        $cat_name = apply_filters('list_cats', $category->name, $category);
+        if (!isset($args['value'])) {
+            $args['value'] = ( $category->taxonomy != 'category'
+                    ? 'slug'
+                    : 'id' );
+        }
+        $value = ($args['value'] == 'slug'
+                ? $category->slug
+                : $category->term_id );
+        $output .= "\t<option class=\"level-$depth\" value=\"" . $value . "\"";
+        if ($value === (string) $args['selected']) {
+            $output .= ' selected="selected"';
+        }
+        $output .= '>';
+        $output .= $pad . $cat_name;
+        if ($args['show_count'])
+            $output .= '&nbsp;&nbsp;(' . $category->count . ')';
+        $output .= "</option>\n";
+    }
+
+}
index c3d9022..941ea4d 100644 (file)
@@ -31,8 +31,20 @@ class glm_employment_job
         add_action('admin_init', array($this, 'metaDates'));
         add_action('save_post', array($this, 'saveEmpMeta'));
         add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortingColumns'));
-        add_action('restrict_manage_posts', array($this, 'jobFilterList'));
-        add_filter('parse_query', array($this, 'jobFilter'));
+//        add_action('restrict_manage_posts', array($this, 'jobFilterList'));
+//        add_filter('parse_query', array($this, 'jobFilter'));
+        add_filter('user_row_actions', array($this, 'remove_row_actions'));
+    }
+
+    public function remove_row_actions($actions, $post)
+    {
+        global $curren_screen;
+        if ($curren_screen->post_type != GLM_EMP_POST_TYPE) {
+            return $actions;
+        }
+        unset($actions['view']);
+        unset($actions['inline hide-if-no-js']);
+        return $actions;
     }
 
     /**
@@ -59,21 +71,40 @@ class glm_employment_job
      */
     public function jobFilter($query)
     {
-        $qv =& $query->query_vars;
+        if (isset($_REQUEST['post_type']) && $_REQUEST['post_type'] == GLM_EMP_POST_TYPE) {
+            $qv =& $query->query_vars;
+            if (isset($qv['post_type']) && $qv['post_type'] == GLM_EMP_POST_TYPE) {
+                if (isset($qv[GLM_EMP_TAX_CATEGORIES]) && $qv[GLM_EMP_TAX_CATEGORIES] != 0) {
+                    $term = get_term_by('id',$qv[GLM_EMP_TAX_CATEGORIES],GLM_EMP_TAX_CATEGORIES);
+                    $qv[GLM_EMP_TAX_CATEGORIES] = $term->slug;
 
-        if (isset($qv['post_type']) && $qv['post_type'] == GLM_EMP_POST_TYPE
-            && isset($qv[GLM_EMP_TAX_CATEGORIES]) && $qv[GLM_EMP_TAX_CATEGORIES] != 0
-        ) {
-            $term = get_term_by('id',$qv[GLM_EMP_TAX_CATEGORIES],GLM_EMP_TAX_CATEGORIES);
-            $qv[GLM_EMP_TAX_CATEGORIES] = $term->slug;
-        }
-        if (isset($qv['post_type']) && $qv['post_type'] == GLM_EMP_POST_TYPE
-            && isset($qv[GLM_EMP_TAX_DEPARTMENTS]) && $qv[GLM_EMP_TAX_DEPARTMENTS] != 0
-        ) {
-            $term = get_term_by('id',$qv[GLM_EMP_TAX_DEPARTMENTS],GLM_EMP_TAX_DEPARTMENTS);
-            $qv[GLM_EMP_TAX_DEPARTMENTS] = $term->slug;
+//                    if (isset($query->tax_query)) {
+//                        $tax_query =& $query->tax_query;
+//                        $queries =& $tax_query->queries;
+////                        echo '<pre>'.print_r($queries, true).'</pre>';
+//                        foreach ($queries as $key => &$qs) {
+//                            if ($qs['taxonomy'] == GLM_EMP_TAX_CATEGORIES) {
+//                                $qs['terms'][$key] = $term->slug;
+//                            }
+//                        }
+//                    }
+
+                }
+                if (isset($qv[GLM_EMP_TAX_DEPARTMENTS]) && $qv[GLM_EMP_TAX_DEPARTMENTS] != 0) {
+                    $term = get_term_by('id',$qv[GLM_EMP_TAX_DEPARTMENTS],GLM_EMP_TAX_DEPARTMENTS);
+                    $qv[GLM_EMP_TAX_DEPARTMENTS] = $term->slug;
+                }
+                if ($qv['post_type'] == GLM_EMP_POST_TYPE) {
+//                    echo '<pre>'.print_r($qv, true).'</pre>';
+
+                }
+//                echo '<pre>'.print_r($query, true).'</pre>';
+            }
+
+
+            return $query;
         }
-        return $query;
+
     }
 
     /**
@@ -248,10 +279,10 @@ class glm_employment_job
             'supports'        => array('title', 'editor'),
             'has_archive'     => true,
             'menu_icon'       => 'dashicons-businessman',
-            'capability_type' => 'post',
+            'capability_type' => 'page',
             '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);
index bb4d10f..233c520 100644 (file)
@@ -1,4 +1,4 @@
-<a href="#">Back To Search</a>
+<a href="<?php echo get_permalink();?>">Back To Search</a>
 <div class="small-12 columns">
     <h2><a href="<?php echo $job->href; ?>"><?php echo $job->post_title; ?></a></h2>
     <div><strong>Status: </strong><?php echo $job->glm_jobs_status; ?></div>
index 85b9dfa..7dbaa99 100644 (file)
@@ -1,23 +1,17 @@
-<style>
-    #job_search {width: 100%;padding: 2%;}
-    #cat_id_wrapper {width: 45%;float:left;}
-    #status_wrapper {width: 45%;float:right;}
-    #submit_wrapper, input[type="submit"] {width: 100%;text-align: center;}
-</style>
-
 <h2>Employment Search</h2>
 <form name="job_search" id="job_search" action="<?php echo $form_url;?>" method="post">
-    <div id="cat_id_wrapper">
-        <div id="cat_id_label">Search by Category</div>
-        <div id="cat_wrap">
+    <input type="hidden" name="glm_job_search" value="1">
+    <div class="row">
+        <div class="small-12 medium-5 columns">
+            <label>Search by Category</label>
             <?php wp_dropdown_categories( $cat_args );?>
         </div>
-    </div>
-       <div id="status_wrapper">
-        <div id="status_label">Search by Department</div>
-        <div id="dept_wrap">
+        <div class="small-12 medium-5 columns">
+            <label>Search by Department</label>
             <?php wp_dropdown_categories( $dep_args );?>
         </div>
+        <div class="small-12 medium-2 columns">
+            <input class="button" type="submit" value="Search">
+        </div>
     </div>
-       <div id="submit_wrapper"><input type="submit" value="Search"></div>
 </form>
\ No newline at end of file