127 lines
3.5 KiB
PHP
127 lines
3.5 KiB
PHP
<?php
|
|
add_filter('widget_text', 'do_shortcode');
|
|
function custom_theme_support() {
|
|
add_theme_support('post-thumbnails');
|
|
set_post_thumbnail_size(150, 150, true);
|
|
add_image_size('product_thumb',280);
|
|
add_image_size('product_single',320);
|
|
add_image_size('product_related',195,195, true);
|
|
add_image_size('sidebar_pad',200);
|
|
add_image_size('sidebar',210);
|
|
}
|
|
add_action('after_setup_theme','custom_theme_support');
|
|
|
|
|
|
function myTagFilter($query) {
|
|
$post_type = $_GET['type'];
|
|
if (is_tag()){
|
|
if (!$post_type) {
|
|
$post_type = 'any';
|
|
}
|
|
$query->set('post_type', $post_type);
|
|
}
|
|
return $query;
|
|
};
|
|
add_filter('pre_get_posts','myTagFilter');
|
|
|
|
function dl_custom_image_sizes_add_settings($sizes) {
|
|
//unset( $sizes['thumbnail']); //comment to remove size if needed
|
|
//unset( $sizes['medium']);// uncomment to remove size if needed
|
|
//unset( $sizes['large']);// uncomment to restore size if needed
|
|
// unset( $sizes['full'] ); // comment to remove size if needed
|
|
$mynewimgsizes = array(
|
|
"product_thumb" => __( "Product Thumb" ),
|
|
"sidebar_pad" => __( "Sidebar Padded Thumb" )
|
|
|
|
);
|
|
$newimgsizes = array_merge($sizes, $mynewimgsizes);
|
|
return $newimgsizes;
|
|
}
|
|
add_filter('image_size_names_choose', 'dl_custom_image_sizes_add_settings');
|
|
|
|
|
|
add_action( 'pre_get_posts', 'modify_query_change_sort' );
|
|
function modify_query_change_sort( $query ) {
|
|
if ( ! is_admin() && $query->is_main_query() && is_tax( 'product_category' ))
|
|
$query->set( 'orderby', 'menu_order' );
|
|
$query->set('order','ASC');
|
|
}
|
|
|
|
add_action( 'pre_get_posts', 'modify_query_change_sort_two' );
|
|
function modify_query_change_sort_two( $query ) {
|
|
if ( ! is_admin() && $query->is_main_query() && is_tax( 'batefuel_category','live-cams' ))
|
|
$query->set( 'orderby', 'menu_order' );
|
|
$query->set('order','ASC');
|
|
}
|
|
|
|
add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );
|
|
function custom_image_sizes_choose( $sizes ) {
|
|
$custom_sizes = array(
|
|
'featured-image' => 'Featured Image'
|
|
);
|
|
return array_merge( $sizes, $custom_sizes );
|
|
|
|
}
|
|
add_action('init', 'custom_taxonomy_flush_rewrite');
|
|
function custom_taxonomy_flush_rewrite() {
|
|
global $wp_rewrite;
|
|
$wp_rewrite->flush_rules();
|
|
}
|
|
|
|
function my_template_redirect()
|
|
{
|
|
global $wp;
|
|
if ($wp->query_vars["taxonomy"] == "batefuel")
|
|
{
|
|
include(get_stylesheet_directory() . "/taxonomy-batefuel.php");
|
|
die();
|
|
}
|
|
}
|
|
//add_action("template_redirect", "my_template_redirect");
|
|
|
|
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
|
|
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );
|
|
|
|
function my_pre_get_posts( $query ) {
|
|
|
|
// do not modify queries in the admin
|
|
if( is_admin() ) {
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
// only modify queries for 'event' post type
|
|
if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'af_product'
|
|
) {
|
|
|
|
// allow the url to alter the query
|
|
if( isset($_GET['country']) ) {
|
|
|
|
$query->set('meta_key', 'international_flags');
|
|
$query->set('meta_value', $_GET['country']);
|
|
$query->set('meta_compare','LIKE');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// return
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
function wpb_alter_comment_form_fields($fields) {
|
|
unset($fields['author']);
|
|
unset($fields['email']);
|
|
unset($fields['url']);
|
|
return $fields;
|
|
}
|
|
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');
|
|
|
|
|
|
add_action('pre_get_posts', 'my_pre_get_posts');
|
|
do_shortcode( '[cf7-db-display-ip]' );
|
|
?>
|