Skip to content

Instantly share code, notes, and snippets.

View seothemes's full-sized avatar

SEO Themes seothemes

View GitHub Profile
@amorkovin
amorkovin / restapi-wp.js
Last active September 8, 2022 10:47
REST API WordPress JavaScript fetch await async
const urlRequest = 'http://wp.loc/wp-json/wp/v2/posts?_fields=title';
async function getPostsFromWp() {
try {
const response = await fetch( urlRequest )
const data = await response.json()
return data
} catch ( e ) {
console.error( e )
}
@keesiemeijer
keesiemeijer / setup-phpunit.sh
Last active December 8, 2023 11:02
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, curl wget, rsync, git, subversion and composer.
#
# WordPress is installed in the `/tmp/wordpress` directory for use by PHPUnit.
# The WordPress test suite is installed in the `/tmp/wordpress-tests-lib` directory.
<?php
/**
* Template Name: Testimonials - Native Functions
*/
add_action( 'genesis_entry_content', 'prefix_output_testimonials' );
/**
* Output ACF testimonials.
*
* @link https://acfextras.com/simple-testimonials-repeater-field/
@OriginalEXE
OriginalEXE / pe-customize-controls.css
Last active June 26, 2023 05:07
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@m1r0
m1r0 / wp_insert_attachment_from_url.php
Last active April 11, 2024 12:33
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from a URL address.
*
* @param string $url The URL address.
* @param int|null $parent_post_id The parent post ID (Optional).
* @return int|false The attachment ID on success. False on failure.
*/
function wp_insert_attachment_from_url( $url, $parent_post_id = null ) {
@bedeabza
bedeabza / hexhsl.php
Created April 11, 2014 12:10
PHP Hex to HSL and HSL to Hex conversion
function hexToHsl($hex) {
$hex = array($hex[0].$hex[1], $hex[2].$hex[3], $hex[4].$hex[5]);
$rgb = array_map(function($part) {
return hexdec($part) / 255;
}, $hex);
$max = max($rgb);
$min = min($rgb);
$l = ($max + $min) / 2;
@georgiecel
georgiecel / wp-comment-walker
Last active December 28, 2022 15:16
Custom comment walker for HTML5 friendly WordPress comment and threaded replies. To be inserted in functions.php.
<?php
class comment_walker extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
<section class="comments-list">
@danielbeardsley
danielbeardsley / grepReplace
Created September 26, 2011 23:29
Shell Script for grep-based search and replace recursively in files
#!/bin/sh
SEARCH=$1
REPLACE=$2
function ConfirmOrExit() {
echo -n "Continue? (y / n) :"
read CONFIRM
if [ $CONFIRM != 'y' ]
then
exit