Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / convert-text-to-url-with-anchor.js
Created January 29, 2018 17:50
Find text of an element and change it to an anchor, while checking if it has HTTP or HTTPS protocol
(function($) {
$( ".website .sb_mod_acf_single_item" ).text(function () {
if ( ($(this).text().length >=5) && ($(this).text().substr(0, 5) != 'http:') && ($(this).text().substr(0, 5) != 'https') ) {
$(this).replaceWith( '<a href="http://' + $(this).text() + '" target="_blank">' + $(this).text() + '</a>' );
}
else {
$(this).replaceWith( '<a href="' + $(this).text() + '" target="_blank">' + $(this).text() + '</a>' );
}
});
})(jQuery);
@Garconis
Garconis / wp-job-manager-posts-for-ultimate-member-profile-tab.php
Created February 5, 2018 17:43
WordPress | Add WP Job Manager posts to Ultimate Member user profile tab
<?php
/** SHORTCODE TO LIST ALL JOBS OF A USER
--- Job Manager shortcode to display a list of "Jobs" (Campaigns) based on the User ID that is set
--- Usage: [campaign-type author="3"]
------ ... You can add additional parameters to the shortcode to override settings if desired
--- Note: Used within the custom Snippet for Ultimate Member tabs.
*/
add_shortcode( 'campaign-type', 'fs_job_type_shortcode' );
function fs_job_type_shortcode( $atts ) {
@Garconis
Garconis / nginx-block-files-unless-logged-in.txt
Created February 16, 2018 17:44
WordPress | NGINX server rule to block access to files in a folder unless logged into WP
set $bar 0;
set $becue 0;
if ( $request_uri ~* "wp-content/uploads/private" ) {
set $bar 1;
}
if ($http_cookie ~ "wordpress_logged_in") {
set $becue 1;
}
set $barbecue "$bar:$becue";
if ($barbecue = "1:0") {
@Garconis
Garconis / fancy-useful-stuff-with-jQuery.js
Created February 26, 2018 20:34
jQuery | Useful jQuery functions to manipulate content
(function($) {
// do this even when ajax updates content
function doStuff(){
$("<span class='icr-item type_checkbox'></span>").insertAfter(".checkbox input");
}
$(document).ready(doStuff);
$(document).ajaxComplete(doStuff);
// add target blank to anchor
@Garconis
Garconis / divi-builder-on-cpt.php
Created March 2, 2018 17:35
Divi | Add Divi Buildler and Divi Library to WordPress custom post types
<?php
function fs_et_builder_post_types( $post_types ) {
// the identifier of the post type
$post_types[] = 'your-cpt';
return $post_types;
}
add_filter( 'et_builder_post_types', 'fs_et_builder_post_types' );
// the code to make the Divi Library work is this:
@Garconis
Garconis / divi-open-toggle-from-another-page.js
Last active September 14, 2020 16:39
Divi | Open toggle from another page (or same page) based on toggle ID and URL hash
// courtesy: https://bernadot.com/divi-theme-how-to-open-toggled-modules-with-a-url-hashtag/
(function($){
// open Toggle module if URL in address bar has same hash
$(window).load(function(){
var et_hash = window.location.hash;
if(window.location.hash) {
$( '.et_pb_toggle' + et_hash )
.removeClass('et_pb_toggle_close')
.addClass('et_pb_toggle_open')
}
@Garconis
Garconis / divi-regular-mobile-header-for-centered.js
Created March 13, 2018 15:53
Divi | Force centered header to use regular mobile header
// https://divibooster.com/use-default-mobile-menu-with-the-centered-inline-logo-header/
(function($) {
function resize() {
$window = $(window);
$body = $('body');
if ($window.width() < 981) {
$body.addClass('et_header_style_left');
$body.removeClass('et_header_style_split');
} else {
$body.removeClass('et_header_style_left');
@Garconis
Garconis / awesome-tickets-dashboard.php
Last active March 20, 2018 13:23
WooCommerce | Show only open tickets in WooCommerce Dashboard to user for Awesome tickets plugin
<?php
add_action( 'woocommerce_account_dashboard', 'my_dashboard_tickets' );
function my_dashboard_tickets() {
$user_id = get_current_user_id();
$ticket_options = array(
'post_type' => 'ticket',
'order' => 'DESC',
'orderby' => 'date',
@Garconis
Garconis / svg-support-in-wordpress.php
Created March 16, 2018 12:42
WordPress | Allow SVG through WordPress Media Uploader
<?php
// Allow SVG through WordPress Media Uploader
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
@Garconis
Garconis / woocommerce-product-attribute-list.php
Created March 20, 2018 13:25
WooCommerce | Output a list of product attribute terms for a specific attribute
<?php
add_shortcode( 'fs-product-special-features', 'fs_product_special_features_img_shortcode' );
function fs_product_special_features_img_shortcode( $atts ) {
// begin output buffering
ob_start();
// grab the terms of the product's attribute
$special_feature_terms = get_the_terms($post->ID, 'pa_special-features');
//$count = count($special_feature_terms);