Instantly share code, notes, and snippets.

@BoweFrankema
BoweFrankema / example.php
Last active Nov 2, 2018
ACF FB Redirect
View example.php
<?php
//Redirect on special URL format. ie: https://examplesite.com/?profile=visit
function fb_acf_profile_redirect()
{
$profile = $_GET['profile'];
//Is the profile link being requested
if ( $profile == 'visit' ) {
wp_safe_redirect( get_field('profile_redirect', 'option') );
exit;
}
@BoweFrankema
BoweFrankema / random_login.php
Created Jun 1, 2017
Add random login string after login.
View random_login.php
function jpr_generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
View author-role.php
add_action('bp_core_activated_user', 'bp_custom_registration_role',10 , 3);
function bp_custom_registration_role($user_id, $key, $user) {
$userdata = array();
$userdata['ID'] = $user_id;
$userdata['role'] = 'author';
//only allow if user role is my_role
if (($userdata['role'] == "subscriber") or ($userdata['role'] == "contributor"))
wp_update_user($userdata);
}
@BoweFrankema
BoweFrankema / 260-2
Created Dec 18, 2015
Add Default Classes to Sidebar
View 260-2
<?php
/**
* Add the code below to your WeFoster Child Theme
*/
function wfc_add_main_class() {
echo 'my-custom-class ';
}
add_action( 'class_main','wfc_add_main_class' );
function wfc_add_sidebar_class() {
View doing-it-right.html
<?php get_template_part('templates/loops/content', 'page'); ?>
<!-- My Custom Content -->
<p>This is some custom content after my page content is shown. I'm adding this by overwriting my template via a Child Theme!</p>
<!-- My Custom Content -->
<?php do_action('close_page_content'); ?>
@BoweFrankema
BoweFrankema / acf-customizer-patch.php
Created Dec 3, 2015 — forked from fabrizim/acf-customizer-patch.php
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
View acf-customizer-patch.php
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch
@BoweFrankema
BoweFrankema / load_anspress.php
Created Nov 6, 2015
Load AnsPress conditionally.
View load_anspress.php
<?php
function wfc_load_anpress_when_needed() {
if ( is_anspress() ) {
ap_scripts_front();
}
}
add_action('wp_enqueue_scripts', 'wfc_load_anpress_when_needed', 1);
View starter-settings.php
<?php
function wefoster_import_starter_settings() {
$screen = get_current_screen();
if (strpos($screen->id, "acf-options-starter-kits") == true) {
// Check to see if the settings have already been imported.
$starterkit = get_field( "choose_a_starter_kit", 'option' );
$template = get_template();
$imported = get_option( $template . '_' . $starterkit . '_customizer_import', false );
@BoweFrankema
BoweFrankema / theme-tour.php
Last active Aug 29, 2015 — forked from DevinWalker/theme-tour.php
Theme activation welcome message
View theme-tour.php
<?php
/**
* Theme Activation Tour
*
* This class handles the pointers used in the introduction tour.
* @package Popup Demo
*
*/
class WordImpress_Theme_Tour {
@BoweFrankema
BoweFrankema / add-dashicons-to-wordpress-customizer.php
Last active Mar 31, 2018
Add Dashicons to your Customizer Panels. You can find the dashicon CSS classes here: https://developer.wordpress.org/resource/dashicons/#id
View add-dashicons-to-wordpress-customizer.php
<?php
/**
* Enqueue the stylesheet.
* http://aristeides.com/blog/modifying-wordpress-customizer/
*/
function my_enqueue_customizer_stylesheet() {
wp_register_style( 'my-customizer-css', YOUR_PLUGIN_URL. 'assets/css/customizer.css', NULL, NULL, 'all' );
wp_enqueue_style( 'my-customizer-css' );