Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / autoimporter.php
Created April 23, 2024 14:43 — forked from RalfAlbert/autoimporter.php
WordPress: Class to allow automatically import posts/pages
<?php
/** Display verbose errors */
define( 'IMPORT_DEBUG', false );
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
if ( ! class_exists( 'WP_Importer' ) ) {
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
if ( file_exists( $class_wp_importer ) )
@dexit
dexit / functions.php
Created April 22, 2024 14:21 — forked from KimJoyFox/functions.php
Wordpress: using Excerpts from Advanced Custom Fields on the Search Results Page
function excerpt_function($ID, $searchTerms) {
global $wpdb;
$thisPost = get_post_meta($ID);
foreach ($thisPost as $key => $value) {
if ( false !== stripos($value[0], $searchTerms) ) {
$found = substr(strip_tags($value[0]), 0, 150);
echo $found . ' ...';
}
}
}
@dexit
dexit / spotifyAPI.php
Created April 22, 2024 14:21 — forked from KimJoyFox/spotifyAPI.php
Display Spotify Episodes on Your Website: Simple API
<?php
add_shortcode( 'spotify', 'getSpotify' );
function getSpotify(){
// Add 'YOUR_CLIENT_ID' and 'YOUR_CLIENT_SECRET' with your actual Spotify API credentials
$client_id = '';
$client_secret = '';
$show_id = '';
$ch = curl_init();
<?php
add_filter('the_content', 'hjs_insert_content_after_chars_words');
function hjs_insert_content_after_chars_words($content) {
// only do this if post is longer than 1000 characters
$enable_length = 1500;
// insert after the first </p> after 500 characters
$after_character = 1500;
if (is_single() && strlen($content) > $enable_length) {
$before_content = substr($content, 0, $after_character);
$after_content = substr($content, $after_character);
@dexit
dexit / events-recurring.php
Created April 22, 2024 14:20 — forked from hirejordansmith/events-recurring.php
Events Recurring with Thumbnail Support
<?php
/**
* Recurring Events
*
* @package BE-Events-Calendar
* @since 1.0.0
* @link https://github.com/billerickson/BE-Events-Calendar
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2014, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
<?php
// Returns subtotal price ($5.00)
$cart_subtotal = WC()->cart->get_cart_subtotal();
// Returns subtotal number value (5)
$cart_subtotal = WC()->cart->subtotal;
/*========================================
Single Product
@dexit
dexit / placeholder_select_for_elementor.js
Created April 22, 2024 14:18 — forked from fgbarrios/placeholder_select_for_elementor.js
Select Form Field - Placeholder Option (for Elementor)
/* Follow up for this thread: https://wordpress.org/support/topic/select-form-field-placeholder-option/
- The first option of your select form must be the placeholder.
- Then, in your JQuery file, copy the code and replace "theName" and "theValue" with the data of your select.
Example:
---- On a HTML page -----
<html>
<head>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="/yourJSfile.js"></script>
@dexit
dexit / Much much simpler option selector for Shopify
Created April 22, 2024 14:18 — forked from AntonLitvin/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
<label for="select-one">{{ product.options[0] }}</label>
<select id="select-one" onchange="letsDoThis()">
{% for value in product.options_with_values[0].values %}
<option value="{{ value }}" {% if product.options_with_values[0].selected_value == value %}selected{% endif %}>
{{ value }}
</option>
{% endfor %}
@dexit
dexit / related-articles.liquid
Created April 22, 2024 14:17 — forked from atikju/related-articles.liquid
Show related articles based on article tags - Shopify
@dexit
dexit / related-articles.liquid
Created April 22, 2024 14:17 — forked from AntonLitvin/related-articles.liquid
Show related articles based on article tags - Shopify