Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🇨🇺

Elvis Morales elvismdev

🇨🇺
View GitHub Profile
@samrocksc
samrocksc / extras.php
Last active December 10, 2021 08:54
<?php
/**
* Clean up the_excerpt()
*/
function roots_excerpt_more() {
return ' &hellip; </p><p><a href="' . get_permalink() . '"><strong>' . __('Read More', 'roots') . '</strong></a>';
}
add_filter('excerpt_more', 'roots_excerpt_more');
<?php
class Utility
{
/**
* @param string $data
* @param array $allowedClasses
* @param bool $extend
* @return mixed
*/
static public function deserialize(string $data, array $allowedClasses, $extend = false)
@tripflex
tripflex / functions.php
Last active March 19, 2025 11:59
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@wkw
wkw / gravity-form.php
Last active November 16, 2020 02:23 — forked from OutThisLife/gravity-form.php
Custom: Gravity Forms WP API Submission and GF API form entry creation plus send notifications
<?php
/**
* Add WP API endpoint for form submission, then create new
* Gravity Forms entry and send notifications.
*/
// rest api endpoint for forms submission
add_action( 'rest_api_init', function () {
register_rest_route( 'ahr/v1', '/forms', array(
'methods' => 'POST',
@josephdicdican
josephdicdican / js_calculate_progress_percentage.js
Created January 18, 2017 09:15
JS Calculate Progress Percentage
var completed = 30;
var target = 30;
var progress = Math.ceil(completed / target * 100);
console.log(progress);
@aimeric
aimeric / DefaultController.php
Created January 23, 2017 00:09
Symfony Ajax live search (autocomplete)
<?php
/* src/AppBundle/Controller/DefaultController */
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\ContainerInterface;
@amboutwe
amboutwe / yoast_seo_primary_category_disable.php
Last active May 3, 2021 19:35
Disable Yoast SEO Primary Category Feature
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Disable Yoast SEO Primary Category Feature
* Credit: Yoast development team
* Last Tested: Jan 24 2017 using Yoast SEO 4.1 on WordPress 4.7.1
*/
add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' );
@kocisov
kocisov / next_nginx.md
Last active February 3, 2025 07:27
How to setup next.js app on nginx with letsencrypt
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@unti1x
unti1x / AuthFailureHandler.php
Last active May 17, 2021 16:10
Using EWZRecaptchaBundle with login form
<?php
namespace AppBundle\Form\Handler;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class AuthFailureHandler extends DefaultAuthenticationFailureHandler
{