tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); register_nav_menus( array( 'primary-menu' => __('Primary Menu'), 'secondary-menu' => __('Secondary Menu') ) ); /** Add custom image sizes */ add_image_size('square-image', 512, 512, true); add_image_size('gallery-image', 1000, 600); add_image_size('masthead', 1600, 1000); add_image_size('50-width-column-images', 600, 480); add_theme_support('menus'); } } add_action('after_setup_theme', 'fifteenten_setup'); add_action('init', 'fifteenten_register_my_menus'); function fifteenten_register_my_menus() { register_nav_menus( array( 'primary-menu' => __('Primary Menu'), 'secondary-menu' => __('Secondary Menu') ) ); } /** * Remove all the annoying things WP spits out */ if (!function_exists('fifteeten_remove_actions')) { function fifteeten_remove_actions() { /** * remove .recentcomments CSS */ global $wp_widget_factory; remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) ); /** * Remove header stuff */ remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); remove_action('wp_head', 'rest_output_link_wp_head', 10); remove_action('template_redirect', 'rest_output_link_header', 11, 0); /** * All actions related to emojis */ remove_action('admin_print_styles', 'print_emoji_styles'); remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_filter('wp_mail', 'wp_staticize_emoji_for_email'); remove_filter('the_content_feed', 'wp_staticize_emoji'); remove_filter('comment_text_rss', 'wp_staticize_emoji'); /** * Remove all new WP SVG nonsense */ // remove SVG and global styles remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles'); // remove wp_footer actions which add's global inline styles remove_action('wp_footer', 'wp_enqueue_global_styles', 1); // remove render_block filters which adding unnecessary stuff remove_filter('render_block', 'wp_render_duotone_support'); remove_filter('render_block', 'wp_restore_group_inner_container'); remove_filter('render_block', 'wp_render_layout_support_flag'); remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles'); remove_action('wp_body_open', 'wp_global_styles_render_svg_filters'); /** * Filter to remove P tags on images */ add_filter('acf_the_content', 'filter_ptags_on_images'); add_filter('use_block_editor_for_post', '__return_false', 10); /** * Remove Default Rest Routes */ remove_action('rest_api_init', 'create_initial_rest_routes', 99); } } add_action('init', 'fifteeten_remove_actions'); /** * Remove native Lazyloading */ add_filter('wp_lazy_loading_enabled', '__return_false'); /** * Allow for SVG & WEBP image uploads and previews */ if (!function_exists('dtd_upload_mimes')) { function dtd_upload_mimes($existing_mimes) { // add WEBP to the list of mime types $existing_mimes['webp'] = 'image/webp'; $existing_mimes['svg'] = 'image/svg+xml'; // return the array back to the function with our added mime type return $existing_mimes; } add_filter('mime_types', 'dtd_upload_mimes'); } if (!function_exists('webp_is_displayable')) { function webp_is_displayable($result, $path) { if ($result === false) { $displayable_image_types = array(IMAGETYPE_WEBP); $info = @getimagesize($path); if (empty($info)) { $result = false; } elseif (!in_array($info[2], $displayable_image_types)) { $result = false; } else { $result = true; } } return $result; } add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2); } if (!function_exists('svg_media_library_css')) { function svg_media_library_css() { $css = ''; $css = 'td.media-icon img[src$=".svg"] { width: 100% !important; height: auto !important; }'; echo ''; } add_action('admin_head', 'svg_media_library_css'); } if (!function_exists('add_mime_types')) { function add_mime_types($mime_types) { $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension return $mime_types; } add_filter('upload_mimes', 'add_mime_types', 1, 1); } function filter_ptags_on_images($content) { return preg_replace('/

\s*()?\s*()\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); } title return $columns; }); // display the column value add_action('manage_' . $post_type . '_posts_custom_column', function ($column_name, $post_id) { if ($column_name == 'menu_order') { echo get_post($post_id)->menu_order; } }, 10, 2); // priority, number of args - MANDATORY HERE! // make it sortable $menu_order_sortable_on_screen = 'edit-' . $post_type; // screen name of LIST page of posts add_filter('manage_' . $menu_order_sortable_on_screen . '_sortable_columns', function ($columns) { // column key => Query variable // menu_order is in Query by default so we can just set it $columns['menu_order'] = 'menu_order'; return $columns; }); $filetype['ext'], 'type' => $filetype['type'], 'proper_filename' => $data['proper_filename'] ]; }, 10, 4); function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'cc_mime_types'); function fix_svg() { echo ''; } add_action('admin_head', 'fix_svg'); and
from Contact Form 7 add_filter('wpcf7_autop_or_not', '__return_false'); /** * * Add URL Params here to enable get_query_var('var') * */ function add_query_vars_filter($vars) { $vars[] = ""; return $vars; } add_filter('query_vars', 'add_query_vars_filter'); /** * Extend WordPress search to include custom fields * * https://adambalee.com */ /** * Join posts and postmeta tables * * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join */ function cf_search_join($join) { global $wpdb; if (is_search() || get_query_var('_s')) { $join .= ' LEFT JOIN ' . $wpdb->postmeta . ' ON ' . $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id '; } return $join; } add_filter('posts_join', 'cf_search_join'); /** * Modify the search query with posts_where * * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where */ function cf_search_where($where) { global $pagenow, $wpdb; if (is_search() || get_query_var('_s')) { $where = preg_replace( "/\(\s*" . $wpdb->posts . ".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", "(" . $wpdb->posts . ".post_title LIKE $1) OR (" . $wpdb->postmeta . ".meta_value LIKE $1)", $where ); } return $where; } add_filter('posts_where', 'cf_search_where'); /** * Prevent duplicates * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct */ function cf_search_distinct($where) { global $wpdb; if (is_search() || get_query_var('_s')) { return "DISTINCT"; } return $where; } add_filter('posts_distinct', 'cf_search_distinct'); /** * Add page slug to the class attribute in the body tag. */ function add_slug_body_class($classes) { global $post; if (isset($post)) { $classes[] = " " . $post->post_type . '-' . $post->post_name . " "; } return $classes; } add_filter('body_class', 'add_slug_body_class');