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 str_replace_around_pre_code( $_search, $_replace, $content ) { | |
$new_content = ''; | |
// deal with matches inside pre and code tags. we don't want to have links in sourcecode so only process around this. | |
if ( preg_match_all( "/(.*)(<(pre|code).*>.+<\/(pre|code)>)(.*)/msiU", $content, $content_split, PREG_PATTERN_ORDER ) ) { | |
foreach ( $content_split[0] as $cnt_key => $raw ) { | |
foreach( $_search as $key => $search ) { | |
$content_split[1][$cnt_key] = str_replace( $search, $_replace[$key], $content_split[1][$cnt_key] ); | |
$content_split[5][$cnt_key] = str_replace( $search, $_replace[$key], $content_split[5][$cnt_key] ); | |
} | |
$new_content .= $content_split[1][$cnt_key] . $content_split[2][$cnt_key] . $content_split[5][$cnt_key]; |
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 | |
/** | |
* Wrapper function around wp_nav_menu() that will cache the wp_nav_menu for all tag/category | |
* pages used in the nav menus | |
*/ | |
function cached_nav_menu( $args = array(), $prime_cache = true ) { | |
global $wp_query; | |
$queried_object_id = empty( $wp_query->queried_object_id ) ? 0 : (int) $wp_query->queried_object_id; |
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
if ( function_exists( 'wpcom_is_vip' ) && wpcom_is_vip() ) { | |
wpcom_vip_load_helper_wpcom(); | |
} else { | |
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-local-development-helper/vip-local-development-helper.php' ); | |
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-powered-wpcom/vip-powered-wpcom.php' ); | |
} | |
wpcom_vip_load_helper(); | |
wpcom_vip_load_plugin( 'easy-custom-fields' ); |
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 | |
$time1 = time(); // set the start time | |
dosomethingnasty(); | |
function dosomethingnasty() { | |
for( $i=0; $i < 300; $i++ ) { | |
progress( $i, 300, 40 ); | |
sleep( 1 ); | |
} |
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 | |
WP_CLI::addCommand('export', 'ExportCommand'); | |
/** | |
* Implement export command | |
* | |
* @package wp-cli | |
* @subpackage commands/internals | |
*/ |
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 ( preg_match_all( '/(?P<protocol>(?:(?:f|ht)tp|https):\/\/)?(?P<domain>(?:(?!-)(?P<sld>[a-zA-Z\d\-]+)(?<!-)[\.]){1,2}(?P<tld>(?:[a-zA-Z]{2,}\.?){1,}){1,}|(?P<ip>(?:(?(?<!\/)\.)(?:25[0-5]|2[0-4]\d|[01]?\d?\d)){4}))(?::(?P<port>\d{2,5}))?(?:\/(?P<script>[~a-zA-Z\/.0-9-_]*)?(?:\?(?P<parameters>[=a-zA-Z+%&\&\'\(\)0-9,.\/_ -]*))?)?(?:\#(?P<anchor>[=a-zA-Z+%&0-9._]*))?/x', $text, $data ) ) { | |
foreach ( $data['0'] as $url_key=>$url ) { | |
$domain = $data['sld'][$url_key].".".$data['tld'][$url_key]; | |
$host = $data['domain'][$url_key]; | |
$script = $data['script'][$url_key]; | |
// for now we only want domains | |
//$urls[] = array('url'=>$url, 'host'=>$host, 'domain'=>$domain, 'script'=>$script); | |
$domains[$domain] = 0; // we do it like this to make sure we have only one hit per domain/context |
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
(defun setup-my-windows () | |
(interactive) | |
(select-window (get-largest-window)) | |
(delete-other-windows) | |
(set-window-dedicated-p (selected-window) 1) | |
(split-window-horizontally) | |
(other-window 1) | |
;; top right | |
;;(set-window-dedicated-p (selected-window) 1) |
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( 'generate_rewrite_rules', 'debug_action_generate_rewrite_rules', 1, 1 ); | |
// debug http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1592 | |
// this should only be hit if the rewrite_rules option is empty. | |
// http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1616 | |
function debug_action_generate_rewrite_rules( $rules ) { | |
global $debug_action_rules; | |
error_log( __FUNCTION__ . ' : ' . __LINE__ ); | |
error_log( var_export( $_SERVER, true ) ); | |
error_log( "Rules Option: " . var_export( get_option( 'rewrite_rules' ), 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
<?php | |
add_action( 'plugins_loaded', 'bypass_wp_login_for_pw_protected_posts' ); | |
function bypass_wp_login_for_pw_protected_posts() { | |
// this functionality is a fork of http://core.trac.wordpress.org/browser/trunk/wp-login.php#L385 | |
// keep this in sync with Core | |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; | |
if ( 'postpass' <> $action ) | |
return; |
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
if ( !class_exists( "Easy_CF_Field_Image" ) ) { | |
class Easy_CF_Field_Image extends Easy_CF_Field { | |
public function print_form() { | |
$class = ( empty( $this->_field_data['class'] ) ) ? $this->_field_data['id'] . '_class' : $this->_field_data['class']; | |
$input_class = ( empty( $this->_field_data['input_class'] ) ) ? $this->_field_data['id'] . '_input_class' : $this->_field_data['input_class']; | |
$name = ( empty( $this->_field_data['name'] ) ) ? $this->_field_data['id'] : $this->_field_data['name']; | |
$id = ( empty( $this->_field_data['id'] ) ) ? $this->_field_data['id'] : $this->_field_data['id']; | |
$label = ( empty( $this->_field_data['label'] ) ) ? $this->_field_data['id'] : $this->_field_data['label']; | |
$value = $this->get(); | |
$hint = ( empty( $this->_field_data['hint'] ) ) ? '' : '<p><em>' . $this->_field_data['hint'] . '</em></p>'; |
OlderNewer