Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@cdsaenz
cdsaenz / blog-infinity.php
Last active May 15, 2023 17:10
WordPress Template for JavaScript Blog Articles Load with Infinity Scroll
<?php
/**
* Template Name: Blog Infinity
* CSDev
* Assign to a page called "Blog" or something
* Requires Bootstrap 5 but can be easily refactored to your Stylesheet
*/
add_action('wp_head', function () {
@cdsaenz
cdsaenz / card.php
Created May 13, 2023 21:31 — forked from Niq1982/card.php
Load more to WordPress blog archive using AlpineJS and Axios
<div class="card">
<?php if ($args['link']) : ?>
<a href="<?php echo esc_url($args['link']); ?>" class="global-link">
</a>
<?php endif; ?>
<div class="card-image">
<?php wp_get_attachment_image($args['image']); ?>
</div>
@cdsaenz
cdsaenz / functions.php
Last active April 22, 2023 16:47
WP Mail using authenticated SMTP without a plugin
<?php
use PHPMailer\PHPMailer\PHPMailer;
// Set up SMTP settings
add_action( 'phpmailer_init', 'wpse_phpmailer_init' );
function wpse_phpmailer_init( PHPMailer $mailer ) {
$mailer->isSMTP();
$mailer->Host = ''; // replace with your SMTP server hostname
@cdsaenz
cdsaenz / home-slides.php
Created March 28, 2023 18:59
Home Sliders for WordPress, work in progress
<?php
/**
* Home Slides
* CSDev
*/
namespace CSDev;
?>
@cdsaenz
cdsaenz / functions.php
Created March 17, 2023 12:37
Hello Elementor Child With Bootstrap
<?php
/**
* Hello Elementor child theme
* Version 1.0 march 2023
* CSDev
*/
require_once get_stylesheet_directory() . '/includes/slider.php';
/**
* NAVWALKER BOOTSTRAP 5
* Extra levels
*/
.navbar.navbar-expand-lg .dropdown .dropdown-menu .dropdown-submenu {
/* dropdown sub menu positioning */
margin: 0;
left: 100%;
}
@cdsaenz
cdsaenz / wpinstall.sh
Created January 18, 2023 18:40 — forked from fmtarif/wpinstall.sh
#wp #bash #cli Install and initial set up for WordPress sites (uses WP-CLI)
#!/bin/bash
# get wp-cli
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && sudo mv wp-cli.phar /usr/local/bin/wp
# wp-cli auto-completion
# wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash && source wp-completion.bash && echo -e "\nsource wp-completion.bash" >> .bashrc
#verify if wp-cli correctly installed
# wp --info
@cdsaenz
cdsaenz / 01-common-example.php
Created November 14, 2022 17:29 — forked from westonruter/01-common-example.php
Temporarily disabling filters in WordPress
<?php // Common way to do it:
remove_filter( 'the_title', 'wptexturize' );
$title = get_the_title();
add_filter( 'the_title', 'wptexturize' );
@cdsaenz
cdsaenz / wpml.md
Created November 8, 2022 16:12
WPML Notes

WooCommerce

  • Let products be managed automatically.
  • Edit categories in Taxonomy Translation, Product Categories.

Templates

  • Some pages I'll create a template (ie template-contact.php) with __('') strings inside
  • Pages with lot of text i'll create as template-contact_es.php etc loaded automatically by a function. The template will be just one which will invoke such function.

Theme strings

@cdsaenz
cdsaenz / Woo_WC_Product_Variable.php
Created October 4, 2022 00:51 — forked from gorkamu/Woo_WC_Product_Variable.php
Extended Woocommerce Variation Class
<?php
class Woo_WC_Product_Variable extends WC_Product_Variable {
public function get_all_variations() {
$available_variations = array();
foreach($this->get_children() as $child_id){
$variation = wc_get_product($child_id);
$available_variations[] = $this->get_available_variation($variation);
}