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
import { select, subscribe } from '@wordpress/data' | |
export function whenEditorIsReady() { | |
return new Promise((resolve) => { | |
const unsubscribe = subscribe(() => { | |
// This will trigger after the initial render blocking, before the window load event | |
// This seems currently more reliable than using __unstableIsEditorReady | |
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) { | |
unsubscribe() | |
resolve() |
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(!defined('ABSPATH')) { die(); } // Include in all php files, to prevent direct execution | |
/** | |
* Plugin Name: WP Geo Query | |
* Plugin URI: https://gschoppe.com/wordpress/geo-searches/ | |
* Description: Adds location search support to WP_Query, making it easy to create completely custom "Find Location" pages. | |
* Author: Greg Schoppe | |
* Author URI: https://gschoppe.com | |
* Version: 1.0.0 | |
**/ |
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 | |
namespace App; | |
use Carbon_Fields\Field; | |
use Carbon_Fields\Block; | |
Block::make( __( 'Gutenberg Block' ) ) | |
->set_icon( 'format-chat') | |
->add_fields( array( | |
Field::make( 'rich_text', 'text', __( 'text', 'my-theme' ) ) |
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
$( '#search' ).select2( { | |
ajax: { | |
url: API.root + '/wp/v2/posts', | |
processResults: function( data, page ) { | |
console.log( data ); | |
return { | |
//do something results | |
} | |
}, | |
cache: 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
this.$el.find( '.taxonomy-terms' ).select2({ | |
multiple: true, | |
ajax: { | |
url: WP_API_Settings.root + 'wp/v2/terms/' + this.options.taxonomy.slug, | |
data: function( term, page ) { | |
return { | |
search: term, | |
page: page, | |
_envelope: true | |
} |
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
$ wp post list --format=ids | xargs wp post update --comment_status=closed | |
# Output: | |
# Success: Updated post 2514. | |
# Success: Updated post 2511. | |
# Success: Updated post 2504. | |
# Success: Updated post 2499. | |
# Success: Updated post 2441. | |
# etc... |
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
/** | |
* Retrieves all the rows in the active spreadsheet that contain data and logs the | |
* values for each row. | |
* For more information on using the Spreadsheet API, see | |
* https://developers.google.com/apps-script/service_spreadsheet | |
*/ | |
function readRows() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var rows = sheet.getDataRange(); | |
var numRows = rows.getNumRows(); |
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 | |
// Just require() this class via your theme's functions.php file. | |
/* Then instantiate this at the top of your 404.php file with: | |
if ( class_exists( 'Clean_404_Email' ) ) | |
new Clean_404_Email; | |
*/ | |
class Clean_404_Email { | |
var $time, $request, $blog, $email, $theme, $theme_data, $site, $referer, $string, $address, $remote, $agent, $message; |
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
function format_phone($phone) | |
{ | |
$phone = preg_replace("/[^0-9]/", "", $phone); | |
if(strlen($phone) == 7) | |
return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone); | |
elseif(strlen($phone) == 10) | |
return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone); | |
else | |
return $phone; |
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
# | |
# Sample nginx.conf optimized for EC2 c1.medium to xlarge instances. | |
# Also look at the haproxy.conf file for how the backend is balanced. | |
# | |
user "nginx" "nginx"; | |
worker_processes 10; | |
error_log /var/log/nginx_error.log info; |
NewerOlder