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 | |
| // checks if there are any posts that match the query | |
| if ( have_posts() ) : | |
| // If there are posts matching the query then start the loop | |
| while ( have_posts() ) : the_post(); ?> | |
| <article id="post-<?php the_ID(); ?>" role="article" itemprop="hasPart" itemscope="" itemtype="http://schema.org/Article"> | |
| <meta itemscope='itemscope' itemprop='mainEntityOfPage' itemType='https://schema.org/WebPage'/> |
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 | |
| /** | |
| * Get the Yoast primary category from its post meta value, and displays it, with HTML markup. | |
| * If there is no primary category set, it displays the first assigned category. | |
| * | |
| * @param boolean $useCatLink Whether to link the category, if it exists | |
| * @return void | |
| */ | |
| function yourtheme_display_yoast_primary_category( $useCatLink = true ) { |
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
| # Look for client IP in the X-Forwarded-For header | |
| real_ip_header X-Forwarded-For; | |
| # Ignore trusted IPs | |
| real_ip_recursive on; | |
| # Trusted list | |
| set_real_ip_from 199.27.128.0/21; | |
| set_real_ip_from 173.245.48.0/20; | |
| set_real_ip_from 103.21.244.0/22; |
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
| user nginx; | |
| # one(1) worker or equal the number of _real_ cpu cores. 4=4 core cpu | |
| worker_processes 4; | |
| # renice workers to reduce priority compared to system processes for | |
| # machine health. worst case nginx will get ~25% system resources at nice=15 | |
| worker_priority -5; |
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
| # GOAL: On a CentOS 6.7 minimal install, set up nginx as a reverse proxy to uWSGI Emperor with python 2.7.11 as a plugin to run Flask apps | |
| # ::NOTE:: All instructions below are run as a sudoer, not as root. Talk to your sysadmins if you're not a sudoer. | |
| # Install bare essentials: | |
| sudo yum install -y epel-release | |
| sudo yum groupinstall 'Development Tools' | |
| sudo yum install -y vim openssl unzip nginx openssl-devel zlib-devel sqlite-devel bzip2-devel libffi-devel lapack-devel blas-devel libpng-devel freetype-devel | |
| # Set SELINUX=disabled in the file below, and reboot, or this tutorial will get unnecessarily complicated: |
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 | |
| class WP_Scholar_Defer_Scripts { | |
| public static function initialize() { | |
| add_filter( 'script_loader_tag', array( __CLASS__, 'defer_scripts' ), 10, 2 ); | |
| add_filter( 'script_loader_tag', array( __CLASS__, 'async_scripts' ), 10, 2 ); | |
| } | |
| public static function defer_scripts( $tag, $handle ) { |
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
| # === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) === | |
| # | |
| # by Fotis Evangelou, developer of Engintron (engintron.com) | |
| # | |
| # ~ Updated September 2024 ~ | |
| # | |
| # | |
| # The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores. | |
| # If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage. | |
| # |
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 | |
| add_action('admin_init', function () { | |
| // Redirect any user trying to access comments page | |
| global $pagenow; | |
| if ($pagenow === 'edit-comments.php') { | |
| wp_redirect(admin_url()); | |
| exit; | |
| } |
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
| # for redirecting hhtp traffic to https version of the site | |
| server { | |
| listen 80; | |
| server_name example.com; | |
| return 301 https://$server_name$request_uri; | |
| } | |
| # for redirecting to non-www version of the site | |
| server { | |
| listen 80; |
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 | |
| /** | |
| * @param $baseUrl - non protected part of the URL including hostname, e.g. http://example.com | |
| * @param $path - protected path to the file, e.g. /downloads/myfile.zip | |
| * @param $secret - the shared secret with the nginx server. Keep this info secure!!! | |
| * @param $ttl - the number of seconds until this link expires | |
| * @param $userIp - ip of the user allowed to download | |
| * @return string | |
| */ |