Created
February 5, 2016 14:05
-
-
Save daveharrisonnet/ac8266044f11bfdbcccd to your computer and use it in GitHub Desktop.
The functions file of listify child theme that caused errors following update to listify 1.3.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Listify child theme. | |
*/ | |
function listify_child_styles() { | |
wp_enqueue_style( 'listify-child', get_stylesheet_uri() ); | |
} | |
add_action( 'wp_enqueue_scripts', 'listify_child_styles', 999 ); | |
/** Place any new code below this line */ | |
//tidy up some code | |
remove_action( 'wp_head', 'wp_generator' ) ; | |
remove_action( 'wp_head', 'wlwmanifest_link' ) ; | |
remove_action( 'wp_head', 'rsd_link' ) ; | |
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); | |
remove_action( 'wp_head', 'feed_links', 2 ); | |
remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
add_filter('show_admin_bar', '__return_false'); | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
//brand the rss feeds that are left | |
function add_rss_logo($content) { | |
if(is_feed()) { | |
$content .= "<hr><a href='blog_url'><img src='http://www.thisisantrim.com/wp-content/uploads/TiALogo_web_onwhite.png'/></a>"; | |
} | |
return $content; | |
} | |
add_filter('the_content', 'add_rss_logo'); | |
add_filter('the_excerpt_rss', 'add_rss_logo'); | |
//add widget for ads to listing page | |
register_sidebar(array( | |
'name'=> 'Adrotate on Listing Results Widget Area', | |
'id' => 'listing_ads_custom' | |
)); | |
// megamenu remove default menu and replace with hacked version split up by top level category | |
function do_things_late() { | |
global $listify_job_manager; | |
$template = $listify_job_manager->template; | |
$childargs = ''; | |
global $listify_navigation; | |
remove_action( 'wp_nav_menu_items', array( $listify_navigation, 'taxonomy_mega_menu' ), 0, 2 ); | |
add_action( 'wp_nav_menu_items', 'modified_taxonomy_mega_menu', 0, 2 ); | |
//remove_action( 'wp_nav_menu_items', array( $template, 'taxonomy_mega_menu' ), 0, 2 ); | |
//add_action( 'wp_nav_menu_items', 'modified_taxonomy_mega_menu' , 20); | |
//add_action( 'wp_nav_menu_items', 'modified_taxonomy_mega_menu', 0, 2 ); | |
function modified_taxonomy_mega_menu( $items, $childargs ) { | |
if ( 'none' == listify_theme_mod( 'nav-megamenu' ) ) { | |
return $items; | |
} | |
if ( 'secondary' != $childargs->theme_location ) { | |
return $items; | |
} | |
$taxonomy = get_taxonomy( listify_theme_mod( 'nav-megamenu' ) ); | |
if ( is_wp_error( $taxonomy ) ) { | |
return $items; | |
} | |
global $listify_strings; | |
$link = sprintf( | |
'<a href="%s">' . __( 'Browse ALL %s', 'listify' ) . '</a>', | |
get_post_type_archive_link( 'job_listing' ), | |
str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->name ) | |
); | |
$submenu = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link1 = '<a href="/listings/things-to-do">Things To Do</a>'; | |
$submenu1 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 146, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link2 = '<a href="/listings/services">Services</a>'; | |
$submenu2 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
//'child_of' => 480, | |
'child_of' => 254, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$link3 = '<a href="/listings/lifestyle">Lifestyle</a>'; | |
$submenu3 = wp_list_categories( apply_filters( 'listify_mega_menu_list', array( | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 159, | |
//child_of' => 481, | |
'hide_empty' => 1, | |
'pad_counts' => true, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => -1, | |
'walker' => new Listify_Walker_Category | |
) ) ); | |
$dropdown = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown1 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 146, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown2 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 254, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$dropdown3 = wp_dropdown_categories( array( | |
'show_option_all' => sprintf( __( 'Select a %s', 'listify' ), str_replace( $listify_strings->label( 'singular' ) . ' ', '', $taxonomy->labels->singular_name ) ), | |
'taxonomy' => $taxonomy->name, | |
'child_of' => 159, | |
'hide_empty' => 0, | |
'pad_counts' => false, | |
'show_count' => true, | |
'echo' => false, | |
'title_li' => false, | |
'depth' => 0, | |
'hierarchical' => true, | |
'name' => $taxonomy->name, | |
'walker' => new Listify_Walker_Category_Dropdown | |
) ); | |
$submenu = | |
'<ul class="sub-menu category-list">' . | |
'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown . '</form> | |
<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu1 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown1 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu1 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu2 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown2 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu2 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
$submenu3 = | |
'<ul class="sub-menu category-list">' . | |
//'<form id="job_listing_tax_mobile" action="' . home_url() . '" method="get">' . $dropdown3 . '</form> | |
'<div class="container"> | |
<div class="mega-category-list-wrapper">' . $submenu3 . '</div> | |
<!--<a href="' . get_post_type_archive_link( 'job_listing' ) . '">' . __( 'View All', 'listify' ) . '</a>--> | |
</div> | |
</ul>'; | |
return '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link . $submenu .'<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link1 . $submenu1 . '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link2 . $submenu2 . '<li id="categories-mega-menu" class="ion-navicon-round menu-item menu-type-link">'. $link3 . $submenu3 . '' .$items; | |
} | |
} | |
add_action( 'init', 'do_things_late', 20 ); | |
// set up image directory for homepage image grid taxonomy | |
function custom_listify_cover_image( $image, $args ) { | |
if ( ! isset( $args[ 'term' ] ) ) { | |
return $image; | |
} | |
$term = $args[ 'term' ]; | |
/** | |
* Only edit the URL here. | |
* | |
* Do not add the name of the image to this URL. | |
* | |
* Once the URL is set upload images to your web server's directory with the name | |
* of each of your terms slug. | |
* | |
* Example: | |
* Restaurants = http://yourwebsite.com/images/directory/restaurants.jpg | |
*/ | |
//$url = 'http://local.thisisantrim.com/wp-content/uploads/taxonomy-images/'; | |
$url = 'http://www.thisisantrim.com/wp-content/uploads/taxonomy-images/'; | |
//$url = 'http://brawny-smash.flywheelsites.com/wp-content/uploads/taxonomy-images/'; | |
$image = array( $url . $term->slug . '.jpg' ); | |
return $image; | |
} | |
add_filter( 'listify_cover_image', 'custom_listify_cover_image', 10, 2 ); | |
// change default font (stack) | |
function custom_listify_fonts() { | |
wp_dequeue_style( 'listify-fonts-css' ); | |
//wp_enqueue_style( 'listify-fonts-css', 'http://fonts.googleapis.com/css?family=Titillium+Web' ); | |
wp_enqueue_style( 'listify-fonts-css', 'http://fonts.googleapis.com/css?family=Alegreya+Sans' ); | |
} | |
//add_action( 'wp_enqueue_scripts', 'custom_listify_fonts', 20 ); | |
// tweak comment/review form to point login to woo-commerce social login | |
add_filter( 'comment_form_defaults', 'thisisantrim_modify_comment_fields' ); | |
function thisisantrim_modify_comment_fields( $fields ) { | |
$fields['must_log_in'] = '<p class="must-log-in">You must be <a href="/my-account/" class="alert popup-trigger-ajax popup-wide">logged in</a> to take part in our community. If you don\'t already have a login you can register now using any of your social media accounts, it only takes a few seconds so</p> | |
<div class="cta-button-wrapper col-sm-12 col-md-12 col-lg-12"> | |
<a class="popup-trigger-ajax popup-wide" href="/create-free-account/"><span class="cta-button button">Join our community</span></a> | |
<small class="cta-subtext">and get started in seconds</small> | |
</div>'; | |
return $fields; | |
} | |
function custom_address_formats( $formats ) { | |
$formats[ 'EN' ] = "{address_1}\n{address_2}\n{city} {postcode}"; | |
return $formats; | |
} | |
add_filter( 'woocommerce_localisation_address_formats', 'custom_address_formats', 20 ); | |
function remove_formatted_locations() { | |
add_filter( 'listify_force_skip_formatted_address', '__return_true' ); | |
} | |
add_action( 'init', 'remove_formatted_locations' ); | |
/** | |
* Plugin Name: Listify - Remove "Add Photos" Link | |
*/ | |
function custom_listify_remove_action_links() { | |
global $listify_job_manager; | |
remove_action( 'listify_single_job_listing_actions_start', array( $listify_job_manager->gallery, 'add_link' ) ); | |
} | |
add_action( 'init', 'custom_listify_remove_action_links' ); | |
/** | |
* Plugin Name: Listify - Make submit review button a modal popup | |
*/ | |
function custom_listify_remove_review_button() { | |
global $listify_job_manager; | |
remove_action( 'listify_single_job_listing_actions_start', array( $listify_job_manager->post, 'submit_review_link' ) ); | |
add_action( 'listify_single_job_listing_actions_after', array( $listify_job_manager->post, 'modified_submit_review_link' ) ); | |
} | |
function modified_submit_review_link() { | |
global $post; | |
if ( ! comments_open() || ! ( is_active_widget( false, false, 'listify_widget_panel_listing_comments', true ) || ! | |
is_active_sidebar( 'single-job_listing-widget-area' ) ) || 'preview' == $post->post_type ) { | |
return; | |
} | |
if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { | |
$url = get_permalink( wc_get_page_id( 'create-free-account' ) ); | |
} else { | |
$url = '#respond'; | |
} | |
?> | |
<a href="<?php echo esc_url( $url ); ?>" class="single-job_listing-respond button button-secondary popup-trigger-ajax popup-wide"><?php _e( 'Submit a Review', 'listify' ); ?></a> | |
<?php | |
} | |
add_action( 'init', 'custom_listify_remove_review_button' ); | |
/** | |
* Plugin Name: Listify - Limit Photo Uploads to Listing Owner | |
*/ | |
function limit_who_can_upload($can) { | |
global $post; | |
if ( $post->post_author == get_current_user_id() ) { | |
return $can; | |
} | |
return false; | |
} | |
add_filter( 'listify_can_upload_to_listing','limit_who_can_upload' ); | |
// Load Custom JavaScript via Child Theme | |
function custom_theme_js() { | |
/* REGISTER ALL JS FOR CHILD THEME */ | |
wp_register_script('jitter-bug',get_stylesheet_directory_uri().'/js/jitter-bug-fix.js', array('jquery'), '', true); | |
//wp_register_script('respimage',get_stylesheet_directory_uri().'/js/respimage.min.js', array('jquery'), '', true); | |
/* CALL ALL CUSTOM SCRIPTS FOR CHILD THEME */ | |
wp_enqueue_script('jitter-bug'); | |
//wp_enqueue_script('respimage'); | |
} | |
add_action('wp_enqueue_scripts', 'custom_theme_js'); | |
/* TRIM DONE WooCOMMERCE STUFF TO WHAT IS NEEDED */ | |
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); | |
function custom_override_checkout_fields( $fields ) { | |
//unset($fields['billing']['billing_first_name']); | |
//unset($fields['billing']['billing_last_name']); | |
unset($fields['billing']['billing_company']); | |
unset($fields['billing']['billing_address_1']); | |
unset($fields['billing']['billing_address_2']); | |
unset($fields['billing']['billing_city']); | |
unset($fields['billing']['billing_postcode']); | |
unset($fields['billing']['billing_country']); | |
unset($fields['billing']['billing_state']); | |
unset($fields['billing']['billing_phone']); | |
unset($fields['order']['order_comments']); | |
unset($fields['billing']['billing_address_2']); | |
unset($fields['billing']['billing_postcode']); | |
unset($fields['billing']['billing_company']); | |
unset($fields['billing']['billing_last_name']); | |
unset($fields['billing']['billing_email']); | |
unset($fields['billing']['billing_city']); | |
return $fields; | |
} | |
function wpdebug_disable_account_addresses( $fields ) { | |
return array(); | |
} | |
add_filter( 'woocommerce_my_account_get_addresses', 'wpdebug_disable_account_addresses' ); | |
// Changes the login text from what's set in our WooCommerce settings so we're not talking about checkout elsewhere. | |
function change_social_login_text_option( $login_text ) { | |
global $pagenow; | |
// Only modify the text from this option if we're not on the wp-login page | |
if( 'wp-login.php' === $pagenow ) { | |
$login_text = __( 'You can also create an account with a social network.', 'WC_Social_Login' ); | |
// Adjust the login text as desired | |
} elseif( ! ( is_admin() || is_woocommerce() || is_cart() || is_checkout() ) ) { | |
// Okay if we're not on an admin or WooCommerce page, then we also want to change it: | |
$login_text = __( 'Use a social account to Sign Up / Log In and begin reviewing listings now. We won\'t post anything to your accounts. Registration takes about 12 seconds. If you don\'t have a social media account you can register using the create account link at the top of the page' ); | |
// Adjust the login text as desired | |
} | |
return $login_text; | |
} | |
add_filter( 'pre_option_wc_social_login_text', 'change_social_login_text_option' ); | |
/** | |
* Only copy opening php if needed | |
* | |
* Moves social login profiles section to the top of the My Account page | |
*/ | |
function sv_move_wc_social_login_my_account_profiles() { | |
if ( function_exists( 'wc_social_login' ) ) { | |
remove_action( 'woocommerce_before_my_account', array( wc_social_login()->frontend, 'render_social_login_profile' ) ); | |
add_action( 'woocommerce_before_my_account', array( wc_social_login()->frontend, 'render_social_login_profile' ), 2 ); | |
} | |
} | |
add_action( 'init', 'sv_move_wc_social_login_my_account_profiles'); | |
/** | |
* | |
* Moves contact menu, toosl menu and jetpack form admin page | |
*/ | |
function remove_contact_menu () { | |
global $menu; | |
$restricted = array(__('Contact')); | |
end ($menu); | |
while (prev($menu)){ | |
$value = explode(' ',$menu[key($menu)][0]); | |
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);} | |
} | |
} | |
function my_remove_admin_menus() { | |
remove_menu_page( 'edit-comments.php' ); | |
} | |
function remove_tools_admin_menu() { | |
global $submenu; | |
unset($submenu['tools.php'][5]); | |
if(count($submenu['tools.php']) == 0) { | |
remove_menu_page('tools.php'); | |
} | |
} | |
//add_action('admin_menu', 'remove_contact_menu'); | |
if(!current_user_can('level_10')) { | |
add_action('admin_menu', 'remove_contact_menu'); | |
add_action( 'admin_init', 'my_remove_admin_menus' ); | |
add_action('admin_init', 'remove_tools_admin_menu'); | |
} | |
/** | |
* * Do a random order by on listings - turn off if featured listings are active | |
*/ | |
function custom_orderby( $query_args ) { | |
$query_args[ 'orderby' ] = 'rand'; | |
return $query_args; | |
} | |
//add_filter( 'job_manager_get_listings_args', 'custom_orderby', 99 ); | |
function custom_orderby_cache( $query_args ) { | |
$query_args[ 'cache-bust' ] = time(); | |
return $query_args; | |
} | |
//add_filter( 'get_job_listings_query_args', 'custom_orderby_cache', 99 ); | |
/** | |
* * Contact-form-7 0n sinlg elisting page only | |
*/ | |
function my_deregister_javascript() | |
{if ( ! is_singular( 'job_listing' ) ) {wp_deregister_script( 'contact-form-7' );}} | |
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); | |
function my_deregister_styles() | |
{if ( ! is_singular( 'job_listing' ) ) {wp_deregister_style( 'contact-form-7' );}} | |
add_action( 'wp_print_styles', 'my_deregister_styles', 100 ); | |
/** | |
* * Switch heartbeat down to speed up page load delay caused by WC_ajax issue | |
*/ | |
add_action( 'init', 'stop_heartbeat', 1 ); | |
function stop_heartbeat() { | |
global $pagenow; | |
if ( $pagenow != 'post.php' && $pagenow != 'post-new.php' ) | |
wp_deregister_script('heartbeat'); | |
} | |
/** | |
* Optimize WooCommerce Scripts | |
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages. | |
*/ | |
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 ); | |
function child_manage_woocommerce_styles() { | |
//remove generator meta tag | |
remove_action('wp_head', 'wc_generator_tag'); | |
//first check that woo exists to prevent fatal errors | |
if ( function_exists( 'is_woocommerce' ) ) { | |
//dequeue scripts and styles | |
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { | |
wp_dequeue_style( 'woocommerce-layout' ); | |
wp_dequeue_style( 'woocommerce-smallscreen' ); | |
wp_dequeue_style( 'woocommerce-general' ); | |
wp_dequeue_script( 'wc-add-to-cart' ); | |
wp_dequeue_script( 'wc-cart-fragments' ); | |
wp_dequeue_script( 'woocommerce' ); | |
wp_dequeue_script( 'jquery-blockui' ); | |
wp_dequeue_script( 'jquery-placeholder' ); | |
} | |
} | |
} | |
/** | |
* Region breadcrumbs added. | |
*/ | |
function region_breadcrumb() { | |
$crumbs = new Listify_Taxonomy_Breadcrumbs( array( | |
'taxonomy' => 'job_listing_region', | |
'sep' => '<span class="ion-chevron-right"></span>' | |
) ); | |
?> | |
<div class="content-single-job_listing-title-category"> | |
<?php if ( ! empty( $crumbs->crumbs ) ) : ?> | |
<?php $crumbs->output(); ?> | |
<?php endif; ?> | |
</div> | |
<?php | |
} | |
//add_action( 'single_job_listing_meta_start', 'region_breadcrumb', 31 ); | |
/** | |
* Contact button added although only works if listing has an email. | |
*/ | |
function custom_listify_single_job_listing_actions_after() { | |
echo '<a href="#job_listing-author-apply" data-mfp-src=".job_application" class="popup-trigger button">' . __( 'Contact', 'listify' ) . '</a>'; | |
} | |
add_filter( 'listify_single_job_listing_actions_after', 'custom_listify_single_job_listing_actions_after' ); | |
/** | |
* info on map on single page added. | |
*/ | |
function custom_listify_widget_job_listing_map_before() { | |
global $post; | |
echo $post->_application; | |
} | |
add_filter( 'listify_widget_job_listing_map_before', 'custom_listify_widget_job_listing_map_before' ); | |
function custom_listify_widget_job_listing_map_after() { | |
global $post; | |
echo $post->_application; | |
} | |
//add_filter( 'listify_widget_job_listing_map_after', 'custom_listify_widget_job_listing_map_after' ); | |
/** | |
* temp fix for comment problem. | |
*/ | |
add_filter( 'wpjmr_can_post_multiple_reviews', '__return_true' ); | |
/** | |
* remove disqus from listing/reviews comments | |
*/ | |
add_filter( 'comments_template' , 'wpb_block_disqus', 1 ); | |
function wpb_block_disqus($file) { | |
if ( 'job_listing' == get_post_type() ) | |
remove_filter('comments_template', 'dsq_comments_template'); | |
return $file; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment