From 81479e51b380cf8150929090aaeb8c22ed61815b Mon Sep 17 00:00:00 2001 From: Gregory Pradun Date: Tue, 4 May 2021 22:12:50 +0300 Subject: [PATCH 1/2] fix top menu loading --- htdocs/wp-content/themes/lawcarta/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/wp-content/themes/lawcarta/functions.php b/htdocs/wp-content/themes/lawcarta/functions.php index ec20d90..aff19ac 100644 --- a/htdocs/wp-content/themes/lawcarta/functions.php +++ b/htdocs/wp-content/themes/lawcarta/functions.php @@ -59,7 +59,7 @@ function lawcarta_fonts_url() { add_action('wp_enqueue_scripts', function () { wp_enqueue_style('lawcarta-fonts', lawcarta_fonts_url(), array(), null); - wp_enqueue_script('custom-jquery', '//code.jquery.com/jquery-2.2.4.min.js', [], null, true); + wp_enqueue_script('custom-jquery', '//code.jquery.com/jquery-2.2.4.min.js', [], null); wp_enqueue_style('bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', ['lawcarta-fonts'], null); wp_enqueue_script('bootstrap', '//stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', ['custom-jquery'], null, true); From bf6918cbdf8aa5db37696642f7ca40fe74e46cbf Mon Sep 17 00:00:00 2001 From: Gregory Pradun Date: Tue, 18 May 2021 17:34:53 +0300 Subject: [PATCH 2/2] LAW-4201 --- .../wp-content/themes/lawcarta/functions.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/htdocs/wp-content/themes/lawcarta/functions.php b/htdocs/wp-content/themes/lawcarta/functions.php index aff19ac..138ee4c 100644 --- a/htdocs/wp-content/themes/lawcarta/functions.php +++ b/htdocs/wp-content/themes/lawcarta/functions.php @@ -289,3 +289,69 @@ function add_custom_class($classes=array(), $menu_item=false) { } add_filter('nav_menu_css_class', 'add_custom_class', 100, 2); +/** + * Add Disallow for some file types. + * Add "Disallow: /wp-login.php/\n". + * Remove "Allow: /wp-admin/admin-ajax.php\n". + * Calculate and add a "Sitemap:" link. + */ +add_filter( 'robots_txt', function( $output, $public ) { + /** + * If "Search engine visibility" is disabled, + * strongly tell all robots to go away. + */ + if ( '0' == $public || LAWCARTA_ENVIRONMENT_NAME != 'prod') { + $output = "User-agent: *\nDisallow: /\nDisallow: /*\nDisallow: /*?\n"; + } else { + /** + * Disallow some file types + */ + foreach( array( 'jpeg','jpg','gif','png','mp4','webm','woff','woff2','ttf','eot' ) as $ext ) { + $output .= "Disallow: /*.{$ext}$\n"; + } + + /** + * Get site path. + */ + $site_url = parse_url( site_url() ); + $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : ''; + + /** + * Add new disallow. + */ + $output .= "Disallow: $path/wp-login.php\n"; + + /** + * Remove line that allows robots to access AJAX interface. + */ + $robots = preg_replace( '/Allow: [^\0\s]*\/wp-admin\/admin-ajax\.php\n/', '', $output ); + + /** + * If no error occurred, replace $output with modified value. + */ + if ( ! is_null( robots ) ) { + $output = $robots; + } + + /** + * Remove line Sitemap. + */ + $robots = preg_replace( '/Sitemap: [^\0\s]*\n/', '', $output ); + + /** + * If no error occurred, replace $output with modified value. + */ + if ( ! is_null( robots ) ) { + $output = $robots; + } + + /** + * Calculate and add a "Sitemap:" link. + * Modify as needed. + */ + $output .= "Sitemap: {$site_url['scheme']}://{$site_url[ 'host' ]}/wp-sitemap.xml\n"; + } + + return $output; + +}, 99, 2 ); // Priority 99, Number of Arguments 2. \ No newline at end of file