Skip to content

Instantly share code, notes, and snippets.

View JarrydLong's full-sized avatar

Jarryd Long JarrydLong

  • Paid Memberships Pro
  • South Africa
  • 04:55 (UTC +02:00)
  • X @jarrydlong
View GitHub Profile
@JarrydLong
JarrydLong / gist:3bdb5a280d56e695c2a7de96d93136cc
Created September 21, 2016 18:32 — forked from mikejolley/gist:3b37b9cc19a774665f31
Example instance based shipping method
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Sample instance based method.
*/
class WC_Shipping_Test_Method extends WC_Shipping_Method {
@JarrydLong
JarrydLong / wp-live-chat-support-conditional-pages.php
Created October 10, 2016 09:12
Choose which page a specific agent's profile picture will display on.
add_action("wplc_hook_push_js_to_front", "my_function"); //Our Hook
function my_function(){ //Our Function
$post_id = url_to_postid($url); //Get Post ID
if($post_id === 3){ //Post ID matches '3'
//More complicated logic could be added
$user_id = 5; //Set the new user ID - You would need your own logic here
change_active_agent($user_id); //Set the active agent to '$user_id'
}
@JarrydLong
JarrydLong / WP Live Chat Support
Created June 23, 2017 07:01
Open the chat window without having the hovercard open first
/**
* Opens the chat window (both online/offline) instead of having to click on the hover card's 'Send Message' or 'Start Chat' button.
*/
jQuery(document).ready(function(){
jQuery("body").on("click", "#wp-live-chat-header", function(){
setTimeout(function(){
jQuery("#wplc_start_chat_btn").click();
jQuery("#speeching_button").click();
}, 300);
@JarrydLong
JarrydLong / WP Live Chat Support Pro
Created June 23, 2017 07:04
Only show the departments menu to administrators on the site
add_filter( 'wplc_ma_filter_menu_control', 'wplc_custom_settings_permission_plug', 11, 1 );
function wplc_custom_settings_permission_plug( $array ){
$array[1] = 'manage_options';
$array[3] = 'manage_options';
return $array;
}
@JarrydLong
JarrydLong / WP Live Chat Support Pro
Created July 12, 2017 20:26
Hide all menu items except for the Live Chat dashboard to agents
add_action( 'init', 'wplc_remove_non_agent_menu_items' );
function wplc_remove_non_agent_menu_items(){
if( !current_user_can( 'manage_options' ) ){
remove_action('admin_menu', 'wplc_admin_menu_pro');
remove_action('admin_menu', 'wplc_admin_menu', 4);
add_action('admin_menu', 'wplc_new_agent_dashboard' );
@JarrydLong
JarrydLong / WP Live Chat Support
Created July 24, 2017 19:57
Hide the hovercard once the visitor has closed the chat window
jQuery(document).on('wplc_animation_done', function(){
var should_hide = Cookies.get('wplc_prevent_popup');
if( should_hide == '1' && typeof should_hide != 'undefined' ){
jQuery("#wplc_hovercard").hide();
} else {
jQuery("#wplc_hovercard").fadeIn();
jQuery("#wp-live-chat-header").addClass('active');
}
jQuery("#wp-live-chat-header").on("click", function(){
if( jQuery(this).hasClass('active' ) ){
@JarrydLong
JarrydLong / Nifty Desk API Endpoint
Last active July 28, 2017 06:04
Creates the endpoint /get_tickets to return tickets from a specific number of days ago, or between two dates. Pagination is supported.
/**
* Creates the endpoint /get_tickets to return tickets from a specific number of days ago, or between two dates.
* Pagination is supported.
* Dates are required to be in a formatted string
*/
add_action( 'nifty_desk_api_route_hook', 'nifty_desk_api_route_get_all_tickets' );
function nifty_desk_api_route_get_all_tickets(){
@JarrydLong
JarrydLong / WP Google Maps
Last active August 16, 2017 19:13
Show total markers for a specific map
add_shortcode( 'wpgmza_total_markers', 'wpgmza_total_marker_count' );
function wpgmza_total_marker_count( $atts ){
$atts = shortcode_atts( array(
'id' => 1,
), $atts, 'wpgmza_total_markers' );
$map_id = intval( $atts['id'] );
@JarrydLong
JarrydLong / H-code Theme
Created August 16, 2017 20:24
Fixes the H-code transitions affect on Google Map zooming
.wpgmza_map * {
transition-timing-function: initial !important;
-moz-transition-timing-function: initial !important;
-webkit-transition-timing-function: initial !important;
-o-transition-timing-function: initial !important;
transition-duration: initial !important;
-moz-transition-duration: initial !important;
-webkit-transition-duration: initial !important;
-o-transition-duration: initial !important;
}
@JarrydLong
JarrydLong / WP Live Chat Support
Last active August 24, 2017 17:11
Render a popup on the page. Choose weather to open or close the chat from the popup.
jQuery(document).ready(function(){
var popup_string = "<div class='wplc_custom_popup'>";
popup_string = popup_string + "<p>Can we help you?</p>";
popup_string = popup_string + "<button class='custom_popup_open_chat'>Yes</button>";
popup_string = popup_string + "<button class='custom_popup_close_chat'>No</button>";
popup_string = popup_string + "</div>";
var show_popup = Cookies.get( 'wplc_chat_popup_window' );