Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Last active October 4, 2018 12:22
Show Gist options
  • Save yousufansa/1b14a7f68447ccbc7fef5d2f63de5ea8 to your computer and use it in GitHub Desktop.
Save yousufansa/1b14a7f68447ccbc7fef5d2f63de5ea8 to your computer and use it in GitHub Desktop.
Jobhunt Single Company Header Background And Instagram Fields Added
add_filter('jobhunt_submit_job_form_company_fields' , 'jobhunt_custom_submit_job_form_company_fields');
if ( ! function_exists( 'jobhunt_custom_submit_job_form_company_fields' ) ) {
function jobhunt_custom_submit_job_form_company_fields ($fields) {
$fields['company_instagram'] = array(
'label' => esc_html__( 'Instagram', 'jobhunt' ),
'type' => 'text',
'required' => false,
'placeholder' => esc_html__( 'Instagram url', 'jobhunt' ),
'priority' => 5,
);
$fields['company_youtube'] = array(
'label' => esc_html__( 'Youtube', 'jobhunt' ),
'type' => 'text',
'required' => false,
'placeholder' => esc_html__( 'Youtube url', 'jobhunt' ),
'priority' => 5,
);
$fields['header_bg_image'] = array(
'label' => esc_html__( 'Header Background Image', 'jobhunt' ),
'type' => 'file',
'required' => false,
'priority' => 6,
);
return $fields;
}
}
add_filter('jobhunt_submit_company_form_required_fields' , 'jobhunt_submit_custom_company_form_required_fields');
if ( ! function_exists( 'jobhunt_submit_custom_company_form_required_fields' ) ) {
function jobhunt_submit_custom_company_form_required_fields ($required_fields) {
$required_fields['meta_fields'][] = 'company_instagram';
$required_fields['meta_fields'][] = 'company_youtube';
$required_fields['meta_fields'][] = 'header_bg_image';
return $required_fields;
}
}
add_filter('company_manager_company_fields' , 'jobhunt_custom_company_manager_company_fields');
if ( ! function_exists( 'jobhunt_custom_company_manager_company_fields' ) ) {
function jobhunt_custom_company_manager_company_fields ($fields) {
$fields['_company_instagram'] = array(
'label' => esc_html__( 'Instagram', 'jobhunt-extensions' ),
'placeholder' => esc_html__( 'company instagram page link', 'jobhunt-extensions' ),
);
$fields['_company_youtube'] = array(
'label' => esc_html__( 'Youtube', 'jobhunt-extensions' ),
'placeholder' => esc_html__( 'company youtube page link', 'jobhunt-extensions' ),
);
$fields['_header_bg_image'] = array(
'label' => esc_html__( 'Header Background Image', 'jobhunt-extensions' ),
'placeholder' => esc_html__( 'URL to the Company Header Image', 'jobhunt-extensions' ),
'type' => 'file'
);
return $fields;
}
}
if ( ! function_exists( 'the_company_instagram_page' ) ) {
function the_company_instagram_page( $post = null ) {
if ( ! empty( get_the_company_instagram_page( $post ) ) ) {
echo '<a href="' . esc_url( get_the_company_instagram_page( $post ) ) . '" class="company-instagram"><i class="fab fa-instagram"></i></a>';
}
}
}
if ( ! function_exists( 'get_the_company_instagram_page' ) ) {
function get_the_company_instagram_page( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'company' )
return;
if ( $post->_company_instagram && ! strstr( $post->_company_instagram, 'http:' ) && ! strstr( $post->_company_instagram, 'https:' ) ) {
$post->_company_instagram = 'https://' . $post->_company_instagram;
}
return $post->_company_instagram;
}
}
if ( ! function_exists( 'the_company_youtube_page' ) ) {
function the_company_youtube_page( $post = null ) {
if ( ! empty( get_the_company_youtube_page( $post ) ) ) {
echo '<a href="' . esc_url( get_the_company_youtube_page( $post ) ) . '" class="company-youtube"><i class="fab fa-youtube"></i></a>';
}
}
}
if ( ! function_exists( 'get_the_company_youtube_page' ) ) {
function get_the_company_youtube_page( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'company' )
return;
if ( $post->_company_youtube && ! strstr( $post->_company_youtube, 'http:' ) && ! strstr( $post->_company_youtube, 'https:' ) ) {
$post->_company_youtube = 'https://' . $post->_company_youtube;
}
return $post->_company_youtube;
}
}
if ( ! function_exists( 'jobhunt_company_socail_network' ) ) {
function jobhunt_company_socail_network() {
if( ! empty( get_the_company_twitter_page() || get_the_company_facebook_page() || get_the_company_googleplus_page() || get_the_company_linkedin_page() || the_company_instagram_page() ) ) :
echo '<div class="social-network-pages">';
the_company_twitter_page();
the_company_facebook_page();
the_company_googleplus_page();
the_company_linkedin_page();
the_company_instagram_page();
the_company_youtube_page();
echo '</div>';
endif;
}
}
add_filter('jobhunt_get_wpjmc_header_bg_img' , 'jobhunt_get_wpjmc__single_header_bg_img');
if ( ! function_exists( 'jobhunt_get_wpjmc__single_header_bg_img' ) ) {
function jobhunt_get_wpjmc__single_header_bg_img($bg_url) {
global $post;
if ( is_singular( 'company' ) && !empty($post->_header_bg_image) ) {
$bg_url = $post->_header_bg_image;
}
return $bg_url;
}
}
.company-single-head__right .social-network-pages .company-instagram {
color: #fb3958;
border-color: #fb3958;
}
.company-single-head__right .social-network-pages .company-instagram:hover {
color: #fff;
background-color: #fb3958;
}
.company-single-head__right .social-network-pages .company-youtube {
color: #fc0d1b;
border-color: #fc0d1b;
}
.company-single-head__right .social-network-pages .company-youtube:hover {
color: #fff;
background-color: #fc0d1b;
}
.company-single-head__right .social-network-pages {
margin-bottom: 4px;
}
.company-single-head__right .social-network-pages a {
margin-bottom: 16px;
}
@yousufansa
Copy link
Author

add_filter('jobhunt_get_wpjm_header_bg_img' , 'jobhunt_get_wpjm__single_header_bg_img');

if ( ! function_exists( 'jobhunt_get_wpjm__single_header_bg_img' ) ) {
    function jobhunt_get_wpjm__single_header_bg_img($bg_url) {
        global $post;
        $post = get_post( $post );

        $job_id = get_the_ID();
        $company = '';

        if( $job_id ) {
            $post_title = get_post_meta( $job_id, '_company_name', true );
            if( ! empty( $post_title ) ) {
                $company = get_page_by_title( $post_title, OBJECT, 'company' );
            }
        }

        if ( !empty($company->_header_bg_image) ) {
            $bg_url = $company->_header_bg_image;
        }

        return $bg_url;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment