Plugin Directory

Changeset 1589766


Ignore:
Timestamp:
02/06/2017 09:03:04 AM (9 years ago)
Author:
zartis
Message:

Stopped empty h3 group name appearing if there are empty

Location:
zartis-job-plugin
Files:
17 added
2 edited

Legend:

Unmodified
Added
Removed
  • zartis-job-plugin/trunk/Zartis_Job_Plugin.php

    r1588382 r1589766  
    44Plugin URI: http://hirehive.io
    55Description: (Formerly Zartis ATS) Easily add your own secure jobs and careers page to your WordPress site. Includes full access to professional candidate management and posting to twitter, facebook and free job aggregation sites.
    6 Version: 2.3.2
     6Version: 2.3.3
    77Author: HireHive
    88Author URI: http://hirehive.io
     
    3434    if (!defined('Zartis_Url'))
    3535        define('Zartis_Url', WP_PLUGIN_URL . '/' . HireHive_Folder);
    36 
     36   
    3737    // Add jquery core and our css styles
    3838    if (is_admin()) {
     
    4040        wp_enqueue_style('zartis_wp', Zartis_Url . '/css/zartis_wp.css');
    4141        wp_enqueue_script('zartis_functions', Zartis_Url . '/js/zartis_functions.js');
    42 
     42       
    4343        // The styles for the widget
    4444        wp_enqueue_style('hirehive_wp_widget', Zartis_Url . '/css/hirehive-widget-styles.css');
     
    8383    global $wpdb;
    8484    $zartis_page_ID = get_option('Zartis_Page_ID');
    85 
     85   
    8686    // Clean up DB fields
    8787    HireHive_CleanUp_DB();
    88 
     88   
    8989    //  the id of our page...
    9090    $page_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ID = '" . $zartis_page_ID . "'");
     
    114114    add_action('admin_menu', 'Add_HireHive_Admin_Menu');
    115115    $Zartis_Notice = get_option('Zartis_Notice');
    116 
     116   
    117117    //checks if this is an activation and then displays the zartis message
    118118    if ($Zartis_Notice == "False") {
     
    133133function Display_HireHive_Widget( $atts ) {
    134134    $category = '';
    135 
     135   
    136136    if( isset( $atts['category'] ) && $atts['category']) {
    137137        $category = $atts['category'];
    138138    }
    139 
     139   
    140140    $Company_Zartis_ID = get_option('Zartis_Unique_ID');
    141 
     141   
    142142    $Zartis_Group = get_option('Zartis_Group');
    143 
     143   
    144144    if ($Zartis_Group == null){
    145145        $Zartis_Group = 1;
    146146    }
    147 
     147   
    148148    if ($Company_Zartis_ID != "False") {
    149149        try {
    150 
     150           
    151151            if ($category !=null){
    152152                $url = 'https://my.hirehive.io/api/v2/public/search?cname='.$Company_Zartis_ID.'&groupBy='.$Zartis_Group.'&category='.$category;
     
    155155                $url = 'https://my.hirehive.io/api/v2/public/search?cname='.$Company_Zartis_ID.'&groupBy='.$Zartis_Group;
    156156            }
    157 
     157           
    158158            $jsondata = file_get_contents($url);
    159 
     159           
    160160            if (strlen($jsondata) == 0){
    161161                throw new Exception('file_get_contents returned nothing');
    162162            }
    163 
     163           
    164164            $groups = json_decode($jsondata, true);
    165 
     165           
    166166            if (strlen($groups) == 0){
    167167                throw new Exception('json_decode returned nothing');
    168168            }
    169 
     169           
    170170            $decodeError = '';
    171171            switch (json_last_error()) {
    172 
     172               
    173173                case JSON_ERROR_NONE:
    174174                    break;
     
    192192                    break;
    193193        }
    194 
     194       
    195195        if (strlen($decodeError) > 0) {
    196196            $emailBody = "JSON Decode failed: " .$Company_Zartis_ID;
     
    201201            $emailBody .= '<br><br>';
    202202            $emailBody .= '<pre>' .print_r($decodeError, 1). '</pre>';
    203 
     203           
    204204            $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    205 
     205           
    206206            error_log($emailBody, 1, '[email protected]', $headers);
    207 
     207           
    208208            throw new Exception('JSON version failed, fallback to JS widget');
    209209        }
    210 
     210       
    211211        $jobTemplate = '<a class="hh-list-row" href="{{Link}}"><span class="hh-list-title">{{Title}}</span> <span class="hh-list-location">{{Location}}, {{Country}}</span> <span class="hh-list-type">{{Type}}</span></a>';
    212 
     212       
    213213        $jobsHTML = "<div id='jobs_iframe' class='hh-list'>";
    214214        $jobsHTML .= '<!-- Jobs for - ' .$Company_Zartis_ID. ' -->';
    215         $jobsHTML .= '<!-- Chosen group - ' .$Zartis_Group. ' -->';
     215            $jobsHTML .= '<!-- Chosen group - ' .$Zartis_Group. ' -->';
    216216        $jobsHTML .= '<!-- Category - ' .$category. ' -->';
    217 
     217       
    218218        foreach ($groups as $group) {
    219219            if ($Zartis_Group > 1){
    220                 $jobsHTML .= '<h3 class="hh-list-cat">'.$group["name"].'</h3>';
    221             }
    222 
     220                if (strlen($group["name"]) > 0){
     221                    $jobsHTML .= '<h3 class="hh-list-cat">'.$group["name"].'</h3>';
     222                }
     223            }
     224           
    223225            if ($category !=null){
    224226                $jobsHTML .= Compile_Job_Template($jobTemplate, $group);
     
    230232            }
    231233        }
    232 
     234       
    233235        $jobsHTML .= "</div>";
    234 
     236       
    235237        return $jobsHTML;
    236238    }
     
    238240        // If we have an exception using the API to get the jobs then we fallback to the old JS Version
    239241        $script = '<script type="text/javascript"src="https://my.hirehive.io/' . $Company_Zartis_ID . '/getwidget"></script><script type="text/javascript"charset="utf-8">function getParam(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)return"";else return results[1];}function updateIFrame(height){var iframe=document.getElementById("jobs_iframe");iframe.setAttribute("height",height);}var height=getParam("height");if(height==""){var zartis_options={};zartis_options.display="iframe";zartis_options.company="' . $Company_Zartis_ID . '";zartis_options.placement="left";zartis_options.type="widget";zartis_options.color="#222";zartis_options.width="' . $Zartis_Width . '%";zartis_options.style="idea";zartis_options.url=document.URL;var zartis_widget=new ZARTIS.jobs_widget(zartis_options);}else{window.top.updateIFrame(height);}</script>';
    240 
     242       
    241243        $script .= '<!-- Jobs for - ' .$Company_Zartis_ID. ' -->';
    242         $script .= '<!-- Chosen group - ' .$Zartis_Group. ' -->';
     244            $script .= '<!-- Chosen group - ' .$Zartis_Group. ' -->';
    243245        $script .= '<!-- Category - ' .$category. ' -->';
    244246        $script .= '<!--' .$e.message. '-->';
    245 
     247       
    246248        return $script;
    247249    }
    248 
     250   
    249251} else {
    250252    return false;
     
    253255
    254256function Compile_Job_Template($template, &$job){
    255 
     257   
    256258    $template = str_replace("{{Title}}",$job["title"],$template);
    257259    $template = str_replace("{{Link}}",$job["jobUrl"],$template);
     
    259261    $template = str_replace("{{Country}}",$job["countryName"],$template);
    260262    $template = str_replace("{{Type}}",$job["type"],$template);
    261 
     263   
    262264    return $template;
    263265}
  • zartis-job-plugin/trunk/readme.txt

    r1588382 r1589766  
    55Requires at least: 2.9
    66Tested up to: 4.7.2
    7 Stable tag: 2.3.2
     7Stable tag: 2.3.3
    88
    99Easily add job listings and secure candidate management to your Wordpress site.
     
    105105= 2.3.2
    106106* Added a fallback for file_get_contents not working
     107
     108= 2.3.3
     109* Check if group name is not empty before adding the h3 tag
Note: See TracChangeset for help on using the changeset viewer.