Skip to content

Instantly share code, notes, and snippets.

View karlazz's full-sized avatar

Karla Leibowitz karlazz

  • herself
  • Walnut Creek, CA
View GitHub Profile
add_filter( 'page_template', 'wpa3396_page_template' );
function wpa3396_page_template( $page_template )
{
if ( is_page( 'talent-matrix-search' ) ) {
$page_template = dirname( __FILE__ ) . '/talentpage.php';
}
return $page_template;
}
@karlazz
karlazz / gist:137eac6a1ee591a9562f9f62a2b0957d
Created March 23, 2017 17:05
.bash-profile shell command to open a file with text wrangler
alias tw='open -a /Applications/TextWrangler.app'
export tw
@karlazz
karlazz / Wordpress plugin load without ftp
Created April 5, 2017 20:14
Config item for Wordpress plugin load without ftp
define('FS_METHOD','direct');
@karlazz
karlazz / gist:8d5fd25701761abd0030706ec90cab0f
Created April 11, 2017 20:06
check route on wordpress and redirect
add_action('template_redirect','twilio_check_route');
function twilio_check_route() {
global $wp;
$path = explode('/',$wp->request);
trace($path);
if (strtolower($path[0])=='safety-forums') {
/* triggered from google connect */
/* set in the google connect option for redirect on login */
if (! is_user_logged_in() ) {
sed -ie 's/utf8mb4_unicode_520_ci/utf8_general_ci/g' mysql.sql
sed -ie 's/CHARSET=utf8mb4/CHARSET=utf8/g' mysql.sql
sed -ie 's/utf8mb4_unicode_ci/utf8_general_ci/g' mysql.sql
@karlazz
karlazz / jQuery and WordPress no noconflict
Last active February 20, 2023 08:57
Getting around noconflict mode for jQuery and WordPress
From: https://stackoverflow.com/questions/17687619/is-there-a-way-turn-off-jquery-noconflict-mode-in-wordpress
Is there a way turn off jquery noconflict mode in Wordpress? I don't mean loading an alternative version of jquery or the common workarounds:
jQuery(document).ready(function( $ ) {
});
or:
(function($) {
@karlazz
karlazz / gist:2bffba4d0330bf746998319ae144ccaa
Created November 22, 2017 21:57
add a route to wordpress example from delicious brains
function benchmark_request() {
$result = array( 'time' => time() );
echo json_encode( $result );
exit;
}
add_action( 'wp_ajax_benchmark_request', 'benchmark_request' );
add_action( 'rest_api_init', function() {
register_rest_route( 'benchmark/v1', '/benchmark/', array(
'methods' => 'POST',
/*
https://wordpress.stackexchange.com/questions/216376/how-do-i-add-a-template-to-a-theme-using-a-plugin
Here is a fairly simple approach I was able to get working within a plugin. You'll want to reference https://developer.wordpress.org/reference/hooks/theme_page_templates/ and https://developer.wordpress.org/reference/hooks/template_include/ as you review the code below.
*/
<?php
//Add our custom template to the admin's templates dropdown
add_filter( 'theme_page_templates', 'pluginname_template_as_option', 10, 3 );
function pluginname_template_as_option( $page_templates, $this, $post ){
$page_templates['template-landing.php'] = 'Example Landing Page';
function filter_joblisting_json( $data, $post, $context ) {
$phone = get_post_meta( $post->ID, '_phone', true );
if( $phone ) {
$data->data['phone'] = $phone;
}
return $data;
}
add_filter( 'rest_prepare_joblisting', 'filter_joblisting_json', 10, 3 );
@karlazz
karlazz / Wordpress oop starter example
Last active July 18, 2018 23:18
Wordpress OOP starter example tidbits
class MyPlugin {
function __construct() {
add_shortcode('ShowMsg', [$this,'ShowMsg']);
//add_action( 'admin_menu', [$this,'load_starter_tab'] );
add_action( 'admin_menu',
function () {
add_menu_page( 'Publications Upload', 'Publications Upload',
'manage_options', 'ha_pubs_load', [$this,'load_starter']);