Scaling truths, according to Automattic Wordpress VIP dev Matt Perry:
- Wordpress is built to scale
- Truth #1 doesn't matter if your theme or plugin is not built to scale
- Sometimes even fast code is not enough, but it's a good place to start
<?php | |
// Add filter to determine if certain posts should excluded | |
add_filter( 'toplytics_exclude_post', 'check_if_topolytics_should_exclude', 10, 2 ); | |
function check_if_topolytics_should_exclude( $should_exclude, $post_id ) { | |
$excluded_posts = get_peta_excluded_posts(); | |
if ( in_array( $post_id, $excluded_posts ) ) { | |
$should_exclude = true; | |
} | |
return $should_exclude; |
<?php | |
// Add this to the bottom of wp-config.php to log plugin activation errors: | |
add_action( 'activated_plugin','fpt_save_error' ); | |
function fpt_save_error( $tmp_plugin ) { | |
$out_txt = PHP_EOL . date( "Y/m/d H:i" ) . ' Plugin activation: ' . $tmp_plugin . ' ---messages--->' . PHP_EOL; | |
$out_txt .= ob_get_contents(); | |
$out_txt .= PHP_EOL . '<---- end plugin activation ---' . PHP_EOL; | |
file_put_contents( ABSPATH. 'wp-content/uploads/plugin_activation.log', $out_txt, FILE_APPEND ); | |
} |
<?php | |
class Gravity_Forms_Customizations { | |
public static function init() { | |
add_action( 'gform_after_save_form', array( __CLASS__, 'enable_honeypot_on_new_form_creation' ), 10, 2 ); | |
} | |
public static function enable_honeypot_on_new_form_creation( $form, $is_new ) { | |
if ( $is_new ) { | |
$form['enableHoneypot'] = true; |
<?php | |
/** | |
* Wrapping with a class the static way: | |
*/ | |
Static_Convio_Gravity_Forms_Meta::init(); | |
class Static_Convio_Gravity_Forms_Meta { | |
public static function init() { | |
add_action( 'gform_post_update_form_meta', array( __CLASS__, 'pga_gform_post_update_form_meta' ), 10, 3 ); |
<pre> | |
<?php | |
ini_set( 'display_errors', 'On' ); | |
error_reporting( E_ALL ); | |
function test_function() { | |
$test = rand(); | |
return $test; | |
} |