Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Register Styles and Scripts
*/
add_action( 'wp_enqueue_scripts', 'ft_scripts_styles' );
function ft_scripts_styles() {
@slopesweb
slopesweb / test.md
Created February 18, 2023 01:49 — forked from ityonemo/test.md
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@slopesweb
slopesweb / settings.json
Created February 17, 2023 22:50 — forked from diego3g/NODE.md
VSCode Settings (Updated)
{
"emmet.syntaxProfiles": {
"javascript": "jsx"
},
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 16,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [
80,
@slopesweb
slopesweb / introrx.md
Created December 27, 2022 18:53 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@slopesweb
slopesweb / README.md
Created December 10, 2022 19:49 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@slopesweb
slopesweb / load-posts.js
Created November 21, 2022 23:08 — forked from bebaps/load-posts.js
Load posts into a page using the WP REST API
// This function uses AJAX to run a query.
// It assumes that there are no posts on the page, and they will be loaded by the user on demand.
// // There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page)
$(function() {
// Grab the load button, since I only want to run the code if the button is on the page
var ajaxButton = $('#ajax-button');
if (ajaxButton) {
// The AJAX request
var getPosts = function() {
@slopesweb
slopesweb / rest-api-loop.php
Created November 21, 2022 23:07 — forked from bebaps/rest-api-loop.php
Standard loop of posts using the WP REST API
<?php
// Standard API query arguments
$args = array(
'orderby' => 'title',
'per_page' => 3
);
// Put into the `add_query_arg();` to build a URL for use
// Just an alternative to manually typing the query string
$url = add_query_arg( $args, rest_url('wp/v2/posts') );
@slopesweb
slopesweb / tag-cloud-based-on-category-via-shortcode.php
Created September 13, 2022 12:21 — forked from Garconis/tag-cloud-based-on-category-via-shortcode.php
WordPress | Tag cloud for categories via shortcode
<?php
function tag_cloud_shortcode($atts) {
// first make sure we are within a category
if (is_category()) {
// get info of current category
$category = get_category( get_query_var( 'cat' ) );
// get current category ID
@slopesweb
slopesweb / get-first-category.php
Created September 12, 2022 12:14 — forked from hslaszlo/get-first-category.php
Get first category name or id from wordpress post
<?php
// in the loop
$category = get_the_category();
$currentcat = $category[0]->cat_ID;
$currentcatname = $category[0]->cat_name;
$currentcatslug = $category[0]->slug;
// outside the loop
global $post;
$categories = get_the_category($post->ID);
@slopesweb
slopesweb / AdminMenusImprover.php
Created September 8, 2022 15:37 — forked from iksent/AdminMenusImprover.php
Add new fields to nav_menu_item posts in the WordPress menu editor.
<?php
require_once plugin_dir_path( __FILE__ ) . '/CustomWalkerNavMenuEdit.php';
class AdminMenusImprover {
/**
* Class instance.
*
* @var AdminTaxonomiesImprover instance
*/