Skip to content

Instantly share code, notes, and snippets.

View raftaar1191's full-sized avatar
🏠
Working from home

Deepak Gupta raftaar1191

🏠
Working from home
View GitHub Profile
@raftaar1191
raftaar1191 / functions.php
Last active August 26, 2024 17:07
Child theme Update via Github
define( 'CHILD_THEME_FILES', __FILE__ );
define( 'CHILD_THEME_NAME_SLUG', 'astra-child' );
$stylesheet_directory = get_stylesheet_directory();
/**
* Load the file that include the code of product single page
*/
@raftaar1191
raftaar1191 / functions.php
Created July 25, 2024 18:00
Add settings button into the plugins
/**
* Add Settings link to plugins area.
*
* @since 1.0.0
*
* @param array $links Links array in which we would prepend our link.
* @param string $file Current plugin basename.
* @return array Processed links.
*/
@raftaar1191
raftaar1191 / functions.php
Created May 31, 2024 10:35
Limit search results to WooCommerce Products only in frontend
/**
* Only allow the product CPT to be search on the golbal search page
*
* @param WP_Query $query The WP_Query instance (passed by reference).
*/
function tometal_filter_search_only_products( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
$query->set( 'post_type', 'product' );
}
@raftaar1191
raftaar1191 / functions.php
Last active May 30, 2024 09:18
Get Draft post for non login user as well via WP REST API
/**
* Filter to alter the rest_query args to add draft and filter
*
* @param array $args Array of arguments for WP_Query.
* @param WP_REST_Request $request The REST API request.
*
* @return array $args Array of arguments for WP_Query.
*/
function lubus_custom_allow_drafts_in_rest_query( $args, $request ) {
@raftaar1191
raftaar1191 / functions.php
Created May 30, 2024 07:51
Generate the post slug for the draft testimonial (CPT) as well
/**
* Generate the post slug for the draft post as well
*
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
* @param bool $update Whether this is an existing post being updated.
**/
function lubus_generate_slug_for_draft_post( $post_id, $post, $update ) {
// If the post is a draft and has no slug.
@raftaar1191
raftaar1191 / functions.php
Created April 19, 2024 15:04
Only show the admin user list when deleting a user and assing his content
function delete_user_account( $query_args ) {
// Use this array to specify multiple roles to show in dropdown
$query_args['role__in'] = array( 'administrator' );
// Unset the 'who' as this defaults to the 'author' role
unset( $query_args['who'] );
return $query_args;
}
@raftaar1191
raftaar1191 / pretty-link-creation.php
Created April 1, 2024 05:50 — forked from DumahX/pretty-link-creation.php
Creating new pretty links through code
@raftaar1191
raftaar1191 / functions.php
Created October 18, 2023 07:02
How can I limit the activity feed to show 10 posts, then the load more appears?
function limit_activities_displayed( $retval ) {
$isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile"));
if ($isMob) {
$retval['per_page'] = 15;
}
else {
$retval['per_page'] = 5;
}
return $retval;
}
@raftaar1191
raftaar1191 / functions.php
Created October 12, 2023 08:28
Fix for Not able to comment on Other User Activity Post in PHP version 8.2
remove_action( 'bp_activity_after_email_content', 'bb_gif_activity_after_email_content' );
@raftaar1191
raftaar1191 / functions.php
Created October 11, 2023 08:53
Change/Update place holder of the login input of BuddyBoss login page
/**
* Update the place holder into the login page
*/
function acrosswp_custom_bb_login_head_callback() {
?>
<script>
jQuery( document ).ready( function ($) {
jQuery( 'form#loginform #user_login' ).attr( 'placeholder', "Custom Email" );
});