Skip to content

Instantly share code, notes, and snippets.

@kraftbj
kraftbj / functions.php
Created May 6, 2016 19:33
Add beautiful math support to Sensei Answer Notes
<?php //remove in an existing file
add_filter( 'sensei_question_answer_notes', 'latex_markup' );
@kraftbj
kraftbj / functions.php
Created May 4, 2016 19:37
Show hidden WC products in the job listing
<?php //remove in an existing file
add_filter( 'wcpl_get_job_packages_args', 'bk_show_hidden_job_packages');
function bk_show_hidden_job_packages( $args ) {
unset( $args['meta_query'] );
return $args;
}
@kraftbj
kraftbj / functions.php
Last active May 3, 2016 18:02
Remove job_feed
add_action( 'init', 'bk_remove_jobfeed' );
function bk_remove_jobfeed(){
global $wp_rewrite;
if ( ( $key = array_search( 'job_feed', $wp_rewrite->feeds ) ) !== false ) {
unset( $wp_rewrite->feeds['jobfeed'] );
remove_all_actions( 'do_feed_job_feed' );
}
}
@kraftbj
kraftbj / functions.php
Created April 19, 2016 22:07
Force paid orders as approved
<?php //remove in an existing file
add_action( 'woocommerce_order_status_completed', 'bk_force_add', 9 );
add_action( 'woocommerce_order_status_completed', 'bk_force_drop', 11 );
function bk_force_add() {
add_filter( 'pre_option_job_manager_submission_requires_approval', '__return_false' );
}
function bk_force_drop() {
@kraftbj
kraftbj / functions.php
Created April 18, 2016 20:02
Change WordPress' from e-mail address
add_filter( 'wp_mail_from', 'bk_from_addy');
function bk_from_addy( $email ) {
$email = "[email protected]";
return $email;
}
@kraftbj
kraftbj / functions.php
Created April 15, 2016 19:37
Show which package was used to purchase
add_filter( 'job_manager_job_listing_data_fields', 'custom_job_manager_job_listing_data_fields' );
function custom_job_manager_job_listing_data_fields( $fields ) {
// Here we target one of the job fields (location) and change it's placeholder
$fields['_package_id'] = array(
'label' => "Package ID",
'placeholder' => "None",
'description' => '',
'type' => 'package_display'
@kraftbj
kraftbj / functions.php
Created April 13, 2016 16:39
Exclude password protected posts
<?php //remove in an existing file
add_action( 'before_get_job_listings', 'bk_remove_password_posts' );
add_action( 'after_get_job_listings' , 'bk_clean_password_posts' );
function bk_remove_password_posts() {
add_filter( 'posts_where', 'bk_password_post_filter' );
}
function bk_clean_password_posts() {
@kraftbj
kraftbj / functions.php
Created April 12, 2016 22:35
Change the password prompt
add_filter( 'the_password_form', 'bk_custom_password_form' );
function bk_custom_password_form( $output ){
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
';
return $output;
}
@kraftbj
kraftbj / functions.php
Created April 1, 2016 16:19
Needed server vars
<?php // remove in an existing file
add_action( 'admin_notices', 'bk_output_vars' );
function bk_output_vars(){
echo "The port is " . $_SERVER['SERVER_PORT'];
echo "<br>The host is " . $_SERVER['HTTP_HOST'];
}
@kraftbj
kraftbj / functions.php
Created March 30, 2016 22:17
What's the server port?
<?php //do not add to an existing file
add_action('admin_notices', 'bk_server_port_output');
function bk_server_port_output(){
echo "Server port is " . $_SERVER['SERVER_PORT'];
}