This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Include this file in your theme and enqueue it like this in PHP: | |
function my_customize_preview_js() { | |
wp_enqueue_script( 'customizer-preview', get_template_directory_uri() . '/path/to/customizer.js', array( 'customize-preview' ), '20170422', true ); | |
} | |
add_action( 'customize_preview_init', 'my_customize_preview_js' ); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$options = [ | |
'parent' => '', | |
'name' => 'Child Theme', | |
'description' => 'Enter child theme description...', | |
'screenshot' => '', | |
'bootstrap' => false | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* FlxZipArchive, Extends ZipArchiv. | |
* Add Dirs with Files and Subdirs. | |
* | |
* <code> | |
* $archive = new FlxZipArchive; | |
* // ..... | |
* $archive->addDir( 'test/blub', 'blub' ); | |
* </code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('init', 'add_countries', 100); | |
function add_countries() | |
{ | |
$country_array = array ( | |
'AF' => 'Afghanistan', | |
'AX' => 'Åland Islands', | |
'AL' => 'Albania', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Subscribe Page | |
*/ | |
get_header(); | |
if( isset($_POST['subscriber_email']) ){ | |
$api_url = 'http://API_URL'; | |
$subscriber_name = $_POST['subscriber_name']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('America/Los_Angeles'); | |
session_start(); | |
include("ratelimiter.php"); | |
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you. | |
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]); | |
$limit = 100; // number of connections to limit user to per $minutes | |
$minutes = 1; // number of $minutes to check for. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( is_admin() ) { | |
add_filter( 'pre_set_site_transient_update_themes', 'gb_check_for_premium_theme_update' ); | |
} | |
function gb_check_for_premium_theme_update( $transient ) { | |
$current_version = 1.2; | |
$api_key = get_option('theme_api_key'); // your theme options will need to have an option to add the API key. | |
$theme_slug = 'theme_slug'; // Change to match with API Key Manager | |
$api_url = 'http://yoursite.com/check-key/'; // change to your site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disables the #wpadmin bar for users without "edit_posts" permissions. | |
*/ | |
function prefix_hide_admin_bar() { | |
if ( ! current_user_can( 'edit_posts' ) ) { | |
add_filter( 'show_admin_bar', '__return_false' ); | |
} | |
} | |
add_action( 'after_setup_theme', 'prefix_hide_admin_bar' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Redirects subscribers back to the home page if they attempt to access the dashboard. | |
*/ | |
function prefix_redirect_admin() { | |
if ( ! current_user_can( 'edit_posts' ) && ! defined( 'DOING_AJAX' ) ) { | |
wp_safe_redirect( home_url() ); | |
exit; | |
} | |
} |
NewerOlder