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 | |
/* | |
* 1. Go to Settings > Permalinks and select any page as home page | |
* Then use the following code | |
* | |
* You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. | |
* Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. | |
* If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, | |
* give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, | |
* so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the 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( 'show_user_profile', 'extra_fields' ); | |
add_action( 'edit_user_profile', 'extra_fields' ); | |
add_action( 'personal_options_update', 'save_fields' ); | |
add_action( 'edit_user_profile_update', 'save_fields' ); | |
add_action( 'pre_get_posts', 'exclude_category' ); | |
function extra_fields($user) { | |
$pref_cat = explode( ',', get_user_meta( $user->ID, 'pref_cat', 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 | |
/** | |
* | |
* Safe Search and Replace on Database with Serialized Data v2.0.1 | |
* | |
* This script is to solve the problem of doing database search and replace when | |
* developers have only gone and used the non-relational concept of serializing | |
* PHP arrays into single database columns. It will search for all matching | |
* data on the database and change it, even if it's within a serialized PHP | |
* array. |
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 | |
/** | |
* Get a WP_Post object by its slug ( post_name ) | |
* | |
* @param $post_name | |
* | |
* @return WP_Post|null | |
*/ | |
function get_post_by_slug( $post_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
function bulk_delete_posts(){ | |
$args = array( 'post_type' =>'post', 'posts_per_page' => -1, 'post_status' => 'any', 'fields' =>'ids'); | |
$books = get_posts( $args ); | |
foreach ($posts as $post) { | |
wp_delete_post( $post, true); | |
} | |
} | |
add_action( 'wp_head', 'bulk_delete_posts' ); |
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 update_cover_image() { | |
$getposts = get_posts( array( | |
'numberposts' => -1, | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'fields' => 'ids', | |
'meta_query' => array( | |
array( | |
'key' => 'cover_image', | |
'compare' => 'LIKE', |
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 bulk_delete_comments(){ | |
$args = array('fields' => 'ids','number' => '','status' => 'all'); | |
$comments = get_comments( $args ); | |
foreach ($comments as $comment) { | |
wp_delete_comment( $comment, true); | |
} | |
} | |
add_action( 'wp_head', 'bulk_delete_comments' ); |
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
* Add Gravity Forms capabilities | |
*/ | |
add_filter('user_has_cap', | |
function( $caps ){ | |
if (! empty( $caps['edit_pages'] ) ) { // user has edit capabilities | |
$caps['gravityforms_delete_entries'] = true; | |
$caps['gravityforms_edit_entries'] = true; | |
$caps['gravityforms_edit_entry_notes'] = true; | |
$caps['gravityforms_view_entries'] = true; | |
$caps['gravityforms_view_entry_notes'] = 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
//https://www.gravityhelp.com/documentation/article/gform_save_field_value/ | |
add_filter( 'gform_save_field_value', 'jb_encrypt_value', 10, 4 ); | |
function jb_encrypt_value( $value, $lead, $field, $form ) { | |
if($field->cssClass == 'secure'){ | |
$encrypted = GFCommon::encrypt( $value ); | |
return $encrypted; | |
} | |
return $value; |