Skip to content

Instantly share code, notes, and snippets.

View jamiecalabro's full-sized avatar

Jamie Calabro jamiecalabro

View GitHub Profile
<?php
namespace App\Nova;
use App\Nova\Fields\DateTime;
use Carbon\CarbonImmutable;
use Cron\CronExpression;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Text;
@tarecord
tarecord / get_primary_taxonomy_term.php
Last active October 7, 2023 18:16
Returns the primary term for the chosen taxonomy set by Yoast SEO or the first term selected.
<?php
/**
* Returns the primary term for the chosen taxonomy set by Yoast SEO
* or the first term selected.
*
* @link https://www.tannerrecord.com/how-to-get-yoasts-primary-category/
* @param integer $post The post id.
* @param string $taxonomy The taxonomy to query. Defaults to category.
* @return array The term with keys of 'title', 'slug', and 'url'.
*/
@MelMacaluso
MelMacaluso / expose_ACF_fields_to_REST.php
Created June 4, 2019 22:54
Automatically expose all the ACF fields to the Wordpress REST API in Pages and in your custom post types.
<?php
function create_ACF_meta_in_REST() {
$postypes_to_exclude = ['acf-field-group','acf-field'];
$extra_postypes_to_include = ["page"];
$post_types = array_diff(get_post_types(["_builtin" => false], 'names'),$postypes_to_exclude);
array_push($post_types, $extra_postypes_to_include);
foreach ($post_types as $post_type) {
register_rest_field( $post_type, 'ACF', [
@bradtraversy
bradtraversy / docker_wordpress.md
Last active May 1, 2024 19:13
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@paulund
paulund / SmokeGuestTest.php
Last active April 12, 2024 15:56
Example of smoke testing guest URLs in a Laravel application
<?php
namespace Tests\Feature\SmokeTests;
use App\Models\Post;
use App\Models\Tutorial;
use Illuminate\Routing\Router;
use Tests\TestCase;
class SmokeGuestTest extends TestCase
@phillip-boombox
phillip-boombox / functions.php
Last active June 5, 2021 19:36
WordPress: Required plugins from the plugins repository
add_filter( 'install_plugins_tabs', 'cmfy_required_plugins_tab' );
function cmfy_required_plugins_tab( $tabs ) {
$tabs['cmfy'] = _x( 'Required', 'Plugin Installer', 'cmfy' );
return $tabs;
}
add_action( 'install_plugins_cmfy', 'cmfy_required_plugins_page' );
function cmfy_required_plugins_page() {
$required_plugin_slugs = array(
'cmb2',
@seoagentur-hamburg
seoagentur-hamburg / .htaccess
Last active April 30, 2024 18:10
UPDATE 2024/03: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2.0.9 - 03/2024
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@joseluisq
joseluisq / 1README.md
Created April 19, 2017 07:33
How add a custom field to Laravel 5.4 default login. LoginController.php

How add a custom field to Laravel 5.4 default login controller.

In this php example (app/Http/Controllers/Auth/LoginController.php) my model is called Client and the custom field for login validation is status. (Client->status)

Add in your resources/lang/en/auth.php file :

    'failed_status' => 'Your account is inactive yet. Please confirm your e-mail address.',
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active April 27, 2024 06:08
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@dduvnjak
dduvnjak / add_cloudflare_ips.sh
Last active March 7, 2024 15:18
Add CloudFlare IP addresses to an EC2 Security Group using awscli
# first we download the list of IP ranges from CloudFlare
wget https://www.cloudflare.com/ips-v4
# set the security group ID
SG_ID="sg-00000000000000"
# iterate over the IP ranges in the downloaded file
# and allow access to ports 80 and 443
while read p
do