Skip to content

Instantly share code, notes, and snippets.

@Genyus
Genyus / functions.php
Created March 4, 2022 21:39
Fix for broken Elementor landing pages when using custom permalinks (v3.4.3+)
/**
* Fixes landing page 404 when non-standard permalinks are enabled.
*
* @param \WP_Query $query
*/
function elementor_pre_get_posts( \WP_Query $query ) {
if (
// If the post type includes the Elementor landing page CPT.
class_exists( '\Elementor\Modules\LandingPages\Module' )
&& is_array( $query->get( 'post_type' ) )
@Genyus
Genyus / condition.js
Last active June 22, 2020 17:20
JS snippet demonstrating code refactoring
function isMatch(computerChoice, playerChoice, option1, option2) {
return computerChoice === option1 && playerChoice === option2 || computerChoice === option2 && playerChoice === option1;
}
if (computer.currentChoice == player.currentChoice) {
console.log("It's a tie!");
}
else if (isMatch(computer.currentChoice, player.currentChoice, gameOptions[1], gameOptions[2]) {
console.log("Scalpellus wins!");
}
@Genyus
Genyus / create_plugin.sh
Last active March 29, 2020 15:24
Bash script to create WordPress plugin using modified WordPress Plugin Boilerplate
#!/bin/bash
# Constants
git_url=https://github.com/karannagupta/WordPress-Plugin-Boilerplate/archive/master.zip
archive=WordPress-Plugin-Boilerplate-master
# Save present working directory
pwd=$(pwd)
# Ask the user for details
read -p 'Plugin installation path (e.g. /Users/user/Sites/my-site/wp-content/plugins): ' plugin_path